eslint 8.12.0 → 8.15.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/README.md +17 -12
- package/lib/cli-engine/cli-engine.js +2 -1
- package/lib/cli-engine/formatters/html.js +3 -3
- package/lib/eslint/eslint.js +4 -19
- package/lib/linter/apply-disable-directives.js +1 -1
- package/lib/rules/index.js +1 -0
- package/lib/rules/no-constant-binary-expression.js +500 -0
- package/lib/rules/no-constant-condition.js +4 -197
- package/lib/rules/no-eval.js +17 -16
- package/lib/rules/no-underscore-dangle.js +30 -1
- package/lib/rules/operator-assignment.js +7 -5
- package/lib/rules/utils/ast-utils.js +203 -7
- package/lib/shared/types.js +24 -0
- package/messages/all-files-ignored.js +1 -1
- package/messages/extend-config-missing.js +1 -1
- package/messages/failed-to-read-json.js +1 -1
- package/messages/file-not-found.js +1 -1
- package/messages/no-config-found.js +1 -1
- package/messages/plugin-invalid.js +1 -1
- package/messages/plugin-missing.js +1 -1
- package/messages/print-config-with-directory-path.js +1 -1
- package/messages/whitespace-found.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
@@ -235,15 +235,15 @@ Milos Djermanovic
|
|
235
235
|
The people who review and implement new features.
|
236
236
|
|
237
237
|
<table><tbody><tr><td align="center" valign="top" width="11%">
|
238
|
-
<a href="https://github.com/mysticatea">
|
239
|
-
<img src="https://github.com/mysticatea.png?s=75" width="75" height="75"><br />
|
240
|
-
Toru Nagashima
|
241
|
-
</a>
|
242
|
-
</td><td align="center" valign="top" width="11%">
|
243
238
|
<a href="https://github.com/aladdin-add">
|
244
239
|
<img src="https://github.com/aladdin-add.png?s=75" width="75" height="75"><br />
|
245
240
|
唯然
|
246
241
|
</a>
|
242
|
+
</td><td align="center" valign="top" width="11%">
|
243
|
+
<a href="https://github.com/snitin315">
|
244
|
+
<img src="https://github.com/snitin315.png?s=75" width="75" height="75"><br />
|
245
|
+
Nitin Kumar
|
246
|
+
</a>
|
247
247
|
</td></tr></tbody></table>
|
248
248
|
|
249
249
|
### Committers
|
@@ -261,6 +261,16 @@ Brett Zamir
|
|
261
261
|
Bryan Mishkin
|
262
262
|
</a>
|
263
263
|
</td><td align="center" valign="top" width="11%">
|
264
|
+
<a href="https://github.com/mysticatea">
|
265
|
+
<img src="https://github.com/mysticatea.png?s=75" width="75" height="75"><br />
|
266
|
+
Toru Nagashima
|
267
|
+
</a>
|
268
|
+
</td><td align="center" valign="top" width="11%">
|
269
|
+
<a href="https://github.com/SaraSoueidan">
|
270
|
+
<img src="https://github.com/SaraSoueidan.png?s=75" width="75" height="75"><br />
|
271
|
+
Sara Soueidan
|
272
|
+
</a>
|
273
|
+
</td><td align="center" valign="top" width="11%">
|
264
274
|
<a href="https://github.com/g-plane">
|
265
275
|
<img src="https://github.com/g-plane.png?s=75" width="75" height="75"><br />
|
266
276
|
Pig Fang
|
@@ -275,11 +285,6 @@ Anix
|
|
275
285
|
<img src="https://github.com/yeonjuan.png?s=75" width="75" height="75"><br />
|
276
286
|
YeonJuan
|
277
287
|
</a>
|
278
|
-
</td><td align="center" valign="top" width="11%">
|
279
|
-
<a href="https://github.com/snitin315">
|
280
|
-
<img src="https://github.com/snitin315.png?s=75" width="75" height="75"><br />
|
281
|
-
Nitin Kumar
|
282
|
-
</a>
|
283
288
|
</td></tr></tbody></table>
|
284
289
|
|
285
290
|
<!--teamend-->
|
@@ -292,9 +297,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
292
297
|
<!--sponsorsstart-->
|
293
298
|
<h3>Platinum Sponsors</h3>
|
294
299
|
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
|
295
|
-
<p><a href="https://contra.com"><img src="https://images.opencollective.com/contra1/c70f93f/logo.png" alt="Contra" height="96"></a> <a href="https://
|
300
|
+
<p><a href="https://contra.com"><img src="https://images.opencollective.com/contra1/c70f93f/logo.png" alt="Contra" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="96"></a> <a href="https://substack.com/"><img src="https://avatars.githubusercontent.com/u/53023767?v=4" alt="Substack" height="96"></a></p><h3>Silver Sponsors</h3>
|
296
301
|
<p><a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a></p><h3>Bronze Sponsors</h3>
|
297
|
-
<p><a href="https://launchdarkly.com"><img src="https://images.opencollective.com/launchdarkly/574bb9e/logo.png" alt="launchdarkly" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a></p>
|
302
|
+
<p><a href="https://launchdarkly.com"><img src="https://images.opencollective.com/launchdarkly/574bb9e/logo.png" alt="launchdarkly" height="32"></a> <a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a></p>
|
298
303
|
<!--sponsorsend-->
|
299
304
|
|
300
305
|
## <a name="technology-sponsors"></a>Technology Sponsors
|
@@ -56,6 +56,7 @@ const validFixTypes = new Set(["directive", "problem", "suggestion", "layout"]);
|
|
56
56
|
/** @typedef {import("../shared/types").Plugin} Plugin */
|
57
57
|
/** @typedef {import("../shared/types").RuleConf} RuleConf */
|
58
58
|
/** @typedef {import("../shared/types").Rule} Rule */
|
59
|
+
/** @typedef {import("../shared/types").FormatterFunction} FormatterFunction */
|
59
60
|
/** @typedef {ReturnType<CascadingConfigArrayFactory.getConfigArrayForFile>} ConfigArray */
|
60
61
|
/** @typedef {ReturnType<ConfigArray.extractConfig>} ExtractedConfig */
|
61
62
|
|
@@ -1002,7 +1003,7 @@ class CLIEngine {
|
|
1002
1003
|
* @param {string} [format] The name of the format to load or the path to a
|
1003
1004
|
* custom formatter.
|
1004
1005
|
* @throws {any} As may be thrown by requiring of formatter
|
1005
|
-
* @returns {(
|
1006
|
+
* @returns {(FormatterFunction|null)} The formatter function or null if the `format` is not a string.
|
1006
1007
|
*/
|
1007
1008
|
getFormatter(format) {
|
1008
1009
|
|
@@ -151,7 +151,7 @@ function pageTemplate(it) {
|
|
151
151
|
</script>
|
152
152
|
</body>
|
153
153
|
</html>
|
154
|
-
`.
|
154
|
+
`.trimStart();
|
155
155
|
}
|
156
156
|
|
157
157
|
/**
|
@@ -222,7 +222,7 @@ function messageTemplate(it) {
|
|
222
222
|
<a href="${ruleUrl ? ruleUrl : ""}" target="_blank" rel="noopener noreferrer">${ruleId ? ruleId : ""}</a>
|
223
223
|
</td>
|
224
224
|
</tr>
|
225
|
-
`.
|
225
|
+
`.trimStart();
|
226
226
|
}
|
227
227
|
|
228
228
|
/**
|
@@ -280,7 +280,7 @@ function resultTemplate(it) {
|
|
280
280
|
<span>${encodeHTML(summary)}</span>
|
281
281
|
</th>
|
282
282
|
</tr>
|
283
|
-
`.
|
283
|
+
`.trimStart();
|
284
284
|
}
|
285
285
|
|
286
286
|
/**
|
package/lib/eslint/eslint.js
CHANGED
@@ -35,10 +35,11 @@ const { version } = require("../../package.json");
|
|
35
35
|
/** @typedef {import("../shared/types").SuppressedLintMessage} SuppressedLintMessage */
|
36
36
|
/** @typedef {import("../shared/types").Plugin} Plugin */
|
37
37
|
/** @typedef {import("../shared/types").Rule} Rule */
|
38
|
+
/** @typedef {import("../shared/types").LintResult} LintResult */
|
38
39
|
|
39
40
|
/**
|
40
41
|
* The main formatter object.
|
41
|
-
* @typedef
|
42
|
+
* @typedef LoadedFormatter
|
42
43
|
* @property {function(LintResult[]): string | Promise<string>} format format function.
|
43
44
|
*/
|
44
45
|
|
@@ -74,22 +75,6 @@ const { version } = require("../../package.json");
|
|
74
75
|
* @property {Object} definition The plugin definition.
|
75
76
|
*/
|
76
77
|
|
77
|
-
/**
|
78
|
-
* A linting result.
|
79
|
-
* @typedef {Object} LintResult
|
80
|
-
* @property {string} filePath The path to the file that was linted.
|
81
|
-
* @property {LintMessage[]} messages All of the messages for the result.
|
82
|
-
* @property {SuppressedLintMessage[]} suppressedMessages All of the suppressed messages for the result.
|
83
|
-
* @property {number} errorCount Number of errors for the result.
|
84
|
-
* @property {number} fatalErrorCount Number of fatal errors for the result.
|
85
|
-
* @property {number} warningCount Number of warnings for the result.
|
86
|
-
* @property {number} fixableErrorCount Number of fixable errors for the result.
|
87
|
-
* @property {number} fixableWarningCount Number of fixable warnings for the result.
|
88
|
-
* @property {string} [source] The source code of the file that was linted.
|
89
|
-
* @property {string} [output] The source code of the file that was linted, with as many fixes applied as possible.
|
90
|
-
* @property {DeprecatedRuleInfo[]} usedDeprecatedRules The list of used deprecated rules.
|
91
|
-
*/
|
92
|
-
|
93
78
|
/**
|
94
79
|
* Private members for the `ESLint` instance.
|
95
80
|
* @typedef {Object} ESLintPrivateMembers
|
@@ -619,7 +604,7 @@ class ESLint {
|
|
619
604
|
* - `@foo` → `@foo/eslint-formatter`
|
620
605
|
* - `@foo/bar` → `@foo/eslint-formatter-bar`
|
621
606
|
* - A file path ... Load the file.
|
622
|
-
* @returns {Promise<
|
607
|
+
* @returns {Promise<LoadedFormatter>} A promise resolving to the formatter object.
|
623
608
|
* This promise will be rejected if the given formatter was not found or not
|
624
609
|
* a function.
|
625
610
|
*/
|
@@ -639,7 +624,7 @@ class ESLint {
|
|
639
624
|
|
640
625
|
/**
|
641
626
|
* The main formatter method.
|
642
|
-
* @param {
|
627
|
+
* @param {LintResult[]} results The lint results to format.
|
643
628
|
* @returns {string | Promise<string>} The formatted lint results.
|
644
629
|
*/
|
645
630
|
format(results) {
|
@@ -66,7 +66,7 @@ function createIndividualDirectivesRemoval(directives, commentToken) {
|
|
66
66
|
const listText = commentToken.value
|
67
67
|
.slice(listStartOffset) // remove directive name and all whitespace before the list
|
68
68
|
.split(/\s-{2,}\s/u)[0] // remove `-- comment`, if it exists
|
69
|
-
.
|
69
|
+
.trimEnd(); // remove all whitespace after the list
|
70
70
|
|
71
71
|
/*
|
72
72
|
* We can assume that `listText` contains multiple elements.
|
package/lib/rules/index.js
CHANGED
@@ -103,6 +103,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
|
|
103
103
|
"no-confusing-arrow": () => require("./no-confusing-arrow"),
|
104
104
|
"no-console": () => require("./no-console"),
|
105
105
|
"no-const-assign": () => require("./no-const-assign"),
|
106
|
+
"no-constant-binary-expression": () => require("./no-constant-binary-expression"),
|
106
107
|
"no-constant-condition": () => require("./no-constant-condition"),
|
107
108
|
"no-constructor-return": () => require("./no-constructor-return"),
|
108
109
|
"no-continue": () => require("./no-continue"),
|