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.
Files changed (174) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +4 -3
  3. package/lib/cli-engine/cascading-config-array-factory.js +2 -1
  4. package/lib/cli-engine/cli-engine.js +9 -7
  5. package/lib/cli-engine/config-array/config-array.js +0 -4
  6. package/lib/cli-engine/config-array/config-dependency.js +2 -0
  7. package/lib/cli-engine/config-array/override-tester.js +2 -0
  8. package/lib/cli-engine/config-array-factory.js +7 -1
  9. package/lib/cli-engine/file-enumerator.js +5 -3
  10. package/lib/cli-engine/formatters/html.js +1 -0
  11. package/lib/cli-engine/ignored-paths.js +1 -0
  12. package/lib/init/autoconfig.js +1 -11
  13. package/lib/init/config-file.js +0 -1
  14. package/lib/init/config-initializer.js +0 -1
  15. package/lib/init/config-rule.js +1 -5
  16. package/lib/init/npm-utils.js +0 -5
  17. package/lib/linter/code-path-analysis/code-path-analyzer.js +24 -38
  18. package/lib/linter/code-path-analysis/code-path-segment.js +17 -25
  19. package/lib/linter/code-path-analysis/code-path-state.js +40 -81
  20. package/lib/linter/code-path-analysis/code-path.js +10 -11
  21. package/lib/linter/code-path-analysis/debug-helpers.js +8 -12
  22. package/lib/linter/code-path-analysis/fork-context.js +23 -34
  23. package/lib/linter/code-path-analysis/id-generator.js +2 -2
  24. package/lib/linter/linter.js +121 -95
  25. package/lib/linter/node-event-generator.js +3 -2
  26. package/lib/rule-tester/rule-tester.js +6 -8
  27. package/lib/rules/accessor-pairs.js +8 -8
  28. package/lib/rules/array-bracket-newline.js +12 -15
  29. package/lib/rules/array-bracket-spacing.js +12 -12
  30. package/lib/rules/array-callback-return.js +6 -11
  31. package/lib/rules/array-element-newline.js +5 -8
  32. package/lib/rules/arrow-parens.js +0 -1
  33. package/lib/rules/block-scoped-var.js +3 -3
  34. package/lib/rules/block-spacing.js +4 -4
  35. package/lib/rules/capitalized-comments.js +0 -7
  36. package/lib/rules/class-methods-use-this.js +3 -3
  37. package/lib/rules/comma-dangle.js +15 -23
  38. package/lib/rules/comma-spacing.js +1 -1
  39. package/lib/rules/computed-property-spacing.js +10 -10
  40. package/lib/rules/consistent-return.js +4 -5
  41. package/lib/rules/consistent-this.js +5 -5
  42. package/lib/rules/constructor-super.js +14 -16
  43. package/lib/rules/curly.js +3 -5
  44. package/lib/rules/default-param-last.js +1 -0
  45. package/lib/rules/dot-location.js +11 -12
  46. package/lib/rules/func-names.js +6 -6
  47. package/lib/rules/function-call-argument-newline.js +5 -5
  48. package/lib/rules/generator-star-spacing.js +4 -9
  49. package/lib/rules/getter-return.js +4 -7
  50. package/lib/rules/indent.js +2 -2
  51. package/lib/rules/init-declarations.js +2 -2
  52. package/lib/rules/jsx-quotes.js +1 -1
  53. package/lib/rules/keyword-spacing.js +32 -56
  54. package/lib/rules/lines-around-directive.js +1 -1
  55. package/lib/rules/max-len.js +0 -5
  56. package/lib/rules/max-statements-per-line.js +3 -7
  57. package/lib/rules/multiline-ternary.js +3 -3
  58. package/lib/rules/newline-after-var.js +6 -7
  59. package/lib/rules/newline-before-return.js +8 -9
  60. package/lib/rules/newline-per-chained-call.js +2 -4
  61. package/lib/rules/no-class-assign.js +2 -2
  62. package/lib/rules/no-compare-neg-zero.js +1 -2
  63. package/lib/rules/no-confusing-arrow.js +2 -2
  64. package/lib/rules/no-console.js +4 -8
  65. package/lib/rules/no-const-assign.js +1 -1
  66. package/lib/rules/no-dupe-args.js +1 -1
  67. package/lib/rules/no-dupe-class-members.js +3 -4
  68. package/lib/rules/no-dupe-keys.js +6 -5
  69. package/lib/rules/no-duplicate-imports.js +14 -18
  70. package/lib/rules/no-else-return.js +0 -8
  71. package/lib/rules/no-empty-function.js +2 -4
  72. package/lib/rules/no-eval.js +10 -18
  73. package/lib/rules/no-ex-assign.js +1 -1
  74. package/lib/rules/no-extra-bind.js +5 -12
  75. package/lib/rules/no-extra-boolean-cast.js +0 -2
  76. package/lib/rules/no-extra-label.js +4 -9
  77. package/lib/rules/no-extra-parens.js +17 -15
  78. package/lib/rules/no-extra-semi.js +5 -6
  79. package/lib/rules/no-fallthrough.js +6 -6
  80. package/lib/rules/no-func-assign.js +3 -3
  81. package/lib/rules/no-global-assign.js +4 -4
  82. package/lib/rules/no-implicit-coercion.js +10 -10
  83. package/lib/rules/no-implied-eval.js +0 -1
  84. package/lib/rules/no-invalid-this.js +1 -3
  85. package/lib/rules/no-labels.js +3 -6
  86. package/lib/rules/no-lone-blocks.js +1 -1
  87. package/lib/rules/no-loop-func.js +6 -11
  88. package/lib/rules/no-magic-numbers.js +6 -6
  89. package/lib/rules/no-misleading-character-class.js +14 -7
  90. package/lib/rules/no-mixed-operators.js +13 -22
  91. package/lib/rules/no-mixed-requires.js +0 -1
  92. package/lib/rules/no-multi-spaces.js +1 -1
  93. package/lib/rules/no-native-reassign.js +4 -4
  94. package/lib/rules/no-param-reassign.js +28 -7
  95. package/lib/rules/no-redeclare.js +1 -1
  96. package/lib/rules/no-regex-spaces.js +0 -1
  97. package/lib/rules/no-restricted-imports.js +11 -11
  98. package/lib/rules/no-self-assign.js +12 -13
  99. package/lib/rules/no-sequences.js +3 -3
  100. package/lib/rules/no-shadow.js +1 -4
  101. package/lib/rules/no-tabs.js +8 -2
  102. package/lib/rules/no-this-before-super.js +12 -13
  103. package/lib/rules/no-trailing-spaces.js +19 -7
  104. package/lib/rules/no-unmodified-loop-condition.js +16 -29
  105. package/lib/rules/no-unneeded-ternary.js +3 -3
  106. package/lib/rules/no-unreachable.js +7 -7
  107. package/lib/rules/no-unsafe-finally.js +4 -7
  108. package/lib/rules/no-unsafe-negation.js +32 -9
  109. package/lib/rules/no-unused-expressions.js +11 -7
  110. package/lib/rules/no-unused-labels.js +3 -6
  111. package/lib/rules/no-unused-vars.js +22 -29
  112. package/lib/rules/no-use-before-define.js +10 -15
  113. package/lib/rules/no-useless-call.js +4 -4
  114. package/lib/rules/no-useless-concat.js +4 -4
  115. package/lib/rules/no-useless-constructor.js +14 -22
  116. package/lib/rules/no-useless-escape.js +3 -5
  117. package/lib/rules/no-useless-rename.js +7 -7
  118. package/lib/rules/no-useless-return.js +8 -15
  119. package/lib/rules/no-var.js +12 -25
  120. package/lib/rules/no-warning-comments.js +0 -1
  121. package/lib/rules/no-whitespace-before-property.js +3 -3
  122. package/lib/rules/object-curly-newline.js +7 -10
  123. package/lib/rules/object-curly-spacing.js +13 -14
  124. package/lib/rules/object-shorthand.js +1 -1
  125. package/lib/rules/one-var-declaration-per-line.js +2 -2
  126. package/lib/rules/operator-assignment.js +22 -1
  127. package/lib/rules/padded-blocks.js +1 -1
  128. package/lib/rules/padding-line-between-statements.js +0 -16
  129. package/lib/rules/prefer-arrow-callback.js +6 -6
  130. package/lib/rules/prefer-const.js +13 -21
  131. package/lib/rules/prefer-destructuring.js +1 -7
  132. package/lib/rules/prefer-named-capture-group.js +0 -1
  133. package/lib/rules/prefer-numeric-literals.js +32 -4
  134. package/lib/rules/prefer-object-spread.js +7 -7
  135. package/lib/rules/prefer-rest-params.js +3 -6
  136. package/lib/rules/prefer-spread.js +4 -4
  137. package/lib/rules/prefer-template.js +5 -6
  138. package/lib/rules/quote-props.js +1 -1
  139. package/lib/rules/quotes.js +5 -6
  140. package/lib/rules/radix.js +5 -10
  141. package/lib/rules/require-await.js +2 -5
  142. package/lib/rules/require-yield.js +2 -2
  143. package/lib/rules/rest-spread-spacing.js +1 -1
  144. package/lib/rules/sort-imports.js +3 -4
  145. package/lib/rules/sort-keys.js +1 -3
  146. package/lib/rules/space-before-blocks.js +1 -2
  147. package/lib/rules/space-in-parens.js +4 -4
  148. package/lib/rules/space-infix-ops.js +5 -5
  149. package/lib/rules/spaced-comment.js +15 -18
  150. package/lib/rules/strict.js +2 -4
  151. package/lib/rules/symbol-description.js +1 -2
  152. package/lib/rules/template-curly-spacing.js +2 -2
  153. package/lib/rules/use-isnan.js +40 -3
  154. package/lib/rules/utils/ast-utils.js +53 -81
  155. package/lib/rules/utils/fix-tracker.js +0 -6
  156. package/lib/rules/utils/lazy-loading-rule-map.js +0 -1
  157. package/lib/rules/vars-on-top.js +11 -11
  158. package/lib/shared/config-ops.js +2 -2
  159. package/lib/shared/runtime-info.js +8 -8
  160. package/lib/shared/traverser.js +2 -0
  161. package/lib/source-code/source-code.js +8 -8
  162. package/lib/source-code/token-store/backward-token-comment-cursor.js +5 -5
  163. package/lib/source-code/token-store/backward-token-cursor.js +5 -5
  164. package/lib/source-code/token-store/cursors.js +17 -19
  165. package/lib/source-code/token-store/decorative-cursor.js +1 -1
  166. package/lib/source-code/token-store/filter-cursor.js +2 -2
  167. package/lib/source-code/token-store/forward-token-comment-cursor.js +5 -5
  168. package/lib/source-code/token-store/forward-token-cursor.js +5 -5
  169. package/lib/source-code/token-store/index.js +86 -92
  170. package/lib/source-code/token-store/limit-cursor.js +2 -2
  171. package/lib/source-code/token-store/padded-token-cursor.js +7 -7
  172. package/lib/source-code/token-store/skip-cursor.js +2 -2
  173. package/lib/source-code/token-store/utils.js +9 -13
  174. package/package.json +6 -5
