eslint 4.7.1 → 4.10.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 +113 -0
- package/README.md +34 -19
- package/conf/default-cli-options.js +2 -1
- package/conf/eslint-recommended.js +2 -0
- package/lib/ast-utils.js +2 -1
- package/lib/cli-engine.js +26 -5
- package/lib/cli.js +17 -9
- package/lib/code-path-analysis/code-path-segment.js +39 -39
- package/lib/code-path-analysis/code-path-state.js +3 -0
- package/lib/formatters/html-template-message.html +1 -1
- package/lib/formatters/html-template-page.html +3 -1
- package/lib/formatters/html.js +2 -1
- package/lib/ignored-paths.js +1 -1
- package/lib/linter.js +43 -71
- package/lib/logging.js +2 -2
- package/lib/options.js +12 -0
- package/lib/rules/array-bracket-newline.js +19 -5
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/callback-return.js +2 -1
- package/lib/rules/capitalized-comments.js +2 -1
- package/lib/rules/comma-style.js +3 -1
- package/lib/rules/dot-notation.js +56 -35
- package/lib/rules/generator-star-spacing.js +3 -3
- package/lib/rules/indent-legacy.js +5 -2
- package/lib/rules/indent.js +25 -19
- package/lib/rules/lines-around-comment.js +33 -4
- package/lib/rules/lines-between-class-members.js +91 -0
- package/lib/rules/max-len.js +2 -3
- package/lib/rules/multiline-comment-style.js +294 -0
- package/lib/rules/new-cap.js +2 -1
- package/lib/rules/newline-before-return.js +4 -2
- package/lib/rules/no-alert.js +7 -15
- package/lib/rules/no-catch-shadow.js +1 -1
- package/lib/rules/no-constant-condition.js +2 -2
- package/lib/rules/no-control-regex.js +2 -1
- package/lib/rules/no-else-return.js +43 -8
- package/lib/rules/no-extra-parens.js +6 -3
- package/lib/rules/no-lonely-if.js +2 -1
- package/lib/rules/no-loop-func.js +2 -3
- package/lib/rules/no-mixed-requires.js +8 -4
- package/lib/rules/no-restricted-imports.js +86 -17
- package/lib/rules/no-restricted-modules.js +84 -15
- package/lib/rules/no-trailing-spaces.js +1 -1
- package/lib/rules/no-unneeded-ternary.js +3 -1
- package/lib/rules/no-unused-labels.js +2 -1
- package/lib/rules/no-useless-computed-key.js +2 -1
- package/lib/rules/no-useless-escape.js +8 -1
- package/lib/rules/no-var.js +11 -0
- package/lib/rules/object-shorthand.js +6 -2
- package/lib/rules/operator-linebreak.js +3 -1
- package/lib/rules/padding-line-between-statements.js +2 -2
- package/lib/rules/require-jsdoc.js +11 -18
- package/lib/rules/sort-imports.js +6 -3
- package/lib/rules/space-unary-ops.js +6 -8
- package/lib/rules/valid-jsdoc.js +39 -33
- package/lib/testers/rule-tester.js +20 -6
- package/lib/util/apply-disable-directives.js +56 -27
- package/lib/util/node-event-generator.js +6 -20
- package/lib/util/safe-emitter.js +54 -0
- package/lib/util/source-code.js +73 -67
- package/messages/no-config-found.txt +1 -1
- package/package.json +3 -4
- package/lib/internal-rules/.eslintrc.yml +0 -3
- package/lib/internal-rules/internal-consistent-docs-description.js +0 -130
- package/lib/internal-rules/internal-no-invalid-meta.js +0 -188
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,116 @@
|
|
1
|
+
v4.10.0 - October 27, 2017
|
2
|
+
|
3
|
+
* bb6e60a Fix: Improve the doc for no-restricted-modules rule (fixes #9437) (#9495) (vibss2397)
|
4
|
+
* c529de9 Docs: Amend rule document to correct and complete it (refs #6251). (#9498) (Jonathan Pool)
|
5
|
+
* f9c6673 Chore: Add tests to cover array and object values and leading commas. (#9502) (Jonathan Pool)
|
6
|
+
* 9169258 Chore: remove `npm run check-commit` script (#9513) (Teddy Katz)
|
7
|
+
* 7d390b2 Docs: Revise contributor documentation on issue labels. (#9469) (Jonathan Pool)
|
8
|
+
* d80b9d0 Fix: no-var don't fix globals (fixes #9520) (#9525) (Toru Nagashima)
|
9
|
+
* b8aa071 Fix: allow linting the empty string from stdin (fixes #9515) (#9517) (Teddy Katz)
|
10
|
+
* 350a72c Chore: regex.test => string.startsWith (#9518) (薛定谔的猫)
|
11
|
+
* de0bef4 Chore: remove obsolete eslintbot templates (#9512) (Teddy Katz)
|
12
|
+
* 720b6d5 Docs: Update ISSUE_TEMPLATE.md (#9504) (薛定谔的猫)
|
13
|
+
* 2fa64b7 Fix: should not convert non-consecutive line comments to a single blo… (#9475) (薛定谔的猫)
|
14
|
+
* 9725146 Fix: multiline-comment-style fix produces invalid code (fixes #9461). (#9463) (薛定谔的猫)
|
15
|
+
* b12cff8 Fix: Expected order of jsdoc tags (fixes #9412) (#9451) (Orlando Wenzinger)
|
16
|
+
* f054ab5 Docs: add `.md` to link (for github users) (#9501) (薛定谔的猫)
|
17
|
+
* 5ed9cfc Docs: Correct violations of “Variable Declarations” in Code Conventions (#9447) (Jonathan Pool)
|
18
|
+
* 3171097 Docs: Clears confusion on usage of global and local plugins.(#9492) (Vasili Sviridov)
|
19
|
+
* 3204773 Chore: enable max-len. (#9414) (薛定谔的猫)
|
20
|
+
* 0f71fef Docs: Unquote booleans in lines-between-class-members docs (#9497) (Brandon Mills)
|
21
|
+
* b3d7532 Docs: use consistent terminology & fix link etc. (#9490) (薛定谔的猫)
|
22
|
+
* 87db8ae Docs: Fix broken links (#9488) (gpiress)
|
23
|
+
* 51bdb2f Docs: Incorrect link to related rule (#9477) (Gavin King)
|
24
|
+
* 1a962e8 Docs: Add FAQ for when ESLint cannot find plugin (#9467) (Kevin Partington)
|
25
|
+
* 8768b2d Fix: multiline-comment-style autofixer added trailing space (#9454) (Teddy Katz)
|
26
|
+
* e830aa1 Fix: multiline-comment-style reports block comments followed by code (#9450) (Teddy Katz)
|
27
|
+
* b12e5fe Docs: Repair broken links and add migration links. (#9473) (Jonathan Pool)
|
28
|
+
* eca01ed Docs: Add missing info about special status of home-dir config files. (#9472) (Jonathan Pool)
|
29
|
+
* eb8cfb1 Fix: change err report in constant condition (fixes #9398) (#9436) (Victor Hom)
|
30
|
+
* da77eb4 Chore: Revise no-config-file test to prevent false failure. (#9443) (Jonathan Pool)
|
31
|
+
* 47e5f6f Docs: ensure "good commit message" examples actually follow guidelines (#9466) (Teddy Katz)
|
32
|
+
* ebb530d Update: Don't ignore comments (no-trailing-spaces) (#9416) (Chris van Marle)
|
33
|
+
* 5012661 Build: fix `npm run profile` script (fixes #9397) (#9455) (Teddy Katz)
|
34
|
+
* ecac0fd Docs: Remove blockBindings references (#9446) (Jan Pilzer)
|
35
|
+
* 0b89865 Chore: ensure tests for internal rules get run (#9453) (Teddy Katz)
|
36
|
+
* 052c504 Docs: suggest deleting branches after merging PRs (#9449) (Teddy Katz)
|
37
|
+
* b31e55a Chore: move internal rules out of lib/ (#9448) (Teddy Katz)
|
38
|
+
* a7521e3 Docs: improve examples for multiline-comment-style (#9440) (Teddy Katz)
|
39
|
+
* 235c7dd 4.9.0 (ESLint Jenkins)
|
40
|
+
* b6f31a9 Build: changelog update for 4.9.0 (ESLint Jenkins)
|
41
|
+
* 85388fb Fix: Correct error and test messages to fit config search path (#9428) (Jonathan Pool)
|
42
|
+
* 62a323c Fix: Add class options for `lines-around-comment` (fixes #8564) (#8565) (Ed Lee)
|
43
|
+
* 8eb4aae New: multiline-comment-style rule (fixes #8320) (#9389) (薛定谔的猫)
|
44
|
+
* db41408 Chore: avoid applying eslint-env comments twice (#9278) (Teddy Katz)
|
45
|
+
* febb897 Chore: avoid loose equality assertions (#9415) (Teddy Katz)
|
46
|
+
* 2247efa Update: Add FunctionExpression to require-jsdoc (fixes #5867) (#9395) (Kai Cataldo)
|
47
|
+
* 6791d18 Docs: Corrected noun to verb. (#9438) (Jonathan Pool)
|
48
|
+
* b02fbb6 Update: custom messages for no-restricted-* (refs #8400) (Maja Wichrowska)
|
49
|
+
* 02732bd Docs: Reorganized to avoid misunderstandings. (#9434) (Jonathan Pool)
|
50
|
+
* d9466b8 Docs: Correct time forecast for tests. (#9432) (Jonathan Pool)
|
51
|
+
* f7ed84f Docs: Add instruction re home-directory config files (refs #7729) (#9426) (Jonathan Pool)
|
52
|
+
* 30d018b Chore: Add Aladdin-ADD & VictorHom to README (#9424) (Kai Cataldo)
|
53
|
+
* 2d8a303 Docs: fix examples for prefer-numeric-literals (#9155) (Lutz Lengemann)
|
54
|
+
* d7610f5 Docs: Add jquery warning to prefer-destructuring (#9409) (Thomas Grainger)
|
55
|
+
* e835dd1 Docs: clarify no-mixed-operators (fixes #8051) (Ruxandra Fediuc)
|
56
|
+
* 51360c8 Docs: update block-spacing details (fixes #8743) (#9375) (Victor Hom)
|
57
|
+
* 6767857 Update: fix ignored nodes in indent rule when using tabs (fixes #9392) (#9393) (Robin Houston)
|
58
|
+
* 37dde77 Chore: Refactor SourceCode#getJSDocComment (#9403) (Kai Cataldo)
|
59
|
+
* 9fedd51 Chore: Add missing space in blog post template (#9407) (Kevin Partington)
|
60
|
+
* 7654c99 Docs: add installing prerequisites in readme. (#9401) (薛定谔的猫)
|
61
|
+
|
62
|
+
v4.9.0 - October 14, 2017
|
63
|
+
|
64
|
+
* 85388fb Fix: Correct error and test messages to fit config search path (#9428) (Jonathan Pool)
|
65
|
+
* 62a323c Fix: Add class options for `lines-around-comment` (fixes #8564) (#8565) (Ed Lee)
|
66
|
+
* 8eb4aae New: multiline-comment-style rule (fixes #8320) (#9389) (薛定谔的猫)
|
67
|
+
* db41408 Chore: avoid applying eslint-env comments twice (#9278) (Teddy Katz)
|
68
|
+
* febb897 Chore: avoid loose equality assertions (#9415) (Teddy Katz)
|
69
|
+
* 2247efa Update: Add FunctionExpression to require-jsdoc (fixes #5867) (#9395) (Kai Cataldo)
|
70
|
+
* 6791d18 Docs: Corrected noun to verb. (#9438) (Jonathan Pool)
|
71
|
+
* b02fbb6 Update: custom messages for no-restricted-* (refs #8400) (Maja Wichrowska)
|
72
|
+
* 02732bd Docs: Reorganized to avoid misunderstandings. (#9434) (Jonathan Pool)
|
73
|
+
* d9466b8 Docs: Correct time forecast for tests. (#9432) (Jonathan Pool)
|
74
|
+
* f7ed84f Docs: Add instruction re home-directory config files (refs #7729) (#9426) (Jonathan Pool)
|
75
|
+
* 30d018b Chore: Add Aladdin-ADD & VictorHom to README (#9424) (Kai Cataldo)
|
76
|
+
* 2d8a303 Docs: fix examples for prefer-numeric-literals (#9155) (Lutz Lengemann)
|
77
|
+
* d7610f5 Docs: Add jquery warning to prefer-destructuring (#9409) (Thomas Grainger)
|
78
|
+
* e835dd1 Docs: clarify no-mixed-operators (fixes #8051) (Ruxandra Fediuc)
|
79
|
+
* 51360c8 Docs: update block-spacing details (fixes #8743) (#9375) (Victor Hom)
|
80
|
+
* 6767857 Update: fix ignored nodes in indent rule when using tabs (fixes #9392) (#9393) (Robin Houston)
|
81
|
+
* 37dde77 Chore: Refactor SourceCode#getJSDocComment (#9403) (Kai Cataldo)
|
82
|
+
* 9fedd51 Chore: Add missing space in blog post template (#9407) (Kevin Partington)
|
83
|
+
* 7654c99 Docs: add installing prerequisites in readme. (#9401) (薛定谔的猫)
|
84
|
+
* 786cc73 Update: Add "consistent" option to array-bracket-newline (fixes #9136) (#9206) (Ethan Rutherford)
|
85
|
+
* e171f6b Docs: add installing prerequisites. (#9394) (薛定谔的猫)
|
86
|
+
* 74dfc87 Docs: update doc for class-methods-use-this (fixes #8910) (#9374) (Victor Hom)
|
87
|
+
* b4a9dbf Docs: show console call with no-restricted-syntax (fixes #7806) (#9376) (Victor Hom)
|
88
|
+
* 8da525f Fix: recognise multiline comments as multiline arrays (fixes #9211) (#9369) (Phil Quinn)
|
89
|
+
* c581b77 Chore: Error => TypeError (#9390) (薛定谔的猫)
|
90
|
+
* ee99876 New: lines-between-class-members rule (fixes #5949) (#9141) (薛定谔的猫)
|
91
|
+
* 9d3f5ad Chore: report unused eslint-disable directives in ESLint codebase (#9371) (Teddy Katz)
|
92
|
+
* 1167638 Update: add allowElseIf option to no-else-return (fixes #9228) (#9229) (Thomas Grainger)
|
93
|
+
* 4567ab1 New: Add the fix-dry-run flag (fixes #9076) (#9073) (Rafał Ruciński)
|
94
|
+
|
95
|
+
v4.8.0 - September 29, 2017
|
96
|
+
|
97
|
+
* 3f2b908 New: add option to report unused eslint-disable directives (fixes #9249) (#9250) (Teddy Katz)
|
98
|
+
* ff2be59 Fix: dot notation rule failing to catch string template (fixes #9350) (#9357) (Phil Quinn)
|
99
|
+
* b1372da Chore: remove sourceCode property from Linter (refs #9161) (#9363) (Teddy Katz)
|
100
|
+
* cef6f8c Docs: remove line about removing rules from semver policy (#9367) (Teddy Katz)
|
101
|
+
* 06efe87 Fix: Add meta element with charset attribute. (#9365) (H1Gdev)
|
102
|
+
* 458ca67 Docs: update architecture page (fixes #9337) (#9345) (Victor Hom)
|
103
|
+
* 1c6bc67 Fix: special EventEmitter keys leak information about other rules (#9328) (Teddy Katz)
|
104
|
+
* d593e61 Docs: update eslint.org links to use https (#9358) (Teddy Katz)
|
105
|
+
* 38d0cb2 Fix: fix wrong code-path about try-for-in (fixes #8848) (#9348) (Toru Nagashima)
|
106
|
+
* 434d9e2 Fix: Invalid font-size property value issue. (#9341) (H1Gdev)
|
107
|
+
* a7668c2 Chore: Remove unnecessary slice from logging utility (#9343) (Gyandeep Singh)
|
108
|
+
* 2ff6fb6 Chore: remove unused arguments in codebase (#9340) (Teddy Katz)
|
109
|
+
|
110
|
+
v4.7.2 - September 21, 2017
|
111
|
+
|
112
|
+
* 4f87732 Fix: Revert setting node.parent early (fixes #9331) (#9336) (Teddy Katz)
|
113
|
+
|
1
114
|
v4.7.1 - September 18, 2017
|
2
115
|
|
3
116
|
* 08656db Fix: Handle nested disable directive correctly (fixes #9318) (#9322) (Gyandeep Singh)
|
package/README.md
CHANGED
@@ -9,11 +9,11 @@
|
|
9
9
|
|
10
10
|
# ESLint
|
11
11
|
|
12
|
-
[Website](
|
13
|
-
[Configuring](
|
14
|
-
[Rules](
|
15
|
-
[Contributing](
|
16
|
-
[Reporting Bugs](
|
12
|
+
[Website](https://eslint.org) |
|
13
|
+
[Configuring](https://eslint.org/docs/user-guide/configuring) |
|
14
|
+
[Rules](https://eslint.org/docs/rules/) |
|
15
|
+
[Contributing](https://eslint.org/docs/developer-guide/contributing) |
|
16
|
+
[Reporting Bugs](https://eslint.org/docs/developer-guide/contributing/reporting-bugs) |
|
17
17
|
[Code of Conduct](https://js.foundation/community/code-of-conduct) |
|
18
18
|
[Twitter](https://twitter.com/geteslint) |
|
19
19
|
[Mailing List](https://groups.google.com/group/eslint) |
|
@@ -27,6 +27,8 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J
|
|
27
27
|
|
28
28
|
## Installation and Usage
|
29
29
|
|
30
|
+
Prerequisites: [Node.js](https://nodejs.org/en/) (>=4.x), npm version 2+.
|
31
|
+
|
30
32
|
There are two ways to install ESLint: globally and locally.
|
31
33
|
|
32
34
|
### Local Installation and Usage
|
@@ -88,17 +90,17 @@ After running `eslint --init`, you'll have a `.eslintrc` file in your directory.
|
|
88
90
|
}
|
89
91
|
```
|
90
92
|
|
91
|
-
The names `"semi"` and `"quotes"` are the names of [rules](
|
93
|
+
The names `"semi"` and `"quotes"` are the names of [rules](https://eslint.org/docs/rules) in ESLint. The first value is the error level of the rule and can be one of these values:
|
92
94
|
|
93
95
|
* `"off"` or `0` - turn the rule off
|
94
96
|
* `"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code)
|
95
97
|
* `"error"` or `2` - turn the rule on as an error (exit code will be 1)
|
96
98
|
|
97
|
-
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](
|
99
|
+
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](https://eslint.org/docs/user-guide/configuring)).
|
98
100
|
|
99
101
|
## Sponsors
|
100
102
|
|
101
|
-
* Site search ([eslint.org](
|
103
|
+
* Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com)
|
102
104
|
|
103
105
|
## Team
|
104
106
|
|
@@ -132,6 +134,8 @@ These folks keep the project moving and are resources for help.
|
|
132
134
|
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))
|
133
135
|
* James Henry ([@JamesHenry](https://github.com/JamesHenry))
|
134
136
|
* Reyad Attiyat ([@soda0289](https://github.com/soda0289))
|
137
|
+
* 薛定谔的猫 ([@Aladdin-ADD](https://github.com/Aladdin-ADD))
|
138
|
+
* Victor Hom ([@VictorHom](https://github.com/VictorHom))
|
135
139
|
|
136
140
|
## Releases
|
137
141
|
|
@@ -145,10 +149,10 @@ ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/comm
|
|
145
149
|
|
146
150
|
Before filing an issue, please be sure to read the guidelines for what you're reporting:
|
147
151
|
|
148
|
-
* [Bug Report](
|
149
|
-
* [Propose a New Rule](
|
150
|
-
* [Proposing a Rule Change](
|
151
|
-
* [Request a Change](
|
152
|
+
* [Bug Report](https://eslint.org/docs/developer-guide/contributing/reporting-bugs)
|
153
|
+
* [Propose a New Rule](https://eslint.org/docs/developer-guide/contributing/new-rules)
|
154
|
+
* [Proposing a Rule Change](https://eslint.org/docs/developer-guide/contributing/rule-changes)
|
155
|
+
* [Request a Change](https://eslint.org/docs/developer-guide/contributing/changes)
|
152
156
|
|
153
157
|
## Semantic Versioning Policy
|
154
158
|
|
@@ -171,7 +175,6 @@ ESLint follows [semantic versioning](http://semver.org). However, due to the nat
|
|
171
175
|
* Major release (likely to break your lint build)
|
172
176
|
* `eslint:recommended` is updated.
|
173
177
|
* A new option to an existing rule that results in ESLint reporting more errors by default.
|
174
|
-
* An existing rule is removed.
|
175
178
|
* An existing formatter is removed.
|
176
179
|
* Part of the public API is removed or changed in an incompatible way.
|
177
180
|
|
@@ -195,32 +198,44 @@ Despite being slower, we believe that ESLint is fast enough to replace JSHint wi
|
|
195
198
|
|
196
199
|
### I heard ESLint is going to replace JSCS?
|
197
200
|
|
198
|
-
Yes. Since we are solving the same problems, ESLint and JSCS teams have decided to join forces and work together in the development of ESLint instead of competing with each other. You can read more about this in both [ESLint](
|
201
|
+
Yes. Since we are solving the same problems, ESLint and JSCS teams have decided to join forces and work together in the development of ESLint instead of competing with each other. You can read more about this in both [ESLint](https://eslint.org/blog/2016/04/welcoming-jscs-to-eslint) and [JSCS](https://medium.com/@markelog/jscs-end-of-the-line-bc9bf0b3fdb2#.u76sx334n) announcements.
|
199
202
|
|
200
203
|
### So, should I stop using JSCS and start using ESLint?
|
201
204
|
|
202
|
-
Maybe, depending on how much you need it. [JSCS has reached end of life](
|
205
|
+
Maybe, depending on how much you need it. [JSCS has reached end of life](https://eslint.org/blog/2016/07/jscs-end-of-life), but if it is working for you then there is no reason to move yet. We are still working to smooth the transition. You can see our progress [here](https://github.com/eslint/eslint/milestones/JSCS%20Compatibility). We’ll announce when all of the changes necessary to support JSCS users in ESLint are complete and will start encouraging JSCS users to switch to ESLint at that time.
|
203
206
|
|
204
207
|
If you are having issues with JSCS, you can try to move to ESLint. We are focusing our time and energy on JSCS compatibility issues.
|
205
208
|
|
206
|
-
|
207
209
|
### Is ESLint just linting or does it also check style?
|
208
210
|
|
209
211
|
ESLint does both traditional linting (looking for problematic patterns) and style checking (enforcement of conventions). You can use it for both.
|
210
212
|
|
213
|
+
### Why can't ESLint find my plugins?
|
214
|
+
|
215
|
+
ESLint can be [globally or locally installed](#installation-and-usage). If you install ESLint globally, your plugins must also be installed globally; if you install ESLint locally, your plugins must also be installed locally.
|
216
|
+
|
217
|
+
If you are trying to run globally, make sure your plugins are installed globally (use `npm ls -g`).
|
218
|
+
|
219
|
+
If you are trying to run locally:
|
220
|
+
|
221
|
+
* Make sure your plugins (and ESLint) are both in your project's `package.json` as devDependencies (or dependencies, if your project uses ESLint at runtime).
|
222
|
+
* Make sure you have run `npm install` and all your dependencies are installed.
|
223
|
+
|
224
|
+
In all cases, make sure your plugins' peerDependencies have been installed as well. You can use `npm view eslint-plugin-myplugin peerDepencies` to see what peer dependencies `eslint-plugin-myplugin` has.
|
225
|
+
|
211
226
|
### Does ESLint support JSX?
|
212
227
|
|
213
|
-
Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](
|
228
|
+
Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/user-guide/configuring).). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.
|
214
229
|
|
215
230
|
### What about ECMAScript 6 support?
|
216
231
|
|
217
|
-
ESLint has full support for ECMAScript 6. By default, this support is off. You can enable ECMAScript 6 syntax and global variables through [configuration](
|
232
|
+
ESLint has full support for ECMAScript 6. By default, this support is off. You can enable ECMAScript 6 syntax and global variables through [configuration](https://eslint.org/docs/user-guide/configuring).
|
218
233
|
|
219
234
|
### What about experimental features?
|
220
235
|
|
221
236
|
ESLint doesn't natively support experimental ECMAScript language features. You can use [babel-eslint](https://github.com/babel/babel-eslint) to use any option available in Babel.
|
222
237
|
|
223
|
-
Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](
|
238
|
+
Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](https://eslint.org/docs/developer-guide/contributing). Until then, please use the appropriate parser and plugin(s) for your experimental feature.
|
224
239
|
|
225
240
|
### Where to ask for help?
|
226
241
|
|
@@ -63,6 +63,7 @@ module.exports = {
|
|
63
63
|
"linebreak-style": "off",
|
64
64
|
"lines-around-comment": "off",
|
65
65
|
"lines-around-directive": "off",
|
66
|
+
"lines-between-class-members": "off",
|
66
67
|
"max-depth": "off",
|
67
68
|
"max-len": "off",
|
68
69
|
"max-lines": "off",
|
@@ -70,6 +71,7 @@ module.exports = {
|
|
70
71
|
"max-params": "off",
|
71
72
|
"max-statements": "off",
|
72
73
|
"max-statements-per-line": "off",
|
74
|
+
"multiline-comment-style": "off",
|
73
75
|
"multiline-ternary": "off",
|
74
76
|
"new-cap": "off",
|
75
77
|
"new-parens": "off",
|
package/lib/ast-utils.js
CHANGED
@@ -1041,7 +1041,8 @@ module.exports = {
|
|
1041
1041
|
} else if (parent.type === "Property" || parent.type === "MethodDefinition") {
|
1042
1042
|
if (parent.kind === "constructor") {
|
1043
1043
|
return "constructor";
|
1044
|
-
}
|
1044
|
+
}
|
1045
|
+
if (parent.kind === "get") {
|
1045
1046
|
tokens.push("getter");
|
1046
1047
|
} else if (parent.kind === "set") {
|
1047
1048
|
tokens.push("setter");
|
package/lib/cli-engine.js
CHANGED
@@ -56,6 +56,7 @@ const debug = require("debug")("eslint:cli-engine");
|
|
56
56
|
* @property {string[]} plugins An array of plugins to load.
|
57
57
|
* @property {Object<string,*>} rules An object of rules to use.
|
58
58
|
* @property {string[]} rulePaths An array of directories to load custom rules from.
|
59
|
+
* @property {boolean} reportUnusedDisableDirectives `true` adds reports for unused eslint-disable directives
|
59
60
|
*/
|
60
61
|
|
61
62
|
/**
|
@@ -137,11 +138,12 @@ function calculateStatsPerRun(results) {
|
|
137
138
|
* @param {string} filename An optional string representing the texts filename.
|
138
139
|
* @param {boolean|Function} fix Indicates if fixes should be processed.
|
139
140
|
* @param {boolean} allowInlineConfig Allow/ignore comments that change config.
|
141
|
+
* @param {boolean} reportUnusedDisableDirectives Allow/ignore comments that change config.
|
140
142
|
* @param {Linter} linter Linter context
|
141
143
|
* @returns {LintResult} The results for linting on this text.
|
142
144
|
* @private
|
143
145
|
*/
|
144
|
-
function processText(text, configHelper, filename, fix, allowInlineConfig, linter) {
|
146
|
+
function processText(text, configHelper, filename, fix, allowInlineConfig, reportUnusedDisableDirectives, linter) {
|
145
147
|
let filePath,
|
146
148
|
fileExtension,
|
147
149
|
processor;
|
@@ -173,6 +175,7 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, linte
|
|
173
175
|
const fixedResult = linter.verifyAndFix(text, config, {
|
174
176
|
filename,
|
175
177
|
allowInlineConfig,
|
178
|
+
reportUnusedDisableDirectives,
|
176
179
|
fix: !!autofixingEnabled && fix,
|
177
180
|
preprocess: processor && (rawText => processor.preprocess(rawText, filename)),
|
178
181
|
postprocess: processor && (problemLists => processor.postprocess(problemLists, filename))
|
@@ -213,7 +216,15 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, linte
|
|
213
216
|
function processFile(filename, configHelper, options, linter) {
|
214
217
|
|
215
218
|
const text = fs.readFileSync(path.resolve(filename), "utf8"),
|
216
|
-
result = processText(
|
219
|
+
result = processText(
|
220
|
+
text,
|
221
|
+
configHelper,
|
222
|
+
filename,
|
223
|
+
options.fix,
|
224
|
+
options.allowInlineConfig,
|
225
|
+
options.reportUnusedDisableDirectives,
|
226
|
+
linter
|
227
|
+
);
|
217
228
|
|
218
229
|
return result;
|
219
230
|
|
@@ -229,8 +240,8 @@ function processFile(filename, configHelper, options, linter) {
|
|
229
240
|
function createIgnoreResult(filePath, baseDir) {
|
230
241
|
let message;
|
231
242
|
const isHidden = /^\./.test(path.basename(filePath));
|
232
|
-
const isInNodeModules = baseDir &&
|
233
|
-
const isInBowerComponents = baseDir &&
|
243
|
+
const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules");
|
244
|
+
const isInBowerComponents = baseDir && path.relative(baseDir, filePath).startsWith("bower_components");
|
234
245
|
|
235
246
|
if (isHidden) {
|
236
247
|
message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override.";
|
@@ -591,7 +602,17 @@ class CLIEngine {
|
|
591
602
|
results.push(createIgnoreResult(filename, options.cwd));
|
592
603
|
}
|
593
604
|
} else {
|
594
|
-
results.push(
|
605
|
+
results.push(
|
606
|
+
processText(
|
607
|
+
text,
|
608
|
+
configHelper,
|
609
|
+
filename,
|
610
|
+
options.fix,
|
611
|
+
options.allowInlineConfig,
|
612
|
+
options.reportUnusedDisableDirectives,
|
613
|
+
this.linter
|
614
|
+
)
|
615
|
+
);
|
595
616
|
}
|
596
617
|
|
597
618
|
const stats = calculateStatsPerRun(results);
|
package/lib/cli.js
CHANGED
@@ -63,8 +63,9 @@ function translateOptions(cliOptions) {
|
|
63
63
|
cache: cliOptions.cache,
|
64
64
|
cacheFile: cliOptions.cacheFile,
|
65
65
|
cacheLocation: cliOptions.cacheLocation,
|
66
|
-
fix: cliOptions.fix && (cliOptions.quiet ? quietFixPredicate : true),
|
67
|
-
allowInlineConfig: cliOptions.inlineConfig
|
66
|
+
fix: (cliOptions.fix || cliOptions.fixDryRun) && (cliOptions.quiet ? quietFixPredicate : true),
|
67
|
+
allowInlineConfig: cliOptions.inlineConfig,
|
68
|
+
reportUnusedDisableDirectives: cliOptions.reportUnusedDisableDirectives
|
68
69
|
};
|
69
70
|
}
|
70
71
|
|
@@ -143,6 +144,8 @@ const cli = {
|
|
143
144
|
|
144
145
|
const files = currentOptions._;
|
145
146
|
|
147
|
+
const useStdin = typeof text === "string";
|
148
|
+
|
146
149
|
if (currentOptions.version) { // version from package.json
|
147
150
|
|
148
151
|
log.info(`v${require("../package.json").version}`);
|
@@ -151,7 +154,8 @@ const cli = {
|
|
151
154
|
if (files.length) {
|
152
155
|
log.error("The --print-config option must be used with exactly one file name.");
|
153
156
|
return 1;
|
154
|
-
}
|
157
|
+
}
|
158
|
+
if (useStdin) {
|
155
159
|
log.error("The --print-config option is not available for piped-in code.");
|
156
160
|
return 1;
|
157
161
|
}
|
@@ -162,23 +166,27 @@ const cli = {
|
|
162
166
|
|
163
167
|
log.info(JSON.stringify(fileConfig, null, " "));
|
164
168
|
return 0;
|
165
|
-
} else if (currentOptions.help || (!files.length && !
|
169
|
+
} else if (currentOptions.help || (!files.length && !useStdin)) {
|
166
170
|
|
167
171
|
log.info(options.generateHelp());
|
168
172
|
|
169
173
|
} else {
|
170
174
|
|
171
|
-
debug(`Running on ${
|
175
|
+
debug(`Running on ${useStdin ? "text" : "files"}`);
|
176
|
+
|
177
|
+
if (currentOptions.fix && currentOptions.fixDryRun) {
|
178
|
+
log.error("The --fix option and the --fix-dry-run option cannot be used together.");
|
179
|
+
return 1;
|
180
|
+
}
|
172
181
|
|
173
|
-
|
174
|
-
|
175
|
-
log.error("The --fix option is not available for piped-in code.");
|
182
|
+
if (useStdin && currentOptions.fix) {
|
183
|
+
log.error("The --fix option is not available for piped-in code; use --fix-dry-run instead.");
|
176
184
|
return 1;
|
177
185
|
}
|
178
186
|
|
179
187
|
const engine = new CLIEngine(translateOptions(currentOptions));
|
180
188
|
|
181
|
-
const report =
|
189
|
+
const report = useStdin ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files);
|
182
190
|
|
183
191
|
if (currentOptions.fix) {
|
184
192
|
debug("Fix mode enabled - applying fixes");
|
@@ -15,43 +15,6 @@ const debug = require("./debug-helpers");
|
|
15
15
|
// Helpers
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
/**
|
19
|
-
* Replaces unused segments with the previous segments of each unused segment.
|
20
|
-
*
|
21
|
-
* @param {CodePathSegment[]} segments - An array of segments to replace.
|
22
|
-
* @returns {CodePathSegment[]} The replaced array.
|
23
|
-
*/
|
24
|
-
function flattenUnusedSegments(segments) {
|
25
|
-
const done = Object.create(null);
|
26
|
-
const retv = [];
|
27
|
-
|
28
|
-
for (let i = 0; i < segments.length; ++i) {
|
29
|
-
const segment = segments[i];
|
30
|
-
|
31
|
-
// Ignores duplicated.
|
32
|
-
if (done[segment.id]) {
|
33
|
-
continue;
|
34
|
-
}
|
35
|
-
|
36
|
-
// Use previous segments if unused.
|
37
|
-
if (!segment.internal.used) {
|
38
|
-
for (let j = 0; j < segment.allPrevSegments.length; ++j) {
|
39
|
-
const prevSegment = segment.allPrevSegments[j];
|
40
|
-
|
41
|
-
if (!done[prevSegment.id]) {
|
42
|
-
done[prevSegment.id] = true;
|
43
|
-
retv.push(prevSegment);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
} else {
|
47
|
-
done[segment.id] = true;
|
48
|
-
retv.push(segment);
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
return retv;
|
53
|
-
}
|
54
|
-
|
55
18
|
/**
|
56
19
|
* Checks whether or not a given segment is reachable.
|
57
20
|
*
|
@@ -163,7 +126,7 @@ class CodePathSegment {
|
|
163
126
|
static newNext(id, allPrevSegments) {
|
164
127
|
return new CodePathSegment(
|
165
128
|
id,
|
166
|
-
flattenUnusedSegments(allPrevSegments),
|
129
|
+
CodePathSegment.flattenUnusedSegments(allPrevSegments),
|
167
130
|
allPrevSegments.some(isReachable)
|
168
131
|
);
|
169
132
|
}
|
@@ -176,7 +139,7 @@ class CodePathSegment {
|
|
176
139
|
* @returns {CodePathSegment} The created segment.
|
177
140
|
*/
|
178
141
|
static newUnreachable(id, allPrevSegments) {
|
179
|
-
const segment = new CodePathSegment(id, flattenUnusedSegments(allPrevSegments), false);
|
142
|
+
const segment = new CodePathSegment(id, CodePathSegment.flattenUnusedSegments(allPrevSegments), false);
|
180
143
|
|
181
144
|
// In `if (a) return a; foo();` case, the unreachable segment preceded by
|
182
145
|
// the return statement is not used but must not be remove.
|
@@ -238,6 +201,43 @@ class CodePathSegment {
|
|
238
201
|
static markPrevSegmentAsLooped(segment, prevSegment) {
|
239
202
|
segment.internal.loopedPrevSegments.push(prevSegment);
|
240
203
|
}
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Replaces unused segments with the previous segments of each unused segment.
|
207
|
+
*
|
208
|
+
* @param {CodePathSegment[]} segments - An array of segments to replace.
|
209
|
+
* @returns {CodePathSegment[]} The replaced array.
|
210
|
+
*/
|
211
|
+
static flattenUnusedSegments(segments) {
|
212
|
+
const done = Object.create(null);
|
213
|
+
const retv = [];
|
214
|
+
|
215
|
+
for (let i = 0; i < segments.length; ++i) {
|
216
|
+
const segment = segments[i];
|
217
|
+
|
218
|
+
// Ignores duplicated.
|
219
|
+
if (done[segment.id]) {
|
220
|
+
continue;
|
221
|
+
}
|
222
|
+
|
223
|
+
// Use previous segments if unused.
|
224
|
+
if (!segment.internal.used) {
|
225
|
+
for (let j = 0; j < segment.allPrevSegments.length; ++j) {
|
226
|
+
const prevSegment = segment.allPrevSegments[j];
|
227
|
+
|
228
|
+
if (!done[prevSegment.id]) {
|
229
|
+
done[prevSegment.id] = true;
|
230
|
+
retv.push(prevSegment);
|
231
|
+
}
|
232
|
+
}
|
233
|
+
} else {
|
234
|
+
done[segment.id] = true;
|
235
|
+
retv.push(segment);
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
return retv;
|
240
|
+
}
|
241
241
|
}
|
242
242
|
|
243
243
|
module.exports = CodePathSegment;
|
@@ -169,6 +169,9 @@ function removeConnection(prevSegments, nextSegments) {
|
|
169
169
|
* @returns {void}
|
170
170
|
*/
|
171
171
|
function makeLooped(state, fromSegments, toSegments) {
|
172
|
+
fromSegments = CodePathSegment.flattenUnusedSegments(fromSegments);
|
173
|
+
toSegments = CodePathSegment.flattenUnusedSegments(toSegments);
|
174
|
+
|
172
175
|
const end = Math.min(fromSegments.length, toSegments.length);
|
173
176
|
|
174
177
|
for (let i = 0; i < end; ++i) {
|
@@ -3,6 +3,6 @@
|
|
3
3
|
<td class="clr-<%= severityNumber %>"><%= severityName %></td>
|
4
4
|
<td><%- message %></td>
|
5
5
|
<td>
|
6
|
-
<a href="
|
6
|
+
<a href="https://eslint.org/docs/rules/<%= ruleId %>" target="_blank"><%= ruleId %></a>
|
7
7
|
</td>
|
8
8
|
</tr>
|
package/lib/formatters/html.js
CHANGED
package/lib/ignored-paths.js
CHANGED
@@ -184,7 +184,7 @@ class IgnoredPaths {
|
|
184
184
|
addPattern(this.ig.default, pattern);
|
185
185
|
});
|
186
186
|
} else {
|
187
|
-
throw new
|
187
|
+
throw new TypeError("Package.json eslintIgnore property requires an array of paths");
|
188
188
|
}
|
189
189
|
}
|
190
190
|
}
|