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
@@ -22,8 +22,7 @@ const assert = require("assert"),
22
22
 
23
23
  /**
24
24
  * Checks whether or not a given node is a `case` node (not `default` node).
25
- *
26
- * @param {ASTNode} node - A `SwitchCase` node to check.
25
+ * @param {ASTNode} node A `SwitchCase` node to check.
27
26
  * @returns {boolean} `true` if the node is a `case` node (not `default` node).
28
27
  */
29
28
  function isCaseNode(node) {
@@ -33,8 +32,7 @@ function isCaseNode(node) {
33
32
  /**
34
33
  * Checks whether the given logical operator is taken into account for the code
35
34
  * path analysis.
36
- *
37
- * @param {string} operator - The operator found in the LogicalExpression node
35
+ * @param {string} operator The operator found in the LogicalExpression node
38
36
  * @returns {boolean} `true` if the operator is "&&" or "||"
39
37
  */
40
38
  function isHandledLogicalOperator(operator) {
@@ -43,8 +41,7 @@ function isHandledLogicalOperator(operator) {
43
41
 
44
42
  /**
45
43
  * Gets the label if the parent node of a given node is a LabeledStatement.
46
- *
47
- * @param {ASTNode} node - A node to get.
44
+ * @param {ASTNode} node A node to get.
48
45
  * @returns {string|null} The label or `null`.
49
46
  */
50
47
  function getLabel(node) {
@@ -57,8 +54,7 @@ function getLabel(node) {
57
54
  /**
58
55
  * Checks whether or not a given logical expression node goes different path
59
56
  * between the `true` case and the `false` case.
60
- *
61
- * @param {ASTNode} node - A node to check.
57
+ * @param {ASTNode} node A node to check.
62
58
  * @returns {boolean} `true` if the node is a test of a choice statement.
63
59
  */
64
60
  function isForkingByTrueOrFalse(node) {
@@ -86,8 +82,7 @@ function isForkingByTrueOrFalse(node) {
86
82
  * This is used to detect infinity loops (e.g. `while (true) {}`).
87
83
  * Statements preceded by an infinity loop are unreachable if the loop didn't
88
84
  * have any `break` statement.
89
- *
90
- * @param {ASTNode} node - A node to get.
85
+ * @param {ASTNode} node A node to get.
91
86
  * @returns {boolean|undefined} a boolean value if the node is a Literal node,
92
87
  * otherwise `undefined`.
93
88
  */
@@ -102,8 +97,7 @@ function getBooleanValueIfSimpleConstant(node) {
102
97
  * Checks that a given identifier node is a reference or not.
103
98
  *
104
99
  * This is used to detect the first throwable node in a `try` block.
105
- *
106
- * @param {ASTNode} node - An Identifier node to check.
100
+ * @param {ASTNode} node An Identifier node to check.
107
101
  * @returns {boolean} `true` if the node is a reference.
108
102
  */
109
103
  function isIdentifierReference(node) {
@@ -153,9 +147,8 @@ function isIdentifierReference(node) {
153
147
  *
154
148
  * In this process, both "onCodePathSegmentStart" and "onCodePathSegmentEnd"
155
149
  * events are fired.
156
- *
157
- * @param {CodePathAnalyzer} analyzer - The instance.
158
- * @param {ASTNode} node - The current AST node.
150
+ * @param {CodePathAnalyzer} analyzer The instance.
151
+ * @param {ASTNode} node The current AST node.
159
152
  * @returns {void}
160
153
  */
161
154
  function forwardCurrentToHead(analyzer, node) {
@@ -211,9 +204,8 @@ function forwardCurrentToHead(analyzer, node) {
211
204
  /**
212
205
  * Updates the current segment with empty.
213
206
  * This is called at the last of functions or the program.
214
- *
215
- * @param {CodePathAnalyzer} analyzer - The instance.
216
- * @param {ASTNode} node - The current AST node.
207
+ * @param {CodePathAnalyzer} analyzer The instance.
208
+ * @param {ASTNode} node The current AST node.
217
209
  * @returns {void}
218
210
  */
219
211
  function leaveFromCurrentSegment(analyzer, node) {
@@ -242,9 +234,8 @@ function leaveFromCurrentSegment(analyzer, node) {
242
234
  *
243
235
  * For example, if the node is `parent.consequent`, this creates a fork from the
244
236
  * current path.
245
- *
246
- * @param {CodePathAnalyzer} analyzer - The instance.
247
- * @param {ASTNode} node - The current AST node.
237
+ * @param {CodePathAnalyzer} analyzer The instance.
238
+ * @param {ASTNode} node The current AST node.
248
239
  * @returns {void}
249
240
  */
250
241
  function preprocess(analyzer, node) {
@@ -352,9 +343,8 @@ function preprocess(analyzer, node) {
352
343
 
353
344
  /**
354
345
  * Updates the code path due to the type of a given node in entering.
355
- *
356
- * @param {CodePathAnalyzer} analyzer - The instance.
357
- * @param {ASTNode} node - The current AST node.
346
+ * @param {CodePathAnalyzer} analyzer The instance.
347
+ * @param {ASTNode} node The current AST node.
358
348
  * @returns {void}
359
349
  */
360
350
  function processCodePathToEnter(analyzer, node) {
@@ -449,9 +439,8 @@ function processCodePathToEnter(analyzer, node) {
449
439
 
450
440
  /**
451
441
  * Updates the code path due to the type of a given node in leaving.
452
- *
453
- * @param {CodePathAnalyzer} analyzer - The instance.
454
- * @param {ASTNode} node - The current AST node.
442
+ * @param {CodePathAnalyzer} analyzer The instance.
443
+ * @param {ASTNode} node The current AST node.
455
444
  * @returns {void}
456
445
  */
457
446
  function processCodePathToExit(analyzer, node) {
@@ -563,9 +552,8 @@ function processCodePathToExit(analyzer, node) {
563
552
 
564
553
  /**
565
554
  * Updates the code path to finalize the current code path.
566
- *
567
- * @param {CodePathAnalyzer} analyzer - The instance.
568
- * @param {ASTNode} node - The current AST node.
555
+ * @param {CodePathAnalyzer} analyzer The instance.
556
+ * @param {ASTNode} node The current AST node.
569
557
  * @returns {void}
570
558
  */
571
559
  function postprocess(analyzer, node) {
@@ -609,8 +597,9 @@ function postprocess(analyzer, node) {
609
597
  */
610
598
  class CodePathAnalyzer {
611
599
 
600
+ // eslint-disable-next-line jsdoc/require-description
612
601
  /**
613
- * @param {EventGenerator} eventGenerator - An event generator to wrap.
602
+ * @param {EventGenerator} eventGenerator An event generator to wrap.
614
603
  */
615
604
  constructor(eventGenerator) {
616
605
  this.original = eventGenerator;
@@ -624,8 +613,7 @@ class CodePathAnalyzer {
624
613
  /**
625
614
  * Does the process to enter a given AST node.
626
615
  * This updates state of analysis and calls `enterNode` of the wrapped.
627
- *
628
- * @param {ASTNode} node - A node which is entering.
616
+ * @param {ASTNode} node A node which is entering.
629
617
  * @returns {void}
630
618
  */
631
619
  enterNode(node) {
@@ -651,8 +639,7 @@ class CodePathAnalyzer {
651
639
  /**
652
640
  * Does the process to leave a given AST node.
653
641
  * This updates state of analysis and calls `leaveNode` of the wrapped.
654
- *
655
- * @param {ASTNode} node - A node which is leaving.
642
+ * @param {ASTNode} node A node which is leaving.
656
643
  * @returns {void}
657
644
  */
658
645
  leaveNode(node) {
@@ -676,9 +663,8 @@ class CodePathAnalyzer {
676
663
  /**
677
664
  * This is called on a code path looped.
678
665
  * Then this raises a looped event.
679
- *
680
- * @param {CodePathSegment} fromSegment - A segment of prev.
681
- * @param {CodePathSegment} toSegment - A segment of next.
666
+ * @param {CodePathSegment} fromSegment A segment of prev.
667
+ * @param {CodePathSegment} toSegment A segment of next.
682
668
  * @returns {void}
683
669
  */
684
670
  onLooped(fromSegment, toSegment) {
@@ -17,8 +17,7 @@ const debug = require("./debug-helpers");
17
17
 
18
18
  /**
19
19
  * Checks whether or not a given segment is reachable.
20
- *
21
- * @param {CodePathSegment} segment - A segment to check.
20
+ * @param {CodePathSegment} segment A segment to check.
22
21
  * @returns {boolean} `true` if the segment is reachable.
23
22
  */
24
23
  function isReachable(segment) {
@@ -34,11 +33,12 @@ function isReachable(segment) {
34
33
  */
35
34
  class CodePathSegment {
36
35
 
36
+ // eslint-disable-next-line jsdoc/require-description
37
37
  /**
38
- * @param {string} id - An identifier.
39
- * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments.
38
+ * @param {string} id An identifier.
39
+ * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
40
40
  * This array includes unreachable segments.
41
- * @param {boolean} reachable - A flag which shows this is reachable.
41
+ * @param {boolean} reachable A flag which shows this is reachable.
42
42
  */
43
43
  constructor(id, allPrevSegments, reachable) {
44
44
 
@@ -98,8 +98,7 @@ class CodePathSegment {
98
98
 
99
99
  /**
100
100
  * Checks a given previous segment is coming from the end of a loop.
101
- *
102
- * @param {CodePathSegment} segment - A previous segment to check.
101
+ * @param {CodePathSegment} segment A previous segment to check.
103
102
  * @returns {boolean} `true` if the segment is coming from the end of a loop.
104
103
  */
105
104
  isLoopedPrevSegment(segment) {
@@ -108,8 +107,7 @@ class CodePathSegment {
108
107
 
109
108
  /**
110
109
  * Creates the root segment.
111
- *
112
- * @param {string} id - An identifier.
110
+ * @param {string} id An identifier.
113
111
  * @returns {CodePathSegment} The created segment.
114
112
  */
115
113
  static newRoot(id) {
@@ -118,9 +116,8 @@ class CodePathSegment {
118
116
 
119
117
  /**
120
118
  * Creates a segment that follows given segments.
121
- *
122
- * @param {string} id - An identifier.
123
- * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments.
119
+ * @param {string} id An identifier.
120
+ * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
124
121
  * @returns {CodePathSegment} The created segment.
125
122
  */
126
123
  static newNext(id, allPrevSegments) {
@@ -133,9 +130,8 @@ class CodePathSegment {
133
130
 
134
131
  /**
135
132
  * Creates an unreachable segment that follows given segments.
136
- *
137
- * @param {string} id - An identifier.
138
- * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments.
133
+ * @param {string} id An identifier.
134
+ * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
139
135
  * @returns {CodePathSegment} The created segment.
140
136
  */
141
137
  static newUnreachable(id, allPrevSegments) {
@@ -154,9 +150,8 @@ class CodePathSegment {
154
150
  * Creates a segment that follows given segments.
155
151
  * This factory method does not connect with `allPrevSegments`.
156
152
  * But this inherits `reachable` flag.
157
- *
158
- * @param {string} id - An identifier.
159
- * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments.
153
+ * @param {string} id An identifier.
154
+ * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
160
155
  * @returns {CodePathSegment} The created segment.
161
156
  */
162
157
  static newDisconnected(id, allPrevSegments) {
@@ -167,8 +162,7 @@ class CodePathSegment {
167
162
  * Makes a given segment being used.
168
163
  *
169
164
  * And this function registers the segment into the previous segments as a next.
170
- *
171
- * @param {CodePathSegment} segment - A segment to mark.
165
+ * @param {CodePathSegment} segment A segment to mark.
172
166
  * @returns {void}
173
167
  */
174
168
  static markUsed(segment) {
@@ -195,9 +189,8 @@ class CodePathSegment {
195
189
 
196
190
  /**
197
191
  * Marks a previous segment as looped.
198
- *
199
- * @param {CodePathSegment} segment - A segment.
200
- * @param {CodePathSegment} prevSegment - A previous segment to mark.
192
+ * @param {CodePathSegment} segment A segment.
193
+ * @param {CodePathSegment} prevSegment A previous segment to mark.
201
194
  * @returns {void}
202
195
  */
203
196
  static markPrevSegmentAsLooped(segment, prevSegment) {
@@ -206,8 +199,7 @@ class CodePathSegment {
206
199
 
207
200
  /**
208
201
  * Replaces unused segments with the previous segments of each unused segment.
209
- *
210
- * @param {CodePathSegment[]} segments - An array of segments to replace.
202
+ * @param {CodePathSegment[]} segments An array of segments to replace.
211
203
  * @returns {CodePathSegment[]} The replaced array.
212
204
  */
213
205
  static flattenUnusedSegments(segments) {