eslint 5.6.0 → 5.9.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/CHANGELOG.md +65 -0
- package/bin/eslint.js +0 -1
- package/lib/cli-engine.js +128 -31
- package/lib/cli.js +6 -1
- package/lib/linter.js +9 -0
- package/lib/options.js +5 -0
- package/lib/rules/accessor-pairs.js +4 -0
- package/lib/rules/array-bracket-newline.js +5 -0
- package/lib/rules/array-bracket-spacing.js +5 -0
- package/lib/rules/array-callback-return.js +2 -0
- package/lib/rules/array-element-newline.js +4 -0
- package/lib/rules/arrow-body-style.js +2 -0
- package/lib/rules/arrow-parens.js +2 -0
- package/lib/rules/arrow-spacing.js +2 -0
- package/lib/rules/block-scoped-var.js +2 -0
- package/lib/rules/block-spacing.js +2 -0
- package/lib/rules/brace-style.js +2 -0
- package/lib/rules/callback-return.js +2 -0
- package/lib/rules/camelcase.js +38 -8
- package/lib/rules/capitalized-comments.js +4 -0
- package/lib/rules/class-methods-use-this.js +3 -0
- package/lib/rules/comma-dangle.js +4 -0
- package/lib/rules/comma-spacing.js +2 -0
- package/lib/rules/comma-style.js +5 -0
- package/lib/rules/complexity.js +2 -0
- package/lib/rules/computed-property-spacing.js +2 -0
- package/lib/rules/consistent-return.js +2 -0
- package/lib/rules/consistent-this.js +2 -0
- package/lib/rules/constructor-super.js +2 -0
- package/lib/rules/curly.js +2 -0
- package/lib/rules/default-case.js +2 -0
- package/lib/rules/dot-location.js +2 -0
- package/lib/rules/dot-notation.js +2 -0
- package/lib/rules/eol-last.js +5 -0
- package/lib/rules/eqeqeq.js +2 -0
- package/lib/rules/for-direction.js +4 -0
- package/lib/rules/func-call-spacing.js +4 -0
- package/lib/rules/func-name-matching.js +3 -0
- package/lib/rules/func-names.js +3 -0
- package/lib/rules/func-style.js +3 -0
- package/lib/rules/function-paren-newline.js +5 -0
- package/lib/rules/generator-star-spacing.js +3 -0
- package/lib/rules/getter-return.js +5 -0
- package/lib/rules/global-require.js +2 -0
- package/lib/rules/guard-for-in.js +2 -0
- package/lib/rules/handle-callback-err.js +2 -0
- package/lib/rules/id-blacklist.js +2 -0
- package/lib/rules/id-length.js +2 -0
- package/lib/rules/id-match.js +101 -27
- package/lib/rules/implicit-arrow-linebreak.js +4 -0
- package/lib/rules/indent-legacy.js +4 -1
- package/lib/rules/indent.js +2 -0
- package/lib/rules/init-declarations.js +2 -0
- package/lib/rules/jsx-quotes.js +2 -0
- package/lib/rules/key-spacing.js +4 -3
- package/lib/rules/keyword-spacing.js +2 -0
- package/lib/rules/line-comment-position.js +2 -0
- package/lib/rules/linebreak-style.js +2 -0
- package/lib/rules/lines-around-comment.js +2 -0
- package/lib/rules/lines-around-directive.js +6 -2
- package/lib/rules/lines-between-class-members.js +2 -0
- package/lib/rules/max-classes-per-file.js +4 -0
- package/lib/rules/max-depth.js +2 -0
- package/lib/rules/max-len.js +2 -0
- package/lib/rules/max-lines-per-function.js +2 -0
- package/lib/rules/max-lines.js +2 -0
- package/lib/rules/max-nested-callbacks.js +2 -0
- package/lib/rules/max-params.js +2 -0
- package/lib/rules/max-statements-per-line.js +2 -0
- package/lib/rules/max-statements.js +2 -0
- package/lib/rules/multiline-comment-style.js +3 -0
- package/lib/rules/multiline-ternary.js +3 -0
- package/lib/rules/new-cap.js +2 -0
- package/lib/rules/new-parens.js +2 -1
- package/lib/rules/newline-after-var.js +5 -2
- package/lib/rules/newline-before-return.js +5 -2
- package/lib/rules/newline-per-chained-call.js +4 -0
- package/lib/rules/no-alert.js +2 -0
- package/lib/rules/no-array-constructor.js +2 -0
- package/lib/rules/no-async-promise-executor.js +3 -0
- package/lib/rules/no-await-in-loop.js +4 -0
- package/lib/rules/no-bitwise.js +2 -0
- package/lib/rules/no-buffer-constructor.js +4 -0
- package/lib/rules/no-caller.js +2 -0
- package/lib/rules/no-case-declarations.js +2 -0
- package/lib/rules/no-catch-shadow.js +6 -3
- package/lib/rules/no-class-assign.js +2 -0
- package/lib/rules/no-compare-neg-zero.js +4 -0
- package/lib/rules/no-cond-assign.js +2 -0
- package/lib/rules/no-confusing-arrow.js +2 -0
- package/lib/rules/no-console.js +2 -0
- package/lib/rules/no-const-assign.js +2 -0
- package/lib/rules/no-constant-condition.js +2 -0
- package/lib/rules/no-continue.js +2 -0
- package/lib/rules/no-control-regex.js +4 -2
- package/lib/rules/no-debugger.js +4 -0
- package/lib/rules/no-delete-var.js +2 -0
- package/lib/rules/no-div-regex.js +2 -0
- package/lib/rules/no-dupe-args.js +2 -0
- package/lib/rules/no-dupe-class-members.js +2 -0
- package/lib/rules/no-dupe-keys.js +2 -0
- package/lib/rules/no-duplicate-case.js +2 -0
- package/lib/rules/no-duplicate-imports.js +2 -0
- package/lib/rules/no-else-return.js +2 -0
- package/lib/rules/no-empty-character-class.js +2 -0
- package/lib/rules/no-empty-function.js +2 -0
- package/lib/rules/no-empty-pattern.js +2 -0
- package/lib/rules/no-empty.js +2 -0
- package/lib/rules/no-eq-null.js +2 -0
- package/lib/rules/no-eval.js +2 -0
- package/lib/rules/no-ex-assign.js +2 -0
- package/lib/rules/no-extend-native.js +2 -0
- package/lib/rules/no-extra-bind.js +24 -1
- package/lib/rules/no-extra-boolean-cast.js +2 -1
- package/lib/rules/no-extra-label.js +2 -1
- package/lib/rules/no-extra-parens.js +5 -6
- package/lib/rules/no-extra-semi.js +2 -0
- package/lib/rules/no-fallthrough.js +2 -0
- package/lib/rules/no-floating-decimal.js +2 -1
- package/lib/rules/no-func-assign.js +2 -0
- package/lib/rules/no-global-assign.js +2 -0
- package/lib/rules/no-implicit-coercion.js +3 -0
- package/lib/rules/no-implicit-globals.js +2 -0
- package/lib/rules/no-implied-eval.js +2 -0
- package/lib/rules/no-inline-comments.js +2 -0
- package/lib/rules/no-inner-declarations.js +2 -0
- package/lib/rules/no-invalid-regexp.js +2 -0
- package/lib/rules/no-invalid-this.js +2 -0
- package/lib/rules/no-irregular-whitespace.js +6 -8
- package/lib/rules/no-iterator.js +2 -0
- package/lib/rules/no-label-var.js +2 -0
- package/lib/rules/no-labels.js +2 -0
- package/lib/rules/no-lone-blocks.js +2 -0
- package/lib/rules/no-lonely-if.js +2 -1
- package/lib/rules/no-loop-func.js +2 -0
- package/lib/rules/no-magic-numbers.js +3 -0
- package/lib/rules/no-misleading-character-class.js +4 -0
- package/lib/rules/no-mixed-operators.js +3 -0
- package/lib/rules/no-mixed-requires.js +2 -0
- package/lib/rules/no-mixed-spaces-and-tabs.js +2 -0
- package/lib/rules/no-multi-assign.js +3 -0
- package/lib/rules/no-multi-spaces.js +2 -0
- package/lib/rules/no-multi-str.js +2 -0
- package/lib/rules/no-multiple-empty-lines.js +2 -0
- package/lib/rules/no-native-reassign.js +4 -1
- package/lib/rules/no-negated-condition.js +2 -0
- package/lib/rules/no-negated-in-lhs.js +5 -2
- package/lib/rules/no-nested-ternary.js +2 -0
- package/lib/rules/no-new-func.js +2 -0
- package/lib/rules/no-new-object.js +2 -0
- package/lib/rules/no-new-require.js +2 -0
- package/lib/rules/no-new-symbol.js +2 -0
- package/lib/rules/no-new-wrappers.js +2 -0
- package/lib/rules/no-new.js +2 -0
- package/lib/rules/no-obj-calls.js +2 -0
- package/lib/rules/no-octal-escape.js +2 -0
- package/lib/rules/no-octal.js +2 -0
- package/lib/rules/no-param-reassign.js +2 -0
- package/lib/rules/no-path-concat.js +2 -0
- package/lib/rules/no-plusplus.js +2 -0
- package/lib/rules/no-process-env.js +2 -0
- package/lib/rules/no-process-exit.js +2 -0
- package/lib/rules/no-proto.js +2 -0
- package/lib/rules/no-prototype-builtins.js +2 -0
- package/lib/rules/no-redeclare.js +2 -0
- package/lib/rules/no-regex-spaces.js +2 -1
- package/lib/rules/no-restricted-globals.js +2 -0
- package/lib/rules/no-restricted-imports.js +40 -22
- package/lib/rules/no-restricted-modules.js +2 -0
- package/lib/rules/no-restricted-properties.js +2 -0
- package/lib/rules/no-restricted-syntax.js +2 -0
- package/lib/rules/no-return-assign.js +2 -0
- package/lib/rules/no-return-await.js +4 -0
- package/lib/rules/no-script-url.js +2 -0
- package/lib/rules/no-self-assign.js +2 -0
- package/lib/rules/no-self-compare.js +2 -0
- package/lib/rules/no-sequences.js +2 -0
- package/lib/rules/no-shadow-restricted-names.js +2 -0
- package/lib/rules/no-shadow.js +2 -0
- package/lib/rules/no-spaced-func.js +4 -1
- package/lib/rules/no-sparse-arrays.js +2 -0
- package/lib/rules/no-sync.js +2 -0
- package/lib/rules/no-tabs.js +25 -6
- package/lib/rules/no-template-curly-in-string.js +2 -0
- package/lib/rules/no-ternary.js +2 -0
- package/lib/rules/no-this-before-super.js +2 -0
- package/lib/rules/no-throw-literal.js +2 -0
- package/lib/rules/no-trailing-spaces.js +2 -0
- package/lib/rules/no-undef-init.js +2 -1
- package/lib/rules/no-undef.js +2 -0
- package/lib/rules/no-undefined.js +2 -0
- package/lib/rules/no-underscore-dangle.js +2 -0
- package/lib/rules/no-unexpected-multiline.js +2 -0
- package/lib/rules/no-unmodified-loop-condition.js +2 -0
- package/lib/rules/no-unneeded-ternary.js +2 -0
- package/lib/rules/no-unreachable.js +2 -1
- package/lib/rules/no-unsafe-finally.js +2 -0
- package/lib/rules/no-unsafe-negation.js +3 -0
- package/lib/rules/no-unused-expressions.js +2 -0
- package/lib/rules/no-unused-labels.js +2 -1
- package/lib/rules/no-unused-vars.js +37 -13
- package/lib/rules/no-use-before-define.js +2 -0
- package/lib/rules/no-useless-call.js +2 -0
- package/lib/rules/no-useless-computed-key.js +2 -1
- package/lib/rules/no-useless-concat.js +2 -0
- package/lib/rules/no-useless-constructor.js +2 -0
- package/lib/rules/no-useless-escape.js +2 -0
- package/lib/rules/no-useless-rename.js +4 -0
- package/lib/rules/no-useless-return.js +3 -0
- package/lib/rules/no-var.js +2 -0
- package/lib/rules/no-void.js +2 -0
- package/lib/rules/no-warning-comments.js +2 -0
- package/lib/rules/no-whitespace-before-property.js +2 -0
- package/lib/rules/no-with.js +2 -0
- package/lib/rules/nonblock-statement-body-position.js +4 -0
- package/lib/rules/object-curly-newline.js +4 -0
- package/lib/rules/object-curly-spacing.js +2 -0
- package/lib/rules/object-property-newline.js +3 -2
- package/lib/rules/object-shorthand.js +2 -0
- package/lib/rules/one-var-declaration-per-line.js +2 -0
- package/lib/rules/one-var.js +13 -1
- package/lib/rules/operator-assignment.js +2 -0
- package/lib/rules/operator-linebreak.js +2 -0
- package/lib/rules/padded-blocks.js +2 -0
- package/lib/rules/padding-line-between-statements.js +7 -0
- package/lib/rules/prefer-arrow-callback.js +2 -0
- package/lib/rules/prefer-const.js +116 -11
- package/lib/rules/prefer-destructuring.js +3 -0
- package/lib/rules/prefer-numeric-literals.js +2 -1
- package/lib/rules/prefer-object-spread.js +4 -0
- package/lib/rules/prefer-promise-reject-errors.js +4 -0
- package/lib/rules/prefer-reflect.js +4 -1
- package/lib/rules/prefer-rest-params.js +2 -0
- package/lib/rules/prefer-spread.js +2 -1
- package/lib/rules/prefer-template.js +2 -1
- package/lib/rules/quote-props.js +2 -0
- package/lib/rules/quotes.js +2 -0
- package/lib/rules/radix.js +2 -0
- package/lib/rules/require-atomic-updates.js +91 -30
- package/lib/rules/require-await.js +3 -0
- package/lib/rules/require-jsdoc.js +2 -0
- package/lib/rules/require-unicode-regexp.js +4 -0
- package/lib/rules/require-yield.js +2 -0
- package/lib/rules/rest-spread-spacing.js +4 -0
- package/lib/rules/semi-spacing.js +2 -0
- package/lib/rules/semi-style.js +3 -0
- package/lib/rules/semi.js +2 -0
- package/lib/rules/sort-imports.js +2 -0
- package/lib/rules/sort-keys.js +3 -0
- package/lib/rules/sort-vars.js +2 -0
- package/lib/rules/space-before-blocks.js +46 -35
- package/lib/rules/space-before-function-paren.js +2 -0
- package/lib/rules/space-in-parens.js +2 -0
- package/lib/rules/space-infix-ops.js +18 -25
- package/lib/rules/space-unary-ops.js +2 -0
- package/lib/rules/spaced-comment.js +2 -0
- package/lib/rules/strict.js +2 -0
- package/lib/rules/switch-colon-spacing.js +4 -0
- package/lib/rules/symbol-description.js +2 -0
- package/lib/rules/template-curly-spacing.js +2 -0
- package/lib/rules/template-tag-spacing.js +2 -0
- package/lib/rules/unicode-bom.js +2 -0
- package/lib/rules/use-isnan.js +2 -0
- package/lib/rules/valid-jsdoc.js +2 -0
- package/lib/rules/valid-typeof.js +2 -0
- package/lib/rules/vars-on-top.js +2 -0
- package/lib/rules/wrap-iife.js +2 -0
- package/lib/rules/wrap-regex.js +3 -1
- package/lib/rules/yield-star-spacing.js +2 -0
- package/lib/rules/yoda.js +2 -0
- package/lib/testers/rule-tester.js +2 -2
- package/lib/util/source-code-fixer.js +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,68 @@
|
|
1
|
+
v5.9.0 - November 9, 2018
|
2
|
+
|
3
|
+
* 9436712 Fix: Unused recursive function expressions (fixes #10982) (#11032) (Sergei Startsev)
|
4
|
+
* c832cd5 Update: add `ignoreDestructuring` option to `id-match` rule (#10554) (一名宅。)
|
5
|
+
* 54687a8 Fix: prefer-const autofix multiline assignment (fixes #10582) (#10987) (Scott Stern)
|
6
|
+
* ae2b61d Update: "off" options for "space-before-blocks" (refs #10906) (#10907) (Sophie Kirschner)
|
7
|
+
* 57f357e Docs: Update require-await docs with exception (fixes #9540) (#11063) (Nicholas C. Zakas)
|
8
|
+
* 79a2797 Update: no-restricted-imports to check re-export (fixes #9678) (#11064) (Nicholas C. Zakas)
|
9
|
+
* 3dd7493 Docs: update ecmaVersion to include 2019/10 values (#11059) (Vse Mozhet Byt)
|
10
|
+
* 607635d Upgrade: eslint-plugin-node & eslint-plugin (#11067) (薛定谔的猫)
|
11
|
+
* dcc6233 Fix: Ignore empty statements in no-unreachable (fixes #9081) (#11058) (Nicholas C. Zakas)
|
12
|
+
* 7ad86de New: Add --fix-type option to CLI (fixes #10855) (#10912) (Nicholas C. Zakas)
|
13
|
+
* 0800b20 Chore: fix invalid super() calls in tests (#11054) (Teddy Katz)
|
14
|
+
* 4fe3287 Docs: Cross-reference two rules (refs #11041) (#11042) (Paul Melnikow)
|
15
|
+
* 5525eb6 Fix: rule deprecation warnings did not consider all rules (#11044) (Teddy Katz)
|
16
|
+
* 44d37ca Docs: Update steps for adding new TSC member (#11038) (Nicholas C. Zakas)
|
17
|
+
* 802e926 Update: Warn for deprecation in Node output (fixes #7443) (#10953) (Colin Chang)
|
18
|
+
|
19
|
+
v5.8.0 - October 26, 2018
|
20
|
+
|
21
|
+
* 9152417 Fix: deprecation warning in RuleTester using Node v11 (#11009) (Teddy Katz)
|
22
|
+
* e349a03 Docs: Update issue templates to ask for PRs (#11012) (Nicholas C. Zakas)
|
23
|
+
* 3d88b38 Chore: avoid using legacy report API in no-irregular-whitespace (#11013) (Teddy Katz)
|
24
|
+
* 5a31a92 Build: compile espree's deps to ES5 when generating site (fixes #11014) (#11015) (Teddy Katz)
|
25
|
+
* 3943635 Update: Create Linter.version API (fixes #9271) (#11010) (Nicholas C. Zakas)
|
26
|
+
* a940cf4 Docs: Mention version for config glob patterns (fixes #8793) (Nicholas C. Zakas)
|
27
|
+
* 6e1c530 Build: run tests on Node 11 (#11008) (Teddy Katz)
|
28
|
+
* 58ff359 Docs: add instructions for npm 2FA (refs #10631) (#10992) (Teddy Katz)
|
29
|
+
* 2f87bb3 Upgrade: eslint-release@1.0.0 (refs #10631) (#10991) (Teddy Katz)
|
30
|
+
* 57ef0fd Fix: prefer-const when using destructuring assign (fixes #8308) (#10924) (Nicholas C. Zakas)
|
31
|
+
* 577cbf1 Chore: Add typescript-specific edge case tests to space-infix-ops (#10986) (Bence Dányi)
|
32
|
+
* d45b184 Chore: Using deconstruction assignment for shelljs (#10974) (ZYSzys)
|
33
|
+
|
34
|
+
v5.7.0 - October 12, 2018
|
35
|
+
|
36
|
+
* 6cb63fd Update: Add iife to padding-line-between-statements (fixes #10853) (#10916) (Kevin Partington)
|
37
|
+
* 5fd1bda Update: no-tabs allowIndentationTabs option (fixes #10256) (#10925) (Kevin Partington)
|
38
|
+
* d12be69 Fix: no-extra-bind No autofix if arg may have side effect (fixes #10846) (#10918) (Kevin Partington)
|
39
|
+
* 847372f Fix: no-unused-vars false pos. with markVariableAsUsed (fixes #10952) (#10954) (Roy Sutton)
|
40
|
+
* 4132de7 Chore: Simplify space-infix-ops (#10935) (Bence Dányi)
|
41
|
+
* 543edfa Fix: Fix error with one-var (fixes #10937) (#10938) (Justin Krup)
|
42
|
+
* 95c4cb1 Docs: Fix typo for no-unsafe-finally (#10945) (Sergio Santoro)
|
43
|
+
* 5fe0e1a Fix: no-invalid-regexp disallows \ at end of pattern (fixes #10861) (#10920) (Toru Nagashima)
|
44
|
+
* f85547a Docs: Add 'When Not To Use' section to space-infix-ops (#10931) (Bence Dányi)
|
45
|
+
* 3dccac4 Docs: Update working-with-parsers link (#10929) (Azeem Bande-Ali)
|
46
|
+
* 557a8bb Docs: Remove old note about caching, add a new one (fixes #10739) (#10913) (Zac)
|
47
|
+
* fe8111a Chore: Add more test cases to space-infix-ops (#10936) (Bence Dányi)
|
48
|
+
* 066f7e0 Update: camelcase rule ignoreList added (#10783) (Julien Martin)
|
49
|
+
* 70bde69 Upgrade: table to version 5 (#10903) (Rouven Weßling)
|
50
|
+
* 2e52bca Chore: Update issue templates (#10900) (Nicholas C. Zakas)
|
51
|
+
|
52
|
+
v5.6.1 - September 28, 2018
|
53
|
+
|
54
|
+
* 9b26bdb Fix: avoid exponential require-atomic-updates traversal (fixes #10893) (#10894) (Teddy Katz)
|
55
|
+
* 9432b10 Fix: make separateRequires work in consecutive mode (fixes #10784) (#10886) (Pig Fang)
|
56
|
+
* e51868d Upgrade: debug@4 (fixes #10854) (#10887) (薛定谔的猫)
|
57
|
+
* d3f3994 Docs: add information about reporting security issues (#10889) (Teddy Katz)
|
58
|
+
* cc458f4 Build: fix failing tests on master (#10890) (Teddy Katz)
|
59
|
+
* a6ebfd3 Docs: clarify defaultAssignment option, fix no-unneeded-ternary examples (#10874) (CoffeeTableEspresso)
|
60
|
+
* 9d52541 Fix: Remove duplicate error message on crash (fixes #8964) (#10865) (Nicholas C. Zakas)
|
61
|
+
* 4eb9a49 Docs: Update quotes.md (#10862) (The Jared Wilcurt)
|
62
|
+
* 9159e9b Docs: Update complexity.md (#10867) (Szymon Przybylski)
|
63
|
+
* 14f4e46 Docs: Use Linter instead of linter in Nodejs API page (#10864) (Nicholas C. Zakas)
|
64
|
+
* b3e3cb1 Chore: Update debug log name to match filename (#10863) (Nicholas C. Zakas)
|
65
|
+
|
1
66
|
v5.6.0 - September 14, 2018
|
2
67
|
|
3
68
|
* c5b688e Update: Added generators option to func-names (fixes #9511) (#10697) (Oscar Barrett)
|
package/bin/eslint.js
CHANGED
package/lib/cli-engine.js
CHANGED
@@ -19,8 +19,10 @@ const fs = require("fs"),
|
|
19
19
|
path = require("path"),
|
20
20
|
defaultOptions = require("../conf/default-cli-options"),
|
21
21
|
Linter = require("./linter"),
|
22
|
+
lodash = require("lodash"),
|
22
23
|
IgnoredPaths = require("./ignored-paths"),
|
23
24
|
Config = require("./config"),
|
25
|
+
ConfigOps = require("./config/config-ops"),
|
24
26
|
LintResultCache = require("./util/lint-result-cache"),
|
25
27
|
globUtils = require("./util/glob-utils"),
|
26
28
|
validator = require("./config/config-validator"),
|
@@ -31,6 +33,7 @@ const fs = require("fs"),
|
|
31
33
|
|
32
34
|
const debug = require("debug")("eslint:cli-engine");
|
33
35
|
const resolver = new ModuleResolver();
|
36
|
+
const validFixTypes = new Set(["problem", "suggestion", "layout"]);
|
34
37
|
|
35
38
|
//------------------------------------------------------------------------------
|
36
39
|
// Typedefs
|
@@ -48,6 +51,7 @@ const resolver = new ModuleResolver();
|
|
48
51
|
* @property {string[]} envs An array of environments to load.
|
49
52
|
* @property {string[]} extensions An array of file extensions to check.
|
50
53
|
* @property {boolean|Function} fix Execute in autofix mode. If a function, should return a boolean.
|
54
|
+
* @property {string[]} fixTypes Array of rule types to apply fixes for.
|
51
55
|
* @property {string[]} globals An array of global variables to declare.
|
52
56
|
* @property {boolean} ignore False disables use of .eslintignore.
|
53
57
|
* @property {string} ignorePath The ignore file to use instead of .eslintignore.
|
@@ -84,6 +88,21 @@ const resolver = new ModuleResolver();
|
|
84
88
|
// Helpers
|
85
89
|
//------------------------------------------------------------------------------
|
86
90
|
|
91
|
+
/**
|
92
|
+
* Determines if each fix type in an array is supported by ESLint and throws
|
93
|
+
* an error if not.
|
94
|
+
* @param {string[]} fixTypes An array of fix types to check.
|
95
|
+
* @returns {void}
|
96
|
+
* @throws {Error} If an invalid fix type is found.
|
97
|
+
*/
|
98
|
+
function validateFixTypes(fixTypes) {
|
99
|
+
for (const fixType of fixTypes) {
|
100
|
+
if (!validFixTypes.has(fixType)) {
|
101
|
+
throw new Error(`Invalid fix type "${fixType}" found.`);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
87
106
|
/**
|
88
107
|
* It will calculate the error and warning count for collection of messages per file
|
89
108
|
* @param {Object[]} messages - Collection of messages
|
@@ -142,7 +161,7 @@ function calculateStatsPerRun(results) {
|
|
142
161
|
* @param {boolean} allowInlineConfig Allow/ignore comments that change config.
|
143
162
|
* @param {boolean} reportUnusedDisableDirectives Allow/ignore comments that change config.
|
144
163
|
* @param {Linter} linter Linter context
|
145
|
-
* @returns {LintResult} The results for linting on this text.
|
164
|
+
* @returns {{rules: LintResult, config: Object}} The results for linting on this text and the fully-resolved config for it.
|
146
165
|
* @private
|
147
166
|
*/
|
148
167
|
function processText(text, configHelper, filename, fix, allowInlineConfig, reportUnusedDisableDirectives, linter) {
|
@@ -174,7 +193,6 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor
|
|
174
193
|
}
|
175
194
|
|
176
195
|
const autofixingEnabled = typeof fix !== "undefined" && (!processor || processor.supportsAutofix);
|
177
|
-
|
178
196
|
const fixedResult = linter.verifyAndFix(text, config, {
|
179
197
|
filename: effectiveFilename,
|
180
198
|
allowInlineConfig,
|
@@ -183,7 +201,6 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor
|
|
183
201
|
preprocess: processor && (rawText => processor.preprocess(rawText, effectiveFilename)),
|
184
202
|
postprocess: processor && (problemLists => processor.postprocess(problemLists, effectiveFilename))
|
185
203
|
});
|
186
|
-
|
187
204
|
const stats = calculateStatsPerFile(fixedResult.messages);
|
188
205
|
|
189
206
|
const result = {
|
@@ -203,7 +220,7 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor
|
|
203
220
|
result.source = text;
|
204
221
|
}
|
205
222
|
|
206
|
-
return result;
|
223
|
+
return { result, config };
|
207
224
|
}
|
208
225
|
|
209
226
|
/**
|
@@ -213,24 +230,22 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor
|
|
213
230
|
* @param {Object} configHelper The configuration options for ESLint.
|
214
231
|
* @param {Object} options The CLIEngine options object.
|
215
232
|
* @param {Linter} linter Linter context
|
216
|
-
* @returns {LintResult} The results for linting on this
|
233
|
+
* @returns {{rules: LintResult, config: Object}} The results for linting on this text and the fully-resolved config for it.
|
217
234
|
* @private
|
218
235
|
*/
|
219
236
|
function processFile(filename, configHelper, options, linter) {
|
220
237
|
|
221
|
-
const text = fs.readFileSync(path.resolve(filename), "utf8")
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
return result;
|
233
|
-
|
238
|
+
const text = fs.readFileSync(path.resolve(filename), "utf8");
|
239
|
+
|
240
|
+
return processText(
|
241
|
+
text,
|
242
|
+
configHelper,
|
243
|
+
filename,
|
244
|
+
options.fix,
|
245
|
+
options.allowInlineConfig,
|
246
|
+
options.reportUnusedDisableDirectives,
|
247
|
+
linter
|
248
|
+
);
|
234
249
|
}
|
235
250
|
|
236
251
|
/**
|
@@ -272,6 +287,33 @@ function createIgnoreResult(filePath, baseDir) {
|
|
272
287
|
};
|
273
288
|
}
|
274
289
|
|
290
|
+
/**
|
291
|
+
* Produces rule warnings (i.e. deprecation) from configured rules
|
292
|
+
* @param {(Array<string>|Set<string>)} usedRules - Rules configured
|
293
|
+
* @param {Map} loadedRules - Map of loaded rules
|
294
|
+
* @returns {Array<Object>} Contains rule warnings
|
295
|
+
* @private
|
296
|
+
*/
|
297
|
+
function createRuleDeprecationWarnings(usedRules, loadedRules) {
|
298
|
+
const usedDeprecatedRules = [];
|
299
|
+
|
300
|
+
usedRules.forEach(name => {
|
301
|
+
const loadedRule = loadedRules.get(name);
|
302
|
+
|
303
|
+
if (loadedRule && loadedRule.meta && loadedRule.meta.deprecated) {
|
304
|
+
const deprecatedRule = { ruleId: name };
|
305
|
+
const replacedBy = lodash.get(loadedRule, "meta.replacedBy", []);
|
306
|
+
|
307
|
+
if (replacedBy.every(newRule => lodash.isString(newRule))) {
|
308
|
+
deprecatedRule.replacedBy = replacedBy;
|
309
|
+
}
|
310
|
+
|
311
|
+
usedDeprecatedRules.push(deprecatedRule);
|
312
|
+
}
|
313
|
+
});
|
314
|
+
|
315
|
+
return usedDeprecatedRules;
|
316
|
+
}
|
275
317
|
|
276
318
|
/**
|
277
319
|
* Checks if the given message is an error message.
|
@@ -429,6 +471,33 @@ class CLIEngine {
|
|
429
471
|
*/
|
430
472
|
this._lintResultCache = new LintResultCache(cacheFile, this.config);
|
431
473
|
}
|
474
|
+
|
475
|
+
// setup special filter for fixes
|
476
|
+
if (this.options.fix && this.options.fixTypes && this.options.fixTypes.length > 0) {
|
477
|
+
|
478
|
+
debug(`Using fix types ${this.options.fixTypes}`);
|
479
|
+
|
480
|
+
// throw an error if any invalid fix types are found
|
481
|
+
validateFixTypes(this.options.fixTypes);
|
482
|
+
|
483
|
+
// convert to Set for faster lookup
|
484
|
+
const fixTypes = new Set(this.options.fixTypes);
|
485
|
+
|
486
|
+
// save original value of options.fix in case it's a function
|
487
|
+
const originalFix = (typeof this.options.fix === "function")
|
488
|
+
? this.options.fix : () => this.options.fix;
|
489
|
+
|
490
|
+
// create a cache of rules (but don't populate until needed)
|
491
|
+
this._rulesCache = null;
|
492
|
+
|
493
|
+
this.options.fix = lintResult => {
|
494
|
+
const rule = this._rulesCache.get(lintResult.ruleId);
|
495
|
+
const matches = rule.meta && fixTypes.has(rule.meta.type);
|
496
|
+
|
497
|
+
return matches && originalFix(lintResult);
|
498
|
+
};
|
499
|
+
}
|
500
|
+
|
432
501
|
}
|
433
502
|
|
434
503
|
getRules() {
|
@@ -511,6 +580,7 @@ class CLIEngine {
|
|
511
580
|
|
512
581
|
const startTime = Date.now();
|
513
582
|
const fileList = globUtils.listFilesToProcess(patterns, options);
|
583
|
+
const allUsedRules = new Set();
|
514
584
|
const results = fileList.map(fileInfo => {
|
515
585
|
if (fileInfo.ignored) {
|
516
586
|
return createIgnoreResult(fileInfo.filename, options.cwd);
|
@@ -532,9 +602,20 @@ class CLIEngine {
|
|
532
602
|
}
|
533
603
|
}
|
534
604
|
|
605
|
+
// if there's a cache, populate it
|
606
|
+
if ("_rulesCache" in this) {
|
607
|
+
this._rulesCache = this.getRules();
|
608
|
+
}
|
609
|
+
|
535
610
|
debug(`Processing ${fileInfo.filename}`);
|
536
611
|
|
537
|
-
|
612
|
+
const { result, config } = processFile(fileInfo.filename, configHelper, options, this.linter);
|
613
|
+
|
614
|
+
Object.keys(config.rules)
|
615
|
+
.filter(ruleId => ConfigOps.getRuleSeverity(config.rules[ruleId]))
|
616
|
+
.forEach(ruleId => allUsedRules.add(ruleId));
|
617
|
+
|
618
|
+
return result;
|
538
619
|
});
|
539
620
|
|
540
621
|
if (options.cache) {
|
@@ -555,6 +636,8 @@ class CLIEngine {
|
|
555
636
|
|
556
637
|
const stats = calculateStatsPerRun(results);
|
557
638
|
|
639
|
+
const usedDeprecatedRules = createRuleDeprecationWarnings(allUsedRules, this.getRules());
|
640
|
+
|
558
641
|
debug(`Linting complete in: ${Date.now() - startTime}ms`);
|
559
642
|
|
560
643
|
return {
|
@@ -562,7 +645,8 @@ class CLIEngine {
|
|
562
645
|
errorCount: stats.errorCount,
|
563
646
|
warningCount: stats.warningCount,
|
564
647
|
fixableErrorCount: stats.fixableErrorCount,
|
565
|
-
fixableWarningCount: stats.fixableWarningCount
|
648
|
+
fixableWarningCount: stats.fixableWarningCount,
|
649
|
+
usedDeprecatedRules
|
566
650
|
};
|
567
651
|
}
|
568
652
|
|
@@ -585,22 +669,34 @@ class CLIEngine {
|
|
585
669
|
const resolvedFilename = filename && !path.isAbsolute(filename)
|
586
670
|
? path.resolve(options.cwd, filename)
|
587
671
|
: filename;
|
672
|
+
let usedDeprecatedRules;
|
588
673
|
|
589
674
|
if (resolvedFilename && ignoredPaths.contains(resolvedFilename)) {
|
590
675
|
if (warnIgnored) {
|
591
676
|
results.push(createIgnoreResult(resolvedFilename, options.cwd));
|
592
677
|
}
|
678
|
+
usedDeprecatedRules = [];
|
593
679
|
} else {
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
680
|
+
|
681
|
+
// if there's a cache, populate it
|
682
|
+
if ("_rulesCache" in this) {
|
683
|
+
this._rulesCache = this.getRules();
|
684
|
+
}
|
685
|
+
|
686
|
+
const { result, config } = processText(
|
687
|
+
text,
|
688
|
+
configHelper,
|
689
|
+
resolvedFilename,
|
690
|
+
options.fix,
|
691
|
+
options.allowInlineConfig,
|
692
|
+
options.reportUnusedDisableDirectives,
|
693
|
+
this.linter
|
694
|
+
);
|
695
|
+
|
696
|
+
results.push(result);
|
697
|
+
usedDeprecatedRules = createRuleDeprecationWarnings(
|
698
|
+
Object.keys(config.rules).filter(rule => ConfigOps.getRuleSeverity(config.rules[rule])),
|
699
|
+
this.getRules()
|
604
700
|
);
|
605
701
|
}
|
606
702
|
|
@@ -611,7 +707,8 @@ class CLIEngine {
|
|
611
707
|
errorCount: stats.errorCount,
|
612
708
|
warningCount: stats.warningCount,
|
613
709
|
fixableErrorCount: stats.fixableErrorCount,
|
614
|
-
fixableWarningCount: stats.fixableWarningCount
|
710
|
+
fixableWarningCount: stats.fixableWarningCount,
|
711
|
+
usedDeprecatedRules
|
615
712
|
};
|
616
713
|
}
|
617
714
|
|
package/lib/cli.js
CHANGED
@@ -64,6 +64,7 @@ function translateOptions(cliOptions) {
|
|
64
64
|
cacheFile: cliOptions.cacheFile,
|
65
65
|
cacheLocation: cliOptions.cacheLocation,
|
66
66
|
fix: (cliOptions.fix || cliOptions.fixDryRun) && (cliOptions.quiet ? quietFixPredicate : true),
|
67
|
+
fixTypes: cliOptions.fixType,
|
67
68
|
allowInlineConfig: cliOptions.inlineConfig,
|
68
69
|
reportUnusedDisableDirectives: cliOptions.reportUnusedDisableDirectives
|
69
70
|
};
|
@@ -187,8 +188,12 @@ const cli = {
|
|
187
188
|
return 2;
|
188
189
|
}
|
189
190
|
|
190
|
-
|
191
|
+
if (currentOptions.fixType && !currentOptions.fix && !currentOptions.fixDryRun) {
|
192
|
+
log.error("The --fix-type option requires either --fix or --fix-dry-run.");
|
193
|
+
return 2;
|
194
|
+
}
|
191
195
|
|
196
|
+
const engine = new CLIEngine(translateOptions(currentOptions));
|
192
197
|
const report = useStdin ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files);
|
193
198
|
|
194
199
|
if (currentOptions.fix) {
|
package/lib/linter.js
CHANGED
@@ -888,6 +888,15 @@ module.exports = class Linter {
|
|
888
888
|
this.environments = new Environments();
|
889
889
|
}
|
890
890
|
|
891
|
+
/**
|
892
|
+
* Getter for package version.
|
893
|
+
* @static
|
894
|
+
* @returns {string} The version from package.json.
|
895
|
+
*/
|
896
|
+
static get version() {
|
897
|
+
return pkg.version;
|
898
|
+
}
|
899
|
+
|
891
900
|
/**
|
892
901
|
* Configuration object for the `verify` API. A JS representation of the eslintrc files.
|
893
902
|
* @typedef {Object} ESLintConfig
|
package/lib/options.js
CHANGED
@@ -97,6 +97,11 @@ module.exports = optionator({
|
|
97
97
|
default: false,
|
98
98
|
description: "Automatically fix problems without saving the changes to the file system"
|
99
99
|
},
|
100
|
+
{
|
101
|
+
option: "fix-type",
|
102
|
+
type: "Array",
|
103
|
+
description: "Specify the types of fixes to apply (problem, suggestion, layout)"
|
104
|
+
},
|
100
105
|
{
|
101
106
|
heading: "Ignoring files"
|
102
107
|
},
|
@@ -72,12 +72,15 @@ function isPropertyDescriptor(node) {
|
|
72
72
|
|
73
73
|
module.exports = {
|
74
74
|
meta: {
|
75
|
+
type: "suggestion",
|
76
|
+
|
75
77
|
docs: {
|
76
78
|
description: "enforce getter and setter pairs in objects",
|
77
79
|
category: "Best Practices",
|
78
80
|
recommended: false,
|
79
81
|
url: "https://eslint.org/docs/rules/accessor-pairs"
|
80
82
|
},
|
83
|
+
|
81
84
|
schema: [{
|
82
85
|
type: "object",
|
83
86
|
properties: {
|
@@ -90,6 +93,7 @@ module.exports = {
|
|
90
93
|
},
|
91
94
|
additionalProperties: false
|
92
95
|
}],
|
96
|
+
|
93
97
|
messages: {
|
94
98
|
getter: "Getter is not present.",
|
95
99
|
setter: "Setter is not present."
|
@@ -13,13 +13,17 @@ const astUtils = require("../util/ast-utils");
|
|
13
13
|
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
|
+
type: "layout",
|
17
|
+
|
16
18
|
docs: {
|
17
19
|
description: "enforce linebreaks after opening and before closing array brackets",
|
18
20
|
category: "Stylistic Issues",
|
19
21
|
recommended: false,
|
20
22
|
url: "https://eslint.org/docs/rules/array-bracket-newline"
|
21
23
|
},
|
24
|
+
|
22
25
|
fixable: "whitespace",
|
26
|
+
|
23
27
|
schema: [
|
24
28
|
{
|
25
29
|
oneOf: [
|
@@ -42,6 +46,7 @@ module.exports = {
|
|
42
46
|
]
|
43
47
|
}
|
44
48
|
],
|
49
|
+
|
45
50
|
messages: {
|
46
51
|
unexpectedOpeningLinebreak: "There should be no linebreak after '['.",
|
47
52
|
unexpectedClosingLinebreak: "There should be no linebreak before ']'.",
|
@@ -12,13 +12,17 @@ const astUtils = require("../util/ast-utils");
|
|
12
12
|
|
13
13
|
module.exports = {
|
14
14
|
meta: {
|
15
|
+
type: "layout",
|
16
|
+
|
15
17
|
docs: {
|
16
18
|
description: "enforce consistent spacing inside array brackets",
|
17
19
|
category: "Stylistic Issues",
|
18
20
|
recommended: false,
|
19
21
|
url: "https://eslint.org/docs/rules/array-bracket-spacing"
|
20
22
|
},
|
23
|
+
|
21
24
|
fixable: "whitespace",
|
25
|
+
|
22
26
|
schema: [
|
23
27
|
{
|
24
28
|
enum: ["always", "never"]
|
@@ -39,6 +43,7 @@ module.exports = {
|
|
39
43
|
additionalProperties: false
|
40
44
|
}
|
41
45
|
],
|
46
|
+
|
42
47
|
messages: {
|
43
48
|
unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
|
44
49
|
unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
|
@@ -13,13 +13,17 @@ const astUtils = require("../util/ast-utils");
|
|
13
13
|
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
|
+
type: "layout",
|
17
|
+
|
16
18
|
docs: {
|
17
19
|
description: "enforce line breaks after each array element",
|
18
20
|
category: "Stylistic Issues",
|
19
21
|
recommended: false,
|
20
22
|
url: "https://eslint.org/docs/rules/array-element-newline"
|
21
23
|
},
|
24
|
+
|
22
25
|
fixable: "whitespace",
|
26
|
+
|
23
27
|
schema: [
|
24
28
|
{
|
25
29
|
oneOf: [
|
package/lib/rules/brace-style.js
CHANGED