eslint 6.3.0 → 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 (189) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +11 -10
  3. package/bin/eslint.js +38 -12
  4. package/lib/cli-engine/cascading-config-array-factory.js +2 -1
  5. package/lib/cli-engine/cli-engine.js +11 -11
  6. package/lib/cli-engine/config-array/config-array.js +0 -4
  7. package/lib/cli-engine/config-array/config-dependency.js +2 -0
  8. package/lib/cli-engine/config-array/override-tester.js +4 -2
  9. package/lib/cli-engine/config-array-factory.js +7 -1
  10. package/lib/cli-engine/file-enumerator.js +5 -3
  11. package/lib/cli-engine/formatters/html.js +1 -0
  12. package/lib/cli-engine/ignored-paths.js +4 -3
  13. package/lib/cli-engine/lint-result-cache.js +0 -1
  14. package/lib/cli.js +13 -12
  15. package/lib/init/autoconfig.js +1 -11
  16. package/lib/init/config-file.js +0 -1
  17. package/lib/init/config-initializer.js +0 -1
  18. package/lib/init/config-rule.js +3 -7
  19. package/lib/init/npm-utils.js +1 -6
  20. package/lib/linter/code-path-analysis/code-path-analyzer.js +24 -38
  21. package/lib/linter/code-path-analysis/code-path-segment.js +17 -25
  22. package/lib/linter/code-path-analysis/code-path-state.js +40 -81
  23. package/lib/linter/code-path-analysis/code-path.js +10 -11
  24. package/lib/linter/code-path-analysis/debug-helpers.js +9 -13
  25. package/lib/linter/code-path-analysis/fork-context.js +23 -34
  26. package/lib/linter/code-path-analysis/id-generator.js +2 -2
  27. package/lib/linter/linter.js +121 -96
  28. package/lib/linter/node-event-generator.js +3 -2
  29. package/lib/options.js +6 -0
  30. package/lib/rule-tester/rule-tester.js +7 -10
  31. package/lib/rules/accessor-pairs.js +59 -19
  32. package/lib/rules/array-bracket-newline.js +12 -15
  33. package/lib/rules/array-bracket-spacing.js +12 -12
  34. package/lib/rules/array-callback-return.js +6 -11
  35. package/lib/rules/array-element-newline.js +5 -8
  36. package/lib/rules/arrow-parens.js +0 -1
  37. package/lib/rules/block-scoped-var.js +3 -3
  38. package/lib/rules/block-spacing.js +4 -4
  39. package/lib/rules/capitalized-comments.js +2 -9
  40. package/lib/rules/class-methods-use-this.js +3 -3
  41. package/lib/rules/comma-dangle.js +15 -23
  42. package/lib/rules/comma-spacing.js +1 -1
  43. package/lib/rules/computed-property-spacing.js +28 -11
  44. package/lib/rules/consistent-return.js +4 -5
  45. package/lib/rules/consistent-this.js +5 -5
  46. package/lib/rules/constructor-super.js +14 -16
  47. package/lib/rules/curly.js +3 -5
  48. package/lib/rules/default-param-last.js +62 -0
  49. package/lib/rules/dot-location.js +11 -12
  50. package/lib/rules/eqeqeq.js +7 -19
  51. package/lib/rules/func-names.js +6 -6
  52. package/lib/rules/function-call-argument-newline.js +5 -5
  53. package/lib/rules/generator-star-spacing.js +4 -9
  54. package/lib/rules/getter-return.js +4 -7
  55. package/lib/rules/indent-legacy.js +1 -1
  56. package/lib/rules/indent.js +46 -8
  57. package/lib/rules/index.js +3 -0
  58. package/lib/rules/init-declarations.js +2 -2
  59. package/lib/rules/jsx-quotes.js +1 -1
  60. package/lib/rules/keyword-spacing.js +32 -56
  61. package/lib/rules/lines-around-directive.js +1 -1
  62. package/lib/rules/max-len.js +0 -5
  63. package/lib/rules/max-statements-per-line.js +3 -7
  64. package/lib/rules/multiline-ternary.js +3 -3
  65. package/lib/rules/new-parens.js +5 -1
  66. package/lib/rules/newline-after-var.js +6 -7
  67. package/lib/rules/newline-before-return.js +8 -9
  68. package/lib/rules/newline-per-chained-call.js +2 -4
  69. package/lib/rules/no-class-assign.js +2 -2
  70. package/lib/rules/no-compare-neg-zero.js +1 -2
  71. package/lib/rules/no-confusing-arrow.js +2 -2
  72. package/lib/rules/no-console.js +4 -8
  73. package/lib/rules/no-const-assign.js +1 -1
  74. package/lib/rules/no-dupe-args.js +1 -1
  75. package/lib/rules/no-dupe-class-members.js +3 -4
  76. package/lib/rules/no-dupe-keys.js +6 -5
  77. package/lib/rules/no-duplicate-imports.js +14 -18
  78. package/lib/rules/no-else-return.js +0 -8
  79. package/lib/rules/no-empty-function.js +2 -4
  80. package/lib/rules/no-eval.js +10 -18
  81. package/lib/rules/no-ex-assign.js +1 -1
  82. package/lib/rules/no-extra-bind.js +12 -13
  83. package/lib/rules/no-extra-boolean-cast.js +1 -3
  84. package/lib/rules/no-extra-label.js +13 -10
  85. package/lib/rules/no-extra-parens.js +32 -17
  86. package/lib/rules/no-extra-semi.js +5 -6
  87. package/lib/rules/no-fallthrough.js +6 -6
  88. package/lib/rules/no-func-assign.js +3 -3
  89. package/lib/rules/no-global-assign.js +4 -4
  90. package/lib/rules/no-implicit-coercion.js +10 -10
  91. package/lib/rules/no-implied-eval.js +0 -1
  92. package/lib/rules/no-import-assign.js +238 -0
  93. package/lib/rules/no-invalid-this.js +1 -3
  94. package/lib/rules/no-labels.js +3 -6
  95. package/lib/rules/no-lone-blocks.js +7 -2
  96. package/lib/rules/no-loop-func.js +6 -11
  97. package/lib/rules/no-magic-numbers.js +6 -6
  98. package/lib/rules/no-misleading-character-class.js +14 -7
  99. package/lib/rules/no-mixed-operators.js +13 -22
  100. package/lib/rules/no-mixed-requires.js +0 -1
  101. package/lib/rules/no-multi-spaces.js +1 -1
  102. package/lib/rules/no-native-reassign.js +4 -4
  103. package/lib/rules/no-obj-calls.js +29 -9
  104. package/lib/rules/no-octal-escape.js +14 -8
  105. package/lib/rules/no-param-reassign.js +28 -7
  106. package/lib/rules/no-redeclare.js +1 -1
  107. package/lib/rules/no-regex-spaces.js +105 -45
  108. package/lib/rules/no-restricted-imports.js +11 -11
  109. package/lib/rules/no-self-assign.js +18 -18
  110. package/lib/rules/no-sequences.js +5 -5
  111. package/lib/rules/no-shadow.js +1 -4
  112. package/lib/rules/no-tabs.js +8 -2
  113. package/lib/rules/no-this-before-super.js +12 -13
  114. package/lib/rules/no-trailing-spaces.js +19 -7
  115. package/lib/rules/no-undef-init.js +7 -1
  116. package/lib/rules/no-unmodified-loop-condition.js +16 -29
  117. package/lib/rules/no-unneeded-ternary.js +3 -3
  118. package/lib/rules/no-unreachable.js +7 -7
  119. package/lib/rules/no-unsafe-finally.js +4 -7
  120. package/lib/rules/no-unsafe-negation.js +34 -19
  121. package/lib/rules/no-unused-expressions.js +11 -7
  122. package/lib/rules/no-unused-labels.js +3 -6
  123. package/lib/rules/no-unused-vars.js +22 -29
  124. package/lib/rules/no-use-before-define.js +10 -15
  125. package/lib/rules/no-useless-call.js +4 -4
  126. package/lib/rules/no-useless-concat.js +4 -4
  127. package/lib/rules/no-useless-constructor.js +14 -22
  128. package/lib/rules/no-useless-escape.js +3 -5
  129. package/lib/rules/no-useless-rename.js +32 -20
  130. package/lib/rules/no-useless-return.js +11 -17
  131. package/lib/rules/no-var.js +12 -25
  132. package/lib/rules/no-warning-comments.js +0 -1
  133. package/lib/rules/no-whitespace-before-property.js +3 -3
  134. package/lib/rules/object-curly-newline.js +7 -10
  135. package/lib/rules/object-curly-spacing.js +14 -15
  136. package/lib/rules/object-shorthand.js +36 -10
  137. package/lib/rules/one-var-declaration-per-line.js +2 -2
  138. package/lib/rules/operator-assignment.js +22 -1
  139. package/lib/rules/padded-blocks.js +1 -1
  140. package/lib/rules/padding-line-between-statements.js +0 -16
  141. package/lib/rules/prefer-arrow-callback.js +6 -6
  142. package/lib/rules/prefer-const.js +13 -21
  143. package/lib/rules/prefer-destructuring.js +1 -7
  144. package/lib/rules/prefer-named-capture-group.js +3 -16
  145. package/lib/rules/prefer-numeric-literals.js +35 -3
  146. package/lib/rules/prefer-object-spread.js +7 -7
  147. package/lib/rules/prefer-regex-literals.js +125 -0
  148. package/lib/rules/prefer-rest-params.js +3 -6
  149. package/lib/rules/prefer-spread.js +4 -4
  150. package/lib/rules/prefer-template.js +5 -6
  151. package/lib/rules/quote-props.js +1 -1
  152. package/lib/rules/quotes.js +11 -6
  153. package/lib/rules/radix.js +5 -10
  154. package/lib/rules/require-await.js +2 -5
  155. package/lib/rules/require-yield.js +2 -2
  156. package/lib/rules/rest-spread-spacing.js +1 -1
  157. package/lib/rules/sort-imports.js +3 -4
  158. package/lib/rules/sort-keys.js +1 -3
  159. package/lib/rules/space-before-blocks.js +1 -2
  160. package/lib/rules/space-before-function-paren.js +12 -1
  161. package/lib/rules/space-in-parens.js +81 -75
  162. package/lib/rules/space-infix-ops.js +5 -5
  163. package/lib/rules/spaced-comment.js +15 -18
  164. package/lib/rules/strict.js +2 -4
  165. package/lib/rules/symbol-description.js +1 -2
  166. package/lib/rules/template-curly-spacing.js +2 -2
  167. package/lib/rules/use-isnan.js +104 -6
  168. package/lib/rules/utils/ast-utils.js +53 -81
  169. package/lib/rules/utils/fix-tracker.js +0 -6
  170. package/lib/rules/utils/lazy-loading-rule-map.js +0 -1
  171. package/lib/rules/vars-on-top.js +11 -11
  172. package/lib/shared/config-ops.js +2 -2
  173. package/lib/shared/logging.js +2 -0
  174. package/lib/shared/runtime-info.js +163 -0
  175. package/lib/shared/traverser.js +2 -0
  176. package/lib/source-code/source-code.js +11 -12
  177. package/lib/source-code/token-store/backward-token-comment-cursor.js +5 -5
  178. package/lib/source-code/token-store/backward-token-cursor.js +5 -5
  179. package/lib/source-code/token-store/cursors.js +17 -19
  180. package/lib/source-code/token-store/decorative-cursor.js +1 -1
  181. package/lib/source-code/token-store/filter-cursor.js +2 -2
  182. package/lib/source-code/token-store/forward-token-comment-cursor.js +5 -5
  183. package/lib/source-code/token-store/forward-token-cursor.js +5 -5
  184. package/lib/source-code/token-store/index.js +86 -92
  185. package/lib/source-code/token-store/limit-cursor.js +2 -2
  186. package/lib/source-code/token-store/padded-token-cursor.js +7 -7
  187. package/lib/source-code/token-store/skip-cursor.js +2 -2
  188. package/lib/source-code/token-store/utils.js +9 -13
  189. package/package.json +8 -5
