eslint 7.25.0 → 7.29.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +7 -7
  3. package/bin/eslint.js +2 -12
  4. package/lib/cli-engine/cli-engine.js +2 -7
  5. package/lib/cli-engine/file-enumerator.js +1 -1
  6. package/lib/cli-engine/formatters/html.js +193 -9
  7. package/lib/eslint/eslint.js +38 -2
  8. package/lib/init/autoconfig.js +2 -2
  9. package/lib/init/config-file.js +1 -0
  10. package/lib/init/config-initializer.js +14 -1
  11. package/lib/init/npm-utils.js +2 -2
  12. package/lib/linter/apply-disable-directives.js +15 -3
  13. package/lib/linter/linter.js +15 -9
  14. package/lib/linter/node-event-generator.js +43 -6
  15. package/lib/rule-tester/rule-tester.js +83 -23
  16. package/lib/rules/arrow-body-style.js +21 -11
  17. package/lib/rules/comma-dangle.js +16 -7
  18. package/lib/rules/comma-spacing.js +1 -1
  19. package/lib/rules/comma-style.js +1 -2
  20. package/lib/rules/complexity.js +2 -3
  21. package/lib/rules/consistent-return.js +2 -2
  22. package/lib/rules/eol-last.js +2 -7
  23. package/lib/rules/indent.js +10 -13
  24. package/lib/rules/max-lines-per-function.js +2 -3
  25. package/lib/rules/max-lines.js +32 -7
  26. package/lib/rules/max-params.js +2 -3
  27. package/lib/rules/max-statements.js +2 -3
  28. package/lib/rules/no-duplicate-imports.js +214 -66
  29. package/lib/rules/no-fallthrough.js +18 -13
  30. package/lib/rules/no-implicit-coercion.js +21 -2
  31. package/lib/rules/no-restricted-imports.js +61 -24
  32. package/lib/rules/no-unused-vars.js +40 -10
  33. package/lib/rules/no-useless-backreference.js +1 -2
  34. package/lib/rules/no-useless-computed-key.js +8 -2
  35. package/lib/rules/no-warning-comments.js +1 -1
  36. package/lib/rules/object-curly-newline.js +19 -4
  37. package/lib/rules/radix.js +19 -3
  38. package/lib/rules/require-atomic-updates.js +23 -20
  39. package/lib/rules/spaced-comment.js +2 -2
  40. package/lib/rules/utils/ast-utils.js +2 -2
  41. package/lib/shared/deprecation-warnings.js +12 -3
  42. package/lib/shared/string-utils.js +22 -0
  43. package/lib/source-code/source-code.js +6 -5
  44. package/lib/source-code/token-store/utils.js +4 -12
  45. package/messages/{all-files-ignored.txt → all-files-ignored.js} +10 -2
  46. package/messages/extend-config-missing.js +13 -0
  47. package/messages/failed-to-read-json.js +11 -0
  48. package/messages/file-not-found.js +10 -0
  49. package/messages/{no-config-found.txt → no-config-found.js} +9 -1
  50. package/messages/plugin-conflict.js +22 -0
  51. package/messages/plugin-invalid.js +16 -0
  52. package/messages/plugin-missing.js +19 -0
  53. package/messages/{print-config-with-directory-path.txt → print-config-with-directory-path.js} +6 -0
  54. package/messages/whitespace-found.js +11 -0
  55. package/package.json +8 -8
  56. package/lib/cli-engine/formatters/html-template-message.html +0 -8
  57. package/lib/cli-engine/formatters/html-template-page.html +0 -115
  58. package/lib/cli-engine/formatters/html-template-result.html +0 -6
  59. package/messages/extend-config-missing.txt +0 -5
  60. package/messages/failed-to-read-json.txt +0 -3
  61. package/messages/file-not-found.txt +0 -2
  62. package/messages/plugin-conflict.txt +0 -7
  63. package/messages/plugin-invalid.txt +0 -8
  64. package/messages/plugin-missing.txt +0 -11
  65. package/messages/whitespace-found.txt +0 -3
@@ -1,8 +1,16 @@
1
- You are linting "<%= pattern %>", but all of the files matching the glob pattern "<%= pattern %>" are ignored.
1
+ "use strict";
2
2
 
