eslint 5.14.1 → 5.15.3
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 +51 -0
- package/README.md +2 -2
- package/lib/built-in-rules-index.js +1 -0
- package/lib/cli-engine.js +2 -2
- package/lib/config/config-file.js +3 -3
- package/lib/config/config-initializer.js +1 -1
- package/lib/config/config-validator.js +13 -13
- package/lib/config/plugins.js +1 -1
- package/lib/formatters/codeframe.js +1 -1
- package/lib/formatters/stylish.js +2 -2
- package/lib/linter.js +23 -8
- package/lib/rules/array-bracket-newline.js +2 -4
- package/lib/rules/array-callback-return.js +2 -2
- package/lib/rules/array-element-newline.js +2 -4
- package/lib/rules/arrow-body-style.js +2 -2
- package/lib/rules/camelcase.js +2 -2
- package/lib/rules/capitalized-comments.js +12 -17
- package/lib/rules/complexity.js +6 -5
- package/lib/rules/curly.js +1 -1
- package/lib/rules/default-case.js +2 -2
- package/lib/rules/dot-notation.js +2 -2
- package/lib/rules/eol-last.js +1 -1
- package/lib/rules/eqeqeq.js +1 -2
- package/lib/rules/func-call-spacing.js +3 -4
- package/lib/rules/getter-return.js +1 -1
- package/lib/rules/handle-callback-err.js +1 -1
- package/lib/rules/id-match.js +1 -1
- package/lib/rules/implicit-arrow-linebreak.js +17 -172
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +2 -2
- package/lib/rules/init-declarations.js +1 -2
- package/lib/rules/jsx-quotes.js +2 -2
- package/lib/rules/key-spacing.js +28 -55
- package/lib/rules/keyword-spacing.js +7 -7
- package/lib/rules/line-comment-position.js +5 -7
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/max-depth.js +6 -5
- package/lib/rules/max-len.js +4 -4
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/max-lines.js +4 -7
- package/lib/rules/max-nested-callbacks.js +6 -5
- package/lib/rules/max-params.js +6 -5
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +6 -5
- package/lib/rules/multiline-comment-style.js +9 -9
- package/lib/rules/new-cap.js +2 -2
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-caller.js +1 -1
- package/lib/rules/no-dupe-keys.js +2 -2
- package/lib/rules/no-else-return.js +2 -2
- package/lib/rules/no-empty-character-class.js +1 -1
- package/lib/rules/no-extra-parens.js +11 -5
- package/lib/rules/no-fallthrough.js +2 -2
- package/lib/rules/no-implicit-coercion.js +1 -1
- package/lib/rules/no-implied-eval.js +1 -1
- package/lib/rules/no-invalid-regexp.js +2 -2
- package/lib/rules/no-irregular-whitespace.js +3 -3
- package/lib/rules/no-lonely-if.js +1 -1
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-mixed-requires.js +3 -5
- package/lib/rules/no-mixed-spaces-and-tabs.js +2 -2
- package/lib/rules/no-octal-escape.js +1 -1
- package/lib/rules/no-octal.js +1 -1
- package/lib/rules/no-param-reassign.js +1 -1
- package/lib/rules/no-path-concat.js +1 -1
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-return-assign.js +1 -1
- package/lib/rules/no-self-assign.js +1 -1
- package/lib/rules/no-tabs.js +2 -2
- package/lib/rules/no-template-curly-in-string.js +1 -1
- package/lib/rules/no-trailing-spaces.js +2 -2
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unmodified-loop-condition.js +5 -5
- package/lib/rules/no-unsafe-finally.js +3 -3
- package/lib/rules/no-unused-expressions.js +2 -2
- package/lib/rules/no-unused-vars.js +10 -14
- package/lib/rules/no-use-before-define.js +5 -5
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-var.js +1 -1
- package/lib/rules/no-warning-comments.js +6 -6
- package/lib/rules/object-curly-newline.js +4 -6
- package/lib/rules/object-shorthand.js +4 -8
- package/lib/rules/one-var.js +3 -6
- package/lib/rules/padding-line-between-statements.js +4 -3
- package/lib/rules/prefer-const.js +3 -3
- package/lib/rules/prefer-destructuring.js +7 -14
- package/lib/rules/prefer-named-capture-group.js +123 -0
- package/lib/rules/prefer-object-spread.js +1 -1
- package/lib/rules/prefer-template.js +3 -3
- package/lib/rules/quote-props.js +5 -10
- package/lib/rules/quotes.js +4 -6
- package/lib/rules/semi.js +7 -8
- package/lib/rules/space-before-function-paren.js +3 -6
- package/lib/rules/spaced-comment.js +4 -4
- package/lib/rules/template-curly-spacing.js +2 -2
- package/lib/rules/use-isnan.js +1 -1
- package/lib/rules/valid-jsdoc.js +2 -2
- package/lib/rules/vars-on-top.js +1 -1
- package/lib/rules/yield-star-spacing.js +2 -2
- package/lib/rules/yoda.js +2 -2
- package/lib/testers/rule-tester.js +1 -1
- package/lib/util/ast-utils.js +12 -12
- package/lib/util/config-comment-parser.js +4 -4
- package/lib/util/glob-utils.js +15 -4
- package/lib/util/ignored-paths.js +4 -4
- package/lib/util/interpolate.js +1 -1
- package/lib/util/naming.js +6 -6
- package/lib/util/node-event-generator.js +1 -1
- package/lib/util/path-utils.js +2 -2
- package/lib/util/patterns/letters.js +1 -1
- package/lib/util/source-code.js +2 -2
- package/lib/util/xml-escape.js +1 -1
- package/package.json +10 -9
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,54 @@
|
|
1
|
+
v5.15.3 - March 18, 2019
|
2
|
+
|
3
|
+
* [`71adc66`](https://github.com/eslint/eslint/commit/71adc665b9649b173adc76f80723b8de20664ae1) Fix: avoid moving comments in implicit-arrow-linebreak (fixes #11521) (#11522) (Teddy Katz)
|
4
|
+
* [`1f715a2`](https://github.com/eslint/eslint/commit/1f715a20c145d8ccc38f3310afccd838495d09d4) Chore: make test-case-property-ordering reasonable (#11511) (Toru Nagashima)
|
5
|
+
|
6
|
+
v5.15.2 - March 15, 2019
|
7
|
+
|
8
|
+
* [`29dbca7`](https://github.com/eslint/eslint/commit/29dbca73d762a809adb2f457b527e144426d54a7) Fix: implicit-arrow-linebreak adds extra characters (fixes #11268) (#11407) (Mark de Dios)
|
9
|
+
* [`5d2083f`](https://github.com/eslint/eslint/commit/5d2083fa3e14c024197f6c386ff72237a145e258) Upgrade: eslint-scope@4.0.3 (#11513) (Teddy Katz)
|
10
|
+
* [`a5dae7c`](https://github.com/eslint/eslint/commit/a5dae7c3d30231c2f5f075d98c2c8825899bab16) Fix: Empty glob pattern incorrectly expands to "/**" (#11476) (Ben Chauvette)
|
11
|
+
* [`448e8da`](https://github.com/eslint/eslint/commit/448e8da94d09b397e98ffcb6f22b55a578ef79c1) Chore: improve crash reporting (fixes #11304) (#11463) (Alex Zherdev)
|
12
|
+
* [`0f56dc6`](https://github.com/eslint/eslint/commit/0f56dc6d9eadad05dc3d5c9d1d9ddef94e10c5d3) Chore: make config validator params more consistent (#11435) (薛定谔的猫)
|
13
|
+
* [`d6c1122`](https://github.com/eslint/eslint/commit/d6c112289f0f16ade070865c8786831b7940ca79) Docs: Add working groups to maintainer guide (#11400) (Nicholas C. Zakas)
|
14
|
+
* [`5fdb4d3`](https://github.com/eslint/eslint/commit/5fdb4d3fb01b9d8a4c2dff71ed9cddb2f8feefb0) Build: compile deps to ES5 when generating browser file (fixes #11504) (#11505) (Teddy Katz)
|
15
|
+
* [`06fa165`](https://github.com/eslint/eslint/commit/06fa1655c3da8394ed9144d727115fc434b0416f) Build: update CI testing configuration (#11500) (Reece Dunham)
|
16
|
+
* [`956e883`](https://github.com/eslint/eslint/commit/956e883c21fd9f393bf6718d032a4e2e53b33f22) Docs: Fix example in no-restricted-modules docs (#11454) (Paul O’Shannessy)
|
17
|
+
* [`2c7431d`](https://github.com/eslint/eslint/commit/2c7431d6b32063f74e3837ee727f26af215eada7) Docs: fix json schema example dead link (#11498) (kazuya kawaguchi)
|
18
|
+
* [`e7266c2`](https://github.com/eslint/eslint/commit/e7266c2478aff5d66e7859313feb49e3a129f85e) Docs: Fix invalid JSON in "Specifying Parser Options" (#11492) (Mihira Jayasekera)
|
19
|
+
* [`6693161`](https://github.com/eslint/eslint/commit/6693161978a83e0730d5ea0fecdb627c5a2acdfd) Sponsors: Sync README with website (ESLint Jenkins)
|
20
|
+
* [`62fee4a`](https://github.com/eslint/eslint/commit/62fee4a976897d158c8c137339728cd280333286) Chore: eslint-config-eslint enable comma-dangle functions: "never" (#11434) (薛定谔的猫)
|
21
|
+
* [`34a5382`](https://github.com/eslint/eslint/commit/34a53829e7a63ff2f6b371d77ce283bbdd373b91) Build: copy bundled espree to website directory (#11478) (Pig Fang)
|
22
|
+
* [`f078f9a`](https://github.com/eslint/eslint/commit/f078f9a9e094ec00c61a6ef1c9550d017631e69a) Chore: use "file:" dependencies for internal rules/config (#11465) (Teddy Katz)
|
23
|
+
* [`0756128`](https://github.com/eslint/eslint/commit/075612871f85aa04cef8137bd32247e128ad600b) Docs: Add `visualstudio` to formatter list (#11480) (Patrick Eriksson)
|
24
|
+
* [`44de9d7`](https://github.com/eslint/eslint/commit/44de9d7e1aa2fcae475a97b8f597b7d8094566b2) Docs: Fix typo in func-name-matching rule docs (#11484) (Iulian Onofrei)
|
25
|
+
|
26
|
+
v5.15.1 - March 4, 2019
|
27
|
+
|
28
|
+
* [`fe1a892`](https://github.com/eslint/eslint/commit/fe1a892f85b09c3d2fea05bef011530a678a6af5) Build: bundle espree (fixes eslint/eslint.github.io#546) (#11467) (薛定谔的猫)
|
29
|
+
* [`458053b`](https://github.com/eslint/eslint/commit/458053b0b541f857bf233dacbde5ba80681820f8) Fix: avoid creating invalid regex in no-warning-comments (fixes #11471) (#11472) (Teddy Katz)
|
30
|
+
|
31
|
+
v5.15.0 - March 1, 2019
|
32
|
+
|
33
|
+
* [`4088c6c`](https://github.com/eslint/eslint/commit/4088c6c9d4578cd581ce8ff4385d90b58a75b755) Build: Remove path.resolve in webpack build (#11462) (Kevin Partington)
|
34
|
+
* [`ec59ec0`](https://github.com/eslint/eslint/commit/ec59ec09c8d001b8c04f9edc09994e2b0d0af0f9) New: add rule "prefer-named-capture-group" (fixes #11381) (#11392) (Pig Fang)
|
35
|
+
* [`a44f750`](https://github.com/eslint/eslint/commit/a44f75073306e5ea4e6722654009a99884fbca4f) Upgrade: eslint-scope@4.0.2 (#11461) (Teddy Katz)
|
36
|
+
* [`d3ce611`](https://github.com/eslint/eslint/commit/d3ce611e1c705440ccbcae357f2194134d026541) Sponsors: Sync README with website (ESLint Jenkins)
|
37
|
+
* [`ee88475`](https://github.com/eslint/eslint/commit/ee884754e4111e11994ff0df3f0c29e43e1dc3f2) Chore: add utils for rule tests (#11453) (薛定谔的猫)
|
38
|
+
* [`d4824e4`](https://github.com/eslint/eslint/commit/d4824e46d7a6ca1618454d3c6198403382108123) Sponsors: Sync README with website (ESLint Jenkins)
|
39
|
+
* [`6489518`](https://github.com/eslint/eslint/commit/64895185bde5233223648bcaf46f8deb72c9fb55) Fix: no-extra-parens crash when code is "((let))" (#11444) (Teddy Katz)
|
40
|
+
* [`9d20de2`](https://github.com/eslint/eslint/commit/9d20de2b0ac756bd62888119b8e08c7441d8a5aa) Sponsors: Sync README with website (ESLint Jenkins)
|
41
|
+
* [`3f14de4`](https://github.com/eslint/eslint/commit/3f14de458ba120e9c013f5fc7c6fe3e9b40c1460) Sponsors: Sync README with website (ESLint Jenkins)
|
42
|
+
* [`3d6c770`](https://github.com/eslint/eslint/commit/3d6c7709d47e047b25d91ca1a77d6dab92313061) Sponsors: Sync README with website (ESLint Jenkins)
|
43
|
+
* [`de5cbc5`](https://github.com/eslint/eslint/commit/de5cbc526b30405e742b35d85d04361529d49ed4) Update: remove invalid defaults from core rules (fixes #11415) (#11427) (Teddy Katz)
|
44
|
+
* [`eb0650b`](https://github.com/eslint/eslint/commit/eb0650ba20cf9f9ad78dbaccfeb7e0e7ab56e31d) Build: fix linting errors on master (#11428) (Teddy Katz)
|
45
|
+
* [`5018378`](https://github.com/eslint/eslint/commit/5018378131fd5190bbccca902c0cf4276ee1581a) Chore: enable require-unicode-regexp on ESLint codebase (#11422) (Teddy Katz)
|
46
|
+
* [`f6ba633`](https://github.com/eslint/eslint/commit/f6ba633f56eca6be20fc4b0d9496a78b9498d578) Chore: lint all files in the repo at the same time (#11425) (Teddy Katz)
|
47
|
+
* [`8f3d717`](https://github.com/eslint/eslint/commit/8f3d71754932669332ad7623bcc4c1aef3897125) Docs: Add non-attending TSC member info (#11411) (Nicholas C. Zakas)
|
48
|
+
* [`ce0777d`](https://github.com/eslint/eslint/commit/ce0777da5bc167fe0c529158fd8216d3eaf11565) Docs: use more common spelling (#11417) (薛定谔的猫)
|
49
|
+
* [`b9aabe3`](https://github.com/eslint/eslint/commit/b9aabe34311f6189b87c9d8a1aa40f3513fed773) Chore: run fuzzer along with unit tests (#11404) (Teddy Katz)
|
50
|
+
* [`db0c5e2`](https://github.com/eslint/eslint/commit/db0c5e2a7f894b7cda71007b0ba43d7814b3fb2e) Build: switch from browserify to webpack (fixes #11366) (#11398) (Pig Fang)
|
51
|
+
|
1
52
|
v5.14.1 - February 18, 2019
|
2
53
|
|
3
54
|
* [`1d6e639`](https://github.com/eslint/eslint/commit/1d6e63930073e79e52890f552cc6e9a0646b7fb4) Fix: sort-keys throws Error at SpreadElement (fixes #11402) (#11403) (Krist Wongsuphasawat)
|
package/README.md
CHANGED
@@ -266,9 +266,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
266
266
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
267
267
|
<!--sponsorsstart-->
|
268
268
|
<h3>Gold Sponsors</h3>
|
269
|
-
<p><a href="https://code.facebook.com/projects/"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Fres.cloudinary.com%2Fopencollective%2Fimage%2Fupload%2Fv1508519428%2FS9gk78AS_400x400_fulq2l.jpg&height=96" alt="Facebook Open Source" height="96"></a> <a href="https://
|
269
|
+
<p><a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F098e3bd0-4d57-11e8-9324-0f6cc1f92bf1.png&height=96" alt="Airbnb" height="96"></a> <a href="https://code.facebook.com/projects/"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Fres.cloudinary.com%2Fopencollective%2Fimage%2Fupload%2Fv1508519428%2FS9gk78AS_400x400_fulq2l.jpg&height=96" alt="Facebook Open Source" height="96"></a> <a href="https://badoo.com/team?utm_source=eslint"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2Fbbdb9cc0-3b5d-11e9-9537-ad85092287b8.png&height=96" alt="Badoo" height="96"></a></p><h3>Silver Sponsors</h3>
|
270
270
|
<p><a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F68ed8b70-ebf2-11e6-9958-cb7e79408c56.png&height=96" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
|
271
|
-
<p><a href="http://faithlife.com/ref/about"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Flogo.clearbit.com%2Ffaithlife.com&height=96" alt="Faithlife" height="32"></a></p>
|
271
|
+
<p><a href="http://faithlife.com/ref/about"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Flogo.clearbit.com%2Ffaithlife.com&height=96" alt="Faithlife" height="32"></a> <a href="https://jsheroes.io/"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Flogo.clearbit.com%2Fjsheroes.io&height=96" alt="JSHeroes " height="32"></a></p>
|
272
272
|
<!--sponsorsend-->
|
273
273
|
|
274
274
|
## Technology Sponsors
|
@@ -232,6 +232,7 @@ module.exports = {
|
|
232
232
|
"prefer-arrow-callback": require("./rules/prefer-arrow-callback"),
|
233
233
|
"prefer-const": require("./rules/prefer-const"),
|
234
234
|
"prefer-destructuring": require("./rules/prefer-destructuring"),
|
235
|
+
"prefer-named-capture-group": require("./rules/prefer-named-capture-group"),
|
235
236
|
"prefer-numeric-literals": require("./rules/prefer-numeric-literals"),
|
236
237
|
"prefer-object-spread": require("./rules/prefer-object-spread"),
|
237
238
|
"prefer-promise-reject-errors": require("./rules/prefer-promise-reject-errors"),
|
package/lib/cli-engine.js
CHANGED
@@ -258,7 +258,7 @@ function processFile(filename, configHelper, options, linter) {
|
|
258
258
|
*/
|
259
259
|
function createIgnoreResult(filePath, baseDir) {
|
260
260
|
let message;
|
261
|
-
const isHidden =
|
261
|
+
const isHidden = /^\./u.test(path.basename(filePath));
|
262
262
|
const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules");
|
263
263
|
const isInBowerComponents = baseDir && path.relative(baseDir, filePath).startsWith("bower_components");
|
264
264
|
|
@@ -757,7 +757,7 @@ class CLIEngine {
|
|
757
757
|
if (typeof resolvedFormatName === "string") {
|
758
758
|
|
759
759
|
// replace \ with / for Windows compatibility
|
760
|
-
const normalizedFormatName = resolvedFormatName.replace(/\\/
|
760
|
+
const normalizedFormatName = resolvedFormatName.replace(/\\/gu, "/");
|
761
761
|
|
762
762
|
const cwd = this.options ? this.options.cwd : process.cwd();
|
763
763
|
const namespace = naming.getNamespaceFromTerm(normalizedFormatName);
|
@@ -61,7 +61,7 @@ const resolver = new ModuleResolver();
|
|
61
61
|
* @private
|
62
62
|
*/
|
63
63
|
function readFile(filePath) {
|
64
|
-
return fs.readFileSync(filePath, "utf8").replace(/^\ufeff
|
64
|
+
return fs.readFileSync(filePath, "utf8").replace(/^\ufeff/u, "");
|
65
65
|
}
|
66
66
|
|
67
67
|
/**
|
@@ -73,7 +73,7 @@ function readFile(filePath) {
|
|
73
73
|
* @private
|
74
74
|
*/
|
75
75
|
function isFilePath(filePath) {
|
76
|
-
return path.isAbsolute(filePath) || !/\w
|
76
|
+
return path.isAbsolute(filePath) || !/\w|@/u.test(filePath.charAt(0));
|
77
77
|
}
|
78
78
|
|
79
79
|
/**
|
@@ -541,7 +541,7 @@ function loadFromDisk(resolvedPath, configContext) {
|
|
541
541
|
const ruleMap = configContext.linterContext.getRules();
|
542
542
|
|
543
543
|
// validate the configuration before continuing
|
544
|
-
validator.validate(config,
|
544
|
+
validator.validate(config, ruleMap.get.bind(ruleMap), configContext.linterContext.environments, resolvedPath.configFullName);
|
545
545
|
|
546
546
|
/*
|
547
547
|
* If an `extends` property is defined, it represents a configuration file to use as
|
@@ -152,7 +152,7 @@ function configureRules(answers, config) {
|
|
152
152
|
bar.tick(0); // Shows the progress bar
|
153
153
|
|
154
154
|
// Get the SourceCode of all chosen files
|
155
|
-
const patterns = answers.patterns.split(/[\s]+/);
|
155
|
+
const patterns = answers.patterns.split(/[\s]+/u);
|
156
156
|
|
157
157
|
try {
|
158
158
|
sourceCodes = getSourceCodeOfFiles(patterns, { baseConfig: newConfig, useEslintrc: false }, total => {
|
@@ -76,7 +76,7 @@ function validateRuleSeverity(options) {
|
|
76
76
|
return normSeverity;
|
77
77
|
}
|
78
78
|
|
79
|
-
throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/
|
79
|
+
throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`);
|
80
80
|
|
81
81
|
}
|
82
82
|
|
@@ -116,7 +116,7 @@ function validateRuleSchema(rule, localOptions) {
|
|
116
116
|
* no source is prepended to the message.
|
117
117
|
* @returns {void}
|
118
118
|
*/
|
119
|
-
function validateRuleOptions(rule, ruleId, options, source) {
|
119
|
+
function validateRuleOptions(rule, ruleId, options, source = null) {
|
120
120
|
if (!rule) {
|
121
121
|
return;
|
122
122
|
}
|
@@ -140,11 +140,11 @@ function validateRuleOptions(rule, ruleId, options, source) {
|
|
140
140
|
/**
|
141
141
|
* Validates an environment object
|
142
142
|
* @param {Object} environment The environment config object to validate.
|
143
|
-
* @param {string} source The name of the configuration source to report in any errors.
|
144
143
|
* @param {Environments} envContext Env context
|
144
|
+
* @param {string} source The name of the configuration source to report in any errors.
|
145
145
|
* @returns {void}
|
146
146
|
*/
|
147
|
-
function validateEnvironment(environment,
|
147
|
+
function validateEnvironment(environment, envContext, source = null) {
|
148
148
|
|
149
149
|
// not having an environment is ok
|
150
150
|
if (!environment) {
|
@@ -163,11 +163,11 @@ function validateEnvironment(environment, source, envContext) {
|
|
163
163
|
/**
|
164
164
|
* Validates a rules config object
|
165
165
|
* @param {Object} rulesConfig The rules config object to validate.
|
166
|
-
* @param {string} source The name of the configuration source to report in any errors.
|
167
166
|
* @param {function(string): {create: Function}} ruleMapper A mapper function from strings to loaded rules
|
167
|
+
* @param {string} source The name of the configuration source to report in any errors.
|
168
168
|
* @returns {void}
|
169
169
|
*/
|
170
|
-
function validateRules(rulesConfig,
|
170
|
+
function validateRules(rulesConfig, ruleMapper, source = null) {
|
171
171
|
if (!rulesConfig) {
|
172
172
|
return;
|
173
173
|
}
|
@@ -228,7 +228,7 @@ const emitDeprecationWarning = lodash.memoize((source, errorCode) => {
|
|
228
228
|
* @param {string} source The name of the configuration source to report in any errors.
|
229
229
|
* @returns {void}
|
230
230
|
*/
|
231
|
-
function validateConfigSchema(config, source) {
|
231
|
+
function validateConfigSchema(config, source = null) {
|
232
232
|
validateSchema = validateSchema || ajv.compile(configSchema);
|
233
233
|
|
234
234
|
if (!validateSchema(config)) {
|
@@ -252,19 +252,19 @@ function validateConfigSchema(config, source) {
|
|
252
252
|
/**
|
253
253
|
* Validates an entire config object.
|
254
254
|
* @param {Object} config The config object to validate.
|
255
|
-
* @param {string} source The name of the configuration source to report in any errors.
|
256
255
|
* @param {function(string): {create: Function}} ruleMapper A mapper function from rule IDs to defined rules
|
257
256
|
* @param {Environments} envContext The env context
|
257
|
+
* @param {string} source The name of the configuration source to report in any errors.
|
258
258
|
* @returns {void}
|
259
259
|
*/
|
260
|
-
function validate(config,
|
260
|
+
function validate(config, ruleMapper, envContext, source = null) {
|
261
261
|
validateConfigSchema(config, source);
|
262
|
-
validateRules(config.rules,
|
263
|
-
validateEnvironment(config.env,
|
262
|
+
validateRules(config.rules, ruleMapper, source);
|
263
|
+
validateEnvironment(config.env, envContext, source);
|
264
264
|
|
265
265
|
for (const override of config.overrides || []) {
|
266
|
-
validateRules(override.rules,
|
267
|
-
validateEnvironment(override.env,
|
266
|
+
validateRules(override.rules, ruleMapper, source);
|
267
|
+
validateEnvironment(override.env, envContext, source);
|
268
268
|
}
|
269
269
|
}
|
270
270
|
|
package/lib/config/plugins.js
CHANGED
@@ -84,7 +84,7 @@ class Plugins {
|
|
84
84
|
const shortName = naming.getShorthandName(longName, "eslint-plugin");
|
85
85
|
let plugin = null;
|
86
86
|
|
87
|
-
if (pluginName.match(/\s+/)) {
|
87
|
+
if (pluginName.match(/\s+/u)) {
|
88
88
|
const whitespaceError = new Error(`Whitespace found in plugin name '${pluginName}'`);
|
89
89
|
|
90
90
|
whitespaceError.messageTemplate = "whitespace-found";
|
@@ -47,7 +47,7 @@ function formatFilePath(filePath, line, column) {
|
|
47
47
|
*/
|
48
48
|
function formatMessage(message, parentResult) {
|
49
49
|
const type = (message.fatal || message.severity === 2) ? chalk.red("error") : chalk.yellow("warning");
|
50
|
-
const msg = `${chalk.bold(message.message.replace(/([^ ])
|
50
|
+
const msg = `${chalk.bold(message.message.replace(/([^ ])\.$/u, "$1"))}`;
|
51
51
|
const ruleId = message.fatal ? "" : chalk.dim(`(${message.ruleId})`);
|
52
52
|
const filePath = formatFilePath(parentResult.filePath, message.line, message.column);
|
53
53
|
const sourceCode = parentResult.output ? parentResult.output : parentResult.source;
|
@@ -65,7 +65,7 @@ module.exports = function(results) {
|
|
65
65
|
message.line || 0,
|
66
66
|
message.column || 0,
|
67
67
|
messageType,
|
68
|
-
message.message.replace(/([^ ])
|
68
|
+
message.message.replace(/([^ ])\.$/u, "$1"),
|
69
69
|
chalk.dim(message.ruleId || "")
|
70
70
|
];
|
71
71
|
}),
|
@@ -75,7 +75,7 @@ module.exports = function(results) {
|
|
75
75
|
return stripAnsi(str).length;
|
76
76
|
}
|
77
77
|
}
|
78
|
-
).split("\n").map(el => el.replace(/(\d+)\s+(\d+)
|
78
|
+
).split("\n").map(el => el.replace(/(\d+)\s+(\d+)/u, (m, p1, p2) => chalk.dim(`${p1}:${p2}`))).join("\n")}\n\n`;
|
79
79
|
});
|
80
80
|
|
81
81
|
const total = errorCount + warningCount;
|
package/lib/linter.js
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
|
12
12
|
const eslintScope = require("eslint-scope"),
|
13
13
|
evk = require("eslint-visitor-keys"),
|
14
|
+
espree = require("espree"),
|
14
15
|
lodash = require("lodash"),
|
15
16
|
CodePathAnalyzer = require("./code-path-analysis/code-path-analyzer"),
|
16
17
|
ConfigOps = require("./config/config-ops"),
|
@@ -163,7 +164,7 @@ function getDirectiveComments(filename, ast, ruleMapper) {
|
|
163
164
|
|
164
165
|
ast.comments.filter(token => token.type !== "Shebang").forEach(comment => {
|
165
166
|
const trimmedCommentText = comment.value.trim();
|
166
|
-
const match = /^(eslint(-\w+){0,3}|exported|globals?)(\s|$)
|
167
|
+
const match = /^(eslint(-\w+){0,3}|exported|globals?)(\s|$)/u.exec(trimmedCommentText);
|
167
168
|
|
168
169
|
if (!match) {
|
169
170
|
return;
|
@@ -171,7 +172,7 @@ function getDirectiveComments(filename, ast, ruleMapper) {
|
|
171
172
|
|
172
173
|
const directiveValue = trimmedCommentText.slice(match.index + match[1].length);
|
173
174
|
|
174
|
-
if (/^eslint-disable-(next-)?line
|
175
|
+
if (/^eslint-disable-(next-)?line$/u.test(match[1])) {
|
175
176
|
if (comment.loc.start.line === comment.loc.end.line) {
|
176
177
|
const directiveType = match[1].slice("eslint-".length);
|
177
178
|
|
@@ -275,7 +276,7 @@ function normalizeEcmaVersion(ecmaVersion, isModule) {
|
|
275
276
|
return ecmaVersion;
|
276
277
|
}
|
277
278
|
|
278
|
-
const eslintEnvPattern = /\/\*\s*eslint-env\s(.+?)\*\//
|
279
|
+
const eslintEnvPattern = /\/\*\s*eslint-env\s(.+?)\*\//gu;
|
279
280
|
|
280
281
|
/**
|
281
282
|
* Checks whether or not there is a comment which has "eslint-env *" in a given text.
|
@@ -497,7 +498,7 @@ function parse(text, providedParserOptions, parserName, parserMap, filePath) {
|
|
497
498
|
} catch (ex) {
|
498
499
|
|
499
500
|
// If the message includes a leading line number, strip it:
|
500
|
-
const message = `Parsing error: ${ex.message.replace(/^line \d+:/
|
501
|
+
const message = `Parsing error: ${ex.message.replace(/^line \d+:/iu, "").trim()}`;
|
501
502
|
|
502
503
|
return {
|
503
504
|
success: false,
|
@@ -746,10 +747,15 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parser
|
|
746
747
|
nodeQueue.forEach(traversalInfo => {
|
747
748
|
currentNode = traversalInfo.node;
|
748
749
|
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
750
|
+
try {
|
751
|
+
if (traversalInfo.isEntering) {
|
752
|
+
eventGenerator.enterNode(currentNode);
|
753
|
+
} else {
|
754
|
+
eventGenerator.leaveNode(currentNode);
|
755
|
+
}
|
756
|
+
} catch (err) {
|
757
|
+
err.currentNode = currentNode;
|
758
|
+
throw err;
|
753
759
|
}
|
754
760
|
});
|
755
761
|
|
@@ -776,6 +782,8 @@ module.exports = class Linter {
|
|
776
782
|
ruleMaps.set(this, new Rules());
|
777
783
|
this.version = pkg.version;
|
778
784
|
this.environments = new Environments();
|
785
|
+
|
786
|
+
this.defineParser("espree", espree);
|
779
787
|
}
|
780
788
|
|
781
789
|
/**
|
@@ -898,8 +906,15 @@ module.exports = class Linter {
|
|
898
906
|
options.filename
|
899
907
|
);
|
900
908
|
} catch (err) {
|
909
|
+
err.message += `\nOccurred while linting ${options.filename}`;
|
901
910
|
debug("An error occurred while traversing");
|
902
911
|
debug("Filename:", options.filename);
|
912
|
+
if (err.currentNode) {
|
913
|
+
const { line } = err.currentNode.loc.start;
|
914
|
+
|
915
|
+
debug("Line:", line);
|
916
|
+
err.message += `:${line}`;
|
917
|
+
}
|
903
918
|
debug("Parser Options:", parserOptions);
|
904
919
|
debug("Parser Path:", parserName);
|
905
920
|
debug("Settings:", settings);
|
@@ -34,13 +34,11 @@ module.exports = {
|
|
34
34
|
type: "object",
|
35
35
|
properties: {
|
36
36
|
multiline: {
|
37
|
-
type: "boolean"
|
38
|
-
default: true
|
37
|
+
type: "boolean"
|
39
38
|
},
|
40
39
|
minItems: {
|
41
40
|
type: ["integer", "null"],
|
42
|
-
minimum: 0
|
43
|
-
default: null
|
41
|
+
minimum: 0
|
44
42
|
}
|
45
43
|
},
|
46
44
|
additionalProperties: false
|
@@ -17,8 +17,8 @@ const astUtils = require("../util/ast-utils");
|
|
17
17
|
// Helpers
|
18
18
|
//------------------------------------------------------------------------------
|
19
19
|
|
20
|
-
const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression
|
21
|
-
const TARGET_METHODS = /^(?:every|filter|find(?:Index)?|map|reduce(?:Right)?|some|sort)
|
20
|
+
const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
|
21
|
+
const TARGET_METHODS = /^(?:every|filter|find(?:Index)?|map|reduce(?:Right)?|some|sort)$/u;
|
22
22
|
|
23
23
|
/**
|
24
24
|
* Checks a given code path segment is reachable.
|
@@ -34,13 +34,11 @@ module.exports = {
|
|
34
34
|
type: "object",
|
35
35
|
properties: {
|
36
36
|
multiline: {
|
37
|
-
type: "boolean"
|
38
|
-
default: false
|
37
|
+
type: "boolean"
|
39
38
|
},
|
40
39
|
minItems: {
|
41
40
|
type: ["integer", "null"],
|
42
|
-
minimum: 0
|
43
|
-
default: null
|
41
|
+
minimum: 0
|
44
42
|
}
|
45
43
|
},
|
46
44
|
additionalProperties: false
|
@@ -46,7 +46,7 @@ module.exports = {
|
|
46
46
|
{
|
47
47
|
type: "object",
|
48
48
|
properties: {
|
49
|
-
requireReturnForObjectLiteral: { type: "boolean"
|
49
|
+
requireReturnForObjectLiteral: { type: "boolean" }
|
50
50
|
},
|
51
51
|
additionalProperties: false
|
52
52
|
}
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
82
82
|
* @returns {boolean} `true` if it changes semantics if `;` or `}` followed by the token are removed.
|
83
83
|
*/
|
84
84
|
function hasASIProblem(token) {
|
85
|
-
return token && token.type === "Punctuator" && /^[([/`+-]
|
85
|
+
return token && token.type === "Punctuator" && /^[([/`+-]/u.test(token.value);
|
86
86
|
}
|
87
87
|
|
88
88
|
/**
|
package/lib/rules/camelcase.js
CHANGED
@@ -90,7 +90,7 @@ module.exports = {
|
|
90
90
|
*/
|
91
91
|
function isAllowed(name) {
|
92
92
|
return allow.findIndex(
|
93
|
-
entry => name === entry || name.match(new RegExp(entry))
|
93
|
+
entry => name === entry || name.match(new RegExp(entry)) // eslint-disable-line require-unicode-regexp
|
94
94
|
) !== -1;
|
95
95
|
}
|
96
96
|
|
@@ -142,7 +142,7 @@ module.exports = {
|
|
142
142
|
* private/protected identifiers, strip them before checking if underscored
|
143
143
|
*/
|
144
144
|
const name = node.name,
|
145
|
-
nameIsUnderscored = isUnderscored(name.replace(/^_+|_+$/
|
145
|
+
nameIsUnderscored = isUnderscored(name.replace(/^_+|_+$/gu, "")),
|
146
146
|
effectiveParent = (node.parent.type === "MemberExpression") ? node.parent.parent : node.parent;
|
147
147
|
|
148
148
|
// First, we ignore the node if it match the ignore list
|
@@ -16,8 +16,8 @@ const astUtils = require("../util/ast-utils");
|
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
18
|
const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN,
|
19
|
-
WHITESPACE = /\s/
|
20
|
-
MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]
|
19
|
+
WHITESPACE = /\s/gu,
|
20
|
+
MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/u; // TODO: Combine w/ max-len pattern?
|
21
21
|
|
22
22
|
/*
|
23
23
|
* Base schema body for defining the basic capitalization rule, ignorePattern,
|
@@ -28,27 +28,22 @@ const SCHEMA_BODY = {
|
|
28
28
|
type: "object",
|
29
29
|
properties: {
|
30
30
|
ignorePattern: {
|
31
|
-
type: "string"
|
32
|
-
default: ""
|
31
|
+
type: "string"
|
33
32
|
},
|
34
33
|
ignoreInlineComments: {
|
35
|
-
type: "boolean"
|
36
|
-
default: false
|
34
|
+
type: "boolean"
|
37
35
|
},
|
38
36
|
ignoreConsecutiveComments: {
|
39
|
-
type: "boolean"
|
40
|
-
default: false
|
37
|
+
type: "boolean"
|
41
38
|
}
|
42
39
|
},
|
43
40
|
additionalProperties: false
|
44
41
|
};
|
45
|
-
const DEFAULTS =
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
{}
|
51
|
-
);
|
42
|
+
const DEFAULTS = {
|
43
|
+
ignorePattern: "",
|
44
|
+
ignoreInlineComments: false,
|
45
|
+
ignoreConsecutiveComments: false
|
46
|
+
};
|
52
47
|
|
53
48
|
/**
|
54
49
|
* Get normalized options for either block or line comments from the given
|
@@ -96,7 +91,7 @@ function createRegExpForIgnorePatterns(normalizedOptions) {
|
|
96
91
|
const ignorePatternStr = normalizedOptions[key].ignorePattern;
|
97
92
|
|
98
93
|
if (ignorePatternStr) {
|
99
|
-
const regExp = RegExp(`^\\s*(?:${ignorePatternStr})`);
|
94
|
+
const regExp = RegExp(`^\\s*(?:${ignorePatternStr})`); // eslint-disable-line require-unicode-regexp
|
100
95
|
|
101
96
|
normalizedOptions[key].ignorePatternRegExp = regExp;
|
102
97
|
}
|
@@ -215,7 +210,7 @@ module.exports = {
|
|
215
210
|
|
216
211
|
// 2. Check for custom ignore pattern.
|
217
212
|
const commentWithoutAsterisks = comment.value
|
218
|
-
.replace(/\*/
|
213
|
+
.replace(/\*/gu, "");
|
219
214
|
|
220
215
|
if (options.ignorePatternRegExp && options.ignorePatternRegExp.test(commentWithoutAsterisks)) {
|
221
216
|
return true;
|
package/lib/rules/complexity.js
CHANGED
@@ -41,13 +41,11 @@ module.exports = {
|
|
41
41
|
properties: {
|
42
42
|
maximum: {
|
43
43
|
type: "integer",
|
44
|
-
minimum: 0
|
45
|
-
default: 20
|
44
|
+
minimum: 0
|
46
45
|
},
|
47
46
|
max: {
|
48
47
|
type: "integer",
|
49
|
-
minimum: 0
|
50
|
-
default: 20
|
48
|
+
minimum: 0
|
51
49
|
}
|
52
50
|
},
|
53
51
|
additionalProperties: false
|
@@ -65,7 +63,10 @@ module.exports = {
|
|
65
63
|
const option = context.options[0];
|
66
64
|
let THRESHOLD = 20;
|
67
65
|
|
68
|
-
if (
|
66
|
+
if (
|
67
|
+
typeof option === "object" &&
|
68
|
+
(Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))
|
69
|
+
) {
|
69
70
|
THRESHOLD = option.maximum || option.max;
|
70
71
|
} else if (typeof option === "number") {
|
71
72
|
THRESHOLD = option;
|
package/lib/rules/curly.js
CHANGED
@@ -191,7 +191,7 @@ module.exports = {
|
|
191
191
|
return true;
|
192
192
|
}
|
193
193
|
|
194
|
-
if (/^[([/`+-]
|
194
|
+
if (/^[([/`+-]/u.test(tokenAfter.value)) {
|
195
195
|
|
196
196
|
// If the next token starts with a character that would disrupt ASI, insert a semicolon.
|
197
197
|
return true;
|
@@ -4,7 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
const DEFAULT_COMMENT_PATTERN = /^no default$/
|
7
|
+
const DEFAULT_COMMENT_PATTERN = /^no default$/iu;
|
8
8
|
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
// Rule Definition
|
@@ -39,7 +39,7 @@ module.exports = {
|
|
39
39
|
create(context) {
|
40
40
|
const options = context.options[0] || {};
|
41
41
|
const commentPattern = options.commentPattern
|
42
|
-
? new RegExp(options.commentPattern)
|
42
|
+
? new RegExp(options.commentPattern) // eslint-disable-line require-unicode-regexp
|
43
43
|
: DEFAULT_COMMENT_PATTERN;
|
44
44
|
|
45
45
|
const sourceCode = context.getSourceCode();
|
@@ -14,7 +14,7 @@ const astUtils = require("../util/ast-utils");
|
|
14
14
|
// Rule Definition
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
|
17
|
-
const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]
|
17
|
+
const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u;
|
18
18
|
const keywords = require("../util/keywords");
|
19
19
|
|
20
20
|
module.exports = {
|
@@ -61,7 +61,7 @@ module.exports = {
|
|
61
61
|
let allowPattern;
|
62
62
|
|
63
63
|
if (options.allowPattern) {
|
64
|
-
allowPattern = new RegExp(options.allowPattern);
|
64
|
+
allowPattern = new RegExp(options.allowPattern); // eslint-disable-line require-unicode-regexp
|
65
65
|
}
|
66
66
|
|
67
67
|
/**
|
package/lib/rules/eol-last.js
CHANGED
@@ -97,7 +97,7 @@ module.exports = {
|
|
97
97
|
loc: location,
|
98
98
|
messageId: "unexpected",
|
99
99
|
fix(fixer) {
|
100
|
-
const finalEOLs = /(?:\r?\n)
|
100
|
+
const finalEOLs = /(?:\r?\n)+$/u,
|
101
101
|
match = finalEOLs.exec(sourceCode.text),
|
102
102
|
start = match.index,
|
103
103
|
end = sourceCode.text.length;
|
package/lib/rules/eqeqeq.js
CHANGED
@@ -50,8 +50,7 @@ module.exports = {
|
|
50
50
|
type: "object",
|
51
51
|
properties: {
|
52
52
|
allowNewlines: {
|
53
|
-
type: "boolean"
|
54
|
-
default: false
|
53
|
+
type: "boolean"
|
55
54
|
}
|
56
55
|
},
|
57
56
|
additionalProperties: false
|
@@ -93,8 +92,8 @@ module.exports = {
|
|
93
92
|
return;
|
94
93
|
}
|
95
94
|
|
96
|
-
const textBetweenTokens = text.slice(prevToken.range[1], parenToken.range[0]).replace(/\/\*.*?\*\//
|
97
|
-
const hasWhitespace = /\s
|
95
|
+
const textBetweenTokens = text.slice(prevToken.range[1], parenToken.range[0]).replace(/\/\*.*?\*\//gu, "");
|
96
|
+
const hasWhitespace = /\s/u.test(textBetweenTokens);
|
98
97
|
const hasNewline = hasWhitespace && astUtils.LINEBREAK_MATCHER.test(textBetweenTokens);
|
99
98
|
|
100
99
|
/*
|
@@ -14,7 +14,7 @@ const astUtils = require("../util/ast-utils");
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
16
16
|
//------------------------------------------------------------------------------
|
17
|
-
const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression
|
17
|
+
const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
|
18
18
|
|
19
19
|
/**
|
20
20
|
* Checks a given code path segment is reachable.
|
@@ -52,7 +52,7 @@ module.exports = {
|
|
52
52
|
*/
|
53
53
|
function matchesConfiguredErrorName(name) {
|
54
54
|
if (isPattern(errorArgument)) {
|
55
|
-
const regexp = new RegExp(errorArgument);
|
55
|
+
const regexp = new RegExp(errorArgument); // eslint-disable-line require-unicode-regexp
|
56
56
|
|
57
57
|
return regexp.test(name);
|
58
58
|
}
|