eslint 7.23.0 → 7.27.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 (62) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +7 -2
  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/init/autoconfig.js +2 -2
  8. package/lib/init/config-file.js +1 -0
  9. package/lib/init/config-initializer.js +14 -1
  10. package/lib/init/npm-utils.js +1 -0
  11. package/lib/linter/apply-disable-directives.js +15 -3
  12. package/lib/linter/linter.js +9 -7
  13. package/lib/linter/node-event-generator.js +43 -6
  14. package/lib/rule-tester/rule-tester.js +14 -10
  15. package/lib/rules/comma-dangle.js +16 -7
  16. package/lib/rules/comma-spacing.js +1 -1
  17. package/lib/rules/complexity.js +2 -3
  18. package/lib/rules/consistent-return.js +2 -2
  19. package/lib/rules/eol-last.js +2 -7
  20. package/lib/rules/indent.js +8 -9
  21. package/lib/rules/max-lines-per-function.js +2 -3
  22. package/lib/rules/max-lines.js +32 -7
  23. package/lib/rules/max-params.js +2 -3
  24. package/lib/rules/max-statements.js +2 -3
  25. package/lib/rules/no-fallthrough.js +2 -8
  26. package/lib/rules/no-implicit-coercion.js +37 -0
  27. package/lib/rules/no-multi-assign.js +15 -2
  28. package/lib/rules/no-restricted-imports.js +61 -24
  29. package/lib/rules/no-unused-vars.js +53 -16
  30. package/lib/rules/no-useless-backreference.js +1 -2
  31. package/lib/rules/no-useless-computed-key.js +8 -2
  32. package/lib/rules/no-warning-comments.js +1 -1
  33. package/lib/rules/object-curly-newline.js +19 -4
  34. package/lib/rules/radix.js +19 -3
  35. package/lib/rules/require-atomic-updates.js +23 -20
  36. package/lib/rules/spaced-comment.js +2 -2
  37. package/lib/rules/utils/ast-utils.js +2 -2
  38. package/lib/shared/deprecation-warnings.js +12 -3
  39. package/lib/shared/string-utils.js +22 -0
  40. package/lib/source-code/source-code.js +6 -5
  41. package/lib/source-code/token-store/utils.js +4 -12
  42. package/messages/{all-files-ignored.txt → all-files-ignored.js} +10 -2
  43. package/messages/extend-config-missing.js +13 -0
  44. package/messages/failed-to-read-json.js +11 -0
  45. package/messages/file-not-found.js +10 -0
  46. package/messages/{no-config-found.txt → no-config-found.js} +9 -1
  47. package/messages/plugin-conflict.js +22 -0
  48. package/messages/plugin-invalid.js +16 -0
  49. package/messages/plugin-missing.js +19 -0
  50. package/messages/{print-config-with-directory-path.txt → print-config-with-directory-path.js} +6 -0
  51. package/messages/whitespace-found.js +11 -0
  52. package/package.json +10 -13
  53. package/lib/cli-engine/formatters/html-template-message.html +0 -8
  54. package/lib/cli-engine/formatters/html-template-page.html +0 -115
  55. package/lib/cli-engine/formatters/html-template-result.html +0 -6
  56. package/messages/extend-config-missing.txt +0 -5
  57. package/messages/failed-to-read-json.txt +0 -3
  58. package/messages/file-not-found.txt +0 -2
  59. package/messages/plugin-conflict.txt +0 -7
  60. package/messages/plugin-invalid.txt +0 -8
  61. package/messages/plugin-missing.txt +0 -11
  62. package/messages/whitespace-found.txt +0 -3
@@ -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.23.0",
3
+ "version": "7.27.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -27,10 +27,7 @@
27
27
  "pre-commit": "lint-staged"
28
28
  },
29
29
  "lint-staged": {
30
- "*.js": [
31
- "eslint --fix",
32
- "git add"
33
- ],
30
+ "*.js": "eslint --fix",
34
31
  "*.md": "markdownlint"
35
32
  },
