eslint 6.5.1 → 6.6.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 +54 -0
- package/README.md +4 -3
- package/lib/cli-engine/cascading-config-array-factory.js +2 -1
- package/lib/cli-engine/cli-engine.js +9 -7
- package/lib/cli-engine/config-array/config-array.js +0 -4
- package/lib/cli-engine/config-array/config-dependency.js +2 -0
- package/lib/cli-engine/config-array/override-tester.js +2 -0
- package/lib/cli-engine/config-array-factory.js +7 -1
- package/lib/cli-engine/file-enumerator.js +5 -3
- package/lib/cli-engine/formatters/html.js +1 -0
- package/lib/cli-engine/ignored-paths.js +1 -0
- package/lib/init/autoconfig.js +1 -11
- package/lib/init/config-file.js +0 -1
- package/lib/init/config-initializer.js +0 -1
- package/lib/init/config-rule.js +1 -5
- package/lib/init/npm-utils.js +0 -5
- package/lib/linter/code-path-analysis/code-path-analyzer.js +24 -38
- package/lib/linter/code-path-analysis/code-path-segment.js +17 -25
- package/lib/linter/code-path-analysis/code-path-state.js +40 -81
- package/lib/linter/code-path-analysis/code-path.js +10 -11
- package/lib/linter/code-path-analysis/debug-helpers.js +8 -12
- package/lib/linter/code-path-analysis/fork-context.js +23 -34
- package/lib/linter/code-path-analysis/id-generator.js +2 -2
- package/lib/linter/linter.js +121 -95
- package/lib/linter/node-event-generator.js +3 -2
- package/lib/rule-tester/rule-tester.js +6 -8
- package/lib/rules/accessor-pairs.js +8 -8
- package/lib/rules/array-bracket-newline.js +12 -15
- package/lib/rules/array-bracket-spacing.js +12 -12
- package/lib/rules/array-callback-return.js +6 -11
- package/lib/rules/array-element-newline.js +5 -8
- package/lib/rules/arrow-parens.js +0 -1
- package/lib/rules/block-scoped-var.js +3 -3
- package/lib/rules/block-spacing.js +4 -4
- package/lib/rules/capitalized-comments.js +0 -7
- package/lib/rules/class-methods-use-this.js +3 -3
- package/lib/rules/comma-dangle.js +15 -23
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/computed-property-spacing.js +10 -10
- package/lib/rules/consistent-return.js +4 -5
- package/lib/rules/consistent-this.js +5 -5
- package/lib/rules/constructor-super.js +14 -16
- package/lib/rules/curly.js +3 -5
- package/lib/rules/default-param-last.js +1 -0
- package/lib/rules/dot-location.js +11 -12
- package/lib/rules/func-names.js +6 -6
- package/lib/rules/function-call-argument-newline.js +5 -5
- package/lib/rules/generator-star-spacing.js +4 -9
- package/lib/rules/getter-return.js +4 -7
- package/lib/rules/indent.js +2 -2
- package/lib/rules/init-declarations.js +2 -2
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/keyword-spacing.js +32 -56
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/max-len.js +0 -5
- package/lib/rules/max-statements-per-line.js +3 -7
- package/lib/rules/multiline-ternary.js +3 -3
- package/lib/rules/newline-after-var.js +6 -7
- package/lib/rules/newline-before-return.js +8 -9
- package/lib/rules/newline-per-chained-call.js +2 -4
- package/lib/rules/no-class-assign.js +2 -2
- package/lib/rules/no-compare-neg-zero.js +1 -2
- package/lib/rules/no-confusing-arrow.js +2 -2
- package/lib/rules/no-console.js +4 -8
- package/lib/rules/no-const-assign.js +1 -1
- package/lib/rules/no-dupe-args.js +1 -1
- package/lib/rules/no-dupe-class-members.js +3 -4
- package/lib/rules/no-dupe-keys.js +6 -5
- package/lib/rules/no-duplicate-imports.js +14 -18
- package/lib/rules/no-else-return.js +0 -8
- package/lib/rules/no-empty-function.js +2 -4
- package/lib/rules/no-eval.js +10 -18
- package/lib/rules/no-ex-assign.js +1 -1
- package/lib/rules/no-extra-bind.js +5 -12
- package/lib/rules/no-extra-boolean-cast.js +0 -2
- package/lib/rules/no-extra-label.js +4 -9
- package/lib/rules/no-extra-parens.js +17 -15
- package/lib/rules/no-extra-semi.js +5 -6
- package/lib/rules/no-fallthrough.js +6 -6
- package/lib/rules/no-func-assign.js +3 -3
- package/lib/rules/no-global-assign.js +4 -4
- package/lib/rules/no-implicit-coercion.js +10 -10
- package/lib/rules/no-implied-eval.js +0 -1
- package/lib/rules/no-invalid-this.js +1 -3
- package/lib/rules/no-labels.js +3 -6
- package/lib/rules/no-lone-blocks.js +1 -1
- package/lib/rules/no-loop-func.js +6 -11
- package/lib/rules/no-magic-numbers.js +6 -6
- package/lib/rules/no-misleading-character-class.js +14 -7
- package/lib/rules/no-mixed-operators.js +13 -22
- package/lib/rules/no-mixed-requires.js +0 -1
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-native-reassign.js +4 -4
- package/lib/rules/no-param-reassign.js +28 -7
- package/lib/rules/no-redeclare.js +1 -1
- package/lib/rules/no-regex-spaces.js +0 -1
- package/lib/rules/no-restricted-imports.js +11 -11
- package/lib/rules/no-self-assign.js +12 -13
- package/lib/rules/no-sequences.js +3 -3
- package/lib/rules/no-shadow.js +1 -4
- package/lib/rules/no-tabs.js +8 -2
- package/lib/rules/no-this-before-super.js +12 -13
- package/lib/rules/no-trailing-spaces.js +19 -7
- package/lib/rules/no-unmodified-loop-condition.js +16 -29
- package/lib/rules/no-unneeded-ternary.js +3 -3
- package/lib/rules/no-unreachable.js +7 -7
- package/lib/rules/no-unsafe-finally.js +4 -7
- package/lib/rules/no-unsafe-negation.js +32 -9
- package/lib/rules/no-unused-expressions.js +11 -7
- package/lib/rules/no-unused-labels.js +3 -6
- package/lib/rules/no-unused-vars.js +22 -29
- package/lib/rules/no-use-before-define.js +10 -15
- package/lib/rules/no-useless-call.js +4 -4
- package/lib/rules/no-useless-concat.js +4 -4
- package/lib/rules/no-useless-constructor.js +14 -22
- package/lib/rules/no-useless-escape.js +3 -5
- package/lib/rules/no-useless-rename.js +7 -7
- package/lib/rules/no-useless-return.js +8 -15
- package/lib/rules/no-var.js +12 -25
- package/lib/rules/no-warning-comments.js +0 -1
- package/lib/rules/no-whitespace-before-property.js +3 -3
- package/lib/rules/object-curly-newline.js +7 -10
- package/lib/rules/object-curly-spacing.js +13 -14
- package/lib/rules/object-shorthand.js +1 -1
- package/lib/rules/one-var-declaration-per-line.js +2 -2
- package/lib/rules/operator-assignment.js +22 -1
- package/lib/rules/padded-blocks.js +1 -1
- package/lib/rules/padding-line-between-statements.js +0 -16
- package/lib/rules/prefer-arrow-callback.js +6 -6
- package/lib/rules/prefer-const.js +13 -21
- package/lib/rules/prefer-destructuring.js +1 -7
- package/lib/rules/prefer-named-capture-group.js +0 -1
- package/lib/rules/prefer-numeric-literals.js +32 -4
- package/lib/rules/prefer-object-spread.js +7 -7
- package/lib/rules/prefer-rest-params.js +3 -6
- package/lib/rules/prefer-spread.js +4 -4
- package/lib/rules/prefer-template.js +5 -6
- package/lib/rules/quote-props.js +1 -1
- package/lib/rules/quotes.js +5 -6
- package/lib/rules/radix.js +5 -10
- package/lib/rules/require-await.js +2 -5
- package/lib/rules/require-yield.js +2 -2
- package/lib/rules/rest-spread-spacing.js +1 -1
- package/lib/rules/sort-imports.js +3 -4
- package/lib/rules/sort-keys.js +1 -3
- package/lib/rules/space-before-blocks.js +1 -2
- package/lib/rules/space-in-parens.js +4 -4
- package/lib/rules/space-infix-ops.js +5 -5
- package/lib/rules/spaced-comment.js +15 -18
- package/lib/rules/strict.js +2 -4
- package/lib/rules/symbol-description.js +1 -2
- package/lib/rules/template-curly-spacing.js +2 -2
- package/lib/rules/use-isnan.js +40 -3
- package/lib/rules/utils/ast-utils.js +53 -81
- package/lib/rules/utils/fix-tracker.js +0 -6
- package/lib/rules/utils/lazy-loading-rule-map.js +0 -1
- package/lib/rules/vars-on-top.js +11 -11
- package/lib/shared/config-ops.js +2 -2
- package/lib/shared/runtime-info.js +8 -8
- package/lib/shared/traverser.js +2 -0
- package/lib/source-code/source-code.js +8 -8
- package/lib/source-code/token-store/backward-token-comment-cursor.js +5 -5
- package/lib/source-code/token-store/backward-token-cursor.js +5 -5
- package/lib/source-code/token-store/cursors.js +17 -19
- package/lib/source-code/token-store/decorative-cursor.js +1 -1
- package/lib/source-code/token-store/filter-cursor.js +2 -2
- package/lib/source-code/token-store/forward-token-comment-cursor.js +5 -5
- package/lib/source-code/token-store/forward-token-cursor.js +5 -5
- package/lib/source-code/token-store/index.js +86 -92
- package/lib/source-code/token-store/limit-cursor.js +2 -2
- package/lib/source-code/token-store/padded-token-cursor.js +7 -7
- package/lib/source-code/token-store/skip-cursor.js +2 -2
- package/lib/source-code/token-store/utils.js +9 -13
- package/package.json +6 -5
@@ -78,9 +78,8 @@ module.exports = {
|
|
78
78
|
|
79
79
|
/**
|
80
80
|
* Returns resolved option definitions based on an option and defaults
|
81
|
-
*
|
82
|
-
* @param {
|
83
|
-
* @param {Object} defaults - The defaults to use if options are not present
|
81
|
+
* @param {any} option The option object or string value
|
82
|
+
* @param {Object} defaults The defaults to use if options are not present
|
84
83
|
* @returns {Object} the resolved object definition
|
85
84
|
*/
|
86
85
|
function optionToDefinition(option, defaults) {
|
@@ -107,8 +106,7 @@ module.exports = {
|
|
107
106
|
|
108
107
|
/**
|
109
108
|
* Checks if the given token is a star token or not.
|
110
|
-
*
|
111
|
-
* @param {Token} token - The token to check.
|
109
|
+
* @param {Token} token The token to check.
|
112
110
|
* @returns {boolean} `true` if the token is a star token.
|
113
111
|
*/
|
114
112
|
function isStarToken(token) {
|
@@ -117,8 +115,7 @@ module.exports = {
|
|
117
115
|
|
118
116
|
/**
|
119
117
|
* Gets the generator star token of the given function node.
|
120
|
-
*
|
121
|
-
* @param {ASTNode} node - The function node to get.
|
118
|
+
* @param {ASTNode} node The function node to get.
|
122
119
|
* @returns {Token} Found star token.
|
123
120
|
*/
|
124
121
|
function getStarToken(node) {
|
@@ -139,7 +136,6 @@ module.exports = {
|
|
139
136
|
|
140
137
|
/**
|
141
138
|
* Checks the spacing between two tokens before or after the star token.
|
142
|
-
*
|
143
139
|
* @param {string} kind Either "named", "anonymous", or "method"
|
144
140
|
* @param {string} side Either "before" or "after".
|
145
141
|
* @param {Token} leftToken `function` keyword token if side is "before", or
|
@@ -173,7 +169,6 @@ module.exports = {
|
|
173
169
|
|
174
170
|
/**
|
175
171
|
* Enforces the spacing around the star if node is a generator function.
|
176
|
-
*
|
177
172
|
* @param {ASTNode} node A function expression or declaration node.
|
178
173
|
* @returns {void}
|
179
174
|
*/
|
@@ -18,8 +18,7 @@ const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
|
|
18
18
|
|
19
19
|
/**
|
20
20
|
* Checks a given code path segment is reachable.
|
21
|
-
*
|
22
|
-
* @param {CodePathSegment} segment - A segment to check.
|
21
|
+
* @param {CodePathSegment} segment A segment to check.
|
23
22
|
* @returns {boolean} `true` if the segment is reachable.
|
24
23
|
*/
|
25
24
|
function isReachable(segment) {
|
@@ -30,8 +29,7 @@ function isReachable(segment) {
|
|
30
29
|
* Gets a readable location.
|
31
30
|
*
|
32
31
|
* - FunctionExpression -> the function name or `function` keyword.
|
33
|
-
*
|
34
|
-
* @param {ASTNode} node - A function node to get.
|
32
|
+
* @param {ASTNode} node A function node to get.
|
35
33
|
* @returns {ASTNode|Token} The node or the token of a location.
|
36
34
|
*/
|
37
35
|
function getId(node) {
|
@@ -92,8 +90,7 @@ module.exports = {
|
|
92
90
|
*
|
93
91
|
* If the last code path segment is reachable, there are paths which are not
|
94
92
|
* returned or thrown.
|
95
|
-
*
|
96
|
-
* @param {ASTNode} node - A node to check.
|
93
|
+
* @param {ASTNode} node A node to check.
|
97
94
|
* @returns {void}
|
98
95
|
*/
|
99
96
|
function checkLastSegment(node) {
|
@@ -113,7 +110,7 @@ module.exports = {
|
|
113
110
|
|
114
111
|
/**
|
115
112
|
* Checks whether a node means a getter function.
|
116
|
-
* @param {ASTNode} node
|
113
|
+
* @param {ASTNode} node a node to check.
|
117
114
|
* @returns {boolean} if node means a getter, return true; else return false.
|
118
115
|
*/
|
119
116
|
function isGetter(node) {
|
package/lib/rules/indent.js
CHANGED
@@ -187,6 +187,7 @@ class BinarySearchTree {
|
|
187
187
|
*/
|
188
188
|
class TokenInfo {
|
189
189
|
|
190
|
+
// eslint-disable-next-line jsdoc/require-description
|
190
191
|
/**
|
191
192
|
* @param {SourceCode} sourceCode A SourceCode object
|
192
193
|
*/
|
@@ -236,6 +237,7 @@ class TokenInfo {
|
|
236
237
|
*/
|
237
238
|
class OffsetStorage {
|
238
239
|
|
240
|
+
// eslint-disable-next-line jsdoc/require-description
|
239
241
|
/**
|
240
242
|
* @param {TokenInfo} tokenInfo a TokenInfo instance
|
241
243
|
* @param {number} indentSize The desired size of each indentation level
|
@@ -329,7 +331,6 @@ class OffsetStorage {
|
|
329
331
|
* Instead, the correct way would be to offset `baz` by 1 level from `bar`, offset `bar` by 1 level from the `)`, and
|
330
332
|
* offset the `)` by 0 levels from `foo`. This ensures that the offset between `bar` and the `)` are correctly collapsed
|
331
333
|
* in the second case.
|
332
|
-
*
|
333
334
|
* @param {Token} token The token
|
334
335
|
* @param {Token} fromToken The token that `token` should be offset from
|
335
336
|
* @param {number} offset The desired indent level
|
@@ -358,7 +359,6 @@ class OffsetStorage {
|
|
358
359
|
*
|
359
360
|
* The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using:
|
360
361
|
* `setDesiredOffsets([30, 43], fooToken, 1);`
|
361
|
-
*
|
362
362
|
* @param {[number, number]} range A [start, end] pair. All tokens with range[0] <= token.start < range[1] will have the offset applied.
|
363
363
|
* @param {Token} fromToken The token that this is offset from
|
364
364
|
* @param {number} offset The desired indent level
|
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
/**
|
13
13
|
* Checks whether or not a given node is a for loop.
|
14
|
-
* @param {ASTNode} block
|
14
|
+
* @param {ASTNode} block A node to check.
|
15
15
|
* @returns {boolean} `true` when the node is a for loop.
|
16
16
|
*/
|
17
17
|
function isForLoop(block) {
|
@@ -22,7 +22,7 @@ function isForLoop(block) {
|
|
22
22
|
|
23
23
|
/**
|
24
24
|
* Checks whether or not a given declarator node has its initializer.
|
25
|
-
* @param {ASTNode} node
|
25
|
+
* @param {ASTNode} node A declarator node to check.
|
26
26
|
* @returns {boolean} `true` when the node has its initializer.
|
27
27
|
*/
|
28
28
|
function isInitialized(node) {
|
package/lib/rules/jsx-quotes.js
CHANGED
@@ -65,7 +65,7 @@ module.exports = {
|
|
65
65
|
|
66
66
|
/**
|
67
67
|
* Checks if the given string literal node uses the expected quotes
|
68
|
-
* @param {ASTNode} node
|
68
|
+
* @param {ASTNode} node A string literal node.
|
69
69
|
* @returns {boolean} Whether or not the string literal used the expected quotes.
|
70
70
|
* @public
|
71
71
|
*/
|
@@ -41,8 +41,7 @@ const KEYS = keywords.concat(["as", "async", "await", "from", "get", "let", "of"
|
|
41
41
|
|
42
42
|
/**
|
43
43
|
* Checks whether or not a given token is a "Template" token ends with "${".
|
44
|
-
*
|
45
|
-
* @param {Token} token - A token to check.
|
44
|
+
* @param {Token} token A token to check.
|
46
45
|
* @returns {boolean} `true` if the token is a "Template" token ends with "${".
|
47
46
|
*/
|
48
47
|
function isOpenParenOfTemplate(token) {
|
@@ -51,8 +50,7 @@ function isOpenParenOfTemplate(token) {
|
|
51
50
|
|
52
51
|
/**
|
53
52
|
* Checks whether or not a given token is a "Template" token starts with "}".
|
54
|
-
*
|
55
|
-
* @param {Token} token - A token to check.
|
53
|
+
* @param {Token} token A token to check.
|
56
54
|
* @returns {boolean} `true` if the token is a "Template" token starts with "}".
|
57
55
|
*/
|
58
56
|
function isCloseParenOfTemplate(token) {
|
@@ -88,8 +86,8 @@ module.exports = {
|
|
88
86
|
retv[key] = {
|
89
87
|
type: "object",
|
90
88
|
properties: {
|
91
|
-
before: { type: "boolean"
|
92
|
-
after: { type: "boolean"
|
89
|
+
before: { type: "boolean" },
|
90
|
+
after: { type: "boolean" }
|
93
91
|
},
|
94
92
|
additionalProperties: false
|
95
93
|
};
|
@@ -114,9 +112,8 @@ module.exports = {
|
|
114
112
|
|
115
113
|
/**
|
116
114
|
* Reports a given token if there are not space(s) before the token.
|
117
|
-
*
|
118
|
-
* @param {
|
119
|
-
* @param {RegExp} pattern - A pattern of the previous token to check.
|
115
|
+
* @param {Token} token A token to report.
|
116
|
+
* @param {RegExp} pattern A pattern of the previous token to check.
|
120
117
|
* @returns {void}
|
121
118
|
*/
|
122
119
|
function expectSpaceBefore(token, pattern) {
|
@@ -141,9 +138,8 @@ module.exports = {
|
|
141
138
|
|
142
139
|
/**
|
143
140
|
* Reports a given token if there are space(s) before the token.
|
144
|
-
*
|
145
|
-
* @param {
|
146
|
-
* @param {RegExp} pattern - A pattern of the previous token to check.
|
141
|
+
* @param {Token} token A token to report.
|
142
|
+
* @param {RegExp} pattern A pattern of the previous token to check.
|
147
143
|
* @returns {void}
|
148
144
|
*/
|
149
145
|
function unexpectSpaceBefore(token, pattern) {
|
@@ -168,9 +164,8 @@ module.exports = {
|
|
168
164
|
|
169
165
|
/**
|
170
166
|
* Reports a given token if there are not space(s) after the token.
|
171
|
-
*
|
172
|
-
* @param {
|
173
|
-
* @param {RegExp} pattern - A pattern of the next token to check.
|
167
|
+
* @param {Token} token A token to report.
|
168
|
+
* @param {RegExp} pattern A pattern of the next token to check.
|
174
169
|
* @returns {void}
|
175
170
|
*/
|
176
171
|
function expectSpaceAfter(token, pattern) {
|
@@ -195,9 +190,8 @@ module.exports = {
|
|
195
190
|
|
196
191
|
/**
|
197
192
|
* Reports a given token if there are space(s) after the token.
|
198
|
-
*
|
199
|
-
* @param {
|
200
|
-
* @param {RegExp} pattern - A pattern of the next token to check.
|
193
|
+
* @param {Token} token A token to report.
|
194
|
+
* @param {RegExp} pattern A pattern of the next token to check.
|
201
195
|
* @returns {void}
|
202
196
|
*/
|
203
197
|
function unexpectSpaceAfter(token, pattern) {
|
@@ -222,8 +216,7 @@ module.exports = {
|
|
222
216
|
|
223
217
|
/**
|
224
218
|
* Parses the option object and determines check methods for each keyword.
|
225
|
-
*
|
226
|
-
* @param {Object|undefined} options - The option object to parse.
|
219
|
+
* @param {Object|undefined} options The option object to parse.
|
227
220
|
* @returns {Object} - Normalized option object.
|
228
221
|
* Keys are keywords (there are for every keyword).
|
229
222
|
* Values are instances of `{"before": function, "after": function}`.
|
@@ -263,9 +256,8 @@ module.exports = {
|
|
263
256
|
/**
|
264
257
|
* Reports a given token if usage of spacing followed by the token is
|
265
258
|
* invalid.
|
266
|
-
*
|
267
|
-
* @param {
|
268
|
-
* @param {RegExp|undefined} pattern - Optional. A pattern of the previous
|
259
|
+
* @param {Token} token A token to report.
|
260
|
+
* @param {RegExp} [pattern] Optional. A pattern of the previous
|
269
261
|
* token to check.
|
270
262
|
* @returns {void}
|
271
263
|
*/
|
@@ -276,9 +268,8 @@ module.exports = {
|
|
276
268
|
/**
|
277
269
|
* Reports a given token if usage of spacing preceded by the token is
|
278
270
|
* invalid.
|
279
|
-
*
|
280
|
-
* @param {
|
281
|
-
* @param {RegExp|undefined} pattern - Optional. A pattern of the next
|
271
|
+
* @param {Token} token A token to report.
|
272
|
+
* @param {RegExp} [pattern] Optional. A pattern of the next
|
282
273
|
* token to check.
|
283
274
|
* @returns {void}
|
284
275
|
*/
|
@@ -288,8 +279,7 @@ module.exports = {
|
|
288
279
|
|
289
280
|
/**
|
290
281
|
* Reports a given token if usage of spacing around the token is invalid.
|
291
|
-
*
|
292
|
-
* @param {Token} token - A token to report.
|
282
|
+
* @param {Token} token A token to report.
|
293
283
|
* @returns {void}
|
294
284
|
*/
|
295
285
|
function checkSpacingAround(token) {
|
@@ -300,8 +290,7 @@ module.exports = {
|
|
300
290
|
/**
|
301
291
|
* Reports the first token of a given node if the first token is a keyword
|
302
292
|
* and usage of spacing around the token is invalid.
|
303
|
-
*
|
304
|
-
* @param {ASTNode|null} node - A node to report.
|
293
|
+
* @param {ASTNode|null} node A node to report.
|
305
294
|
* @returns {void}
|
306
295
|
*/
|
307
296
|
function checkSpacingAroundFirstToken(node) {
|
@@ -318,8 +307,7 @@ module.exports = {
|
|
318
307
|
*
|
319
308
|
* This is used for unary operators (e.g. `typeof`), `function`, and `super`.
|
320
309
|
* Other rules are handling usage of spacing preceded by those keywords.
|
321
|
-
*
|
322
|
-
* @param {ASTNode|null} node - A node to report.
|
310
|
+
* @param {ASTNode|null} node A node to report.
|
323
311
|
* @returns {void}
|
324
312
|
*/
|
325
313
|
function checkSpacingBeforeFirstToken(node) {
|
@@ -333,8 +321,7 @@ module.exports = {
|
|
333
321
|
/**
|
334
322
|
* Reports the previous token of a given node if the token is a keyword and
|
335
323
|
* usage of spacing around the token is invalid.
|
336
|
-
*
|
337
|
-
* @param {ASTNode|null} node - A node to report.
|
324
|
+
* @param {ASTNode|null} node A node to report.
|
338
325
|
* @returns {void}
|
339
326
|
*/
|
340
327
|
function checkSpacingAroundTokenBefore(node) {
|
@@ -348,8 +335,7 @@ module.exports = {
|
|
348
335
|
/**
|
349
336
|
* Reports `async` or `function` keywords of a given node if usage of
|
350
337
|
* spacing around those keywords is invalid.
|
351
|
-
*
|
352
|
-
* @param {ASTNode} node - A node to report.
|
338
|
+
* @param {ASTNode} node A node to report.
|
353
339
|
* @returns {void}
|
354
340
|
*/
|
355
341
|
function checkSpacingForFunction(node) {
|
@@ -366,8 +352,7 @@ module.exports = {
|
|
366
352
|
/**
|
367
353
|
* Reports `class` and `extends` keywords of a given node if usage of
|
368
354
|
* spacing around those keywords is invalid.
|
369
|
-
*
|
370
|
-
* @param {ASTNode} node - A node to report.
|
355
|
+
* @param {ASTNode} node A node to report.
|
371
356
|
* @returns {void}
|
372
357
|
*/
|
373
358
|
function checkSpacingForClass(node) {
|
@@ -378,8 +363,7 @@ module.exports = {
|
|
378
363
|
/**
|
379
364
|
* Reports `if` and `else` keywords of a given node if usage of spacing
|
380
365
|
* around those keywords is invalid.
|
381
|
-
*
|
382
|
-
* @param {ASTNode} node - A node to report.
|
366
|
+
* @param {ASTNode} node A node to report.
|
383
367
|
* @returns {void}
|
384
368
|
*/
|
385
369
|
function checkSpacingForIfStatement(node) {
|
@@ -390,8 +374,7 @@ module.exports = {
|
|
390
374
|
/**
|
391
375
|
* Reports `try`, `catch`, and `finally` keywords of a given node if usage
|
392
376
|
* of spacing around those keywords is invalid.
|
393
|
-
*
|
394
|
-
* @param {ASTNode} node - A node to report.
|
377
|
+
* @param {ASTNode} node A node to report.
|
395
378
|
* @returns {void}
|
396
379
|
*/
|
397
380
|
function checkSpacingForTryStatement(node) {
|
@@ -403,8 +386,7 @@ module.exports = {
|
|
403
386
|
/**
|
404
387
|
* Reports `do` and `while` keywords of a given node if usage of spacing
|
405
388
|
* around those keywords is invalid.
|
406
|
-
*
|
407
|
-
* @param {ASTNode} node - A node to report.
|
389
|
+
* @param {ASTNode} node A node to report.
|
408
390
|
* @returns {void}
|
409
391
|
*/
|
410
392
|
function checkSpacingForDoWhileStatement(node) {
|
@@ -415,8 +397,7 @@ module.exports = {
|
|
415
397
|
/**
|
416
398
|
* Reports `for` and `in` keywords of a given node if usage of spacing
|
417
399
|
* around those keywords is invalid.
|
418
|
-
*
|
419
|
-
* @param {ASTNode} node - A node to report.
|
400
|
+
* @param {ASTNode} node A node to report.
|
420
401
|
* @returns {void}
|
421
402
|
*/
|
422
403
|
function checkSpacingForForInStatement(node) {
|
@@ -427,8 +408,7 @@ module.exports = {
|
|
427
408
|
/**
|
428
409
|
* Reports `for` and `of` keywords of a given node if usage of spacing
|
429
410
|
* around those keywords is invalid.
|
430
|
-
*
|
431
|
-
* @param {ASTNode} node - A node to report.
|
411
|
+
* @param {ASTNode} node A node to report.
|
432
412
|
* @returns {void}
|
433
413
|
*/
|
434
414
|
function checkSpacingForForOfStatement(node) {
|
@@ -449,8 +429,7 @@ module.exports = {
|
|
449
429
|
*
|
450
430
|
* import*as A from "./a"; /*error Expected space(s) after "import".
|
451
431
|
* error Expected space(s) before "as".
|
452
|
-
*
|
453
|
-
* @param {ASTNode} node - A node to report.
|
432
|
+
* @param {ASTNode} node A node to report.
|
454
433
|
* @returns {void}
|
455
434
|
*/
|
456
435
|
function checkSpacingForModuleDeclaration(node) {
|
@@ -474,8 +453,7 @@ module.exports = {
|
|
474
453
|
/**
|
475
454
|
* Reports `as` keyword of a given node if usage of spacing around this
|
476
455
|
* keyword is invalid.
|
477
|
-
*
|
478
|
-
* @param {ASTNode} node - A node to report.
|
456
|
+
* @param {ASTNode} node A node to report.
|
479
457
|
* @returns {void}
|
480
458
|
*/
|
481
459
|
function checkSpacingForImportNamespaceSpecifier(node) {
|
@@ -487,8 +465,7 @@ module.exports = {
|
|
487
465
|
/**
|
488
466
|
* Reports `static`, `get`, and `set` keywords of a given node if usage of
|
489
467
|
* spacing around those keywords is invalid.
|
490
|
-
*
|
491
|
-
* @param {ASTNode} node - A node to report.
|
468
|
+
* @param {ASTNode} node A node to report.
|
492
469
|
* @returns {void}
|
493
470
|
*/
|
494
471
|
function checkSpacingForProperty(node) {
|
@@ -528,8 +505,7 @@ module.exports = {
|
|
528
505
|
/**
|
529
506
|
* Reports `await` keyword of a given node if usage of spacing before
|
530
507
|
* this keyword is invalid.
|
531
|
-
*
|
532
|
-
* @param {ASTNode} node - A node to report.
|
508
|
+
* @param {ASTNode} node A node to report.
|
533
509
|
* @returns {void}
|
534
510
|
*/
|
535
511
|
function checkSpacingForAwaitExpression(node) {
|
package/lib/rules/max-len.js
CHANGED
@@ -198,7 +198,6 @@ module.exports = {
|
|
198
198
|
|
199
199
|
/**
|
200
200
|
* Ensure that an array exists at [key] on `object`, and add `value` to it.
|
201
|
-
*
|
202
201
|
* @param {Object} object the object to mutate
|
203
202
|
* @param {string} key the object's key
|
204
203
|
* @param {*} value the value to add
|
@@ -214,7 +213,6 @@ module.exports = {
|
|
214
213
|
|
215
214
|
/**
|
216
215
|
* Retrieves an array containing all strings (" or ') in the source code.
|
217
|
-
*
|
218
216
|
* @returns {ASTNode[]} An array of string nodes.
|
219
217
|
*/
|
220
218
|
function getAllStrings() {
|
@@ -224,7 +222,6 @@ module.exports = {
|
|
224
222
|
|
225
223
|
/**
|
226
224
|
* Retrieves an array containing all template literals in the source code.
|
227
|
-
*
|
228
225
|
* @returns {ASTNode[]} An array of template literal nodes.
|
229
226
|
*/
|
230
227
|
function getAllTemplateLiterals() {
|
@@ -234,7 +231,6 @@ module.exports = {
|
|
234
231
|
|
235
232
|
/**
|
236
233
|
* Retrieves an array containing all RegExp literals in the source code.
|
237
|
-
*
|
238
234
|
* @returns {ASTNode[]} An array of RegExp literal nodes.
|
239
235
|
*/
|
240
236
|
function getAllRegExpLiterals() {
|
@@ -244,7 +240,6 @@ module.exports = {
|
|
244
240
|
|
245
241
|
/**
|
246
242
|
* A reducer to group an AST node by line number, both start and end.
|
247
|
-
*
|
248
243
|
* @param {Object} acc the accumulator
|
249
244
|
* @param {ASTNode} node the AST node in question
|
250
245
|
* @returns {Object} the modified accumulator
|
@@ -61,7 +61,6 @@ module.exports = {
|
|
61
61
|
|
62
62
|
/**
|
63
63
|
* Reports with the first extra statement, and clears it.
|
64
|
-
*
|
65
64
|
* @returns {void}
|
66
65
|
*/
|
67
66
|
function reportFirstExtraStatementAndClear() {
|
@@ -81,8 +80,7 @@ module.exports = {
|
|
81
80
|
|
82
81
|
/**
|
83
82
|
* Gets the actual last token of a given node.
|
84
|
-
*
|
85
|
-
* @param {ASTNode} node - A node to get. This is a node except EmptyStatement.
|
83
|
+
* @param {ASTNode} node A node to get. This is a node except EmptyStatement.
|
86
84
|
* @returns {Token} The actual last token.
|
87
85
|
*/
|
88
86
|
function getActualLastToken(node) {
|
@@ -92,8 +90,7 @@ module.exports = {
|
|
92
90
|
/**
|
93
91
|
* Addresses a given node.
|
94
92
|
* It updates the state of this rule, then reports the node if the node violated this rule.
|
95
|
-
*
|
96
|
-
* @param {ASTNode} node - A node to check.
|
93
|
+
* @param {ASTNode} node A node to check.
|
97
94
|
* @returns {void}
|
98
95
|
*/
|
99
96
|
function enterStatement(node) {
|
@@ -127,8 +124,7 @@ module.exports = {
|
|
127
124
|
|
128
125
|
/**
|
129
126
|
* Updates the state of this rule with the end line of leaving node to check with the next statement.
|
130
|
-
*
|
131
|
-
* @param {ASTNode} node - A node to check.
|
127
|
+
* @param {ASTNode} node A node to check.
|
132
128
|
* @returns {void}
|
133
129
|
*/
|
134
130
|
function leaveStatement(node) {
|
@@ -46,9 +46,9 @@ module.exports = {
|
|
46
46
|
|
47
47
|
/**
|
48
48
|
* Tests whether node is preceded by supplied tokens
|
49
|
-
* @param {ASTNode} node
|
50
|
-
* @param {ASTNode} parentNode
|
51
|
-
* @param {boolean} expected
|
49
|
+
* @param {ASTNode} node node to check
|
50
|
+
* @param {ASTNode} parentNode parent of node to report
|
51
|
+
* @param {boolean} expected whether newline was expected or not
|
52
52
|
* @returns {void}
|
53
53
|
* @private
|
54
54
|
*/
|
@@ -72,8 +72,7 @@ module.exports = {
|
|
72
72
|
* var foo = 1
|
73
73
|
*
|
74
74
|
* ;(a || b).doSomething()
|
75
|
-
*
|
76
|
-
* @param {ASTNode} node - The node to get.
|
75
|
+
* @param {ASTNode} node The node to get.
|
77
76
|
* @returns {Token} The token to compare line to the next statement.
|
78
77
|
*/
|
79
78
|
function getLastToken(node) {
|
@@ -93,7 +92,7 @@ module.exports = {
|
|
93
92
|
/**
|
94
93
|
* Determine if provided keyword is a variable declaration
|
95
94
|
* @private
|
96
|
-
* @param {string} keyword
|
95
|
+
* @param {string} keyword keyword to test
|
97
96
|
* @returns {boolean} True if `keyword` is a type of var
|
98
97
|
*/
|
99
98
|
function isVar(keyword) {
|
@@ -103,7 +102,7 @@ module.exports = {
|
|
103
102
|
/**
|
104
103
|
* Determine if provided keyword is a variant of for specifiers
|
105
104
|
* @private
|
106
|
-
* @param {string} keyword
|
105
|
+
* @param {string} keyword keyword to test
|
107
106
|
* @returns {boolean} True if `keyword` is a variant of for specifier
|
108
107
|
*/
|
109
108
|
function isForTypeSpecifier(keyword) {
|
@@ -113,7 +112,7 @@ module.exports = {
|
|
113
112
|
/**
|
114
113
|
* Determine if provided keyword is an export specifiers
|
115
114
|
* @private
|
116
|
-
* @param {string} nodeType
|
115
|
+
* @param {string} nodeType nodeType to test
|
117
116
|
* @returns {boolean} True if `nodeType` is an export specifier
|
118
117
|
*/
|
119
118
|
function isExportSpecifier(nodeType) {
|
@@ -124,7 +123,7 @@ module.exports = {
|
|
124
123
|
/**
|
125
124
|
* Determine if provided node is the last of their parent block.
|
126
125
|
* @private
|
127
|
-
* @param {ASTNode} node
|
126
|
+
* @param {ASTNode} node node to test
|
128
127
|
* @returns {boolean} True if `node` is last of their parent block.
|
129
128
|
*/
|
130
129
|
function isLastNode(node) {
|
@@ -159,7 +158,7 @@ module.exports = {
|
|
159
158
|
* set to "always", or checks that there is no blank line when mode is set
|
160
159
|
* to "never"
|
161
160
|
* @private
|
162
|
-
* @param {ASTNode} node
|
161
|
+
* @param {ASTNode} node `VariableDeclaration` node to test
|
163
162
|
* @returns {void}
|
164
163
|
*/
|
165
164
|
function checkForBlankLine(node) {
|
@@ -39,8 +39,8 @@ module.exports = {
|
|
39
39
|
|
40
40
|
/**
|
41
41
|
* Tests whether node is preceded by supplied tokens
|
42
|
-
* @param {ASTNode} node
|
43
|
-
* @param {Array} testTokens
|
42
|
+
* @param {ASTNode} node node to check
|
43
|
+
* @param {Array} testTokens array of tokens to test against
|
44
44
|
* @returns {boolean} Whether or not the node is preceded by one of the supplied tokens
|
45
45
|
* @private
|
46
46
|
*/
|
@@ -52,7 +52,7 @@ module.exports = {
|
|
52
52
|
|
53
53
|
/**
|
54
54
|
* Checks whether node is the first node after statement or in block
|
55
|
-
* @param {ASTNode} node
|
55
|
+
* @param {ASTNode} node node to check
|
56
56
|
* @returns {boolean} Whether or not the node is the first node after statement or in block
|
57
57
|
* @private
|
58
58
|
*/
|
@@ -80,8 +80,8 @@ module.exports = {
|
|
80
80
|
|
81
81
|
/**
|
82
82
|
* Returns the number of lines of comments that precede the node
|
83
|
-
* @param {ASTNode} node
|
84
|
-
* @param {number} lineNumTokenBefore
|
83
|
+
* @param {ASTNode} node node to check for overlapping comments
|
84
|
+
* @param {number} lineNumTokenBefore line number of previous token, to check for overlapping comments
|
85
85
|
* @returns {number} Number of lines of comments that precede the node
|
86
86
|
* @private
|
87
87
|
*/
|
@@ -115,7 +115,7 @@ module.exports = {
|
|
115
115
|
|
116
116
|
/**
|
117
117
|
* Returns the line number of the token before the node that is passed in as an argument
|
118
|
-
* @param {ASTNode} node
|
118
|
+
* @param {ASTNode} node The node to use as the start of the calculation
|
119
119
|
* @returns {number} Line number of the token before `node`
|
120
120
|
* @private
|
121
121
|
*/
|
@@ -142,7 +142,7 @@ module.exports = {
|
|
142
142
|
|
143
143
|
/**
|
144
144
|
* Checks whether node is preceded by a newline
|
145
|
-
* @param {ASTNode} node
|
145
|
+
* @param {ASTNode} node node to check
|
146
146
|
* @returns {boolean} Whether or not the node is preceded by a newline
|
147
147
|
* @private
|
148
148
|
*/
|
@@ -160,8 +160,7 @@ module.exports = {
|
|
160
160
|
* The fix is not considered safe if the given return statement has leading comments,
|
161
161
|
* as we cannot safely determine if the newline should be added before or after the comments.
|
162
162
|
* For more information, see: https://github.com/eslint/eslint/issues/5958#issuecomment-222767211
|
163
|
-
*
|
164
|
-
* @param {ASTNode} node - The return statement node to check.
|
163
|
+
* @param {ASTNode} node The return statement node to check.
|
165
164
|
* @returns {boolean} `true` if it can fix the node.
|
166
165
|
* @private
|
167
166
|
*/
|
@@ -53,8 +53,7 @@ module.exports = {
|
|
53
53
|
* Get the prefix of a given MemberExpression node.
|
54
54
|
* If the MemberExpression node is a computed value it returns a
|
55
55
|
* left bracket. If not it returns a period.
|
56
|
-
*
|
57
|
-
* @param {ASTNode} node - A MemberExpression node to get
|
56
|
+
* @param {ASTNode} node A MemberExpression node to get
|
58
57
|
* @returns {string} The prefix of the node.
|
59
58
|
*/
|
60
59
|
function getPrefix(node) {
|
@@ -64,8 +63,7 @@ module.exports = {
|
|
64
63
|
/**
|
65
64
|
* Gets the property text of a given MemberExpression node.
|
66
65
|
* If the text is multiline, this returns only the first line.
|
67
|
-
*
|
68
|
-
* @param {ASTNode} node - A MemberExpression node to get.
|
66
|
+
* @param {ASTNode} node A MemberExpression node to get.
|
69
67
|
* @returns {string} The property text of the node.
|
70
68
|
*/
|
71
69
|
function getPropertyText(node) {
|
@@ -33,7 +33,7 @@ module.exports = {
|
|
33
33
|
|
34
34
|
/**
|
35
35
|
* Finds and reports references that are non initializer and writable.
|
36
|
-
* @param {Variable} variable
|
36
|
+
* @param {Variable} variable A variable to check.
|
37
37
|
* @returns {void}
|
38
38
|
*/
|
39
39
|
function checkVariable(variable) {
|
@@ -45,7 +45,7 @@ module.exports = {
|
|
45
45
|
|
46
46
|
/**
|
47
47
|
* Finds and reports references that are non initializer and writable.
|
48
|
-
* @param {ASTNode} node
|
48
|
+
* @param {ASTNode} node A ClassDeclaration/ClassExpression node to check.
|
49
49
|
* @returns {void}
|
50
50
|
*/
|
51
51
|
function checkForClass(node) {
|