npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@peggyjs/eslint-plugin

v2.1.2

Published

An [eslint](https://eslint.org/) plugin to check [peggy](https://peggyjs.org) grammars.

Downloads

391

Readme

@peggyjs/eslint-plugin

An eslint plugin to check peggy grammars.

Usage

Install with:

npm install --save-dev @peggyjs/eslint-plugin @peggyjs/eslint-parser eslint

Add to your .eslintrc.js file:

module.exports = {
  extends: ["plugin:@peggyjs/recommended"],
};

You can also use "plugin:@peggyjs/all" or to get ALL of the rules. If you'd like more control:

module.exports = {
  plugins: ["@peggyjs"],
  overrides: [
    {
      files: ["*.peggy", "*.pegjs"],
      parser: "@peggyjs/eslint-parser",
      settings: {
        "@peggyjs/indent": 2,
        "@peggyjs/newline": "\n",
      }
      rules: {
        "@peggyjs/equal-next-line": "error",
        ...
      },
    },
    {
      files: ["**/*.peggy/*.js", "**/*.pegjs/*.js"],
      rules: {
        // Even if you normally want BOMs (which you shouldn't.  Always use
        // UTF-8.), you're not getting one this time.
        "unicode-bom": "off",
      },
    },
  ],
};

Or, if you are using ESLint Flat configs, add this to your eslint.config.js file:

// ESM
import peggylint from "@peggyjs/eslint-plugin/lib/flat/recommended.js"
export default [
  peggyLint,
];

Or:

// CommonJS
module.exports = [
  ...require("@peggyjs/eslint-plugin/lib/flat/recommended.js"),
];

VSCode

If you are using VSCode, you might be interested in these for your .vscode/settings.json file:

{
  "eslint.validate": [
    "javascript",
    "peggy",
    "typescript"
  ],
  "eslint.experimental.useFlatConfig": true
}

Rules

  • ✒️ - Fixable rules.
  • ⭐️ - Recommended rules.

| Rule ID | Description | | |:--------|:------------|:--:| | @peggyjs/camelCase | Rule names should be UpperCamelCase and label names should be lowerCamelCase. | ✒️ ⭐️ | | @peggyjs/equal-next-line | Ensure that the equals sign in a rule is in a consistent location. | ✒️ ⭐️ | | @peggyjs/no-empty-code-blocks | Code blocks in actions and semantic predicates should not be empty. | ✒️ ⭐️ | | @peggyjs/no-empty-initializers | Top-level and per-instance initializers should not be empty. | ✒️ ⭐️ | | @peggyjs/no-unused-labels | Labels may not be used without either an action or a semantic predicate to reference them. | ✒️ ⭐️ | | @peggyjs/no-unused-rules | All rules except for the first one must be referenced by another rule. | ⭐️ | | @peggyjs/quotes | Enforce the consistent use of double or single quotes. | ✒️ ⭐️ | | @peggyjs/rule-order | Rule definitions should come after all references to that rule, unless there is a rule loop. | | | @peggyjs/semantic-predicate-must-return | Semantic predicates must have a return statement. | ⭐️ | | @peggyjs/semi | Enforce consistent semicolon usage. | ✒️ ⭐️ | | @peggyjs/separate-choices | Ensure that each top-level choice in a rule is on a new line. | ✒️ ⭐️ | | @peggyjs/space-ops | Consistent spacing around operators and other punctuation. | ✒️ ⭐️ | | @peggyjs/valid-imports | All imports must point to correct JS files, compiled by Peggy 4.0.0 or later, which export the expected rule name as an allowedStartRule. | ⭐️ |

Settings

There are several plugin-wide settings that control whitespace insertion.

Other Features

  • Checks the Javascript code embedded in your grammar according to your existing ESlint rules for JS.

Using with Visual Studio Code

Add the following to your project's .vscode/settings.json file:

{
  "eslint.validate": [
    "javascript",
    "peggy"
  ]
}

Tests codecov