eslint 6.0.1 → 6.2.2
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 +8 -5
- package/bin/eslint.js +3 -0
- package/conf/config-schema.js +1 -0
- package/conf/environments.js +72 -15
- package/lib/cli-engine/cli-engine.js +5 -2
- package/lib/cli-engine/config-array/config-array.js +7 -0
- package/lib/cli-engine/config-array/extracted-config.js +16 -1
- package/lib/cli-engine/config-array-factory.js +3 -1
- package/lib/cli-engine/file-enumerator.js +5 -13
- package/lib/init/config-initializer.js +19 -9
- package/lib/init/npm-utils.js +2 -2
- package/lib/linter/code-path-analysis/code-path-analyzer.js +1 -0
- package/lib/linter/linter.js +49 -16
- package/lib/rule-tester/rule-tester.js +1 -1
- package/lib/rules/accessor-pairs.js +195 -35
- package/lib/rules/arrow-body-style.js +2 -2
- package/lib/rules/class-methods-use-this.js +10 -3
- package/lib/rules/dot-location.js +21 -17
- package/lib/rules/dot-notation.js +6 -2
- package/lib/rules/func-call-spacing.js +30 -20
- package/lib/rules/func-names.js +4 -0
- package/lib/rules/function-call-argument-newline.js +120 -0
- package/lib/rules/function-paren-newline.js +34 -22
- package/lib/rules/indent.js +13 -2
- package/lib/rules/index.js +1 -0
- package/lib/rules/new-cap.js +2 -1
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-duplicate-case.js +10 -8
- package/lib/rules/no-extra-bind.js +1 -0
- package/lib/rules/no-extra-boolean-cast.js +44 -5
- package/lib/rules/no-extra-parens.js +295 -39
- package/lib/rules/no-mixed-operators.js +48 -13
- package/lib/rules/no-param-reassign.js +12 -1
- package/lib/rules/no-restricted-syntax.js +2 -2
- package/lib/rules/no-unused-vars.js +1 -1
- package/lib/rules/prefer-const.js +9 -3
- package/lib/rules/prefer-template.js +1 -10
- package/lib/rules/sort-keys.js +11 -3
- package/lib/rules/utils/ast-utils.js +45 -3
- package/lib/rules/yoda.js +1 -1
- package/lib/{cli-engine → shared}/naming.js +0 -0
- package/lib/shared/types.js +2 -0
- package/package.json +22 -21
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,80 @@
|
|
1
|
+
v6.2.2 - August 23, 2019
|
2
|
+
|
3
|
+
* [`0e0b784`](https://github.com/eslint/eslint/commit/0e0b784b922051c2a1d39dd8160382114b645800) Upgrade: espree@^6.1.1 (#12158) (Kevin Partington)
|
4
|
+
* [`04e859f`](https://github.com/eslint/eslint/commit/04e859f228d081efd3af6edb22563dbc775f8d1d) Sponsors: Sync README with website (ESLint Jenkins)
|
5
|
+
* [`34783d1`](https://github.com/eslint/eslint/commit/34783d10ff9b58a3c1e39a36e10864caeb9f66e0) Sponsors: Sync README with website (ESLint Jenkins)
|
6
|
+
* [`b809e72`](https://github.com/eslint/eslint/commit/b809e72221bc658e5a42bfd4b8723d3771571f9e) Docs: Update README team and sponsors (ESLint Jenkins)
|
7
|
+
|
8
|
+
v6.2.1 - August 20, 2019
|
9
|
+
|
10
|
+
* [`8c021b5`](https://github.com/eslint/eslint/commit/8c021b5917b3aa3c578ffe3972106d0a6bcf0838) Upgrade: eslint-utils 1.4.2 (#12131) (Toru Nagashima)
|
11
|
+
* [`e82388b`](https://github.com/eslint/eslint/commit/e82388bd87717430200ec554634cc08806e38d3c) Sponsors: Sync README with website (ESLint Jenkins)
|
12
|
+
* [`4aeeeed`](https://github.com/eslint/eslint/commit/4aeeeedb656ee3519ea82ebf0cb41ca801215046) Docs: update docs for ecmaVersion 2020 (#12120) (silverwind)
|
13
|
+
* [`6886148`](https://github.com/eslint/eslint/commit/6886148d1f528659ec3e125f61ef7a5f4c67556d) Docs: Add duplicate keys limitation to accessor-pairs (#12124) (Milos Djermanovic)
|
14
|
+
|
15
|
+
v6.2.0 - August 18, 2019
|
16
|
+
|
17
|
+
* [`fee6acb`](https://github.com/eslint/eslint/commit/fee6acbe13cecd4c028e681e185fc6a6d6ba9452) Update: support bigint and dynamic import (refs #11803) (#11983) (Toru Nagashima)
|
18
|
+
* [`afd8012`](https://github.com/eslint/eslint/commit/afd8012c2797f2f5bf3c360cb241ea2ba6e1a489) New: noInlineConfig setting (refs eslint/rfcs#22) (#12091) (Toru Nagashima)
|
19
|
+
* [`3d12378`](https://github.com/eslint/eslint/commit/3d12378221961439c27ddae0ecda9845ac575107) Update: Fix accessor-pairs to enforce pairs per property in literals (#12062) (Milos Djermanovic)
|
20
|
+
* [`8cd00b3`](https://github.com/eslint/eslint/commit/8cd00b308987e0db0bdb2e242bf13b2b07b350bd) New: function-call-argument-newline (#12024) (finico)
|
21
|
+
* [`30ebf92`](https://github.com/eslint/eslint/commit/30ebf929f60684520b1201c1adfd86214c19d614) Fix: prefer-template autofix produces syntax error with octal escapes (#12085) (Milos Djermanovic)
|
22
|
+
* [`13c3988`](https://github.com/eslint/eslint/commit/13c3988a4001ae368ea7b6c8d3dd0abfa7c6cf64) Fix: Check literal type explicitly in dot-notation (#12095) (Milos Djermanovic)
|
23
|
+
* [`3e5ceca`](https://github.com/eslint/eslint/commit/3e5ceca4d2284b55a2292a1d3de9aa4cdf6fa213) Fix: Handle empty string property names in getFunctionNameWithKind (#12104) (Milos Djermanovic)
|
24
|
+
* [`9a043ff`](https://github.com/eslint/eslint/commit/9a043ffbb864fc65baeb16fe5668435e3b7cfe34) Fix: no-duplicate-case false positives on Object.prototype keys (#12107) (Milos Djermanovic)
|
25
|
+
* [`fe631af`](https://github.com/eslint/eslint/commit/fe631afee59641876598d19b1935967099cc6fa0) Chore: minor typo fix (#12112) (James George)
|
26
|
+
* [`4cb7877`](https://github.com/eslint/eslint/commit/4cb78774f6cc687a3c8701462f8c7f7b587ecaf0) Fix: fix no-extra-parens ignores some nodes (#11909) (Pig Fang)
|
27
|
+
* [`2dc23b8`](https://github.com/eslint/eslint/commit/2dc23b81e54defbce7a70a7f26c2e4c7b692cf58) Update: fix no-dupe-keys false negatives on empty string names (#12069) (Milos Djermanovic)
|
28
|
+
* [`19ab666`](https://github.com/eslint/eslint/commit/19ab6666e8e4142a183bdee2be96e5bafbac0e21) Fix: yoda exceptRange false positives on empty string property names (#12071) (Milos Djermanovic)
|
29
|
+
* [`d642150`](https://github.com/eslint/eslint/commit/d642150fe016608e71a1df2a72960e915b3cfbad) Update: Check empty string property names in sort-keys (#12073) (Milos Djermanovic)
|
30
|
+
* [`acce6de`](https://github.com/eslint/eslint/commit/acce6de940e2b089ff5ba59e4518a54af1682d5e) Fix: class-methods-use-this reports 'undefined' names (#12103) (Milos Djermanovic)
|
31
|
+
* [`92ec2cb`](https://github.com/eslint/eslint/commit/92ec2cb1731b7b6e0ac66336d583fbb782504290) Fix: Allow bind call with a single spread element in no-extra-bind (#12088) (Milos Djermanovic)
|
32
|
+
* [`bfdb0c9`](https://github.com/eslint/eslint/commit/bfdb0c97003fc0e045aa6ed10b177c35305a6e46) Fix: no-extra-boolean-cast invalid autofix for Boolean() without args (#12076) (Milos Djermanovic)
|
33
|
+
* [`34ccc0c`](https://github.com/eslint/eslint/commit/34ccc0cd81f495190e585c6efa8ae233d45bd3ed) Chore: Remove TDZ scope type condition from no-unused-vars (#12055) (Milos Djermanovic)
|
34
|
+
* [`01d38ce`](https://github.com/eslint/eslint/commit/01d38ce2faf0abbc9dd5d25694baeee131036165) Docs: Remove TDZ scope from the scope manager interface documentation (#12054) (Milos Djermanovic)
|
35
|
+
* [`1aff8fc`](https://github.com/eslint/eslint/commit/1aff8fc4f9394cd9126654a55f7f3a43ab1cf8f0) Update: warn about mixing ternary and logical operators (fixes #11704) (#12001) (Karthik Priyadarshan)
|
36
|
+
* [`11be2f8`](https://github.com/eslint/eslint/commit/11be2f8513bd61499f6247392a33ac0a26901c90) Docs: do not recommend global-installed usage (#12016) (薛定谔的猫)
|
37
|
+
* [`cf31dab`](https://github.com/eslint/eslint/commit/cf31dab5d5982151e0cfcc32879e69a83180ec70) Fix: no-restricted-syntax - correct the schema (#12051) (Brad Zacher)
|
38
|
+
* [`fbec99e`](https://github.com/eslint/eslint/commit/fbec99ea3e39316791685652c66e522d698f52d8) Update: fix class-methods-use-this false negatives with exceptMethods (#12077) (Milos Djermanovic)
|
39
|
+
* [`fb08b7c`](https://github.com/eslint/eslint/commit/fb08b7c9d28bc68864eb940e26df274059228b6a) Docs: Remove readonly/writable global logic from no-undef (fixes #11963) (#12053) (Milos Djermanovic)
|
40
|
+
* [`5b5934b`](https://github.com/eslint/eslint/commit/5b5934b9513f9114f5bf8e12ff4f4981590d64d3) Sponsors: Sync README with website (ESLint Jenkins)
|
41
|
+
* [`9156760`](https://github.com/eslint/eslint/commit/915676022a100ae5dba788fa3329d34b3c1f18d3) Sponsors: Sync README with website (ESLint Jenkins)
|
42
|
+
* [`f5e0cc4`](https://github.com/eslint/eslint/commit/f5e0cc40795f175692acb05daaadb91e9e5ae5d3) Update: Check computed method keys in no-extra-parens (#11973) (Milos Djermanovic)
|
43
|
+
* [`d961438`](https://github.com/eslint/eslint/commit/d9614388df8cfb977842ed7ac4725d76a3e05df3) Docs: Fix Incorrect Documentation (#12045) (Michael Miceli)
|
44
|
+
* [`887d08c`](https://github.com/eslint/eslint/commit/887d08c244e32f1fc18359e63380e2cdb0cb3797) Sponsors: Sync README with website (ESLint Jenkins)
|
45
|
+
* [`d90183f`](https://github.com/eslint/eslint/commit/d90183ff6757cff854f4ca4d25b835143dfb4b21) Docs: add a case to func-names (#12038) (Chiawen Chen)
|
46
|
+
* [`8a5b62d`](https://github.com/eslint/eslint/commit/8a5b62de2ae574f416c0f8ad91205da9b1837275) Docs: no use eslint.linter in code example (#12037) (薛定谔的猫)
|
47
|
+
* [`5831767`](https://github.com/eslint/eslint/commit/58317673210e48be3975e317c2c566fae155c94f) Update: report location of func-names (fixes #12022) (#12028) (Pig Fang)
|
48
|
+
|
49
|
+
v6.1.0 - July 20, 2019
|
50
|
+
|
51
|
+
* [`8f86cca`](https://github.com/eslint/eslint/commit/8f86ccaa89daf10123370868c5dcb48c1fcbef7d) Upgrade: eslint-scope@^5.0.0 (#12011) (Kevin Partington)
|
52
|
+
* [`d08683e`](https://github.com/eslint/eslint/commit/d08683e3c807f92daf266894093c70f8d5ac6afa) Fix: glob processing (fixes #11940) (#11986) (Toru Nagashima)
|
53
|
+
* [`bfcf8b2`](https://github.com/eslint/eslint/commit/bfcf8b21011466b570b536ca31ec10fd228b3dca) Fix: dot-location errors with parenthesized objects (fixes #11868) (#11933) (Milos Djermanovic)
|
54
|
+
* [`79e8d09`](https://github.com/eslint/eslint/commit/79e8d099bbbebfa4d804484eeeeea9c074ede870) Fix: add parens for sequence expr in arrow-body-style (fixes #11917) (#11918) (Pig Fang)
|
55
|
+
* [`105c098`](https://github.com/eslint/eslint/commit/105c098f3cece8b83ab8d1566b8ea41dd94a60b9) Docs: update docs for object-curly-spacing (fixes #11634) (#12009) (Chiawen Chen)
|
56
|
+
* [`c90a12c`](https://github.com/eslint/eslint/commit/c90a12c283698befcafd2c86f8bd8942428fe80b) Chore: update release script for new website repo (#12006) (Kai Cataldo)
|
57
|
+
* [`e2c08a9`](https://github.com/eslint/eslint/commit/e2c08a9c8d86238955ecc8fd5a626584ee91eba5) Sponsors: Sync README with website (ESLint Jenkins)
|
58
|
+
* [`b974fcb`](https://github.com/eslint/eslint/commit/b974fcbd3321ab382a914520018d4c051b2e5c62) Update: Check computed property keys in no-extra-parens (#11952) (Milos Djermanovic)
|
59
|
+
* [`222d27c`](https://github.com/eslint/eslint/commit/222d27c32a6d6d8828233b3b99e93ecefa94c603) Update: Add for-in and for-of checks for props in no-param-reassign (#11941) (Milos Djermanovic)
|
60
|
+
* [`e4c450f`](https://github.com/eslint/eslint/commit/e4c450febc9bd77b33f6473667afa9f955be6b71) Fix: no-extra-parens autofix with `in` in a for-loop init (fixes #11706) (#11848) (Milos Djermanovic)
|
61
|
+
* [`2dafe2d`](https://github.com/eslint/eslint/commit/2dafe2d288d1e0d353bb938d12a5da888091cfdb) Fix: prefer-const produces invalid autofix (fixes #11699) (#11827) (Milos Djermanovic)
|
62
|
+
* [`cb475fd`](https://github.com/eslint/eslint/commit/cb475fd8c0bbfcb00340459966b6780f39ea87a7) Fix: Cache file error handling on read-only file system. (fixes #11945) (#11946) (Cuki)
|
63
|
+
* [`89412c3`](https://github.com/eslint/eslint/commit/89412c3cbc52e556dba590fa94e10bf40faf1fdf) Docs: Fixed a typo (fixes #11999) (#12000) (Eddie Olson)
|
64
|
+
* [`6669f78`](https://github.com/eslint/eslint/commit/6669f78a3dd305aef6191e7eea24fae2ae4fd2e8) Fix: --init with Vue.js failed (fixes #11970) (#11985) (Toru Nagashima)
|
65
|
+
* [`93633c2`](https://github.com/eslint/eslint/commit/93633c2b3716b17816bcb3dc221c49b75db41317) Upgrade: Upgrade lodash dependency (fixes #11992) (#11994) (Cyd La Luz)
|
66
|
+
* [`776dae7`](https://github.com/eslint/eslint/commit/776dae71f2f5c7b5f0650ea3c277eca26e324e41) Docs: fix wrong Node.js version in getting started (#11993) (Toru Nagashima)
|
67
|
+
* [`4448261`](https://github.com/eslint/eslint/commit/4448261f5d217d8a06eb0ef898401928b54a34e3) Docs: some typos and optimization points (#11960) (Jason Lee)
|
68
|
+
* [`2a10856`](https://github.com/eslint/eslint/commit/2a10856d1ed5880a09a5ba452bd80d49c1be4e6c) Chore: Add temporary test files to .gitignore (#11978) (Milos Djermanovic)
|
69
|
+
* [`d83b233`](https://github.com/eslint/eslint/commit/d83b23382de3b80056a7e6330ed5846316c94147) Chore: update path for release bundles (#11977) (Kai Cataldo)
|
70
|
+
* [`1fb3620`](https://github.com/eslint/eslint/commit/1fb362093a65b99456a11029967d9ee0c31fd697) Fix: creating of enabledGlobals object without prototype (fixes #11929) (#11935) (finico)
|
71
|
+
* [`c2f2db9`](https://github.com/eslint/eslint/commit/c2f2db97c6d6a415b78ee7b3e8924853d465e757) Docs: Replace global true and false with writable and readonly in rules (#11956) (Milos Djermanovic)
|
72
|
+
* [`19335b8`](https://github.com/eslint/eslint/commit/19335b8f47029b2f742d5507ba39484eaf68d07b) Fix: actual messageId and expected messageId are switched in rule tester (#11928) (Milos Djermanovic)
|
73
|
+
* [`8b216e0`](https://github.com/eslint/eslint/commit/8b216e04fb0dd0a1a4d3730ebe4b24780020b09c) Docs: Fix incorrect example comments for unicode-bom rule (fixes #11937) (#11938) (Brandon Yeager)
|
74
|
+
* [`cc3885b`](https://github.com/eslint/eslint/commit/cc3885b028e29ebc575c900f43af81cb0dabffb6) Chore: add v8-compile-cache to speed up instantiation time (#11921) (薛定谔的猫)
|
75
|
+
* [`d8f2688`](https://github.com/eslint/eslint/commit/d8f26886f19a17f2e1cdcb91e2db84fc7ba3fdfb) Upgrade: deps (#11904) (薛定谔的猫)
|
76
|
+
* [`e5f1ccc`](https://github.com/eslint/eslint/commit/e5f1ccc9e2d07ad0acf149027ffc382021d54da1) Docs: add 'stricter rule config validating' in migrating docs (#11905) (薛定谔的猫)
|
77
|
+
|
1
78
|
v6.0.1 - June 24, 2019
|
2
79
|
|
3
80
|
* [`b5bde06`](https://github.com/eslint/eslint/commit/b5bde0669bd6a7a6b8e38cdf204d8d4b932cea63) Fix: --rulesdir option didn't work (fixes #11888) (#11890) (Toru Nagashima)
|
package/README.md
CHANGED
@@ -59,8 +59,6 @@ After that, you can run ESLint on any file or directory like this:
|
|
59
59
|
$ ./node_modules/.bin/eslint yourfile.js
|
60
60
|
```
|
61
61
|
|
62
|
-
It is also possible to install ESLint globally rather than locally (using `npm install eslint --global`). However, any plugins or shareable configs that you use must be installed locally in either case.
|
63
|
-
|
64
62
|
## <a name="configuration"></a>Configuration
|
65
63
|
|
66
64
|
After running `eslint --init`, you'll have a `.eslintrc` file in your directory. In it, you'll see some rules configured like this:
|
@@ -246,6 +244,11 @@ The people who review and fix bugs and help triage issues.
|
|
246
244
|
<img src="https://github.com/g-plane.png?s=75" width="75" height="75"><br />
|
247
245
|
Pig Fang
|
248
246
|
</a>
|
247
|
+
</td><td align="center" valign="top" width="11%">
|
248
|
+
<a href="https://github.com/mdjermanovic">
|
249
|
+
<img src="https://github.com/mdjermanovic.png?s=75" width="75" height="75"><br />
|
250
|
+
Milos Djermanovic
|
251
|
+
</a>
|
249
252
|
</td></tr></tbody></table>
|
250
253
|
|
251
254
|
|
@@ -258,9 +261,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
258
261
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
259
262
|
<!--sponsorsstart-->
|
260
263
|
<h3>Gold Sponsors</h3>
|
261
|
-
<p><a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/logo.png" alt="Shopify" height="96"></a> <a href="http://salesforce.com"><img src="https://images.opencollective.com/salesforce/logo.png" alt="Salesforce" height="96"></a> <a href="https://badoo.com/team?utm_source=eslint"><img src="https://images.opencollective.com/badoo/logo.png" alt="Badoo" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/logo.png" alt="Airbnb" height="96"></a> <a href="https://code.facebook.com/projects/"><img src="https://images.opencollective.com/fbopensource/logo.png" alt="Facebook Open Source" height="96"></a></p><h3>Silver Sponsors</h3>
|
262
|
-
<p><a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/amp/logo.png" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
|
263
|
-
<p><a href="https://
|
264
|
+
<p><a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/eeb91aa/logo.png" alt="Shopify" height="96"></a> <a href="http://engineering.salesforce.com"><img src="https://images.opencollective.com/salesforce/d1b37c4/logo.png" alt="Salesforce" height="96"></a> <a href="https://badoo.com/team?utm_source=eslint"><img src="https://images.opencollective.com/badoo/2826a3b/logo.png" alt="Badoo" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/001a341/logo.png" alt="Airbnb" height="96"></a> <a href="https://code.facebook.com/projects/"><img src="https://images.opencollective.com/fbopensource/fbb8a5b/logo.png" alt="Facebook Open Source" height="96"></a></p><h3>Silver Sponsors</h3>
|
265
|
+
<p><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>
|
266
|
+
<p><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/0b37d14/logo.png" alt="Free Icons by Icons8" height="32"></a> <a href="https://uxplanet.org/top-ui-ux-design-agencies-user-experience-firms-8c54697e290"><img src="https://images.opencollective.com/ui-ux-design-agencies/cae5dfe/logo.png" alt="UI UX Design Agencies" height="32"></a> <a href="https://clay.global"><img src="https://images.opencollective.com/clayglobal/2468f34/logo.png" alt="clay" 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/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://tekhattan.com"><img src="https://images.opencollective.com/tekhattan/bc73c28/logo.png" alt="TekHattan" 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="http://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://jsheroes.io/"><img src="https://images.opencollective.com/jsheroes1/9fedf0b/logo.png" alt="JSHeroes " height="32"></a></p>
|
264
267
|
<!--sponsorsend-->
|
265
268
|
|
266
269
|
## <a name="technology-sponsors"></a>Technology Sponsors
|
package/bin/eslint.js
CHANGED
@@ -9,6 +9,9 @@
|
|
9
9
|
|
10
10
|
"use strict";
|
11
11
|
|
12
|
+
// to use V8's code cache to speed up instantiation time
|
13
|
+
require("v8-compile-cache");
|
14
|
+
|
12
15
|
//------------------------------------------------------------------------------
|
13
16
|
// Helpers
|
14
17
|
//------------------------------------------------------------------------------
|
package/conf/config-schema.js
CHANGED
package/conf/environments.js
CHANGED
@@ -10,15 +10,76 @@
|
|
10
10
|
|
11
11
|
const globals = require("globals");
|
12
12
|
|
13
|
+
//------------------------------------------------------------------------------
|
14
|
+
// Helpers
|
15
|
+
//------------------------------------------------------------------------------
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Get the object that has differentce.
|
19
|
+
* @param {Record<string,boolean>} current The newer object.
|
20
|
+
* @param {Record<string,boolean>} prev The older object.
|
21
|
+
* @returns {Record<string,boolean>} The difference object.
|
22
|
+
*/
|
23
|
+
function getDiff(current, prev) {
|
24
|
+
const retv = {};
|
25
|
+
|
26
|
+
for (const [key, value] of Object.entries(current)) {
|
27
|
+
if (!Object.hasOwnProperty.call(prev, key)) {
|
28
|
+
retv[key] = value;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
return retv;
|
33
|
+
}
|
34
|
+
|
35
|
+
const newGlobals2015 = getDiff(globals.es2015, globals.es5); // 19 variables such as Promise, Map, ...
|
36
|
+
const newGlobals2017 = {
|
37
|
+
Atomics: false,
|
38
|
+
SharedArrayBuffer: false
|
39
|
+
};
|
40
|
+
const newGlobals2020 = {
|
41
|
+
BigInt: false,
|
42
|
+
BigInt64Array: false,
|
43
|
+
BigUint64Array: false
|
44
|
+
};
|
45
|
+
|
13
46
|
//------------------------------------------------------------------------------
|
14
47
|
// Public Interface
|
15
48
|
//------------------------------------------------------------------------------
|
16
49
|
|
17
50
|
/** @type {Map<string, import("../lib/shared/types").Environment>} */
|
18
51
|
module.exports = new Map(Object.entries({
|
52
|
+
|
53
|
+
// Language
|
19
54
|
builtin: {
|
20
55
|
globals: globals.es5
|
21
56
|
},
|
57
|
+
es6: {
|
58
|
+
globals: newGlobals2015,
|
59
|
+
parserOptions: {
|
60
|
+
ecmaVersion: 6
|
61
|
+
}
|
62
|
+
},
|
63
|
+
es2015: {
|
64
|
+
globals: newGlobals2015,
|
65
|
+
parserOptions: {
|
66
|
+
ecmaVersion: 6
|
67
|
+
}
|
68
|
+
},
|
69
|
+
es2017: {
|
70
|
+
globals: { ...newGlobals2015, ...newGlobals2017 },
|
71
|
+
parserOptions: {
|
72
|
+
ecmaVersion: 8
|
73
|
+
}
|
74
|
+
},
|
75
|
+
es2020: {
|
76
|
+
globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020 },
|
77
|
+
parserOptions: {
|
78
|
+
ecmaVersion: 11
|
79
|
+
}
|
80
|
+
},
|
81
|
+
|
82
|
+
// Platforms
|
22
83
|
browser: {
|
23
84
|
globals: globals.browser
|
24
85
|
},
|
@@ -30,6 +91,17 @@ module.exports = new Map(Object.entries({
|
|
30
91
|
}
|
31
92
|
}
|
32
93
|
},
|
94
|
+
"shared-node-browser": {
|
95
|
+
globals: globals["shared-node-browser"]
|
96
|
+
},
|
97
|
+
worker: {
|
98
|
+
globals: globals.worker
|
99
|
+
},
|
100
|
+
serviceworker: {
|
101
|
+
globals: globals.serviceworker
|
102
|
+
},
|
103
|
+
|
104
|
+
// Frameworks
|
33
105
|
commonjs: {
|
34
106
|
globals: globals.commonjs,
|
35
107
|
parserOptions: {
|
@@ -38,12 +110,6 @@ module.exports = new Map(Object.entries({
|
|
38
110
|
}
|
39
111
|
}
|
40
112
|
},
|
41
|
-
"shared-node-browser": {
|
42
|
-
globals: globals["shared-node-browser"]
|
43
|
-
},
|
44
|
-
worker: {
|
45
|
-
globals: globals.worker
|
46
|
-
},
|
47
113
|
amd: {
|
48
114
|
globals: globals.amd
|
49
115
|
},
|
@@ -86,9 +152,6 @@ module.exports = new Map(Object.entries({
|
|
86
152
|
nashorn: {
|
87
153
|
globals: globals.nashorn
|
88
154
|
},
|
89
|
-
serviceworker: {
|
90
|
-
globals: globals.serviceworker
|
91
|
-
},
|
92
155
|
atomtest: {
|
93
156
|
globals: globals.atomtest
|
94
157
|
},
|
@@ -98,12 +161,6 @@ module.exports = new Map(Object.entries({
|
|
98
161
|
webextensions: {
|
99
162
|
globals: globals.webextensions
|
100
163
|
},
|
101
|
-
es6: {
|
102
|
-
globals: globals.es2015,
|
103
|
-
parserOptions: {
|
104
|
-
ecmaVersion: 6
|
105
|
-
}
|
106
|
-
},
|
107
164
|
greasemonkey: {
|
108
165
|
globals: globals.greasemonkey
|
109
166
|
}
|
@@ -20,6 +20,7 @@ const path = require("path");
|
|
20
20
|
const defaultOptions = require("../../conf/default-cli-options");
|
21
21
|
const pkg = require("../../package.json");
|
22
22
|
const ConfigOps = require("../shared/config-ops");
|
23
|
+
const naming = require("../shared/naming");
|
23
24
|
const ModuleResolver = require("../shared/relative-module-resolver");
|
24
25
|
const { Linter } = require("../linter");
|
25
26
|
const builtInRules = require("../rules");
|
@@ -29,7 +30,6 @@ const { FileEnumerator } = require("./file-enumerator");
|
|
29
30
|
const hash = require("./hash");
|
30
31
|
const { IgnoredPaths } = require("./ignored-paths");
|
31
32
|
const LintResultCache = require("./lint-result-cache");
|
32
|
-
const naming = require("./naming");
|
33
33
|
|
34
34
|
const debug = require("debug")("eslint:cli-engine");
|
35
35
|
const validFixTypes = new Set(["problem", "suggestion", "layout"]);
|
@@ -734,7 +734,10 @@ class CLIEngine {
|
|
734
734
|
try {
|
735
735
|
fs.unlinkSync(cacheFilePath);
|
736
736
|
} catch (error) {
|
737
|
-
|
737
|
+
const errorCode = error && error.code;
|
738
|
+
|
739
|
+
// Ignore errors when no such file exists or file system is read only (and cache file does not exist)
|
740
|
+
if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !fs.existsSync(cacheFilePath))) {
|
738
741
|
throw error;
|
739
742
|
}
|
740
743
|
}
|
@@ -54,6 +54,7 @@ const { ExtractedConfig } = require("./extracted-config");
|
|
54
54
|
* @property {InstanceType<OverrideTester>|null} criteria The tester for the `files` and `excludedFiles` of this config element.
|
55
55
|
* @property {Record<string, boolean>|undefined} env The environment settings.
|
56
56
|
* @property {Record<string, GlobalConf>|undefined} globals The global variable settings.
|
57
|
+
* @property {boolean|undefined} noInlineConfig The flag that disables directive comments.
|
57
58
|
* @property {DependentParser|undefined} parser The parser loader.
|
58
59
|
* @property {Object|undefined} parserOptions The parser options.
|
59
60
|
* @property {Record<string, DependentPlugin>|undefined} plugins The plugin loaders.
|
@@ -250,6 +251,12 @@ function createConfig(instance, indices) {
|
|
250
251
|
config.processor = element.processor;
|
251
252
|
}
|
252
253
|
|
254
|
+
// Adopt the noInlineConfig which was found at first.
|
255
|
+
if (config.noInlineConfig === void 0 && element.noInlineConfig !== void 0) {
|
256
|
+
config.noInlineConfig = element.noInlineConfig;
|
257
|
+
config.configNameOfNoInlineConfig = element.name;
|
258
|
+
}
|
259
|
+
|
253
260
|
// Merge others.
|
254
261
|
mergeWithoutOverwrite(config.env, element.env);
|
255
262
|
mergeWithoutOverwrite(config.globals, element.globals);
|
@@ -29,6 +29,12 @@
|
|
29
29
|
class ExtractedConfig {
|
30
30
|
constructor() {
|
31
31
|
|
32
|
+
/**
|
33
|
+
* The config name what `noInlineConfig` setting came from.
|
34
|
+
* @type {string}
|
35
|
+
*/
|
36
|
+
this.configNameOfNoInlineConfig = "";
|
37
|
+
|
32
38
|
/**
|
33
39
|
* Environments.
|
34
40
|
* @type {Record<string, boolean>}
|
@@ -41,6 +47,12 @@ class ExtractedConfig {
|
|
41
47
|
*/
|
42
48
|
this.globals = {};
|
43
49
|
|
50
|
+
/**
|
51
|
+
* The flag that disables directive comments.
|
52
|
+
* @type {boolean|undefined}
|
53
|
+
*/
|
54
|
+
this.noInlineConfig = void 0;
|
55
|
+
|
44
56
|
/**
|
45
57
|
* Parser definition.
|
46
58
|
* @type {DependentParser|null}
|
@@ -84,7 +96,10 @@ class ExtractedConfig {
|
|
84
96
|
*/
|
85
97
|
toCompatibleObjectAsConfigFileContent() {
|
86
98
|
const {
|
87
|
-
|
99
|
+
/* eslint-disable no-unused-vars */
|
100
|
+
configNameOfNoInlineConfig: _ignore1,
|
101
|
+
processor: _ignore2,
|
102
|
+
/* eslint-enable no-unused-vars */
|
88
103
|
...config
|
89
104
|
} = this;
|
90
105
|
|
@@ -38,9 +38,9 @@ const path = require("path");
|
|
38
38
|
const importFresh = require("import-fresh");
|
39
39
|
const stripComments = require("strip-json-comments");
|
40
40
|
const { validateConfigSchema } = require("../shared/config-validator");
|
41
|
+
const naming = require("../shared/naming");
|
41
42
|
const ModuleResolver = require("../shared/relative-module-resolver");
|
42
43
|
const { ConfigArray, ConfigDependency, OverrideTester } = require("./config-array");
|
43
|
-
const naming = require("./naming");
|
44
44
|
const debug = require("debug")("eslint:config-array-factory");
|
45
45
|
|
46
46
|
//------------------------------------------------------------------------------
|
@@ -526,6 +526,7 @@ class ConfigArrayFactory {
|
|
526
526
|
env,
|
527
527
|
extends: extend,
|
528
528
|
globals,
|
529
|
+
noInlineConfig,
|
529
530
|
parser: parserName,
|
530
531
|
parserOptions,
|
531
532
|
plugins: pluginList,
|
@@ -567,6 +568,7 @@ class ConfigArrayFactory {
|
|
567
568
|
criteria: null,
|
568
569
|
env,
|
569
570
|
globals,
|
571
|
+
noInlineConfig,
|
570
572
|
parser,
|
571
573
|
parserOptions,
|
572
574
|
plugins,
|
@@ -292,26 +292,18 @@ class FileEnumerator {
|
|
292
292
|
_iterateFiles(pattern) {
|
293
293
|
const { cwd, globInputPaths } = internalSlotsMap.get(this);
|
294
294
|
const absolutePath = path.resolve(cwd, pattern);
|
295
|
-
|
296
|
-
if (globInputPaths && isGlobPattern(pattern)) {
|
297
|
-
return this._iterateFilesWithGlob(
|
298
|
-
absolutePath,
|
299
|
-
dotfilesPattern.test(pattern)
|
300
|
-
);
|
301
|
-
}
|
302
|
-
|
295
|
+
const isDot = dotfilesPattern.test(pattern);
|
303
296
|
const stat = statSafeSync(absolutePath);
|
304
297
|
|
305
298
|
if (stat && stat.isDirectory()) {
|
306
|
-
return this._iterateFilesWithDirectory(
|
307
|
-
absolutePath,
|
308
|
-
dotfilesPattern.test(pattern)
|
309
|
-
);
|
299
|
+
return this._iterateFilesWithDirectory(absolutePath, isDot);
|
310
300
|
}
|
311
|
-
|
312
301
|
if (stat && stat.isFile()) {
|
313
302
|
return this._iterateFilesWithFile(absolutePath);
|
314
303
|
}
|
304
|
+
if (globInputPaths && isGlobPattern(pattern)) {
|
305
|
+
return this._iterateFilesWithGlob(absolutePath, isDot);
|
306
|
+
}
|
315
307
|
|
316
308
|
return [];
|
317
309
|
}
|
@@ -18,6 +18,7 @@ const util = require("util"),
|
|
18
18
|
recConfig = require("../../conf/eslint-recommended"),
|
19
19
|
ConfigOps = require("../shared/config-ops"),
|
20
20
|
log = require("../shared/logging"),
|
21
|
+
naming = require("../shared/naming"),
|
21
22
|
ModuleResolver = require("../shared/relative-module-resolver"),
|
22
23
|
autoconfig = require("./autoconfig.js"),
|
23
24
|
ConfigFile = require("./config-file"),
|
@@ -97,17 +98,26 @@ function getModulesList(config, installESLint) {
|
|
97
98
|
// Create a list of modules which should be installed based on config
|
98
99
|
if (config.plugins) {
|
99
100
|
for (const plugin of config.plugins) {
|
100
|
-
|
101
|
+
const moduleName = naming.normalizePackageName(plugin, "eslint-plugin");
|
102
|
+
|
103
|
+
modules[moduleName] = "latest";
|
101
104
|
}
|
102
105
|
}
|
103
|
-
if (config.extends
|
104
|
-
const
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
if (config.extends) {
|
107
|
+
const extendList = Array.isArray(config.extends) ? config.extends : [config.extends];
|
108
|
+
|
109
|
+
for (const extend of extendList) {
|
110
|
+
if (extend.startsWith("eslint:") || extend.startsWith("plugin:")) {
|
111
|
+
continue;
|
112
|
+
}
|
113
|
+
const moduleName = naming.normalizePackageName(extend, "eslint-config");
|
114
|
+
|
115
|
+
modules[moduleName] = "latest";
|
116
|
+
Object.assign(
|
117
|
+
modules,
|
118
|
+
getPeerDependencies(`${moduleName}@latest`)
|
119
|
+
);
|
120
|
+
}
|
111
121
|
}
|
112
122
|
|
113
123
|
if (installESLint === false) {
|
package/lib/init/npm-utils.js
CHANGED
@@ -135,7 +135,7 @@ function check(packages, opt) {
|
|
135
135
|
* Check whether node modules are included in the dependencies of a project's
|
136
136
|
* package.json.
|
137
137
|
*
|
138
|
-
*
|
138
|
+
* Convenience wrapper around check().
|
139
139
|
*
|
140
140
|
* @param {string[]} packages Array of node modules to check.
|
141
141
|
* @param {string} rootDir The directory contianing a package.json
|
@@ -150,7 +150,7 @@ function checkDeps(packages, rootDir) {
|
|
150
150
|
* Check whether node modules are included in the devDependencies of a project's
|
151
151
|
* package.json.
|
152
152
|
*
|
153
|
-
*
|
153
|
+
* Convenience wrapper around check().
|
154
154
|
*
|
155
155
|
* @param {string[]} packages Array of node modules to check.
|
156
156
|
* @returns {Object} An object whose keys are the module names
|
package/lib/linter/linter.js
CHANGED
@@ -198,14 +198,20 @@ function createMissingRuleMessage(ruleId) {
|
|
198
198
|
/**
|
199
199
|
* creates a linting problem
|
200
200
|
* @param {Object} options to create linting error
|
201
|
-
* @param {string} options.ruleId the ruleId to report
|
202
|
-
* @param {Object} options.loc the loc to report
|
203
|
-
* @param {string} options.message the error message to report
|
204
|
-
* @
|
201
|
+
* @param {string} [options.ruleId] the ruleId to report
|
202
|
+
* @param {Object} [options.loc] the loc to report
|
203
|
+
* @param {string} [options.message] the error message to report
|
204
|
+
* @param {string} [options.severity] the error message to report
|
205
|
+
* @returns {LintMessage} created problem, returns a missing-rule problem if only provided ruleId.
|
205
206
|
* @private
|
206
207
|
*/
|
207
208
|
function createLintingProblem(options) {
|
208
|
-
const {
|
209
|
+
const {
|
210
|
+
ruleId = null,
|
211
|
+
loc = DEFAULT_ERROR_LOC,
|
212
|
+
message = createMissingRuleMessage(options.ruleId),
|
213
|
+
severity = 2
|
214
|
+
} = options;
|
209
215
|
|
210
216
|
return {
|
211
217
|
ruleId,
|
@@ -214,7 +220,7 @@ function createLintingProblem(options) {
|
|
214
220
|
column: loc.start.column + 1,
|
215
221
|
endLine: loc.end.line,
|
216
222
|
endColumn: loc.end.column + 1,
|
217
|
-
severity
|
223
|
+
severity,
|
218
224
|
nodeType: null
|
219
225
|
};
|
220
226
|
}
|
@@ -257,28 +263,42 @@ function createDisableDirectives(options) {
|
|
257
263
|
* @param {string} filename The file being checked.
|
258
264
|
* @param {ASTNode} ast The top node of the AST.
|
259
265
|
* @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
|
266
|
+
* @param {string|null} warnInlineConfig If a string then it should warn directive comments as disabled. The string value is the config name what the setting came from.
|
260
267
|
* @returns {{configuredRules: Object, enabledGlobals: {value:string,comment:Token}[], exportedVariables: Object, problems: Problem[], disableDirectives: DisableDirective[]}}
|
261
268
|
* A collection of the directive comments that were found, along with any problems that occurred when parsing
|
262
269
|
*/
|
263
|
-
function getDirectiveComments(filename, ast, ruleMapper) {
|
270
|
+
function getDirectiveComments(filename, ast, ruleMapper, warnInlineConfig) {
|
264
271
|
const configuredRules = {};
|
265
|
-
const enabledGlobals =
|
272
|
+
const enabledGlobals = Object.create(null);
|
266
273
|
const exportedVariables = {};
|
267
274
|
const problems = [];
|
268
275
|
const disableDirectives = [];
|
269
276
|
|
270
277
|
ast.comments.filter(token => token.type !== "Shebang").forEach(comment => {
|
271
278
|
const trimmedCommentText = comment.value.trim();
|
272
|
-
const match = /^(eslint(
|
279
|
+
const match = /^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u.exec(trimmedCommentText);
|
273
280
|
|
274
281
|
if (!match) {
|
275
282
|
return;
|
276
283
|
}
|
284
|
+
const lineCommentSupported = /^eslint-disable-(next-)?line$/u.test(match[1]);
|
285
|
+
|
286
|
+
if (warnInlineConfig && (lineCommentSupported || comment.type === "Block")) {
|
287
|
+
const kind = comment.type === "Block" ? `/*${match[1]}*/` : `//${match[1]}`;
|
288
|
+
|
289
|
+
problems.push(createLintingProblem({
|
290
|
+
ruleId: null,
|
291
|
+
message: `'${kind}' has no effect because you have 'noInlineConfig' setting in ${warnInlineConfig}.`,
|
292
|
+
loc: comment.loc,
|
293
|
+
severity: 1
|
294
|
+
}));
|
295
|
+
return;
|
296
|
+
}
|
277
297
|
|
278
298
|
const directiveValue = trimmedCommentText.slice(match.index + match[1].length);
|
279
299
|
let directiveType = "";
|
280
300
|
|
281
|
-
if (
|
301
|
+
if (lineCommentSupported) {
|
282
302
|
if (comment.loc.start.line === comment.loc.end.line) {
|
283
303
|
directiveType = match[1].slice("eslint-".length);
|
284
304
|
} else {
|
@@ -441,16 +461,27 @@ function normalizeFilename(filename) {
|
|
441
461
|
return index === -1 ? filename : parts.slice(index).join(path.sep);
|
442
462
|
}
|
443
463
|
|
464
|
+
// eslint-disable-next-line valid-jsdoc
|
444
465
|
/**
|
445
466
|
* Normalizes the possible options for `linter.verify` and `linter.verifyAndFix` to a
|
446
467
|
* consistent shape.
|
447
468
|
* @param {VerifyOptions} providedOptions Options
|
448
|
-
* @
|
469
|
+
* @param {ConfigData} config Config.
|
470
|
+
* @returns {Required<VerifyOptions> & { warnInlineConfig: string|null }} Normalized options
|
449
471
|
*/
|
450
|
-
function normalizeVerifyOptions(providedOptions) {
|
472
|
+
function normalizeVerifyOptions(providedOptions, config) {
|
473
|
+
const disableInlineConfig = config.noInlineConfig === true;
|
474
|
+
const ignoreInlineConfig = providedOptions.allowInlineConfig === false;
|
475
|
+
const configNameOfNoInlineConfig = config.configNameOfNoInlineConfig
|
476
|
+
? ` (${config.configNameOfNoInlineConfig})`
|
477
|
+
: "";
|
478
|
+
|
451
479
|
return {
|
452
480
|
filename: normalizeFilename(providedOptions.filename || "<input>"),
|
453
|
-
allowInlineConfig:
|
481
|
+
allowInlineConfig: !ignoreInlineConfig,
|
482
|
+
warnInlineConfig: disableInlineConfig && !ignoreInlineConfig
|
483
|
+
? `your config${configNameOfNoInlineConfig}`
|
484
|
+
: null,
|
454
485
|
reportUnusedDisableDirectives: Boolean(providedOptions.reportUnusedDisableDirectives),
|
455
486
|
disableFixes: Boolean(providedOptions.disableFixes)
|
456
487
|
};
|
@@ -984,7 +1015,7 @@ class Linter {
|
|
984
1015
|
_verifyWithoutProcessors(textOrSourceCode, providedConfig, providedOptions) {
|
985
1016
|
const slots = internalSlotsMap.get(this);
|
986
1017
|
const config = providedConfig || {};
|
987
|
-
const options = normalizeVerifyOptions(providedOptions);
|
1018
|
+
const options = normalizeVerifyOptions(providedOptions, config);
|
988
1019
|
let text;
|
989
1020
|
|
990
1021
|
// evaluate arguments
|
@@ -1019,7 +1050,9 @@ class Linter {
|
|
1019
1050
|
}
|
1020
1051
|
|
1021
1052
|
// search and apply "eslint-env *".
|
1022
|
-
const envInFile =
|
1053
|
+
const envInFile = options.allowInlineConfig && !options.warnInlineConfig
|
1054
|
+
? findEslintEnv(text)
|
1055
|
+
: {};
|
1023
1056
|
const resolvedEnvConfig = Object.assign({ builtin: true }, config.env, envInFile);
|
1024
1057
|
const enabledEnvs = Object.keys(resolvedEnvConfig)
|
1025
1058
|
.filter(envName => resolvedEnvConfig[envName])
|
@@ -1062,7 +1095,7 @@ class Linter {
|
|
1062
1095
|
|
1063
1096
|
const sourceCode = slots.lastSourceCode;
|
1064
1097
|
const commentDirectives = options.allowInlineConfig
|
1065
|
-
? getDirectiveComments(options.filename, sourceCode.ast, ruleId => getRule(slots, ruleId))
|
1098
|
+
? getDirectiveComments(options.filename, sourceCode.ast, ruleId => getRule(slots, ruleId), options.warnInlineConfig)
|
1066
1099
|
: { configuredRules: {}, enabledGlobals: {}, exportedVariables: {}, problems: [], disableDirectives: [] };
|
1067
1100
|
|
1068
1101
|
// augment global scope with declared global variables
|