eslint 8.29.0 → 8.30.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/lib/cli-engine/formatters/formatters-meta.json +46 -0
- package/lib/config/default-config.js +1 -1
- package/lib/options.js +5 -5
- package/lib/rule-tester/flat-rule-tester.js +11 -9
- package/lib/rule-tester/rule-tester.js +11 -7
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/multiline-ternary.js +2 -2
- package/lib/rules/no-else-return.js +1 -1
- package/lib/rules/no-return-await.js +28 -1
- package/lib/rules/no-unneeded-ternary.js +1 -1
- package/lib/rules/no-var.js +1 -1
- package/package.json +18 -18
@@ -0,0 +1,46 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "checkstyle",
|
4
|
+
"description": "Outputs results to the [Checkstyle](https://checkstyle.sourceforge.io/) format."
|
5
|
+
},
|
6
|
+
{
|
7
|
+
"name": "compact",
|
8
|
+
"description": "Human-readable output format. Mimics the default output of JSHint."
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"name": "html",
|
12
|
+
"description": "Outputs results to HTML. The `html` formatter is useful for visual presentation in the browser."
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "jslint-xml",
|
16
|
+
"description": "Outputs results to format compatible with the [JSLint Jenkins plugin](https://plugins.jenkins.io/jslint/)."
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"name": "json-with-metadata",
|
20
|
+
"description": "Outputs JSON-serialized results. The `json-with-metadata` provides the same linting results as the [`json`](#json) formatter with additional metadata about the rules applied. The linting results are included in the `results` property and the rules metadata is included in the `metadata` property.\n\nAlternatively, you can use the [ESLint Node.js API](../../developer-guide/nodejs-api) to programmatically use ESLint."
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"name": "json",
|
24
|
+
"description": "Outputs JSON-serialized results. The `json` formatter is useful when you want to programmatically work with the CLI's linting results.\n\nAlternatively, you can use the [ESLint Node.js API](../../developer-guide/nodejs-api) to programmatically use ESLint."
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "junit",
|
28
|
+
"description": "Outputs results to format compatible with the [JUnit Jenkins plugin](https://plugins.jenkins.io/junit/)."
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"name": "stylish",
|
32
|
+
"description": "Human-readable output format. This is the default formatter."
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "tap",
|
36
|
+
"description": "Outputs results to the [Test Anything Protocol (TAP)](https://testanything.org/) specification format."
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "unix",
|
40
|
+
"description": "Outputs results to a format similar to many commands in UNIX-like systems. Parsable with tools such as [grep](https://www.gnu.org/software/grep/manual/grep.html), [sed](https://www.gnu.org/software/sed/manual/sed.html), and [awk](https://www.gnu.org/software/gawk/manual/gawk.html)."
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"name": "visualstudio",
|
44
|
+
"description": "Outputs results to format compatible with the integrated terminal of the [Visual Studio](https://visualstudio.microsoft.com/) IDE. When using Visual Studio, you can click on the linting results in the integrated terminal to go to the issue in the source code."
|
45
|
+
}
|
46
|
+
]
|
package/lib/options.js
CHANGED
@@ -177,7 +177,7 @@ module.exports = function(usingFlatConfig) {
|
|
177
177
|
},
|
178
178
|
resolvePluginsFlag,
|
179
179
|
{
|
180
|
-
heading: "
|
180
|
+
heading: "Specify Rules and Plugins"
|
181
181
|
},
|
182
182
|
{
|
183
183
|
option: "plugin",
|
@@ -191,7 +191,7 @@ module.exports = function(usingFlatConfig) {
|
|
191
191
|
},
|
192
192
|
rulesDirFlag,
|
193
193
|
{
|
194
|
-
heading: "
|
194
|
+
heading: "Fix Problems"
|
195
195
|
},
|
196
196
|
{
|
197
197
|
option: "fix",
|
@@ -211,7 +211,7 @@ module.exports = function(usingFlatConfig) {
|
|
211
211
|
description: "Specify the types of fixes to apply (directive, problem, suggestion, layout)"
|
212
212
|
},
|
213
213
|
{
|
214
|
-
heading: "
|
214
|
+
heading: "Ignore Files"
|
215
215
|
},
|
216
216
|
ignorePathFlag,
|
217
217
|
{
|
@@ -229,7 +229,7 @@ module.exports = function(usingFlatConfig) {
|
|
229
229
|
}]
|
230
230
|
},
|
231
231
|
{
|
232
|
-
heading: "
|
232
|
+
heading: "Use stdin"
|
233
233
|
},
|
234
234
|
{
|
235
235
|
option: "stdin",
|
@@ -243,7 +243,7 @@ module.exports = function(usingFlatConfig) {
|
|
243
243
|
description: "Specify filename to process STDIN as"
|
244
244
|
},
|
245
245
|
{
|
246
|
-
heading: "
|
246
|
+
heading: "Handle Warnings"
|
247
247
|
},
|
248
248
|
{
|
249
249
|
option: "quiet",
|
@@ -619,15 +619,17 @@ class FlatRuleTester {
|
|
619
619
|
plugins: {
|
620
620
|
"rule-tester": {
|
621
621
|
rules: {
|
622
|
-
"validate-ast"
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
622
|
+
"validate-ast": {
|
623
|
+
create() {
|
624
|
+
return {
|
625
|
+
Program(node) {
|
626
|
+
beforeAST = cloneDeeplyExcludesParent(node);
|
627
|
+
},
|
628
|
+
"Program:exit"(node) {
|
629
|
+
afterAST = node;
|
630
|
+
}
|
631
|
+
};
|
632
|
+
}
|
631
633
|
}
|
632
634
|
}
|
633
635
|
}
|
@@ -632,14 +632,18 @@ class RuleTester {
|
|
632
632
|
* The goal is to check whether or not AST was modified when
|
633
633
|
* running the rule under test.
|
634
634
|
*/
|
635
|
-
linter.defineRule("rule-tester/validate-ast",
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
635
|
+
linter.defineRule("rule-tester/validate-ast", {
|
636
|
+
create() {
|
637
|
+
return {
|
638
|
+
Program(node) {
|
639
|
+
beforeAST = cloneDeeplyExcludesParent(node);
|
640
|
+
},
|
641
|
+
"Program:exit"(node) {
|
642
|
+
afterAST = node;
|
643
|
+
}
|
644
|
+
};
|
641
645
|
}
|
642
|
-
})
|
646
|
+
});
|
643
647
|
|
644
648
|
if (typeof config.parser === "string") {
|
645
649
|
assert(path.isAbsolute(config.parser), "Parsers provided as strings to RuleTester must be absolute paths");
|
@@ -73,7 +73,7 @@ module.exports = {
|
|
73
73
|
end: lastTokenOfTest.loc.end
|
74
74
|
},
|
75
75
|
messageId: "unexpectedTestCons",
|
76
|
-
fix
|
76
|
+
fix(fixer) {
|
77
77
|
if (hasComments) {
|
78
78
|
return null;
|
79
79
|
}
|
@@ -101,7 +101,7 @@ module.exports = {
|
|
101
101
|
end: lastTokenOfConsequent.loc.end
|
102
102
|
},
|
103
103
|
messageId: "unexpectedConsAlt",
|
104
|
-
fix
|
104
|
+
fix(fixer) {
|
105
105
|
if (hasComments) {
|
106
106
|
return null;
|
107
107
|
}
|
@@ -13,6 +13,7 @@ const astUtils = require("./utils/ast-utils");
|
|
13
13
|
/** @type {import('../shared/types').Rule} */
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
|
+
hasSuggestions: true,
|
16
17
|
type: "suggestion",
|
17
18
|
|
18
19
|
docs: {
|
@@ -29,6 +30,7 @@ module.exports = {
|
|
29
30
|
],
|
30
31
|
|
31
32
|
messages: {
|
33
|
+
removeAwait: "Remove redundant `await`.",
|
32
34
|
redundantUseOfAwait: "Redundant use of `await` on a return value."
|
33
35
|
}
|
34
36
|
},
|
@@ -44,7 +46,32 @@ module.exports = {
|
|
44
46
|
context.report({
|
45
47
|
node: context.getSourceCode().getFirstToken(node),
|
46
48
|
loc: node.loc,
|
47
|
-
messageId: "redundantUseOfAwait"
|
49
|
+
messageId: "redundantUseOfAwait",
|
50
|
+
suggest: [
|
51
|
+
{
|
52
|
+
messageId: "removeAwait",
|
53
|
+
fix(fixer) {
|
54
|
+
const sourceCode = context.getSourceCode();
|
55
|
+
const [awaitToken, tokenAfterAwait] = sourceCode.getFirstTokens(node, 2);
|
56
|
+
|
57
|
+
const areAwaitAndAwaitedExpressionOnTheSameLine = awaitToken.loc.start.line === tokenAfterAwait.loc.start.line;
|
58
|
+
|
59
|
+
if (!areAwaitAndAwaitedExpressionOnTheSameLine) {
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
|
63
|
+
const [startOfAwait, endOfAwait] = awaitToken.range;
|
64
|
+
|
65
|
+
const characterAfterAwait = sourceCode.text[endOfAwait];
|
66
|
+
const trimLength = characterAfterAwait === " " ? 1 : 0;
|
67
|
+
|
68
|
+
const range = [startOfAwait, endOfAwait + trimLength];
|
69
|
+
|
70
|
+
return fixer.removeRange(range);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
]
|
74
|
+
|
48
75
|
});
|
49
76
|
}
|
50
77
|
|
package/lib/rules/no-var.js
CHANGED
@@ -159,7 +159,7 @@ function hasReferenceInTDZ(node) {
|
|
159
159
|
return !reference.init && (
|
160
160
|
start < idStart ||
|
161
161
|
(defaultValue !== null && start >= defaultStart && end <= defaultEnd) ||
|
162
|
-
(start >= initStart && end <= initEnd)
|
162
|
+
(!astUtils.isFunction(node) && start >= initStart && end <= initEnd)
|
163
163
|
);
|
164
164
|
});
|
165
165
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.30.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -13,22 +13,22 @@
|
|
13
13
|
"./use-at-your-own-risk": "./lib/unsupported-api.js"
|
14
14
|
},
|
15
15
|
"scripts": {
|
16
|
+
"build:docs:update-links": "node tools/fetch-docs-links.js",
|
17
|
+
"release:generate:latest": "node Makefile.js generateRelease",
|
18
|
+
"release:generate:alpha": "node Makefile.js generatePrerelease -- alpha",
|
19
|
+
"release:generate:beta": "node Makefile.js generatePrerelease -- beta",
|
20
|
+
"release:publish": "node Makefile.js publishRelease",
|
21
|
+
"release:generate:rc": "node Makefile.js generatePrerelease -- rc",
|
22
|
+
"build:site": "node Makefile.js gensite",
|
23
|
+
"build:webpack": "node Makefile.js webpack",
|
24
|
+
"lint": "node Makefile.js lint",
|
25
|
+
"lint:fix": "node Makefile.js lint -- fix",
|
26
|
+
"lint:docs:js": "node Makefile.js lintDocsJS",
|
27
|
+
"lint:fix:docs:js": "node Makefile.js lintDocsJS -- fix",
|
16
28
|
"test": "node Makefile.js test",
|
17
29
|
"test:cli": "mocha",
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"fix": "node Makefile.js lint -- fix",
|
21
|
-
"fix:docsjs": "node Makefile.js lintDocsJS -- fix",
|
22
|
-
"fuzz": "node Makefile.js fuzz",
|
23
|
-
"generate-release": "node Makefile.js generateRelease",
|
24
|
-
"generate-alpharelease": "node Makefile.js generatePrerelease -- alpha",
|
25
|
-
"generate-betarelease": "node Makefile.js generatePrerelease -- beta",
|
26
|
-
"generate-rcrelease": "node Makefile.js generatePrerelease -- rc",
|
27
|
-
"publish-release": "node Makefile.js publishRelease",
|
28
|
-
"gensite": "node Makefile.js gensite",
|
29
|
-
"webpack": "node Makefile.js webpack",
|
30
|
-
"perf": "node Makefile.js perf",
|
31
|
-
"docs:update-links": "node tools/fetch-docs-links.js"
|
30
|
+
"test:fuzz": "node Makefile.js fuzz",
|
31
|
+
"test:performance": "node Makefile.js perf"
|
32
32
|
},
|
33
33
|
"gitHooks": {
|
34
34
|
"pre-commit": "lint-staged"
|
@@ -55,8 +55,8 @@
|
|
55
55
|
"homepage": "https://eslint.org",
|
56
56
|
"bugs": "https://github.com/eslint/eslint/issues/",
|
57
57
|
"dependencies": {
|
58
|
-
"@eslint/eslintrc": "^1.
|
59
|
-
"@humanwhocodes/config-array": "^0.11.
|
58
|
+
"@eslint/eslintrc": "^1.4.0",
|
59
|
+
"@humanwhocodes/config-array": "^0.11.8",
|
60
60
|
"@humanwhocodes/module-importer": "^1.0.1",
|
61
61
|
"@nodelib/fs.walk": "^1.2.8",
|
62
62
|
"ajv": "^6.10.0",
|
@@ -75,7 +75,7 @@
|
|
75
75
|
"file-entry-cache": "^6.0.1",
|
76
76
|
"find-up": "^5.0.0",
|
77
77
|
"glob-parent": "^6.0.2",
|
78
|
-
"globals": "^13.
|
78
|
+
"globals": "^13.19.0",
|
79
79
|
"grapheme-splitter": "^1.0.4",
|
80
80
|
"ignore": "^5.2.0",
|
81
81
|
"import-fresh": "^3.0.0",
|