eslint 8.3.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -16
- package/conf/globals.js +144 -0
- package/lib/cli.js +1 -1
- package/lib/config/default-config.js +11 -2
- package/lib/config/flat-config-array.js +2 -2
- package/lib/config/flat-config-helpers.js +67 -0
- package/lib/config/flat-config-schema.js +13 -8
- package/lib/config/rule-validator.js +28 -27
- package/lib/eslint/eslint.js +11 -3
- package/lib/linter/apply-disable-directives.js +20 -16
- package/lib/linter/linter.js +463 -49
- package/lib/options.js +6 -6
- package/lib/rule-tester/rule-tester.js +14 -0
- package/lib/rules/accessor-pairs.js +1 -0
- package/lib/rules/array-bracket-newline.js +1 -0
- package/lib/rules/array-bracket-spacing.js +1 -0
- package/lib/rules/array-callback-return.js +1 -0
- package/lib/rules/array-element-newline.js +1 -0
- package/lib/rules/arrow-body-style.js +1 -0
- package/lib/rules/arrow-parens.js +1 -0
- package/lib/rules/arrow-spacing.js +1 -0
- package/lib/rules/block-scoped-var.js +1 -0
- package/lib/rules/block-spacing.js +1 -0
- package/lib/rules/brace-style.js +1 -0
- package/lib/rules/callback-return.js +1 -0
- package/lib/rules/camelcase.js +1 -0
- package/lib/rules/capitalized-comments.js +1 -0
- package/lib/rules/class-methods-use-this.js +1 -0
- package/lib/rules/comma-dangle.js +1 -0
- package/lib/rules/comma-spacing.js +1 -0
- package/lib/rules/comma-style.js +1 -0
- package/lib/rules/complexity.js +1 -0
- package/lib/rules/computed-property-spacing.js +1 -0
- package/lib/rules/consistent-return.js +1 -0
- package/lib/rules/consistent-this.js +1 -0
- package/lib/rules/constructor-super.js +1 -0
- package/lib/rules/curly.js +1 -0
- package/lib/rules/default-case-last.js +1 -0
- package/lib/rules/default-case.js +1 -0
- package/lib/rules/default-param-last.js +1 -0
- package/lib/rules/dot-location.js +1 -0
- package/lib/rules/dot-notation.js +1 -0
- package/lib/rules/eol-last.js +1 -0
- package/lib/rules/eqeqeq.js +1 -0
- package/lib/rules/for-direction.js +1 -0
- package/lib/rules/func-call-spacing.js +1 -0
- package/lib/rules/func-name-matching.js +1 -0
- package/lib/rules/func-names.js +1 -0
- package/lib/rules/func-style.js +1 -0
- package/lib/rules/function-call-argument-newline.js +1 -0
- package/lib/rules/function-paren-newline.js +1 -0
- package/lib/rules/generator-star-spacing.js +1 -0
- package/lib/rules/getter-return.js +1 -0
- package/lib/rules/global-require.js +1 -0
- package/lib/rules/grouped-accessor-pairs.js +1 -0
- package/lib/rules/guard-for-in.js +1 -0
- package/lib/rules/handle-callback-err.js +1 -0
- package/lib/rules/id-blacklist.js +1 -0
- package/lib/rules/id-denylist.js +1 -0
- package/lib/rules/id-length.js +1 -0
- package/lib/rules/id-match.js +35 -0
- package/lib/rules/implicit-arrow-linebreak.js +1 -0
- package/lib/rules/indent-legacy.js +1 -0
- package/lib/rules/indent.js +1 -0
- package/lib/rules/index.js +1 -0
- package/lib/rules/init-declarations.js +1 -0
- package/lib/rules/jsx-quotes.js +1 -0
- package/lib/rules/key-spacing.js +1 -0
- package/lib/rules/keyword-spacing.js +1 -0
- package/lib/rules/line-comment-position.js +1 -0
- package/lib/rules/linebreak-style.js +1 -0
- package/lib/rules/lines-around-comment.js +1 -0
- package/lib/rules/lines-around-directive.js +1 -0
- package/lib/rules/lines-between-class-members.js +1 -0
- package/lib/rules/max-classes-per-file.js +1 -0
- package/lib/rules/max-depth.js +1 -0
- package/lib/rules/max-len.js +1 -0
- package/lib/rules/max-lines-per-function.js +1 -0
- package/lib/rules/max-lines.js +1 -0
- package/lib/rules/max-nested-callbacks.js +1 -0
- package/lib/rules/max-params.js +1 -0
- package/lib/rules/max-statements-per-line.js +1 -0
- package/lib/rules/max-statements.js +1 -0
- package/lib/rules/multiline-comment-style.js +1 -0
- package/lib/rules/multiline-ternary.js +1 -0
- package/lib/rules/new-cap.js +1 -0
- package/lib/rules/new-parens.js +1 -0
- package/lib/rules/newline-after-var.js +1 -0
- package/lib/rules/newline-before-return.js +1 -0
- package/lib/rules/newline-per-chained-call.js +1 -0
- package/lib/rules/no-alert.js +1 -0
- package/lib/rules/no-array-constructor.js +1 -0
- package/lib/rules/no-async-promise-executor.js +1 -0
- package/lib/rules/no-await-in-loop.js +1 -0
- package/lib/rules/no-bitwise.js +1 -0
- package/lib/rules/no-buffer-constructor.js +1 -0
- package/lib/rules/no-caller.js +1 -0
- package/lib/rules/no-case-declarations.js +1 -0
- package/lib/rules/no-catch-shadow.js +1 -0
- package/lib/rules/no-class-assign.js +1 -0
- package/lib/rules/no-compare-neg-zero.js +1 -0
- package/lib/rules/no-cond-assign.js +1 -0
- package/lib/rules/no-confusing-arrow.js +1 -0
- package/lib/rules/no-console.js +1 -0
- package/lib/rules/no-const-assign.js +1 -0
- package/lib/rules/no-constant-condition.js +4 -1
- package/lib/rules/no-constructor-return.js +1 -0
- package/lib/rules/no-continue.js +1 -0
- package/lib/rules/no-control-regex.js +1 -0
- package/lib/rules/no-debugger.js +1 -0
- package/lib/rules/no-delete-var.js +1 -0
- package/lib/rules/no-div-regex.js +1 -0
- package/lib/rules/no-dupe-args.js +1 -0
- package/lib/rules/no-dupe-class-members.js +1 -0
- package/lib/rules/no-dupe-else-if.js +1 -0
- package/lib/rules/no-dupe-keys.js +1 -0
- package/lib/rules/no-duplicate-case.js +1 -0
- package/lib/rules/no-duplicate-imports.js +1 -0
- package/lib/rules/no-else-return.js +1 -0
- package/lib/rules/no-empty-character-class.js +1 -0
- package/lib/rules/no-empty-function.js +1 -0
- package/lib/rules/no-empty-pattern.js +1 -0
- package/lib/rules/no-empty.js +1 -0
- package/lib/rules/no-eq-null.js +1 -0
- package/lib/rules/no-eval.js +1 -0
- package/lib/rules/no-ex-assign.js +1 -0
- package/lib/rules/no-extend-native.js +1 -0
- package/lib/rules/no-extra-bind.js +1 -0
- package/lib/rules/no-extra-boolean-cast.js +1 -0
- package/lib/rules/no-extra-label.js +1 -0
- package/lib/rules/no-extra-parens.js +1 -0
- package/lib/rules/no-extra-semi.js +1 -0
- package/lib/rules/no-fallthrough.js +1 -0
- package/lib/rules/no-floating-decimal.js +1 -0
- package/lib/rules/no-func-assign.js +1 -0
- package/lib/rules/no-global-assign.js +1 -0
- package/lib/rules/no-implicit-coercion.js +1 -0
- package/lib/rules/no-implicit-globals.js +1 -0
- package/lib/rules/no-implied-eval.js +1 -0
- package/lib/rules/no-import-assign.js +1 -0
- package/lib/rules/no-inline-comments.js +1 -0
- package/lib/rules/no-inner-declarations.js +1 -0
- package/lib/rules/no-invalid-regexp.js +1 -0
- package/lib/rules/no-invalid-this.js +1 -0
- package/lib/rules/no-irregular-whitespace.js +1 -0
- package/lib/rules/no-iterator.js +1 -0
- package/lib/rules/no-label-var.js +1 -0
- package/lib/rules/no-labels.js +1 -0
- package/lib/rules/no-lone-blocks.js +1 -0
- package/lib/rules/no-lonely-if.js +1 -0
- package/lib/rules/no-loop-func.js +1 -0
- package/lib/rules/no-loss-of-precision.js +1 -0
- package/lib/rules/no-magic-numbers.js +1 -0
- package/lib/rules/no-misleading-character-class.js +1 -0
- package/lib/rules/no-mixed-operators.js +1 -0
- package/lib/rules/no-mixed-requires.js +1 -0
- package/lib/rules/no-mixed-spaces-and-tabs.js +1 -0
- package/lib/rules/no-multi-assign.js +1 -0
- package/lib/rules/no-multi-spaces.js +1 -0
- package/lib/rules/no-multi-str.js +1 -0
- package/lib/rules/no-multiple-empty-lines.js +1 -0
- package/lib/rules/no-native-reassign.js +1 -0
- package/lib/rules/no-negated-condition.js +1 -0
- package/lib/rules/no-negated-in-lhs.js +1 -0
- package/lib/rules/no-nested-ternary.js +1 -0
- package/lib/rules/no-new-func.js +1 -0
- package/lib/rules/no-new-object.js +1 -0
- package/lib/rules/no-new-require.js +1 -0
- package/lib/rules/no-new-symbol.js +1 -0
- package/lib/rules/no-new-wrappers.js +1 -0
- package/lib/rules/no-new.js +1 -0
- package/lib/rules/no-nonoctal-decimal-escape.js +1 -0
- package/lib/rules/no-obj-calls.js +1 -0
- package/lib/rules/no-octal-escape.js +1 -0
- package/lib/rules/no-octal.js +1 -0
- package/lib/rules/no-param-reassign.js +1 -0
- package/lib/rules/no-path-concat.js +1 -0
- package/lib/rules/no-plusplus.js +1 -0
- package/lib/rules/no-process-env.js +1 -0
- package/lib/rules/no-process-exit.js +1 -0
- package/lib/rules/no-promise-executor-return.js +1 -0
- package/lib/rules/no-proto.js +1 -0
- package/lib/rules/no-prototype-builtins.js +1 -0
- package/lib/rules/no-redeclare.js +1 -0
- package/lib/rules/no-regex-spaces.js +1 -0
- package/lib/rules/no-restricted-exports.js +1 -0
- package/lib/rules/no-restricted-globals.js +1 -0
- package/lib/rules/no-restricted-imports.js +1 -0
- package/lib/rules/no-restricted-modules.js +1 -0
- package/lib/rules/no-restricted-properties.js +1 -0
- package/lib/rules/no-restricted-syntax.js +1 -0
- package/lib/rules/no-return-assign.js +1 -0
- package/lib/rules/no-return-await.js +1 -0
- package/lib/rules/no-script-url.js +1 -0
- package/lib/rules/no-self-assign.js +2 -1
- package/lib/rules/no-self-compare.js +1 -0
- package/lib/rules/no-sequences.js +1 -0
- package/lib/rules/no-setter-return.js +1 -0
- package/lib/rules/no-shadow-restricted-names.js +1 -0
- package/lib/rules/no-shadow.js +1 -0
- package/lib/rules/no-spaced-func.js +1 -0
- package/lib/rules/no-sparse-arrays.js +1 -0
- package/lib/rules/no-sync.js +1 -0
- package/lib/rules/no-tabs.js +1 -0
- package/lib/rules/no-template-curly-in-string.js +1 -0
- package/lib/rules/no-ternary.js +1 -0
- package/lib/rules/no-this-before-super.js +1 -0
- package/lib/rules/no-throw-literal.js +1 -0
- package/lib/rules/no-trailing-spaces.js +1 -0
- package/lib/rules/no-undef-init.js +1 -0
- package/lib/rules/no-undef.js +1 -0
- package/lib/rules/no-undefined.js +1 -0
- package/lib/rules/no-underscore-dangle.js +1 -0
- package/lib/rules/no-unexpected-multiline.js +1 -0
- package/lib/rules/no-unmodified-loop-condition.js +1 -0
- package/lib/rules/no-unneeded-ternary.js +1 -0
- package/lib/rules/no-unreachable-loop.js +1 -0
- package/lib/rules/no-unreachable.js +1 -0
- package/lib/rules/no-unsafe-finally.js +1 -0
- package/lib/rules/no-unsafe-negation.js +1 -0
- package/lib/rules/no-unsafe-optional-chaining.js +1 -0
- package/lib/rules/no-unused-expressions.js +1 -0
- package/lib/rules/no-unused-labels.js +1 -0
- package/lib/rules/no-unused-private-class-members.js +1 -0
- package/lib/rules/no-unused-vars.js +1 -0
- package/lib/rules/no-use-before-define.js +1 -0
- package/lib/rules/no-useless-backreference.js +1 -0
- package/lib/rules/no-useless-call.js +1 -0
- package/lib/rules/no-useless-catch.js +1 -0
- package/lib/rules/no-useless-computed-key.js +1 -0
- package/lib/rules/no-useless-concat.js +1 -0
- package/lib/rules/no-useless-constructor.js +1 -0
- package/lib/rules/no-useless-escape.js +1 -0
- package/lib/rules/no-useless-rename.js +1 -0
- package/lib/rules/no-useless-return.js +1 -0
- package/lib/rules/no-var.js +1 -0
- package/lib/rules/no-void.js +1 -0
- package/lib/rules/no-warning-comments.js +1 -0
- package/lib/rules/no-whitespace-before-property.js +1 -0
- package/lib/rules/no-with.js +1 -0
- package/lib/rules/nonblock-statement-body-position.js +1 -0
- package/lib/rules/object-curly-newline.js +1 -0
- package/lib/rules/object-curly-spacing.js +1 -0
- package/lib/rules/object-property-newline.js +1 -0
- package/lib/rules/object-shorthand.js +1 -0
- package/lib/rules/one-var-declaration-per-line.js +1 -0
- package/lib/rules/one-var.js +1 -0
- package/lib/rules/operator-assignment.js +1 -0
- package/lib/rules/operator-linebreak.js +1 -0
- package/lib/rules/padded-blocks.js +1 -0
- package/lib/rules/padding-line-between-statements.js +1 -0
- package/lib/rules/prefer-arrow-callback.js +1 -0
- package/lib/rules/prefer-const.js +1 -0
- package/lib/rules/prefer-destructuring.js +1 -0
- package/lib/rules/prefer-exponentiation-operator.js +1 -0
- package/lib/rules/prefer-named-capture-group.js +1 -0
- package/lib/rules/prefer-numeric-literals.js +1 -0
- package/lib/rules/prefer-object-has-own.js +112 -0
- package/lib/rules/prefer-object-spread.js +1 -0
- package/lib/rules/prefer-promise-reject-errors.js +1 -0
- package/lib/rules/prefer-reflect.js +1 -0
- package/lib/rules/prefer-regex-literals.js +218 -1
- package/lib/rules/prefer-rest-params.js +1 -0
- package/lib/rules/prefer-spread.js +1 -0
- package/lib/rules/prefer-template.js +2 -1
- package/lib/rules/quote-props.js +1 -0
- package/lib/rules/quotes.js +1 -0
- package/lib/rules/radix.js +1 -0
- package/lib/rules/require-atomic-updates.js +1 -0
- package/lib/rules/require-await.js +1 -0
- package/lib/rules/require-jsdoc.js +1 -0
- package/lib/rules/require-unicode-regexp.js +1 -0
- package/lib/rules/require-yield.js +1 -0
- package/lib/rules/rest-spread-spacing.js +1 -0
- package/lib/rules/semi-spacing.js +1 -0
- package/lib/rules/semi-style.js +1 -0
- package/lib/rules/semi.js +1 -0
- package/lib/rules/sort-imports.js +1 -0
- package/lib/rules/sort-keys.js +1 -0
- package/lib/rules/sort-vars.js +1 -0
- package/lib/rules/space-before-blocks.js +1 -0
- package/lib/rules/space-before-function-paren.js +1 -0
- package/lib/rules/space-in-parens.js +1 -0
- package/lib/rules/space-infix-ops.js +1 -0
- package/lib/rules/space-unary-ops.js +1 -0
- package/lib/rules/spaced-comment.js +1 -0
- package/lib/rules/strict.js +1 -0
- package/lib/rules/switch-colon-spacing.js +1 -0
- package/lib/rules/symbol-description.js +1 -0
- package/lib/rules/template-curly-spacing.js +1 -0
- package/lib/rules/template-tag-spacing.js +1 -0
- package/lib/rules/unicode-bom.js +1 -0
- package/lib/rules/use-isnan.js +1 -0
- package/lib/rules/valid-jsdoc.js +1 -0
- package/lib/rules/valid-typeof.js +1 -0
- package/lib/rules/vars-on-top.js +1 -0
- package/lib/rules/wrap-iife.js +1 -0
- package/lib/rules/wrap-regex.js +1 -0
- package/lib/rules/yield-star-spacing.js +1 -0
- package/lib/rules/yoda.js +1 -0
- package/lib/shared/types.js +10 -0
- package/package.json +7 -6
package/README.md
CHANGED
@@ -47,19 +47,19 @@ Prerequisites: [Node.js](https://nodejs.org/) (`^12.22.0`, `^14.17.0`, or `>=16.
|
|
47
47
|
|
48
48
|
You can install ESLint using npm:
|
49
49
|
|
50
|
-
```
|
50
|
+
```sh
|
51
51
|
$ npm install eslint --save-dev
|
52
52
|
```
|
53
53
|
|
54
54
|
You should then set up a configuration file:
|
55
55
|
|
56
|
-
```
|
56
|
+
```sh
|
57
57
|
$ ./node_modules/.bin/eslint --init
|
58
58
|
```
|
59
59
|
|
60
60
|
After that, you can run ESLint on any file or directory like this:
|
61
61
|
|
62
|
-
```
|
62
|
+
```sh
|
63
63
|
$ ./node_modules/.bin/eslint yourfile.js
|
64
64
|
```
|
65
65
|
|
@@ -207,8 +207,6 @@ These folks keep the project moving and are resources for help.
|
|
207
207
|
|
208
208
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
209
209
|
|
210
|
-
|
211
|
-
|
212
210
|
<!--teamstart-->
|
213
211
|
|
214
212
|
### Technical Steering Committee (TSC)
|
@@ -232,7 +230,6 @@ Milos Djermanovic
|
|
232
230
|
</a>
|
233
231
|
</td></tr></tbody></table>
|
234
232
|
|
235
|
-
|
236
233
|
### Reviewers
|
237
234
|
|
238
235
|
The people who review and implement new features.
|
@@ -249,9 +246,6 @@ Toru Nagashima
|
|
249
246
|
</a>
|
250
247
|
</td></tr></tbody></table>
|
251
248
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
249
|
### Committers
|
256
250
|
|
257
251
|
The people who review and fix bugs and help triage issues.
|
@@ -288,12 +282,8 @@ Nitin Kumar
|
|
288
282
|
</a>
|
289
283
|
</td></tr></tbody></table>
|
290
284
|
|
291
|
-
|
292
285
|
<!--teamend-->
|
293
286
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
287
|
## <a name="sponsors"></a>Sponsors
|
298
288
|
|
299
289
|
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://opencollective.com/eslint) to get your logo on our README and website.
|
@@ -301,10 +291,10 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
301
291
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
302
292
|
<!--sponsorsstart-->
|
303
293
|
<h3>Platinum Sponsors</h3>
|
304
|
-
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/
|
305
|
-
<p><a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://coinbase.com"><img src="https://avatars.githubusercontent.com/u/1885080?v=4" alt="Coinbase" height="96"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="96"></a> <a href="https://substack.com/"><img src="https://avatars.githubusercontent.com/u/53023767?v=4" alt="Substack" height="96"></a></p><h3>Silver Sponsors</h3>
|
294
|
+
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
|
295
|
+
<p><a href="https://contra.com"><img src="https://images.opencollective.com/contra1/c70f93f/logo.png" alt="Contra" height="96"></a> <a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://coinbase.com"><img src="https://avatars.githubusercontent.com/u/1885080?v=4" alt="Coinbase" height="96"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="96"></a> <a href="https://substack.com/"><img src="https://avatars.githubusercontent.com/u/53023767?v=4" alt="Substack" height="96"></a></p><h3>Silver Sponsors</h3>
|
306
296
|
<p><a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a></p><h3>Bronze Sponsors</h3>
|
307
|
-
<p><a href="https://launchdarkly.com"><img src="https://images.opencollective.com/launchdarkly/574bb9e/logo.png" alt="launchdarkly" height="32"></a> <a href="https://
|
297
|
+
<p><a href="https://launchdarkly.com"><img src="https://images.opencollective.com/launchdarkly/574bb9e/logo.png" alt="launchdarkly" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a> <a href="https://www.practiceignition.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Practice Ignition" height="32"></a></p>
|
308
298
|
<!--sponsorsend-->
|
309
299
|
|
310
300
|
## <a name="technology-sponsors"></a>Technology Sponsors
|
package/conf/globals.js
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Globals for ecmaVersion/sourceType
|
3
|
+
* @author Nicholas C. Zakas
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
//-----------------------------------------------------------------------------
|
9
|
+
// Globals
|
10
|
+
//-----------------------------------------------------------------------------
|
11
|
+
|
12
|
+
const commonjs = {
|
13
|
+
exports: true,
|
14
|
+
global: false,
|
15
|
+
module: false,
|
16
|
+
require: false
|
17
|
+
};
|
18
|
+
|
19
|
+
const es3 = {
|
20
|
+
Array: false,
|
21
|
+
Boolean: false,
|
22
|
+
constructor: false,
|
23
|
+
Date: false,
|
24
|
+
decodeURI: false,
|
25
|
+
decodeURIComponent: false,
|
26
|
+
encodeURI: false,
|
27
|
+
encodeURIComponent: false,
|
28
|
+
Error: false,
|
29
|
+
escape: false,
|
30
|
+
eval: false,
|
31
|
+
EvalError: false,
|
32
|
+
Function: false,
|
33
|
+
hasOwnProperty: false,
|
34
|
+
Infinity: false,
|
35
|
+
isFinite: false,
|
36
|
+
isNaN: false,
|
37
|
+
isPrototypeOf: false,
|
38
|
+
Math: false,
|
39
|
+
NaN: false,
|
40
|
+
Number: false,
|
41
|
+
Object: false,
|
42
|
+
parseFloat: false,
|
43
|
+
parseInt: false,
|
44
|
+
propertyIsEnumerable: false,
|
45
|
+
RangeError: false,
|
46
|
+
ReferenceError: false,
|
47
|
+
RegExp: false,
|
48
|
+
String: false,
|
49
|
+
SyntaxError: false,
|
50
|
+
toLocaleString: false,
|
51
|
+
toString: false,
|
52
|
+
TypeError: false,
|
53
|
+
undefined: false,
|
54
|
+
unescape: false,
|
55
|
+
URIError: false,
|
56
|
+
valueOf: false
|
57
|
+
};
|
58
|
+
|
59
|
+
const es5 = {
|
60
|
+
...es3,
|
61
|
+
JSON: false
|
62
|
+
};
|
63
|
+
|
64
|
+
const es2015 = {
|
65
|
+
...es5,
|
66
|
+
ArrayBuffer: false,
|
67
|
+
DataView: false,
|
68
|
+
Float32Array: false,
|
69
|
+
Float64Array: false,
|
70
|
+
Int16Array: false,
|
71
|
+
Int32Array: false,
|
72
|
+
Int8Array: false,
|
73
|
+
Map: false,
|
74
|
+
Promise: false,
|
75
|
+
Proxy: false,
|
76
|
+
Reflect: false,
|
77
|
+
Set: false,
|
78
|
+
Symbol: false,
|
79
|
+
Uint16Array: false,
|
80
|
+
Uint32Array: false,
|
81
|
+
Uint8Array: false,
|
82
|
+
Uint8ClampedArray: false,
|
83
|
+
WeakMap: false,
|
84
|
+
WeakSet: false
|
85
|
+
};
|
86
|
+
|
87
|
+
// no new globals in ES2016
|
88
|
+
const es2016 = {
|
89
|
+
...es2015
|
90
|
+
};
|
91
|
+
|
92
|
+
const es2017 = {
|
93
|
+
...es2016,
|
94
|
+
Atomics: false,
|
95
|
+
SharedArrayBuffer: false
|
96
|
+
};
|
97
|
+
|
98
|
+
// no new globals in ES2018
|
99
|
+
const es2018 = {
|
100
|
+
...es2017
|
101
|
+
};
|
102
|
+
|
103
|
+
// no new globals in ES2019
|
104
|
+
const es2019 = {
|
105
|
+
...es2018
|
106
|
+
};
|
107
|
+
|
108
|
+
const es2020 = {
|
109
|
+
...es2019,
|
110
|
+
BigInt: false,
|
111
|
+
BigInt64Array: false,
|
112
|
+
BigUint64Array: false,
|
113
|
+
globalThis: false
|
114
|
+
};
|
115
|
+
|
116
|
+
const es2021 = {
|
117
|
+
...es2020,
|
118
|
+
AggregateError: false,
|
119
|
+
FinalizationRegistry: false,
|
120
|
+
WeakRef: false
|
121
|
+
};
|
122
|
+
|
123
|
+
const es2022 = {
|
124
|
+
...es2021
|
125
|
+
};
|
126
|
+
|
127
|
+
|
128
|
+
//-----------------------------------------------------------------------------
|
129
|
+
// Exports
|
130
|
+
//-----------------------------------------------------------------------------
|
131
|
+
|
132
|
+
module.exports = {
|
133
|
+
commonjs,
|
134
|
+
es3,
|
135
|
+
es5,
|
136
|
+
es2015,
|
137
|
+
es2016,
|
138
|
+
es2017,
|
139
|
+
es2018,
|
140
|
+
es2019,
|
141
|
+
es2020,
|
142
|
+
es2021,
|
143
|
+
es2022
|
144
|
+
};
|
package/lib/cli.js
CHANGED
@@ -26,7 +26,7 @@ exports.defaultConfig = [
|
|
26
26
|
|
27
27
|
/*
|
28
28
|
* Because we try to delay loading rules until absolutely
|
29
|
-
* necessary, a proxy
|
29
|
+
* necessary, a proxy allows us to hook into the lazy-loading
|
30
30
|
* aspect of the rules map while still keeping all of the
|
31
31
|
* relevant configuration inside of the config array.
|
32
32
|
*/
|
@@ -46,7 +46,16 @@ exports.defaultConfig = [
|
|
46
46
|
".git/**"
|
47
47
|
],
|
48
48
|
languageOptions: {
|
49
|
-
|
49
|
+
ecmaVersion: "latest",
|
50
|
+
sourceType: "module",
|
51
|
+
parser: "@/espree",
|
52
|
+
parserOptions: {}
|
53
|
+
}
|
54
|
+
},
|
55
|
+
{
|
56
|
+
files: ["**/*.cjs"],
|
57
|
+
languageOptions: {
|
58
|
+
sourceType: "commonjs"
|
50
59
|
}
|
51
60
|
}
|
52
61
|
];
|
@@ -52,13 +52,13 @@ class FlatConfigArray extends ConfigArray {
|
|
52
52
|
* @param {{basePath: string, baseConfig: FlatConfig}} options The options
|
53
53
|
* to use for the config array instance.
|
54
54
|
*/
|
55
|
-
constructor(configs, { basePath, baseConfig = defaultConfig }) {
|
55
|
+
constructor(configs, { basePath, baseConfig = defaultConfig } = {}) {
|
56
56
|
super(configs, {
|
57
57
|
basePath,
|
58
58
|
schema: flatConfigSchema
|
59
59
|
});
|
60
60
|
|
61
|
-
this.unshift(baseConfig);
|
61
|
+
this.unshift(...baseConfig);
|
62
62
|
}
|
63
63
|
|
64
64
|
/* eslint-disable class-methods-use-this -- Desired as instance method */
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Shared functions to work with configs.
|
3
|
+
* @author Nicholas C. Zakas
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
//-----------------------------------------------------------------------------
|
9
|
+
// Functions
|
10
|
+
//-----------------------------------------------------------------------------
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Parses a ruleId into its plugin and rule parts.
|
14
|
+
* @param {string} ruleId The rule ID to parse.
|
15
|
+
* @returns {{pluginName:string,ruleName:string}} The plugin and rule
|
16
|
+
* parts of the ruleId;
|
17
|
+
*/
|
18
|
+
function parseRuleId(ruleId) {
|
19
|
+
let pluginName, ruleName;
|
20
|
+
|
21
|
+
// distinguish between core rules and plugin rules
|
22
|
+
if (ruleId.includes("/")) {
|
23
|
+
pluginName = ruleId.slice(0, ruleId.lastIndexOf("/"));
|
24
|
+
ruleName = ruleId.slice(pluginName.length + 1);
|
25
|
+
} else {
|
26
|
+
pluginName = "@";
|
27
|
+
ruleName = ruleId;
|
28
|
+
}
|
29
|
+
|
30
|
+
return {
|
31
|
+
pluginName,
|
32
|
+
ruleName
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Retrieves a rule instance from a given config based on the ruleId.
|
38
|
+
* @param {string} ruleId The rule ID to look for.
|
39
|
+
* @param {FlatConfig} config The config to search.
|
40
|
+
* @returns {import("../shared/types").Rule|undefined} The rule if found
|
41
|
+
* or undefined if not.
|
42
|
+
*/
|
43
|
+
function getRuleFromConfig(ruleId, config) {
|
44
|
+
|
45
|
+
const { pluginName, ruleName } = parseRuleId(ruleId);
|
46
|
+
|
47
|
+
const plugin = config.plugins && config.plugins[pluginName];
|
48
|
+
let rule = plugin && plugin.rules && plugin.rules[ruleName];
|
49
|
+
|
50
|
+
// normalize function rules into objects
|
51
|
+
if (rule && typeof rule === "function") {
|
52
|
+
rule = {
|
53
|
+
create: rule
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
return rule;
|
58
|
+
}
|
59
|
+
|
60
|
+
//-----------------------------------------------------------------------------
|
61
|
+
// Exports
|
62
|
+
//-----------------------------------------------------------------------------
|
63
|
+
|
64
|
+
module.exports = {
|
65
|
+
parseRuleId,
|
66
|
+
getRuleFromConfig
|
67
|
+
};
|
@@ -195,13 +195,6 @@ function assertIsObjectOrString(value) {
|
|
195
195
|
// Low-Level Schemas
|
196
196
|
//-----------------------------------------------------------------------------
|
197
197
|
|
198
|
-
|
199
|
-
/** @type {ObjectPropertySchema} */
|
200
|
-
const numberSchema = {
|
201
|
-
merge: "replace",
|
202
|
-
validate: "number"
|
203
|
-
};
|
204
|
-
|
205
198
|
/** @type {ObjectPropertySchema} */
|
206
199
|
const booleanSchema = {
|
207
200
|
merge: "replace",
|
@@ -415,6 +408,18 @@ const rulesSchema = {
|
|
415
408
|
}
|
416
409
|
};
|
417
410
|
|
411
|
+
/** @type {ObjectPropertySchema} */
|
412
|
+
const ecmaVersionSchema = {
|
413
|
+
merge: "replace",
|
414
|
+
validate(value) {
|
415
|
+
if (typeof value === "number" || value === "latest") {
|
416
|
+
return;
|
417
|
+
}
|
418
|
+
|
419
|
+
throw new TypeError("Expected a number or \"latest\".");
|
420
|
+
}
|
421
|
+
};
|
422
|
+
|
418
423
|
/** @type {ObjectPropertySchema} */
|
419
424
|
const sourceTypeSchema = {
|
420
425
|
merge: "replace",
|
@@ -439,7 +444,7 @@ exports.flatConfigSchema = {
|
|
439
444
|
},
|
440
445
|
languageOptions: {
|
441
446
|
schema: {
|
442
|
-
ecmaVersion:
|
447
|
+
ecmaVersion: ecmaVersionSchema,
|
443
448
|
sourceType: sourceTypeSchema,
|
444
449
|
globals: globalsSchema,
|
445
450
|
parser: parserSchema,
|
@@ -10,52 +10,49 @@
|
|
10
10
|
//-----------------------------------------------------------------------------
|
11
11
|
|
12
12
|
const ajv = require("../shared/ajv")();
|
13
|
+
const { parseRuleId, getRuleFromConfig } = require("./flat-config-helpers");
|
14
|
+
const ruleReplacements = require("../../conf/replacements.json");
|
13
15
|
|
14
16
|
//-----------------------------------------------------------------------------
|
15
17
|
// Helpers
|
16
18
|
//-----------------------------------------------------------------------------
|
17
19
|
|
18
20
|
/**
|
19
|
-
*
|
20
|
-
* @param {
|
21
|
+
* Throws a helpful error when a rule cannot be found.
|
22
|
+
* @param {Object} ruleId The rule identifier.
|
23
|
+
* @param {string} ruleId.pluginName The ID of the rule to find.
|
24
|
+
* @param {string} ruleId.ruleName The ID of the rule to find.
|
21
25
|
* @param {Object} config The config to search in.
|
22
26
|
* @throws {TypeError} For missing plugin or rule.
|
23
|
-
* @returns {
|
27
|
+
* @returns {void}
|
24
28
|
*/
|
25
|
-
function
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
// built-in rule
|
30
|
-
if (ruleIdParts.length === 1) {
|
31
|
-
pluginName = "@";
|
32
|
-
ruleName = ruleIdParts[0];
|
33
|
-
} else {
|
34
|
-
ruleName = ruleIdParts.pop();
|
35
|
-
pluginName = ruleIdParts.join("/");
|
36
|
-
}
|
29
|
+
function throwRuleNotFoundError({ pluginName, ruleName }, config) {
|
30
|
+
|
31
|
+
const ruleId = pluginName === "@" ? ruleName : `${pluginName}/${ruleName}`;
|
37
32
|
|
38
33
|
const errorMessageHeader = `Key "rules": Key "${ruleId}"`;
|
39
34
|
let errorMessage = `${errorMessageHeader}: Could not find plugin "${pluginName}".`;
|
40
35
|
|
41
36
|
// if the plugin exists then we need to check if the rule exists
|
42
37
|
if (config.plugins && config.plugins[pluginName]) {
|
38
|
+
const replacementRuleName = ruleReplacements.rules[ruleName];
|
43
39
|
|
44
|
-
|
40
|
+
if (pluginName === "@" && replacementRuleName) {
|
45
41
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
42
|
+
errorMessage = `${errorMessageHeader}: Rule "${ruleName}" was removed and replaced by "${replacementRuleName}".`;
|
43
|
+
|
44
|
+
} else {
|
50
45
|
|
51
|
-
|
46
|
+
errorMessage = `${errorMessageHeader}: Could not find "${ruleName}" in plugin "${pluginName}".`;
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
// otherwise, let's see if we can find the rule name elsewhere
|
49
|
+
for (const [otherPluginName, otherPlugin] of Object.entries(config.plugins)) {
|
50
|
+
if (otherPlugin.rules && otherPlugin.rules[ruleName]) {
|
51
|
+
errorMessage += ` Did you mean "${otherPluginName}/${ruleName}"?`;
|
52
|
+
break;
|
53
|
+
}
|
58
54
|
}
|
55
|
+
|
59
56
|
}
|
60
57
|
|
61
58
|
// falls through to throw error
|
@@ -154,7 +151,11 @@ class RuleValidator {
|
|
154
151
|
continue;
|
155
152
|
}
|
156
153
|
|
157
|
-
const rule =
|
154
|
+
const rule = getRuleFromConfig(ruleId, config);
|
155
|
+
|
156
|
+
if (!rule) {
|
157
|
+
throwRuleNotFoundError(parseRuleId(ruleId), config);
|
158
|
+
}
|
158
159
|
|
159
160
|
// Precompile and cache validator the first time
|
160
161
|
if (!this.validators.has(rule)) {
|
package/lib/eslint/eslint.js
CHANGED
@@ -34,7 +34,12 @@ const { version } = require("../../package.json");
|
|
34
34
|
/** @typedef {import("../shared/types").LintMessage} LintMessage */
|
35
35
|
/** @typedef {import("../shared/types").Plugin} Plugin */
|
36
36
|
/** @typedef {import("../shared/types").Rule} Rule */
|
37
|
-
|
37
|
+
|
38
|
+
/**
|
39
|
+
* The main formatter object.
|
40
|
+
* @typedef Formatter
|
41
|
+
* @property {function(LintResult[]): string | Promise<string>} format format function.
|
42
|
+
*/
|
38
43
|
|
39
44
|
/**
|
40
45
|
* The options with which to configure the ESLint instance.
|
@@ -617,7 +622,7 @@ class ESLint {
|
|
617
622
|
throw new Error("'name' must be a string");
|
618
623
|
}
|
619
624
|
|
620
|
-
const { cliEngine } = privateMembersMap.get(this);
|
625
|
+
const { cliEngine, options } = privateMembersMap.get(this);
|
621
626
|
const formatter = cliEngine.getFormatter(name);
|
622
627
|
|
623
628
|
if (typeof formatter !== "function") {
|
@@ -629,7 +634,7 @@ class ESLint {
|
|
629
634
|
/**
|
630
635
|
* The main formatter method.
|
631
636
|
* @param {LintResults[]} results The lint results to format.
|
632
|
-
* @returns {string} The formatted lint results.
|
637
|
+
* @returns {string | Promise<string>} The formatted lint results.
|
633
638
|
*/
|
634
639
|
format(results) {
|
635
640
|
let rulesMeta = null;
|
@@ -637,6 +642,9 @@ class ESLint {
|
|
637
642
|
results.sort(compareResultsByFilePath);
|
638
643
|
|
639
644
|
return formatter(results, {
|
645
|
+
get cwd() {
|
646
|
+
return options.cwd;
|
647
|
+
},
|
640
648
|
get rulesMeta() {
|
641
649
|
if (!rulesMeta) {
|
642
650
|
rulesMeta = createRulesMeta(cliEngine.getRules());
|
@@ -43,7 +43,7 @@ function groupByParentComment(directives) {
|
|
43
43
|
* Creates removal details for a set of directives within the same comment.
|
44
44
|
* @param {Directive[]} directives Unused directives to be removed.
|
45
45
|
* @param {Token} commentToken The backing Comment token.
|
46
|
-
* @returns {{ description, fix,
|
46
|
+
* @returns {{ description, fix, unprocessedDirective }[]} Details for later creation of output Problems.
|
47
47
|
*/
|
48
48
|
function createIndividualDirectivesRemoval(directives, commentToken) {
|
49
49
|
|
@@ -138,7 +138,7 @@ function createIndividualDirectivesRemoval(directives, commentToken) {
|
|
138
138
|
],
|
139
139
|
text: ""
|
140
140
|
},
|
141
|
-
|
141
|
+
unprocessedDirective: directive.unprocessedDirective
|
142
142
|
};
|
143
143
|
});
|
144
144
|
}
|
@@ -147,7 +147,7 @@ function createIndividualDirectivesRemoval(directives, commentToken) {
|
|
147
147
|
* Creates a description of deleting an entire unused disable comment.
|
148
148
|
* @param {Directive[]} directives Unused directives to be removed.
|
149
149
|
* @param {Token} commentToken The backing Comment token.
|
150
|
-
* @returns {{ description, fix,
|
150
|
+
* @returns {{ description, fix, unprocessedDirective }} Details for later creation of an output Problem.
|
151
151
|
*/
|
152
152
|
function createCommentRemoval(directives, commentToken) {
|
153
153
|
const { range } = commentToken;
|
@@ -161,14 +161,14 @@ function createCommentRemoval(directives, commentToken) {
|
|
161
161
|
range,
|
162
162
|
text: " "
|
163
163
|
},
|
164
|
-
|
164
|
+
unprocessedDirective: directives[0].unprocessedDirective
|
165
165
|
};
|
166
166
|
}
|
167
167
|
|
168
168
|
/**
|
169
169
|
* Parses details from directives to create output Problems.
|
170
170
|
* @param {Directive[]} allDirectives Unused directives to be removed.
|
171
|
-
* @returns {{ description, fix,
|
171
|
+
* @returns {{ description, fix, unprocessedDirective }[]} Details for later creation of output Problems.
|
172
172
|
*/
|
173
173
|
function processUnusedDisableDirectives(allDirectives) {
|
174
174
|
const directiveGroups = groupByParentComment(allDirectives);
|
@@ -261,17 +261,21 @@ function applyDirectives(options) {
|
|
261
261
|
const processed = processUnusedDisableDirectives(unusedDisableDirectivesToReport);
|
262
262
|
|
263
263
|
const unusedDisableDirectives = processed
|
264
|
-
.map(({ description, fix,
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
:
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
264
|
+
.map(({ description, fix, unprocessedDirective }) => {
|
265
|
+
const { parentComment, type, line, column } = unprocessedDirective;
|
266
|
+
|
267
|
+
return {
|
268
|
+
ruleId: null,
|
269
|
+
message: description
|
270
|
+
? `Unused eslint-disable directive (no problems were reported from ${description}).`
|
271
|
+
: "Unused eslint-disable directive (no problems were reported).",
|
272
|
+
line: type === "disable-next-line" ? parentComment.commentToken.loc.start.line : line,
|
273
|
+
column: type === "disable-next-line" ? parentComment.commentToken.loc.start.column + 1 : column,
|
274
|
+
severity: options.reportUnusedDisableDirectives === "warn" ? 1 : 2,
|
275
|
+
nodeType: null,
|
276
|
+
...options.disableFixes ? {} : { fix }
|
277
|
+
};
|
278
|
+
});
|
275
279
|
|
276
280
|
return { problems, unusedDisableDirectives };
|
277
281
|
}
|