eslint 7.26.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.
- package/CHANGELOG.md +13 -0
- package/README.md +7 -2
- package/bin/eslint.js +2 -12
- package/lib/cli-engine/file-enumerator.js +1 -1
- package/lib/cli-engine/formatters/html.js +193 -9
- package/lib/init/autoconfig.js +2 -2
- package/lib/linter/apply-disable-directives.js +15 -3
- package/lib/linter/linter.js +6 -4
- package/lib/linter/node-event-generator.js +43 -6
- package/lib/rule-tester/rule-tester.js +14 -10
- package/lib/rules/comma-dangle.js +16 -7
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/complexity.js +2 -3
- package/lib/rules/consistent-return.js +2 -2
- package/lib/rules/eol-last.js +2 -7
- package/lib/rules/indent.js +8 -9
- package/lib/rules/max-lines-per-function.js +2 -3
- package/lib/rules/max-lines.js +32 -7
- package/lib/rules/max-params.js +2 -3
- package/lib/rules/max-statements.js +2 -3
- package/lib/rules/no-fallthrough.js +2 -8
- package/lib/rules/no-restricted-imports.js +61 -24
- package/lib/rules/no-unused-vars.js +27 -3
- package/lib/rules/no-useless-backreference.js +1 -2
- package/lib/rules/no-useless-computed-key.js +8 -2
- package/lib/rules/no-warning-comments.js +1 -1
- package/lib/rules/object-curly-newline.js +19 -4
- package/lib/rules/spaced-comment.js +2 -2
- package/lib/rules/utils/ast-utils.js +2 -2
- package/lib/shared/deprecation-warnings.js +12 -3
- package/lib/shared/string-utils.js +22 -0
- package/lib/source-code/source-code.js +6 -5
- package/lib/source-code/token-store/utils.js +4 -12
- package/messages/{all-files-ignored.txt → all-files-ignored.js} +10 -2
- package/messages/extend-config-missing.js +13 -0
- package/messages/failed-to-read-json.js +11 -0
- package/messages/file-not-found.js +10 -0
- package/messages/{no-config-found.txt → no-config-found.js} +9 -1
- package/messages/plugin-conflict.js +22 -0
- package/messages/plugin-invalid.js +16 -0
- package/messages/plugin-missing.js +19 -0
- package/messages/{print-config-with-directory-path.txt → print-config-with-directory-path.js} +6 -0
- package/messages/whitespace-found.js +11 -0
- package/package.json +5 -4
- package/lib/cli-engine/formatters/html-template-message.html +0 -8
- package/lib/cli-engine/formatters/html-template-page.html +0 -115
- package/lib/cli-engine/formatters/html-template-result.html +0 -6
- package/messages/extend-config-missing.txt +0 -5
- package/messages/failed-to-read-json.txt +0 -3
- package/messages/file-not-found.txt +0 -2
- package/messages/plugin-conflict.txt +0 -7
- package/messages/plugin-invalid.txt +0 -8
- package/messages/plugin-missing.txt +0 -11
- package/messages/whitespace-found.txt +0 -3
@@ -12,8 +12,7 @@ const
|
|
12
12
|
{ isCommentToken } = require("eslint-utils"),
|
13
13
|
TokenStore = require("./token-store"),
|
14
14
|
astUtils = require("../shared/ast-utils"),
|
15
|
-
Traverser = require("../shared/traverser")
|
16
|
-
lodash = require("lodash");
|
15
|
+
Traverser = require("../shared/traverser");
|
17
16
|
|
18
17
|
//------------------------------------------------------------------------------
|
19
18
|
// Private
|
@@ -531,10 +530,12 @@ class SourceCode extends TokenStore {
|
|
531
530
|
}
|
532
531
|
|
533
532
|
/*
|
534
|
-
* To figure out which line
|
535
|
-
* be inserted into
|
533
|
+
* To figure out which line index is on, determine the last place at which index could
|
534
|
+
* be inserted into lineStartIndices to keep the list sorted.
|
536
535
|
*/
|
537
|
-
const lineNumber =
|
536
|
+
const lineNumber = index >= this.lineStartIndices[this.lineStartIndices.length - 1]
|
537
|
+
? this.lineStartIndices.length
|
538
|
+
: this.lineStartIndices.findIndex(el => index < el);
|
538
539
|
|
539
540
|
return { line: lineNumber, column: index - this.lineStartIndices[lineNumber - 1] };
|
540
541
|
}
|
@@ -4,12 +4,6 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
//------------------------------------------------------------------------------
|
8
|
-
// Requirements
|
9
|
-
//------------------------------------------------------------------------------
|
10
|
-
|
11
|
-
const lodash = require("lodash");
|
12
|
-
|
13
7
|
//------------------------------------------------------------------------------
|
14
8
|
// Helpers
|
15
9
|
//------------------------------------------------------------------------------
|
@@ -29,18 +23,16 @@ function getStartLocation(token) {
|
|
29
23
|
//------------------------------------------------------------------------------
|
30
24
|
|
31
25
|
/**
|
32
|
-
*
|
26
|
+
* Finds the index of the first token which is after the given location.
|
33
27
|
* If it was not found, this returns `tokens.length`.
|
34
28
|
* @param {(Token|Comment)[]} tokens It searches the token in this list.
|
35
29
|
* @param {number} location The location to search.
|
36
30
|
* @returns {number} The found index or `tokens.length`.
|
37
31
|
*/
|
38
32
|
exports.search = function search(tokens, location) {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
getStartLocation
|
43
|
-
);
|
33
|
+
const index = tokens.findIndex(el => location <= getStartLocation(el));
|
34
|
+
|
35
|
+
return index === -1 ? tokens.length : index;
|
44
36
|
};
|
45
37
|
|
46
38
|
/**
|
@@ -1,8 +1,16 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
|
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,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
|
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
|
+
};
|
@@ -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.
|
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": {
|
@@ -51,12 +51,14 @@
|
|
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
64
|
"glob-parent": "^5.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.
|
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,7 +79,7 @@
|
|
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.
|
82
|
+
"table": "^6.0.9",
|
81
83
|
"text-table": "^0.2.0",
|
82
84
|
"v8-compile-cache": "^2.0.3"
|
83
85
|
},
|
@@ -91,7 +93,6 @@
|
|
91
93
|
"core-js": "^3.1.3",
|
92
94
|
"dateformat": "^3.0.3",
|
93
95
|
"ejs": "^3.0.2",
|
94
|
-
"escape-string-regexp": "^3.0.0",
|
95
96
|
"eslint": "file:.",
|
96
97
|
"eslint-config-eslint": "file:packages/eslint-config-eslint",
|
97
98
|
"eslint-plugin-eslint-plugin": "^2.2.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,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,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.
|