eslint 5.0.0 → 5.3.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 +78 -0
- package/README.md +1 -1
- package/conf/eslint-recommended.js +4 -0
- package/lib/cli-engine.js +37 -76
- package/lib/cli.js +1 -1
- package/lib/code-path-analysis/code-path-analyzer.js +2 -2
- package/lib/config/config-initializer.js +8 -8
- package/lib/config/config-validator.js +13 -6
- package/lib/config.js +1 -1
- package/lib/formatters/stylish.js +1 -1
- package/lib/ignored-paths.js +125 -37
- package/lib/linter.js +6 -7
- package/lib/rules/array-bracket-newline.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/array-callback-return.js +1 -1
- package/lib/rules/array-element-newline.js +1 -1
- package/lib/rules/arrow-body-style.js +1 -1
- package/lib/rules/arrow-parens.js +1 -1
- package/lib/rules/arrow-spacing.js +1 -1
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/brace-style.js +1 -1
- package/lib/rules/capitalized-comments.js +1 -1
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/comma-style.js +1 -1
- package/lib/rules/complexity.js +1 -1
- package/lib/rules/computed-property-spacing.js +1 -1
- package/lib/rules/consistent-return.js +1 -1
- package/lib/rules/curly.js +1 -1
- package/lib/rules/dot-location.js +1 -1
- package/lib/rules/dot-notation.js +1 -1
- package/lib/rules/eqeqeq.js +1 -1
- package/lib/rules/func-call-spacing.js +1 -1
- package/lib/rules/func-name-matching.js +1 -1
- package/lib/rules/func-names.js +1 -1
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/getter-return.js +1 -1
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +37 -5
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +2 -2
- package/lib/rules/keyword-spacing.js +1 -1
- package/lib/rules/line-comment-position.js +2 -2
- package/lib/rules/linebreak-style.js +1 -1
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/lines-between-class-members.js +1 -1
- package/lib/rules/max-len.js +1 -1
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/max-lines.js +1 -1
- package/lib/rules/max-params.js +1 -1
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +1 -1
- package/lib/rules/multiline-comment-style.js +1 -1
- package/lib/rules/multiline-ternary.js +1 -1
- package/lib/rules/new-parens.js +1 -1
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-per-chained-call.js +1 -1
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-async-promise-executor.js +33 -0
- package/lib/rules/no-catch-shadow.js +5 -2
- package/lib/rules/no-class-assign.js +1 -1
- package/lib/rules/no-cond-assign.js +1 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-console.js +1 -1
- package/lib/rules/no-const-assign.js +1 -1
- package/lib/rules/no-debugger.js +2 -10
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-else-return.js +1 -1
- package/lib/rules/no-empty-function.js +1 -1
- package/lib/rules/no-empty.js +1 -1
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-ex-assign.js +1 -1
- package/lib/rules/no-extend-native.js +1 -1
- package/lib/rules/no-extra-bind.js +1 -1
- package/lib/rules/no-extra-boolean-cast.js +1 -1
- package/lib/rules/no-extra-label.js +1 -1
- package/lib/rules/no-extra-parens.js +1 -1
- package/lib/rules/no-extra-semi.js +1 -1
- package/lib/rules/no-floating-decimal.js +1 -1
- package/lib/rules/no-func-assign.js +1 -1
- package/lib/rules/no-implicit-coercion.js +1 -1
- package/lib/rules/no-inline-comments.js +1 -1
- package/lib/rules/no-invalid-this.js +1 -1
- package/lib/rules/no-irregular-whitespace.js +1 -1
- package/lib/rules/no-label-var.js +1 -1
- package/lib/rules/no-labels.js +1 -1
- package/lib/rules/no-misleading-character-class.js +189 -0
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-multi-str.js +1 -1
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-restricted-properties.js +1 -1
- package/lib/rules/no-return-assign.js +1 -1
- package/lib/rules/no-return-await.js +1 -1
- package/lib/rules/no-self-assign.js +1 -1
- package/lib/rules/no-sequences.js +1 -1
- package/lib/rules/no-shadow.js +1 -1
- package/lib/rules/no-this-before-super.js +1 -1
- package/lib/rules/no-throw-literal.js +1 -1
- package/lib/rules/no-trailing-spaces.js +1 -1
- package/lib/rules/no-undef-init.js +1 -1
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unmodified-loop-condition.js +2 -3
- package/lib/rules/no-unneeded-ternary.js +1 -1
- package/lib/rules/no-unsafe-negation.js +1 -1
- package/lib/rules/no-unused-vars.js +1 -1
- package/lib/rules/no-useless-call.js +1 -1
- package/lib/rules/no-useless-computed-key.js +1 -1
- package/lib/rules/no-useless-concat.js +1 -1
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-useless-return.js +2 -11
- package/lib/rules/no-var.js +1 -1
- package/lib/rules/no-warning-comments.js +1 -1
- package/lib/rules/no-whitespace-before-property.js +1 -1
- package/lib/rules/object-curly-newline.js +1 -1
- package/lib/rules/object-curly-spacing.js +1 -1
- package/lib/rules/object-shorthand.js +1 -1
- package/lib/rules/operator-assignment.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padding-line-between-statements.js +2 -2
- package/lib/rules/prefer-const.js +3 -12
- package/lib/rules/prefer-object-spread.js +154 -197
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-spread.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/radix.js +1 -1
- package/lib/rules/require-atomic-updates.js +239 -0
- package/lib/rules/require-await.js +1 -1
- package/lib/rules/require-unicode-regexp.js +65 -0
- package/lib/rules/semi-spacing.js +1 -1
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +1 -1
- package/lib/rules/sort-keys.js +2 -2
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/space-before-function-paren.js +1 -1
- package/lib/rules/space-in-parens.js +1 -1
- package/lib/rules/space-unary-ops.js +1 -1
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/strict.js +1 -1
- package/lib/rules/switch-colon-spacing.js +1 -1
- package/lib/rules/symbol-description.js +1 -1
- package/lib/rules/template-curly-spacing.js +1 -1
- package/lib/rules/valid-jsdoc.js +1 -1
- package/lib/rules/wrap-iife.js +1 -1
- package/lib/rules/wrap-regex.js +8 -4
- package/lib/rules/yoda.js +1 -1
- package/lib/testers/rule-tester.js +3 -5
- package/lib/token-store/index.js +1 -1
- package/lib/{ast-utils.js → util/ast-utils.js} +0 -0
- package/lib/{file-finder.js → util/file-finder.js} +0 -0
- package/lib/util/fix-tracker.js +1 -1
- package/lib/util/{glob-util.js → glob-utils.js} +4 -4
- package/lib/util/lint-result-cache.js +146 -0
- package/lib/{logging.js → util/logging.js} +0 -0
- package/lib/util/naming.js +2 -2
- package/lib/util/node-event-generator.js +3 -3
- package/lib/util/{npm-util.js → npm-utils.js} +1 -1
- package/lib/util/{path-util.js → path-utils.js} +1 -1
- package/lib/util/{source-code-util.js → source-code-utils.js} +3 -3
- package/lib/util/source-code.js +1 -1
- package/lib/{timing.js → util/timing.js} +0 -0
- package/lib/util/unicode/index.js +11 -0
- package/lib/util/unicode/is-combining-character.js +13 -0
- package/lib/util/unicode/is-emoji-modifier.js +13 -0
- package/lib/util/unicode/is-regional-indicator-symbol.js +13 -0
- package/lib/util/unicode/is-surrogate-pair.js +14 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,81 @@
|
|
1
|
+
v5.3.0 - August 3, 2018
|
2
|
+
|
3
|
+
* dd6cb19 Docs: Updated no-return-await Rule Documentation (fixes #9695) (#10699) (Marla Foreman)
|
4
|
+
* 6009239 Chore: rename utils for consistency (#10727) (薛定谔的猫)
|
5
|
+
* 6eb972c New: require-unicode-regexp rule (fixes #9961) (#10698) (Toru Nagashima)
|
6
|
+
* 5c5d64d Fix: ignored-paths for Windows path (fixes #10687) (#10691) (Toru Nagashima)
|
7
|
+
* 5f6a765 Build: ensure URL fragments remain in documentation links (fixes #10717) (#10720) (Teddy Katz)
|
8
|
+
* 863aa78 Docs: add another example for when not to use no-await-in-loop (#10714) (Valeri Karpov)
|
9
|
+
* 6e78b7d Docs: remove links to terminated jscs.info domain (#10706) (Piotr Kuczynski)
|
10
|
+
* d56c39d Fix: ESLint cache no longer stops autofix (fixes #10679) (#10694) (Kevin Partington)
|
11
|
+
* 2cc3240 New: add no-misleading-character-class (fixes #10049) (#10511) (Toru Nagashima)
|
12
|
+
* 877f4b8 Fix: The "../.." folder is always ignored (fixes #10675) (#10682) (Sridhar)
|
13
|
+
* 5984820 Chore: Move lib/file-finder.js to lib/util/ (refs #10559) (#10695) (Kevin Partington)
|
14
|
+
* e37a593 Update: Fix incorrect default value for position (#10670) (Iulian Onofrei)
|
15
|
+
* 8084bfc Docs: change when not to use object spread (#10621) (Benny Powers)
|
16
|
+
* 7f496e2 Chore: Update require path for ast-utils (#10693) (Kevin Partington)
|
17
|
+
* 648a33a Chore: reorganize code structure of utilities (refs #10599) (#10680) (薛定谔的猫)
|
18
|
+
* f026fe1 Update: Fix 'function' in padding-line-between-statements (fixes #10487) (#10676) (Kevin Partington)
|
19
|
+
* c2bb8bb Docs: Remove superfluous object option sample code (#10652) (Iulian Onofrei)
|
20
|
+
* d34a13b Docs: add subheader in configuring/configuring-rules (#10686) (薛定谔的猫)
|
21
|
+
* d8aea28 Chore: rm unnecessary plugin in eslint-config-eslint (#10685) (薛定谔的猫)
|
22
|
+
* 9e76be7 Update: indent comments w/ nearby code if no blank lines (fixes #9733) (#10640) (Kevin Partington)
|
23
|
+
* 9e93d46 New: add no-async-promise-executor rule (fixes #10217) (#10661) (Teddy Katz)
|
24
|
+
* 5a2538c New: require-atomic-updates rule (fixes #10405) (#10655) (Teddy Katz)
|
25
|
+
* 8b83d2b Fix: always resolve default ignore patterns from CWD (fixes #9227) (#10638) (Teddy Katz)
|
26
|
+
* acb6658 Fix: ESLint crash with prefer-object-spread (fixes #10646) (#10649) (薛定谔的猫)
|
27
|
+
* 99fb7d3 Docs: fix misleading no-prototype-builtins description (#10666) (薛定谔的猫)
|
28
|
+
* 005b849 Docs: fix outdated description of `baseConfig` option (#10657) (Teddy Katz)
|
29
|
+
* 15a77c4 Docs: fix broken links (fixes eslint/eslint-jp#6) (#10658) (Toru Nagashima)
|
30
|
+
* 87cd344 Docs: Make marking a default option consistent with other rules (#10650) (Iulian Onofrei)
|
31
|
+
* 0cb5e3e Chore: Replace some function application with spread operators (#10645) (Kevin Partington)
|
32
|
+
* b6daf0e Docs: Remove superfluous section from no-unsafe-negation (#10648) (Iulian Onofrei)
|
33
|
+
* e1a3cac Chore: rm deprecated experimentalObjectRestSpread option in tests (#10647) (薛定谔的猫)
|
34
|
+
|
35
|
+
v5.2.0 - July 20, 2018
|
36
|
+
|
37
|
+
* 81283d0 Update: Cache files that failed linting (fixes #9948) (#10571) (Kevin Partington)
|
38
|
+
* 13cc63e Upgrade: ignore@4.0.2 (#10619) (Rouven Weßling)
|
39
|
+
* ac77a80 Chore: Fixing a call to Object.assign.apply in Linter (#10629) (Kevin Partington)
|
40
|
+
* 761f802 Upgrade: eslint-plugin-node to 7.0.1 (#10612) (Toru Nagashima)
|
41
|
+
* c517b2a Build: fix npm run perf failing(fixes #10577) (#10607) (薛定谔的猫)
|
42
|
+
* e596939 Chore: fix redundant equality check (#10617) (Toru Nagashima)
|
43
|
+
* 9f93d5f Docs: Updated Working with Custom Formatters (fixes #9950) (#10592) (Marla Foreman)
|
44
|
+
* 9aaf195 Chore: Extract lint result cache logic (refs #9948) (#10562) (Kevin Partington)
|
45
|
+
* 80b296e Build: package.json update for eslint-config-eslint release (ESLint Jenkins)
|
46
|
+
* e4e7ff2 Chore: fix error message in eslint-config-eslint (#10588) (薛定谔的猫)
|
47
|
+
* 1e88170 Chore: Move lib/logging and lib/timing to lib/util/ (refs #10559) (#10579) (Kevin Partington)
|
48
|
+
* 64dfa21 Build: Fix prerelease logic in blog post generation (fixes #10578) (#10581) (Kevin Partington)
|
49
|
+
* 0faf633 Chore: Simplify helper method in Linter tests (#10580) (Kevin Partington)
|
50
|
+
|
51
|
+
v5.1.0 - July 8, 2018
|
52
|
+
|
53
|
+
* 7328f99 Build: package.json update for eslint-config-eslint release (ESLint Jenkins)
|
54
|
+
* b161f6b Build: Include prerelease install info in release blog post (#10463) (Kevin Partington)
|
55
|
+
* b2df738 Fix: prefer-object-spread duplicated comma (fixes #10512, fixes #10532) (#10524) (Toru Nagashima)
|
56
|
+
* d8c3a25 Fix: wrap-regex doesn't work in some expression(fixes #10573) (#10576) (薛定谔的猫)
|
57
|
+
* 114f42e Docs: Clarify option defaults in max-lines-per-function docs (#10569) (Chris Harwood)
|
58
|
+
* 63f36f7 Fix: sort-keys in an object that contains spread (fixes #10261) (#10495) (katerberg)
|
59
|
+
* 601a5c4 Fix: Prefer-const rule crashing on array destructuring (fixes #10520) (#10527) (Michael Mason)
|
60
|
+
* 143890a Update: Adjust grammar of error/warnings fixable (#10546) (Matt Mischuk)
|
61
|
+
* 8ee39c5 Chore: small refactor config-validator (#10565) (薛定谔的猫)
|
62
|
+
* 100f1be Docs: add note about release issues to readme (#10572) (Teddy Katz)
|
63
|
+
* 02efeac Fix: do not fail on nested unknown operators (#10561) (Rubén Norte)
|
64
|
+
* 92b19ca Chore: use eslintrc overrides(dogfooding) (#10566) (薛定谔的猫)
|
65
|
+
* 076a6b6 Docs: add actionable fix to no-irregular-whitespace (#10558) (Matteo Collina)
|
66
|
+
* de663ec Docs: Only successfully linted files are cached (fixes #9802) (#10557) (Kevin Partington)
|
67
|
+
* f0e22fc Upgrade: globals@11.7.0 (#10497) (薛定谔的猫)
|
68
|
+
* 8a2ff2c Docs: adding a section about disable rules for some files (#10536) (Wellington Soares)
|
69
|
+
* f22a3f8 Docs: fix a word in no-implied-eval (#10539) (Dan Homola)
|
70
|
+
* 20d8bbd Docs: add missing paragraph about "custom parsers" (#10547) (Pig Fang)
|
71
|
+
* b7addf6 Update: deprecate no-catch-shadow (fixes #10466) (#10526) (Toru Nagashima)
|
72
|
+
* e862dc3 Fix: Remove autofixer for no-debugger (fixes #10242) (#10509) (Teddy Katz)
|
73
|
+
|
74
|
+
v5.0.1 - June 25, 2018
|
75
|
+
|
76
|
+
* 196c102 Fix: valid-jsdoc should allow optional returns for async (fixes #10386) (#10480) (Mark Banner)
|
77
|
+
* 4c823bd Docs: Fix max-lines-per-function correct code's max value (#10513) (Rhys Bower)
|
78
|
+
|
1
79
|
v5.0.0 - June 22, 2018
|
2
80
|
|
3
81
|
* 0feedfd New: Added max-lines-per-function rule (fixes #9842) (#10188) (peteward44)
|
package/README.md
CHANGED
@@ -157,7 +157,7 @@ Join our [Mailing List](https://groups.google.com/group/eslint) or [Chatroom](ht
|
|
157
157
|
|
158
158
|
## Releases
|
159
159
|
|
160
|
-
We have scheduled releases every two weeks on Friday or Saturday.
|
160
|
+
We have scheduled releases every two weeks on Friday or Saturday. You can follow a [release issue](https://github.com/eslint/eslint/issues?q=is%3Aopen+is%3Aissue+label%3Arelease) for updates about the scheduling of any particular release.
|
161
161
|
|
162
162
|
## Semantic Versioning Policy
|
163
163
|
|
@@ -83,6 +83,7 @@ module.exports = {
|
|
83
83
|
"newline-per-chained-call": "off",
|
84
84
|
"no-alert": "off",
|
85
85
|
"no-array-constructor": "off",
|
86
|
+
"no-async-promise-executor": "off",
|
86
87
|
"no-await-in-loop": "off",
|
87
88
|
"no-bitwise": "off",
|
88
89
|
"no-buffer-constructor": "off",
|
@@ -139,6 +140,7 @@ module.exports = {
|
|
139
140
|
"no-lonely-if": "off",
|
140
141
|
"no-loop-func": "off",
|
141
142
|
"no-magic-numbers": "off",
|
143
|
+
"no-misleading-character-class": "off",
|
142
144
|
"no-mixed-operators": "off",
|
143
145
|
"no-mixed-requires": "off",
|
144
146
|
"no-mixed-spaces-and-tabs": "error",
|
@@ -240,8 +242,10 @@ module.exports = {
|
|
240
242
|
"quote-props": "off",
|
241
243
|
quotes: "off",
|
242
244
|
radix: "off",
|
245
|
+
"require-atomic-updates": "off",
|
243
246
|
"require-await": "off",
|
244
247
|
"require-jsdoc": "off",
|
248
|
+
"require-unicode-regexp": "off",
|
245
249
|
"require-yield": "error",
|
246
250
|
"rest-spread-spacing": "off",
|
247
251
|
semi: "off",
|
package/lib/cli-engine.js
CHANGED
@@ -21,10 +21,9 @@ const fs = require("fs"),
|
|
21
21
|
Linter = require("./linter"),
|
22
22
|
IgnoredPaths = require("./ignored-paths"),
|
23
23
|
Config = require("./config"),
|
24
|
-
|
25
|
-
|
24
|
+
LintResultCache = require("./util/lint-result-cache"),
|
25
|
+
globUtils = require("./util/glob-utils"),
|
26
26
|
validator = require("./config/config-validator"),
|
27
|
-
stringify = require("json-stable-stringify-without-jsonify"),
|
28
27
|
hash = require("./util/hash"),
|
29
28
|
ModuleResolver = require("./util/module-resolver"),
|
30
29
|
naming = require("./util/naming"),
|
@@ -42,7 +41,7 @@ const resolver = new ModuleResolver();
|
|
42
41
|
* The options to configure a CLI engine with.
|
43
42
|
* @typedef {Object} CLIEngineOptions
|
44
43
|
* @property {boolean} allowInlineConfig Enable or disable inline configuration comments.
|
45
|
-
* @property {
|
44
|
+
* @property {Object} baseConfig Base config object, extended by all configs used with this CLIEngine instance
|
46
45
|
* @property {boolean} cache Enable result caching.
|
47
46
|
* @property {string} cacheLocation The cache file to use instead of .eslintcache.
|
48
47
|
* @property {string} configFile The configuration file to use.
|
@@ -359,8 +358,6 @@ function getCacheFile(cacheFile, cwd) {
|
|
359
358
|
return resolvedCacheFile;
|
360
359
|
}
|
361
360
|
|
362
|
-
const configHashCache = new WeakMap();
|
363
|
-
|
364
361
|
//------------------------------------------------------------------------------
|
365
362
|
// Public Interface
|
366
363
|
//------------------------------------------------------------------------------
|
@@ -403,18 +400,6 @@ class CLIEngine {
|
|
403
400
|
this.options = options;
|
404
401
|
this.linter = new Linter();
|
405
402
|
|
406
|
-
if (options.cache) {
|
407
|
-
const cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
|
408
|
-
|
409
|
-
/**
|
410
|
-
* Cache used to avoid operating on files that haven't changed since the
|
411
|
-
* last successful execution (e.g., file passed linting with no errors and
|
412
|
-
* no warnings).
|
413
|
-
* @type {Object}
|
414
|
-
*/
|
415
|
-
this._fileCache = fileEntryCache.create(cacheFile);
|
416
|
-
}
|
417
|
-
|
418
403
|
// load in additional rules
|
419
404
|
if (this.options.rulePaths) {
|
420
405
|
const cwd = this.options.cwd;
|
@@ -434,6 +419,17 @@ class CLIEngine {
|
|
434
419
|
}
|
435
420
|
|
436
421
|
this.config = new Config(this.options, this.linter);
|
422
|
+
|
423
|
+
if (this.options.cache) {
|
424
|
+
const cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
|
425
|
+
|
426
|
+
/**
|
427
|
+
* Cache used to avoid operating on files that haven't changed since the
|
428
|
+
* last successful execution.
|
429
|
+
* @type {Object}
|
430
|
+
*/
|
431
|
+
this._lintResultCache = new LintResultCache(cacheFile, this.config);
|
432
|
+
}
|
437
433
|
}
|
438
434
|
|
439
435
|
getRules() {
|
@@ -496,7 +492,7 @@ class CLIEngine {
|
|
496
492
|
* @returns {string[]} The equivalent glob patterns.
|
497
493
|
*/
|
498
494
|
resolveFileGlobPatterns(patterns) {
|
499
|
-
return
|
495
|
+
return globUtils.resolveFileGlobPatterns(patterns.filter(Boolean), this.options);
|
500
496
|
}
|
501
497
|
|
502
498
|
/**
|
@@ -506,7 +502,7 @@ class CLIEngine {
|
|
506
502
|
*/
|
507
503
|
executeOnFiles(patterns) {
|
508
504
|
const options = this.options,
|
509
|
-
|
505
|
+
lintResultCache = this._lintResultCache,
|
510
506
|
configHelper = this.config;
|
511
507
|
const cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
|
512
508
|
|
@@ -514,49 +510,26 @@ class CLIEngine {
|
|
514
510
|
fs.unlinkSync(cacheFile);
|
515
511
|
}
|
516
512
|
|
517
|
-
/**
|
518
|
-
* Calculates the hash of the config file used to validate a given file
|
519
|
-
* @param {string} filename The path of the file to retrieve a config object for to calculate the hash
|
520
|
-
* @returns {string} the hash of the config
|
521
|
-
*/
|
522
|
-
function hashOfConfigFor(filename) {
|
523
|
-
const config = configHelper.getConfig(filename);
|
524
|
-
|
525
|
-
if (!configHashCache.has(config)) {
|
526
|
-
configHashCache.set(config, hash(`${pkg.version}_${stringify(config)}`));
|
527
|
-
}
|
528
|
-
|
529
|
-
return configHashCache.get(config);
|
530
|
-
}
|
531
|
-
|
532
513
|
const startTime = Date.now();
|
533
|
-
const fileList =
|
514
|
+
const fileList = globUtils.listFilesToProcess(patterns, options);
|
534
515
|
const results = fileList.map(fileInfo => {
|
535
516
|
if (fileInfo.ignored) {
|
536
517
|
return createIgnoreResult(fileInfo.filename, options.cwd);
|
537
518
|
}
|
538
519
|
|
539
520
|
if (options.cache) {
|
521
|
+
const cachedLintResults = lintResultCache.getCachedLintResults(fileInfo.filename);
|
540
522
|
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
debug(`Skipping file since hasn't changed: ${fileInfo.filename}`);
|
552
|
-
|
553
|
-
/*
|
554
|
-
* Add the the cached results (always will be 0 error and
|
555
|
-
* 0 warnings). We should not cache results for files that
|
556
|
-
* failed, in order to guarantee that next execution will
|
557
|
-
* process those files as well.
|
558
|
-
*/
|
559
|
-
return descriptor.meta.results;
|
523
|
+
if (cachedLintResults) {
|
524
|
+
const resultHadMessages = cachedLintResults.messages && cachedLintResults.messages.length;
|
525
|
+
|
526
|
+
if (resultHadMessages && options.fix) {
|
527
|
+
debug(`Reprocessing cached file to allow autofix: ${fileInfo.filename}`);
|
528
|
+
} else {
|
529
|
+
debug(`Skipping file since it hasn't changed: ${fileInfo.filename}`);
|
530
|
+
|
531
|
+
return cachedLintResults;
|
532
|
+
}
|
560
533
|
}
|
561
534
|
}
|
562
535
|
|
@@ -567,30 +540,18 @@ class CLIEngine {
|
|
567
540
|
|
568
541
|
if (options.cache) {
|
569
542
|
results.forEach(result => {
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
} else {
|
579
|
-
|
580
|
-
/*
|
581
|
-
* since the file passed we store the result here
|
582
|
-
* TODO: it might not be necessary to store the results list in the cache,
|
583
|
-
* since it should always be 0 errors/warnings
|
584
|
-
*/
|
585
|
-
const descriptor = fileCache.getFileDescriptor(result.filePath);
|
586
|
-
|
587
|
-
descriptor.meta.hashOfConfig = hashOfConfigFor(result.filePath);
|
588
|
-
descriptor.meta.results = result;
|
589
|
-
}
|
543
|
+
|
544
|
+
/*
|
545
|
+
* Store the lint result in the LintResultCache.
|
546
|
+
* NOTE: The LintResultCache will remove the file source and any
|
547
|
+
* other properties that are difficult to serialize, and will
|
548
|
+
* hydrate those properties back in on future lint runs.
|
549
|
+
*/
|
550
|
+
lintResultCache.setCachedLintResults(result.filePath, result);
|
590
551
|
});
|
591
552
|
|
592
553
|
// persist the cache to disk
|
593
|
-
|
554
|
+
lintResultCache.reconcile();
|
594
555
|
}
|
595
556
|
|
596
557
|
const stats = calculateStatsPerRun(results);
|
package/lib/cli.js
CHANGED
@@ -14,7 +14,7 @@ const assert = require("assert"),
|
|
14
14
|
CodePathSegment = require("./code-path-segment"),
|
15
15
|
IdGenerator = require("./id-generator"),
|
16
16
|
debug = require("./debug-helpers"),
|
17
|
-
astUtils = require("../ast-utils");
|
17
|
+
astUtils = require("../util/ast-utils");
|
18
18
|
|
19
19
|
//------------------------------------------------------------------------------
|
20
20
|
// Helpers
|
@@ -60,7 +60,7 @@ function isForkingByTrueOrFalse(node) {
|
|
60
60
|
return parent.test === node;
|
61
61
|
|
62
62
|
case "LogicalExpression":
|
63
|
-
return
|
63
|
+
return isHandledLogicalOperator(parent.operator);
|
64
64
|
|
65
65
|
default:
|
66
66
|
return false;
|
@@ -16,11 +16,11 @@ const util = require("util"),
|
|
16
16
|
autoconfig = require("./autoconfig.js"),
|
17
17
|
ConfigFile = require("./config-file"),
|
18
18
|
ConfigOps = require("./config-ops"),
|
19
|
-
getSourceCodeOfFiles = require("../util/source-code-
|
19
|
+
getSourceCodeOfFiles = require("../util/source-code-utils").getSourceCodeOfFiles,
|
20
20
|
ModuleResolver = require("../util/module-resolver"),
|
21
|
-
|
21
|
+
npmUtils = require("../util/npm-utils"),
|
22
22
|
recConfig = require("../../conf/eslint-recommended"),
|
23
|
-
log = require("../logging");
|
23
|
+
log = require("../util/logging");
|
24
24
|
|
25
25
|
const debug = require("debug")("eslint:config-initializer");
|
26
26
|
|
@@ -61,7 +61,7 @@ function writeFile(config, format) {
|
|
61
61
|
/**
|
62
62
|
* Get the peer dependencies of the given module.
|
63
63
|
* This adds the gotten value to cache at the first time, then reuses it.
|
64
|
-
* In a process, this function is called twice, but `
|
64
|
+
* In a process, this function is called twice, but `npmUtils.fetchPeerDependencies` needs to access network which is relatively slow.
|
65
65
|
* @param {string} moduleName The module name to get.
|
66
66
|
* @returns {Object} The peer dependencies of the given module.
|
67
67
|
* This object is the object of `peerDependencies` field of `package.json`.
|
@@ -73,7 +73,7 @@ function getPeerDependencies(moduleName) {
|
|
73
73
|
if (!result) {
|
74
74
|
log.info(`Checking peerDependencies of ${moduleName}`);
|
75
75
|
|
76
|
-
result =
|
76
|
+
result = npmUtils.fetchPeerDependencies(moduleName);
|
77
77
|
getPeerDependencies.cache.set(moduleName, result);
|
78
78
|
}
|
79
79
|
|
@@ -109,7 +109,7 @@ function getModulesList(config, installESLint) {
|
|
109
109
|
if (installESLint === false) {
|
110
110
|
delete modules.eslint;
|
111
111
|
} else {
|
112
|
-
const installStatus =
|
112
|
+
const installStatus = npmUtils.checkDevDeps(["eslint"]);
|
113
113
|
|
114
114
|
// Mark to show messages if it's new installation of eslint.
|
115
115
|
if (installStatus.eslint === false) {
|
@@ -373,7 +373,7 @@ function hasESLintVersionConflict(answers) {
|
|
373
373
|
*/
|
374
374
|
function installModules(modules) {
|
375
375
|
log.info(`Installing ${modules.join(", ")}`);
|
376
|
-
|
376
|
+
npmUtils.installSyncSaveDev(modules);
|
377
377
|
}
|
378
378
|
|
379
379
|
/* istanbul ignore next: no need to test inquirer */
|
@@ -438,7 +438,7 @@ function promptUser() {
|
|
438
438
|
{ name: "Google (https://github.com/google/eslint-config-google)", value: "google" }
|
439
439
|
],
|
440
440
|
when(answers) {
|
441
|
-
answers.packageJsonExists =
|
441
|
+
answers.packageJsonExists = npmUtils.checkPackageJson();
|
442
442
|
return answers.source === "guide" && answers.packageJsonExists;
|
443
443
|
}
|
444
444
|
},
|
@@ -23,10 +23,15 @@ const ruleValidators = new WeakMap();
|
|
23
23
|
let validateSchema;
|
24
24
|
|
25
25
|
// Defitions for deprecation warnings.
|
26
|
-
const deprecationWarningMessages =
|
26
|
+
const deprecationWarningMessages = {
|
27
27
|
ESLINT_LEGACY_ECMAFEATURES: "The 'ecmaFeatures' config file property is deprecated, and has no effect.",
|
28
28
|
ESLINT_LEGACY_OBJECT_REST_SPREAD: "The 'parserOptions.ecmaFeatures.experimentalObjectRestSpread' option is deprecated. Use 'parserOptions.ecmaVersion' instead."
|
29
|
-
}
|
29
|
+
};
|
30
|
+
const severityMap = {
|
31
|
+
error: 2,
|
32
|
+
warn: 1,
|
33
|
+
off: 0
|
34
|
+
};
|
30
35
|
|
31
36
|
/**
|
32
37
|
* Gets a complete options schema for a rule.
|
@@ -65,12 +70,14 @@ function getRuleOptionsSchema(rule) {
|
|
65
70
|
*/
|
66
71
|
function validateRuleSeverity(options) {
|
67
72
|
const severity = Array.isArray(options) ? options[0] : options;
|
73
|
+
const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
|
68
74
|
|
69
|
-
if (
|
70
|
-
|
75
|
+
if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
|
76
|
+
return normSeverity;
|
71
77
|
}
|
72
78
|
|
73
|
-
|
79
|
+
throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/g, "\"").replace(/\n/g, "")}').\n`);
|
80
|
+
|
74
81
|
}
|
75
82
|
|
76
83
|
/**
|
@@ -116,7 +123,7 @@ function validateRuleOptions(rule, ruleId, options, source) {
|
|
116
123
|
try {
|
117
124
|
const severity = validateRuleSeverity(options);
|
118
125
|
|
119
|
-
if (severity !== 0
|
126
|
+
if (severity !== 0) {
|
120
127
|
validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
|
121
128
|
}
|
122
129
|
} catch (err) {
|
package/lib/config.js
CHANGED
@@ -15,7 +15,7 @@ const path = require("path"),
|
|
15
15
|
ConfigFile = require("./config/config-file"),
|
16
16
|
ConfigCache = require("./config/config-cache"),
|
17
17
|
Plugins = require("./config/plugins"),
|
18
|
-
FileFinder = require("./file-finder"),
|
18
|
+
FileFinder = require("./util/file-finder"),
|
19
19
|
isResolvable = require("is-resolvable");
|
20
20
|
|
21
21
|
const debug = require("debug")("eslint:config");
|
@@ -89,7 +89,7 @@ module.exports = function(results) {
|
|
89
89
|
|
90
90
|
if (fixableErrorCount > 0 || fixableWarningCount > 0) {
|
91
91
|
output += chalk[summaryColor].bold([
|
92
|
-
" ", fixableErrorCount, pluralize(" error", fixableErrorCount), "
|
92
|
+
" ", fixableErrorCount, pluralize(" error", fixableErrorCount), " and ",
|
93
93
|
fixableWarningCount, pluralize(" warning", fixableWarningCount),
|
94
94
|
" potentially fixable with the `--fix` option.\n"
|
95
95
|
].join(""));
|