3
- If you don't want to lint these files, remove the pattern "<%= pattern %>" from the list of arguments passed to ESLint.
3
+ module.exports = function(it) {
4
+ const { pattern } = it;
5
+
6
+ return `
7
+ You are linting "${pattern}", but all of the files matching the glob pattern "${pattern}" are ignored.
8
+
9
+ If you don't want to lint these files, remove the pattern "${pattern}" from the list of arguments passed to ESLint.
4
10
 
5
11
  If you do want to lint these files, try the following solutions:
6
12
 
7
13
  * Check your .eslintignore file, or the eslintIgnore property in package.json, to ensure that the files are not configured to be ignored.
8
14
  * Explicitly list the files from this glob that you'd like to lint on the command-line, rather than providing a glob as an argument.
15
+ `.trimLeft();
16
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ module.exports = function(it) {
4
+ const { configName, importerName } = it;
5
+
6
+ return `
7
+ ESLint couldn't find the config "${configName}" to extend from. Please check that the name of the config is correct.
8
+
9
+ The config "${configName}" was referenced from the config file in "${importerName}".
10
+
11
+ If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
12
+ `.trimLeft();
13
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ module.exports = function(it) {
4
+ const { path, message } = it;
5
+
6
+ return `
7
+ Failed to read JSON file at ${path}:
8
+
9
+ ${message}
10
+ `.trimLeft();
11
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ module.exports = function(it) {
4
+ const { pattern, globDisabled } = it;
5
+
6
+ return `
7
+ No files matching the pattern "${pattern}"${globDisabled ? " (with disabling globs)" : ""} were found.
8
+ Please check for typing mistakes in the pattern.
9
+ `.trimLeft();
10
+ };
@@ -1,7 +1,15 @@
1
+ "use strict";
2
+
3
+ module.exports = function(it) {
4
+ const { directoryPath } = it;
5
+
6
+ return `
1
7
  ESLint couldn't find a configuration file. To set up a configuration file for this project, please run:
2
8
 
3
9
  eslint --init
4
10
 
5
- ESLint looked for configuration files in <%= directoryPath %> and its ancestors. If it found none, it then looked in your home directory.
11
+ ESLint looked for configuration files in ${directoryPath} and its ancestors. If it found none, it then looked in your home directory.
6
12
 
7
13
  If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://eslint.org/chat/help
14
+ `.trimLeft();
15
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ module.exports = function(it) {
4
+ const { pluginId, plugins } = it;
5
+
6
+ let result = `ESLint couldn't determine the plugin "${pluginId}" uniquely.
7
+ `;
8
+
9
+ for (const { filePath, importerName } of plugins) {
10
+ result += `
11
+ - ${filePath} (loaded in "${importerName}")`;
12
+ }
13
+
14
+ result += `
15
+
16
+ Please remove the "plugins" setting from either config or remove either plugin installation.
17
+
18
+ If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
19
+ `;
20
+
21
+ return result;
22
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ module.exports = function(it) {
4
+ const { configName, importerName } = it;
5
+
6
+ return `
7
+ "${configName}" is invalid syntax for a config specifier.
8
+
9
+ * If your intention is to extend from a configuration exported from the plugin, add the configuration name after a slash: e.g. "${configName}/myConfig".
10
+ * If this is the name of a shareable config instead of a plugin, remove the "plugin:" prefix: i.e. "${configName.slice("plugin:".length)}".
11
+
12
+ "${configName}" was referenced from the config file in "${importerName}".
13
+
14
+ If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
15
+ `.trimLeft();
16
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ module.exports = function(it) {
4
+ const { pluginName, resolvePluginsRelativeTo, importerName } = it;
5
+
6
+ return `
7
+ ESLint couldn't find the plugin "${pluginName}".
8
+
9
+ (The package "${pluginName}" was not found when loaded as a Node module from the directory "${resolvePluginsRelativeTo}".)
10
+
11
+ It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
12
+
13
+ npm install ${pluginName}@latest --save-dev
14
+
15
+ The plugin "${pluginName}" was referenced from the config file in "${importerName}".
16
+
17
+ If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
18
+ `.trimLeft();
19
+ };
@@ -1,2 +1,8 @@
1
+ "use strict";
2
+
3
+ module.exports = function() {
4
+ return `
1
5
  The '--print-config' CLI option requires a path to a source code file rather than a directory.
2
6
  See also: https://eslint.org/docs/user-guide/command-line-interface#--print-config
7
+ `.trimLeft();
8
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ module.exports = function(it) {
4
+ const { pluginName } = it;
5
+
6
+ return `
7
+ ESLint couldn't find the plugin "${pluginName}". because there is whitespace in the name. Please check your configuration and remove all whitespace from the plugin name.
8
+
9
+ If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
10
+ `.trimLeft();
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "7.25.0",
3
+ "version": "7.29.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -44,22 +44,24 @@
44
44
  "bugs": "https://github.com/eslint/eslint/issues/",
45
45
  "dependencies": {
46
46
  "@babel/code-frame": "7.12.11",
47
- "@eslint/eslintrc": "^0.4.0",
47
+ "@eslint/eslintrc": "^0.4.2",
48
48
  "ajv": "^6.10.0",
49
49
  "chalk": "^4.0.0",
50
50
  "cross-spawn": "^7.0.2",
51
51
  "debug": "^4.0.1",
52
52
  "doctrine": "^3.0.0",
53
53
  "enquirer": "^2.3.5",
54
+ "escape-string-regexp": "^4.0.0",
54
55
  "eslint-scope": "^5.1.1",
55
56
  "eslint-utils": "^2.1.0",
56
57
  "eslint-visitor-keys": "^2.0.0",
57
58
  "espree": "^7.3.1",
58
59
  "esquery": "^1.4.0",
59
60
  "esutils": "^2.0.2",
61
+ "fast-deep-equal": "^3.1.3",
60
62
  "file-entry-cache": "^6.0.1",
61
63
  "functional-red-black-tree": "^1.0.1",
62
- "glob-parent": "^5.0.0",
64
+ "glob-parent": "^5.1.2",
63
65
  "globals": "^13.6.0",
64
66
  "ignore": "^4.0.6",
65
67
  "import-fresh": "^3.0.0",
@@ -68,7 +70,7 @@
68
70
  "js-yaml": "^3.13.1",
69
71
  "json-stable-stringify-without-jsonify": "^1.0.1",
70
72
  "levn": "^0.4.1",
71
- "lodash": "^4.17.21",
73
+ "lodash.merge": "^4.6.2",
72
74
  "minimatch": "^3.0.4",
73
75
  "natural-compare": "^1.4.0",
74
76
  "optionator": "^0.9.1",
@@ -77,14 +79,13 @@
77
79
  "semver": "^7.2.1",
78
80
  "strip-ansi": "^6.0.0",
79
81
  "strip-json-comments": "^3.1.0",
80
- "table": "^6.0.4",
82
+ "table": "^6.0.9",
81
83
  "text-table": "^0.2.0",
82
84
  "v8-compile-cache": "^2.0.3"
83
85
  },
84
86
  "devDependencies": {
85
87
  "@babel/core": "^7.4.3",
86
88
  "@babel/preset-env": "^7.4.3",
87
- "acorn": "^7.2.0",
88
89
  "babel-loader": "^8.0.5",
89
90
  "chai": "^4.0.1",
90
91
  "cheerio": "^0.22.0",
@@ -92,10 +93,9 @@
92
93
  "core-js": "^3.1.3",
93
94
  "dateformat": "^3.0.3",
94
95
  "ejs": "^3.0.2",
95
- "escape-string-regexp": "^3.0.0",
96
96
  "eslint": "file:.",
97
97
  "eslint-config-eslint": "file:packages/eslint-config-eslint",
98
- "eslint-plugin-eslint-plugin": "^2.2.1",
98
+ "eslint-plugin-eslint-plugin": "^3.0.3",
99
99
  "eslint-plugin-internal-rules": "file:tools/internal-rules",
100
100
  "eslint-plugin-jsdoc": "^25.4.3",
101
101
  "eslint-plugin-node": "^11.1.0",
@@ -1,8 +0,0 @@
1
- <tr style="display:none" class="f-<%= parentIndex %>">
2
- <td><%= lineNumber %>:<%= columnNumber %></td>
3
- <td class="clr-<%= severityNumber %>"><%= severityName %></td>
4
- <td><%- message %></td>
5
- <td>
6
- <a href="<%= ruleUrl %>" target="_blank" rel="noopener noreferrer"><%= ruleId %></a>
7
- </td>
8
- </tr>
@@ -1,115 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>ESLint Report</title>
6
- <style>
7
- body {
8
- font-family:Arial, "Helvetica Neue", Helvetica, sans-serif;
9
- font-size:16px;
10
- font-weight:normal;
11
- margin:0;
12
- padding:0;
13
- color:#333
14
- }
15
- #overview {
16
- padding:20px 30px
17
- }
18
- td, th {
19
- padding:5px 10px
20
- }
21
- h1 {
22
- margin:0
23
- }
24
- table {
25
- margin:30px;
26
- width:calc(100% - 60px);
27
- max-width:1000px;
28
- border-radius:5px;
29
- border:1px solid #ddd;
30
- border-spacing:0px;
31
- }
32
- th {
33
- font-weight:400;
34
- font-size:medium;
35
- text-align:left;
36
- cursor:pointer
37
- }
38
- td.clr-1, td.clr-2, th span {
39
- font-weight:700
40
- }
41
- th span {
42
- float:right;
43
- margin-left:20px
44
- }
45
- th span:after {
46
- content:"";
47
- clear:both;
48
- display:block
49
- }
50
- tr:last-child td {
51
- border-bottom:none
52
- }
53
- tr td:first-child, tr td:last-child {
54
- color:#9da0a4
55
- }
56
- #overview.bg-0, tr.bg-0 th {
57
- color:#468847;
58
- background:#dff0d8;
59
- border-bottom:1px solid #d6e9c6
60
- }
61
- #overview.bg-1, tr.bg-1 th {
62
- color:#f0ad4e;
63
- background:#fcf8e3;
64
- border-bottom:1px solid #fbeed5
65
- }
66
- #overview.bg-2, tr.bg-2 th {
67
- color:#b94a48;
68
- background:#f2dede;
69
- border-bottom:1px solid #eed3d7
70
- }
71
- td {
72
- border-bottom:1px solid #ddd
73
- }
74
- td.clr-1 {
75
- color:#f0ad4e
76
- }
77
- td.clr-2 {
78
- color:#b94a48
79
- }
80
- td a {
81
- color:#3a33d1;
82
- text-decoration:none
83
- }
84
- td a:hover {
85
- color:#272296;
86
- text-decoration:underline
87
- }
88
- </style>
89
- </head>
90
- <body>
91
- <div id="overview" class="bg-<%= reportColor %>">
92
- <h1>ESLint Report</h1>
93
- <div>
94
- <span><%= reportSummary %></span> - Generated on <%= date %>
95
- </div>
96
- </div>
97
- <table>
98
- <tbody>
99
- <%= results %>
100
- </tbody>
101
- </table>
102
- <script type="text/javascript">
103
- var groups = document.querySelectorAll("tr[data-group]");
104
- for (i = 0; i < groups.length; i++) {
105
- groups[i].addEventListener("click", function() {
106
- var inGroup = document.getElementsByClassName(this.getAttribute("data-group"));
107
- this.innerHTML = (this.innerHTML.indexOf("+") > -1) ? this.innerHTML.replace("+", "-") : this.innerHTML.replace("-", "+");
108
- for (var j = 0; j < inGroup.length; j++) {
109
- inGroup[j].style.display = (inGroup[j].style.display !== "none") ? "none" : "table-row";
110
- }
111
- });
112
- }
113
- </script>
114
- </body>
115
- </html>
@@ -1,6 +0,0 @@
1
- <tr class="bg-<%- color %>" data-group="f-<%- index %>">
2
- <th colspan="4">
3
- [+] <%- filePath %>
4
- <span><%- summary %></span>
5
- </th>
6
- </tr>
@@ -1,5 +0,0 @@
1
- ESLint couldn't find the config "<%- configName %>" to extend from. Please check that the name of the config is correct.
2
-
3
- The config "<%- configName %>" was referenced from the config file in "<%- importerName %>".
4
-
5
- If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
@@ -1,3 +0,0 @@
1
- Failed to read JSON file at <%= path %>:
2
-
3
- <%= message %>
@@ -1,2 +0,0 @@
1
- No files matching the pattern "<%= pattern %>"<% if (globDisabled) { %> (with disabling globs)<% } %> were found.
2
- Please check for typing mistakes in the pattern.
@@ -1,7 +0,0 @@
1
- ESLint couldn't determine the plugin "<%- pluginId %>" uniquely.
2
- <% for (const { filePath, importerName } of plugins) { %>
3
- - <%= filePath %> (loaded in "<%= importerName %>")<% } %>
4
-
5
- Please remove the "plugins" setting from either config or remove either plugin installation.
6
-
7
- If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
@@ -1,8 +0,0 @@
1
- "<%- configName %>" is invalid syntax for a config specifier.
2
-
3
- * If your intention is to extend from a configuration exported from the plugin, add the configuration name after a slash: e.g. "<%- configName %>/myConfig".
4
- * If this is the name of a shareable config instead of a plugin, remove the "plugin:" prefix: i.e. "<%- configName.slice("plugin:".length) %>".
5
-
6
- "<%- configName %>" was referenced from the config file in "<%- importerName %>".
7
-
8
- If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
@@ -1,11 +0,0 @@
1
- ESLint couldn't find the plugin "<%- pluginName %>".
2
-
3
- (The package "<%- pluginName %>" was not found when loaded as a Node module from the directory "<%- resolvePluginsRelativeTo %>".)
4
-
5
- It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
6
-
7
- npm install <%- pluginName %>@latest --save-dev
8
-
9
- The plugin "<%- pluginName %>" was referenced from the config file in "<%- importerName %>".
10
-
11
- If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
@@ -1,3 +0,0 @@
1
- ESLint couldn't find the plugin "<%- pluginName %>". because there is whitespace in the name. Please check your configuration and remove all whitespace from the plugin name.
2
-
3
- If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.