eslint 7.8.1 → 7.12.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 +77 -0
- package/README.md +5 -4
- package/lib/cli-engine/cli-engine.js +26 -7
- package/lib/cli-engine/file-enumerator.js +7 -2
- package/lib/linter/report-translator.js +13 -9
- package/lib/rules/constructor-super.js +11 -0
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/id-length.js +2 -7
- package/lib/rules/max-lines.js +8 -0
- package/lib/rules/no-constant-condition.js +42 -20
- package/lib/rules/no-extra-parens.js +16 -1
- package/lib/rules/no-inline-comments.js +25 -4
- package/lib/rules/no-prototype-builtins.js +4 -4
- package/lib/rules/no-script-url.js +21 -7
- package/lib/rules/prefer-destructuring.js +26 -1
- package/lib/rules/prefer-template.js +14 -22
- package/lib/rules/quotes.js +5 -2
- package/lib/rules/space-before-blocks.js +34 -9
- package/lib/rules/utils/ast-utils.js +25 -8
- package/lib/rules/yoda.js +33 -23
- package/messages/plugin-invalid.txt +8 -0
- package/package.json +5 -4
- package/lib/cli-engine/cascading-config-array-factory.js +0 -502
- package/lib/cli-engine/config-array/config-array.js +0 -536
- package/lib/cli-engine/config-array/config-dependency.js +0 -128
- package/lib/cli-engine/config-array/extracted-config.js +0 -158
- package/lib/cli-engine/config-array/ignore-pattern.js +0 -249
- package/lib/cli-engine/config-array/index.js +0 -32
- package/lib/cli-engine/config-array/override-tester.js +0 -235
- package/lib/cli-engine/config-array-factory.js +0 -1086
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,80 @@
|
|
1
|
+
v7.12.0 - October 23, 2020
|
2
|
+
|
3
|
+
* [`cbf3585`](https://github.com/eslint/eslint/commit/cbf3585f1d6c60414c07380367a8b4505ee3538d) Update: skip keyword check for fns in space-before-blocks (fixes #13553) (#13712) (Milos Djermanovic)
|
4
|
+
* [`256f656`](https://github.com/eslint/eslint/commit/256f656455b47bcf9ed3fc30fbf72532678f97da) Fix: autofix shouldn't produce template literals with `\8` or `\9` (#13737) (Milos Djermanovic)
|
5
|
+
* [`b165aa5`](https://github.com/eslint/eslint/commit/b165aa5f4d4d19328f13ab80e5f058cbce94c3a6) Fix: yoda rule autofix produces syntax errors with adjacent tokens (#13760) (Milos Djermanovic)
|
6
|
+
* [`3175316`](https://github.com/eslint/eslint/commit/3175316db26aebef4b19e269aca90c8ce3955363) Fix: prefer-destructuring invalid autofix with comma operator (#13761) (Milos Djermanovic)
|
7
|
+
* [`1a9f171`](https://github.com/eslint/eslint/commit/1a9f17151a4e93eb17c8a2bf4f0a5320cce616de) Chore: Remove more ESLintRC-related files (refs #13481) (#13762) (Nicholas C. Zakas)
|
8
|
+
* [`bfddced`](https://github.com/eslint/eslint/commit/bfddcedace5587d662c840c2edf33062b54a178e) Update: remove suggestion if it didn't provide a fix (fixes #13723) (#13772) (Milos Djermanovic)
|
9
|
+
* [`5183b14`](https://github.com/eslint/eslint/commit/5183b14a2420b42b4089fb134a61ae57142f31fd) Update: check template literal in no-script-url (#13775) (YeonJuan)
|
10
|
+
* [`bfe97d2`](https://github.com/eslint/eslint/commit/bfe97d2332e711ca76b1fd2e7f8548b0cc84cb1c) Sponsors: Sync README with website (ESLint Jenkins)
|
11
|
+
* [`6c51ade`](https://github.com/eslint/eslint/commit/6c51adeb86f1de292cd02d2ee19f7b56182e358b) Sponsors: Sync README with website (ESLint Jenkins)
|
12
|
+
* [`603de04`](https://github.com/eslint/eslint/commit/603de04cab5e700df12999af2918decd4da9d11b) Update: treat all literals like boolean literal in no-constant-condition (#13245) (Zen)
|
13
|
+
* [`289aa6f`](https://github.com/eslint/eslint/commit/289aa6fcef3874ba5f86455f9302dc4209ea83e5) Sponsors: Sync README with website (ESLint Jenkins)
|
14
|
+
* [`9a1f669`](https://github.com/eslint/eslint/commit/9a1f6694e59eb3e584d4c5a98b98675c895a9783) Sponsors: Sync README with website (ESLint Jenkins)
|
15
|
+
* [`637f818`](https://github.com/eslint/eslint/commit/637f8187404ded600fb3d4013b3cd495d5ae675b) Docs: add more examples for no-func-assign (fixes #13705) (#13777) (Nitin Kumar)
|
16
|
+
* [`17cc0dd`](https://github.com/eslint/eslint/commit/17cc0dd9b5d2d500359c36881cd3e5637443c133) Chore: add test case for no-func-assign (refs #13705) (#13783) (Nitin Kumar)
|
17
|
+
* [`dee0f77`](https://github.com/eslint/eslint/commit/dee0f7764a1d5a323c89b22c4db94acee2b3c718) Docs: add TOC to user-guide/configuring.md (#13727) (metasean)
|
18
|
+
* [`0510621`](https://github.com/eslint/eslint/commit/05106212985cb1ffa1e6fa996a57f6fd2fc3c970) Update: Fix && vs || short-circuiting false negatives (fixes #13634) (#13769) (Brandon Mills)
|
19
|
+
* [`8b6ed69`](https://github.com/eslint/eslint/commit/8b6ed691c48189b7d096339441a78cb5874d4137) Sponsors: Sync README with website (ESLint Jenkins)
|
20
|
+
* [`1457509`](https://github.com/eslint/eslint/commit/145750991b04fd4cfb3fff3c5d4211a4428e011c) Docs: fix broken links in Node.js API docs (#13771) (Laura Barluzzi)
|
21
|
+
* [`7c813d4`](https://github.com/eslint/eslint/commit/7c813d458f9aedf7a94351d137728a4647542879) Docs: Fix typo in v7 migration page (#13778) (Yusuke Sasaki)
|
22
|
+
* [`b025795`](https://github.com/eslint/eslint/commit/b0257953be704d0bb387fc15afd7859fd6f19ba5) Docs: Fix the format option name in the document (#13770) (Hideki Igarashi)
|
23
|
+
* [`84fd591`](https://github.com/eslint/eslint/commit/84fd591c234accc41bb5af555f178825012fd35d) Chore: Increase Mocha timeout for copying fixtures (#13768) (Brandon Mills)
|
24
|
+
* [`1faeb84`](https://github.com/eslint/eslint/commit/1faeb84e663d88c5d85a3cb3f15cd224cc552c2d) Docs: clarify that space-unary-ops doesn't apply when space is required (#13767) (Taylor Morgan)
|
25
|
+
* [`67c0605`](https://github.com/eslint/eslint/commit/67c06059dd1ddcee6f369c650ce71220da1510c3) Update: check computed keys in no-prototype-builtins (fixes #13088) (#13755) (Milos Djermanovic)
|
26
|
+
* [`b5e011c`](https://github.com/eslint/eslint/commit/b5e011c865e95d700d29cb9a4ba71c671d99e423) Sponsors: Sync README with website (ESLint Jenkins)
|
27
|
+
|
28
|
+
v7.11.0 - October 9, 2020
|
29
|
+
|
30
|
+
* [`23e966f`](https://github.com/eslint/eslint/commit/23e966f6cf2a6c6b699dff5d6950ece3cc396498) Chore: Refactor CLIEngine tests (refs #13481) (#13709) (Nicholas C. Zakas)
|
31
|
+
* [`fa9429a`](https://github.com/eslint/eslint/commit/fa9429aac0ffed505f3f02e8fc75f646c69f5c61) Fix: don't count line after EOF in max-lines (#13735) (Milos Djermanovic)
|
32
|
+
* [`d973675`](https://github.com/eslint/eslint/commit/d973675a5c06a2bd4f8ce640c78b67842cfebfd4) Docs: Update anchor links to use existing linkrefs (refs #13715) (#13741) (Brandon Mills)
|
33
|
+
* [`2c6d774`](https://github.com/eslint/eslint/commit/2c6d774c89dcd14f386bd9d73d451fa2a892c3ef) Docs: Fix typos (#13730) (Frieder Bluemle)
|
34
|
+
* [`cc468c0`](https://github.com/eslint/eslint/commit/cc468c01021385a028de727eefcd442e7f34875c) Upgrade: eslint-visitor-keys@2.0.0 (#13732) (Milos Djermanovic)
|
35
|
+
* [`ab0ac6c`](https://github.com/eslint/eslint/commit/ab0ac6c532fb7b7d49779c8913146244d680743b) Docs: Fix anchor links (#13715) (Gary Moore)
|
36
|
+
* [`27f0de6`](https://github.com/eslint/eslint/commit/27f0de62e6281c28043be38ef051818c9edc15cd) Fix: account for linebreaks before postfix `++`/`--` in no-extra-parens (#13731) (Milos Djermanovic)
|
37
|
+
* [`da78fa1`](https://github.com/eslint/eslint/commit/da78fa11632a2908db4ac494012a16f5d5a88a64) Update: support async arrow fn in function-paren-newline (fixes #13728) (#13729) (Michal Dziekonski)
|
38
|
+
* [`fe301b8`](https://github.com/eslint/eslint/commit/fe301b8cc0762d7f4edd59603ca51ed0ec0c2a43) Docs: Add configuration comments in examples (#13738) (YeonJuan)
|
39
|
+
* [`504408c`](https://github.com/eslint/eslint/commit/504408cd65e9d8827b2b8bbeb8f589df90eee523) Sponsors: Sync README with website (ESLint Jenkins)
|
40
|
+
* [`3900659`](https://github.com/eslint/eslint/commit/390065985b2289ad4412a83598e3e833c382d27e) Sponsors: Sync README with website (ESLint Jenkins)
|
41
|
+
* [`c1974b3`](https://github.com/eslint/eslint/commit/c1974b3f7169a8e5fab7007df92d02d8c1a8d5a3) Sponsors: Sync README with website (ESLint Jenkins)
|
42
|
+
* [`6f4abe5`](https://github.com/eslint/eslint/commit/6f4abe5d5ade2711cc4c21bc8485af952763c2d3) Sponsors: Sync README with website (ESLint Jenkins)
|
43
|
+
|
44
|
+
v7.10.0 - September 26, 2020
|
45
|
+
|
46
|
+
* [`6919fbb`](https://github.com/eslint/eslint/commit/6919fbb83f86552b0f49ae749da866e4edc7c46a) Docs: Clarify that ignorePattern should be a string (refs #13029) (#13718) (Brandon Mills)
|
47
|
+
* [`07d9bea`](https://github.com/eslint/eslint/commit/07d9bea7c6f953e8f754afffc9752edcee799431) Update: Add ignorePattern to no-inline-comments (#13029) (Edie Lemoine)
|
48
|
+
* [`d79bbe9`](https://github.com/eslint/eslint/commit/d79bbe982930b53358d34ad91cc6e5eaac8ddede) Docs: fix typo (#13717) (Alexander Liu)
|
49
|
+
* [`9b8490e`](https://github.com/eslint/eslint/commit/9b8490ee6391c986b1314540a92b71d8c1e0efc4) Docs: grammatical error (#13687) (rajdeep)
|
50
|
+
* [`cb44e93`](https://github.com/eslint/eslint/commit/cb44e93f4780e925a75a68ce2f7f6d065b5f756c) Fix: prefer-destructuring invalid autofix with computed property access (#13704) (Milos Djermanovic)
|
51
|
+
* [`46c73b1`](https://github.com/eslint/eslint/commit/46c73b159a5ceed2f7f26f254fd97e459fb0e81a) Upgrade: eslint-scope@5.1.1 (#13716) (Milos Djermanovic)
|
52
|
+
* [`b7b12ba`](https://github.com/eslint/eslint/commit/b7b12ba0bd4e9c66883f11e97de8ed84b600cdaa) Chore: Move comment to make tests more organized (#13707) (Yusuke Tanaka)
|
53
|
+
* [`51674a4`](https://github.com/eslint/eslint/commit/51674a4113a1ca877094606bbf4938ab06cc1aad) Docs: Add missing quotes (#13714) (Lucio Paiva)
|
54
|
+
* [`7c34a98`](https://github.com/eslint/eslint/commit/7c34a982aaf93a02348f56c9ce887c7dcf51b5bd) Chore: remove mistakenly added file (#13710) (Milos Djermanovic)
|
55
|
+
* [`30b76c9`](https://github.com/eslint/eslint/commit/30b76c9a13fae3dff59f7db406d6c66f11152973) Docs: Clarify package.json requirement in Getting Started (refs #13549) (#13696) (Nicholas C. Zakas)
|
56
|
+
* [`044560d`](https://github.com/eslint/eslint/commit/044560dcc74db98b28e293da2e2f3b41ecbf5884) Sponsors: Sync README with website (ESLint Jenkins)
|
57
|
+
* [`54000d1`](https://github.com/eslint/eslint/commit/54000d13f27d5255851b5ac0606ad027e2b8d331) Sponsors: Sync README with website (ESLint Jenkins)
|
58
|
+
|
59
|
+
v7.9.0 - September 12, 2020
|
60
|
+
|
61
|
+
* [`3ca2700`](https://github.com/eslint/eslint/commit/3ca27004ece5016ba7aed775f01ad13bc9282296) Fix: Corrected notice for invalid (:) plugin names (#13473) (Josh Goldberg)
|
62
|
+
* [`fc5783d`](https://github.com/eslint/eslint/commit/fc5783d2ff9e3b0d7a1f9664928d49270b4a6c01) Docs: Fix leaky anchors in v4 migration page (#13635) (Timo Tijhof)
|
63
|
+
* [`f1d07f1`](https://github.com/eslint/eslint/commit/f1d07f112be96c64dfdaa154aa9ac81985b16238) Docs: Provide install commands for Yarn (#13661) (Nikita Baksalyar)
|
64
|
+
* [`29d1cdc`](https://github.com/eslint/eslint/commit/29d1cdceedd6c056a39149723cf9ff2fbb260cbf) Fix: prefer-destructuring removes comments (refs #13678) (#13682) (Milos Djermanovic)
|
65
|
+
* [`b4da0a7`](https://github.com/eslint/eslint/commit/b4da0a7ca7995435bdfc116fd374eb0649470131) Docs: fix typo in working with plugins docs (#13683) (啸生)
|
66
|
+
* [`6f87db7`](https://github.com/eslint/eslint/commit/6f87db7c318225e48ccbbf0bec8b3758ea839b82) Update: fix id-length false negatives on Object.prototype property names (#13670) (Milos Djermanovic)
|
67
|
+
* [`361ac4d`](https://github.com/eslint/eslint/commit/361ac4d895c15086fb4351d4dca1405b2fdc4bd5) Fix: NonOctalDecimalIntegerLiteral is decimal integer (fixes #13588) (#13664) (Milos Djermanovic)
|
68
|
+
* [`f260716`](https://github.com/eslint/eslint/commit/f260716695064e4b4193337107b60401bd4b3f20) Docs: update outdated link (#13677) (klkhan)
|
69
|
+
* [`5138c91`](https://github.com/eslint/eslint/commit/5138c913c256e4266ffb68278783af45bf70af84) Docs: add missing eslint directive comments in no-await-in-loop (#13673) (Milos Djermanovic)
|
70
|
+
* [`17b58b5`](https://github.com/eslint/eslint/commit/17b58b528df62bf96813d50c087cafdf83306810) Docs: clarify correct example in no-return-await (fixes #13656) (#13657) (Milos Djermanovic)
|
71
|
+
* [`9171f0a`](https://github.com/eslint/eslint/commit/9171f0a99bb4d7c53f109b1c2b215004a7c27713) Chore: fix typo (#13660) (Nitin Kumar)
|
72
|
+
* [`6d9f8fb`](https://github.com/eslint/eslint/commit/6d9f8fbb7ed4361b475fb50d04e6d25744d5b1a2) Sponsors: Sync README with website (ESLint Jenkins)
|
73
|
+
* [`97b0dd9`](https://github.com/eslint/eslint/commit/97b0dd9a1af1ae4ae3857adcfe6eeac7837101ed) Sponsors: Sync README with website (ESLint Jenkins)
|
74
|
+
* [`deab125`](https://github.com/eslint/eslint/commit/deab125fc9220dab43baeb32c6cf78942ad25a83) Sponsors: Sync README with website (ESLint Jenkins)
|
75
|
+
* [`bf2e367`](https://github.com/eslint/eslint/commit/bf2e367bf4f6fde9930af9de8b8d8bc3d8b5782f) Sponsors: Sync README with website (ESLint Jenkins)
|
76
|
+
* [`8929208`](https://github.com/eslint/eslint/commit/89292084bf91ba5ae5bf966c6c56fa3da139ce57) Sponsors: Sync README with website (ESLint Jenkins)
|
77
|
+
|
1
78
|
v7.8.1 - September 1, 2020
|
2
79
|
|
3
80
|
* [`f542b5d`](https://github.com/eslint/eslint/commit/f542b5d0679b73326ad249fc44a54c3f848bd3e6) Fix: Update broken @eslint/eslintrc version (fixes #13641) (#13647) (Nicholas C. Zakas)
|
package/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://www.npmjs.com/package/eslint)
|
2
2
|
[](https://www.npmjs.com/package/eslint)
|
3
3
|
[](https://github.com/eslint/eslint/actions)
|
4
4
|
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint?ref=badge_shield)
|
@@ -263,10 +263,11 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
263
263
|
|
264
264
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
265
265
|
<!--sponsorsstart-->
|
266
|
-
<h3>
|
267
|
-
<p><a href="https://
|
266
|
+
<h3>Platinum Sponsors</h3>
|
267
|
+
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/photomatt/ff91f0b/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
|
268
|
+
<p><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://aka.ms/microsoftfossfund"><img src="https://avatars1.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3>
|
268
269
|
<p><a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/amp/c8a3b25/logo.png" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
|
269
|
-
<p><a href="https://
|
270
|
+
<p><a href="https://writersperhour.com/write-my-essay"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.betacalendars.com/printable-calendar"><img src="https://images.opencollective.com/betacalendars/9334b33/logo.png" alt="2021 calendar" height="32"></a> <a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/2002c40/logo.png" alt="Buy.Fineproxy.Org" height="32"></a> <a href="https://www.veikkaajat.com"><img src="https://images.opencollective.com/veikkaajat/b92b427/logo.png" alt="Veikkaajat.com" 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.marfeel.com/"><img src="https://images.opencollective.com/marfeel/4b88e30/logo.png" alt="Marfeel" 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>
|
270
271
|
<!--sponsorsend-->
|
271
272
|
|
272
273
|
## <a name="technology-sponsors"></a>Technology Sponsors
|
@@ -19,14 +19,29 @@ const fs = require("fs");
|
|
19
19
|
const path = require("path");
|
20
20
|
const defaultOptions = require("../../conf/default-cli-options");
|
21
21
|
const pkg = require("../../package.json");
|
22
|
-
|
23
|
-
|
24
|
-
const
|
22
|
+
|
23
|
+
|
24
|
+
const {
|
25
|
+
Legacy: {
|
26
|
+
ConfigOps,
|
27
|
+
naming,
|
28
|
+
CascadingConfigArrayFactory,
|
29
|
+
IgnorePattern,
|
30
|
+
getUsedExtractedConfigs
|
31
|
+
}
|
32
|
+
} = require("@eslint/eslintrc");
|
33
|
+
|
34
|
+
/*
|
35
|
+
* For some reason, ModuleResolver must be included via filepath instead of by
|
36
|
+
* API exports in order to work properly. That's why this is separated out onto
|
37
|
+
* its own require() statement.
|
38
|
+
*/
|
39
|
+
const ModuleResolver = require("@eslint/eslintrc/lib/shared/relative-module-resolver");
|
40
|
+
const { FileEnumerator } = require("./file-enumerator");
|
41
|
+
|
25
42
|
const { Linter } = require("../linter");
|
26
43
|
const builtInRules = require("../rules");
|
27
|
-
const
|
28
|
-
const { IgnorePattern, getUsedExtractedConfigs } = require("./config-array");
|
29
|
-
const { FileEnumerator } = require("./file-enumerator");
|
44
|
+
const loadRules = require("./load-rules");
|
30
45
|
const hash = require("./hash");
|
31
46
|
const LintResultCache = require("./lint-result-cache");
|
32
47
|
|
@@ -559,7 +574,11 @@ class CLIEngine {
|
|
559
574
|
resolvePluginsRelativeTo: options.resolvePluginsRelativeTo,
|
560
575
|
rulePaths: options.rulePaths,
|
561
576
|
specificConfigPath: options.configFile,
|
562
|
-
useEslintrc: options.useEslintrc
|
577
|
+
useEslintrc: options.useEslintrc,
|
578
|
+
builtInRules,
|
579
|
+
loadRules,
|
580
|
+
eslintRecommendedPath: path.resolve(__dirname, "../../conf/eslint-recommended.js"),
|
581
|
+
eslintAllPath: path.resolve(__dirname, "../../conf/eslint-all.js")
|
563
582
|
});
|
564
583
|
const fileEnumerator = new FileEnumerator({
|
565
584
|
configArrayFactory,
|
@@ -40,8 +40,13 @@ const getGlobParent = require("glob-parent");
|
|
40
40
|
const isGlob = require("is-glob");
|
41
41
|
const { escapeRegExp } = require("lodash");
|
42
42
|
const { Minimatch } = require("minimatch");
|
43
|
-
|
44
|
-
const {
|
43
|
+
|
44
|
+
const {
|
45
|
+
Legacy: {
|
46
|
+
IgnorePattern,
|
47
|
+
CascadingConfigArrayFactory
|
48
|
+
}
|
49
|
+
} = require("@eslint/eslintrc");
|
45
50
|
const debug = require("debug")("eslint:file-enumerator");
|
46
51
|
|
47
52
|
//------------------------------------------------------------------------------
|
@@ -196,15 +196,19 @@ function mapSuggestions(descriptor, sourceCode, messages) {
|
|
196
196
|
return [];
|
197
197
|
}
|
198
198
|
|
199
|
-
return descriptor.suggest
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
199
|
+
return descriptor.suggest
|
200
|
+
.map(suggestInfo => {
|
201
|
+
const computedDesc = suggestInfo.desc || messages[suggestInfo.messageId];
|
202
|
+
|
203
|
+
return {
|
204
|
+
...suggestInfo,
|
205
|
+
desc: interpolate(computedDesc, suggestInfo.data),
|
206
|
+
fix: normalizeFixes(suggestInfo, sourceCode)
|
207
|
+
};
|
208
|
+
})
|
209
|
+
|
210
|
+
// Remove suggestions that didn't provide a fix
|
211
|
+
.filter(({ fix }) => fix);
|
208
212
|
}
|
209
213
|
|
210
214
|
/**
|
@@ -79,6 +79,17 @@ function isPossibleConstructor(node) {
|
|
79
79
|
return false;
|
80
80
|
|
81
81
|
case "LogicalExpression":
|
82
|
+
|
83
|
+
/*
|
84
|
+
* If the && operator short-circuits, the left side was falsy and therefore not a constructor, and if
|
85
|
+
* it doesn't short-circuit, it takes the value from the right side, so the right side must always be a
|
86
|
+
* possible constructor. A future improvement could verify that the left side could be truthy by
|
87
|
+
* excluding falsy literals.
|
88
|
+
*/
|
89
|
+
if (node.operator === "&&") {
|
90
|
+
return isPossibleConstructor(node.right);
|
91
|
+
}
|
92
|
+
|
82
93
|
return (
|
83
94
|
isPossibleConstructor(node.left) ||
|
84
95
|
isPossibleConstructor(node.right)
|
@@ -218,7 +218,7 @@ module.exports = {
|
|
218
218
|
}
|
219
219
|
|
220
220
|
case "ArrowFunctionExpression": {
|
221
|
-
const firstToken = sourceCode.getFirstToken(node);
|
221
|
+
const firstToken = sourceCode.getFirstToken(node, { skip: (node.async ? 1 : 0) });
|
222
222
|
|
223
223
|
if (!astUtils.isOpeningParenToken(firstToken)) {
|
224
224
|
|
package/lib/rules/id-length.js
CHANGED
@@ -64,12 +64,7 @@ module.exports = {
|
|
64
64
|
const minLength = typeof options.min !== "undefined" ? options.min : 2;
|
65
65
|
const maxLength = typeof options.max !== "undefined" ? options.max : Infinity;
|
66
66
|
const properties = options.properties !== "never";
|
67
|
-
const exceptions = (options.exceptions
|
68
|
-
.reduce((obj, item) => {
|
69
|
-
obj[item] = true;
|
70
|
-
|
71
|
-
return obj;
|
72
|
-
}, {});
|
67
|
+
const exceptions = new Set(options.exceptions);
|
73
68
|
const exceptionPatterns = (options.exceptionPatterns || []).map(pattern => new RegExp(pattern, "u"));
|
74
69
|
const reportedNode = new Set();
|
75
70
|
|
@@ -130,7 +125,7 @@ module.exports = {
|
|
130
125
|
const isShort = name.length < minLength;
|
131
126
|
const isLong = name.length > maxLength;
|
132
127
|
|
133
|
-
if (!(isShort || isLong) || exceptions
|
128
|
+
if (!(isShort || isLong) || exceptions.has(name) || matchesExceptionPattern(name)) {
|
134
129
|
return; // Nothing to report
|
135
130
|
}
|
136
131
|
|
package/lib/rules/max-lines.js
CHANGED
@@ -131,6 +131,14 @@ module.exports = {
|
|
131
131
|
text
|
132
132
|
}));
|
133
133
|
|
134
|
+
/*
|
135
|
+
* If file ends with a linebreak, `sourceCode.lines` will have one extra empty line at the end.
|
136
|
+
* That isn't a real line, so we shouldn't count it.
|
137
|
+
*/
|
138
|
+
if (lines.length > 1 && lodash.last(lines).text === "") {
|
139
|
+
lines.pop();
|
140
|
+
}
|
141
|
+
|
134
142
|
if (skipBlankLines) {
|
135
143
|
lines = lines.filter(l => l.text.trim() !== "");
|
136
144
|
}
|
@@ -9,9 +9,6 @@
|
|
9
9
|
// Helpers
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const EQUALITY_OPERATORS = ["===", "!==", "==", "!="];
|
13
|
-
const RELATIONAL_OPERATORS = [">", "<", ">=", "<=", "in", "instanceof"];
|
14
|
-
|
15
12
|
//------------------------------------------------------------------------------
|
16
13
|
// Rule Definition
|
17
14
|
//------------------------------------------------------------------------------
|
@@ -56,6 +53,35 @@ module.exports = {
|
|
56
53
|
// Helpers
|
57
54
|
//--------------------------------------------------------------------------
|
58
55
|
|
56
|
+
/**
|
57
|
+
* Returns literal's value converted to the Boolean type
|
58
|
+
* @param {ASTNode} node any `Literal` node
|
59
|
+
* @returns {boolean | null} `true` when node is truthy, `false` when node is falsy,
|
60
|
+
* `null` when it cannot be determined.
|
61
|
+
*/
|
62
|
+
function getBooleanValue(node) {
|
63
|
+
if (node.value === null) {
|
64
|
+
|
65
|
+
/*
|
66
|
+
* it might be a null literal or bigint/regex literal in unsupported environments .
|
67
|
+
* https://github.com/estree/estree/blob/14df8a024956ea289bd55b9c2226a1d5b8a473ee/es5.md#regexpliteral
|
68
|
+
* https://github.com/estree/estree/blob/14df8a024956ea289bd55b9c2226a1d5b8a473ee/es2020.md#bigintliteral
|
69
|
+
*/
|
70
|
+
|
71
|
+
if (node.raw === "null") {
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
|
75
|
+
// regex is always truthy
|
76
|
+
if (typeof node.regex === "object") {
|
77
|
+
return true;
|
78
|
+
}
|
79
|
+
|
80
|
+
return null;
|
81
|
+
}
|
82
|
+
|
83
|
+
return !!node.value;
|
84
|
+
}
|
59
85
|
|
60
86
|
/**
|
61
87
|
* Checks if a branch node of LogicalExpression short circuits the whole condition
|
@@ -66,15 +92,23 @@ module.exports = {
|
|
66
92
|
function isLogicalIdentity(node, operator) {
|
67
93
|
switch (node.type) {
|
68
94
|
case "Literal":
|
69
|
-
return (operator === "||" && node
|
70
|
-
(operator === "&&" && node
|
95
|
+
return (operator === "||" && getBooleanValue(node) === true) ||
|
96
|
+
(operator === "&&" && getBooleanValue(node) === false);
|
71
97
|
|
72
98
|
case "UnaryExpression":
|
73
99
|
return (operator === "&&" && node.operator === "void");
|
74
100
|
|
75
101
|
case "LogicalExpression":
|
76
|
-
|
77
|
-
|
102
|
+
|
103
|
+
/*
|
104
|
+
* handles `a && false || b`
|
105
|
+
* `false` is an identity element of `&&` but not `||`
|
106
|
+
*/
|
107
|
+
return operator === node.operator &&
|
108
|
+
(
|
109
|
+
isLogicalIdentity(node.left, node.operator) ||
|
110
|
+
isLogicalIdentity(node.right, node.operator)
|
111
|
+
);
|
78
112
|
|
79
113
|
// no default
|
80
114
|
}
|
@@ -129,21 +163,9 @@ module.exports = {
|
|
129
163
|
const isLeftConstant = isConstant(node.left, inBooleanPosition);
|
130
164
|
const isRightConstant = isConstant(node.right, inBooleanPosition);
|
131
165
|
const isLeftShortCircuit = (isLeftConstant && isLogicalIdentity(node.left, node.operator));
|
132
|
-
const isRightShortCircuit = (isRightConstant && isLogicalIdentity(node.right, node.operator));
|
166
|
+
const isRightShortCircuit = (inBooleanPosition && isRightConstant && isLogicalIdentity(node.right, node.operator));
|
133
167
|
|
134
168
|
return (isLeftConstant && isRightConstant) ||
|
135
|
-
(
|
136
|
-
|
137
|
-
// in the case of an "OR", we need to know if the right constant value is truthy
|
138
|
-
node.operator === "||" &&
|
139
|
-
isRightConstant &&
|
140
|
-
node.right.value &&
|
141
|
-
(
|
142
|
-
!node.parent ||
|
143
|
-
node.parent.type !== "BinaryExpression" ||
|
144
|
-
!(EQUALITY_OPERATORS.includes(node.parent.operator) || RELATIONAL_OPERATORS.includes(node.parent.operator))
|
145
|
-
)
|
146
|
-
) ||
|
147
169
|
isLeftShortCircuit ||
|
148
170
|
isRightShortCircuit;
|
149
171
|
}
|
@@ -1109,7 +1109,22 @@ module.exports = {
|
|
1109
1109
|
},
|
1110
1110
|
|
1111
1111
|
UnaryExpression: checkArgumentWithPrecedence,
|
1112
|
-
UpdateExpression
|
1112
|
+
UpdateExpression(node) {
|
1113
|
+
if (node.prefix) {
|
1114
|
+
checkArgumentWithPrecedence(node);
|
1115
|
+
} else {
|
1116
|
+
const { argument } = node;
|
1117
|
+
const operatorToken = sourceCode.getLastToken(node);
|
1118
|
+
|
1119
|
+
if (argument.loc.end.line === operatorToken.loc.start.line) {
|
1120
|
+
checkArgumentWithPrecedence(node);
|
1121
|
+
} else {
|
1122
|
+
if (hasDoubleExcessParens(argument)) {
|
1123
|
+
report(argument);
|
1124
|
+
}
|
1125
|
+
}
|
1126
|
+
}
|
1127
|
+
},
|
1113
1128
|
AwaitExpression: checkArgumentWithPrecedence,
|
1114
1129
|
|
1115
1130
|
VariableDeclarator(node) {
|
@@ -21,7 +21,17 @@ module.exports = {
|
|
21
21
|
url: "https://eslint.org/docs/rules/no-inline-comments"
|
22
22
|
},
|
23
23
|
|
24
|
-
schema: [
|
24
|
+
schema: [
|
25
|
+
{
|
26
|
+
type: "object",
|
27
|
+
properties: {
|
28
|
+
ignorePattern: {
|
29
|
+
type: "string"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
additionalProperties: false
|
33
|
+
}
|
34
|
+
],
|
25
35
|
|
26
36
|
messages: {
|
27
37
|
unexpectedInlineComment: "Unexpected comment inline with code."
|
@@ -30,6 +40,12 @@ module.exports = {
|
|
30
40
|
|
31
41
|
create(context) {
|
32
42
|
const sourceCode = context.getSourceCode();
|
43
|
+
const options = context.options[0];
|
44
|
+
let customIgnoreRegExp;
|
45
|
+
|
46
|
+
if (options && options.ignorePattern) {
|
47
|
+
customIgnoreRegExp = new RegExp(options.ignorePattern, "u");
|
48
|
+
}
|
33
49
|
|
34
50
|
/**
|
35
51
|
* Will check that comments are not on lines starting with or ending with code
|
@@ -51,6 +67,11 @@ module.exports = {
|
|
51
67
|
return;
|
52
68
|
}
|
53
69
|
|
70
|
+
// Matches the ignore pattern
|
71
|
+
if (customIgnoreRegExp && customIgnoreRegExp.test(node.value)) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
|
54
75
|
// JSX Exception
|
55
76
|
if (
|
56
77
|
(isPreambleEmpty || preamble === "{") &&
|
@@ -80,9 +101,9 @@ module.exports = {
|
|
80
101
|
|
81
102
|
return {
|
82
103
|
Program() {
|
83
|
-
|
84
|
-
|
85
|
-
|
104
|
+
sourceCode.getAllComments()
|
105
|
+
.filter(token => token.type !== "Shebang")
|
106
|
+
.forEach(testCodeAroundComment);
|
86
107
|
}
|
87
108
|
};
|
88
109
|
}
|
@@ -46,15 +46,15 @@ module.exports = {
|
|
46
46
|
*/
|
47
47
|
function disallowBuiltIns(node) {
|
48
48
|
|
49
|
-
// TODO: just use `astUtils.getStaticPropertyName(node.callee)`
|
50
49
|
const callee = astUtils.skipChainExpression(node.callee);
|
51
50
|
|
52
|
-
if (callee.type !== "MemberExpression"
|
51
|
+
if (callee.type !== "MemberExpression") {
|
53
52
|
return;
|
54
53
|
}
|
55
|
-
const propName = callee.property.name;
|
56
54
|
|
57
|
-
|
55
|
+
const propName = astUtils.getStaticPropertyName(callee);
|
56
|
+
|
57
|
+
if (propName !== null && DISALLOWED_PROPS.indexOf(propName) > -1) {
|
58
58
|
context.report({
|
59
59
|
messageId: "prototypeBuildIn",
|
60
60
|
loc: callee.property.loc,
|
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
"use strict";
|
9
9
|
|
10
|
+
const astUtils = require("./utils/ast-utils");
|
11
|
+
|
10
12
|
//------------------------------------------------------------------------------
|
11
13
|
// Rule Definition
|
12
14
|
//------------------------------------------------------------------------------
|
@@ -31,18 +33,30 @@ module.exports = {
|
|
31
33
|
|
32
34
|
create(context) {
|
33
35
|
|
36
|
+
/**
|
37
|
+
* Check whether a node's static value starts with "javascript:" or not.
|
38
|
+
* And report an error for unexpected script URL.
|
39
|
+
* @param {ASTNode} node node to check
|
40
|
+
* @returns {void}
|
41
|
+
*/
|
42
|
+
function check(node) {
|
43
|
+
const value = astUtils.getStaticStringValue(node);
|
44
|
+
|
45
|
+
if (typeof value === "string" && value.toLowerCase().indexOf("javascript:") === 0) {
|
46
|
+
context.report({ node, messageId: "unexpectedScriptURL" });
|
47
|
+
}
|
48
|
+
}
|
34
49
|
return {
|
35
|
-
|
36
50
|
Literal(node) {
|
37
51
|
if (node.value && typeof node.value === "string") {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
52
|
+
check(node);
|
53
|
+
}
|
54
|
+
},
|
55
|
+
TemplateLiteral(node) {
|
56
|
+
if (!(node.parent && node.parent.type === "TaggedTemplateExpression")) {
|
57
|
+
check(node);
|
43
58
|
}
|
44
59
|
}
|
45
60
|
};
|
46
|
-
|
47
61
|
}
|
48
62
|
};
|
@@ -4,6 +4,18 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
//------------------------------------------------------------------------------
|
8
|
+
// Requirements
|
9
|
+
//------------------------------------------------------------------------------
|
10
|
+
|
11
|
+
const astUtils = require("./utils/ast-utils");
|
12
|
+
|
13
|
+
//------------------------------------------------------------------------------
|
14
|
+
// Helpers
|
15
|
+
//------------------------------------------------------------------------------
|
16
|
+
|
17
|
+
const PRECEDENCE_OF_ASSIGNMENT_EXPR = astUtils.getPrecedence({ type: "AssignmentExpression" });
|
18
|
+
|
7
19
|
//------------------------------------------------------------------------------
|
8
20
|
// Rule Definition
|
9
21
|
//------------------------------------------------------------------------------
|
@@ -163,6 +175,8 @@ module.exports = {
|
|
163
175
|
return node.type === "VariableDeclarator" &&
|
164
176
|
node.id.type === "Identifier" &&
|
165
177
|
node.init.type === "MemberExpression" &&
|
178
|
+
!node.init.computed &&
|
179
|
+
node.init.property.type === "Identifier" &&
|
166
180
|
node.id.name === node.init.property.name;
|
167
181
|
}
|
168
182
|
|
@@ -178,9 +192,20 @@ module.exports = {
|
|
178
192
|
const rightNode = node.init;
|
179
193
|
const sourceCode = context.getSourceCode();
|
180
194
|
|
195
|
+
// Don't fix if that would remove any comments. Only comments inside `rightNode.object` can be preserved.
|
196
|
+
if (sourceCode.getCommentsInside(node).length > sourceCode.getCommentsInside(rightNode.object).length) {
|
197
|
+
return null;
|
198
|
+
}
|
199
|
+
|
200
|
+
let objectText = sourceCode.getText(rightNode.object);
|
201
|
+
|
202
|
+
if (astUtils.getPrecedence(rightNode.object) < PRECEDENCE_OF_ASSIGNMENT_EXPR) {
|
203
|
+
objectText = `(${objectText})`;
|
204
|
+
}
|
205
|
+
|
181
206
|
return fixer.replaceText(
|
182
207
|
node,
|
183
|
-
`{${rightNode.property.name}} = ${
|
208
|
+
`{${rightNode.property.name}} = ${objectText}`
|
184
209
|
);
|
185
210
|
}
|
186
211
|
|