@@ -16,7 +16,6 @@ const astUtils = require("./utils/ast-utils");
16
16
 
17
17
  /**
18
18
  * Get location should be reported by AST node.
19
- *
20
19
  * @param {ASTNode} node AST Node.
21
20
  * @returns {Location} Location information.
22
21
  */
@@ -31,7 +31,7 @@ module.exports = {
31
31
 
32
32
  /**
33
33
  * Makes a block scope.
34
- * @param {ASTNode} node - A node of a scope.
34
+ * @param {ASTNode} node A node of a scope.
35
35
  * @returns {void}
36
36
  */
37
37
  function enterScope(node) {
@@ -48,7 +48,7 @@ module.exports = {
48
48
 
49
49
  /**
50
50
  * Reports a given reference.
51
- * @param {eslint-scope.Reference} reference - A reference to report.
51
+ * @param {eslint-scope.Reference} reference A reference to report.
52
52
  * @returns {void}
53
53
  */
54
54
  function report(reference) {
@@ -59,7 +59,7 @@ module.exports = {
59
59
 
60
60
  /**
61
61
  * Finds and reports references which are outside of valid scopes.
62
- * @param {ASTNode} node - A node to get variables.
62
+ * @param {ASTNode} node A node to get variables.
63
63
  * @returns {void}
64
64
  */
65
65
  function checkForVariables(node) {
@@ -41,7 +41,7 @@ module.exports = {
41
41
 
42
42
  /**
43
43
  * Gets the open brace token from a given node.
44
- * @param {ASTNode} node - A BlockStatement/SwitchStatement node to get.
44
+ * @param {ASTNode} node A BlockStatement/SwitchStatement node to get.
45
45
  * @returns {Token} The token of the open brace.
46
46
  */
47
47
  function getOpenBrace(node) {
@@ -58,8 +58,8 @@ module.exports = {
58
58
  * Checks whether or not:
59
59
  * - given tokens are on same line.
60
60
  * - there is/isn't a space between given tokens.
61
- * @param {Token} left - A token to check.
62
- * @param {Token} right - The token which is next to `left`.
61
+ * @param {Token} left A token to check.
62
+ * @param {Token} right The token which is next to `left`.
63
63
  * @returns {boolean}
64
64
  * When the option is `"always"`, `true` if there are one or more spaces between given tokens.
65
65
  * When the option is `"never"`, `true` if there are not any spaces between given tokens.
@@ -74,7 +74,7 @@ module.exports = {
74
74
 
75
75
  /**
76
76
  * Reports invalid spacing style inside braces.
77
- * @param {ASTNode} node - A BlockStatement/SwitchStatement node to get.
77
+ * @param {ASTNode} node A BlockStatement/SwitchStatement node to get.
78
78
  * @returns {void}
79
79
  */
80
80
  function checkSpacingInsideBraces(node) {
@@ -54,7 +54,6 @@ const DEFAULTS = {
54
54
  * set is returned. Options specified in overrides will take priority
55
55
  * over options specified in the main options object, which will in
56
56
  * turn take priority over the rule's defaults.
57
- *
58
57
  * @param {Object|string} rawOptions The user-provided options.
59
58
  * @param {string} which Either "line" or "block".
60
59
  * @returns {Object} The normalized options.
@@ -65,7 +64,6 @@ function getNormalizedOptions(rawOptions, which) {
65
64
 
66
65
  /**
67
66
  * Get normalized options for block and line comments.
68
- *
69
67
  * @param {Object|string} rawOptions The user-provided options.
70
68
  * @returns {Object} An object with "Line" and "Block" keys and corresponding
71
69
  * normalized options objects.
@@ -82,7 +80,6 @@ function getAllNormalizedOptions(rawOptions = {}) {
82
80
  * options.
83
81
  *
84
82
  * This is done in order to avoid invoking the RegExp constructor repeatedly.
85
- *
86
83
  * @param {Object} normalizedOptions The normalized rule options.
87
84
  * @returns {void}
88
85
  */
@@ -162,7 +159,6 @@ module.exports = {
162
159
  * Also, it follows from this definition that only block comments can
163
160
  * be considered as possibly inline. This is because line comments
164
161
  * would consume any following tokens on the same line as the comment.
165
- *
166
162
  * @param {ASTNode} comment The comment node to check.
167
163
  * @returns {boolean} True if the comment is an inline comment, false
168
164
  * otherwise.
@@ -181,7 +177,6 @@ module.exports = {
181
177
 
182
178
  /**
183
179
  * Determine if a comment follows another comment.
184
- *
185
180
  * @param {ASTNode} comment The comment to check.
186
181
  * @returns {boolean} True if the comment follows a valid comment.
187
182
  */
@@ -196,7 +191,6 @@ module.exports = {
196
191
 
197
192
  /**
198
193
  * Check a comment to determine if it is valid for this rule.
199
- *
200
194
  * @param {ASTNode} comment The comment node to process.
201
195
  * @param {Object} options The options for checking this comment.
202
196
  * @returns {boolean} True if the comment is valid, false otherwise.
@@ -261,7 +255,6 @@ module.exports = {
261
255
 
262
256
  /**
263
257
  * Process a comment to determine if it needs to be reported.
264
- *
265
258
  * @param {ASTNode} comment The comment node to process.
266
259
  * @returns {void}
267
260
  */
@@ -61,7 +61,7 @@ module.exports = {
61
61
 
62
62
  /**
63
63
  * Check if the node is an instance method
64
- * @param {ASTNode} node - node to check
64
+ * @param {ASTNode} node node to check
65
65
  * @returns {boolean} True if its an instance method
66
66
  * @private
67
67
  */
@@ -71,7 +71,7 @@ module.exports = {
71
71
 
72
72
  /**
73
73
  * Check if the node is an instance method not excluded by config
74
- * @param {ASTNode} node - node to check
74
+ * @param {ASTNode} node node to check
75
75
  * @returns {boolean} True if it is an instance method, and not excluded by config
76
76
  * @private
77
77
  */
@@ -84,7 +84,7 @@ module.exports = {
84
84
  * Checks if we are leaving a function that is a method, and reports if 'this' has not been used.
85
85
  * Static methods and the constructor are exempt.
86
86
  * Then pops the context off the stack.
87
- * @param {ASTNode} node - A function node that was entered.
87
+ * @param {ASTNode} node A function node that was entered.
88
88
  * @returns {void}
89
89
  * @private
90
90
  */
@@ -27,8 +27,7 @@ const DEFAULT_OPTIONS = Object.freeze({
27
27
  /**
28
28
  * Checks whether or not a trailing comma is allowed in a given node.
29
29
  * If the `lastItem` is `RestElement` or `RestProperty`, it disallows trailing commas.
30
- *
31
- * @param {ASTNode} lastItem - The node of the last element in the given node.
30
+ * @param {ASTNode} lastItem The node of the last element in the given node.
32
31
  * @returns {boolean} `true` if a trailing comma is allowed.
33
32
  */
34
33
  function isTrailingCommaAllowed(lastItem) {
@@ -41,20 +40,18 @@ function isTrailingCommaAllowed(lastItem) {
41
40
 
42
41
  /**
43
42
  * Normalize option value.
44
- *
45
- * @param {string|Object|undefined} optionValue - The 1st option value to normalize.
43
+ * @param {string|Object|undefined} optionValue The 1st option value to normalize.
44
+ * @param {number} ecmaVersion The normalized ECMAScript version.
46
45
  * @returns {Object} The normalized option value.
47
46
  */
48
- function normalizeOptions(optionValue) {
47
+ function normalizeOptions(optionValue, ecmaVersion) {
49
48
  if (typeof optionValue === "string") {
50
49
  return {
51
50
  arrays: optionValue,
52
51
  objects: optionValue,
53
52
  imports: optionValue,
54
53
  exports: optionValue,
55
-
56
- // For backward compatibility, always ignore functions.
57
- functions: "ignore"
54
+ functions: (!ecmaVersion || ecmaVersion < 8) ? "ignore" : optionValue
58
55
  };
59
56
  }
60
57
  if (typeof optionValue === "object" && optionValue !== null) {
@@ -137,12 +134,13 @@ module.exports = {
137
134
  },
138
135
 
139
136
  create(context) {
140
- const options = normalizeOptions(context.options[0]);
137
+ const options = normalizeOptions(context.options[0], context.parserOptions.ecmaVersion);
138
+
141
139
  const sourceCode = context.getSourceCode();
142
140
 
143
141
  /**
144
142
  * Gets the last item of the given node.
145
- * @param {ASTNode} node - The node to get.
143
+ * @param {ASTNode} node The node to get.
146
144
  * @returns {ASTNode|null} The last node or null.
147
145
  */
148
146
  function getLastItem(node) {
@@ -172,9 +170,8 @@ module.exports = {
172
170
  * Gets the trailing comma token of the given node.
173
171
  * If the trailing comma does not exist, this returns the token which is
174
172
  * the insertion point of the trailing comma token.
175
- *
176
- * @param {ASTNode} node - The node to get.
177
- * @param {ASTNode} lastItem - The last item of the node.
173
+ * @param {ASTNode} node The node to get.
174
+ * @param {ASTNode} lastItem The last item of the node.
178
175
  * @returns {Token} The trailing comma token or the insertion point.
179
176
  */
180
177
  function getTrailingToken(node, lastItem) {
@@ -199,8 +196,7 @@ module.exports = {
199
196
  * Checks whether or not a given node is multiline.
200
197
  * This rule handles a given node as multiline when the closing parenthesis
201
198
  * and the last element are not on the same line.
202
- *
203
- * @param {ASTNode} node - A node to check.
199
+ * @param {ASTNode} node A node to check.
204
200
  * @returns {boolean} `true` if the node is multiline.
205
201
  */
206
202
  function isMultiline(node) {
@@ -218,8 +214,7 @@ module.exports = {
218
214
 
219
215
  /**
220
216
  * Reports a trailing comma if it exists.
221
- *
222
- * @param {ASTNode} node - A node to check. Its type is one of
217
+ * @param {ASTNode} node A node to check. Its type is one of
223
218
  * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
224
219
  * ImportDeclaration, and ExportNamedDeclaration.
225
220
  * @returns {void}
@@ -251,8 +246,7 @@ module.exports = {
251
246
  *
252
247
  * If a given node is `ArrayPattern` which has `RestElement`, the trailing
253
248
  * comma is disallowed, so report if it exists.
254
- *
255
- * @param {ASTNode} node - A node to check. Its type is one of
249
+ * @param {ASTNode} node A node to check. Its type is one of
256
250
  * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
257
251
  * ImportDeclaration, and ExportNamedDeclaration.
258
252
  * @returns {void}
@@ -286,8 +280,7 @@ module.exports = {
286
280
  * If a given node is multiline, reports the last element of a given node
287
281
  * when it does not have a trailing comma.
288
282
  * Otherwise, reports a trailing comma if it exists.
289
- *
290
- * @param {ASTNode} node - A node to check. Its type is one of
283
+ * @param {ASTNode} node A node to check. Its type is one of
291
284
  * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
292
285
  * ImportDeclaration, and ExportNamedDeclaration.
293
286
  * @returns {void}
@@ -304,8 +297,7 @@ module.exports = {
304
297
  * Only if a given node is not multiline, reports the last element of a given node
305
298
  * when it does not have a trailing comma.
306
299
  * Otherwise, reports a trailing comma if it exists.
307
- *
308
- * @param {ASTNode} node - A node to check. Its type is one of
300
+ * @param {ASTNode} node A node to check. Its type is one of
309
301
  * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
310
302
  * ImportDeclaration, and ExportNamedDeclaration.
311
303
  * @returns {void}
@@ -105,7 +105,7 @@ module.exports = {
105
105
 
106
106
  /**
107
107
  * Validates the spacing around a comma token.
108
- * @param {Object} tokens - The tokens to be validated.
108
+ * @param {Object} tokens The tokens to be validated.
109
109
  * @param {Token} tokens.comma The token representing the comma.
110
110
  * @param {Token} [tokens.left] The last token before the comma.
111
111
  * @param {Token} [tokens.right] The first token after the comma.
@@ -59,9 +59,9 @@ module.exports = {
59
59
 
60
60
  /**
61
61
  * Reports that there shouldn't be a space after the first token
62
- * @param {ASTNode} node - The node to report in the event of an error.
63
- * @param {Token} token - The token to use for the report.
64
- * @param {Token} tokenAfter - The token after `token`.
62
+ * @param {ASTNode} node The node to report in the event of an error.
63
+ * @param {Token} token The token to use for the report.
64
+ * @param {Token} tokenAfter The token after `token`.
65
65
  * @returns {void}
66
66
  */
67
67
  function reportNoBeginningSpace(node, token, tokenAfter) {
@@ -80,9 +80,9 @@ module.exports = {
80
80
 
81
81
  /**
82
82
  * Reports that there shouldn't be a space before the last token
83
- * @param {ASTNode} node - The node to report in the event of an error.
84
- * @param {Token} token - The token to use for the report.
85
- * @param {Token} tokenBefore - The token before `token`.
83
+ * @param {ASTNode} node The node to report in the event of an error.
84
+ * @param {Token} token The token to use for the report.
85
+ * @param {Token} tokenBefore The token before `token`.
86
86
  * @returns {void}
87
87
  */
88
88
  function reportNoEndingSpace(node, token, tokenBefore) {
@@ -101,8 +101,8 @@ module.exports = {
101
101
 
102
102
  /**
103
103
  * Reports that there should be a space after the first token
104
- * @param {ASTNode} node - The node to report in the event of an error.
105
- * @param {Token} token - The token to use for the report.
104
+ * @param {ASTNode} node The node to report in the event of an error.
105
+ * @param {Token} token The token to use for the report.
106
106
  * @returns {void}
107
107
  */
108
108
  function reportRequiredBeginningSpace(node, token) {
@@ -121,8 +121,8 @@ module.exports = {
121
121
 
122
122
  /**
123
123
  * Reports that there should be a space before the last token
124
- * @param {ASTNode} node - The node to report in the event of an error.
125
- * @param {Token} token - The token to use for the report.
124
+ * @param {ASTNode} node The node to report in the event of an error.
125
+ * @param {Token} token The token to use for the report.
126
126
  * @returns {void}
127
127
  */
128
128
  function reportRequiredEndingSpace(node, token) {
@@ -18,8 +18,8 @@ const astUtils = require("./utils/ast-utils");
18
18
 
19
19
  /**
20
20
  * Checks whether or not a given node is an `Identifier` node which was named a given name.
21
- * @param {ASTNode} node - A node to check.
22
- * @param {string} name - An expected name of the node.
21
+ * @param {ASTNode} node A node to check.
22
+ * @param {string} name An expected name of the node.
23
23
  * @returns {boolean} `true` if the node is an `Identifier` node which was named as expected.
24
24
  */
25
25
  function isIdentifier(node, name) {
@@ -28,7 +28,7 @@ function isIdentifier(node, name) {
28
28
 
29
29
  /**
30
30
  * Checks whether or not a given code path segment is unreachable.
31
- * @param {CodePathSegment} segment - A CodePathSegment to check.
31
+ * @param {CodePathSegment} segment A CodePathSegment to check.
32
32
  * @returns {boolean} `true` if the segment is unreachable.
33
33
  */
34
34
  function isUnreachable(segment) {
@@ -88,8 +88,7 @@ module.exports = {
88
88
  /**
89
89
  * Checks whether of not the implicit returning is consistent if the last
90
90
  * code path segment is reachable.
91
- *
92
- * @param {ASTNode} node - A program/function node to check.
91
+ * @param {ASTNode} node A program/function node to check.
93
92
  * @returns {void}
94
93
  */
95
94
  function checkLastSegment(node) {
@@ -46,8 +46,8 @@ module.exports = {
46
46
  /**
47
47
  * Reports that a variable declarator or assignment expression is assigning
48
48
  * a non-'this' value to the specified alias.
49
- * @param {ASTNode} node - The assigning node.
50
- * @param {string} name - the name of the alias that was incorrectly used.
49
+ * @param {ASTNode} node The assigning node.
50
+ * @param {string} name the name of the alias that was incorrectly used.
51
51
  * @returns {void}
52
52
  */
53
53
  function reportBadAssignment(node, name) {
@@ -57,9 +57,9 @@ module.exports = {
57
57
  /**
58
58
  * Checks that an assignment to an identifier only assigns 'this' to the
59
59
  * appropriate alias, and the alias is only assigned to 'this'.
60
- * @param {ASTNode} node - The assigning node.
61
- * @param {Identifier} name - The name of the variable assigned to.
62
- * @param {Expression} value - The value of the assignment.
60
+ * @param {ASTNode} node The assigning node.
61
+ * @param {Identifier} name The name of the variable assigned to.
62
+ * @param {Expression} value The value of the assignment.
63
63
  * @returns {void}
64
64
  */
65
65
  function checkAssignment(node, name, value) {
@@ -11,8 +11,7 @@
11
11
 
12
12
  /**
13
13
  * Checks whether a given code path segment is reachable or not.
14
- *
15
- * @param {CodePathSegment} segment - A code path segment to check.
14
+ * @param {CodePathSegment} segment A code path segment to check.
16
15
  * @returns {boolean} `true` if the segment is reachable.
17
16
  */
18
17
  function isReachable(segment) {
@@ -21,7 +20,7 @@ function isReachable(segment) {
21
20
 
22
21
  /**
23
22
  * Checks whether or not a given node is a constructor.
24
- * @param {ASTNode} node - A node to check. This node type is one of
23
+ * @param {ASTNode} node A node to check. This node type is one of
25
24
  * `Program`, `FunctionDeclaration`, `FunctionExpression`, and
26
25
  * `ArrowFunctionExpression`.
27
26
  * @returns {boolean} `true` if the node is a constructor.
@@ -36,8 +35,7 @@ function isConstructorFunction(node) {
36
35
 
37
36
  /**
38
37
  * Checks whether a given node can be a constructor or not.
39
- *
40
- * @param {ASTNode} node - A node to check.
38
+ * @param {ASTNode} node A node to check.
41
39
  * @returns {boolean} `true` if the node can be a constructor.
42
40
  */
43
41
  function isPossibleConstructor(node) {
@@ -137,7 +135,7 @@ module.exports = {
137
135
 
138
136
  /**
139
137
  * Gets the flag which shows `super()` is called in some paths.
140
- * @param {CodePathSegment} segment - A code path segment to get.
138
+ * @param {CodePathSegment} segment A code path segment to get.
141
139
  * @returns {boolean} The flag which shows `super()` is called in some paths
142
140
  */
143
141
  function isCalledInSomePath(segment) {
@@ -146,7 +144,7 @@ module.exports = {
146
144
 
147
145
  /**
148
146
  * Gets the flag which shows `super()` is called in all paths.
149
- * @param {CodePathSegment} segment - A code path segment to get.
147
+ * @param {CodePathSegment} segment A code path segment to get.
150
148
  * @returns {boolean} The flag which shows `super()` is called in all paths.
151
149
  */
152
150
  function isCalledInEveryPath(segment) {
@@ -168,8 +166,8 @@ module.exports = {
168
166
 
169
167
  /**
170
168
  * Stacks a constructor information.
171
- * @param {CodePath} codePath - A code path which was started.
172
- * @param {ASTNode} node - The current node.
169
+ * @param {CodePath} codePath A code path which was started.
170
+ * @param {ASTNode} node The current node.
173
171
  * @returns {void}
174
172
  */
175
173
  onCodePathStart(codePath, node) {
@@ -200,8 +198,8 @@ module.exports = {
200
198
  /**
201
199
  * Pops a constructor information.
202
200
  * And reports if `super()` lacked.
203
- * @param {CodePath} codePath - A code path which was ended.
204
- * @param {ASTNode} node - The current node.
201
+ * @param {CodePath} codePath A code path which was ended.
202
+ * @param {ASTNode} node The current node.
205
203
  * @returns {void}
206
204
  */
207
205
  onCodePathEnd(codePath, node) {
@@ -231,7 +229,7 @@ module.exports = {
231
229
 
232
230
  /**
233
231
  * Initialize information of a given code path segment.
234
- * @param {CodePathSegment} segment - A code path segment to initialize.
232
+ * @param {CodePathSegment} segment A code path segment to initialize.
235
233
  * @returns {void}
236
234
  */
237
235
  onCodePathSegmentStart(segment) {
@@ -258,9 +256,9 @@ module.exports = {
258
256
  /**
259
257
  * Update information of the code path segment when a code path was
260
258
  * looped.
261
- * @param {CodePathSegment} fromSegment - The code path segment of the
259
+ * @param {CodePathSegment} fromSegment The code path segment of the
262
260
  * end of a loop.
263
- * @param {CodePathSegment} toSegment - A code path segment of the head
261
+ * @param {CodePathSegment} toSegment A code path segment of the head
264
262
  * of a loop.
265
263
  * @returns {void}
266
264
  */
@@ -303,7 +301,7 @@ module.exports = {
303
301
 
304
302
  /**
305
303
  * Checks for a call of `super()`.
306
- * @param {ASTNode} node - A CallExpression node to check.
304
+ * @param {ASTNode} node A CallExpression node to check.
307
305
  * @returns {void}
308
306
  */
309
307
  "CallExpression:exit"(node) {
@@ -358,7 +356,7 @@ module.exports = {
358
356
 
359
357
  /**
360
358
  * Set the mark to the returned path as `super()` was called.
361
- * @param {ASTNode} node - A ReturnStatement node to check.
359
+ * @param {ASTNode} node A ReturnStatement node to check.
362
360
  * @returns {void}
363
361
  */
364
362
  ReturnStatement(node) {
@@ -119,8 +119,7 @@ module.exports = {
119
119
 
120
120
  /**
121
121
  * Checks if the given token is an `else` token or not.
122
- *
123
- * @param {Token} token - The token to check.
122
+ * @param {Token} token The token to check.
124
123
  * @returns {boolean} `true` if the token is an `else` token.
125
124
  */
126
125
  function isElseKeywordToken(token) {
@@ -129,7 +128,7 @@ module.exports = {
129
128
 
130
129
  /**
131
130
  * Gets the `else` keyword token of a given `IfStatement` node.
132
- * @param {ASTNode} node - A `IfStatement` node to get.
131
+ * @param {ASTNode} node A `IfStatement` node to get.
133
132
  * @returns {Token} The `else` keyword token.
134
133
  */
135
134
  function getElseKeyword(node) {
@@ -143,8 +142,7 @@ module.exports = {
143
142
  * 1. The given node has the `alternate` node.
144
143
  * 2. There is a `IfStatement` which doesn't have `alternate` node in the
145
144
  * trailing statement chain of the `consequent` node.
146
- *
147
- * @param {ASTNode} node - A IfStatement node to check.
145
+ * @param {ASTNode} node A IfStatement node to check.
148
146
  * @returns {boolean} `true` if the node requires braces of the consequent chunk.
149
147
  */
150
148
  function requiresBraceOfConsequent(node) {
@@ -25,6 +25,7 @@ module.exports = {
25
25
 
26
26
  create(context) {
27
27
 
28
+ // eslint-disable-next-line jsdoc/require-description
28
29
  /**
29
30
  * @param {ASTNode} node function node
30
31
  * @returns {void}
@@ -47,19 +47,18 @@ module.exports = {
47
47
 
48
48
  /**
49
49
  * Reports if the dot between object and property is on the correct loccation.
50
- * @param {ASTNode} obj The object owning the property.
51
- * @param {ASTNode} prop The property of the object.
52
- * @param {ASTNode} node The corresponding node of the token.
50
+ * @param {ASTNode} node The `MemberExpression` node.
53
51
  * @returns {void}
54
52
  */
55
- function checkDotLocation(obj, prop, node) {
56
- const dot = sourceCode.getTokenBefore(prop);
53
+ function checkDotLocation(node) {
54
+ const property = node.property;
55
+ const dot = sourceCode.getTokenBefore(property);
57
56
 
58
57
  // `obj` expression can be parenthesized, but those paren tokens are not a part of the `obj` node.
59
58
  const tokenBeforeDot = sourceCode.getTokenBefore(dot);
60
59
 
61
60
  const textBeforeDot = sourceCode.getText().slice(tokenBeforeDot.range[1], dot.range[0]);
62
- const textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]);
61
+ const textAfterDot = sourceCode.getText().slice(dot.range[1], property.range[0]);
63
62
 
64
63
  if (onObject) {
65
64
  if (!astUtils.isTokenOnSameLine(tokenBeforeDot, dot)) {
@@ -67,17 +66,17 @@ module.exports = {
67
66
 
68
67
  context.report({
69
68
  node,
70
- loc: dot.loc.start,
69
+ loc: dot.loc,
71
70
  messageId: "expectedDotAfterObject",
72
- fix: fixer => fixer.replaceTextRange([tokenBeforeDot.range[1], prop.range[0]], `${neededTextAfterToken}.${textBeforeDot}${textAfterDot}`)
71
+ fix: fixer => fixer.replaceTextRange([tokenBeforeDot.range[1], property.range[0]], `${neededTextAfterToken}.${textBeforeDot}${textAfterDot}`)
73
72
  });
74
73
  }
75
- } else if (!astUtils.isTokenOnSameLine(dot, prop)) {
74
+ } else if (!astUtils.isTokenOnSameLine(dot, property)) {
76
75
  context.report({
77
76
  node,
78
- loc: dot.loc.start,
77
+ loc: dot.loc,
79
78
  messageId: "expectedDotBeforeProperty",
80
- fix: fixer => fixer.replaceTextRange([tokenBeforeDot.range[1], prop.range[0]], `${textBeforeDot}${textAfterDot}.`)
79
+ fix: fixer => fixer.replaceTextRange([tokenBeforeDot.range[1], property.range[0]], `${textBeforeDot}${textAfterDot}.`)
81
80
  });
82
81
  }
83
82
  }
@@ -89,7 +88,7 @@ module.exports = {
89
88
  */
90
89
  function checkNode(node) {
91
90
  if (!node.computed) {
92
- checkDotLocation(node.object, node.property, node);
91
+ checkDotLocation(node);
93
92
  }
94
93
  }
95
94
 
@@ -13,7 +13,7 @@ const astUtils = require("./utils/ast-utils");
13
13
 
14
14
  /**
15
15
  * Checks whether or not a given variable is a function name.
16
- * @param {eslint-scope.Variable} variable - A variable to check.
16
+ * @param {eslint-scope.Variable} variable A variable to check.
17
17
  * @returns {boolean} `true` if the variable is a function name.
18
18
  */
19
19
  function isFunctionName(variable) {
@@ -73,7 +73,7 @@ module.exports = {
73
73
 
74
74
  /**
75
75
  * Returns the config option for the given node.
76
- * @param {ASTNode} node - A node to get the config for.
76
+ * @param {ASTNode} node A node to get the config for.
77
77
  * @returns {string} The config option.
78
78
  */
79
79
  function getConfigForNode(node) {
@@ -91,7 +91,7 @@ module.exports = {
91
91
  /**
92
92
  * Determines whether the current FunctionExpression node is a get, set, or
93
93
  * shorthand method in an object literal or a class.
94
- * @param {ASTNode} node - A node to check.
94
+ * @param {ASTNode} node A node to check.
95
95
  * @returns {boolean} True if the node is a get, set, or shorthand method.
96
96
  */
97
97
  function isObjectOrClassMethod(node) {
@@ -109,7 +109,7 @@ module.exports = {
109
109
  /**
110
110
  * Determines whether the current FunctionExpression node has a name that would be
111
111
  * inferred from context in a conforming ES6 environment.
112
- * @param {ASTNode} node - A node to check.
112
+ * @param {ASTNode} node A node to check.
113
113
  * @returns {boolean} True if the node would have a name assigned automatically.
114
114
  */
115
115
  function hasInferredName(node) {
@@ -125,7 +125,7 @@ module.exports = {
125
125
 
126
126
  /**
127
127
  * Reports that an unnamed function should be named
128
- * @param {ASTNode} node - The node to report in the event of an error.
128
+ * @param {ASTNode} node The node to report in the event of an error.
129
129
  * @returns {void}
130
130
  */
131
131
  function reportUnexpectedUnnamedFunction(node) {
@@ -139,7 +139,7 @@ module.exports = {
139
139
 
140
140
  /**
141
141
  * Reports that a named function should be unnamed
142
- * @param {ASTNode} node - The node to report in the event of an error.
142
+ * @param {ASTNode} node The node to report in the event of an error.
143
143
  * @returns {void}
144
144
  */
145
145
  function reportUnexpectedNamedFunction(node) {
@@ -40,13 +40,13 @@ module.exports = {
40
40
  const checkers = {
41
41
  unexpected: {
42
42
  messageId: "unexpectedLineBreak",
43
- check: (prevToken, currentToken) => prevToken.loc.start.line !== currentToken.loc.start.line,
43
+ check: (prevToken, currentToken) => prevToken.loc.end.line !== currentToken.loc.start.line,
44
44
  createFix: (token, tokenBefore) => fixer =>
45
45
  fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ")
46
46
  },
47
47
  missing: {
48
48
  messageId: "missingLineBreak",
49
- check: (prevToken, currentToken) => prevToken.loc.start.line === currentToken.loc.start.line,
49
+ check: (prevToken, currentToken) => prevToken.loc.end.line === currentToken.loc.start.line,
50
50
  createFix: (token, tokenBefore) => fixer =>
51
51
  fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n")
52
52
  }
@@ -61,7 +61,7 @@ module.exports = {
61
61
  */
62
62
  function checkArguments(node, checker) {
63
63
  for (let i = 1; i < node.arguments.length; i++) {
64
- const prevArgToken = sourceCode.getFirstToken(node.arguments[i - 1]);
64
+ const prevArgToken = sourceCode.getLastToken(node.arguments[i - 1]);
65
65
  const currentArgToken = sourceCode.getFirstToken(node.arguments[i]);
66
66
 
67
67
  if (checker.check(prevArgToken, currentArgToken)) {
@@ -101,10 +101,10 @@ module.exports = {
101
101
  } else if (option === "always") {
102
102
  checkArguments(node, checkers.missing);
103
103
  } else if (option === "consistent") {
104
- const firstArgToken = sourceCode.getFirstToken(node.arguments[0]);
104
+ const firstArgToken = sourceCode.getLastToken(node.arguments[0]);
105
105
  const secondArgToken = sourceCode.getFirstToken(node.arguments[1]);
106
106
 
107
- if (firstArgToken.loc.start.line === secondArgToken.loc.start.line) {
107
+ if (firstArgToken.loc.end.line === secondArgToken.loc.start.line) {
108
108
  checkArguments(node, checkers.unexpected);
109
109
  } else {
110
110
  checkArguments(node, checkers.missing);