eslint 6.1.0 → 6.3.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +8 -4
  3. package/conf/config-schema.js +2 -0
  4. package/conf/default-cli-options.js +1 -1
  5. package/conf/environments.js +72 -15
  6. package/lib/cli-engine/config-array/config-array.js +13 -0
  7. package/lib/cli-engine/config-array/extracted-config.js +22 -1
  8. package/lib/cli-engine/config-array-factory.js +4 -0
  9. package/lib/cli-engine/formatters/stylish.js +2 -1
  10. package/lib/init/config-initializer.js +29 -0
  11. package/lib/init/npm-utils.js +10 -10
  12. package/lib/linter/apply-disable-directives.js +17 -9
  13. package/lib/linter/code-path-analysis/code-path-analyzer.js +1 -0
  14. package/lib/linter/linter.js +70 -17
  15. package/lib/options.js +1 -1
  16. package/lib/rules/accessor-pairs.js +195 -35
  17. package/lib/rules/class-methods-use-this.js +10 -3
  18. package/lib/rules/dot-notation.js +6 -2
  19. package/lib/rules/func-call-spacing.js +30 -20
  20. package/lib/rules/func-name-matching.js +1 -0
  21. package/lib/rules/func-names.js +4 -0
  22. package/lib/rules/function-call-argument-newline.js +120 -0
  23. package/lib/rules/function-paren-newline.js +36 -24
  24. package/lib/rules/indent.js +13 -2
  25. package/lib/rules/index.js +1 -0
  26. package/lib/rules/new-cap.js +2 -1
  27. package/lib/rules/no-dupe-keys.js +1 -1
  28. package/lib/rules/no-duplicate-case.js +10 -8
  29. package/lib/rules/no-extra-bind.js +1 -0
  30. package/lib/rules/no-extra-boolean-cast.js +54 -5
  31. package/lib/rules/no-extra-parens.js +62 -23
  32. package/lib/rules/no-mixed-operators.js +48 -13
  33. package/lib/rules/no-restricted-syntax.js +2 -2
  34. package/lib/rules/no-self-assign.js +11 -1
  35. package/lib/rules/no-unused-vars.js +1 -1
  36. package/lib/rules/prefer-template.js +1 -10
  37. package/lib/rules/sort-keys.js +11 -3
  38. package/lib/rules/utils/ast-utils.js +19 -2
  39. package/lib/rules/yoda.js +12 -3
  40. package/lib/shared/types.js +4 -0
  41. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,3 +1,70 @@