@@ -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", default: true },
92
- after: { type: "boolean", default: true }
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 {Token} token - A token to report.
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 {Token} token - A token to report.
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 {Token} token - A token to report.
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 {Token} token - A token to report.
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 {Token} token - A token to report.
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 {Token} token - A token to report.
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) {
@@ -131,7 +131,7 @@ module.exports = {
131
131
 
132
132
  /**
133
133
  * Check lines around directives in node
134
- * @param {ASTNode} node - node to check
134
+ * @param {ASTNode} node node to check
135
135
  * @returns {void}
136
136
  */
137
137
  function checkDirectives(node) {
@@ -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 - node to check
50
- * @param {ASTNode} parentNode - parent of node to report
51
- * @param {boolean} expected - whether newline was expected or not
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
  */
@@ -65,7 +65,11 @@ module.exports = {
65
65
 
66
66
  const lastToken = sourceCode.getLastToken(node);
67
67
  const hasLastParen = lastToken && astUtils.isClosingParenToken(lastToken);
68
- const hasParens = hasLastParen && astUtils.isOpeningParenToken(sourceCode.getTokenBefore(lastToken));
68
+
69
+ // `hasParens` is true only if the new expression ends with its own parens, e.g., new new foo() does not end with its own parens
70
+ const hasParens = hasLastParen &&
71
+ astUtils.isOpeningParenToken(sourceCode.getTokenBefore(lastToken)) &&
72
+ node.callee.range[1] < node.range[1];
69
73
 
70
74
  if (always) {
71
75
  if (!hasParens) {
@@ -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 - keyword to test
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 - keyword to test
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 - nodeType to test
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 - node to test
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 - `VariableDeclaration` node to test
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 - node to check
43
- * @param {Array} testTokens - array of tokens to test against
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 - node to check
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 - node to check for overlapping comments
84
- * @param {number} lineNumTokenBefore - line number of previous token, to check for overlapping comments
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 - The node to use as the start of the calculation
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 - node to check
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 - A variable to check.
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 - A ClassDeclaration/ClassExpression node to check.
48
+ * @param {ASTNode} node A ClassDeclaration/ClassExpression node to check.
49
49
  * @returns {void}
50
50
  */
51
51
  function checkForClass(node) {
@@ -35,8 +35,7 @@ module.exports = {
35
35
 
36
36
  /**
37
37
  * Checks a given node is -0
38
- *
39
- * @param {ASTNode} node - A node to check.
38
+ * @param {ASTNode} node A node to check.
40
39
  * @returns {boolean} `true` if the node is -0.
41
40
  */
42
41
  function isNegZero(node) {
@@ -14,7 +14,7 @@ const astUtils = require("./utils/ast-utils.js");
14
14
 
15
15
  /**
16
16
  * Checks whether or not a node is a conditional expression.
17
- * @param {ASTNode} node - node to test
17
+ * @param {ASTNode} node node to test
18
18
  * @returns {boolean} `true` if the node is a conditional expression.
19
19
  */
20
20
  function isConditional(node) {
@@ -59,7 +59,7 @@ module.exports = {
59
59
 
60
60
  /**
61
61
  * Reports if an arrow function contains an ambiguous conditional.
62
- * @param {ASTNode} node - A node to check and report.
62
+ * @param {ASTNode} node A node to check and report.
63
63
  * @returns {void}
64
64
  */
65
65
  function checkArrowFunc(node) {
@@ -54,8 +54,7 @@ module.exports = {
54
54
 
55
55
  /**
56
56
  * Checks whether the given reference is 'console' or not.
57
- *
58
- * @param {eslint-scope.Reference} reference - The reference to check.
57
+ * @param {eslint-scope.Reference} reference The reference to check.
59
58
  * @returns {boolean} `true` if the reference is 'console'.
60
59
  */
61
60
  function isConsole(reference) {
@@ -67,8 +66,7 @@ module.exports = {
67
66
  /**
68
67
  * Checks whether the property name of the given MemberExpression node
69
68
  * is allowed by options or not.
70
- *
71
- * @param {ASTNode} node - The MemberExpression node to check.
69
+ * @param {ASTNode} node The MemberExpression node to check.
72
70
  * @returns {boolean} `true` if the property name of the node is allowed.
73
71
  */
74
72
  function isAllowed(node) {
@@ -80,8 +78,7 @@ module.exports = {
80
78
  /**
81
79
  * Checks whether the given reference is a member access which is not
82
80
  * allowed by options or not.
83
- *
84
- * @param {eslint-scope.Reference} reference - The reference to check.
81
+ * @param {eslint-scope.Reference} reference The reference to check.
85
82
  * @returns {boolean} `true` if the reference is a member access which
86
83
  * is not allowed by options.
87
84
  */
@@ -98,8 +95,7 @@ module.exports = {
98
95
 
99
96
  /**
100
97
  * Reports the given reference as a violation.
101
- *
102
- * @param {eslint-scope.Reference} reference - The reference to report.
98
+ * @param {eslint-scope.Reference} reference The reference to report.
103
99
  * @returns {void}
104
100
  */
105
101
  function report(reference) {
@@ -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 - A variable to check.
36
+ * @param {Variable} variable A variable to check.
37
37
  * @returns {void}
38
38
  */
39
39
  function checkVariable(variable) {
@@ -35,7 +35,7 @@ module.exports = {
35
35
 
36
36
  /**
37
37
  * Checks whether or not a given definition is a parameter's.
38
- * @param {eslint-scope.DefEntry} def - A definition to check.
38
+ * @param {eslint-scope.DefEntry} def A definition to check.
39
39
  * @returns {boolean} `true` if the definition is a parameter's.
40
40
  */
41
41
  function isParameter(def) {
@@ -32,8 +32,8 @@ module.exports = {
32
32
 
33
33
  /**
34
34
  * Gets state of a given member name.
35
- * @param {string} name - A name of a member.
36
- * @param {boolean} isStatic - A flag which specifies that is a static member.
35
+ * @param {string} name A name of a member.
36
+ * @param {boolean} isStatic A flag which specifies that is a static member.
37
37
  * @returns {Object} A state of a given member name.
38
38
  * - retv.init {boolean} A flag which shows the name is declared as normal member.
39
39
  * - retv.get {boolean} A flag which shows the name is declared as getter.
@@ -55,8 +55,7 @@ module.exports = {
55
55
 
56
56
  /**
57
57
  * Gets the name text of a given node.
58
- *
59
- * @param {ASTNode} node - A node to get the name.
58
+ * @param {ASTNode} node A node to get the name.
60
59
  * @returns {string} The name text of the node.
61
60
  */
62
61
  function getName(node) {
@@ -23,9 +23,10 @@ const SET_KIND = /^(?:init|set)$/u;
23
23
  */
24
24
  class ObjectInfo {
25
25
 
26
+ // eslint-disable-next-line jsdoc/require-description
26
27
  /**
27
- * @param {ObjectInfo|null} upper - The information of the outer object.
28
- * @param {ASTNode} node - The ObjectExpression node of this information.
28
+ * @param {ObjectInfo|null} upper The information of the outer object.
29
+ * @param {ASTNode} node The ObjectExpression node of this information.
29
30
  */
30
31
  constructor(upper, node) {
31
32
  this.upper = upper;
@@ -35,7 +36,7 @@ class ObjectInfo {
35
36
 
36
37
  /**
37
38
  * Gets the information of the given Property node.
38
- * @param {ASTNode} node - The Property node to get.
39
+ * @param {ASTNode} node The Property node to get.
39
40
  * @returns {{get: boolean, set: boolean}} The information of the property.
40
41
  */
41
42
  getPropertyInfo(node) {
@@ -49,7 +50,7 @@ class ObjectInfo {
49
50
 
50
51
  /**
51
52
  * Checks whether the given property has been defined already or not.
52
- * @param {ASTNode} node - The Property node to check.
53
+ * @param {ASTNode} node The Property node to check.
53
54
  * @returns {boolean} `true` if the property has been defined.
54
55
  */
55
56
  isPropertyDefined(node) {
@@ -63,7 +64,7 @@ class ObjectInfo {
63
64
 
64
65
  /**
65
66
  * Defines the given property.
66
- * @param {ASTNode} node - The Property node to define.
67
+ * @param {ASTNode} node The Property node to define.
67
68
  * @returns {void}
68
69
  */
69
70
  defineProperty(node) {