eslint 6.0.0 → 6.2.1

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +3 -5
  3. package/bin/eslint.js +4 -1
  4. package/conf/config-schema.js +1 -0
  5. package/conf/environments.js +72 -15
  6. package/lib/cli-engine/cascading-config-array-factory.js +15 -3
  7. package/lib/cli-engine/cli-engine.js +13 -3
  8. package/lib/cli-engine/config-array/config-array.js +7 -0
  9. package/lib/cli-engine/config-array/extracted-config.js +16 -1
  10. package/lib/cli-engine/config-array-factory.js +9 -6
  11. package/lib/cli-engine/file-enumerator.js +5 -13
  12. package/lib/init/config-initializer.js +19 -9
  13. package/lib/init/npm-utils.js +2 -2
  14. package/lib/linter/code-path-analysis/code-path-analyzer.js +1 -0
  15. package/lib/linter/linter.js +49 -16
  16. package/lib/rule-tester/rule-tester.js +1 -1
  17. package/lib/rules/accessor-pairs.js +195 -35
  18. package/lib/rules/arrow-body-style.js +2 -2
  19. package/lib/rules/class-methods-use-this.js +10 -3
  20. package/lib/rules/dot-location.js +21 -17
  21. package/lib/rules/dot-notation.js +6 -2
  22. package/lib/rules/func-call-spacing.js +30 -20
  23. package/lib/rules/func-names.js +4 -0
  24. package/lib/rules/function-call-argument-newline.js +120 -0
  25. package/lib/rules/function-paren-newline.js +34 -22
  26. package/lib/rules/indent.js +13 -2
  27. package/lib/rules/index.js +1 -0
  28. package/lib/rules/new-cap.js +2 -1
  29. package/lib/rules/no-dupe-keys.js +1 -1
  30. package/lib/rules/no-duplicate-case.js +10 -8
  31. package/lib/rules/no-extra-bind.js +1 -0
  32. package/lib/rules/no-extra-boolean-cast.js +44 -5
  33. package/lib/rules/no-extra-parens.js +295 -39
  34. package/lib/rules/no-mixed-operators.js +48 -13
  35. package/lib/rules/no-param-reassign.js +12 -1
  36. package/lib/rules/no-restricted-syntax.js +2 -2
  37. package/lib/rules/no-unused-vars.js +1 -1
  38. package/lib/rules/prefer-const.js +9 -3
  39. package/lib/rules/prefer-template.js +1 -10
  40. package/lib/rules/sort-keys.js +11 -3
  41. package/lib/rules/utils/ast-utils.js +45 -3
  42. package/lib/rules/yoda.js +1 -1
  43. package/lib/{cli-engine → shared}/naming.js +0 -0
  44. package/lib/shared/types.js +2 -0
  45. package/messages/extend-config-missing.txt +2 -0
  46. package/messages/print-config-with-directory-path.txt +2 -0
  47. package/package.json +22 -21
