eslint 3.14.0 → 3.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/README.md +1 -1
- package/conf/{eslint.json → eslint-recommended.js} +86 -71
- package/lib/ast-utils.js +192 -24
- package/lib/cli.js +2 -2
- package/lib/code-path-analysis/code-path-state.js +2 -2
- package/lib/config/autoconfig.js +3 -3
- package/lib/config/config-file.js +31 -24
- package/lib/config/config-initializer.js +1 -1
- package/lib/config/config-validator.js +6 -6
- package/lib/config.js +3 -2
- package/lib/eslint.js +18 -18
- package/lib/formatters/checkstyle.js +2 -2
- package/lib/formatters/compact.js +2 -2
- package/lib/formatters/junit.js +2 -2
- package/lib/formatters/tap.js +2 -2
- package/lib/formatters/unix.js +2 -2
- package/lib/formatters/visualstudio.js +2 -2
- package/lib/rules/arrow-body-style.js +7 -4
- package/lib/rules/arrow-spacing.js +7 -6
- package/lib/rules/block-spacing.js +2 -2
- package/lib/rules/brace-style.js +42 -22
- package/lib/rules/capitalized-comments.js +6 -6
- package/lib/rules/comma-spacing.js +16 -16
- package/lib/rules/consistent-return.js +1 -1
- package/lib/rules/constructor-super.js +3 -3
- package/lib/rules/curly.js +11 -7
- package/lib/rules/default-case.js +3 -3
- package/lib/rules/eqeqeq.js +15 -6
- package/lib/rules/func-call-spacing.js +10 -13
- package/lib/rules/func-name-matching.js +1 -1
- package/lib/rules/generator-star-spacing.js +18 -19
- package/lib/rules/global-require.js +2 -2
- package/lib/rules/id-blacklist.js +2 -2
- package/lib/rules/id-length.js +3 -3
- package/lib/rules/id-match.js +2 -2
- package/lib/rules/indent.js +21 -20
- package/lib/rules/key-spacing.js +20 -23
- package/lib/rules/keyword-spacing.js +2 -13
- package/lib/rules/line-comment-position.js +1 -1
- package/lib/rules/linebreak-style.js +7 -1
- package/lib/rules/lines-around-comment.js +4 -4
- package/lib/rules/lines-around-directive.js +3 -3
- package/lib/rules/max-lines.js +2 -2
- package/lib/rules/max-statements-per-line.js +7 -6
- package/lib/rules/new-cap.js +2 -2
- package/lib/rules/newline-after-var.js +7 -2
- package/lib/rules/newline-before-return.js +2 -2
- package/lib/rules/newline-per-chained-call.js +3 -1
- package/lib/rules/no-cond-assign.js +3 -3
- package/lib/rules/no-extend-native.js +3 -3
- package/lib/rules/no-extra-bind.js +3 -4
- package/lib/rules/no-extra-boolean-cast.js +8 -0
- package/lib/rules/no-extra-parens.js +29 -8
- package/lib/rules/no-inner-declarations.js +4 -4
- package/lib/rules/no-irregular-whitespace.js +7 -1
- package/lib/rules/no-lone-blocks.js +10 -10
- package/lib/rules/no-mixed-operators.js +1 -7
- package/lib/rules/no-mixed-requires.js +4 -4
- package/lib/rules/no-multi-spaces.js +4 -1
- package/lib/rules/no-multi-str.js +7 -3
- package/lib/rules/no-redeclare.js +7 -7
- package/lib/rules/no-return-assign.js +7 -14
- package/lib/rules/no-sequences.js +7 -6
- package/lib/rules/no-trailing-spaces.js +8 -2
- package/lib/rules/no-undefined.js +45 -6
- package/lib/rules/no-unexpected-multiline.js +9 -8
- package/lib/rules/no-unneeded-ternary.js +5 -1
- package/lib/rules/no-unused-labels.js +17 -2
- package/lib/rules/no-unused-vars.js +34 -19
- package/lib/rules/no-use-before-define.js +33 -29
- package/lib/rules/no-useless-computed-key.js +8 -3
- package/lib/rules/no-useless-concat.js +10 -7
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-useless-return.js +1 -7
- package/lib/rules/no-var.js +11 -0
- package/lib/rules/no-whitespace-before-property.js +5 -16
- package/lib/rules/object-curly-newline.js +2 -2
- package/lib/rules/object-curly-spacing.js +7 -25
- package/lib/rules/object-property-newline.js +3 -3
- package/lib/rules/object-shorthand.js +10 -10
- package/lib/rules/operator-assignment.js +2 -2
- package/lib/rules/operator-linebreak.js +8 -10
- package/lib/rules/padded-blocks.js +7 -4
- package/lib/rules/prefer-spread.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/quotes.js +10 -6
- package/lib/rules/semi-spacing.js +4 -0
- package/lib/rules/sort-imports.js +4 -4
- package/lib/rules/sort-vars.js +2 -2
- package/lib/rules/space-before-function-paren.js +8 -5
- package/lib/rules/space-in-parens.js +8 -8
- package/lib/rules/spaced-comment.js +10 -10
- package/lib/rules/strict.js +2 -2
- package/lib/rules/template-tag-spacing.js +77 -0
- package/lib/rules/unicode-bom.js +1 -1
- package/lib/rules/wrap-iife.js +5 -5
- package/lib/rules/yoda.js +2 -7
- package/lib/rules.js +2 -2
- package/lib/testers/rule-tester.js +25 -18
- package/lib/token-store/backward-token-comment-cursor.js +57 -0
- package/lib/token-store/backward-token-cursor.js +56 -0
- package/lib/token-store/cursor.js +76 -0
- package/lib/token-store/cursors.js +92 -0
- package/lib/token-store/decorative-cursor.js +39 -0
- package/lib/token-store/filter-cursor.js +43 -0
- package/lib/token-store/forward-token-comment-cursor.js +57 -0
- package/lib/token-store/forward-token-cursor.js +61 -0
- package/lib/token-store/index.js +604 -0
- package/lib/token-store/limit-cursor.js +40 -0
- package/lib/token-store/padded-token-cursor.js +38 -0
- package/lib/token-store/skip-cursor.js +42 -0
- package/lib/token-store/utils.js +100 -0
- package/lib/util/glob.js +1 -1
- package/lib/util/source-code-fixer.js +46 -44
- package/lib/util/source-code.js +35 -19
- package/messages/extend-config-missing.txt +3 -0
- package/package.json +3 -3
- package/lib/token-store.js +0 -203
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,71 @@
|
|
1
|
+
v3.16.1 - February 22, 2017
|
2
|
+
|
3
|
+
* ff8a80c Fix: duplicated autofix output for inverted fix ranges (fixes #8116) (#8117) (Teddy Katz)
|
4
|
+
* a421897 Docs: fix typo in arrow-parens.md (#8132) (Will Chen)
|
5
|
+
* 22d7fbf Chore: fix invalid redeclared variables in tests (#8130) (Teddy Katz)
|
6
|
+
* 8d95598 Chore: fix output assertion typos in rule tests (#8129) (Teddy Katz)
|
7
|
+
* 9fa2559 Docs: Add missing quotes in key-spacing rule (#8121) (Glenn Reyes)
|
8
|
+
* f3a6ced Build: package.json update for eslint-config-eslint release (ESLint Jenkins)
|
9
|
+
|
10
|
+
v3.16.0 - February 20, 2017
|
11
|
+
|
12
|
+
* d89d0b4 Update: fix quotes false negative for string literals as template tags (#8107) (Teddy Katz)
|
13
|
+
* 21be366 Chore: Ensuring eslint:recommended rules are sorted. (#8106) (Kevin Partington)
|
14
|
+
* 360dbe4 Update: Improve error message when extend config missing (fixes #6115) (#8100) (alberto)
|
15
|
+
* f62a724 Chore: use updated token iterator methods (#8103) (Kai Cataldo)
|
16
|
+
* daf6f26 Fix: check output in RuleTester when errors is a number (fixes #7640) (#8097) (alberto)
|
17
|
+
* cfb65c5 Update: make no-lone-blocks report blocks in switch cases (fixes #8047) (#8062) (Teddy Katz)
|
18
|
+
* 290fb1f Update: Add includeComments to getTokenByRangeStart (fixes #8068) (#8069) (Kai Cataldo)
|
19
|
+
* ff066dc Chore: Incorrect source code test text (#8096) (Jack Ford)
|
20
|
+
* 14d146d Docs: Clarify --ext only works with directories (fixes #7939) (#8095) (alberto)
|
21
|
+
* 013a454 Docs: Add TSC meeting quorum requirement (#8086) (Kevin Partington)
|
22
|
+
* 7516303 Fix: `sourceCode.getTokenAfter` shouldn't skip tokens after comments (#8055) (Toru Nagashima)
|
23
|
+
* c53e034 Fix: unicode-bom fixer insert BOM in appropriate location (fixes #8083) (#8084) (pantosha)
|
24
|
+
* 55ac302 Chore: fix the timing to define rules for tests (#8082) (Toru Nagashima)
|
25
|
+
* c7e64f3 Upgrade: mock-fs (#8070) (Toru Nagashima)
|
26
|
+
* acc3301 Update: handle uncommon linebreaks consistently in rules (fixes #7949) (#8049) (Teddy Katz)
|
27
|
+
* 591b74a Chore: enable operator-linebreak on ESLint codebase (#8064) (Teddy Katz)
|
28
|
+
* 6445d2a Docs: Add documentation for /* exported */ (fixes #7998) (#8065) (Lee Yi Min)
|
29
|
+
* fcc38db Chore: simplify and improve performance for autofix (#8035) (Toru Nagashima)
|
30
|
+
* b04fde7 Chore: improve performance of SourceCode constructor (#8054) (Teddy Katz)
|
31
|
+
* 90fd555 Update: improve null detection in eqeqeq for ES6 regexes (fixes #8020) (#8042) (Teddy Katz)
|
32
|
+
* 16248e2 Fix: no-extra-boolean-cast incorrect Boolean() autofixing (fixes #7977) (#8037) (Jonathan Wilsson)
|
33
|
+
* 834f45d Update: rewrite TokenStore (fixes #7810) (#7936) (Toru Nagashima)
|
34
|
+
* 329dcdc Chore: unify checks for statement list parents (#8048) (Teddy Katz)
|
35
|
+
* c596690 Docs: Clarify generator-star-spacing config example (fixes #8027) (#8034) (Hòa Trần)
|
36
|
+
* a11d4a6 Docs: fix a typo in shareable configs documentation (#8036) (Dan Homola)
|
37
|
+
* 1e3d4c6 Update: add fixer for no-unused-labels (#7841) (Teddy Katz)
|
38
|
+
* f47fb98 Update: ensure semi-spacing checks import/export declarations (#8033) (Teddy Katz)
|
39
|
+
* e228d56 Update: no-undefined handles properties/classes/modules (fixes #7964) (#7966) (Kevin Partington)
|
40
|
+
* 7bc92d9 Chore: fix invalid test cases (#8030) (Toru Nagashima)
|
41
|
+
|
42
|
+
v3.15.0 - February 3, 2017
|
43
|
+
|
44
|
+
* f2a3580 Fix: `no-extra-parens` incorrect precedence (fixes #7978) (#7999) (alberto)
|
45
|
+
* d6b6ba1 Fix: no-var should fix ForStatement.init (#7993) (Toru Nagashima)
|
46
|
+
* 99d386d Upgrade: Espree v3.4.0 (#8019) (Kai Cataldo)
|
47
|
+
* 42390fd Docs: update README.md for team (#8016) (Toru Nagashima)
|
48
|
+
* d7ffd88 Chore: enable template-tag-spacing on ESLint codebase (#8005) (Teddy Katz)
|
49
|
+
* f2be7e3 Docs: Fix typo in object-curly-newline.md (#8002) (Danny Andrews)
|
50
|
+
* df2351a Docs: Fix misleading section in brace-style documentation (#7996) (Teddy Katz)
|
51
|
+
* 5ae6e00 Chore: avoid unnecessary feature detection for Symbol (#7992) (Teddy Katz)
|
52
|
+
* 5d57c57 Chore: fix no-else-return lint error (refs #7986) (#7994) (Vitor Balocco)
|
53
|
+
* 62fb054 Chore: enable no-else-return on ESLint codebase (#7986) (Teddy Katz)
|
54
|
+
* c59a0ba Update: add ignoreRestSiblings option to no-unused-vars (#7968) (Zack Argyle)
|
55
|
+
* 5cdfa99 Chore: enable no-unneeded-ternary on ESLint codebase (#7987) (Teddy Katz)
|
56
|
+
* fbd7c13 Update: ensure operator-assignment handles exponentiation operators (#7970) (Teddy Katz)
|
57
|
+
* c5066ce Update: add "variables" option to no-use-before-define (fixes #7111) (#7948) (Teddy Katz)
|
58
|
+
* 09546a4 New: `template-tag-spacing` rule (fixes #7631) (#7913) (Jonathan Wilsson)
|
59
|
+
|
60
|
+
v3.14.1 - January 25, 2017
|
61
|
+
|
62
|
+
* 791f32b Fix: brace-style false positive for keyword method names (fixes #7974) (#7980) (Teddy Katz)
|
63
|
+
* d7a0add Docs: Add ESLint tutorial embed to getting started (#7971) (Jamis Charles)
|
64
|
+
* 72d41f0 Fix: no-var autofix syntax error in single-line statements (fixes #7961) (#7962) (Teddy Katz)
|
65
|
+
* b9e5b68 Fix: indent rule crash on sparse array with object (fixes #7959) (#7960) (Gyandeep Singh)
|
66
|
+
* a7bd66a Chore: Adding assign/redeclare tests to no-undefined (refs #7964) (#7965) (Kevin Partington)
|
67
|
+
* 8bcbf5d Docs: typo in prefer-promise-reject-errors (#7958) (Patrick McElhaney)
|
68
|
+
|
1
69
|
v3.14.0 - January 20, 2017
|
2
70
|
|
3
71
|
* 506324a Fix: `no-var` does not fix if causes ReferenceError (fixes #7950) (#7953) (Toru Nagashima)
|
package/README.md
CHANGED
@@ -112,6 +112,7 @@ These folks keep the project moving and are resources for help.
|
|
112
112
|
* Toru Nagashima ([@mysticatea](https://github.com/mysticatea))
|
113
113
|
* Alberto Rodríguez ([@alberto](https://github.com/alberto))
|
114
114
|
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo))
|
115
|
+
* Teddy Katz ([@not-an-aardvark](https://github.com/not-an-aardvark))
|
115
116
|
|
116
117
|
### Development Team
|
117
118
|
|
@@ -129,7 +130,6 @@ These folks keep the project moving and are resources for help.
|
|
129
130
|
* Kevin Partington ([@platinumazure](https://github.com/platinumazure))
|
130
131
|
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))
|
131
132
|
* James Henry ([@JamesHenry](https://github.com/JamesHenry))
|
132
|
-
* Teddy Katz ([@not-an-aardvark](https://github.com/not-an-aardvark))
|
133
133
|
|
134
134
|
## Releases
|
135
135
|
|
@@ -1,7 +1,81 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
/**
|
2
|
+
* @fileoverview Configuration applied when a user configuration extends from
|
3
|
+
* eslint:recommended.
|
4
|
+
* @author Nicholas C. Zakas
|
5
|
+
*/
|
6
|
+
|
7
|
+
"use strict";
|
8
|
+
|
9
|
+
/* eslint sort-keys: ["error", "asc"], quote-props: ["error", "consistent"] */
|
10
|
+
/* eslint-disable sort-keys */
|
11
|
+
|
12
|
+
module.exports = {
|
13
|
+
parser: "espree",
|
14
|
+
ecmaFeatures: {},
|
15
|
+
|
16
|
+
rules: {
|
17
|
+
|
18
|
+
/* eslint-enable sort-keys */
|
19
|
+
"accessor-pairs": "off",
|
20
|
+
"array-bracket-spacing": "off",
|
21
|
+
"array-callback-return": "off",
|
22
|
+
"arrow-body-style": "off",
|
23
|
+
"arrow-parens": "off",
|
24
|
+
"arrow-spacing": "off",
|
25
|
+
"block-scoped-var": "off",
|
26
|
+
"block-spacing": "off",
|
27
|
+
"brace-style": "off",
|
28
|
+
"callback-return": "off",
|
29
|
+
"camelcase": "off",
|
30
|
+
"capitalized-comments": "off",
|
31
|
+
"class-methods-use-this": "off",
|
32
|
+
"comma-dangle": "off",
|
33
|
+
"comma-spacing": "off",
|
34
|
+
"comma-style": "off",
|
35
|
+
"complexity": "off",
|
36
|
+
"computed-property-spacing": "off",
|
37
|
+
"consistent-return": "off",
|
38
|
+
"consistent-this": "off",
|
39
|
+
"constructor-super": "error",
|
40
|
+
"curly": "off",
|
41
|
+
"default-case": "off",
|
42
|
+
"dot-location": "off",
|
43
|
+
"dot-notation": "off",
|
44
|
+
"eol-last": "off",
|
45
|
+
"eqeqeq": "off",
|
46
|
+
"func-call-spacing": "off",
|
47
|
+
"func-name-matching": "off",
|
48
|
+
"func-names": "off",
|
49
|
+
"func-style": "off",
|
50
|
+
"generator-star-spacing": "off",
|
51
|
+
"global-require": "off",
|
52
|
+
"guard-for-in": "off",
|
53
|
+
"handle-callback-err": "off",
|
54
|
+
"id-blacklist": "off",
|
55
|
+
"id-length": "off",
|
56
|
+
"id-match": "off",
|
57
|
+
"indent": "off",
|
58
|
+
"init-declarations": "off",
|
59
|
+
"jsx-quotes": "off",
|
60
|
+
"key-spacing": "off",
|
61
|
+
"keyword-spacing": "off",
|
62
|
+
"line-comment-position": "off",
|
63
|
+
"linebreak-style": "off",
|
64
|
+
"lines-around-comment": "off",
|
65
|
+
"lines-around-directive": "off",
|
66
|
+
"max-depth": "off",
|
67
|
+
"max-len": "off",
|
68
|
+
"max-lines": "off",
|
69
|
+
"max-nested-callbacks": "off",
|
70
|
+
"max-params": "off",
|
71
|
+
"max-statements": "off",
|
72
|
+
"max-statements-per-line": "off",
|
73
|
+
"multiline-ternary": "off",
|
74
|
+
"new-cap": "off",
|
75
|
+
"new-parens": "off",
|
76
|
+
"newline-after-var": "off",
|
77
|
+
"newline-before-return": "off",
|
78
|
+
"newline-per-chained-call": "off",
|
5
79
|
"no-alert": "off",
|
6
80
|
"no-array-constructor": "off",
|
7
81
|
"no-await-in-loop": "off",
|
@@ -100,20 +174,20 @@
|
|
100
174
|
"no-sequences": "off",
|
101
175
|
"no-shadow": "off",
|
102
176
|
"no-shadow-restricted-names": "off",
|
103
|
-
"no-whitespace-before-property": "off",
|
104
177
|
"no-spaced-func": "off",
|
105
178
|
"no-sparse-arrays": "error",
|
106
179
|
"no-sync": "off",
|
107
180
|
"no-tabs": "off",
|
181
|
+
"no-template-curly-in-string": "off",
|
108
182
|
"no-ternary": "off",
|
109
|
-
"no-trailing-spaces": "off",
|
110
183
|
"no-this-before-super": "error",
|
111
184
|
"no-throw-literal": "off",
|
185
|
+
"no-trailing-spaces": "off",
|
112
186
|
"no-undef": "error",
|
113
187
|
"no-undef-init": "off",
|
114
188
|
"no-undefined": "off",
|
115
|
-
"no-unexpected-multiline": "error",
|
116
189
|
"no-underscore-dangle": "off",
|
190
|
+
"no-unexpected-multiline": "error",
|
117
191
|
"no-unmodified-loop-condition": "off",
|
118
192
|
"no-unneeded-ternary": "off",
|
119
193
|
"no-unreachable": "error",
|
@@ -130,70 +204,11 @@
|
|
130
204
|
"no-useless-escape": "off",
|
131
205
|
"no-useless-rename": "off",
|
132
206
|
"no-useless-return": "off",
|
133
|
-
"no-void": "off",
|
134
207
|
"no-var": "off",
|
208
|
+
"no-void": "off",
|
135
209
|
"no-warning-comments": "off",
|
210
|
+
"no-whitespace-before-property": "off",
|
136
211
|
"no-with": "off",
|
137
|
-
"array-bracket-spacing": "off",
|
138
|
-
"array-callback-return": "off",
|
139
|
-
"arrow-body-style": "off",
|
140
|
-
"arrow-parens": "off",
|
141
|
-
"arrow-spacing": "off",
|
142
|
-
"accessor-pairs": "off",
|
143
|
-
"block-scoped-var": "off",
|
144
|
-
"block-spacing": "off",
|
145
|
-
"brace-style": "off",
|
146
|
-
"callback-return": "off",
|
147
|
-
"camelcase": "off",
|
148
|
-
"capitalized-comments": "off",
|
149
|
-
"class-methods-use-this": "off",
|
150
|
-
"comma-dangle": "off",
|
151
|
-
"comma-spacing": "off",
|
152
|
-
"comma-style": "off",
|
153
|
-
"complexity": "off",
|
154
|
-
"computed-property-spacing": "off",
|
155
|
-
"consistent-return": "off",
|
156
|
-
"consistent-this": "off",
|
157
|
-
"constructor-super": "error",
|
158
|
-
"curly": "off",
|
159
|
-
"default-case": "off",
|
160
|
-
"dot-location": "off",
|
161
|
-
"dot-notation": "off",
|
162
|
-
"eol-last": "off",
|
163
|
-
"eqeqeq": "off",
|
164
|
-
"func-call-spacing": "off",
|
165
|
-
"func-names": "off",
|
166
|
-
"func-name-matching": "off",
|
167
|
-
"func-style": "off",
|
168
|
-
"generator-star-spacing": "off",
|
169
|
-
"global-require": "off",
|
170
|
-
"guard-for-in": "off",
|
171
|
-
"handle-callback-err": "off",
|
172
|
-
"id-blacklist": "off",
|
173
|
-
"id-length": "off",
|
174
|
-
"id-match": "off",
|
175
|
-
"indent": "off",
|
176
|
-
"init-declarations": "off",
|
177
|
-
"jsx-quotes": "off",
|
178
|
-
"key-spacing": "off",
|
179
|
-
"keyword-spacing": "off",
|
180
|
-
"linebreak-style": "off",
|
181
|
-
"line-comment-position": "off",
|
182
|
-
"lines-around-comment": "off",
|
183
|
-
"lines-around-directive": "off",
|
184
|
-
"max-depth": "off",
|
185
|
-
"max-len": "off",
|
186
|
-
"max-lines": "off",
|
187
|
-
"max-nested-callbacks": "off",
|
188
|
-
"max-params": "off",
|
189
|
-
"max-statements": "off",
|
190
|
-
"max-statements-per-line": "off",
|
191
|
-
"multiline-ternary": "off",
|
192
|
-
"new-cap": "off",
|
193
|
-
"new-parens": "off",
|
194
|
-
"newline-after-var": "off",
|
195
|
-
"newline-before-return": "off",
|
196
|
-
"newline-per-chained-call": "off",
|
197
212
|
"object-curly-newline": "off",
|
198
213
|
"object-curly-spacing": ["off", "never"],
|
199
214
|
"object-property-newline": "off",
|
@@ -221,8 +236,8 @@
|
|
221
236
|
"rest-spread-spacing": "off",
|
222
237
|
"semi": "off",
|
223
238
|
"semi-spacing": "off",
|
224
|
-
"sort-keys": "off",
|
225
239
|
"sort-imports": "off",
|
240
|
+
"sort-keys": "off",
|
226
241
|
"sort-vars": "off",
|
227
242
|
"space-before-blocks": "off",
|
228
243
|
"space-before-function-paren": "off",
|
@@ -233,6 +248,7 @@
|
|
233
248
|
"strict": "off",
|
234
249
|
"symbol-description": "off",
|
235
250
|
"template-curly-spacing": "off",
|
251
|
+
"template-tag-spacing": "off",
|
236
252
|
"unicode-bom": "off",
|
237
253
|
"use-isnan": "error",
|
238
254
|
"valid-jsdoc": "off",
|
@@ -240,8 +256,7 @@
|
|
240
256
|
"vars-on-top": "off",
|
241
257
|
"wrap-iife": "off",
|
242
258
|
"wrap-regex": "off",
|
243
|
-
"no-template-curly-in-string": "off",
|
244
259
|
"yield-star-spacing": "off",
|
245
260
|
"yoda": "off"
|
246
261
|
}
|
247
|
-
}
|
262
|
+
};
|
package/lib/ast-utils.js
CHANGED
@@ -24,6 +24,12 @@ const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/;
|
|
24
24
|
const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/;
|
25
25
|
const thisTagPattern = /^[\s*]*@this/m;
|
26
26
|
|
27
|
+
const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
|
28
|
+
const LINEBREAK_MATCHER = /\r\n|[\r\n\u2028\u2029]/;
|
29
|
+
|
30
|
+
// A set of node types that can contain a list of statements
|
31
|
+
const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "SwitchCase"]);
|
32
|
+
|
27
33
|
/**
|
28
34
|
* Checks reference if is non initializer and writable.
|
29
35
|
* @param {Reference} reference - A reference to check.
|
@@ -142,7 +148,7 @@ function isInLoop(node) {
|
|
142
148
|
*/
|
143
149
|
function isNullOrUndefined(node) {
|
144
150
|
return (
|
145
|
-
(node
|
151
|
+
module.exports.isNullLiteral(node) ||
|
146
152
|
(node.type === "Identifier" && node.name === "undefined") ||
|
147
153
|
(node.type === "UnaryExpression" && node.operator === "void")
|
148
154
|
);
|
@@ -210,6 +216,15 @@ function isMethodWhichHasThisArg(node) {
|
|
210
216
|
return false;
|
211
217
|
}
|
212
218
|
|
219
|
+
/**
|
220
|
+
* Creates the negate function of the given function.
|
221
|
+
* @param {Function} f - The function to negate.
|
222
|
+
* @returns {Function} Negated function.
|
223
|
+
*/
|
224
|
+
function negate(f) {
|
225
|
+
return token => !f(token);
|
226
|
+
}
|
227
|
+
|
213
228
|
/**
|
214
229
|
* Checks whether or not a node has a `@this` tag in its comments.
|
215
230
|
* @param {ASTNode} node - A node to check.
|
@@ -247,20 +262,123 @@ function isParenthesised(sourceCode, node) {
|
|
247
262
|
}
|
248
263
|
|
249
264
|
/**
|
250
|
-
*
|
265
|
+
* Checks if the given token is an arrow token or not.
|
251
266
|
*
|
252
|
-
* @param {
|
253
|
-
* @
|
254
|
-
* @returns {Token} `=>` token.
|
267
|
+
* @param {Token} token - The token to check.
|
268
|
+
* @returns {boolean} `true` if the token is an arrow token.
|
255
269
|
*/
|
256
|
-
function
|
257
|
-
|
270
|
+
function isArrowToken(token) {
|
271
|
+
return token.value === "=>" && token.type === "Punctuator";
|
272
|
+
}
|
258
273
|
|
259
|
-
|
260
|
-
|
261
|
-
|
274
|
+
/**
|
275
|
+
* Checks if the given token is a comma token or not.
|
276
|
+
*
|
277
|
+
* @param {Token} token - The token to check.
|
278
|
+
* @returns {boolean} `true` if the token is a comma token.
|
279
|
+
*/
|
280
|
+
function isCommaToken(token) {
|
281
|
+
return token.value === "," && token.type === "Punctuator";
|
282
|
+
}
|
262
283
|
|
263
|
-
|
284
|
+
/**
|
285
|
+
* Checks if the given token is a semicolon token or not.
|
286
|
+
*
|
287
|
+
* @param {Token} token - The token to check.
|
288
|
+
* @returns {boolean} `true` if the token is a semicolon token.
|
289
|
+
*/
|
290
|
+
function isSemicolonToken(token) {
|
291
|
+
return token.value === ";" && token.type === "Punctuator";
|
292
|
+
}
|
293
|
+
|
294
|
+
/**
|
295
|
+
* Checks if the given token is a colon token or not.
|
296
|
+
*
|
297
|
+
* @param {Token} token - The token to check.
|
298
|
+
* @returns {boolean} `true` if the token is a colon token.
|
299
|
+
*/
|
300
|
+
function isColonToken(token) {
|
301
|
+
return token.value === ":" && token.type === "Punctuator";
|
302
|
+
}
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Checks if the given token is an opening parenthesis token or not.
|
306
|
+
*
|
307
|
+
* @param {Token} token - The token to check.
|
308
|
+
* @returns {boolean} `true` if the token is an opening parenthesis token.
|
309
|
+
*/
|
310
|
+
function isOpeningParenToken(token) {
|
311
|
+
return token.value === "(" && token.type === "Punctuator";
|
312
|
+
}
|
313
|
+
|
314
|
+
/**
|
315
|
+
* Checks if the given token is a closing parenthesis token or not.
|
316
|
+
*
|
317
|
+
* @param {Token} token - The token to check.
|
318
|
+
* @returns {boolean} `true` if the token is a closing parenthesis token.
|
319
|
+
*/
|
320
|
+
function isClosingParenToken(token) {
|
321
|
+
return token.value === ")" && token.type === "Punctuator";
|
322
|
+
}
|
323
|
+
|
324
|
+
/**
|
325
|
+
* Checks if the given token is an opening square bracket token or not.
|
326
|
+
*
|
327
|
+
* @param {Token} token - The token to check.
|
328
|
+
* @returns {boolean} `true` if the token is an opening square bracket token.
|
329
|
+
*/
|
330
|
+
function isOpeningBracketToken(token) {
|
331
|
+
return token.value === "[" && token.type === "Punctuator";
|
332
|
+
}
|
333
|
+
|
334
|
+
/**
|
335
|
+
* Checks if the given token is a closing square bracket token or not.
|
336
|
+
*
|
337
|
+
* @param {Token} token - The token to check.
|
338
|
+
* @returns {boolean} `true` if the token is a closing square bracket token.
|
339
|
+
*/
|
340
|
+
function isClosingBracketToken(token) {
|
341
|
+
return token.value === "]" && token.type === "Punctuator";
|
342
|
+
}
|
343
|
+
|
344
|
+
/**
|
345
|
+
* Checks if the given token is an opening brace token or not.
|
346
|
+
*
|
347
|
+
* @param {Token} token - The token to check.
|
348
|
+
* @returns {boolean} `true` if the token is an opening brace token.
|
349
|
+
*/
|
350
|
+
function isOpeningBraceToken(token) {
|
351
|
+
return token.value === "{" && token.type === "Punctuator";
|
352
|
+
}
|
353
|
+
|
354
|
+
/**
|
355
|
+
* Checks if the given token is a closing brace token or not.
|
356
|
+
*
|
357
|
+
* @param {Token} token - The token to check.
|
358
|
+
* @returns {boolean} `true` if the token is a closing brace token.
|
359
|
+
*/
|
360
|
+
function isClosingBraceToken(token) {
|
361
|
+
return token.value === "}" && token.type === "Punctuator";
|
362
|
+
}
|
363
|
+
|
364
|
+
/**
|
365
|
+
* Checks if the given token is a comment token or not.
|
366
|
+
*
|
367
|
+
* @param {Token} token - The token to check.
|
368
|
+
* @returns {boolean} `true` if the token is a comment token.
|
369
|
+
*/
|
370
|
+
function isCommentToken(token) {
|
371
|
+
return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
|
372
|
+
}
|
373
|
+
|
374
|
+
/**
|
375
|
+
* Checks if the given token is a keyword token or not.
|
376
|
+
*
|
377
|
+
* @param {Token} token - The token to check.
|
378
|
+
* @returns {boolean} `true` if the token is a keyword token.
|
379
|
+
*/
|
380
|
+
function isKeywordToken(token) {
|
381
|
+
return token.type === "Keyword";
|
264
382
|
}
|
265
383
|
|
266
384
|
/**
|
@@ -271,13 +389,18 @@ function getArrowToken(node, sourceCode) {
|
|
271
389
|
* @returns {Token} `(` token.
|
272
390
|
*/
|
273
391
|
function getOpeningParenOfParams(node, sourceCode) {
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
}
|
392
|
+
return node.id
|
393
|
+
? sourceCode.getTokenAfter(node.id, isOpeningParenToken)
|
394
|
+
: sourceCode.getFirstToken(node, isOpeningParenToken);
|
395
|
+
}
|
279
396
|
|
280
|
-
|
397
|
+
/**
|
398
|
+
* Creates a version of the LINEBREAK_MATCHER regex with the global flag.
|
399
|
+
* Global regexes are mutable, so this needs to be a function instead of a constant.
|
400
|
+
* @returns {RegExp} A global regular expression that matches line terminators
|
401
|
+
*/
|
402
|
+
function createGlobalLinebreakMatcher() {
|
403
|
+
return new RegExp(LINEBREAK_MATCHER.source, "g");
|
281
404
|
}
|
282
405
|
|
283
406
|
const lineIndexCache = new WeakMap();
|
@@ -291,7 +414,7 @@ function getLineIndices(sourceCode) {
|
|
291
414
|
|
292
415
|
if (!lineIndexCache.has(sourceCode)) {
|
293
416
|
const lineIndices = [0];
|
294
|
-
const lineEndingPattern =
|
417
|
+
const lineEndingPattern = createGlobalLinebreakMatcher();
|
295
418
|
let match;
|
296
419
|
|
297
420
|
/*
|
@@ -319,6 +442,9 @@ function getLineIndices(sourceCode) {
|
|
319
442
|
//------------------------------------------------------------------------------
|
320
443
|
|
321
444
|
module.exports = {
|
445
|
+
LINEBREAKS,
|
446
|
+
LINEBREAK_MATCHER,
|
447
|
+
STATEMENT_LIST_PARENTS,
|
322
448
|
|
323
449
|
/**
|
324
450
|
* Determines whether two adjacent tokens are on the same line.
|
@@ -340,6 +466,29 @@ module.exports = {
|
|
340
466
|
isInLoop,
|
341
467
|
isArrayFromMethod,
|
342
468
|
isParenthesised,
|
469
|
+
createGlobalLinebreakMatcher,
|
470
|
+
|
471
|
+
isArrowToken,
|
472
|
+
isClosingBraceToken,
|
473
|
+
isClosingBracketToken,
|
474
|
+
isClosingParenToken,
|
475
|
+
isColonToken,
|
476
|
+
isCommaToken,
|
477
|
+
isCommentToken,
|
478
|
+
isKeywordToken,
|
479
|
+
isNotClosingBraceToken: negate(isClosingBraceToken),
|
480
|
+
isNotClosingBracketToken: negate(isClosingBracketToken),
|
481
|
+
isNotClosingParenToken: negate(isClosingParenToken),
|
482
|
+
isNotColonToken: negate(isColonToken),
|
483
|
+
isNotCommaToken: negate(isCommaToken),
|
484
|
+
isNotOpeningBraceToken: negate(isOpeningBraceToken),
|
485
|
+
isNotOpeningBracketToken: negate(isOpeningBracketToken),
|
486
|
+
isNotOpeningParenToken: negate(isOpeningParenToken),
|
487
|
+
isNotSemicolonToken: negate(isSemicolonToken),
|
488
|
+
isOpeningBraceToken,
|
489
|
+
isOpeningBracketToken,
|
490
|
+
isOpeningParenToken,
|
491
|
+
isSemicolonToken,
|
343
492
|
|
344
493
|
/**
|
345
494
|
* Checks whether or not a given node is a string literal.
|
@@ -673,6 +822,8 @@ module.exports = {
|
|
673
822
|
case "/":
|
674
823
|
case "%":
|
675
824
|
return 13;
|
825
|
+
case "**":
|
826
|
+
return 15;
|
676
827
|
|
677
828
|
// no default
|
678
829
|
}
|
@@ -681,10 +832,10 @@ module.exports = {
|
|
681
832
|
|
682
833
|
case "UnaryExpression":
|
683
834
|
case "AwaitExpression":
|
684
|
-
return
|
835
|
+
return 16;
|
685
836
|
|
686
837
|
case "UpdateExpression":
|
687
|
-
return
|
838
|
+
return 17;
|
688
839
|
|
689
840
|
case "CallExpression":
|
690
841
|
|
@@ -692,14 +843,14 @@ module.exports = {
|
|
692
843
|
if (node.callee.type === "FunctionExpression") {
|
693
844
|
return -1;
|
694
845
|
}
|
695
|
-
return
|
846
|
+
return 18;
|
696
847
|
|
697
848
|
case "NewExpression":
|
698
|
-
return
|
849
|
+
return 19;
|
699
850
|
|
700
851
|
// no default
|
701
852
|
}
|
702
|
-
return
|
853
|
+
return 20;
|
703
854
|
},
|
704
855
|
|
705
856
|
/**
|
@@ -1038,7 +1189,7 @@ module.exports = {
|
|
1038
1189
|
let end = null;
|
1039
1190
|
|
1040
1191
|
if (node.type === "ArrowFunctionExpression") {
|
1041
|
-
const arrowToken =
|
1192
|
+
const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
|
1042
1193
|
|
1043
1194
|
start = arrowToken.loc.start;
|
1044
1195
|
end = arrowToken.loc.end;
|
@@ -1148,5 +1299,22 @@ module.exports = {
|
|
1148
1299
|
default:
|
1149
1300
|
return false;
|
1150
1301
|
}
|
1302
|
+
},
|
1303
|
+
|
1304
|
+
/**
|
1305
|
+
* Determines whether the given node is a `null` literal.
|
1306
|
+
* @param {ASTNode} node The node to check
|
1307
|
+
* @returns {boolean} `true` if the node is a `null` literal
|
1308
|
+
*/
|
1309
|
+
isNullLiteral(node) {
|
1310
|
+
|
1311
|
+
/*
|
1312
|
+
* Checking `node.value === null` does not guarantee that a literal is a null literal.
|
1313
|
+
* When parsing values that cannot be represented in the current environment (e.g. unicode
|
1314
|
+
* regexes in Node 4), `node.value` is set to `null` because it wouldn't be possible to
|
1315
|
+
* set `node.value` to a unicode regex. To make sure a literal is actually `null`, check
|
1316
|
+
* `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020
|
1317
|
+
*/
|
1318
|
+
return node.type === "Literal" && node.value === null && !node.regex;
|
1151
1319
|
}
|
1152
1320
|
};
|
package/lib/cli.js
CHANGED
@@ -467,8 +467,8 @@ class CodePathState {
|
|
467
467
|
* Creates the next path from own true/false fork context.
|
468
468
|
*/
|
469
469
|
const prevForkContext =
|
470
|
-
context.kind === "&&" ? context.trueForkContext
|
471
|
-
/* kind === "||" */ context.falseForkContext;
|
470
|
+
context.kind === "&&" ? context.trueForkContext
|
471
|
+
/* kind === "||" */ : context.falseForkContext;
|
472
472
|
|
473
473
|
forkContext.replaceHead(prevForkContext.makeNext(0, -1));
|
474
474
|
prevForkContext.clear();
|
package/lib/config/autoconfig.js
CHANGED
@@ -13,7 +13,7 @@ const lodash = require("lodash"),
|
|
13
13
|
eslint = require("../eslint"),
|
14
14
|
configRule = require("./config-rule"),
|
15
15
|
ConfigOps = require("./config-ops"),
|
16
|
-
recConfig = require("../../conf/eslint
|
16
|
+
recConfig = require("../../conf/eslint-recommended");
|
17
17
|
|
18
18
|
const debug = require("debug")("eslint:autoconfig");
|
19
19
|
|
@@ -300,8 +300,8 @@ class Registry {
|
|
300
300
|
// (https://github.com/eslint/eslint/issues/5992)
|
301
301
|
// (https://github.com/eslint/eslint/issues/7860)
|
302
302
|
if (
|
303
|
-
lintedRegistry.rules[result.ruleId]
|
304
|
-
|
303
|
+
lintedRegistry.rules[result.ruleId] &&
|
304
|
+
lintedRegistry.rules[result.ruleId][ruleSetIdx]
|
305
305
|
) {
|
306
306
|
lintedRegistry.rules[result.ruleId][ruleSetIdx].errorCount += 1;
|
307
307
|
}
|