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
@@ -22,11 +22,10 @@ const CodePathSegment = require("./code-path-segment"),
22
22
  * array as well.
23
23
  *
24
24
  * This adds only reachable and used segments.
25
- *
26
- * @param {CodePathSegment[]} dest - A destination array (`returnedSegments` or `thrownSegments`).
27
- * @param {CodePathSegment[]} others - Another destination array (`returnedSegments` or `thrownSegments`).
28
- * @param {CodePathSegment[]} all - The unified destination array (`finalSegments`).
29
- * @param {CodePathSegment[]} segments - Segments to add.
25
+ * @param {CodePathSegment[]} dest A destination array (`returnedSegments` or `thrownSegments`).
26
+ * @param {CodePathSegment[]} others Another destination array (`returnedSegments` or `thrownSegments`).
27
+ * @param {CodePathSegment[]} all The unified destination array (`finalSegments`).
28
+ * @param {CodePathSegment[]} segments Segments to add.
30
29
  * @returns {void}
31
30
  */
32
31
  function addToReturnedOrThrown(dest, others, all, segments) {
@@ -42,9 +41,8 @@ function addToReturnedOrThrown(dest, others, all, segments) {
42
41
 
43
42
  /**
44
43
  * Gets a loop-context for a `continue` statement.
45
- *
46
- * @param {CodePathState} state - A state to get.
47
- * @param {string} label - The label of a `continue` statement.
44
+ * @param {CodePathState} state A state to get.
45
+ * @param {string} label The label of a `continue` statement.
48
46
  * @returns {LoopContext} A loop-context for a `continue` statement.
49
47
  */
50
48
  function getContinueContext(state, label) {
@@ -67,9 +65,8 @@ function getContinueContext(state, label) {
67
65
 
68
66
  /**
69
67
  * Gets a context for a `break` statement.
70
- *
71
- * @param {CodePathState} state - A state to get.
72
- * @param {string} label - The label of a `break` statement.
68
+ * @param {CodePathState} state A state to get.
69
+ * @param {string} label The label of a `break` statement.
73
70
  * @returns {LoopContext|SwitchContext} A context for a `break` statement.
74
71
  */
75
72
  function getBreakContext(state, label) {
@@ -88,8 +85,7 @@ function getBreakContext(state, label) {
88
85
 
89
86
  /**
90
87
  * Gets a context for a `return` statement.
91
- *
92
- * @param {CodePathState} state - A state to get.
88
+ * @param {CodePathState} state A state to get.
93
89
  * @returns {TryContext|CodePathState} A context for a `return` statement.
94
90
  */
95
91
  function getReturnContext(state) {
@@ -107,8 +103,7 @@ function getReturnContext(state) {
107
103
 
108
104
  /**
109
105
  * Gets a context for a `throw` statement.
110
- *
111
- * @param {CodePathState} state - A state to get.
106
+ * @param {CodePathState} state A state to get.
112
107
  * @returns {TryContext|CodePathState} A context for a `throw` statement.
113
108
  */
114
109
  function getThrowContext(state) {
@@ -128,9 +123,8 @@ function getThrowContext(state) {
128
123
 
129
124
  /**
130
125
  * Removes a given element from a given array.
131
- *
132
- * @param {any[]} xs - An array to remove the specific element.
133
- * @param {any} x - An element to be removed.
126
+ * @param {any[]} xs An array to remove the specific element.
127
+ * @param {any} x An element to be removed.
134
128
  * @returns {void}
135
129
  */
136
130
  function remove(xs, x) {
@@ -143,9 +137,8 @@ function remove(xs, x) {
143
137
  * This is used in a process for switch statements.
144
138
  * If there is the "default" chunk before other cases, the order is different
145
139
  * between node's and running's.
146
- *
147
- * @param {CodePathSegment[]} prevSegments - Forward segments to disconnect.
148
- * @param {CodePathSegment[]} nextSegments - Backward segments to disconnect.
140
+ * @param {CodePathSegment[]} prevSegments Forward segments to disconnect.
141
+ * @param {CodePathSegment[]} nextSegments Backward segments to disconnect.
149
142
  * @returns {void}
150
143
  */
151
144
  function removeConnection(prevSegments, nextSegments) {
@@ -162,10 +155,9 @@ function removeConnection(prevSegments, nextSegments) {
162
155
 
163
156
  /**
164
157
  * Creates looping path.
165
- *
166
- * @param {CodePathState} state - The instance.
167
- * @param {CodePathSegment[]} unflattenedFromSegments - Segments which are source.
168
- * @param {CodePathSegment[]} unflattenedToSegments - Segments which are destination.
158
+ * @param {CodePathState} state The instance.
159
+ * @param {CodePathSegment[]} unflattenedFromSegments Segments which are source.
160
+ * @param {CodePathSegment[]} unflattenedToSegments Segments which are destination.
169
161
  * @returns {void}
170
162
  */
171
163
  function makeLooped(state, unflattenedFromSegments, unflattenedToSegments) {
@@ -200,10 +192,9 @@ function makeLooped(state, unflattenedFromSegments, unflattenedToSegments) {
200
192
  *
201
193
  * - Adds `false` paths to paths which are leaving from the loop.
202
194
  * - Sets `true` paths to paths which go to the body.
203
- *
204
- * @param {LoopContext} context - A loop context to modify.
205
- * @param {ChoiceContext} choiceContext - A choice context of this loop.
206
- * @param {CodePathSegment[]} head - The current head paths.
195
+ * @param {LoopContext} context A loop context to modify.
196
+ * @param {ChoiceContext} choiceContext A choice context of this loop.
197
+ * @param {CodePathSegment[]} head The current head paths.
207
198
  * @returns {void}
208
199
  */
209
200
  function finalizeTestSegmentsOfFor(context, choiceContext, head) {
@@ -227,10 +218,11 @@ function finalizeTestSegmentsOfFor(context, choiceContext, head) {
227
218
  */
228
219
  class CodePathState {
229
220
 
221
+ // eslint-disable-next-line jsdoc/require-description
230
222
  /**
231
- * @param {IdGenerator} idGenerator - An id generator to generate id for code
223
+ * @param {IdGenerator} idGenerator An id generator to generate id for code
232
224
  * path segments.
233
- * @param {Function} onLooped - A callback function to notify looping.
225
+ * @param {Function} onLooped A callback function to notify looping.
234
226
  */
235
227
  constructor(idGenerator, onLooped) {
236
228
  this.idGenerator = idGenerator;
@@ -275,8 +267,7 @@ class CodePathState {
275
267
 
276
268
  /**
277
269
  * Creates and stacks new forking context.
278
- *
279
- * @param {boolean} forkLeavingPath - A flag which shows being in a
270
+ * @param {boolean} forkLeavingPath A flag which shows being in a
280
271
  * "finally" block.
281
272
  * @returns {ForkContext} The created context.
282
273
  */
@@ -313,7 +304,6 @@ class CodePathState {
313
304
  /**
314
305
  * Creates a bypass path.
315
306
  * This is used for such as IfStatement which does not have "else" chunk.
316
- *
317
307
  * @returns {void}
318
308
  */
319
309
  forkBypassPath() {
@@ -346,12 +336,11 @@ class CodePathState {
346
336
  * a -> foo();
347
337
  * a -> b -> foo();
348
338
  * a -> b -> bar();
349
- *
350
- * @param {string} kind - A kind string.
339
+ * @param {string} kind A kind string.
351
340
  * If the new context is LogicalExpression's, this is `"&&"` or `"||"`.
352
341
  * If it's IfStatement's or ConditionalExpression's, this is `"test"`.
353
342
  * Otherwise, this is `"loop"`.
354
- * @param {boolean} isForkingAsResult - A flag that shows that goes different
343
+ * @param {boolean} isForkingAsResult A flag that shows that goes different
355
344
  * paths between `true` and `false`.
356
345
  * @returns {void}
357
346
  */
@@ -368,7 +357,6 @@ class CodePathState {
368
357
 
369
358
  /**
370
359
  * Pops the last choice context and finalizes it.
371
- *
372
360
  * @returns {ChoiceContext} The popped context.
373
361
  */
374
362
  popChoiceContext() {
@@ -456,7 +444,6 @@ class CodePathState {
456
444
  /**
457
445
  * Makes a code path segment of the right-hand operand of a logical
458
446
  * expression.
459
- *
460
447
  * @returns {void}
461
448
  */
462
449
  makeLogicalRight() {
@@ -500,7 +487,6 @@ class CodePathState {
500
487
 
501
488
  /**
502
489
  * Makes a code path segment of the `if` block.
503
- *
504
490
  * @returns {void}
505
491
  */
506
492
  makeIfConsequent() {
@@ -527,7 +513,6 @@ class CodePathState {
527
513
 
528
514
  /**
529
515
  * Makes a code path segment of the `else` block.
530
- *
531
516
  * @returns {void}
532
517
  */
533
518
  makeIfAlternate() {
@@ -554,10 +539,9 @@ class CodePathState {
554
539
 
555
540
  /**
556
541
  * Creates a context object of SwitchStatement and stacks it.
557
- *
558
- * @param {boolean} hasCase - `true` if the switch statement has one or more
542
+ * @param {boolean} hasCase `true` if the switch statement has one or more
559
543
  * case parts.
560
- * @param {string|null} label - The label text.
544
+ * @param {string|null} label The label text.
561
545
  * @returns {void}
562
546
  */
563
547
  pushSwitchContext(hasCase, label) {
@@ -581,7 +565,6 @@ class CodePathState {
581
565
  * - Creates the next code path segment from `context.brokenForkContext`.
582
566
  * - If the last `SwitchCase` node is not a `default` part, creates a path
583
567
  * to the `default` body.
584
- *
585
568
  * @returns {void}
586
569
  */
587
570
  popSwitchContext() {
@@ -655,9 +638,8 @@ class CodePathState {
655
638
 
656
639
  /**
657
640
  * Makes a code path segment for a `SwitchCase` node.
658
- *
659
- * @param {boolean} isEmpty - `true` if the body is empty.
660
- * @param {boolean} isDefault - `true` if the body is the default case.
641
+ * @param {boolean} isEmpty `true` if the body is empty.
642
+ * @param {boolean} isDefault `true` if the body is the default case.
661
643
  * @returns {void}
662
644
  */
663
645
  makeSwitchCaseBody(isEmpty, isDefault) {
@@ -706,8 +688,7 @@ class CodePathState {
706
688
 
707
689
  /**
708
690
  * Creates a context object of TryStatement and stacks it.
709
- *
710
- * @param {boolean} hasFinalizer - `true` if the try statement has a
691
+ * @param {boolean} hasFinalizer `true` if the try statement has a
711
692
  * `finally` block.
712
693
  * @returns {void}
713
694
  */
@@ -729,7 +710,6 @@ class CodePathState {
729
710
 
730
711
  /**
731
712
  * Pops the last context of TryStatement and finalizes it.
732
- *
733
713
  * @returns {void}
734
714
  */
735
715
  popTryContext() {
@@ -785,7 +765,6 @@ class CodePathState {
785
765
 
786
766
  /**
787
767
  * Makes a code path segment for a `catch` block.
788
- *
789
768
  * @returns {void}
790
769
  */
791
770
  makeCatchBlock() {
@@ -814,7 +793,6 @@ class CodePathState {
814
793
  * In the `finally` block, parallel paths are created. The parallel paths
815
794
  * are used as leaving-paths. The leaving-paths are paths from `return`
816
795
  * statements and `throw` statements in a `try` block or a `catch` block.
817
- *
818
796
  * @returns {void}
819
797
  */
820
798
  makeFinallyBlock() {
@@ -874,7 +852,6 @@ class CodePathState {
874
852
  /**
875
853
  * Makes a code path segment from the first throwable node to the `catch`
876
854
  * block or the `finally` block.
877
- *
878
855
  * @returns {void}
879
856
  */
880
857
  makeFirstThrowablePathInTryBlock() {
@@ -903,11 +880,10 @@ class CodePathState {
903
880
 
904
881
  /**
905
882
  * Creates a context object of a loop statement and stacks it.
906
- *
907
- * @param {string} type - The type of the node which was triggered. One of
883
+ * @param {string} type The type of the node which was triggered. One of
908
884
  * `WhileStatement`, `DoWhileStatement`, `ForStatement`, `ForInStatement`,
909
885
  * and `ForStatement`.
910
- * @param {string|null} label - A label of the node which was triggered.
886
+ * @param {string|null} label A label of the node which was triggered.
911
887
  * @returns {void}
912
888
  */
913
889
  pushLoopContext(type, label) {
@@ -979,7 +955,6 @@ class CodePathState {
979
955
 
980
956
  /**
981
957
  * Pops the last context of a loop statement and finalizes it.
982
- *
983
958
  * @returns {void}
984
959
  */
985
960
  popLoopContext() {
@@ -1051,8 +1026,7 @@ class CodePathState {
1051
1026
 
1052
1027
  /**
1053
1028
  * Makes a code path segment for the test part of a WhileStatement.
1054
- *
1055
- * @param {boolean|undefined} test - The test value (only when constant).
1029
+ * @param {boolean|undefined} test The test value (only when constant).
1056
1030
  * @returns {void}
1057
1031
  */
1058
1032
  makeWhileTest(test) {
@@ -1068,7 +1042,6 @@ class CodePathState {
1068
1042
 
1069
1043
  /**
1070
1044
  * Makes a code path segment for the body part of a WhileStatement.
1071
- *
1072
1045
  * @returns {void}
1073
1046
  */
1074
1047
  makeWhileBody() {
@@ -1090,7 +1063,6 @@ class CodePathState {
1090
1063
 
1091
1064
  /**
1092
1065
  * Makes a code path segment for the body part of a DoWhileStatement.
1093
- *
1094
1066
  * @returns {void}
1095
1067
  */
1096
1068
  makeDoWhileBody() {
@@ -1105,8 +1077,7 @@ class CodePathState {
1105
1077
 
1106
1078
  /**
1107
1079
  * Makes a code path segment for the test part of a DoWhileStatement.
1108
- *
1109
- * @param {boolean|undefined} test - The test value (only when constant).
1080
+ * @param {boolean|undefined} test The test value (only when constant).
1110
1081
  * @returns {void}
1111
1082
  */
1112
1083
  makeDoWhileTest(test) {
@@ -1126,8 +1097,7 @@ class CodePathState {
1126
1097
 
1127
1098
  /**
1128
1099
  * Makes a code path segment for the test part of a ForStatement.
1129
- *
1130
- * @param {boolean|undefined} test - The test value (only when constant).
1100
+ * @param {boolean|undefined} test The test value (only when constant).
1131
1101
  * @returns {void}
1132
1102
  */
1133
1103
  makeForTest(test) {
@@ -1145,7 +1115,6 @@ class CodePathState {
1145
1115
 
1146
1116
  /**
1147
1117
  * Makes a code path segment for the update part of a ForStatement.
1148
- *
1149
1118
  * @returns {void}
1150
1119
  */
1151
1120
  makeForUpdate() {
@@ -1173,7 +1142,6 @@ class CodePathState {
1173
1142
 
1174
1143
  /**
1175
1144
  * Makes a code path segment for the body part of a ForStatement.
1176
- *
1177
1145
  * @returns {void}
1178
1146
  */
1179
1147
  makeForBody() {
@@ -1227,7 +1195,6 @@ class CodePathState {
1227
1195
  /**
1228
1196
  * Makes a code path segment for the left part of a ForInStatement and a
1229
1197
  * ForOfStatement.
1230
- *
1231
1198
  * @returns {void}
1232
1199
  */
1233
1200
  makeForInOfLeft() {
@@ -1244,7 +1211,6 @@ class CodePathState {
1244
1211
  /**
1245
1212
  * Makes a code path segment for the right part of a ForInStatement and a
1246
1213
  * ForOfStatement.
1247
- *
1248
1214
  * @returns {void}
1249
1215
  */
1250
1216
  makeForInOfRight() {
@@ -1263,7 +1229,6 @@ class CodePathState {
1263
1229
  /**
1264
1230
  * Makes a code path segment for the body part of a ForInStatement and a
1265
1231
  * ForOfStatement.
1266
- *
1267
1232
  * @returns {void}
1268
1233
  */
1269
1234
  makeForInOfBody() {
@@ -1288,10 +1253,9 @@ class CodePathState {
1288
1253
 
1289
1254
  /**
1290
1255
  * Creates new context for BreakStatement.
1291
- *
1292
- * @param {boolean} breakable - The flag to indicate it can break by
1256
+ * @param {boolean} breakable The flag to indicate it can break by
1293
1257
  * an unlabeled BreakStatement.
1294
- * @param {string|null} label - The label of this context.
1258
+ * @param {string|null} label The label of this context.
1295
1259
  * @returns {Object} The new context.
1296
1260
  */
1297
1261
  pushBreakContext(breakable, label) {
@@ -1306,7 +1270,6 @@ class CodePathState {
1306
1270
 
1307
1271
  /**
1308
1272
  * Removes the top item of the break context stack.
1309
- *
1310
1273
  * @returns {Object} The removed context.
1311
1274
  */
1312
1275
  popBreakContext() {
@@ -1333,8 +1296,7 @@ class CodePathState {
1333
1296
  *
1334
1297
  * It registers the head segment to a context of `break`.
1335
1298
  * It makes new unreachable segment, then it set the head with the segment.
1336
- *
1337
- * @param {string} label - A label of the break statement.
1299
+ * @param {string} label A label of the break statement.
1338
1300
  * @returns {void}
1339
1301
  */
1340
1302
  makeBreak(label) {
@@ -1359,8 +1321,7 @@ class CodePathState {
1359
1321
  *
1360
1322
  * It makes a looping path.
1361
1323
  * It makes new unreachable segment, then it set the head with the segment.
1362
- *
1363
- * @param {string} label - A label of the continue statement.
1324
+ * @param {string} label A label of the continue statement.
1364
1325
  * @returns {void}
1365
1326
  */
1366
1327
  makeContinue(label) {
@@ -1395,7 +1356,6 @@ class CodePathState {
1395
1356
  *
1396
1357
  * It registers the head segment to a context of `return`.
1397
1358
  * It makes new unreachable segment, then it set the head with the segment.
1398
- *
1399
1359
  * @returns {void}
1400
1360
  */
1401
1361
  makeReturn() {
@@ -1412,7 +1372,6 @@ class CodePathState {
1412
1372
  *
1413
1373
  * It registers the head segment to a context of `throw`.
1414
1374
  * It makes new unreachable segment, then it set the head with the segment.
1415
- *
1416
1375
  * @returns {void}
1417
1376
  */
1418
1377
  makeThrow() {
@@ -21,10 +21,11 @@ const IdGenerator = require("./id-generator");
21
21
  */
22
22
  class CodePath {
23
23
 
24
+ // eslint-disable-next-line jsdoc/require-description
24
25
  /**
25
- * @param {string} id - An identifier.
26
- * @param {CodePath|null} upper - The code path of the upper function scope.
27
- * @param {Function} onLooped - A callback function to notify looping.
26
+ * @param {string} id An identifier.
27
+ * @param {CodePath|null} upper The code path of the upper function scope.
28
+ * @param {Function} onLooped A callback function to notify looping.
28
29
  */
29
30
  constructor(id, upper, onLooped) {
30
31
 
@@ -62,8 +63,7 @@ class CodePath {
62
63
 
63
64
  /**
64
65
  * Gets the state of a given code path.
65
- *
66
- * @param {CodePath} codePath - A code path to get.
66
+ * @param {CodePath} codePath A code path to get.
67
67
  * @returns {CodePathState} The state of the code path.
68
68
  */
69
69
  static getState(codePath) {
@@ -126,11 +126,10 @@ class CodePath {
126
126
  *
127
127
  * - `controller.skip()` - Skip the following segments in this branch.
128
128
  * - `controller.break()` - Skip all following segments.
129
- *
130
- * @param {Object} [options] - Omittable.
131
- * @param {CodePathSegment} [options.first] - The first segment to traverse.
132
- * @param {CodePathSegment} [options.last] - The last segment to traverse.
133
- * @param {Function} callback - A callback function.
129
+ * @param {Object} [options] Omittable.
130
+ * @param {CodePathSegment} [options.first] The first segment to traverse.
131
+ * @param {CodePathSegment} [options.last] The last segment to traverse.
132
+ * @param {Function} callback A callback function.
134
133
  * @returns {void}
135
134
  */
136
135
  traverseSegments(options, callback) {
@@ -171,7 +170,7 @@ class CodePath {
171
170
 
172
171
  /**
173
172
  * Checks a given previous segment has been visited.
174
- * @param {CodePathSegment} prevSegment - A previous segment to check.
173
+ * @param {CodePathSegment} prevSegment A previous segment to check.
175
174
  * @returns {boolean} `true` if the segment has been visited.
176
175
  */
177
176
  function isVisited(prevSegment) {
@@ -17,11 +17,11 @@ const debug = require("debug")("eslint:code-path");
17
17
 
18
18
  /**
19
19
  * Gets id of a given segment.
20
- * @param {CodePathSegment} segment - A segment to get.
20
+ * @param {CodePathSegment} segment A segment to get.
21
21
  * @returns {string} Id of the segment.
22
22
  */
23
23
  /* istanbul ignore next */
24
- function getId(segment) { // eslint-disable-line require-jsdoc
24
+ function getId(segment) { // eslint-disable-line jsdoc/require-jsdoc
25
25
  return segment.id + (segment.reachable ? "" : "!");
26
26
  }
27
27
 
@@ -39,18 +39,16 @@ module.exports = {
39
39
 
40
40
  /**
41
41
  * Dumps given objects.
42
- *
43
- * @param {...any} args - objects to dump.
42
+ * @param {...any} args objects to dump.
44
43
  * @returns {void}
45
44
  */
46
45
  dump: debug,
47
46
 
48
47
  /**
49
48
  * Dumps the current analyzing state.
50
- *
51
- * @param {ASTNode} node - A node to dump.
52
- * @param {CodePathState} state - A state to dump.
53
- * @param {boolean} leaving - A flag whether or not it's leaving
49
+ * @param {ASTNode} node A node to dump.
50
+ * @param {CodePathState} state A state to dump.
51
+ * @param {boolean} leaving A flag whether or not it's leaving
54
52
  * @returns {void}
55
53
  */
56
54
  dumpState: !debug.enabled ? debug : /* istanbul ignore next */ function(node, state, leaving) {
@@ -73,8 +71,7 @@ module.exports = {
73
71
  /**
74
72
  * Dumps a DOT code of a given code path.
75
73
  * The DOT code can be visialized with Graphvis.
76
- *
77
- * @param {CodePath} codePath - A code path to dump.
74
+ * @param {CodePath} codePath A code path to dump.
78
75
  * @returns {void}
79
76
  * @see http://www.graphviz.org
80
77
  * @see http://www.webgraphviz.com
@@ -139,9 +136,8 @@ module.exports = {
139
136
  /**
140
137
  * Makes a DOT code of a given code path.
141
138
  * The DOT code can be visialized with Graphvis.
142
- *
143
- * @param {CodePath} codePath - A code path to make DOT.
144
- * @param {Object} traceMap - Optional. A map to check whether or not segments had been done.
139
+ * @param {CodePath} codePath A code path to make DOT.
140
+ * @param {Object} traceMap Optional. A map to check whether or not segments had been done.
145
141
  * @returns {string} A DOT code of the code path.
146
142
  */
147
143
  makeDotArrows(codePath, traceMap) {
@@ -22,8 +22,7 @@ const assert = require("assert"),
22
22
 
23
23
  /**
24
24
  * Gets whether or not a given segment is reachable.
25
- *
26
- * @param {CodePathSegment} segment - A segment to get.
25
+ * @param {CodePathSegment} segment A segment to get.
27
26
  * @returns {boolean} `true` if the segment is reachable.
28
27
  */
29
28
  function isReachable(segment) {
@@ -36,11 +35,10 @@ function isReachable(segment) {
36
35
  * When `context.segmentsList` is `[[a, b], [c, d], [e, f]]`, `begin` is `0`, and
37
36
  * `end` is `-1`, this creates `[g, h]`. This `g` is from `a`, `c`, and `e`.
38
37
  * This `h` is from `b`, `d`, and `f`.
39
- *
40
- * @param {ForkContext} context - An instance.
41
- * @param {number} begin - The first index of the previous segments.
42
- * @param {number} end - The last index of the previous segments.
43
- * @param {Function} create - A factory function of new segments.
38
+ * @param {ForkContext} context An instance.
39
+ * @param {number} begin The first index of the previous segments.
40
+ * @param {number} end The last index of the previous segments.
41
+ * @param {Function} create A factory function of new segments.
44
42
  * @returns {CodePathSegment[]} New segments.
45
43
  */
46
44
  function makeSegments(context, begin, end, create) {
@@ -69,9 +67,8 @@ function makeSegments(context, begin, end, create) {
69
67
  * control statement (such as `break`, `continue`) from the `finally` block, the
70
68
  * destination's segments may be half of the source segments. In that case, this
71
69
  * merges segments.
72
- *
73
- * @param {ForkContext} context - An instance.
74
- * @param {CodePathSegment[]} segments - Segments to merge.
70
+ * @param {ForkContext} context An instance.
71
+ * @param {CodePathSegment[]} segments Segments to merge.
75
72
  * @returns {CodePathSegment[]} The merged segments.
76
73
  */
77
74
  function mergeExtraSegments(context, segments) {
@@ -100,10 +97,11 @@ function mergeExtraSegments(context, segments) {
100
97
  */
101
98
  class ForkContext {
102
99
 
100
+ // eslint-disable-next-line jsdoc/require-description
103
101
  /**
104
- * @param {IdGenerator} idGenerator - An identifier generator for segments.
105
- * @param {ForkContext|null} upper - An upper fork context.
106
- * @param {number} count - A number of parallel segments.
102
+ * @param {IdGenerator} idGenerator An identifier generator for segments.
103
+ * @param {ForkContext|null} upper An upper fork context.
104
+ * @param {number} count A number of parallel segments.
107
105
  */
108
106
  constructor(idGenerator, upper, count) {
109
107
  this.idGenerator = idGenerator;
@@ -142,9 +140,8 @@ class ForkContext {
142
140
 
143
141
  /**
144
142
  * Creates new segments from this context.
145
- *
146
- * @param {number} begin - The first index of previous segments.
147
- * @param {number} end - The last index of previous segments.
143
+ * @param {number} begin The first index of previous segments.
144
+ * @param {number} end The last index of previous segments.
148
145
  * @returns {CodePathSegment[]} New segments.
149
146
  */
150
147
  makeNext(begin, end) {
@@ -154,9 +151,8 @@ class ForkContext {
154
151
  /**
155
152
  * Creates new segments from this context.
156
153
  * The new segments is always unreachable.
157
- *
158
- * @param {number} begin - The first index of previous segments.
159
- * @param {number} end - The last index of previous segments.
154
+ * @param {number} begin The first index of previous segments.
155
+ * @param {number} end The last index of previous segments.
160
156
  * @returns {CodePathSegment[]} New segments.
161
157
  */
162
158
  makeUnreachable(begin, end) {
@@ -167,9 +163,8 @@ class ForkContext {
167
163
  * Creates new segments from this context.
168
164
  * The new segments don't have connections for previous segments.
169
165
  * But these inherit the reachable flag from this context.
170
- *
171
- * @param {number} begin - The first index of previous segments.
172
- * @param {number} end - The last index of previous segments.
166
+ * @param {number} begin The first index of previous segments.
167
+ * @param {number} end The last index of previous segments.
173
168
  * @returns {CodePathSegment[]} New segments.
174
169
  */
175
170
  makeDisconnected(begin, end) {
@@ -179,8 +174,7 @@ class ForkContext {
179
174
  /**
180
175
  * Adds segments into this context.
181
176
  * The added segments become the head.
182
- *
183
- * @param {CodePathSegment[]} segments - Segments to add.
177
+ * @param {CodePathSegment[]} segments Segments to add.
184
178
  * @returns {void}
185
179
  */
186
180
  add(segments) {
@@ -192,8 +186,7 @@ class ForkContext {
192
186
  /**
193
187
  * Replaces the head segments with given segments.
194
188
  * The current head segments are removed.
195
- *
196
- * @param {CodePathSegment[]} segments - Segments to add.
189
+ * @param {CodePathSegment[]} segments Segments to add.
197
190
  * @returns {void}
198
191
  */
199
192
  replaceHead(segments) {
@@ -204,8 +197,7 @@ class ForkContext {
204
197
 
205
198
  /**
206
199
  * Adds all segments of a given fork context into this context.
207
- *
208
- * @param {ForkContext} context - A fork context to add.
200
+ * @param {ForkContext} context A fork context to add.
209
201
  * @returns {void}
210
202
  */
211
203
  addAll(context) {
@@ -220,7 +212,6 @@ class ForkContext {
220
212
 
221
213
  /**
222
214
  * Clears all secments in this context.
223
- *
224
215
  * @returns {void}
225
216
  */
226
217
  clear() {
@@ -229,8 +220,7 @@ class ForkContext {
229
220
 
230
221
  /**
231
222
  * Creates the root fork context.
232
- *
233
- * @param {IdGenerator} idGenerator - An identifier generator for segments.
223
+ * @param {IdGenerator} idGenerator An identifier generator for segments.
234
224
  * @returns {ForkContext} New fork context.
235
225
  */
236
226
  static newRoot(idGenerator) {
@@ -243,9 +233,8 @@ class ForkContext {
243
233
 
244
234
  /**
245
235
  * Creates an empty fork context preceded by a given context.
246
- *
247
- * @param {ForkContext} parentContext - The parent fork context.
248
- * @param {boolean} forkLeavingPath - A flag which shows inside of `finally` block.
236
+ * @param {ForkContext} parentContext The parent fork context.
237
+ * @param {boolean} forkLeavingPath A flag which shows inside of `finally` block.
249
238
  * @returns {ForkContext} New fork context.
250
239
  */
251
240
  static newEmpty(parentContext, forkLeavingPath) {
@@ -18,8 +18,9 @@
18
18
  */
19
19
  class IdGenerator {
20
20
 
21
+ // eslint-disable-next-line jsdoc/require-description
21
22
  /**
22
- * @param {string} prefix - Optional. A prefix of generated ids.
23
+ * @param {string} prefix Optional. A prefix of generated ids.
23
24
  */
24
25
  constructor(prefix) {
25
26
  this.prefix = String(prefix);
@@ -28,7 +29,6 @@ class IdGenerator {
28
29
 
29
30
  /**
30
31
  * Generates id.
31
- *
32
32
  * @returns {string} A generated id.
33
33
  */
34
34
  next() {