package/CHANGELOG.md CHANGED
@@ -1,3 +1,83 @@
1
+ v6.2.1 - August 20, 2019
2
+
3
+ * [`8c021b5`](https://github.com/eslint/eslint/commit/8c021b5917b3aa3c578ffe3972106d0a6bcf0838) Upgrade: eslint-utils 1.4.2 (#12131) (Toru Nagashima)
4
+ * [`e82388b`](https://github.com/eslint/eslint/commit/e82388bd87717430200ec554634cc08806e38d3c) Sponsors: Sync README with website (ESLint Jenkins)
5
+ * [`4aeeeed`](https://github.com/eslint/eslint/commit/4aeeeedb656ee3519ea82ebf0cb41ca801215046) Docs: update docs for ecmaVersion 2020 (#12120) (silverwind)
6
+ * [`6886148`](https://github.com/eslint/eslint/commit/6886148d1f528659ec3e125f61ef7a5f4c67556d) Docs: Add duplicate keys limitation to accessor-pairs (#12124) (Milos Djermanovic)
7
+
8
+ v6.2.0 - August 18, 2019
9
+
10
+ * [`fee6acb`](https://github.com/eslint/eslint/commit/fee6acbe13cecd4c028e681e185fc6a6d6ba9452) Update: support bigint and dynamic import (refs #11803) (#11983) (Toru Nagashima)
11
+ * [`afd8012`](https://github.com/eslint/eslint/commit/afd8012c2797f2f5bf3c360cb241ea2ba6e1a489) New: noInlineConfig setting (refs eslint/rfcs#22) (#12091) (Toru Nagashima)
12
+ * [`3d12378`](https://github.com/eslint/eslint/commit/3d12378221961439c27ddae0ecda9845ac575107) Update: Fix accessor-pairs to enforce pairs per property in literals (#12062) (Milos Djermanovic)
13
+ * [`8cd00b3`](https://github.com/eslint/eslint/commit/8cd00b308987e0db0bdb2e242bf13b2b07b350bd) New: function-call-argument-newline (#12024) (finico)
14
+ * [`30ebf92`](https://github.com/eslint/eslint/commit/30ebf929f60684520b1201c1adfd86214c19d614) Fix: prefer-template autofix produces syntax error with octal escapes (#12085) (Milos Djermanovic)
15
+ * [`13c3988`](https://github.com/eslint/eslint/commit/13c3988a4001ae368ea7b6c8d3dd0abfa7c6cf64) Fix: Check literal type explicitly in dot-notation (#12095) (Milos Djermanovic)
16
+ * [`3e5ceca`](https://github.com/eslint/eslint/commit/3e5ceca4d2284b55a2292a1d3de9aa4cdf6fa213) Fix: Handle empty string property names in getFunctionNameWithKind (#12104) (Milos Djermanovic)
17
+ * [`9a043ff`](https://github.com/eslint/eslint/commit/9a043ffbb864fc65baeb16fe5668435e3b7cfe34) Fix: no-duplicate-case false positives on Object.prototype keys (#12107) (Milos Djermanovic)
18
+ * [`fe631af`](https://github.com/eslint/eslint/commit/fe631afee59641876598d19b1935967099cc6fa0) Chore: minor typo fix (#12112) (James George)
19
+ * [`4cb7877`](https://github.com/eslint/eslint/commit/4cb78774f6cc687a3c8701462f8c7f7b587ecaf0) Fix: fix no-extra-parens ignores some nodes (#11909) (Pig Fang)
20
+ * [`2dc23b8`](https://github.com/eslint/eslint/commit/2dc23b81e54defbce7a70a7f26c2e4c7b692cf58) Update: fix no-dupe-keys false negatives on empty string names (#12069) (Milos Djermanovic)
21
+ * [`19ab666`](https://github.com/eslint/eslint/commit/19ab6666e8e4142a183bdee2be96e5bafbac0e21) Fix: yoda exceptRange false positives on empty string property names (#12071) (Milos Djermanovic)
22
+ * [`d642150`](https://github.com/eslint/eslint/commit/d642150fe016608e71a1df2a72960e915b3cfbad) Update: Check empty string property names in sort-keys (#12073) (Milos Djermanovic)
23
+ * [`acce6de`](https://github.com/eslint/eslint/commit/acce6de940e2b089ff5ba59e4518a54af1682d5e) Fix: class-methods-use-this reports 'undefined' names (#12103) (Milos Djermanovic)
24
+ * [`92ec2cb`](https://github.com/eslint/eslint/commit/92ec2cb1731b7b6e0ac66336d583fbb782504290) Fix: Allow bind call with a single spread element in no-extra-bind (#12088) (Milos Djermanovic)
25
+ * [`bfdb0c9`](https://github.com/eslint/eslint/commit/bfdb0c97003fc0e045aa6ed10b177c35305a6e46) Fix: no-extra-boolean-cast invalid autofix for Boolean() without args (#12076) (Milos Djermanovic)
26
+ * [`34ccc0c`](https://github.com/eslint/eslint/commit/34ccc0cd81f495190e585c6efa8ae233d45bd3ed) Chore: Remove TDZ scope type condition from no-unused-vars (#12055) (Milos Djermanovic)
27
+ * [`01d38ce`](https://github.com/eslint/eslint/commit/01d38ce2faf0abbc9dd5d25694baeee131036165) Docs: Remove TDZ scope from the scope manager interface documentation (#12054) (Milos Djermanovic)
28
+ * [`1aff8fc`](https://github.com/eslint/eslint/commit/1aff8fc4f9394cd9126654a55f7f3a43ab1cf8f0) Update: warn about mixing ternary and logical operators (fixes #11704) (#12001) (Karthik Priyadarshan)
29
+ * [`11be2f8`](https://github.com/eslint/eslint/commit/11be2f8513bd61499f6247392a33ac0a26901c90) Docs: do not recommend global-installed usage (#12016) (薛定谔的猫)
30
+ * [`cf31dab`](https://github.com/eslint/eslint/commit/cf31dab5d5982151e0cfcc32879e69a83180ec70) Fix: no-restricted-syntax - correct the schema (#12051) (Brad Zacher)
31
+ * [`fbec99e`](https://github.com/eslint/eslint/commit/fbec99ea3e39316791685652c66e522d698f52d8) Update: fix class-methods-use-this false negatives with exceptMethods (#12077) (Milos Djermanovic)
32
+ * [`fb08b7c`](https://github.com/eslint/eslint/commit/fb08b7c9d28bc68864eb940e26df274059228b6a) Docs: Remove readonly/writable global logic from no-undef (fixes #11963) (#12053) (Milos Djermanovic)
33
+ * [`5b5934b`](https://github.com/eslint/eslint/commit/5b5934b9513f9114f5bf8e12ff4f4981590d64d3) Sponsors: Sync README with website (ESLint Jenkins)
34
+ * [`9156760`](https://github.com/eslint/eslint/commit/915676022a100ae5dba788fa3329d34b3c1f18d3) Sponsors: Sync README with website (ESLint Jenkins)
35
+ * [`f5e0cc4`](https://github.com/eslint/eslint/commit/f5e0cc40795f175692acb05daaadb91e9e5ae5d3) Update: Check computed method keys in no-extra-parens (#11973) (Milos Djermanovic)
36
+ * [`d961438`](https://github.com/eslint/eslint/commit/d9614388df8cfb977842ed7ac4725d76a3e05df3) Docs: Fix Incorrect Documentation (#12045) (Michael Miceli)
37
+ * [`887d08c`](https://github.com/eslint/eslint/commit/887d08c244e32f1fc18359e63380e2cdb0cb3797) Sponsors: Sync README with website (ESLint Jenkins)
38
+ * [`d90183f`](https://github.com/eslint/eslint/commit/d90183ff6757cff854f4ca4d25b835143dfb4b21) Docs: add a case to func-names (#12038) (Chiawen Chen)
39
+ * [`8a5b62d`](https://github.com/eslint/eslint/commit/8a5b62de2ae574f416c0f8ad91205da9b1837275) Docs: no use eslint.linter in code example (#12037) (薛定谔的猫)
40
+ * [`5831767`](https://github.com/eslint/eslint/commit/58317673210e48be3975e317c2c566fae155c94f) Update: report location of func-names (fixes #12022) (#12028) (Pig Fang)
41
+
42
+ v6.1.0 - July 20, 2019
43
+
44
+ * [`8f86cca`](https://github.com/eslint/eslint/commit/8f86ccaa89daf10123370868c5dcb48c1fcbef7d) Upgrade: eslint-scope@^5.0.0 (#12011) (Kevin Partington)
45
+ * [`d08683e`](https://github.com/eslint/eslint/commit/d08683e3c807f92daf266894093c70f8d5ac6afa) Fix: glob processing (fixes #11940) (#11986) (Toru Nagashima)
46
+ * [`bfcf8b2`](https://github.com/eslint/eslint/commit/bfcf8b21011466b570b536ca31ec10fd228b3dca) Fix: dot-location errors with parenthesized objects (fixes #11868) (#11933) (Milos Djermanovic)
47
+ * [`79e8d09`](https://github.com/eslint/eslint/commit/79e8d099bbbebfa4d804484eeeeea9c074ede870) Fix: add parens for sequence expr in arrow-body-style (fixes #11917) (#11918) (Pig Fang)
48
+ * [`105c098`](https://github.com/eslint/eslint/commit/105c098f3cece8b83ab8d1566b8ea41dd94a60b9) Docs: update docs for object-curly-spacing (fixes #11634) (#12009) (Chiawen Chen)
49
+ * [`c90a12c`](https://github.com/eslint/eslint/commit/c90a12c283698befcafd2c86f8bd8942428fe80b) Chore: update release script for new website repo (#12006) (Kai Cataldo)
50
+ * [`e2c08a9`](https://github.com/eslint/eslint/commit/e2c08a9c8d86238955ecc8fd5a626584ee91eba5) Sponsors: Sync README with website (ESLint Jenkins)
51
+ * [`b974fcb`](https://github.com/eslint/eslint/commit/b974fcbd3321ab382a914520018d4c051b2e5c62) Update: Check computed property keys in no-extra-parens (#11952) (Milos Djermanovic)
52
+ * [`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)
53
+ * [`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)
54
+ * [`2dafe2d`](https://github.com/eslint/eslint/commit/2dafe2d288d1e0d353bb938d12a5da888091cfdb) Fix: prefer-const produces invalid autofix (fixes #11699) (#11827) (Milos Djermanovic)
55
+ * [`cb475fd`](https://github.com/eslint/eslint/commit/cb475fd8c0bbfcb00340459966b6780f39ea87a7) Fix: Cache file error handling on read-only file system. (fixes #11945) (#11946) (Cuki)
56
+ * [`89412c3`](https://github.com/eslint/eslint/commit/89412c3cbc52e556dba590fa94e10bf40faf1fdf) Docs: Fixed a typo (fixes #11999) (#12000) (Eddie Olson)
57
+ * [`6669f78`](https://github.com/eslint/eslint/commit/6669f78a3dd305aef6191e7eea24fae2ae4fd2e8) Fix: --init with Vue.js failed (fixes #11970) (#11985) (Toru Nagashima)
58
+ * [`93633c2`](https://github.com/eslint/eslint/commit/93633c2b3716b17816bcb3dc221c49b75db41317) Upgrade: Upgrade lodash dependency (fixes #11992) (#11994) (Cyd La Luz)
59
+ * [`776dae7`](https://github.com/eslint/eslint/commit/776dae71f2f5c7b5f0650ea3c277eca26e324e41) Docs: fix wrong Node.js version in getting started (#11993) (Toru Nagashima)
60
+ * [`4448261`](https://github.com/eslint/eslint/commit/4448261f5d217d8a06eb0ef898401928b54a34e3) Docs: some typos and optimization points (#11960) (Jason Lee)
61
+ * [`2a10856`](https://github.com/eslint/eslint/commit/2a10856d1ed5880a09a5ba452bd80d49c1be4e6c) Chore: Add temporary test files to .gitignore (#11978) (Milos Djermanovic)
62
+ * [`d83b233`](https://github.com/eslint/eslint/commit/d83b23382de3b80056a7e6330ed5846316c94147) Chore: update path for release bundles (#11977) (Kai Cataldo)
63
+ * [`1fb3620`](https://github.com/eslint/eslint/commit/1fb362093a65b99456a11029967d9ee0c31fd697) Fix: creating of enabledGlobals object without prototype (fixes #11929) (#11935) (finico)
64
+ * [`c2f2db9`](https://github.com/eslint/eslint/commit/c2f2db97c6d6a415b78ee7b3e8924853d465e757) Docs: Replace global true and false with writable and readonly in rules (#11956) (Milos Djermanovic)
65
+ * [`19335b8`](https://github.com/eslint/eslint/commit/19335b8f47029b2f742d5507ba39484eaf68d07b) Fix: actual messageId and expected messageId are switched in rule tester (#11928) (Milos Djermanovic)
66
+ * [`8b216e0`](https://github.com/eslint/eslint/commit/8b216e04fb0dd0a1a4d3730ebe4b24780020b09c) Docs: Fix incorrect example comments for unicode-bom rule (fixes #11937) (#11938) (Brandon Yeager)
67
+ * [`cc3885b`](https://github.com/eslint/eslint/commit/cc3885b028e29ebc575c900f43af81cb0dabffb6) Chore: add v8-compile-cache to speed up instantiation time (#11921) (薛定谔的猫)
68
+ * [`d8f2688`](https://github.com/eslint/eslint/commit/d8f26886f19a17f2e1cdcb91e2db84fc7ba3fdfb) Upgrade: deps (#11904) (薛定谔的猫)
69
+ * [`e5f1ccc`](https://github.com/eslint/eslint/commit/e5f1ccc9e2d07ad0acf149027ffc382021d54da1) Docs: add 'stricter rule config validating' in migrating docs (#11905) (薛定谔的猫)
70
+
71
+ v6.0.1 - June 24, 2019
72
+
73
+ * [`b5bde06`](https://github.com/eslint/eslint/commit/b5bde0669bd6a7a6b8e38cdf204d8d4b932cea63) Fix: --rulesdir option didn't work (fixes #11888) (#11890) (Toru Nagashima)
74
+ * [`13f0418`](https://github.com/eslint/eslint/commit/13f041897ee31982808a57b4d06450b57c9b27dc) Fix: improve error message on --print-config (fixes #11874) (#11885) (Toru Nagashima)
75
+ * [`056c2aa`](https://github.com/eslint/eslint/commit/056c2aaf39a5f8d06de24f06946dda95032a0361) Fix: improve diagnostics for shareable-config-missing errors (#11880) (Teddy Katz)
76
+ * [`566b7aa`](https://github.com/eslint/eslint/commit/566b7aa5d61fb31cd47fe4da7820b07cf9bde1ec) Docs: Update no-confusing-arrow with the new default option (#11886) (Yuping Zuo)
77
+ * [`d07f3fa`](https://github.com/eslint/eslint/commit/d07f3fae19b901c30cf4998f10722cb3182bd237) Fix: CLIEngine#getRules() contains plugin rules (fixes #11871) (#11872) (Toru Nagashima)
78
+ * [`21f4a80`](https://github.com/eslint/eslint/commit/21f4a8057ccc941f72bb617ae3b5c135a774f6c0) Docs: Fix inconsistent linking in migration guide (#11881) (Teddy Katz)
79
+ * [`f3a0774`](https://github.com/eslint/eslint/commit/f3a0774a8879b08777a4aedc76677f13d5156242) Docs: Fix typo in 6.0.0 migration guide (#11870) (Kevin Partington)
80
+
1
81
  v6.0.0 - June 21, 2019
2
82
 
3
83
  * [`81aa06b`](https://github.com/eslint/eslint/commit/81aa06b4cc49e9c15234a2c4d27659a03fea53d8) Upgrade: espree@6.0.0 (#11869) (Teddy Katz)
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:
@@ -258,9 +256,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
258
256
  <!-- NOTE: This section is autogenerated. Do not manually edit.-->
259
257
  <!--sponsorsstart-->
260
258
  <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://clay.global"><img src="https://images.opencollective.com/clayglobal/logo.png" alt="clay" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/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/logo.png" alt="TekHattan" height="32"></a> <a href="https://www.marfeel.com/"><img src="https://images.opencollective.com/marfeel/logo.png" alt="Marfeel" height="32"></a> <a href="http://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/logo.png" alt="Fire Stick Tricks" height="32"></a> <a href="https://jsheroes.io/"><img src="https://images.opencollective.com/jsheroes1/logo.png" alt="JSHeroes " height="32"></a> <a href="https://faithlife.com/ref/about"><img src="https://images.opencollective.com/faithlife/logo.png" alt="Faithlife" height="32"></a></p>
259
+ <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://salesforce.com"><img src="https://images.opencollective.com/salesforce/853ecef/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>
260
+ <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>
261
+ <p><a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/logo.png" alt="ThemeIsle" 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://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://icons8.com"><img src="https://images.opencollective.com/icons8/0b37d14/logo.png" alt="Free Icons by Icons8" 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> <a href="https://faithlife.com/ref/about"><img src="https://images.opencollective.com/faithlife/534b832/logo.png" alt="Faithlife" height="32"></a></p>
264
262
  <!--sponsorsend-->
265
263
 
266
264
  ## <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
  //------------------------------------------------------------------------------
@@ -45,7 +48,7 @@ process.once("uncaughtException", err => {
45
48
  const pkg = require("../package.json");
46
49
 
47
50
  console.error("\nOops! Something went wrong! :(");
48
- console.error(`\nESLint: ${pkg.version}.\n${template(err.messageData || {})}`);
51
+ console.error(`\nESLint: ${pkg.version}.\n\n${template(err.messageData || {})}`);
49
52
  } else {
50
53
 
51
54
  console.error(err.stack);
@@ -20,6 +20,7 @@ const baseConfigProperties = {
20
20
  processor: { type: "string" },
21
21
  rules: { type: "object" },
22
22
  settings: { type: "object" },
23
+ noInlineConfig: { type: "boolean" },
23
24
 
24
25
  ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
25
26
  };
@@ -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
  }
@@ -27,7 +27,7 @@ const os = require("os");
27
27
  const path = require("path");
28
28
  const { validateConfigArray } = require("../shared/config-validator");
29
29
  const { ConfigArrayFactory } = require("./config-array-factory");
30
- const { ConfigDependency } = require("./config-array");
30
+ const { ConfigArray, ConfigDependency } = require("./config-array");
31
31
  const loadRules = require("./load-rules");
32
32
  const debug = require("debug")("eslint:cascading-config-array-factory");
33
33
 
@@ -225,11 +225,22 @@ class CascadingConfigArrayFactory {
225
225
 
226
226
  /**
227
227
  * Get the config array of a given file.
228
- * @param {string} filePath The file path to a file.
228
+ * If `filePath` was not given, it returns the config which contains only
229
+ * `baseConfigData` and `cliConfigData`.
230
+ * @param {string} [filePath] The file path to a file.
229
231
  * @returns {ConfigArray} The config array of the file.
230
232
  */
231
233
  getConfigArrayForFile(filePath) {
232
- const { cwd } = internalSlotsMap.get(this);
234
+ const {
235
+ baseConfigArray,
236
+ cliConfigArray,
237
+ cwd
238
+ } = internalSlotsMap.get(this);
239
+
240
+ if (!filePath) {
241
+ return new ConfigArray(...baseConfigArray, ...cliConfigArray);
242
+ }
243
+
233
244
  const directoryPath = path.dirname(path.resolve(cwd, filePath));
234
245
 
235
246
  debug(`Load config files for ${directoryPath}.`);
@@ -302,6 +313,7 @@ class CascadingConfigArrayFactory {
302
313
 
303
314
  if (configArray.length > 0 && configArray.isRoot()) {
304
315
  debug("Stop traversing because of 'root:true'.");
316
+ configArray.unshift(...baseConfigArray);
305
317
  return this._cacheConfig(directoryPath, configArray);
306
318
  }
307
319
 
@@ -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"]);
@@ -573,7 +573,7 @@ class CLIEngine {
573
573
  const linter = new Linter();
574
574
 
575
575
  /** @type {ConfigArray[]} */
576
- const lastConfigArrays = [];
576
+ const lastConfigArrays = [configArrayFactory.getConfigArrayForFile()];
577
577
 
578
578
  // Store private data.
579
579
  internalSlotsMap.set(this, {
@@ -734,7 +734,10 @@ class CLIEngine {
734
734
  try {
735
735
  fs.unlinkSync(cacheFilePath);
736
736
  } catch (error) {
737
- if (!error || error.code !== "ENOENT") {
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
  }
@@ -904,6 +907,13 @@ class CLIEngine {
904
907
  const { configArrayFactory, options } = internalSlotsMap.get(this);
905
908
  const absolutePath = path.resolve(options.cwd, filePath);
906
909
 
910
+ if (directoryExists(absolutePath)) {
911
+ throw Object.assign(
912
+ new Error("'filePath' should not be a directory path."),
913
+ { messageTemplate: "print-config-with-directory-path" }
914
+ );
915
+ }
916
+
907
917
  return configArrayFactory
908
918
  .getConfigArrayForFile(absolutePath)
909
919
  .extractConfig(absolutePath)
@@ -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
- processor: _ignore, // eslint-disable-line no-unused-vars
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
  //------------------------------------------------------------------------------
@@ -224,15 +224,16 @@ function loadPackageJSONConfigFile(filePath) {
224
224
  /**
225
225
  * Creates an error to notify about a missing config to extend from.
226
226
  * @param {string} configName The name of the missing config.
227
+ * @param {string} importerName The name of the config that imported the missing config
227
228
  * @returns {Error} The error object to throw
228
229
  * @private
229
230
  */
230
- function configMissingError(configName) {
231
+ function configMissingError(configName, importerName) {
231
232
  return Object.assign(
232
233
  new Error(`Failed to load config "${configName}" to extend from.`),
233
234
  {
234
235
  messageTemplate: "extend-config-missing",
235
- messageData: { configName }
236
+ messageData: { configName, importerName }
236
237
  }
237
238
  );
238
239
  }
@@ -525,6 +526,7 @@ class ConfigArrayFactory {
525
526
  env,
526
527
  extends: extend,
527
528
  globals,
529
+ noInlineConfig,
528
530
  parser: parserName,
529
531
  parserOptions,
530
532
  plugins: pluginList,
@@ -566,6 +568,7 @@ class ConfigArrayFactory {
566
568
  criteria: null,
567
569
  env,
568
570
  globals,
571
+ noInlineConfig,
569
572
  parser,
570
573
  parserOptions,
571
574
  plugins,
@@ -637,7 +640,7 @@ class ConfigArrayFactory {
637
640
  return this._loadConfigData(eslintAllPath, name);
638
641
  }
639
642
 
640
- throw configMissingError(extendName);
643
+ throw configMissingError(extendName, importerName);
641
644
  }
642
645
 
643
646
  /**
@@ -670,7 +673,7 @@ class ConfigArrayFactory {
670
673
  );
671
674
  }
672
675
 
673
- throw plugin.error || configMissingError(extendName);
676
+ throw plugin.error || configMissingError(extendName, importerPath);
674
677
  }
675
678
 
676
679
  /**
@@ -704,7 +707,7 @@ class ConfigArrayFactory {
704
707
  } catch (error) {
705
708
  /* istanbul ignore else */
706
709
  if (error && error.code === "MODULE_NOT_FOUND") {
707
- throw configMissingError(extendName);
710
+ throw configMissingError(extendName, importerPath);
708
711
  }
709
712
  throw error;
710
713
  }
@@ -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
- modules[`eslint-plugin-${plugin}`] = "latest";
101
+ const moduleName = naming.normalizePackageName(plugin, "eslint-plugin");
102
+
103
+ modules[moduleName] = "latest";
101
104
  }
102
105
  }
103
- if (config.extends && config.extends.indexOf("eslint:") === -1) {
104
- const moduleName = `eslint-config-${config.extends}`;
105
-
106
- modules[moduleName] = "latest";
107
- Object.assign(
108
- modules,
109
- getPeerDependencies(`${moduleName}@latest`)
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) {
@@ -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
- * Convienience wrapper around check().
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
- * Convienience wrapper around check().
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
@@ -526,6 +526,7 @@ function processCodePathToExit(analyzer, node) {
526
526
  break;
527
527
 
528
528
  case "CallExpression":
529
+ case "ImportExpression":
529
530
  case "MemberExpression":
530
531
  case "NewExpression":
531
532
  state.makeFirstThrowablePathInTryBlock();