eslint 8.30.0 → 8.32.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 +50 -44
- package/conf/rule-type-list.json +2 -2
- package/lib/cli-engine/formatters/formatters-meta.json +2 -2
- package/lib/eslint/flat-eslint.js +37 -1
- package/lib/linter/linter.js +4 -1
- package/lib/rule-tester/flat-rule-tester.js +1 -1
- package/lib/rule-tester/rule-tester.js +3 -3
- package/lib/rules/key-spacing.js +35 -23
- package/lib/rules/no-fallthrough.js +18 -2
- package/lib/rules/no-underscore-dangle.js +36 -11
- package/lib/rules/prefer-arrow-callback.js +2 -1
- package/lib/rules/prefer-regex-literals.js +144 -29
- package/lib/shared/directives.js +15 -0
- package/messages/print-config-with-directory-path.js +1 -1
- package/package.json +9 -8
package/README.md
CHANGED
@@ -10,10 +10,10 @@
|
|
10
10
|
# ESLint
|
11
11
|
|
12
12
|
[Website](https://eslint.org) |
|
13
|
-
[Configuring](https://eslint.org/docs/
|
13
|
+
[Configuring](https://eslint.org/docs/latest/use/configure) |
|
14
14
|
[Rules](https://eslint.org/docs/rules/) |
|
15
|
-
[Contributing](https://eslint.org/docs/
|
16
|
-
[Reporting Bugs](https://eslint.org/docs/
|
15
|
+
[Contributing](https://eslint.org/docs/latest/contribute) |
|
16
|
+
[Reporting Bugs](https://eslint.org/docs/latest/contribute/report-bugs) |
|
17
17
|
[Code of Conduct](https://eslint.org/conduct) |
|
18
18
|
[Twitter](https://twitter.com/geteslint) |
|
19
19
|
[Mailing List](https://groups.google.com/group/eslint) |
|
@@ -31,7 +31,7 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J
|
|
31
31
|
2. [Configuration](#configuration)
|
32
32
|
3. [Code of Conduct](#code-of-conduct)
|
33
33
|
4. [Filing Issues](#filing-issues)
|
34
|
-
5. [Frequently Asked Questions](#
|
34
|
+
5. [Frequently Asked Questions](#frequently-asked-questions)
|
35
35
|
6. [Releases](#releases)
|
36
36
|
7. [Security Policy](#security-policy)
|
37
37
|
8. [Semantic Versioning Policy](#semantic-versioning-policy)
|
@@ -41,7 +41,7 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J
|
|
41
41
|
12. [Sponsors](#sponsors)
|
42
42
|
13. [Technology Sponsors](#technology-sponsors)
|
43
43
|
|
44
|
-
##
|
44
|
+
## Installation and Usage
|
45
45
|
|
46
46
|
Prerequisites: [Node.js](https://nodejs.org/) (`^12.22.0`, `^14.17.0`, or `>=16.0.0`) built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.)
|
47
47
|
|
@@ -57,7 +57,7 @@ After that, you can run ESLint on any file or directory like this:
|
|
57
57
|
./node_modules/.bin/eslint yourfile.js
|
58
58
|
```
|
59
59
|
|
60
|
-
##
|
60
|
+
## Configuration
|
61
61
|
|
62
62
|
After running `npm init @eslint/config`, you'll have a `.eslintrc` file in your directory. In it, you'll see some rules configured like this:
|
63
63
|
|
@@ -76,28 +76,28 @@ The names `"semi"` and `"quotes"` are the names of [rules](https://eslint.org/do
|
|
76
76
|
* `"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code)
|
77
77
|
* `"error"` or `2` - turn the rule on as an error (exit code will be 1)
|
78
78
|
|
79
|
-
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](https://eslint.org/docs/
|
79
|
+
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](https://eslint.org/docs/latest/use/configure)).
|
80
80
|
|
81
|
-
##
|
81
|
+
## Code of Conduct
|
82
82
|
|
83
83
|
ESLint adheres to the [JS Foundation Code of Conduct](https://eslint.org/conduct).
|
84
84
|
|
85
|
-
##
|
85
|
+
## Filing Issues
|
86
86
|
|
87
87
|
Before filing an issue, please be sure to read the guidelines for what you're reporting:
|
88
88
|
|
89
|
-
* [Bug Report](https://eslint.org/docs/
|
90
|
-
* [Propose a New Rule](https://eslint.org/docs/
|
91
|
-
* [Proposing a Rule Change](https://eslint.org/docs/
|
92
|
-
* [Request a Change](https://eslint.org/docs/
|
89
|
+
* [Bug Report](https://eslint.org/docs/latest/contribute/report-bugs)
|
90
|
+
* [Propose a New Rule](https://eslint.org/docs/latest/contribute/propose-new-rule)
|
91
|
+
* [Proposing a Rule Change](https://eslint.org/docs/latest/contribute/propose-rule-change)
|
92
|
+
* [Request a Change](https://eslint.org/docs/latest/contribute/request-change)
|
93
93
|
|
94
|
-
##
|
94
|
+
## Frequently Asked Questions
|
95
95
|
|
96
96
|
### I'm using JSCS, should I migrate to ESLint?
|
97
97
|
|
98
98
|
Yes. [JSCS has reached end of life](https://eslint.org/blog/2016/07/jscs-end-of-life) and is no longer supported.
|
99
99
|
|
100
|
-
We have prepared a [migration guide](https://eslint.org/docs/
|
100
|
+
We have prepared a [migration guide](https://eslint.org/docs/latest/use/migrating-from-jscs) to help you convert your JSCS settings to an ESLint configuration.
|
101
101
|
|
102
102
|
We are now at or near 100% compatibility with JSCS. If you try ESLint and believe we are not yet compatible with a JSCS rule/configuration, please create an issue (mentioning that it is a JSCS compatibility issue) and we will evaluate it as per our normal process.
|
103
103
|
|
@@ -113,11 +113,11 @@ No, ESLint does both traditional linting (looking for problematic patterns) and
|
|
113
113
|
|
114
114
|
### Does ESLint support JSX?
|
115
115
|
|
116
|
-
Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/
|
116
|
+
Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/latest/use/configure)). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.
|
117
117
|
|
118
118
|
### What ECMAScript versions does ESLint support?
|
119
119
|
|
120
|
-
ESLint has full support for ECMAScript 3, 5 (default), 2015, 2016, 2017, 2018, 2019, 2020, 2021 and 2022. You can set your desired ECMAScript syntax (and other settings, like global variables or your target environments) through [configuration](https://eslint.org/docs/
|
120
|
+
ESLint has full support for ECMAScript 3, 5 (default), 2015, 2016, 2017, 2018, 2019, 2020, 2021 and 2022. You can set your desired ECMAScript syntax (and other settings, like global variables or your target environments) through [configuration](https://eslint.org/docs/latest/use/configure).
|
121
121
|
|
122
122
|
### What about experimental features?
|
123
123
|
|
@@ -125,7 +125,7 @@ ESLint's parser only officially supports the latest final ECMAScript standard. W
|
|
125
125
|
|
126
126
|
In other cases (including if rules need to warn on more or fewer cases due to new syntax, rather than just not crashing), we recommend you use other parsers and/or rule plugins. If you are using Babel, you can use [@babel/eslint-parser](https://www.npmjs.com/package/@babel/eslint-parser) and [@babel/eslint-plugin](https://www.npmjs.com/package/@babel/eslint-plugin) to use any option available in Babel.
|
127
127
|
|
128
|
-
Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](https://eslint.org/docs/
|
128
|
+
Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](https://eslint.org/docs/latest/contribute). Until then, please use the appropriate parser and plugin(s) for your experimental feature.
|
129
129
|
|
130
130
|
### Where to ask for help?
|
131
131
|
|
@@ -141,15 +141,15 @@ We intentionally don't lock dependency versions so that we have the latest compa
|
|
141
141
|
|
142
142
|
The Twilio blog has a [deeper dive](https://www.twilio.com/blog/lockfiles-nodejs) to learn more.
|
143
143
|
|
144
|
-
##
|
144
|
+
## Releases
|
145
145
|
|
146
146
|
We have scheduled releases every two weeks on Friday or Saturday. You can follow a [release issue](https://github.com/eslint/eslint/issues?q=is%3Aopen+is%3Aissue+label%3Arelease) for updates about the scheduling of any particular release.
|
147
147
|
|
148
|
-
##
|
148
|
+
## Security Policy
|
149
149
|
|
150
150
|
ESLint takes security seriously. We work hard to ensure that ESLint is safe for everyone and that security issues are addressed quickly and responsibly. Read the full [security policy](https://github.com/eslint/.github/blob/master/SECURITY.md).
|
151
151
|
|
152
|
-
##
|
152
|
+
## Semantic Versioning Policy
|
153
153
|
|
154
154
|
ESLint follows [semantic versioning](https://semver.org). However, due to the nature of ESLint as a code quality tool, it's not always clear when a minor or major version bump occurs. To help clarify this for everyone, we've defined the following semantic versioning policy for ESLint:
|
155
155
|
|
@@ -182,7 +182,7 @@ ESLint follows [semantic versioning](https://semver.org). However, due to the na
|
|
182
182
|
|
183
183
|
According to our policy, any minor update may report more linting errors than the previous release (ex: from a bug fix). As such, we recommend using the tilde (`~`) in `package.json` e.g. `"eslint": "~3.1.0"` to guarantee the results of your builds.
|
184
184
|
|
185
|
-
##
|
185
|
+
## Stylistic Rule Updates
|
186
186
|
|
187
187
|
Stylistic rules are frozen according to [our policy](https://eslint.org/blog/2020/05/changes-to-rules-policies) on how we evaluate new rules and rule changes.
|
188
188
|
This means:
|
@@ -191,11 +191,11 @@ This means:
|
|
191
191
|
* **New ECMAScript features**: We will also make sure stylistic rules are compatible with new ECMAScript features.
|
192
192
|
* **New options**: We will **not** add any new options to stylistic rules unless an option is the only way to fix a bug or support a newly-added ECMAScript feature.
|
193
193
|
|
194
|
-
##
|
194
|
+
## License
|
195
195
|
|
196
196
|
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint?ref=badge_large)
|
197
197
|
|
198
|
-
##
|
198
|
+
## Team
|
199
199
|
|
200
200
|
These folks keep the project moving and are resources for help.
|
201
201
|
|
@@ -245,11 +245,6 @@ Nitin Kumar
|
|
245
245
|
The people who review and fix bugs and help triage issues.
|
246
246
|
|
247
247
|
<table><tbody><tr><td align="center" valign="top" width="11%">
|
248
|
-
<a href="https://github.com/brettz9">
|
249
|
-
<img src="https://github.com/brettz9.png?s=75" width="75" height="75"><br />
|
250
|
-
Brett Zamir
|
251
|
-
</a>
|
252
|
-
</td><td align="center" valign="top" width="11%">
|
253
248
|
<a href="https://github.com/bmish">
|
254
249
|
<img src="https://github.com/bmish.png?s=75" width="75" height="75"><br />
|
255
250
|
Bryan Mishkin
|
@@ -260,38 +255,49 @@ Bryan Mishkin
|
|
260
255
|
Sara Soueidan
|
261
256
|
</a>
|
262
257
|
</td><td align="center" valign="top" width="11%">
|
263
|
-
<a href="https://github.com/
|
264
|
-
<img src="https://github.com/
|
265
|
-
|
258
|
+
<a href="https://github.com/yeonjuan">
|
259
|
+
<img src="https://github.com/yeonjuan.png?s=75" width="75" height="75"><br />
|
260
|
+
YeonJuan
|
261
|
+
</a>
|
262
|
+
</td></tr></tbody></table>
|
263
|
+
|
264
|
+
### Website Team
|
265
|
+
|
266
|
+
Team members who focus specifically on eslint.org
|
267
|
+
|
268
|
+
<table><tbody><tr><td align="center" valign="top" width="11%">
|
269
|
+
<a href="https://github.com/amareshsm">
|
270
|
+
<img src="https://github.com/amareshsm.png?s=75" width="75" height="75"><br />
|
271
|
+
Amaresh S M
|
266
272
|
</a>
|
267
273
|
</td><td align="center" valign="top" width="11%">
|
268
|
-
<a href="https://github.com/
|
269
|
-
<img src="https://github.com/
|
270
|
-
|
274
|
+
<a href="https://github.com/harish-sethuraman">
|
275
|
+
<img src="https://github.com/harish-sethuraman.png?s=75" width="75" height="75"><br />
|
276
|
+
Strek
|
271
277
|
</a>
|
272
278
|
</td><td align="center" valign="top" width="11%">
|
273
|
-
<a href="https://github.com/
|
274
|
-
<img src="https://github.com/
|
275
|
-
|
279
|
+
<a href="https://github.com/kecrily">
|
280
|
+
<img src="https://github.com/kecrily.png?s=75" width="75" height="75"><br />
|
281
|
+
Percy Ma
|
276
282
|
</a>
|
277
283
|
</td></tr></tbody></table>
|
278
284
|
|
279
285
|
<!--teamend-->
|
280
286
|
|
281
|
-
##
|
287
|
+
## Sponsors
|
282
288
|
|
283
289
|
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://opencollective.com/eslint) to get your logo on our README and website.
|
284
290
|
|
285
291
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
286
292
|
<!--sponsorsstart-->
|
287
293
|
<h3>Platinum Sponsors</h3>
|
288
|
-
<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>
|
289
|
-
<p><a href="https://
|
290
|
-
<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>
|
291
|
-
<p><a href="https://
|
294
|
+
<p><a href="#"><img src="https://images.opencollective.com/2021-frameworks-fund/logo.png" alt="Chrome Frameworks Fund" height="undefined"></a> <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://ridicorp.com/career/"><img src="https://images.opencollective.com/ridi-corporation/175dcf3/logo.png" alt="RIDI" height="96"></a> <a href="https://engineering.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></p><h3>Silver Sponsors</h3>
|
296
|
+
<p><a href="https://sentry.io"><img src="https://avatars.githubusercontent.com/u/1396951?v=4" alt="Sentry" 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>
|
297
|
+
<p><a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" 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://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://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://quickbookstoolhub.com"><img src="https://avatars.githubusercontent.com/u/95090305?u=e5bc398ef775c9ed19f955c675cdc1fb6abf01df&v=4" alt="QuickBooks Tool hub" height="32"></a></p>
|
292
298
|
<!--sponsorsend-->
|
293
299
|
|
294
|
-
##
|
300
|
+
## Technology Sponsors
|
295
301
|
|
296
302
|
* Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com)
|
297
303
|
* Hosting for ([eslint.org](https://eslint.org)) is sponsored by [Netlify](https://www.netlify.com)
|
package/conf/rule-type-list.json
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
],
|
7
7
|
"deprecated": {
|
8
8
|
"name": "Deprecated",
|
9
|
-
"description": "These rules have been deprecated in accordance with the <a href=\"/docs/
|
9
|
+
"description": "These rules have been deprecated in accordance with the <a href=\"/docs/use/rule-deprecation\">deprecation policy</a>, and replaced by newer rules:",
|
10
10
|
"rules": []
|
11
11
|
},
|
12
12
|
"removed": {
|
13
13
|
"name": "Removed",
|
14
|
-
"description": "These rules from older versions of ESLint (before the <a href=\"/docs/
|
14
|
+
"description": "These rules from older versions of ESLint (before the <a href=\"/docs/use/rule-deprecation\">deprecation policy</a> existed) have been replaced by newer rules:",
|
15
15
|
"rules": [
|
16
16
|
{ "removed": "generator-star", "replacedBy": ["generator-star-spacing"] },
|
17
17
|
{ "removed": "global-strict", "replacedBy": ["strict"] },
|
@@ -17,11 +17,11 @@
|
|
17
17
|
},
|
18
18
|
{
|
19
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](../../
|
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](../../integrate/nodejs-api) to programmatically use ESLint."
|
21
21
|
},
|
22
22
|
{
|
23
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](../../
|
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](../../integrate/nodejs-api) to programmatically use ESLint."
|
25
25
|
},
|
26
26
|
{
|
27
27
|
"name": "junit",
|
@@ -93,6 +93,7 @@ const FLAT_CONFIG_FILENAME = "eslint.config.js";
|
|
93
93
|
const debug = require("debug")("eslint:flat-eslint");
|
94
94
|
const removedFormatters = new Set(["table", "codeframe"]);
|
95
95
|
const privateMembers = new WeakMap();
|
96
|
+
const importedConfigFileModificationTime = new Map();
|
96
97
|
|
97
98
|
/**
|
98
99
|
* It will calculate the error and warning count for collection of messages per file
|
@@ -281,7 +282,42 @@ async function loadFlatConfigFile(filePath) {
|
|
281
282
|
|
282
283
|
debug(`Config file URL is ${fileURL}`);
|
283
284
|
|
284
|
-
|
285
|
+
const mtime = (await fs.stat(filePath)).mtime.getTime();
|
286
|
+
|
287
|
+
/*
|
288
|
+
* Append a query with the config file's modification time (`mtime`) in order
|
289
|
+
* to import the current version of the config file. Without the query, `import()` would
|
290
|
+
* cache the config file module by the pathname only, and then always return
|
291
|
+
* the same version (the one that was actual when the module was imported for the first time).
|
292
|
+
*
|
293
|
+
* This ensures that the config file module is loaded and executed again
|
294
|
+
* if it has been changed since the last time it was imported.
|
295
|
+
* If it hasn't been changed, `import()` will just return the cached version.
|
296
|
+
*
|
297
|
+
* Note that we should not overuse queries (e.g., by appending the current time
|
298
|
+
* to always reload the config file module) as that could cause memory leaks
|
299
|
+
* because entries are never removed from the import cache.
|
300
|
+
*/
|
301
|
+
fileURL.searchParams.append("mtime", mtime);
|
302
|
+
|
303
|
+
/*
|
304
|
+
* With queries, we can bypass the import cache. However, when import-ing a CJS module,
|
305
|
+
* Node.js uses the require infrastructure under the hood. That includes the require cache,
|
306
|
+
* which caches the config file module by its file path (queries have no effect).
|
307
|
+
* Therefore, we also need to clear the require cache before importing the config file module.
|
308
|
+
* In order to get the same behavior with ESM and CJS config files, in particular - to reload
|
309
|
+
* the config file only if it has been changed, we track file modification times and clear
|
310
|
+
* the require cache only if the file has been changed.
|
311
|
+
*/
|
312
|
+
if (importedConfigFileModificationTime.get(filePath) !== mtime) {
|
313
|
+
delete require.cache[filePath];
|
314
|
+
}
|
315
|
+
|
316
|
+
const config = (await import(fileURL)).default;
|
317
|
+
|
318
|
+
importedConfigFileModificationTime.set(filePath, mtime);
|
319
|
+
|
320
|
+
return config;
|
285
321
|
}
|
286
322
|
|
287
323
|
/**
|
package/lib/linter/linter.js
CHANGED
@@ -18,6 +18,9 @@ const
|
|
18
18
|
merge = require("lodash.merge"),
|
19
19
|
pkg = require("../../package.json"),
|
20
20
|
astUtils = require("../shared/ast-utils"),
|
21
|
+
{
|
22
|
+
directivesPattern
|
23
|
+
} = require("../shared/directives"),
|
21
24
|
{
|
22
25
|
Legacy: {
|
23
26
|
ConfigOps,
|
@@ -377,7 +380,7 @@ function getDirectiveComments(ast, ruleMapper, warnInlineConfig) {
|
|
377
380
|
ast.comments.filter(token => token.type !== "Shebang").forEach(comment => {
|
378
381
|
const { directivePart, justificationPart } = extractDirectiveComment(comment.value);
|
379
382
|
|
380
|
-
const match =
|
383
|
+
const match = directivesPattern.exec(directivePart);
|
381
384
|
|
382
385
|
if (!match) {
|
383
386
|
return;
|
@@ -430,7 +430,7 @@ class FlatRuleTester {
|
|
430
430
|
if (typeof this[DESCRIBE] === "function" || typeof this[IT] === "function") {
|
431
431
|
throw new Error(
|
432
432
|
"Set `RuleTester.itOnly` to use `only` with a custom test framework.\n" +
|
433
|
-
"See https://eslint.org/docs/
|
433
|
+
"See https://eslint.org/docs/latest/integrate/nodejs-api#customizing-ruletester for more."
|
434
434
|
);
|
435
435
|
}
|
436
436
|
if (typeof it === "function") {
|
@@ -314,7 +314,7 @@ function emitLegacyRuleAPIWarning(ruleName) {
|
|
314
314
|
if (!emitLegacyRuleAPIWarning[`warned-${ruleName}`]) {
|
315
315
|
emitLegacyRuleAPIWarning[`warned-${ruleName}`] = true;
|
316
316
|
process.emitWarning(
|
317
|
-
`"${ruleName}" rule is using the deprecated function-style format and will stop working in ESLint v9. Please use object-style format: https://eslint.org/docs/
|
317
|
+
`"${ruleName}" rule is using the deprecated function-style format and will stop working in ESLint v9. Please use object-style format: https://eslint.org/docs/latest/extend/custom-rules`,
|
318
318
|
"DeprecationWarning"
|
319
319
|
);
|
320
320
|
}
|
@@ -329,7 +329,7 @@ function emitMissingSchemaWarning(ruleName) {
|
|
329
329
|
if (!emitMissingSchemaWarning[`warned-${ruleName}`]) {
|
330
330
|
emitMissingSchemaWarning[`warned-${ruleName}`] = true;
|
331
331
|
process.emitWarning(
|
332
|
-
`"${ruleName}" rule has options but is missing the "meta.schema" property and will stop working in ESLint v9. Please add a schema: https://eslint.org/docs/
|
332
|
+
`"${ruleName}" rule has options but is missing the "meta.schema" property and will stop working in ESLint v9. Please add a schema: https://eslint.org/docs/latest/extend/custom-rules#options-schemas`,
|
333
333
|
"DeprecationWarning"
|
334
334
|
);
|
335
335
|
}
|
@@ -493,7 +493,7 @@ class RuleTester {
|
|
493
493
|
if (typeof this[DESCRIBE] === "function" || typeof this[IT] === "function") {
|
494
494
|
throw new Error(
|
495
495
|
"Set `RuleTester.itOnly` to use `only` with a custom test framework.\n" +
|
496
|
-
"See https://eslint.org/docs/
|
496
|
+
"See https://eslint.org/docs/latest/integrate/nodejs-api#customizing-ruletester for more."
|
497
497
|
);
|
498
498
|
}
|
499
499
|
if (typeof it === "function") {
|
package/lib/rules/key-spacing.js
CHANGED
@@ -347,6 +347,40 @@ module.exports = {
|
|
347
347
|
);
|
348
348
|
}
|
349
349
|
|
350
|
+
/**
|
351
|
+
* Starting from the given node (a property.key node here) looks forward
|
352
|
+
* until it finds the colon punctuator and returns it.
|
353
|
+
* @param {ASTNode} node The node to start looking from.
|
354
|
+
* @returns {ASTNode} The colon punctuator.
|
355
|
+
*/
|
356
|
+
function getNextColon(node) {
|
357
|
+
return sourceCode.getTokenAfter(node, astUtils.isColonToken);
|
358
|
+
}
|
359
|
+
|
360
|
+
/**
|
361
|
+
* Starting from the given node (a property.key node here) looks forward
|
362
|
+
* until it finds the last token before a colon punctuator and returns it.
|
363
|
+
* @param {ASTNode} node The node to start looking from.
|
364
|
+
* @returns {ASTNode} The last token before a colon punctuator.
|
365
|
+
*/
|
366
|
+
function getLastTokenBeforeColon(node) {
|
367
|
+
const colonToken = getNextColon(node);
|
368
|
+
|
369
|
+
return sourceCode.getTokenBefore(colonToken);
|
370
|
+
}
|
371
|
+
|
372
|
+
/**
|
373
|
+
* Starting from the given node (a property.key node here) looks forward
|
374
|
+
* until it finds the first token after a colon punctuator and returns it.
|
375
|
+
* @param {ASTNode} node The node to start looking from.
|
376
|
+
* @returns {ASTNode} The first token after a colon punctuator.
|
377
|
+
*/
|
378
|
+
function getFirstTokenAfterColon(node) {
|
379
|
+
const colonToken = getNextColon(node);
|
380
|
+
|
381
|
+
return sourceCode.getTokenAfter(colonToken);
|
382
|
+
}
|
383
|
+
|
350
384
|
/**
|
351
385
|
* Checks whether a property is a member of the property group it follows.
|
352
386
|
* @param {ASTNode} lastMember The last Property known to be in the group.
|
@@ -355,7 +389,7 @@ module.exports = {
|
|
355
389
|
*/
|
356
390
|
function continuesPropertyGroup(lastMember, candidate) {
|
357
391
|
const groupEndLine = lastMember.loc.start.line,
|
358
|
-
candidateValueStartLine = (isKeyValueProperty(candidate) ? candidate.
|
392
|
+
candidateValueStartLine = (isKeyValueProperty(candidate) ? getFirstTokenAfterColon(candidate.key) : candidate).loc.start.line;
|
359
393
|
|
360
394
|
if (candidateValueStartLine - groupEndLine <= 1) {
|
361
395
|
return true;
|
@@ -384,28 +418,6 @@ module.exports = {
|
|
384
418
|
return false;
|
385
419
|
}
|
386
420
|
|
387
|
-
/**
|
388
|
-
* Starting from the given a node (a property.key node here) looks forward
|
389
|
-
* until it finds the last token before a colon punctuator and returns it.
|
390
|
-
* @param {ASTNode} node The node to start looking from.
|
391
|
-
* @returns {ASTNode} The last token before a colon punctuator.
|
392
|
-
*/
|
393
|
-
function getLastTokenBeforeColon(node) {
|
394
|
-
const colonToken = sourceCode.getTokenAfter(node, astUtils.isColonToken);
|
395
|
-
|
396
|
-
return sourceCode.getTokenBefore(colonToken);
|
397
|
-
}
|
398
|
-
|
399
|
-
/**
|
400
|
-
* Starting from the given a node (a property.key node here) looks forward
|
401
|
-
* until it finds the colon punctuator and returns it.
|
402
|
-
* @param {ASTNode} node The node to start looking from.
|
403
|
-
* @returns {ASTNode} The colon punctuator.
|
404
|
-
*/
|
405
|
-
function getNextColon(node) {
|
406
|
-
return sourceCode.getTokenAfter(node, astUtils.isColonToken);
|
407
|
-
}
|
408
|
-
|
409
421
|
/**
|
410
422
|
* Gets an object literal property's key as the identifier name or string value.
|
411
423
|
* @param {ASTNode} property Property node whose key to retrieve.
|
@@ -4,12 +4,28 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
//------------------------------------------------------------------------------
|
8
|
+
// Requirements
|
9
|
+
//------------------------------------------------------------------------------
|
10
|
+
|
11
|
+
const { directivesPattern } = require("../shared/directives");
|
12
|
+
|
7
13
|
//------------------------------------------------------------------------------
|
8
14
|
// Helpers
|
9
15
|
//------------------------------------------------------------------------------
|
10
16
|
|
11
17
|
const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu;
|
12
18
|
|
19
|
+
/**
|
20
|
+
* Checks whether or not a given comment string is really a fallthrough comment and not an ESLint directive.
|
21
|
+
* @param {string} comment The comment string to check.
|
22
|
+
* @param {RegExp} fallthroughCommentPattern The regular expression used for checking for fallthrough comments.
|
23
|
+
* @returns {boolean} `true` if the comment string is truly a fallthrough comment.
|
24
|
+
*/
|
25
|
+
function isFallThroughComment(comment, fallthroughCommentPattern) {
|
26
|
+
return fallthroughCommentPattern.test(comment) && !directivesPattern.test(comment.trim());
|
27
|
+
}
|
28
|
+
|
13
29
|
/**
|
14
30
|
* Checks whether or not a given case has a fallthrough comment.
|
15
31
|
* @param {ASTNode} caseWhichFallsThrough SwitchCase node which falls through.
|
@@ -25,14 +41,14 @@ function hasFallthroughComment(caseWhichFallsThrough, subsequentCase, context, f
|
|
25
41
|
const trailingCloseBrace = sourceCode.getLastToken(caseWhichFallsThrough.consequent[0]);
|
26
42
|
const commentInBlock = sourceCode.getCommentsBefore(trailingCloseBrace).pop();
|
27
43
|
|
28
|
-
if (commentInBlock &&
|
44
|
+
if (commentInBlock && isFallThroughComment(commentInBlock.value, fallthroughCommentPattern)) {
|
29
45
|
return true;
|
30
46
|
}
|
31
47
|
}
|
32
48
|
|
33
49
|
const comment = sourceCode.getCommentsBefore(subsequentCase).pop();
|
34
50
|
|
35
|
-
return Boolean(comment &&
|
51
|
+
return Boolean(comment && isFallThroughComment(comment.value, fallthroughCommentPattern));
|
36
52
|
}
|
37
53
|
|
38
54
|
/**
|
@@ -53,6 +53,14 @@ module.exports = {
|
|
53
53
|
enforceInClassFields: {
|
54
54
|
type: "boolean",
|
55
55
|
default: false
|
56
|
+
},
|
57
|
+
allowInArrayDestructuring: {
|
58
|
+
type: "boolean",
|
59
|
+
default: true
|
60
|
+
},
|
61
|
+
allowInObjectDestructuring: {
|
62
|
+
type: "boolean",
|
63
|
+
default: true
|
56
64
|
}
|
57
65
|
},
|
58
66
|
additionalProperties: false
|
@@ -74,6 +82,8 @@ module.exports = {
|
|
74
82
|
const enforceInMethodNames = typeof options.enforceInMethodNames !== "undefined" ? options.enforceInMethodNames : false;
|
75
83
|
const enforceInClassFields = typeof options.enforceInClassFields !== "undefined" ? options.enforceInClassFields : false;
|
76
84
|
const allowFunctionParams = typeof options.allowFunctionParams !== "undefined" ? options.allowFunctionParams : true;
|
85
|
+
const allowInArrayDestructuring = typeof options.allowInArrayDestructuring !== "undefined" ? options.allowInArrayDestructuring : true;
|
86
|
+
const allowInObjectDestructuring = typeof options.allowInObjectDestructuring !== "undefined" ? options.allowInObjectDestructuring : true;
|
77
87
|
|
78
88
|
//-------------------------------------------------------------------------
|
79
89
|
// Helpers
|
@@ -195,6 +205,7 @@ module.exports = {
|
|
195
205
|
checkForDanglingUnderscoreInFunctionParameters(node);
|
196
206
|
}
|
197
207
|
|
208
|
+
|
198
209
|
/**
|
199
210
|
* Check if variable expression has a dangling underscore
|
200
211
|
* @param {ASTNode} node node to evaluate
|
@@ -202,18 +213,32 @@ module.exports = {
|
|
202
213
|
* @private
|
203
214
|
*/
|
204
215
|
function checkForDanglingUnderscoreInVariableExpression(node) {
|
205
|
-
|
216
|
+
context.getDeclaredVariables(node).forEach(variable => {
|
217
|
+
const definition = variable.defs.find(def => def.node === node);
|
218
|
+
const identifierNode = definition.name;
|
219
|
+
const identifier = identifierNode.name;
|
220
|
+
let parent = identifierNode.parent;
|
221
|
+
|
222
|
+
while (!["VariableDeclarator", "ArrayPattern", "ObjectPattern"].includes(parent.type)) {
|
223
|
+
parent = parent.parent;
|
224
|
+
}
|
206
225
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
226
|
+
if (
|
227
|
+
hasDanglingUnderscore(identifier) &&
|
228
|
+
!isSpecialCaseIdentifierInVariableExpression(identifier) &&
|
229
|
+
!isAllowed(identifier) &&
|
230
|
+
!(allowInArrayDestructuring && parent.type === "ArrayPattern") &&
|
231
|
+
!(allowInObjectDestructuring && parent.type === "ObjectPattern")
|
232
|
+
) {
|
233
|
+
context.report({
|
234
|
+
node,
|
235
|
+
messageId: "unexpectedUnderscore",
|
236
|
+
data: {
|
237
|
+
identifier
|
238
|
+
}
|
239
|
+
});
|
240
|
+
}
|
241
|
+
});
|
217
242
|
}
|
218
243
|
|
219
244
|
/**
|
@@ -335,6 +335,7 @@ module.exports = {
|
|
335
335
|
// Convert the function expression to an arrow function.
|
336
336
|
const functionToken = sourceCode.getFirstToken(node, node.async ? 1 : 0);
|
337
337
|
const leftParenToken = sourceCode.getTokenAfter(functionToken, astUtils.isOpeningParenToken);
|
338
|
+
const tokenBeforeBody = sourceCode.getTokenBefore(node.body);
|
338
339
|
|
339
340
|
if (sourceCode.commentsExistBetween(functionToken, leftParenToken)) {
|
340
341
|
|
@@ -348,7 +349,7 @@ module.exports = {
|
|
348
349
|
// Remove extra tokens and spaces.
|
349
350
|
yield fixer.removeRange([functionToken.range[0], leftParenToken.range[0]]);
|
350
351
|
}
|
351
|
-
yield fixer.
|
352
|
+
yield fixer.insertTextAfter(tokenBeforeBody, " =>");
|
352
353
|
|
353
354
|
// Get the node that will become the new arrow function.
|
354
355
|
let replacedNode = callbackInfo.isLexicalThis ? node.parent.parent : node;
|
@@ -146,6 +146,8 @@ module.exports = {
|
|
146
146
|
messages: {
|
147
147
|
unexpectedRegExp: "Use a regular expression literal instead of the 'RegExp' constructor.",
|
148
148
|
replaceWithLiteral: "Replace with an equivalent regular expression literal.",
|
149
|
+
replaceWithLiteralAndFlags: "Replace with an equivalent regular expression literal with flags '{{ flags }}'.",
|
150
|
+
replaceWithIntendedLiteralAndFlags: "Replace with a regular expression literal with flags '{{ flags }}'.",
|
149
151
|
unexpectedRedundantRegExp: "Regular expression literal is unnecessarily wrapped within a 'RegExp' constructor.",
|
150
152
|
unexpectedRedundantRegExpWithFlags: "Use regular expression literal with flags instead of the 'RegExp' constructor."
|
151
153
|
}
|
@@ -258,6 +260,8 @@ module.exports = {
|
|
258
260
|
return Math.min(ecmaVersion, REGEXPP_LATEST_ECMA_VERSION);
|
259
261
|
}
|
260
262
|
|
263
|
+
const regexppEcmaVersion = getRegexppEcmaVersion(context.languageOptions.ecmaVersion);
|
264
|
+
|
261
265
|
/**
|
262
266
|
* Makes a character escaped or else returns null.
|
263
267
|
* @param {string} character The character to escape.
|
@@ -293,6 +297,83 @@ module.exports = {
|
|
293
297
|
}
|
294
298
|
}
|
295
299
|
|
300
|
+
/**
|
301
|
+
* Checks whether the given regex and flags are valid for the ecma version or not.
|
302
|
+
* @param {string} pattern The regex pattern to check.
|
303
|
+
* @param {string | undefined} flags The regex flags to check.
|
304
|
+
* @returns {boolean} True if the given regex pattern and flags are valid for the ecma version.
|
305
|
+
*/
|
306
|
+
function isValidRegexForEcmaVersion(pattern, flags) {
|
307
|
+
const validator = new RegExpValidator({ ecmaVersion: regexppEcmaVersion });
|
308
|
+
|
309
|
+
try {
|
310
|
+
validator.validatePattern(pattern, 0, pattern.length, flags ? flags.includes("u") : false);
|
311
|
+
if (flags) {
|
312
|
+
validator.validateFlags(flags);
|
313
|
+
}
|
314
|
+
return true;
|
315
|
+
} catch {
|
316
|
+
return false;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
/**
|
321
|
+
* Checks whether two given regex flags contain the same flags or not.
|
322
|
+
* @param {string} flagsA The regex flags.
|
323
|
+
* @param {string} flagsB The regex flags.
|
324
|
+
* @returns {boolean} True if two regex flags contain same flags.
|
325
|
+
*/
|
326
|
+
function areFlagsEqual(flagsA, flagsB) {
|
327
|
+
return [...flagsA].sort().join("") === [...flagsB].sort().join("");
|
328
|
+
}
|
329
|
+
|
330
|
+
|
331
|
+
/**
|
332
|
+
* Merges two regex flags.
|
333
|
+
* @param {string} flagsA The regex flags.
|
334
|
+
* @param {string} flagsB The regex flags.
|
335
|
+
* @returns {string} The merged regex flags.
|
336
|
+
*/
|
337
|
+
function mergeRegexFlags(flagsA, flagsB) {
|
338
|
+
const flagsSet = new Set([
|
339
|
+
...flagsA,
|
340
|
+
...flagsB
|
341
|
+
]);
|
342
|
+
|
343
|
+
return [...flagsSet].join("");
|
344
|
+
}
|
345
|
+
|
346
|
+
/**
|
347
|
+
* Checks whether a give node can be fixed to the given regex pattern and flags.
|
348
|
+
* @param {ASTNode} node The node to check.
|
349
|
+
* @param {string} pattern The regex pattern to check.
|
350
|
+
* @param {string} flags The regex flags
|
351
|
+
* @returns {boolean} True if a node can be fixed to the given regex pattern and flags.
|
352
|
+
*/
|
353
|
+
function canFixTo(node, pattern, flags) {
|
354
|
+
const tokenBefore = sourceCode.getTokenBefore(node);
|
355
|
+
|
356
|
+
return sourceCode.getCommentsInside(node).length === 0 &&
|
357
|
+
(!tokenBefore || validPrecedingTokens.has(tokenBefore.value)) &&
|
358
|
+
isValidRegexForEcmaVersion(pattern, flags);
|
359
|
+
}
|
360
|
+
|
361
|
+
/**
|
362
|
+
* Returns a safe output code considering the before and after tokens.
|
363
|
+
* @param {ASTNode} node The regex node.
|
364
|
+
* @param {string} newRegExpValue The new regex expression value.
|
365
|
+
* @returns {string} The output code.
|
366
|
+
*/
|
367
|
+
function getSafeOutput(node, newRegExpValue) {
|
368
|
+
const tokenBefore = sourceCode.getTokenBefore(node);
|
369
|
+
const tokenAfter = sourceCode.getTokenAfter(node);
|
370
|
+
|
371
|
+
return (tokenBefore && !canTokensBeAdjacent(tokenBefore, newRegExpValue) && tokenBefore.range[1] === node.range[0] ? " " : "") +
|
372
|
+
newRegExpValue +
|
373
|
+
(tokenAfter && !canTokensBeAdjacent(newRegExpValue, tokenAfter) && node.range[1] === tokenAfter.range[0] ? " " : "");
|
374
|
+
|
375
|
+
}
|
376
|
+
|
296
377
|
return {
|
297
378
|
Program() {
|
298
379
|
const scope = context.getScope();
|
@@ -306,10 +387,69 @@ module.exports = {
|
|
306
387
|
|
307
388
|
for (const { node } of tracker.iterateGlobalReferences(traceMap)) {
|
308
389
|
if (disallowRedundantWrapping && isUnnecessarilyWrappedRegexLiteral(node)) {
|
390
|
+
const regexNode = node.arguments[0];
|
391
|
+
|
309
392
|
if (node.arguments.length === 2) {
|
310
|
-
|
393
|
+
const suggests = [];
|
394
|
+
|
395
|
+
const argFlags = getStringValue(node.arguments[1]) || "";
|
396
|
+
|
397
|
+
if (canFixTo(node, regexNode.regex.pattern, argFlags)) {
|
398
|
+
suggests.push({
|
399
|
+
messageId: "replaceWithLiteralAndFlags",
|
400
|
+
pattern: regexNode.regex.pattern,
|
401
|
+
flags: argFlags
|
402
|
+
});
|
403
|
+
}
|
404
|
+
|
405
|
+
const literalFlags = regexNode.regex.flags || "";
|
406
|
+
const mergedFlags = mergeRegexFlags(literalFlags, argFlags);
|
407
|
+
|
408
|
+
if (
|
409
|
+
!areFlagsEqual(mergedFlags, argFlags) &&
|
410
|
+
canFixTo(node, regexNode.regex.pattern, mergedFlags)
|
411
|
+
) {
|
412
|
+
suggests.push({
|
413
|
+
messageId: "replaceWithIntendedLiteralAndFlags",
|
414
|
+
pattern: regexNode.regex.pattern,
|
415
|
+
flags: mergedFlags
|
416
|
+
});
|
417
|
+
}
|
418
|
+
|
419
|
+
context.report({
|
420
|
+
node,
|
421
|
+
messageId: "unexpectedRedundantRegExpWithFlags",
|
422
|
+
suggest: suggests.map(({ flags, pattern, messageId }) => ({
|
423
|
+
messageId,
|
424
|
+
data: {
|
425
|
+
flags
|
426
|
+
},
|
427
|
+
fix(fixer) {
|
428
|
+
return fixer.replaceText(node, getSafeOutput(node, `/${pattern}/${flags}`));
|
429
|
+
}
|
430
|
+
}))
|
431
|
+
});
|
311
432
|
} else {
|
312
|
-
|
433
|
+
const outputs = [];
|
434
|
+
|
435
|
+
if (canFixTo(node, regexNode.regex.pattern, regexNode.regex.flags)) {
|
436
|
+
outputs.push(sourceCode.getText(regexNode));
|
437
|
+
}
|
438
|
+
|
439
|
+
|
440
|
+
context.report({
|
441
|
+
node,
|
442
|
+
messageId: "unexpectedRedundantRegExp",
|
443
|
+
suggest: outputs.map(output => ({
|
444
|
+
messageId: "replaceWithLiteral",
|
445
|
+
fix(fixer) {
|
446
|
+
return fixer.replaceText(
|
447
|
+
node,
|
448
|
+
getSafeOutput(node, output)
|
449
|
+
);
|
450
|
+
}
|
451
|
+
}))
|
452
|
+
});
|
313
453
|
}
|
314
454
|
} else if (hasOnlyStaticStringArguments(node)) {
|
315
455
|
let regexContent = getStringValue(node.arguments[0]);
|
@@ -320,21 +460,7 @@ module.exports = {
|
|
320
460
|
flags = getStringValue(node.arguments[1]);
|
321
461
|
}
|
322
462
|
|
323
|
-
|
324
|
-
const RegExpValidatorInstance = new RegExpValidator({ ecmaVersion: regexppEcmaVersion });
|
325
|
-
|
326
|
-
try {
|
327
|
-
RegExpValidatorInstance.validatePattern(regexContent, 0, regexContent.length, flags ? flags.includes("u") : false);
|
328
|
-
if (flags) {
|
329
|
-
RegExpValidatorInstance.validateFlags(flags);
|
330
|
-
}
|
331
|
-
} catch {
|
332
|
-
noFix = true;
|
333
|
-
}
|
334
|
-
|
335
|
-
const tokenBefore = sourceCode.getTokenBefore(node);
|
336
|
-
|
337
|
-
if (tokenBefore && !validPrecedingTokens.has(tokenBefore.value)) {
|
463
|
+
if (!canFixTo(node, regexContent, flags)) {
|
338
464
|
noFix = true;
|
339
465
|
}
|
340
466
|
|
@@ -342,10 +468,6 @@ module.exports = {
|
|
342
468
|
noFix = true;
|
343
469
|
}
|
344
470
|
|
345
|
-
if (sourceCode.getCommentsInside(node).length > 0) {
|
346
|
-
noFix = true;
|
347
|
-
}
|
348
|
-
|
349
471
|
if (regexContent && !noFix) {
|
350
472
|
let charIncrease = 0;
|
351
473
|
|
@@ -377,14 +499,7 @@ module.exports = {
|
|
377
499
|
suggest: noFix ? [] : [{
|
378
500
|
messageId: "replaceWithLiteral",
|
379
501
|
fix(fixer) {
|
380
|
-
|
381
|
-
|
382
|
-
return fixer.replaceText(
|
383
|
-
node,
|
384
|
-
(tokenBefore && !canTokensBeAdjacent(tokenBefore, newRegExpValue) && tokenBefore.range[1] === node.range[0] ? " " : "") +
|
385
|
-
newRegExpValue +
|
386
|
-
(tokenAfter && !canTokensBeAdjacent(newRegExpValue, tokenAfter) && node.range[1] === tokenAfter.range[0] ? " " : "")
|
387
|
-
);
|
502
|
+
return fixer.replaceText(node, getSafeOutput(node, newRegExpValue));
|
388
503
|
}
|
389
504
|
}]
|
390
505
|
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Common utils for directives.
|
3
|
+
*
|
4
|
+
* This file contains only shared items for directives.
|
5
|
+
* If you make a utility for rules, please see `../rules/utils/ast-utils.js`.
|
6
|
+
*
|
7
|
+
* @author gfyoung <https://github.com/gfyoung>
|
8
|
+
*/
|
9
|
+
"use strict";
|
10
|
+
|
11
|
+
const directivesPattern = /^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u;
|
12
|
+
|
13
|
+
module.exports = {
|
14
|
+
directivesPattern
|
15
|
+
};
|
@@ -3,6 +3,6 @@
|
|
3
3
|
module.exports = function() {
|
4
4
|
return `
|
5
5
|
The '--print-config' CLI option requires a path to a source code file rather than a directory.
|
6
|
-
See also: https://eslint.org/docs/
|
6
|
+
See also: https://eslint.org/docs/latest/use/command-line-interface#--print-config
|
7
7
|
`.trimStart();
|
8
8
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.32.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -14,17 +14,18 @@
|
|
14
14
|
},
|
15
15
|
"scripts": {
|
16
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
17
|
"build:site": "node Makefile.js gensite",
|
23
18
|
"build:webpack": "node Makefile.js webpack",
|
19
|
+
"build:readme": "node tools/update-readme.js",
|
24
20
|
"lint": "node Makefile.js lint",
|
25
|
-
"lint:fix": "node Makefile.js lint -- fix",
|
26
21
|
"lint:docs:js": "node Makefile.js lintDocsJS",
|
22
|
+
"lint:fix": "node Makefile.js lint -- fix",
|
27
23
|
"lint:fix:docs:js": "node Makefile.js lintDocsJS -- fix",
|
24
|
+
"release:generate:alpha": "node Makefile.js generatePrerelease -- alpha",
|
25
|
+
"release:generate:beta": "node Makefile.js generatePrerelease -- beta",
|
26
|
+
"release:generate:latest": "node Makefile.js generateRelease",
|
27
|
+
"release:generate:rc": "node Makefile.js generatePrerelease -- rc",
|
28
|
+
"release:publish": "node Makefile.js publishRelease",
|
28
29
|
"test": "node Makefile.js test",
|
29
30
|
"test:cli": "mocha",
|
30
31
|
"test:fuzz": "node Makefile.js fuzz",
|
@@ -55,7 +56,7 @@
|
|
55
56
|
"homepage": "https://eslint.org",
|
56
57
|
"bugs": "https://github.com/eslint/eslint/issues/",
|
57
58
|
"dependencies": {
|
58
|
-
"@eslint/eslintrc": "^1.4.
|
59
|
+
"@eslint/eslintrc": "^1.4.1",
|
59
60
|
"@humanwhocodes/config-array": "^0.11.8",
|
60
61
|
"@humanwhocodes/module-importer": "^1.0.1",
|
61
62
|
"@nodelib/fs.walk": "^1.2.8",
|