eslint 5.1.0 → 5.5.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 +72 -0
- package/conf/eslint-recommended.js +4 -0
- package/lib/cli-engine.js +38 -78
- package/lib/cli.js +1 -1
- package/lib/code-path-analysis/code-path-analyzer.js +1 -1
- package/lib/config/config-initializer.js +8 -8
- package/lib/config.js +1 -1
- package/lib/formatters/codeframe.js +2 -2
- 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/camelcase.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 +2 -2
- package/lib/rules/complexity.js +3 -3
- 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/for-direction.js +5 -2
- package/lib/rules/func-call-spacing.js +8 -4
- package/lib/rules/func-name-matching.js +13 -7
- package/lib/rules/func-names.js +8 -4
- package/lib/rules/func-style.js +8 -4
- package/lib/rules/function-paren-newline.js +12 -6
- package/lib/rules/generator-star-spacing.js +18 -9
- package/lib/rules/getter-return.js +8 -6
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +43 -7
- 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 +3 -3
- 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-depth.js +2 -2
- package/lib/rules/max-len.js +1 -1
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/max-lines.js +2 -2
- package/lib/rules/max-nested-callbacks.js +2 -2
- package/lib/rules/max-params.js +5 -4
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +3 -3
- 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 +1 -1
- 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-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 +2 -2
- 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-magic-numbers.js +7 -3
- 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-globals.js +1 -1
- package/lib/rules/no-restricted-imports.js +1 -1
- package/lib/rules/no-restricted-modules.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/one-var.js +6 -6
- package/lib/rules/operator-assignment.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padded-blocks.js +6 -6
- package/lib/rules/padding-line-between-statements.js +2 -2
- package/lib/rules/prefer-const.js +2 -11
- package/lib/rules/prefer-object-spread.js +9 -3
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-reflect.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 +3 -3
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +1 -1
- package/lib/rules/sort-keys.js +1 -1
- 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 +2 -2
- 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/yoda.js +1 -1
- package/lib/testers/rule-tester.js +8 -10
- 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} +2 -2
- 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-fixer.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 +14 -15
- package/lib/rules/.eslintrc.yml +0 -4
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,75 @@
|
|
1
|
+
v5.5.0 - August 31, 2018
|
2
|
+
|
3
|
+
* 6e110e6 Fix: camelcase duplicate warning bug (fixes #10801) (#10802) (Julian Rosse)
|
4
|
+
* 5103ee7 Docs: Add Brackets integration (#10813) (Jan Pilzer)
|
5
|
+
* b61d2cd Update: max-params to only highlight function header (#10815) (Ian Obermiller)
|
6
|
+
* 2b2f11d Upgrade: babel-code-frame to version 7 (#10808) (Rouven Weßling)
|
7
|
+
* 2824d43 Docs: fix comment placement in a code example (#10799) (Vse Mozhet Byt)
|
8
|
+
* 10690b7 Upgrade: devdeps and deps to latest (#10622) (薛定谔的猫)
|
9
|
+
* 80c8598 Docs: gitignore syntax updates (fixes #8139) (#10776) (Gustavo Santana)
|
10
|
+
* cb946af Chore: use meta.messages in some rules (1/4) (#10764) (薛定谔的猫)
|
11
|
+
|
12
|
+
v5.4.0 - August 17, 2018
|
13
|
+
|
14
|
+
* a70909f Docs: Add jscs-dev.github.io links (#10771) (Gustavo Santana)
|
15
|
+
* 034690f Fix: no-invalid-meta crashes for non Object values (fixes #10750) (#10753) (Sandeep Kumar Ranka)
|
16
|
+
* 11a462d Docs: Broken jscs.info URLs (fixes #10732) (#10770) (Gustavo Santana)
|
17
|
+
* 985567d Chore: rm unused dep string.prototype.matchall (#10756) (薛定谔的猫)
|
18
|
+
* f3d8454 Update: Improve no-extra-parens error message (#10748) (Timo Tijhof)
|
19
|
+
* 562a03f Fix: consistent-docs-url crashes if meta.docs is empty (fixes #10722) (#10749) (Sandeep Kumar Ranka)
|
20
|
+
* 6492233 Chore: enable no-prototype-builtins in codebase (fixes #10660) (#10664) (薛定谔的猫)
|
21
|
+
* 137140f Chore: use eslintrc overrides (#10677) (薛定谔的猫)
|
22
|
+
|
23
|
+
v5.3.0 - August 3, 2018
|
24
|
+
|
25
|
+
* dd6cb19 Docs: Updated no-return-await Rule Documentation (fixes #9695) (#10699) (Marla Foreman)
|
26
|
+
* 6009239 Chore: rename utils for consistency (#10727) (薛定谔的猫)
|
27
|
+
* 6eb972c New: require-unicode-regexp rule (fixes #9961) (#10698) (Toru Nagashima)
|
28
|
+
* 5c5d64d Fix: ignored-paths for Windows path (fixes #10687) (#10691) (Toru Nagashima)
|
29
|
+
* 5f6a765 Build: ensure URL fragments remain in documentation links (fixes #10717) (#10720) (Teddy Katz)
|
30
|
+
* 863aa78 Docs: add another example for when not to use no-await-in-loop (#10714) (Valeri Karpov)
|
31
|
+
* 6e78b7d Docs: remove links to terminated jscs.info domain (#10706) (Piotr Kuczynski)
|
32
|
+
* d56c39d Fix: ESLint cache no longer stops autofix (fixes #10679) (#10694) (Kevin Partington)
|
33
|
+
* 2cc3240 New: add no-misleading-character-class (fixes #10049) (#10511) (Toru Nagashima)
|
34
|
+
* 877f4b8 Fix: The "../.." folder is always ignored (fixes #10675) (#10682) (Sridhar)
|
35
|
+
* 5984820 Chore: Move lib/file-finder.js to lib/util/ (refs #10559) (#10695) (Kevin Partington)
|
36
|
+
* e37a593 Update: Fix incorrect default value for position (#10670) (Iulian Onofrei)
|
37
|
+
* 8084bfc Docs: change when not to use object spread (#10621) (Benny Powers)
|
38
|
+
* 7f496e2 Chore: Update require path for ast-utils (#10693) (Kevin Partington)
|
39
|
+
* 648a33a Chore: reorganize code structure of utilities (refs #10599) (#10680) (薛定谔的猫)
|
40
|
+
* f026fe1 Update: Fix 'function' in padding-line-between-statements (fixes #10487) (#10676) (Kevin Partington)
|
41
|
+
* c2bb8bb Docs: Remove superfluous object option sample code (#10652) (Iulian Onofrei)
|
42
|
+
* d34a13b Docs: add subheader in configuring/configuring-rules (#10686) (薛定谔的猫)
|
43
|
+
* d8aea28 Chore: rm unnecessary plugin in eslint-config-eslint (#10685) (薛定谔的猫)
|
44
|
+
* 9e76be7 Update: indent comments w/ nearby code if no blank lines (fixes #9733) (#10640) (Kevin Partington)
|
45
|
+
* 9e93d46 New: add no-async-promise-executor rule (fixes #10217) (#10661) (Teddy Katz)
|
46
|
+
* 5a2538c New: require-atomic-updates rule (fixes #10405) (#10655) (Teddy Katz)
|
47
|
+
* 8b83d2b Fix: always resolve default ignore patterns from CWD (fixes #9227) (#10638) (Teddy Katz)
|
48
|
+
* acb6658 Fix: ESLint crash with prefer-object-spread (fixes #10646) (#10649) (薛定谔的猫)
|
49
|
+
* 99fb7d3 Docs: fix misleading no-prototype-builtins description (#10666) (薛定谔的猫)
|
50
|
+
* 005b849 Docs: fix outdated description of `baseConfig` option (#10657) (Teddy Katz)
|
51
|
+
* 15a77c4 Docs: fix broken links (fixes eslint/eslint-jp#6) (#10658) (Toru Nagashima)
|
52
|
+
* 87cd344 Docs: Make marking a default option consistent with other rules (#10650) (Iulian Onofrei)
|
53
|
+
* 0cb5e3e Chore: Replace some function application with spread operators (#10645) (Kevin Partington)
|
54
|
+
* b6daf0e Docs: Remove superfluous section from no-unsafe-negation (#10648) (Iulian Onofrei)
|
55
|
+
* e1a3cac Chore: rm deprecated experimentalObjectRestSpread option in tests (#10647) (薛定谔的猫)
|
56
|
+
|
57
|
+
v5.2.0 - July 20, 2018
|
58
|
+
|
59
|
+
* 81283d0 Update: Cache files that failed linting (fixes #9948) (#10571) (Kevin Partington)
|
60
|
+
* 13cc63e Upgrade: ignore@4.0.2 (#10619) (Rouven Weßling)
|
61
|
+
* ac77a80 Chore: Fixing a call to Object.assign.apply in Linter (#10629) (Kevin Partington)
|
62
|
+
* 761f802 Upgrade: eslint-plugin-node to 7.0.1 (#10612) (Toru Nagashima)
|
63
|
+
* c517b2a Build: fix npm run perf failing(fixes #10577) (#10607) (薛定谔的猫)
|
64
|
+
* e596939 Chore: fix redundant equality check (#10617) (Toru Nagashima)
|
65
|
+
* 9f93d5f Docs: Updated Working with Custom Formatters (fixes #9950) (#10592) (Marla Foreman)
|
66
|
+
* 9aaf195 Chore: Extract lint result cache logic (refs #9948) (#10562) (Kevin Partington)
|
67
|
+
* 80b296e Build: package.json update for eslint-config-eslint release (ESLint Jenkins)
|
68
|
+
* e4e7ff2 Chore: fix error message in eslint-config-eslint (#10588) (薛定谔的猫)
|
69
|
+
* 1e88170 Chore: Move lib/logging and lib/timing to lib/util/ (refs #10559) (#10579) (Kevin Partington)
|
70
|
+
* 64dfa21 Build: Fix prerelease logic in blog post generation (fixes #10578) (#10581) (Kevin Partington)
|
71
|
+
* 0faf633 Chore: Simplify helper method in Linter tests (#10580) (Kevin Partington)
|
72
|
+
|
1
73
|
v5.1.0 - July 8, 2018
|
2
74
|
|
3
75
|
* 7328f99 Build: package.json update for eslint-config-eslint release (ESLint Jenkins)
|
@@ -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,17 +21,15 @@ 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"),
|
31
30
|
pkg = require("../package.json");
|
32
31
|
|
33
32
|
const debug = require("debug")("eslint:cli-engine");
|
34
|
-
|
35
33
|
const resolver = new ModuleResolver();
|
36
34
|
|
37
35
|
//------------------------------------------------------------------------------
|
@@ -42,7 +40,7 @@ const resolver = new ModuleResolver();
|
|
42
40
|
* The options to configure a CLI engine with.
|
43
41
|
* @typedef {Object} CLIEngineOptions
|
44
42
|
* @property {boolean} allowInlineConfig Enable or disable inline configuration comments.
|
45
|
-
* @property {
|
43
|
+
* @property {Object} baseConfig Base config object, extended by all configs used with this CLIEngine instance
|
46
44
|
* @property {boolean} cache Enable result caching.
|
47
45
|
* @property {string} cacheLocation The cache file to use instead of .eslintcache.
|
48
46
|
* @property {string} configFile The configuration file to use.
|
@@ -359,8 +357,6 @@ function getCacheFile(cacheFile, cwd) {
|
|
359
357
|
return resolvedCacheFile;
|
360
358
|
}
|
361
359
|
|
362
|
-
const configHashCache = new WeakMap();
|
363
|
-
|
364
360
|
//------------------------------------------------------------------------------
|
365
361
|
// Public Interface
|
366
362
|
//------------------------------------------------------------------------------
|
@@ -403,18 +399,6 @@ class CLIEngine {
|
|
403
399
|
this.options = options;
|
404
400
|
this.linter = new Linter();
|
405
401
|
|
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
402
|
// load in additional rules
|
419
403
|
if (this.options.rulePaths) {
|
420
404
|
const cwd = this.options.cwd;
|
@@ -434,6 +418,17 @@ class CLIEngine {
|
|
434
418
|
}
|
435
419
|
|
436
420
|
this.config = new Config(this.options, this.linter);
|
421
|
+
|
422
|
+
if (this.options.cache) {
|
423
|
+
const cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
|
424
|
+
|
425
|
+
/**
|
426
|
+
* Cache used to avoid operating on files that haven't changed since the
|
427
|
+
* last successful execution.
|
428
|
+
* @type {Object}
|
429
|
+
*/
|
430
|
+
this._lintResultCache = new LintResultCache(cacheFile, this.config);
|
431
|
+
}
|
437
432
|
}
|
438
433
|
|
439
434
|
getRules() {
|
@@ -473,7 +468,7 @@ class CLIEngine {
|
|
473
468
|
* @returns {void}
|
474
469
|
*/
|
475
470
|
static outputFixes(report) {
|
476
|
-
report.results.filter(result =>
|
471
|
+
report.results.filter(result => Object.prototype.hasOwnProperty.call(result, "output")).forEach(result => {
|
477
472
|
fs.writeFileSync(result.filePath, result.output);
|
478
473
|
});
|
479
474
|
}
|
@@ -496,7 +491,7 @@ class CLIEngine {
|
|
496
491
|
* @returns {string[]} The equivalent glob patterns.
|
497
492
|
*/
|
498
493
|
resolveFileGlobPatterns(patterns) {
|
499
|
-
return
|
494
|
+
return globUtils.resolveFileGlobPatterns(patterns.filter(Boolean), this.options);
|
500
495
|
}
|
501
496
|
|
502
497
|
/**
|
@@ -506,7 +501,7 @@ class CLIEngine {
|
|
506
501
|
*/
|
507
502
|
executeOnFiles(patterns) {
|
508
503
|
const options = this.options,
|
509
|
-
|
504
|
+
lintResultCache = this._lintResultCache,
|
510
505
|
configHelper = this.config;
|
511
506
|
const cacheFile = getCacheFile(this.options.cacheLocation || this.options.cacheFile, this.options.cwd);
|
512
507
|
|
@@ -514,49 +509,26 @@ class CLIEngine {
|
|
514
509
|
fs.unlinkSync(cacheFile);
|
515
510
|
}
|
516
511
|
|
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
512
|
const startTime = Date.now();
|
533
|
-
const fileList =
|
513
|
+
const fileList = globUtils.listFilesToProcess(patterns, options);
|
534
514
|
const results = fileList.map(fileInfo => {
|
535
515
|
if (fileInfo.ignored) {
|
536
516
|
return createIgnoreResult(fileInfo.filename, options.cwd);
|
537
517
|
}
|
538
518
|
|
539
519
|
if (options.cache) {
|
520
|
+
const cachedLintResults = lintResultCache.getCachedLintResults(fileInfo.filename);
|
540
521
|
|
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;
|
522
|
+
if (cachedLintResults) {
|
523
|
+
const resultHadMessages = cachedLintResults.messages && cachedLintResults.messages.length;
|
524
|
+
|
525
|
+
if (resultHadMessages && options.fix) {
|
526
|
+
debug(`Reprocessing cached file to allow autofix: ${fileInfo.filename}`);
|
527
|
+
} else {
|
528
|
+
debug(`Skipping file since it hasn't changed: ${fileInfo.filename}`);
|
529
|
+
|
530
|
+
return cachedLintResults;
|
531
|
+
}
|
560
532
|
}
|
561
533
|
}
|
562
534
|
|
@@ -567,30 +539,18 @@ class CLIEngine {
|
|
567
539
|
|
568
540
|
if (options.cache) {
|
569
541
|
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
|
-
}
|
542
|
+
|
543
|
+
/*
|
544
|
+
* Store the lint result in the LintResultCache.
|
545
|
+
* NOTE: The LintResultCache will remove the file source and any
|
546
|
+
* other properties that are difficult to serialize, and will
|
547
|
+
* hydrate those properties back in on future lint runs.
|
548
|
+
*/
|
549
|
+
lintResultCache.setCachedLintResults(result.filePath, result);
|
590
550
|
});
|
591
551
|
|
592
552
|
// persist the cache to disk
|
593
|
-
|
553
|
+
lintResultCache.reconcile();
|
594
554
|
}
|
595
555
|
|
596
556
|
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
|
@@ -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
|
},
|
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");
|
@@ -5,7 +5,7 @@
|
|
5
5
|
"use strict";
|
6
6
|
|
7
7
|
const chalk = require("chalk");
|
8
|
-
const
|
8
|
+
const { codeFrameColumns } = require("@babel/code-frame");
|
9
9
|
const path = require("path");
|
10
10
|
|
11
11
|
//------------------------------------------------------------------------------
|
@@ -63,7 +63,7 @@ function formatMessage(message, parentResult) {
|
|
63
63
|
|
64
64
|
if (sourceCode) {
|
65
65
|
result.push(
|
66
|
-
|
66
|
+
codeFrameColumns(sourceCode, { start: { line: message.line, column: message.column } }, { highlightCode: false })
|
67
67
|
);
|
68
68
|
}
|
69
69
|
|