eslint 7.28.0 → 7.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/CHANGELOG.md +58 -0
- package/README.md +17 -2
- package/lib/cli-engine/cli-engine.js +6 -0
- package/lib/cli.js +11 -2
- package/lib/config/default-config.js +52 -0
- package/lib/config/flat-config-array.js +125 -0
- package/lib/config/flat-config-schema.js +452 -0
- package/lib/config/rule-validator.js +169 -0
- package/lib/eslint/eslint.js +38 -2
- package/lib/init/npm-utils.js +1 -2
- package/lib/linter/linter.js +16 -12
- package/lib/options.js +6 -0
- package/lib/rule-tester/rule-tester.js +75 -13
- package/lib/rules/comma-style.js +3 -2
- package/lib/rules/consistent-return.js +3 -3
- package/lib/rules/curly.js +2 -11
- package/lib/rules/dot-notation.js +3 -3
- package/lib/rules/indent.js +2 -4
- package/lib/rules/no-fallthrough.js +17 -6
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/operator-assignment.js +6 -3
- package/lib/rules/prefer-arrow-callback.js +4 -4
- package/lib/rules/use-isnan.js +4 -1
- package/lib/source-code/source-code.js +2 -2
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,61 @@
|
|
1
|
+
v7.32.0 - July 30, 2021
|
2
|
+
|
3
|
+
* [`3c78a7b`](https://github.com/eslint/eslint/commit/3c78a7bff6044fd196ae3b737983e6744c6eb7c8) Chore: Adopt `eslint-plugin/prefer-message-ids` rule internally (#14841) (Bryan Mishkin)
|
4
|
+
* [`faecf56`](https://github.com/eslint/eslint/commit/faecf56cdb4146b28bfa4f1980adb41b4d3614b1) Update: change reporting location for `curly` rule (refs #12334) (#14766) (Nitin Kumar)
|
5
|
+
* [`d7dc07a`](https://github.com/eslint/eslint/commit/d7dc07a15e256cee9232183165e2f6102f2c0873) Fix: ignore lines with empty elements (fixes #12756) (#14837) (Soufiane Boutahlil)
|
6
|
+
* [`1bfbefd`](https://github.com/eslint/eslint/commit/1bfbefdaaf19ef32df42b89a3f5d32cff1e5b831) New: Exit on fatal error (fixes #13711) (#14730) (Antonios Katopodis)
|
7
|
+
* [`ed007c8`](https://github.com/eslint/eslint/commit/ed007c82ee9d2170c87500d98303554b5f90b915) Chore: Simplify internal `no-invalid-meta` rule (#14842) (Bryan Mishkin)
|
8
|
+
* [`d53d906`](https://github.com/eslint/eslint/commit/d53d9064b9dd0dd6a8ea39e07b16310c8364db69) Docs: Prepare data for website to indicate rules with suggestions (#14830) (Bryan Mishkin)
|
9
|
+
* [`d28f2ff`](https://github.com/eslint/eslint/commit/d28f2ffb986e49d6da5c1d91215580591f4cfd35) Docs: Reference eslint-config-eslint to avoid potential for staleness (#14805) (Brett Zamir)
|
10
|
+
* [`8be8a36`](https://github.com/eslint/eslint/commit/8be8a36010145dfcd31cbdd4f781a91989e3b1bd) Chore: Adopt `eslint-plugin/require-meta-docs-url` rule internally (#14823) (Bryan Mishkin)
|
11
|
+
* [`f9c164f`](https://github.com/eslint/eslint/commit/f9c164f7b74ca73384c8c80eed5bdbe359b44f6c) Docs: New syntax issue template (#14826) (Nicholas C. Zakas)
|
12
|
+
* [`eba0c45`](https://github.com/eslint/eslint/commit/eba0c4595c126a91f700d5f2e8723ec3f820a830) Chore: assertions on reporting loc in `unicode-bom` (refs #12334) (#14809) (Nitin Kumar)
|
13
|
+
* [`ed945bd`](https://github.com/eslint/eslint/commit/ed945bd662714b1917e9de71d5b322a28be9161b) Docs: fix multiple broken links (#14833) (Sam Chen)
|
14
|
+
* [`60df44c`](https://github.com/eslint/eslint/commit/60df44c79b0f74406119c0c040a360ca84e721fc) Chore: use `actions/setup-node@v2` (#14816) (Nitin Kumar)
|
15
|
+
* [`6641d88`](https://github.com/eslint/eslint/commit/6641d88e17d952a8e51df5e0d3882a842d4c3f35) Docs: Update README team and sponsors (ESLint Jenkins)
|
16
|
+
|
17
|
+
v7.31.0 - July 17, 2021
|
18
|
+
|
19
|
+
* [`efdbb12`](https://github.com/eslint/eslint/commit/efdbb1227019427ec2d968a8d6e9151dd8a77c35) Upgrade: @eslint/eslintrc to v0.4.3 (#14808) (Brandon Mills)
|
20
|
+
* [`a96b05f`](https://github.com/eslint/eslint/commit/a96b05f6c5649cfee112d605c91d95aa191e2f78) Update: add end location to report in `consistent-return` (refs #12334) (#14798) (Nitin Kumar)
|
21
|
+
* [`e0e8e30`](https://github.com/eslint/eslint/commit/e0e8e308929c9c66612505f2da89043f8592eea7) Docs: update BUG_REPORT template (#14787) (Nitin Kumar)
|
22
|
+
* [`39115c8`](https://github.com/eslint/eslint/commit/39115c8b71d2629161359f6456f47fdbd552fddd) Docs: provide more context to no-eq-null (#14801) (gfyoung)
|
23
|
+
* [`9a3c73c`](https://github.com/eslint/eslint/commit/9a3c73c130d437a65f4edba0dcb63390e68cac41) Docs: fix a broken link (#14790) (Sam Chen)
|
24
|
+
* [`ddffa8a`](https://github.com/eslint/eslint/commit/ddffa8ad58b4b124b08061e9045fdb5370cbdbe3) Update: Indicating the operator in question (#14764) (Paul Smith)
|
25
|
+
* [`bba714c`](https://github.com/eslint/eslint/commit/bba714c2ed813821ed288fbc07722cdde6e534fe) Update: Clarifying what changes need to be made in no-mixed-operators (#14765) (Paul Smith)
|
26
|
+
* [`b0d22e3`](https://github.com/eslint/eslint/commit/b0d22e3eff18ea7f08189134c07cddceaec69a09) Docs: Mention benefit of providing `meta.docs.url` (#14774) (Bryan Mishkin)
|
27
|
+
* [`000cc79`](https://github.com/eslint/eslint/commit/000cc796fd487e7b9ba8bcc5857dd691044479cc) Sponsors: Sync README with website (ESLint Jenkins)
|
28
|
+
* [`a6a7438`](https://github.com/eslint/eslint/commit/a6a7438502abc6a1e29ec35cfbe2058ffc0803b1) Chore: pin fs-teardown@0.1.1 (#14771) (Milos Djermanovic)
|
29
|
+
|
30
|
+
v7.30.0 - July 2, 2021
|
31
|
+
|
32
|
+
* [`5f74642`](https://github.com/eslint/eslint/commit/5f746420700d457b92dd86659de588d272937b79) Chore: don't check Program.start in SourceCode#getComments (refs #14744) (#14748) (Milos Djermanovic)
|
33
|
+
* [`19a871a`](https://github.com/eslint/eslint/commit/19a871a35ae9997ce352624b1081c96c54b73a9f) Docs: Suggest linting plugins for ESLint plugin developers (#14754) (Bryan Mishkin)
|
34
|
+
* [`aa87329`](https://github.com/eslint/eslint/commit/aa87329d919f569404ca573b439934552006572f) Docs: fix broken links (#14756) (Sam Chen)
|
35
|
+
* [`278813a`](https://github.com/eslint/eslint/commit/278813a6e759f6b5512ac64c7530c9c51732e692) Docs: fix and add more examples for new-cap rule (fixes #12874) (#14725) (Nitin Kumar)
|
36
|
+
* [`ed1da5d`](https://github.com/eslint/eslint/commit/ed1da5d96af2587b7211854e45cf8657ef808710) Update: ecmaVersion allows "latest" (#14720) (薛定谔的猫)
|
37
|
+
* [`104c0b5`](https://github.com/eslint/eslint/commit/104c0b592f203d315a108d311c58375357e40b24) Update: improve use-isnan rule to detect `Number.NaN` (fixes #14715) (#14718) (Nitin Kumar)
|
38
|
+
* [`b08170b`](https://github.com/eslint/eslint/commit/b08170b92beb22db6ec612ebdfff930f9e0582ab) Update: Implement FlatConfigArray (refs #13481) (#14321) (Nicholas C. Zakas)
|
39
|
+
* [`f113cdd`](https://github.com/eslint/eslint/commit/f113cdd872257d72bbd66d95e4eaf13623323b24) Chore: upgrade eslint-plugin-eslint-plugin (#14738) (薛定谔的猫)
|
40
|
+
* [`1b8997a`](https://github.com/eslint/eslint/commit/1b8997ab63781f4ebf87e3269400b2ef4c7d2973) Docs: Fix getRulesMetaForResults link syntax (#14723) (Brandon Mills)
|
41
|
+
* [`aada733`](https://github.com/eslint/eslint/commit/aada733d2aee830aa32cccb9828cd72db4ccd6bd) Docs: fix two broken links (#14726) (Sam Chen)
|
42
|
+
* [`8972529`](https://github.com/eslint/eslint/commit/8972529f82d13bd04059ee8852b4ebb9b5350962) Docs: Update README team and sponsors (ESLint Jenkins)
|
43
|
+
|
44
|
+
v7.29.0 - June 18, 2021
|
45
|
+
|
46
|
+
* [`bfbfe5c`](https://github.com/eslint/eslint/commit/bfbfe5c1fd4c39a06d5e159dbe48479ca4305fc0) New: Add only to RuleTester (refs eslint/rfcs#73) (#14677) (Brandon Mills)
|
47
|
+
* [`c2cd7b4`](https://github.com/eslint/eslint/commit/c2cd7b4a18057ca6067bdfc16de771dc5d90c0ea) New: Add ESLint#getRulesMetaForResults() (refs #13654) (#14716) (Nicholas C. Zakas)
|
48
|
+
* [`eea7e0d`](https://github.com/eslint/eslint/commit/eea7e0d09d6ef43d6663cbe424e7974764a5f7fe) Chore: remove duplicate code (#14719) (Nitin Kumar)
|
49
|
+
* [`6a1c7a0`](https://github.com/eslint/eslint/commit/6a1c7a0dac050ea5876972c50563a7eb867b38d3) Fix: allow fallthrough comment inside block (fixes #14701) (#14702) (Kevin Gibbons)
|
50
|
+
* [`a47e5e3`](https://github.com/eslint/eslint/commit/a47e5e30b0da364593b6881f6826c595da8696f5) Docs: Add Mega-Linter to the list of integrations (#14707) (Nicolas Vuillamy)
|
51
|
+
* [`353ddf9`](https://github.com/eslint/eslint/commit/353ddf965078030794419b089994373e27ffc86e) Chore: enable reportUnusedDisableDirectives in eslint-config-eslint (#14699) (薛定谔的猫)
|
52
|
+
* [`757c495`](https://github.com/eslint/eslint/commit/757c49584a5852c468c1b4a0b74ad3aa39d954e5) Chore: add some rules to eslint-config-eslint (#14692) (薛定谔的猫)
|
53
|
+
* [`c93a222`](https://github.com/eslint/eslint/commit/c93a222563177a9b5bc7a59aa106bc0a6d31e063) Docs: fix a broken link (#14697) (Sam Chen)
|
54
|
+
* [`655c118`](https://github.com/eslint/eslint/commit/655c1187fc845bac61ae8d06c556f1a59ee2071b) Sponsors: Sync README with website (ESLint Jenkins)
|
55
|
+
* [`e2bed2e`](https://github.com/eslint/eslint/commit/e2bed2ead22b575d55ccaeed94eecd3a979dd871) Sponsors: Sync README with website (ESLint Jenkins)
|
56
|
+
* [`8490fb4`](https://github.com/eslint/eslint/commit/8490fb42e559ef0b3c34ac60be4e05e0d879a9cb) Sponsors: Sync README with website (ESLint Jenkins)
|
57
|
+
* [`ddbe877`](https://github.com/eslint/eslint/commit/ddbe877c95224e127215d35562a175c6f2b7ba22) Sponsors: Sync README with website (ESLint Jenkins)
|
58
|
+
|
1
59
|
v7.28.0 - June 4, 2021
|
2
60
|
|
3
61
|
* [`1237705`](https://github.com/eslint/eslint/commit/1237705dd08c209c5e3136045ec51a4ba87a3abe) Upgrade: @eslint/eslintrc to 0.4.2 (#14672) (Milos Djermanovic)
|
package/README.md
CHANGED
@@ -254,6 +254,16 @@ Toru Nagashima
|
|
254
254
|
The people who review and fix bugs and help triage issues.
|
255
255
|
|
256
256
|
<table><tbody><tr><td align="center" valign="top" width="11%">
|
257
|
+
<a href="https://github.com/brettz9">
|
258
|
+
<img src="https://github.com/brettz9.png?s=75" width="75" height="75"><br />
|
259
|
+
Brett Zamir
|
260
|
+
</a>
|
261
|
+
</td><td align="center" valign="top" width="11%">
|
262
|
+
<a href="https://github.com/bmish">
|
263
|
+
<img src="https://github.com/bmish.png?s=75" width="75" height="75"><br />
|
264
|
+
Bryan Mishkin
|
265
|
+
</a>
|
266
|
+
</td><td align="center" valign="top" width="11%">
|
257
267
|
<a href="https://github.com/g-plane">
|
258
268
|
<img src="https://github.com/g-plane.png?s=75" width="75" height="75"><br />
|
259
269
|
Pig Fang
|
@@ -268,6 +278,11 @@ Anix
|
|
268
278
|
<img src="https://github.com/yeonjuan.png?s=75" width="75" height="75"><br />
|
269
279
|
YeonJuan
|
270
280
|
</a>
|
281
|
+
</td><td align="center" valign="top" width="11%">
|
282
|
+
<a href="https://github.com/snitin315">
|
283
|
+
<img src="https://github.com/snitin315.png?s=75" width="75" height="75"><br />
|
284
|
+
Nitin Kumar
|
285
|
+
</a>
|
271
286
|
</td></tr></tbody></table>
|
272
287
|
|
273
288
|
|
@@ -281,9 +296,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
281
296
|
<!--sponsorsstart-->
|
282
297
|
<h3>Platinum Sponsors</h3>
|
283
298
|
<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.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://substack.com/"><img src="https://avatars.githubusercontent.com/u/53023767?v=4" alt="Substack" height="96"></a></p><h3>Silver Sponsors</h3>
|
299
|
+
<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.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://coinbase.com"><img src="https://avatars.githubusercontent.com/u/1885080?v=4" alt="Coinbase" 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
300
|
<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
|
-
<p><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://discord.com"><img src="https://images.opencollective.com/discordapp/
|
301
|
+
<p><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://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.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a> <a href="https://www.practiceignition.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Practice Ignition" height="32"></a></p>
|
287
302
|
<!--sponsorsend-->
|
288
303
|
|
289
304
|
## <a name="technology-sponsors"></a>Technology Sponsors
|
@@ -156,6 +156,9 @@ function calculateStatsPerFile(messages) {
|
|
156
156
|
return messages.reduce((stat, message) => {
|
157
157
|
if (message.fatal || message.severity === 2) {
|
158
158
|
stat.errorCount++;
|
159
|
+
if (message.fatal) {
|
160
|
+
stat.fatalErrorCount++;
|
161
|
+
}
|
159
162
|
if (message.fix) {
|
160
163
|
stat.fixableErrorCount++;
|
161
164
|
}
|
@@ -168,6 +171,7 @@ function calculateStatsPerFile(messages) {
|
|
168
171
|
return stat;
|
169
172
|
}, {
|
170
173
|
errorCount: 0,
|
174
|
+
fatalErrorCount: 0,
|
171
175
|
warningCount: 0,
|
172
176
|
fixableErrorCount: 0,
|
173
177
|
fixableWarningCount: 0
|
@@ -183,12 +187,14 @@ function calculateStatsPerFile(messages) {
|
|
183
187
|
function calculateStatsPerRun(results) {
|
184
188
|
return results.reduce((stat, result) => {
|
185
189
|
stat.errorCount += result.errorCount;
|
190
|
+
stat.fatalErrorCount += result.fatalErrorCount;
|
186
191
|
stat.warningCount += result.warningCount;
|
187
192
|
stat.fixableErrorCount += result.fixableErrorCount;
|
188
193
|
stat.fixableWarningCount += result.fixableWarningCount;
|
189
194
|
return stat;
|
190
195
|
}, {
|
191
196
|
errorCount: 0,
|
197
|
+
fatalErrorCount: 0,
|
192
198
|
warningCount: 0,
|
193
199
|
fixableErrorCount: 0,
|
194
200
|
fixableWarningCount: 0
|
package/lib/cli.js
CHANGED
@@ -131,14 +131,16 @@ function translateOptions({
|
|
131
131
|
*/
|
132
132
|
function countErrors(results) {
|
133
133
|
let errorCount = 0;
|
134
|
+
let fatalErrorCount = 0;
|
134
135
|
let warningCount = 0;
|
135
136
|
|
136
137
|
for (const result of results) {
|
137
138
|
errorCount += result.errorCount;
|
139
|
+
fatalErrorCount += result.fatalErrorCount;
|
138
140
|
warningCount += result.warningCount;
|
139
141
|
}
|
140
142
|
|
141
|
-
return { errorCount, warningCount };
|
143
|
+
return { errorCount, fatalErrorCount, warningCount };
|
142
144
|
}
|
143
145
|
|
144
146
|
/**
|
@@ -314,9 +316,12 @@ const cli = {
|
|
314
316
|
if (await printResults(engine, resultsToPrint, options.format, options.outputFile)) {
|
315
317
|
|
316
318
|
// Errors and warnings from the original unfiltered results should determine the exit code
|
317
|
-
const { errorCount, warningCount } = countErrors(results);
|
319
|
+
const { errorCount, fatalErrorCount, warningCount } = countErrors(results);
|
320
|
+
|
318
321
|
const tooManyWarnings =
|
319
322
|
options.maxWarnings >= 0 && warningCount > options.maxWarnings;
|
323
|
+
const shouldExitForFatalErrors =
|
324
|
+
options.exitOnFatalError && fatalErrorCount > 0;
|
320
325
|
|
321
326
|
if (!errorCount && tooManyWarnings) {
|
322
327
|
log.error(
|
@@ -325,6 +330,10 @@ const cli = {
|
|
325
330
|
);
|
326
331
|
}
|
327
332
|
|
333
|
+
if (shouldExitForFatalErrors) {
|
334
|
+
return 2;
|
335
|
+
}
|
336
|
+
|
328
337
|
return (errorCount || tooManyWarnings) ? 1 : 0;
|
329
338
|
}
|
330
339
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Default configuration
|
3
|
+
* @author Nicholas C. Zakas
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
//-----------------------------------------------------------------------------
|
9
|
+
// Requirements
|
10
|
+
//-----------------------------------------------------------------------------
|
11
|
+
|
12
|
+
const Rules = require("../rules");
|
13
|
+
|
14
|
+
//-----------------------------------------------------------------------------
|
15
|
+
// Helpers
|
16
|
+
//-----------------------------------------------------------------------------
|
17
|
+
|
18
|
+
|
19
|
+
exports.defaultConfig = [
|
20
|
+
{
|
21
|
+
plugins: {
|
22
|
+
"@": {
|
23
|
+
parsers: {
|
24
|
+
espree: require("espree")
|
25
|
+
},
|
26
|
+
|
27
|
+
/*
|
28
|
+
* Because we try to delay loading rules until absolutely
|
29
|
+
* necessary, a proxy allows us to hook into the lazy-loading
|
30
|
+
* aspect of the rules map while still keeping all of the
|
31
|
+
* relevant configuration inside of the config array.
|
32
|
+
*/
|
33
|
+
rules: new Proxy({}, {
|
34
|
+
get(target, property) {
|
35
|
+
return Rules.get(property);
|
36
|
+
},
|
37
|
+
|
38
|
+
has(target, property) {
|
39
|
+
return Rules.has(property);
|
40
|
+
}
|
41
|
+
})
|
42
|
+
}
|
43
|
+
},
|
44
|
+
ignores: [
|
45
|
+
"**/node_modules/**",
|
46
|
+
".git/**"
|
47
|
+
],
|
48
|
+
languageOptions: {
|
49
|
+
parser: "@/espree"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
];
|
@@ -0,0 +1,125 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Flat Config Array
|
3
|
+
* @author Nicholas C. Zakas
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
//-----------------------------------------------------------------------------
|
9
|
+
// Requirements
|
10
|
+
//-----------------------------------------------------------------------------
|
11
|
+
|
12
|
+
const { ConfigArray, ConfigArraySymbol } = require("@humanwhocodes/config-array");
|
13
|
+
const { flatConfigSchema } = require("./flat-config-schema");
|
14
|
+
const { RuleValidator } = require("./rule-validator");
|
15
|
+
const { defaultConfig } = require("./default-config");
|
16
|
+
const recommendedConfig = require("../../conf/eslint-recommended");
|
17
|
+
const allConfig = require("../../conf/eslint-all");
|
18
|
+
|
19
|
+
//-----------------------------------------------------------------------------
|
20
|
+
// Helpers
|
21
|
+
//-----------------------------------------------------------------------------
|
22
|
+
|
23
|
+
const ruleValidator = new RuleValidator();
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Splits a plugin identifier in the form a/b/c into two parts: a/b and c.
|
27
|
+
* @param {string} identifier The identifier to parse.
|
28
|
+
* @returns {{objectName: string, pluginName: string}} The parts of the plugin
|
29
|
+
* name.
|
30
|
+
*/
|
31
|
+
function splitPluginIdentifier(identifier) {
|
32
|
+
const parts = identifier.split("/");
|
33
|
+
|
34
|
+
return {
|
35
|
+
objectName: parts.pop(),
|
36
|
+
pluginName: parts.join("/")
|
37
|
+
};
|
38
|
+
}
|
39
|
+
|
40
|
+
//-----------------------------------------------------------------------------
|
41
|
+
// Exports
|
42
|
+
//-----------------------------------------------------------------------------
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Represents an array containing configuration information for ESLint.
|
46
|
+
*/
|
47
|
+
class FlatConfigArray extends ConfigArray {
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Creates a new instance.
|
51
|
+
* @param {*[]} configs An array of configuration information.
|
52
|
+
* @param {{basePath: string, baseConfig: FlatConfig}} options The options
|
53
|
+
* to use for the config array instance.
|
54
|
+
*/
|
55
|
+
constructor(configs, { basePath, baseConfig = defaultConfig }) {
|
56
|
+
super(configs, {
|
57
|
+
basePath,
|
58
|
+
schema: flatConfigSchema
|
59
|
+
});
|
60
|
+
|
61
|
+
this.unshift(baseConfig);
|
62
|
+
}
|
63
|
+
|
64
|
+
/* eslint-disable class-methods-use-this */
|
65
|
+
/**
|
66
|
+
* Replaces a config with another config to allow us to put strings
|
67
|
+
* in the config array that will be replaced by objects before
|
68
|
+
* normalization.
|
69
|
+
* @param {Object} config The config to preprocess.
|
70
|
+
* @returns {Object} The preprocessed config.
|
71
|
+
*/
|
72
|
+
[ConfigArraySymbol.preprocessConfig](config) {
|
73
|
+
if (config === "eslint:recommended") {
|
74
|
+
return recommendedConfig;
|
75
|
+
}
|
76
|
+
|
77
|
+
if (config === "eslint:all") {
|
78
|
+
return allConfig;
|
79
|
+
}
|
80
|
+
|
81
|
+
return config;
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Finalizes the config by replacing plugin references with their objects
|
86
|
+
* and validating rule option schemas.
|
87
|
+
* @param {Object} config The config to finalize.
|
88
|
+
* @returns {Object} The finalized config.
|
89
|
+
* @throws {TypeError} If the config is invalid.
|
90
|
+
*/
|
91
|
+
[ConfigArraySymbol.finalizeConfig](config) {
|
92
|
+
|
93
|
+
const { plugins, languageOptions, processor } = config;
|
94
|
+
|
95
|
+
// Check parser value
|
96
|
+
if (languageOptions && languageOptions.parser && typeof languageOptions.parser === "string") {
|
97
|
+
const { pluginName, objectName: parserName } = splitPluginIdentifier(languageOptions.parser);
|
98
|
+
|
99
|
+
if (!plugins || !plugins[pluginName] || !plugins[pluginName].parsers || !plugins[pluginName].parsers[parserName]) {
|
100
|
+
throw new TypeError(`Key "parser": Could not find "${parserName}" in plugin "${pluginName}".`);
|
101
|
+
}
|
102
|
+
|
103
|
+
languageOptions.parser = plugins[pluginName].parsers[parserName];
|
104
|
+
}
|
105
|
+
|
106
|
+
// Check processor value
|
107
|
+
if (processor && typeof processor === "string") {
|
108
|
+
const { pluginName, objectName: processorName } = splitPluginIdentifier(processor);
|
109
|
+
|
110
|
+
if (!plugins || !plugins[pluginName] || !plugins[pluginName].processors || !plugins[pluginName].processors[processorName]) {
|
111
|
+
throw new TypeError(`Key "processor": Could not find "${processorName}" in plugin "${pluginName}".`);
|
112
|
+
}
|
113
|
+
|
114
|
+
config.processor = plugins[pluginName].processors[processorName];
|
115
|
+
}
|
116
|
+
|
117
|
+
ruleValidator.validate(config);
|
118
|
+
|
119
|
+
return config;
|
120
|
+
}
|
121
|
+
/* eslint-enable class-methods-use-this */
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
exports.FlatConfigArray = FlatConfigArray;
|