1
+ v6.3.0 - August 30, 2019
2
+
3
+ * [`0acdefb`](https://github.com/eslint/eslint/commit/0acdefb97f35bb09db2910540c70dc377a01ad62) Chore: refactor code (#12113) (James George)
4
+ * [`52e2cf5`](https://github.com/eslint/eslint/commit/52e2cf50b35d57fb8466e0bcd0581eff1590fb4c) New: reportUnusedDisableDirectives in config (refs eslint/rfcs#22) (#12151) (Toru Nagashima)
5
+ * [`020f952`](https://github.com/eslint/eslint/commit/020f9526b618a191566acea3e17e20815d484c58) Update: enforceForSequenceExpressions to no-extra-parens (fixes #11916) (#12142) (Milos Djermanovic)
6
+ * [`aab1b84`](https://github.com/eslint/eslint/commit/aab1b840f9cffb2a76a5c9fe1852961be71dc184) Fix: reset to the default color (#12174) (Ricardo Gobbo de Souza)
7
+ * [`4009d39`](https://github.com/eslint/eslint/commit/4009d39aa59451510aa24911e758d664f216289a) Fix: yoda rule produces invalid autofix with preceding yield (#12166) (Milos Djermanovic)
8
+ * [`febb660`](https://github.com/eslint/eslint/commit/febb6605d350c936d64cb73e694482cfbb20b29c) Fix: no-extra-boolean-cast invalid autofix with yield before negation (#12164) (Milos Djermanovic)
9
+ * [`4c0b70b`](https://github.com/eslint/eslint/commit/4c0b70b869c16647f7af6de9d5c5479fc19f49db) New: support TypeScript at config initializer (fixes #11789) (#12172) (Pig Fang)
10
+ * [`94e39d9`](https://github.com/eslint/eslint/commit/94e39d9f782f45db86a079e07508d63040118ef1) Chore: use GitHub Actions (#12144) (Toru Nagashima)
11
+ * [`e88f305`](https://github.com/eslint/eslint/commit/e88f305df9d454868624c559fd93b981a680c215) Chore: support es2020 in fuzz (#12180) (薛定谔的猫)
12
+ * [`00d2c5b`](https://github.com/eslint/eslint/commit/00d2c5be9a89efd90135c4368a9589f33df3f7ba) Docs: corrected class extension example (#12176) (Marius M)
13
+ * [`31e5428`](https://github.com/eslint/eslint/commit/31e542819967b2aa1191e1abaa1c4a49fddbe3cf) Chore: Fix wrong error object keys in test files (#12162) (Milos Djermanovic)
14
+ * [`197f443`](https://github.com/eslint/eslint/commit/197f4432fca70a574028e5568c48afad12213224) Fix: func-name-matching crash on descriptor-like arguments (#12100) (Milos Djermanovic)
15
+ * [`644ce33`](https://github.com/eslint/eslint/commit/644ce3306748a33b74fc6a94be0267c2c9f19348) Fix: no-self-assign false positive with rest and spread in array (#12099) (Milos Djermanovic)
16
+ * [`a81d263`](https://github.com/eslint/eslint/commit/a81d2636ce41fb34d6826c2e9857814e11cb9c30) Fix: fix message of function-paren-newline (#12136) (Pig Fang)
17
+ * [`77f8ed1`](https://github.com/eslint/eslint/commit/77f8ed1ad9656c526217ce54a6717fa232d522c8) Chore: update blogpost template (#12154) (Toru Nagashima)
18
+ * [`6abc7b7`](https://github.com/eslint/eslint/commit/6abc7b72dfb824a372379708ca39340b2c7abc03) Docs: Document the exception in no-unsafe-negation (#12161) (Milos Djermanovic)
19
+
20
+ v6.2.2 - August 23, 2019
21
+
22
+ * [`0e0b784`](https://github.com/eslint/eslint/commit/0e0b784b922051c2a1d39dd8160382114b645800) Upgrade: espree@^6.1.1 (#12158) (Kevin Partington)
23
+ * [`04e859f`](https://github.com/eslint/eslint/commit/04e859f228d081efd3af6edb22563dbc775f8d1d) Sponsors: Sync README with website (ESLint Jenkins)
24
+ * [`34783d1`](https://github.com/eslint/eslint/commit/34783d10ff9b58a3c1e39a36e10864caeb9f66e0) Sponsors: Sync README with website (ESLint Jenkins)
25
+ * [`b809e72`](https://github.com/eslint/eslint/commit/b809e72221bc658e5a42bfd4b8723d3771571f9e) Docs: Update README team and sponsors (ESLint Jenkins)
26
+
27
+ v6.2.1 - August 20, 2019
28
+
29
+ * [`8c021b5`](https://github.com/eslint/eslint/commit/8c021b5917b3aa3c578ffe3972106d0a6bcf0838) Upgrade: eslint-utils 1.4.2 (#12131) (Toru Nagashima)
30
+ * [`e82388b`](https://github.com/eslint/eslint/commit/e82388bd87717430200ec554634cc08806e38d3c) Sponsors: Sync README with website (ESLint Jenkins)
31
+ * [`4aeeeed`](https://github.com/eslint/eslint/commit/4aeeeedb656ee3519ea82ebf0cb41ca801215046) Docs: update docs for ecmaVersion 2020 (#12120) (silverwind)
32
+ * [`6886148`](https://github.com/eslint/eslint/commit/6886148d1f528659ec3e125f61ef7a5f4c67556d) Docs: Add duplicate keys limitation to accessor-pairs (#12124) (Milos Djermanovic)
33
+
34
+ v6.2.0 - August 18, 2019
35
+
36
+ * [`fee6acb`](https://github.com/eslint/eslint/commit/fee6acbe13cecd4c028e681e185fc6a6d6ba9452) Update: support bigint and dynamic import (refs #11803) (#11983) (Toru Nagashima)
37
+ * [`afd8012`](https://github.com/eslint/eslint/commit/afd8012c2797f2f5bf3c360cb241ea2ba6e1a489) New: noInlineConfig setting (refs eslint/rfcs#22) (#12091) (Toru Nagashima)
38
+ * [`3d12378`](https://github.com/eslint/eslint/commit/3d12378221961439c27ddae0ecda9845ac575107) Update: Fix accessor-pairs to enforce pairs per property in literals (#12062) (Milos Djermanovic)
39
+ * [`8cd00b3`](https://github.com/eslint/eslint/commit/8cd00b308987e0db0bdb2e242bf13b2b07b350bd) New: function-call-argument-newline (#12024) (finico)
40
+ * [`30ebf92`](https://github.com/eslint/eslint/commit/30ebf929f60684520b1201c1adfd86214c19d614) Fix: prefer-template autofix produces syntax error with octal escapes (#12085) (Milos Djermanovic)
41
+ * [`13c3988`](https://github.com/eslint/eslint/commit/13c3988a4001ae368ea7b6c8d3dd0abfa7c6cf64) Fix: Check literal type explicitly in dot-notation (#12095) (Milos Djermanovic)
42
+ * [`3e5ceca`](https://github.com/eslint/eslint/commit/3e5ceca4d2284b55a2292a1d3de9aa4cdf6fa213) Fix: Handle empty string property names in getFunctionNameWithKind (#12104) (Milos Djermanovic)
43
+ * [`9a043ff`](https://github.com/eslint/eslint/commit/9a043ffbb864fc65baeb16fe5668435e3b7cfe34) Fix: no-duplicate-case false positives on Object.prototype keys (#12107) (Milos Djermanovic)
44
+ * [`fe631af`](https://github.com/eslint/eslint/commit/fe631afee59641876598d19b1935967099cc6fa0) Chore: minor typo fix (#12112) (James George)
45
+ * [`4cb7877`](https://github.com/eslint/eslint/commit/4cb78774f6cc687a3c8701462f8c7f7b587ecaf0) Fix: fix no-extra-parens ignores some nodes (#11909) (Pig Fang)
46
+ * [`2dc23b8`](https://github.com/eslint/eslint/commit/2dc23b81e54defbce7a70a7f26c2e4c7b692cf58) Update: fix no-dupe-keys false negatives on empty string names (#12069) (Milos Djermanovic)
47
+ * [`19ab666`](https://github.com/eslint/eslint/commit/19ab6666e8e4142a183bdee2be96e5bafbac0e21) Fix: yoda exceptRange false positives on empty string property names (#12071) (Milos Djermanovic)
48
+ * [`d642150`](https://github.com/eslint/eslint/commit/d642150fe016608e71a1df2a72960e915b3cfbad) Update: Check empty string property names in sort-keys (#12073) (Milos Djermanovic)
49
+ * [`acce6de`](https://github.com/eslint/eslint/commit/acce6de940e2b089ff5ba59e4518a54af1682d5e) Fix: class-methods-use-this reports 'undefined' names (#12103) (Milos Djermanovic)
50
+ * [`92ec2cb`](https://github.com/eslint/eslint/commit/92ec2cb1731b7b6e0ac66336d583fbb782504290) Fix: Allow bind call with a single spread element in no-extra-bind (#12088) (Milos Djermanovic)
51
+ * [`bfdb0c9`](https://github.com/eslint/eslint/commit/bfdb0c97003fc0e045aa6ed10b177c35305a6e46) Fix: no-extra-boolean-cast invalid autofix for Boolean() without args (#12076) (Milos Djermanovic)
52
+ * [`34ccc0c`](https://github.com/eslint/eslint/commit/34ccc0cd81f495190e585c6efa8ae233d45bd3ed) Chore: Remove TDZ scope type condition from no-unused-vars (#12055) (Milos Djermanovic)
53
+ * [`01d38ce`](https://github.com/eslint/eslint/commit/01d38ce2faf0abbc9dd5d25694baeee131036165) Docs: Remove TDZ scope from the scope manager interface documentation (#12054) (Milos Djermanovic)
54
+ * [`1aff8fc`](https://github.com/eslint/eslint/commit/1aff8fc4f9394cd9126654a55f7f3a43ab1cf8f0) Update: warn about mixing ternary and logical operators (fixes #11704) (#12001) (Karthik Priyadarshan)
55
+ * [`11be2f8`](https://github.com/eslint/eslint/commit/11be2f8513bd61499f6247392a33ac0a26901c90) Docs: do not recommend global-installed usage (#12016) (薛定谔的猫)
56
+ * [`cf31dab`](https://github.com/eslint/eslint/commit/cf31dab5d5982151e0cfcc32879e69a83180ec70) Fix: no-restricted-syntax - correct the schema (#12051) (Brad Zacher)
57
+ * [`fbec99e`](https://github.com/eslint/eslint/commit/fbec99ea3e39316791685652c66e522d698f52d8) Update: fix class-methods-use-this false negatives with exceptMethods (#12077) (Milos Djermanovic)
58
+ * [`fb08b7c`](https://github.com/eslint/eslint/commit/fb08b7c9d28bc68864eb940e26df274059228b6a) Docs: Remove readonly/writable global logic from no-undef (fixes #11963) (#12053) (Milos Djermanovic)
59
+ * [`5b5934b`](https://github.com/eslint/eslint/commit/5b5934b9513f9114f5bf8e12ff4f4981590d64d3) Sponsors: Sync README with website (ESLint Jenkins)
60
+ * [`9156760`](https://github.com/eslint/eslint/commit/915676022a100ae5dba788fa3329d34b3c1f18d3) Sponsors: Sync README with website (ESLint Jenkins)
61
+ * [`f5e0cc4`](https://github.com/eslint/eslint/commit/f5e0cc40795f175692acb05daaadb91e9e5ae5d3) Update: Check computed method keys in no-extra-parens (#11973) (Milos Djermanovic)
62
+ * [`d961438`](https://github.com/eslint/eslint/commit/d9614388df8cfb977842ed7ac4725d76a3e05df3) Docs: Fix Incorrect Documentation (#12045) (Michael Miceli)
63
+ * [`887d08c`](https://github.com/eslint/eslint/commit/887d08c244e32f1fc18359e63380e2cdb0cb3797) Sponsors: Sync README with website (ESLint Jenkins)
64
+ * [`d90183f`](https://github.com/eslint/eslint/commit/d90183ff6757cff854f4ca4d25b835143dfb4b21) Docs: add a case to func-names (#12038) (Chiawen Chen)
65
+ * [`8a5b62d`](https://github.com/eslint/eslint/commit/8a5b62de2ae574f416c0f8ad91205da9b1837275) Docs: no use eslint.linter in code example (#12037) (薛定谔的猫)
66
+ * [`5831767`](https://github.com/eslint/eslint/commit/58317673210e48be3975e317c2c566fae155c94f) Update: report location of func-names (fixes #12022) (#12028) (Pig Fang)
67
+
1
68
  v6.1.0 - July 20, 2019
2
69
 
3
70
  * [`8f86cca`](https://github.com/eslint/eslint/commit/8f86ccaa89daf10123370868c5dcb48c1fcbef7d) Upgrade: eslint-scope@^5.0.0 (#12011) (Kevin Partington)
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![NPM version][npm-image]][npm-url]
2
2
  [![Build Status](https://dev.azure.com/eslint/eslint/_apis/build/status/eslint.eslint?branchName=master)](https://dev.azure.com/eslint/eslint/_build/latest?definitionId=1&branchName=master)
3
+ [![Build Status](https://github.com/eslint/eslint/workflows/CI/badge.svg)](https://github.com/eslint/eslint/actions)
3
4
  [![Downloads][downloads-image]][downloads-url]
4
5
  [![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=282608)](https://www.bountysource.com/trackers/282608-eslint?utm_source=282608&utm_medium=shield&utm_campaign=TRACKER_BADGE)
5
6
  [![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -59,8 +60,6 @@ After that, you can run ESLint on any file or directory like this:
59
60
  $ ./node_modules/.bin/eslint yourfile.js
60
61
  ```
61
62
 
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
63
  ## <a name="configuration"></a>Configuration
65
64
 
66
65
  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 +245,11 @@ The people who review and fix bugs and help triage issues.
246
245
  <img src="https://github.com/g-plane.png?s=75" width="75" height="75"><br />
247
246
  Pig Fang
248
247
  </a>
248
+ </td><td align="center" valign="top" width="11%">
249
+ <a href="https://github.com/mdjermanovic">
250
+ <img src="https://github.com/mdjermanovic.png?s=75" width="75" height="75"><br />
251
+ Milos Djermanovic
252
+ </a>
249
253
  </td></tr></tbody></table>
250
254
 
251
255
 
@@ -258,9 +262,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
258
262
  <!-- NOTE: This section is autogenerated. Do not manually edit.-->
259
263
  <!--sponsorsstart-->
260
264
  <h3>Gold Sponsors</h3>
261
- <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>
265
+ <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>
262
266
  <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>
263
- <p><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> <a href="https://faithlife.com/ref/about"><img src="https://images.opencollective.com/faithlife/534b832/logo.png" alt="Faithlife" height="32"></a></p>
267
+ <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
268
  <!--sponsorsend-->
265
269
 
266
270
  ## <a name="technology-sponsors"></a>Technology Sponsors
@@ -20,6 +20,8 @@ const baseConfigProperties = {
20
20
  processor: { type: "string" },
21
21
  rules: { type: "object" },
22
22
  settings: { type: "object" },
23
+ noInlineConfig: { type: "boolean" },
24
+ reportUnusedDisableDirectives: { type: "boolean" },
23
25
 
24
26
  ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
25
27
  };
@@ -26,6 +26,6 @@ module.exports = {
26
26
  cacheFile: ".eslintcache",
27
27
  fix: false,
28
28
  allowInlineConfig: true,
29
- reportUnusedDisableDirectives: false,
29
+ reportUnusedDisableDirectives: void 0,
30
30
  globInputPaths: true
31
31
  };
@@ -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
  }
@@ -54,10 +54,12 @@ 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.
60
61
  * @property {string|undefined} processor The processor name to refer plugin's processor.
62
+ * @property {boolean|undefined} reportUnusedDisableDirectives The flag to report unused `eslint-disable` comments.
61
63
  * @property {boolean|undefined} root The flag to express root.
62
64
  * @property {Record<string, RuleConf>|undefined} rules The rule settings
63
65
  * @property {Object|undefined} settings The shared settings.
@@ -250,6 +252,17 @@ function createConfig(instance, indices) {
250
252
  config.processor = element.processor;
251
253
  }
252
254
 
255
+ // Adopt the noInlineConfig which was found at first.
256
+ if (config.noInlineConfig === void 0 && element.noInlineConfig !== void 0) {
257
+ config.noInlineConfig = element.noInlineConfig;
258
+ config.configNameOfNoInlineConfig = element.name;
259
+ }
260
+
261
+ // Adopt the reportUnusedDisableDirectives which was found at first.
262
+ if (config.reportUnusedDisableDirectives === void 0 && element.reportUnusedDisableDirectives !== void 0) {
263
+ config.reportUnusedDisableDirectives = element.reportUnusedDisableDirectives;
264
+ }
265
+
253
266
  // Merge others.
254
267
  mergeWithoutOverwrite(config.env, element.env);
255
268
  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}
@@ -65,6 +77,12 @@ class ExtractedConfig {
65
77
  */
66
78
  this.processor = null;
67
79
 
80
+ /**
81
+ * The flag that reports unused `eslint-disable` directive comments.
82
+ * @type {boolean|undefined}
83
+ */
84
+ this.reportUnusedDisableDirectives = void 0;
85
+
68
86
  /**
69
87
  * Rule settings.
70
88
  * @type {Record<string, [SeverityConf, ...any[]]>}
@@ -84,7 +102,10 @@ class ExtractedConfig {
84
102
  */
85
103
  toCompatibleObjectAsConfigFileContent() {
86
104
  const {
87
- processor: _ignore, // eslint-disable-line no-unused-vars
105
+ /* eslint-disable no-unused-vars */
106
+ configNameOfNoInlineConfig: _ignore1,
107
+ processor: _ignore2,
108
+ /* eslint-enable no-unused-vars */
88
109
  ...config
89
110
  } = this;
90
111
 
@@ -526,10 +526,12 @@ 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,
532
533
  processor,
534
+ reportUnusedDisableDirectives,
533
535
  root,
534
536
  rules,
535
537
  settings,
@@ -567,10 +569,12 @@ class ConfigArrayFactory {
567
569
  criteria: null,
568
570
  env,
569
571
  globals,
572
+ noInlineConfig,
570
573
  parser,
571
574
  parserOptions,
572
575
  plugins,
573
576
  processor,
577
+ reportUnusedDisableDirectives,
574
578
  root,
575
579
  rules,
576
580
  settings
@@ -96,5 +96,6 @@ module.exports = function(results) {
96
96
  }
97
97
  }
98
98
 
99
- return total > 0 ? output : "";
99
+ // Resets output color, for prevent change on top level
100
+ return total > 0 ? chalk.reset(output) : "";
100
101
  };
@@ -120,6 +120,12 @@ function getModulesList(config, installESLint) {
120
120
  }
121
121
  }
122
122
 
123
+ const parser = config.parser || (config.parserOptions && config.parserOptions.parser);
124
+
125
+ if (parser) {
126
+ modules[parser] = "latest";
127
+ }
128
+
123
129
  if (installESLint === false) {
124
130
  delete modules.eslint;
125
131
  } else {
@@ -291,6 +297,20 @@ function processAnswers(answers) {
291
297
  config.extends.push("plugin:vue/essential");
292
298
  }
293
299
 
300
+ if (answers.typescript) {
301
+ if (answers.framework === "vue") {
302
+ config.parserOptions.parser = "@typescript-eslint/parser";
303
+ } else {
304
+ config.parser = "@typescript-eslint/parser";
305
+ }
306
+
307
+ if (Array.isArray(config.plugins)) {
308
+ config.plugins.push("@typescript-eslint");
309
+ } else {
310
+ config.plugins = ["@typescript-eslint"];
311
+ }
312
+ }
313
+
294
314
  // setup rules based on problems/style enforcement preferences
295
315
  if (answers.purpose === "problems") {
296
316
  config.extends.unshift("eslint:recommended");
@@ -306,6 +326,9 @@ function processAnswers(answers) {
306
326
  config = autoconfig.extendFromRecommended(config);
307
327
  }
308
328
  }
329
+ if (answers.typescript && config.extends.includes("eslint:recommended")) {
330
+ config.extends.push("plugin:@typescript-eslint/eslint-recommended");
331
+ }
309
332
 
310
333
  // normalize extends
311
334
  if (config.extends.length === 0) {
@@ -465,6 +488,12 @@ function promptUser() {
465
488
  { name: "None of these", value: "none" }
466
489
  ]
467
490
  },
491
+ {
492
+ type: "confirm",
493
+ name: "typescript",
494
+ message: "Does your project use TypeScript?",
495
+ default: false
496
+ },
468
497
  {
469
498
  type: "checkbox",
470
499
  name: "env",
@@ -98,7 +98,7 @@ function fetchPeerDependencies(packageName) {
98
98
  * and values are booleans indicating installation.
99
99
  */
100
100
  function check(packages, opt) {
101
- let deps = [];
101
+ const deps = new Set();
102
102
  const pkgJson = (opt) ? findPackageJson(opt.startDir) : findPackageJson();
103
103
  let fileJson;
104
104
 
@@ -119,14 +119,14 @@ function check(packages, opt) {
119
119
  throw error;
120
120
  }
121
121
 
122
- if (opt.devDependencies && typeof fileJson.devDependencies === "object") {
123
- deps = deps.concat(Object.keys(fileJson.devDependencies));
124
- }
125
- if (opt.dependencies && typeof fileJson.dependencies === "object") {
126
- deps = deps.concat(Object.keys(fileJson.dependencies));
127
- }
122
+ ["dependencies", "devDependencies"].forEach(key => {
123
+ if (opt[key] && typeof fileJson[key] === "object") {
124
+ Object.keys(fileJson[key]).forEach(dep => deps.add(dep));
125
+ }
126
+ });
127
+
128
128
  return packages.reduce((status, pkg) => {
129
- status[pkg] = deps.indexOf(pkg) !== -1;
129
+ status[pkg] = deps.has(pkg);
130
130
  return status;
131
131
  }, {});
132
132
  }
@@ -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
@@ -93,7 +93,7 @@ function applyDirectives(options) {
93
93
  : "Unused eslint-disable directive (no problems were reported).",
94
94
  line: directive.unprocessedDirective.line,
95
95
  column: directive.unprocessedDirective.column,
96
- severity: 2,
96
+ severity: options.reportUnusedDisableDirectives === "warn" ? 1 : 2,
97
97
  nodeType: null
98
98
  }));
99
99
 
@@ -114,17 +114,17 @@ function applyDirectives(options) {
114
114
  * comment for two different rules is represented as two directives).
115
115
  * @param {{ruleId: (string|null), line: number, column: number}[]} options.problems
116
116
  * A list of problems reported by rules, sorted by increasing location in the file, with one-based columns.
117
- * @param {boolean} options.reportUnusedDisableDirectives If `true`, adds additional problems for unused directives
117
+ * @param {"off" | "warn" | "error"} options.reportUnusedDisableDirectives If `"warn"` or `"error"`, adds additional problems for unused directives
118
118
  * @returns {{ruleId: (string|null), line: number, column: number}[]}
119
119
  * A list of reported problems that were not disabled by the directive comments.
120
120
  */
121
- module.exports = options => {
122
- const blockDirectives = options.directives
121
+ module.exports = ({ directives, problems, reportUnusedDisableDirectives = "off" }) => {
122
+ const blockDirectives = directives
123
123
  .filter(directive => directive.type === "disable" || directive.type === "enable")
124
124
  .map(directive => Object.assign({}, directive, { unprocessedDirective: directive }))
125
125
  .sort(compareLocations);
126
126
 
127
- const lineDirectives = lodash.flatMap(options.directives, directive => {
127
+ const lineDirectives = lodash.flatMap(directives, directive => {
128
128
  switch (directive.type) {
129
129
  case "disable":
130
130
  case "enable":
@@ -147,10 +147,18 @@ module.exports = options => {
147
147
  }
148
148
  }).sort(compareLocations);
149
149
 
150
- const blockDirectivesResult = applyDirectives({ problems: options.problems, directives: blockDirectives });
151
- const lineDirectivesResult = applyDirectives({ problems: blockDirectivesResult.problems, directives: lineDirectives });
152
-
153
- return options.reportUnusedDisableDirectives
150
+ const blockDirectivesResult = applyDirectives({
151
+ problems,
152
+ directives: blockDirectives,
153
+ reportUnusedDisableDirectives
154
+ });
155
+ const lineDirectivesResult = applyDirectives({
156
+ problems: blockDirectivesResult.problems,
157
+ directives: lineDirectives,
158
+ reportUnusedDisableDirectives
159
+ });
160
+
161
+ return reportUnusedDisableDirectives !== "off"
154
162
  ? lineDirectivesResult.problems
155
163
  .concat(blockDirectivesResult.unusedDisableDirectives)
156
164
  .concat(lineDirectivesResult.unusedDisableDirectives)
@@ -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();