36
33
  "files": [
@@ -47,19 +44,21 @@
47
44
  "bugs": "https://github.com/eslint/eslint/issues/",
48
45
  "dependencies": {
49
46
  "@babel/code-frame": "7.12.11",
50
- "@eslint/eslintrc": "^0.4.0",
47
+ "@eslint/eslintrc": "^0.4.1",
51
48
  "ajv": "^6.10.0",
52
49
  "chalk": "^4.0.0",
53
50
  "cross-spawn": "^7.0.2",
54
51
  "debug": "^4.0.1",
55
52
  "doctrine": "^3.0.0",
56
53
  "enquirer": "^2.3.5",
54
+ "escape-string-regexp": "^4.0.0",
57
55
  "eslint-scope": "^5.1.1",
58
56
  "eslint-utils": "^2.1.0",
59
57
  "eslint-visitor-keys": "^2.0.0",
60
58
  "espree": "^7.3.1",
61
59
  "esquery": "^1.4.0",
62
60
  "esutils": "^2.0.2",
61
+ "fast-deep-equal": "^3.1.3",
63
62
  "file-entry-cache": "^6.0.1",
64
63
  "functional-red-black-tree": "^1.0.1",
65
64
  "glob-parent": "^5.0.0",
@@ -71,7 +70,7 @@
71
70
  "js-yaml": "^3.13.1",
72
71
  "json-stable-stringify-without-jsonify": "^1.0.1",
73
72
  "levn": "^0.4.1",
74
- "lodash": "^4.17.21",
73
+ "lodash.merge": "^4.6.2",
75
74
  "minimatch": "^3.0.4",
76
75
  "natural-compare": "^1.4.0",
77
76
  "optionator": "^0.9.1",
@@ -80,14 +79,13 @@
80
79
  "semver": "^7.2.1",
81
80
  "strip-ansi": "^6.0.0",
82
81
  "strip-json-comments": "^3.1.0",
83
- "table": "^6.0.4",
82
+ "table": "^6.0.9",
84
83
  "text-table": "^0.2.0",
85
84
  "v8-compile-cache": "^2.0.3"
86
85
  },
87
86
  "devDependencies": {
88
87
  "@babel/core": "^7.4.3",
89
88
  "@babel/preset-env": "^7.4.3",
90
- "acorn": "^7.2.0",
91
89
  "babel-loader": "^8.0.5",
92
90
  "chai": "^4.0.1",
93
91
  "cheerio": "^0.22.0",
@@ -95,7 +93,6 @@
95
93
  "core-js": "^3.1.3",
96
94
  "dateformat": "^3.0.3",
97
95
  "ejs": "^3.0.2",
98
- "escape-string-regexp": "^3.0.0",
99
96
  "eslint": "file:.",
100
97
  "eslint-config-eslint": "file:packages/eslint-config-eslint",
101
98
  "eslint-plugin-eslint-plugin": "^2.2.1",
@@ -103,7 +100,7 @@
103
100
  "eslint-plugin-jsdoc": "^25.4.3",
104
101
  "eslint-plugin-node": "^11.1.0",
105
102
  "eslint-release": "^2.0.0",
106
- "eslump": "^2.0.0",
103
+ "eslump": "^3.0.0",
107
104
  "esprima": "^4.0.1",
108
105
  "fs-teardown": "^0.1.0",
109
106
  "glob": "^7.1.6",
@@ -118,8 +115,8 @@
118
115
  "markdownlint": "^0.19.0",
119
116
  "markdownlint-cli": "^0.22.0",
120
117
  "memfs": "^3.0.1",
121
- "mocha": "^7.1.1",
122
- "mocha-junit-reporter": "^1.23.0",
118
+ "mocha": "^8.3.2",
119
+ "mocha-junit-reporter": "^2.0.0",
123
120
  "node-polyfill-webpack-plugin": "^1.0.3",
124
121
  "npm-license": "^0.3.3",
125
122
  "nyc": "^15.0.1",
@@ -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.