eslint 7.22.0 → 7.23.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 +15 -0
- package/README.md +1 -1
- package/lib/cli.js +10 -3
- package/lib/options.js +47 -0
- package/lib/rules/no-mixed-operators.js +6 -23
- package/lib/rules/no-sequences.js +27 -8
- package/lib/rules/object-curly-newline.js +1 -1
- package/lib/shared/runtime-info.js +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
v7.23.0 - March 26, 2021
|
2
|
+
|
3
|
+
* [`687ccae`](https://github.com/eslint/eslint/commit/687ccae517b8b815cf21e948f80d22e2bf118a99) Update: add option "allowInParentheses" to no-sequences (fixes #14197) (#14199) (Daniel Rentz)
|
4
|
+
* [`dbf2529`](https://github.com/eslint/eslint/commit/dbf252964d9a2b8957cfe0aed5c87a6d4a5cce24) Sponsors: Sync README with website (ESLint Jenkins)
|
5
|
+
* [`4bdf2c1`](https://github.com/eslint/eslint/commit/4bdf2c1dade27625b601080687ce95b8c229e491) Sponsors: Sync README with website (ESLint Jenkins)
|
6
|
+
* [`49d1697`](https://github.com/eslint/eslint/commit/49d16977d969070e5240074e76036f56631a90d3) Chore: Upgrade eslint-plugin-jsdoc to v25 and remove --legacy-peer-deps (#14244) (Brandon Mills)
|
7
|
+
* [`43f1685`](https://github.com/eslint/eslint/commit/43f1685356b9840e09631843ad9ccf0440a498b0) Update: `--quiet` should not supress `--max-warnings` (fixes #14202) (#14242) (Milos Djermanovic)
|
8
|
+
* [`909c727`](https://github.com/eslint/eslint/commit/909c7271b8d294bd884827ad5df02615b6ec5e82) Docs: Add valid example that shows vars in a block scope (#14230) (Ed S)
|
9
|
+
* [`28583eb`](https://github.com/eslint/eslint/commit/28583eb8ada20f32579841bec3fbd60a018d5931) Fix: no-mixed-operators false positives with `? :` (fixes #14223) (#14226) (Milos Djermanovic)
|
10
|
+
* [`a99eb2d`](https://github.com/eslint/eslint/commit/a99eb2dc2a297d16e40a9feef3956668716c4eb5) Fix: Clarify line breaks in object-curly-newline (fixes #14024) (#14063) (armin yahya)
|
11
|
+
* [`8984c91`](https://github.com/eslint/eslint/commit/8984c91372e64d1e8dd2ce21b87b80977d57bff9) Update: eslint --env-info output os info (#14059) (薛定谔的猫)
|
12
|
+
* [`2a79306`](https://github.com/eslint/eslint/commit/2a79306f71c4c80f1e3e73be2a140d07cf55c63d) Sponsors: Sync README with website (ESLint Jenkins)
|
13
|
+
* [`ebd7026`](https://github.com/eslint/eslint/commit/ebd70263f6e6fe597613d90f4b8de84710c2f3d6) Docs: Fix typo (#14225) (Greg Finley)
|
14
|
+
* [`a2013fc`](https://github.com/eslint/eslint/commit/a2013fcf996c8651bc760df21d900442828a6884) Sponsors: Sync README with website (ESLint Jenkins)
|
15
|
+
|
1
16
|
v7.22.0 - March 12, 2021
|
2
17
|
|
3
18
|
* [`3a432d8`](https://github.com/eslint/eslint/commit/3a432d82b3a5710aff7da20302fe0b94fedc46c2) Docs: Improve documentation for indent rule (#14168) (Serkan Özel)
|
package/README.md
CHANGED
@@ -281,7 +281,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
281
281
|
<!--sponsorsstart-->
|
282
282
|
<h3>Platinum Sponsors</h3>
|
283
283
|
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/photomatt/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
|
284
|
-
<p><a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" 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://
|
284
|
+
<p><a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" 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://opensource.microsoft.com"><img src="https://avatars.githubusercontent.com/u/6154722?v=4" alt="Microsoft" 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>
|
285
285
|
<p><a href="https://retool.com/"><img src="https://images.opencollective.com/retool/98ea68e/logo.png" alt="Retool" height="64"></a> <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>
|
286
286
|
<p><a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/b282e39/logo.png" alt="Buy.Fineproxy.Org" 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="null"><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" 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://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/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.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
|
287
287
|
<!--sponsorsend-->
|
package/lib/cli.js
CHANGED
@@ -32,6 +32,7 @@ const debug = require("debug")("eslint:cli");
|
|
32
32
|
/** @typedef {import("./eslint/eslint").ESLintOptions} ESLintOptions */
|
33
33
|
/** @typedef {import("./eslint/eslint").LintMessage} LintMessage */
|
34
34
|
/** @typedef {import("./eslint/eslint").LintResult} LintResult */
|
35
|
+
/** @typedef {import("./options").ParsedCLIOptions} ParsedCLIOptions */
|
35
36
|
|
36
37
|
//------------------------------------------------------------------------------
|
37
38
|
// Helpers
|
@@ -54,7 +55,7 @@ function quietFixPredicate(message) {
|
|
54
55
|
|
55
56
|
/**
|
56
57
|
* Translates the CLI options into the options expected by the CLIEngine.
|
57
|
-
* @param {
|
58
|
+
* @param {ParsedCLIOptions} cliOptions The CLI options to translate.
|
58
59
|
* @returns {ESLintOptions} The options object for the CLIEngine.
|
59
60
|
* @private
|
60
61
|
*/
|
@@ -221,6 +222,8 @@ const cli = {
|
|
221
222
|
if (Array.isArray(args)) {
|
222
223
|
debug("CLI args: %o", args.slice(2));
|
223
224
|
}
|
225
|
+
|
226
|
+
/** @type {ParsedCLIOptions} */
|
224
227
|
let options;
|
225
228
|
|
226
229
|
try {
|
@@ -301,12 +304,16 @@ const cli = {
|
|
301
304
|
await ESLint.outputFixes(results);
|
302
305
|
}
|
303
306
|
|
307
|
+
let resultsToPrint = results;
|
308
|
+
|
304
309
|
if (options.quiet) {
|
305
310
|
debug("Quiet mode enabled - filtering out warnings");
|
306
|
-
|
311
|
+
resultsToPrint = ESLint.getErrorResults(resultsToPrint);
|
307
312
|
}
|
308
313
|
|
309
|
-
if (await printResults(engine,
|
314
|
+
if (await printResults(engine, resultsToPrint, options.format, options.outputFile)) {
|
315
|
+
|
316
|
+
// Errors and warnings from the original unfiltered results should determine the exit code
|
310
317
|
const { errorCount, warningCount } = countErrors(results);
|
311
318
|
const tooManyWarnings =
|
312
319
|
options.maxWarnings >= 0 && warningCount > options.maxWarnings;
|
package/lib/options.js
CHANGED
@@ -11,6 +11,53 @@
|
|
11
11
|
|
12
12
|
const optionator = require("optionator");
|
13
13
|
|
14
|
+
//------------------------------------------------------------------------------
|
15
|
+
// Typedefs
|
16
|
+
//------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
/**
|
19
|
+
* The options object parsed by Optionator.
|
20
|
+
* @typedef {Object} ParsedCLIOptions
|
21
|
+
* @property {boolean} cache Only check changed files
|
22
|
+
* @property {string} cacheFile Path to the cache file. Deprecated: use --cache-location
|
23
|
+
* @property {string} [cacheLocation] Path to the cache file or directory
|
24
|
+
* @property {"metadata" | "content"} cacheStrategy Strategy to use for detecting changed files in the cache
|
25
|
+
* @property {boolean} [color] Force enabling/disabling of color
|
26
|
+
* @property {string} [config] Use this configuration, overriding .eslintrc.* config options if present
|
27
|
+
* @property {boolean} debug Output debugging information
|
28
|
+
* @property {string[]} [env] Specify environments
|
29
|
+
* @property {boolean} envInfo Output execution environment information
|
30
|
+
* @property {boolean} errorOnUnmatchedPattern Prevent errors when pattern is unmatched
|
31
|
+
* @property {boolean} eslintrc Disable use of configuration from .eslintrc.*
|
32
|
+
* @property {string[]} [ext] Specify JavaScript file extensions
|
33
|
+
* @property {boolean} fix Automatically fix problems
|
34
|
+
* @property {boolean} fixDryRun Automatically fix problems without saving the changes to the file system
|
35
|
+
* @property {("problem" | "suggestion" | "layout")[]} [fixType] Specify the types of fixes to apply (problem, suggestion, layout)
|
36
|
+
* @property {string} format Use a specific output format
|
37
|
+
* @property {string[]} [global] Define global variables
|
38
|
+
* @property {boolean} [help] Show help
|
39
|
+
* @property {boolean} ignore Disable use of ignore files and patterns
|
40
|
+
* @property {string} [ignorePath] Specify path of ignore file
|
41
|
+
* @property {string[]} [ignorePattern] Pattern of files to ignore (in addition to those in .eslintignore)
|
42
|
+
* @property {boolean} init Run config initialization wizard
|
43
|
+
* @property {boolean} inlineConfig Prevent comments from changing config or rules
|
44
|
+
* @property {number} maxWarnings Number of warnings to trigger nonzero exit code
|
45
|
+
* @property {string} [outputFile] Specify file to write report to
|
46
|
+
* @property {string} [parser] Specify the parser to be used
|
47
|
+
* @property {Object} [parserOptions] Specify parser options
|
48
|
+
* @property {string[]} [plugin] Specify plugins
|
49
|
+
* @property {string} [printConfig] Print the configuration for the given file
|
50
|
+
* @property {boolean | undefined} reportUnusedDisableDirectives Adds reported errors for unused eslint-disable directives
|
51
|
+
* @property {string} [resolvePluginsRelativeTo] A folder where plugins should be resolved from, CWD by default
|
52
|
+
* @property {Object} [rule] Specify rules
|
53
|
+
* @property {string[]} [rulesdir] Use additional rules from this directory
|
54
|
+
* @property {boolean} stdin Lint code provided on <STDIN>
|
55
|
+
* @property {string} [stdinFilename] Specify filename to process STDIN as
|
56
|
+
* @property {boolean} quiet Report errors only
|
57
|
+
* @property {boolean} [version] Output the version number
|
58
|
+
* @property {string[]} _ Positional filenames or patterns
|
59
|
+
*/
|
60
|
+
|
14
61
|
//------------------------------------------------------------------------------
|
15
62
|
// Initialization and Public Interface
|
16
63
|
//------------------------------------------------------------------------------
|
@@ -161,17 +161,6 @@ module.exports = {
|
|
161
161
|
);
|
162
162
|
}
|
163
163
|
|
164
|
-
/**
|
165
|
-
* Checks whether the operator of a given node is mixed with a
|
166
|
-
* conditional expression.
|
167
|
-
* @param {ASTNode} node A node to check. This is a conditional
|
168
|
-
* expression node
|
169
|
-
* @returns {boolean} `true` if the node was mixed.
|
170
|
-
*/
|
171
|
-
function isMixedWithConditionalParent(node) {
|
172
|
-
return !astUtils.isParenthesised(sourceCode, node) && !astUtils.isParenthesised(sourceCode, node.test);
|
173
|
-
}
|
174
|
-
|
175
164
|
/**
|
176
165
|
* Gets the operator token of a given node.
|
177
166
|
* @param {ASTNode} node A node to check. This is a BinaryExpression
|
@@ -220,19 +209,13 @@ module.exports = {
|
|
220
209
|
* @returns {void}
|
221
210
|
*/
|
222
211
|
function check(node) {
|
223
|
-
if (
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
!shouldIgnore(node)
|
230
|
-
) {
|
231
|
-
reportBothOperators(node);
|
232
|
-
}
|
233
|
-
}
|
212
|
+
if (
|
213
|
+
TARGET_NODE_TYPE.test(node.parent.type) &&
|
214
|
+
isMixedWithParent(node) &&
|
215
|
+
!shouldIgnore(node)
|
216
|
+
) {
|
217
|
+
reportBothOperators(node);
|
234
218
|
}
|
235
|
-
|
236
219
|
}
|
237
220
|
|
238
221
|
return {
|
@@ -11,6 +11,14 @@
|
|
11
11
|
|
12
12
|
const astUtils = require("./utils/ast-utils");
|
13
13
|
|
14
|
+
//------------------------------------------------------------------------------
|
15
|
+
// Helpers
|
16
|
+
//------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
const DEFAULT_OPTIONS = {
|
19
|
+
allowInParentheses: true
|
20
|
+
};
|
21
|
+
|
14
22
|
//------------------------------------------------------------------------------
|
15
23
|
// Rule Definition
|
16
24
|
//------------------------------------------------------------------------------
|
@@ -26,7 +34,15 @@ module.exports = {
|
|
26
34
|
url: "https://eslint.org/docs/rules/no-sequences"
|
27
35
|
},
|
28
36
|
|
29
|
-
schema: [
|
37
|
+
schema: [{
|
38
|
+
properties: {
|
39
|
+
allowInParentheses: {
|
40
|
+
type: "boolean",
|
41
|
+
default: true
|
42
|
+
}
|
43
|
+
},
|
44
|
+
additionalProperties: false
|
45
|
+
}],
|
30
46
|
|
31
47
|
messages: {
|
32
48
|
unexpectedCommaExpression: "Unexpected use of comma operator."
|
@@ -34,6 +50,7 @@ module.exports = {
|
|
34
50
|
},
|
35
51
|
|
36
52
|
create(context) {
|
53
|
+
const options = Object.assign({}, DEFAULT_OPTIONS, context.options[0]);
|
37
54
|
const sourceCode = context.getSourceCode();
|
38
55
|
|
39
56
|
/**
|
@@ -99,13 +116,15 @@ module.exports = {
|
|
99
116
|
}
|
100
117
|
|
101
118
|
// Wrapping a sequence in extra parens indicates intent
|
102
|
-
if (
|
103
|
-
if (
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
119
|
+
if (options.allowInParentheses) {
|
120
|
+
if (requiresExtraParens(node)) {
|
121
|
+
if (isParenthesisedTwice(node)) {
|
122
|
+
return;
|
123
|
+
}
|
124
|
+
} else {
|
125
|
+
if (isParenthesised(node)) {
|
126
|
+
return;
|
127
|
+
}
|
109
128
|
}
|
110
129
|
}
|
111
130
|
|
@@ -134,7 +134,7 @@ module.exports = {
|
|
134
134
|
type: "layout",
|
135
135
|
|
136
136
|
docs: {
|
137
|
-
description: "enforce consistent line breaks
|
137
|
+
description: "enforce consistent line breaks after opening and before closing braces",
|
138
138
|
category: "Stylistic Issues",
|
139
139
|
recommended: false,
|
140
140
|
url: "https://eslint.org/docs/rules/object-curly-newline"
|
@@ -11,6 +11,7 @@
|
|
11
11
|
|
12
12
|
const path = require("path");
|
13
13
|
const spawn = require("cross-spawn");
|
14
|
+
const os = require("os");
|
14
15
|
const log = require("../shared/logging");
|
15
16
|
const packageJson = require("../../package.json");
|
16
17
|
|
@@ -140,7 +141,8 @@ function environment() {
|
|
140
141
|
`Node version: ${getBinVersion("node")}`,
|
141
142
|
`npm version: ${getBinVersion("npm")}`,
|
142
143
|
`Local ESLint version: ${getNpmPackageVersion("eslint", { global: false })}`,
|
143
|
-
`Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}
|
144
|
+
`Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}`,
|
145
|
+
`Operating System: ${os.platform()} ${os.release()}`
|
144
146
|
].join("\n");
|
145
147
|
}
|
146
148
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.23.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -100,7 +100,7 @@
|
|
100
100
|
"eslint-config-eslint": "file:packages/eslint-config-eslint",
|
101
101
|
"eslint-plugin-eslint-plugin": "^2.2.1",
|
102
102
|
"eslint-plugin-internal-rules": "file:tools/internal-rules",
|
103
|
-
"eslint-plugin-jsdoc": "^
|
103
|
+
"eslint-plugin-jsdoc": "^25.4.3",
|
104
104
|
"eslint-plugin-node": "^11.1.0",
|
105
105
|
"eslint-release": "^2.0.0",
|
106
106
|
"eslump": "^2.0.0",
|