eslint 6.2.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +8 -2
- package/conf/config-schema.js +1 -0
- package/conf/default-cli-options.js +1 -1
- package/lib/cli-engine/config-array/config-array.js +6 -0
- package/lib/cli-engine/config-array/extracted-config.js +6 -0
- package/lib/cli-engine/config-array/override-tester.js +2 -2
- package/lib/cli-engine/config-array-factory.js +2 -0
- package/lib/cli-engine/formatters/stylish.js +2 -1
- package/lib/init/config-initializer.js +29 -0
- package/lib/init/npm-utils.js +8 -8
- package/lib/linter/apply-disable-directives.js +17 -9
- package/lib/linter/linter.js +23 -3
- package/lib/options.js +1 -1
- package/lib/rules/accessor-pairs.js +51 -11
- package/lib/rules/computed-property-spacing.js +18 -1
- package/lib/rules/default-param-last.js +61 -0
- package/lib/rules/eqeqeq.js +7 -19
- package/lib/rules/func-name-matching.js +1 -0
- package/lib/rules/function-paren-newline.js +2 -2
- package/lib/rules/indent.js +16 -6
- package/lib/rules/index.js +3 -0
- package/lib/rules/no-extra-boolean-cast.js +12 -2
- package/lib/rules/no-extra-parens.js +8 -1
- package/lib/rules/no-import-assign.js +238 -0
- package/lib/rules/no-lone-blocks.js +6 -1
- package/lib/rules/no-obj-calls.js +29 -9
- package/lib/rules/no-octal-escape.js +14 -8
- package/lib/rules/no-self-assign.js +17 -6
- package/lib/rules/no-sequences.js +2 -2
- package/lib/rules/no-unsafe-negation.js +2 -10
- package/lib/rules/object-curly-spacing.js +1 -1
- package/lib/rules/object-shorthand.js +35 -9
- package/lib/rules/prefer-regex-literals.js +125 -0
- package/lib/rules/quotes.js +6 -0
- package/lib/rules/space-before-function-paren.js +12 -1
- package/lib/rules/space-in-parens.js +77 -71
- package/lib/rules/yoda.js +11 -2
- package/lib/shared/types.js +2 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,69 @@
|
|
1
|
+
v6.4.0 - September 13, 2019
|
2
|
+
|
3
|
+
* [`e915fff`](https://github.com/eslint/eslint/commit/e915fffb6089a23ff1cae926cc607f9b87dc1819) Docs: Improve examples and clarify default option (#12067) (Yuping Zuo)
|
4
|
+
* [`540296f`](https://github.com/eslint/eslint/commit/540296fcecd232a09dc873a5a22f5839b59b7842) Update: enforceForClassMembers option to accessor-pairs (fixes #12063) (#12192) (Milos Djermanovic)
|
5
|
+
* [`d3c2334`](https://github.com/eslint/eslint/commit/d3c2334646eae9287d5be9e457d041e445efb512) Update: flag nested block with declaration as error (#12193) (David Waller)
|
6
|
+
* [`b2498d2`](https://github.com/eslint/eslint/commit/b2498d284b9c30ed1543429c2f45d9014e12fe22) Update: Fix handling of property names in no-self-assign (#12105) (Milos Djermanovic)
|
7
|
+
* [`1ee61b0`](https://github.com/eslint/eslint/commit/1ee61b06715fcc750be2c923034a1e59ba663287) Update: enforceForClassMembers computed-property-spacing (fixes #12049) (#12214) (Milos Djermanovic)
|
8
|
+
* [`520c922`](https://github.com/eslint/eslint/commit/520c92270eed6e90c1a796e8af275980f01705e0) Docs: Added naming convention details to plugin usage (#12202) (Henrique Barcelos)
|
9
|
+
* [`f826eab`](https://github.com/eslint/eslint/commit/f826eabbeecddb047f58f4e7308a14c18148d369) Fix: Allow line comment exception in object-curly-spacing (fixes #11902) (#12216) (Milos Djermanovic)
|
10
|
+
* [`db2a29b`](https://github.com/eslint/eslint/commit/db2a29beb0fa28183f65bf9e659c66c03a8918b5) Update: indentation of comment followed by semicolon (fixes #12232) (#12243) (Kai Cataldo)
|
11
|
+
* [`ae17d1c`](https://github.com/eslint/eslint/commit/ae17d1ca59dd466aa64da0680ec2453c2dc3b80d) Fix: no-sequences is reporting incorrect locations (#12241) (Milos Djermanovic)
|
12
|
+
* [`365331a`](https://github.com/eslint/eslint/commit/365331a42e22af5a77ac9cfa9673d6a8f653eb5a) Fix: object-shorthand providing invalid fixes for typescript (#12260) (Brad Zacher)
|
13
|
+
* [`1c921c6`](https://github.com/eslint/eslint/commit/1c921c6dfd7ddfb0308c8103e53d32c1241475f0) New: add no-import-assign (fixes #12237) (#12252) (Toru Nagashima)
|
14
|
+
* [`3be04fd`](https://github.com/eslint/eslint/commit/3be04fd6a4e7b3f5a5ecb845a29cf29b71fe2dfb) New: Add prefer-regex-literals rule (fixes #12238) (#12254) (Milos Djermanovic)
|
15
|
+
* [`37c0fde`](https://github.com/eslint/eslint/commit/37c0fdeb87b92a0b779b125adf45535b79b65757) Update: Report global Atomics calls in no-obj-calls (fixes #12234) (#12258) (Milos Djermanovic)
|
16
|
+
* [`985c9e5`](https://github.com/eslint/eslint/commit/985c9e5eba351965a8a1491a41dbdcc78154b8f4) Fix: space-before-function-paren autofix removes comments (fixes #12259) (#12264) (Milos Djermanovic)
|
17
|
+
* [`01da7d0`](https://github.com/eslint/eslint/commit/01da7d04c4e5a7376cf241ec02db7971726a1bf9) Fix: eqeqeq rule reports incorrect locations (#12265) (Milos Djermanovic)
|
18
|
+
* [`319e4d8`](https://github.com/eslint/eslint/commit/319e4d8386ea846928f0f906c251b46043a53491) Docs: adding finally example (#12256) (Jens Melgaard)
|
19
|
+
* [`d52328f`](https://github.com/eslint/eslint/commit/d52328f012f3704c7d1ce39427e63f80531c7979) Docs: fix no-sequences `with` examples (#12239) (Milos Djermanovic)
|
20
|
+
* [`a41fdc0`](https://github.com/eslint/eslint/commit/a41fdc07404a7675d14183fab245fb8f49dcb858) Fix: Remove autofixer for no-unsafe-negation (#12157) (Milos Djermanovic)
|
21
|
+
* [`e38f5fd`](https://github.com/eslint/eslint/commit/e38f5fdfc786363a3eae642f1a69a8725600aa61) Update: fix no-octal-escape false negatives after \0 (#12079) (Milos Djermanovic)
|
22
|
+
* [`9418fbe`](https://github.com/eslint/eslint/commit/9418fbe0eb31cace3debe27b620709628df2fad7) Sponsors: Sync README with website (ESLint Jenkins)
|
23
|
+
* [`acc5ec5`](https://github.com/eslint/eslint/commit/acc5ec5082aed466a29899f651e6767b39155aec) Sponsors: Sync README with website (ESLint Jenkins)
|
24
|
+
* [`460c5ad`](https://github.com/eslint/eslint/commit/460c5ad176eaf39ff579cd96b3bcbe0539093f8f) Sponsors: Sync README with website (ESLint Jenkins)
|
25
|
+
* [`0313441`](https://github.com/eslint/eslint/commit/0313441d016c8aa0674c135f9da67a676e766ec5) New: add rule default-param-last (fixes #11361) (#12188) (Chiawen Chen)
|
26
|
+
* [`7621f5d`](https://github.com/eslint/eslint/commit/7621f5d2aa7d87e798b75ca47d6889c280597e99) Update: add more specific linting messages to space-in-parens (#11121) (Che Fisher)
|
27
|
+
* [`21eb904`](https://github.com/eslint/eslint/commit/21eb9044135c01b6c12188517bba840614483fc6) Fix: basePath of OverrideTester (fixes #12032) (#12205) (Toru Nagashima)
|
28
|
+
* [`86e5e65`](https://github.com/eslint/eslint/commit/86e5e657ea3fbf12b10524abcbc197afd215a060) Sponsors: Sync README with website (ESLint Jenkins)
|
29
|
+
* [`2b1a13f`](https://github.com/eslint/eslint/commit/2b1a13fa0de8360586857f3ced8da514c971297d) Fix: no-extra-boolean-cast reports wrong negation node (fixes #11324) (#12197) (Milos Djermanovic)
|
30
|
+
* [`ba8c2aa`](https://github.com/eslint/eslint/commit/ba8c2aa0154561fbeca33db0343cb39a7fbd9b4f) Sponsors: Sync README with website (ESLint Jenkins)
|
31
|
+
* [`a0a9746`](https://github.com/eslint/eslint/commit/a0a9746724ccd22c721ddc1b25c566aa9acea154) Docs: Fix link in no-irregular-whitespace.md (#12196) (Timo Tijhof)
|
32
|
+
* [`e10eeba`](https://github.com/eslint/eslint/commit/e10eebab4abd193dee697c4de7fb2d95bbab2d8c) Fix: quotes autofix produces syntax error with octal escape sequences (#12118) (Milos Djermanovic)
|
33
|
+
|
34
|
+
v6.3.0 - August 30, 2019
|
35
|
+
|
36
|
+
* [`0acdefb`](https://github.com/eslint/eslint/commit/0acdefb97f35bb09db2910540c70dc377a01ad62) Chore: refactor code (#12113) (James George)
|
37
|
+
* [`52e2cf5`](https://github.com/eslint/eslint/commit/52e2cf50b35d57fb8466e0bcd0581eff1590fb4c) New: reportUnusedDisableDirectives in config (refs eslint/rfcs#22) (#12151) (Toru Nagashima)
|
38
|
+
* [`020f952`](https://github.com/eslint/eslint/commit/020f9526b618a191566acea3e17e20815d484c58) Update: enforceForSequenceExpressions to no-extra-parens (fixes #11916) (#12142) (Milos Djermanovic)
|
39
|
+
* [`aab1b84`](https://github.com/eslint/eslint/commit/aab1b840f9cffb2a76a5c9fe1852961be71dc184) Fix: reset to the default color (#12174) (Ricardo Gobbo de Souza)
|
40
|
+
* [`4009d39`](https://github.com/eslint/eslint/commit/4009d39aa59451510aa24911e758d664f216289a) Fix: yoda rule produces invalid autofix with preceding yield (#12166) (Milos Djermanovic)
|
41
|
+
* [`febb660`](https://github.com/eslint/eslint/commit/febb6605d350c936d64cb73e694482cfbb20b29c) Fix: no-extra-boolean-cast invalid autofix with yield before negation (#12164) (Milos Djermanovic)
|
42
|
+
* [`4c0b70b`](https://github.com/eslint/eslint/commit/4c0b70b869c16647f7af6de9d5c5479fc19f49db) New: support TypeScript at config initializer (fixes #11789) (#12172) (Pig Fang)
|
43
|
+
* [`94e39d9`](https://github.com/eslint/eslint/commit/94e39d9f782f45db86a079e07508d63040118ef1) Chore: use GitHub Actions (#12144) (Toru Nagashima)
|
44
|
+
* [`e88f305`](https://github.com/eslint/eslint/commit/e88f305df9d454868624c559fd93b981a680c215) Chore: support es2020 in fuzz (#12180) (薛定谔的猫)
|
45
|
+
* [`00d2c5b`](https://github.com/eslint/eslint/commit/00d2c5be9a89efd90135c4368a9589f33df3f7ba) Docs: corrected class extension example (#12176) (Marius M)
|
46
|
+
* [`31e5428`](https://github.com/eslint/eslint/commit/31e542819967b2aa1191e1abaa1c4a49fddbe3cf) Chore: Fix wrong error object keys in test files (#12162) (Milos Djermanovic)
|
47
|
+
* [`197f443`](https://github.com/eslint/eslint/commit/197f4432fca70a574028e5568c48afad12213224) Fix: func-name-matching crash on descriptor-like arguments (#12100) (Milos Djermanovic)
|
48
|
+
* [`644ce33`](https://github.com/eslint/eslint/commit/644ce3306748a33b74fc6a94be0267c2c9f19348) Fix: no-self-assign false positive with rest and spread in array (#12099) (Milos Djermanovic)
|
49
|
+
* [`a81d263`](https://github.com/eslint/eslint/commit/a81d2636ce41fb34d6826c2e9857814e11cb9c30) Fix: fix message of function-paren-newline (#12136) (Pig Fang)
|
50
|
+
* [`77f8ed1`](https://github.com/eslint/eslint/commit/77f8ed1ad9656c526217ce54a6717fa232d522c8) Chore: update blogpost template (#12154) (Toru Nagashima)
|
51
|
+
* [`6abc7b7`](https://github.com/eslint/eslint/commit/6abc7b72dfb824a372379708ca39340b2c7abc03) Docs: Document the exception in no-unsafe-negation (#12161) (Milos Djermanovic)
|
52
|
+
|
53
|
+
v6.2.2 - August 23, 2019
|
54
|
+
|
55
|
+
* [`0e0b784`](https://github.com/eslint/eslint/commit/0e0b784b922051c2a1d39dd8160382114b645800) Upgrade: espree@^6.1.1 (#12158) (Kevin Partington)
|
56
|
+
* [`04e859f`](https://github.com/eslint/eslint/commit/04e859f228d081efd3af6edb22563dbc775f8d1d) Sponsors: Sync README with website (ESLint Jenkins)
|
57
|
+
* [`34783d1`](https://github.com/eslint/eslint/commit/34783d10ff9b58a3c1e39a36e10864caeb9f66e0) Sponsors: Sync README with website (ESLint Jenkins)
|
58
|
+
* [`b809e72`](https://github.com/eslint/eslint/commit/b809e72221bc658e5a42bfd4b8723d3771571f9e) Docs: Update README team and sponsors (ESLint Jenkins)
|
59
|
+
|
60
|
+
v6.2.1 - August 20, 2019
|
61
|
+
|
62
|
+
* [`8c021b5`](https://github.com/eslint/eslint/commit/8c021b5917b3aa3c578ffe3972106d0a6bcf0838) Upgrade: eslint-utils 1.4.2 (#12131) (Toru Nagashima)
|
63
|
+
* [`e82388b`](https://github.com/eslint/eslint/commit/e82388bd87717430200ec554634cc08806e38d3c) Sponsors: Sync README with website (ESLint Jenkins)
|
64
|
+
* [`4aeeeed`](https://github.com/eslint/eslint/commit/4aeeeedb656ee3519ea82ebf0cb41ca801215046) Docs: update docs for ecmaVersion 2020 (#12120) (silverwind)
|
65
|
+
* [`6886148`](https://github.com/eslint/eslint/commit/6886148d1f528659ec3e125f61ef7a5f4c67556d) Docs: Add duplicate keys limitation to accessor-pairs (#12124) (Milos Djermanovic)
|
66
|
+
|
1
67
|
v6.2.0 - August 18, 2019
|
2
68
|
|
3
69
|
* [`fee6acb`](https://github.com/eslint/eslint/commit/fee6acbe13cecd4c028e681e185fc6a6d6ba9452) Update: support bigint and dynamic import (refs #11803) (#11983) (Toru Nagashima)
|
package/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
[![NPM version][npm-image]][npm-url]
|
2
2
|
[](https://dev.azure.com/eslint/eslint/_build/latest?definitionId=1&branchName=master)
|
3
|
+
[](https://github.com/eslint/eslint/actions)
|
3
4
|
[![Downloads][downloads-image]][downloads-url]
|
4
5
|
[](https://www.bountysource.com/trackers/282608-eslint?utm_source=282608&utm_medium=shield&utm_campaign=TRACKER_BADGE)
|
5
6
|
[](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -244,6 +245,11 @@ The people who review and fix bugs and help triage issues.
|
|
244
245
|
<img src="https://github.com/g-plane.png?s=75" width="75" height="75"><br />
|
245
246
|
Pig Fang
|
246
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>
|
247
253
|
</td></tr></tbody></table>
|
248
254
|
|
249
255
|
|
@@ -256,9 +262,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
256
262
|
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
257
263
|
<!--sponsorsstart-->
|
258
264
|
<h3>Gold Sponsors</h3>
|
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/
|
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/d327d66/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
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>
|
261
|
-
<p><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://
|
267
|
+
<p><a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://moneypug.co.uk/"><img src="https://images.opencollective.com/moneypug/45f8d53/logo.png" alt="MONEYPUG" 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://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" 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>
|
262
268
|
<!--sponsorsend-->
|
263
269
|
|
264
270
|
## <a name="technology-sponsors"></a>Technology Sponsors
|
package/conf/config-schema.js
CHANGED
@@ -21,6 +21,7 @@ const baseConfigProperties = {
|
|
21
21
|
rules: { type: "object" },
|
22
22
|
settings: { type: "object" },
|
23
23
|
noInlineConfig: { type: "boolean" },
|
24
|
+
reportUnusedDisableDirectives: { type: "boolean" },
|
24
25
|
|
25
26
|
ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
|
26
27
|
};
|
@@ -59,6 +59,7 @@ const { ExtractedConfig } = require("./extracted-config");
|
|
59
59
|
* @property {Object|undefined} parserOptions The parser options.
|
60
60
|
* @property {Record<string, DependentPlugin>|undefined} plugins The plugin loaders.
|
61
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.
|
62
63
|
* @property {boolean|undefined} root The flag to express root.
|
63
64
|
* @property {Record<string, RuleConf>|undefined} rules The rule settings
|
64
65
|
* @property {Object|undefined} settings The shared settings.
|
@@ -257,6 +258,11 @@ function createConfig(instance, indices) {
|
|
257
258
|
config.configNameOfNoInlineConfig = element.name;
|
258
259
|
}
|
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
|
+
|
260
266
|
// Merge others.
|
261
267
|
mergeWithoutOverwrite(config.env, element.env);
|
262
268
|
mergeWithoutOverwrite(config.globals, element.globals);
|
@@ -77,6 +77,12 @@ class ExtractedConfig {
|
|
77
77
|
*/
|
78
78
|
this.processor = null;
|
79
79
|
|
80
|
+
/**
|
81
|
+
* The flag that reports unused `eslint-disable` directive comments.
|
82
|
+
* @type {boolean|undefined}
|
83
|
+
*/
|
84
|
+
this.reportUnusedDisableDirectives = void 0;
|
85
|
+
|
80
86
|
/**
|
81
87
|
* Rule settings.
|
82
88
|
* @type {Record<string, [SeverityConf, ...any[]]>}
|
@@ -125,10 +125,10 @@ class OverrideTester {
|
|
125
125
|
*/
|
126
126
|
static and(a, b) {
|
127
127
|
if (!b) {
|
128
|
-
return a;
|
128
|
+
return a && new OverrideTester(a.patterns, a.basePath);
|
129
129
|
}
|
130
130
|
if (!a) {
|
131
|
-
return b;
|
131
|
+
return new OverrideTester(b.patterns, b.basePath);
|
132
132
|
}
|
133
133
|
|
134
134
|
assert.strictEqual(a.basePath, b.basePath);
|
@@ -531,6 +531,7 @@ class ConfigArrayFactory {
|
|
531
531
|
parserOptions,
|
532
532
|
plugins: pluginList,
|
533
533
|
processor,
|
534
|
+
reportUnusedDisableDirectives,
|
534
535
|
root,
|
535
536
|
rules,
|
536
537
|
settings,
|
@@ -573,6 +574,7 @@ class ConfigArrayFactory {
|
|
573
574
|
parserOptions,
|
574
575
|
plugins,
|
575
576
|
processor,
|
577
|
+
reportUnusedDisableDirectives,
|
576
578
|
root,
|
577
579
|
rules,
|
578
580
|
settings
|
@@ -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",
|
package/lib/init/npm-utils.js
CHANGED
@@ -98,7 +98,7 @@ function fetchPeerDependencies(packageName) {
|
|
98
98
|
* and values are booleans indicating installation.
|
99
99
|
*/
|
100
100
|
function check(packages, opt) {
|
101
|
-
|
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
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
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.
|
129
|
+
status[pkg] = deps.has(pkg);
|
130
130
|
return status;
|
131
131
|
}, {});
|
132
132
|
}
|
@@ -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 {
|
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 =
|
122
|
-
const blockDirectives =
|
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(
|
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({
|
151
|
-
|
152
|
-
|
153
|
-
|
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)
|
package/lib/linter/linter.js
CHANGED
@@ -54,6 +54,11 @@ const DEFAULT_ERROR_LOC = { start: { line: 1, column: 0 }, end: { line: 1, colum
|
|
54
54
|
/** @typedef {import("../shared/types").Processor} Processor */
|
55
55
|
/** @typedef {import("../shared/types").Rule} Rule */
|
56
56
|
|
57
|
+
/**
|
58
|
+
* @template T
|
59
|
+
* @typedef {{ [P in keyof T]-?: T[P] }} Required
|
60
|
+
*/
|
61
|
+
|
57
62
|
/**
|
58
63
|
* @typedef {Object} DisableDirective
|
59
64
|
* @property {("disable"|"enable"|"disable-line"|"disable-next-line")} type
|
@@ -79,7 +84,7 @@ const DEFAULT_ERROR_LOC = { start: { line: 1, column: 0 }, end: { line: 1, colum
|
|
79
84
|
* @property {boolean} [disableFixes] if `true` then the linter doesn't make `fix`
|
80
85
|
* properties into the lint result.
|
81
86
|
* @property {string} [filename] the filename of the source code.
|
82
|
-
* @property {boolean} [reportUnusedDisableDirectives] Adds reported errors for
|
87
|
+
* @property {boolean | "off" | "warn" | "error"} [reportUnusedDisableDirectives] Adds reported errors for
|
83
88
|
* unused `eslint-disable` directives.
|
84
89
|
*/
|
85
90
|
|
@@ -103,6 +108,12 @@ const DEFAULT_ERROR_LOC = { start: { line: 1, column: 0 }, end: { line: 1, colum
|
|
103
108
|
* whether fixes should be applied.
|
104
109
|
*/
|
105
110
|
|
111
|
+
/**
|
112
|
+
* @typedef {Object} InternalOptions
|
113
|
+
* @property {string | null} warnInlineConfig The config name what `noInlineConfig` setting came from. If `noInlineConfig` setting didn't exist, this is null. If this is a config name, then the linter warns directive comments.
|
114
|
+
* @property {"off" | "warn" | "error"} reportUnusedDisableDirectives (boolean values were normalized)
|
115
|
+
*/
|
116
|
+
|
106
117
|
//------------------------------------------------------------------------------
|
107
118
|
// Helpers
|
108
119
|
//------------------------------------------------------------------------------
|
@@ -467,7 +478,7 @@ function normalizeFilename(filename) {
|
|
467
478
|
* consistent shape.
|
468
479
|
* @param {VerifyOptions} providedOptions Options
|
469
480
|
* @param {ConfigData} config Config.
|
470
|
-
* @returns {Required<VerifyOptions> &
|
481
|
+
* @returns {Required<VerifyOptions> & InternalOptions} Normalized options
|
471
482
|
*/
|
472
483
|
function normalizeVerifyOptions(providedOptions, config) {
|
473
484
|
const disableInlineConfig = config.noInlineConfig === true;
|
@@ -476,13 +487,22 @@ function normalizeVerifyOptions(providedOptions, config) {
|
|
476
487
|
? ` (${config.configNameOfNoInlineConfig})`
|
477
488
|
: "";
|
478
489
|
|
490
|
+
let reportUnusedDisableDirectives = providedOptions.reportUnusedDisableDirectives;
|
491
|
+
|
492
|
+
if (typeof reportUnusedDisableDirectives === "boolean") {
|
493
|
+
reportUnusedDisableDirectives = reportUnusedDisableDirectives ? "error" : "off";
|
494
|
+
}
|
495
|
+
if (typeof reportUnusedDisableDirectives !== "string") {
|
496
|
+
reportUnusedDisableDirectives = config.reportUnusedDisableDirectives ? "warn" : "off";
|
497
|
+
}
|
498
|
+
|
479
499
|
return {
|
480
500
|
filename: normalizeFilename(providedOptions.filename || "<input>"),
|
481
501
|
allowInlineConfig: !ignoreInlineConfig,
|
482
502
|
warnInlineConfig: disableInlineConfig && !ignoreInlineConfig
|
483
503
|
? `your config${configNameOfNoInlineConfig}`
|
484
504
|
: null,
|
485
|
-
reportUnusedDisableDirectives
|
505
|
+
reportUnusedDisableDirectives,
|
486
506
|
disableFixes: Boolean(providedOptions.disableFixes)
|
487
507
|
};
|
488
508
|
}
|
package/lib/options.js
CHANGED
@@ -152,7 +152,7 @@ module.exports = {
|
|
152
152
|
type: "suggestion",
|
153
153
|
|
154
154
|
docs: {
|
155
|
-
description: "enforce getter and setter pairs in objects",
|
155
|
+
description: "enforce getter and setter pairs in objects and classes",
|
156
156
|
category: "Best Practices",
|
157
157
|
recommended: false,
|
158
158
|
url: "https://eslint.org/docs/rules/accessor-pairs"
|
@@ -168,6 +168,10 @@ module.exports = {
|
|
168
168
|
setWithoutGet: {
|
169
169
|
type: "boolean",
|
170
170
|
default: true
|
171
|
+
},
|
172
|
+
enforceForClassMembers: {
|
173
|
+
type: "boolean",
|
174
|
+
default: false
|
171
175
|
}
|
172
176
|
},
|
173
177
|
additionalProperties: false
|
@@ -177,13 +181,16 @@ module.exports = {
|
|
177
181
|
missingGetterInPropertyDescriptor: "Getter is not present in property descriptor.",
|
178
182
|
missingSetterInPropertyDescriptor: "Setter is not present in property descriptor.",
|
179
183
|
missingGetterInObjectLiteral: "Getter is not present for {{ name }}.",
|
180
|
-
missingSetterInObjectLiteral: "Setter is not present for {{ name }}."
|
184
|
+
missingSetterInObjectLiteral: "Setter is not present for {{ name }}.",
|
185
|
+
missingGetterInClass: "Getter is not present for class {{ name }}.",
|
186
|
+
missingSetterInClass: "Setter is not present for class {{ name }}."
|
181
187
|
}
|
182
188
|
},
|
183
189
|
create(context) {
|
184
190
|
const config = context.options[0] || {};
|
185
191
|
const checkGetWithoutSet = config.getWithoutSet === true;
|
186
192
|
const checkSetWithoutGet = config.setWithoutGet !== false;
|
193
|
+
const enforceForClassMembers = config.enforceForClassMembers === true;
|
187
194
|
const sourceCode = context.getSourceCode();
|
188
195
|
|
189
196
|
/**
|
@@ -201,6 +208,13 @@ module.exports = {
|
|
201
208
|
loc: astUtils.getFunctionHeadLoc(node.value, sourceCode),
|
202
209
|
data: { name: astUtils.getFunctionNameWithKind(node.value) }
|
203
210
|
});
|
211
|
+
} else if (node.type === "MethodDefinition") {
|
212
|
+
context.report({
|
213
|
+
node,
|
214
|
+
messageId: `${messageKind}InClass`,
|
215
|
+
loc: astUtils.getFunctionHeadLoc(node.value, sourceCode),
|
216
|
+
data: { name: astUtils.getFunctionNameWithKind(node.value) }
|
217
|
+
});
|
204
218
|
} else {
|
205
219
|
context.report({
|
206
220
|
node,
|
@@ -313,15 +327,41 @@ module.exports = {
|
|
313
327
|
}
|
314
328
|
}
|
315
329
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
330
|
+
/**
|
331
|
+
* Checks the given object expression as an object literal and as a possible property descriptor.
|
332
|
+
* @param {ASTNode} node `ObjectExpression` node to check.
|
333
|
+
* @returns {void}
|
334
|
+
* @private
|
335
|
+
*/
|
336
|
+
function checkObjectExpression(node) {
|
337
|
+
checkObjectLiteral(node);
|
338
|
+
if (isPropertyDescriptor(node)) {
|
339
|
+
checkPropertyDescriptor(node);
|
324
340
|
}
|
325
|
-
}
|
341
|
+
}
|
342
|
+
|
343
|
+
/**
|
344
|
+
* Checks the given class body.
|
345
|
+
* @param {ASTNode} node `ClassBody` node to check.
|
346
|
+
* @returns {void}
|
347
|
+
* @private
|
348
|
+
*/
|
349
|
+
function checkClassBody(node) {
|
350
|
+
const methodDefinitions = node.body.filter(m => m.type === "MethodDefinition");
|
351
|
+
|
352
|
+
checkList(methodDefinitions.filter(m => m.static));
|
353
|
+
checkList(methodDefinitions.filter(m => !m.static));
|
354
|
+
}
|
355
|
+
|
356
|
+
const listeners = {};
|
357
|
+
|
358
|
+
if (checkSetWithoutGet || checkGetWithoutSet) {
|
359
|
+
listeners.ObjectExpression = checkObjectExpression;
|
360
|
+
if (enforceForClassMembers) {
|
361
|
+
listeners.ClassBody = checkClassBody;
|
362
|
+
}
|
363
|
+
}
|
364
|
+
|
365
|
+
return listeners;
|
326
366
|
}
|
327
367
|
};
|
@@ -26,6 +26,16 @@ module.exports = {
|
|
26
26
|
schema: [
|
27
27
|
{
|
28
28
|
enum: ["always", "never"]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
type: "object",
|
32
|
+
properties: {
|
33
|
+
enforceForClassMembers: {
|
34
|
+
type: "boolean",
|
35
|
+
default: false
|
36
|
+
}
|
37
|
+
},
|
38
|
+
additionalProperties: false
|
29
39
|
}
|
30
40
|
],
|
31
41
|
|
@@ -41,6 +51,7 @@ module.exports = {
|
|
41
51
|
create(context) {
|
42
52
|
const sourceCode = context.getSourceCode();
|
43
53
|
const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never"
|
54
|
+
const enforceForClassMembers = context.options[1] && context.options[1].enforceForClassMembers;
|
44
55
|
|
45
56
|
//--------------------------------------------------------------------------
|
46
57
|
// Helpers
|
@@ -178,10 +189,16 @@ module.exports = {
|
|
178
189
|
// Public
|
179
190
|
//--------------------------------------------------------------------------
|
180
191
|
|
181
|
-
|
192
|
+
const listeners = {
|
182
193
|
Property: checkSpacing("key"),
|
183
194
|
MemberExpression: checkSpacing("property")
|
184
195
|
};
|
185
196
|
|
197
|
+
if (enforceForClassMembers) {
|
198
|
+
listeners.MethodDefinition = checkSpacing("key");
|
199
|
+
}
|
200
|
+
|
201
|
+
return listeners;
|
202
|
+
|
186
203
|
}
|
187
204
|
};
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview enforce default parameters to be last
|
3
|
+
* @author Chiawen Chen
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
module.exports = {
|
9
|
+
meta: {
|
10
|
+
type: "suggestion",
|
11
|
+
|
12
|
+
docs: {
|
13
|
+
description: "enforce default parameters to be last",
|
14
|
+
category: "Best Practices",
|
15
|
+
recommended: false,
|
16
|
+
url: "https://eslint.org/docs/rules/default-param-last"
|
17
|
+
},
|
18
|
+
|
19
|
+
schema: [],
|
20
|
+
|
21
|
+
messages: {
|
22
|
+
shouldBeLast: "Default parameters should be last."
|
23
|
+
}
|
24
|
+
},
|
25
|
+
|
26
|
+
create(context) {
|
27
|
+
|
28
|
+
/**
|
29
|
+
* @param {ASTNode} node function node
|
30
|
+
* @returns {void}
|
31
|
+
*/
|
32
|
+
function handleFunction(node) {
|
33
|
+
let hasSeenPlainParam = false;
|
34
|
+
|
35
|
+
for (let i = node.params.length - 1; i >= 0; i -= 1) {
|
36
|
+
const param = node.params[i];
|
37
|
+
|
38
|
+
if (
|
39
|
+
param.type !== "AssignmentPattern" &&
|
40
|
+
param.type !== "RestElement"
|
41
|
+
) {
|
42
|
+
hasSeenPlainParam = true;
|
43
|
+
continue;
|
44
|
+
}
|
45
|
+
|
46
|
+
if (hasSeenPlainParam && param.type === "AssignmentPattern") {
|
47
|
+
context.report({
|
48
|
+
node: param,
|
49
|
+
messageId: "shouldBeLast"
|
50
|
+
});
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
return {
|
56
|
+
FunctionDeclaration: handleFunction,
|
57
|
+
FunctionExpression: handleFunction,
|
58
|
+
ArrowFunctionExpression: handleFunction
|
59
|
+
};
|
60
|
+
}
|
61
|
+
};
|