Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.45 KB

no-unused-rules.md

File metadata and controls

53 lines (40 loc) · 1.45 KB

@peggyjs/no-unused-rules

All rules except for the first one must be referenced by another rule.

  • ⭐️ This rule is included in plugin:@peggyjs/recommended preset.

📖 Rule Details

The first grammar rule, by default, is the entry point for parsing. All other rules should be referenced in at least one other rule. Unreferenced rules might be caused by typos, or they may be left over from previous versions.

👎 Examples of incorrect code for this rule:

// eslint @peggyjs/no-unused-rules
import baz from "./baz.js" // Bad.  Not referenced.
foo = "1" // Good.  Default entry point.
bar = "2" // Bad.  Not referenced.
// eslint @peggyjs/no-unused-rules: ["error", {filter: "^_"}]
foo = "foo" // Good.
bar = "bar" // Doesn't match the filter
_boo = "boo" // Bad.  Not referenced, and matches the filter.

👍 Examples of correct code for this rule:

// eslint @peggyjs/no-unused-rules
import baz from "./baz.js"
foo = bar / baz
bar = "2"
// eslint @peggyjs/no-unused-rules: ["error", {filter: "^_"}]
foo = _boo
bar = "bar" // Doesn't match the filter
_boo = "boo"

Options

The first option can be an object with the key "filter". The filter is treated as a regular expression; only rules that match this expression will cause errors if they are unused.

🔎 Implementation