eslint 6.5.0 → 6.7.1

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 (196) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +10 -9
  3. package/conf/config-schema.js +1 -0
  4. package/conf/default-cli-options.js +1 -1
  5. package/lib/cli-engine/cascading-config-array-factory.js +40 -14
  6. package/lib/cli-engine/cli-engine.js +49 -21
  7. package/lib/cli-engine/config-array/config-array.js +13 -4
  8. package/lib/cli-engine/config-array/config-dependency.js +2 -0
  9. package/lib/cli-engine/config-array/extracted-config.js +27 -0
  10. package/lib/cli-engine/config-array/ignore-pattern.js +231 -0
  11. package/lib/cli-engine/config-array/index.js +2 -0
  12. package/lib/cli-engine/config-array/override-tester.js +2 -0
  13. package/lib/cli-engine/config-array-factory.js +120 -2
  14. package/lib/cli-engine/file-enumerator.js +51 -30
  15. package/lib/cli-engine/formatters/html.js +1 -0
  16. package/lib/init/autoconfig.js +1 -11
  17. package/lib/init/config-file.js +0 -1
  18. package/lib/init/config-initializer.js +4 -4
  19. package/lib/init/config-rule.js +1 -5
  20. package/lib/init/npm-utils.js +0 -5
  21. package/lib/linter/code-path-analysis/code-path-analyzer.js +24 -38
  22. package/lib/linter/code-path-analysis/code-path-segment.js +17 -25
  23. package/lib/linter/code-path-analysis/code-path-state.js +40 -81
  24. package/lib/linter/code-path-analysis/code-path.js +10 -11
  25. package/lib/linter/code-path-analysis/debug-helpers.js +8 -12
  26. package/lib/linter/code-path-analysis/fork-context.js +23 -34
  27. package/lib/linter/code-path-analysis/id-generator.js +2 -2
  28. package/lib/linter/linter.js +121 -95
  29. package/lib/linter/node-event-generator.js +3 -2
  30. package/lib/linter/report-translator.js +73 -7
  31. package/lib/rule-tester/rule-tester.js +46 -14
  32. package/lib/rules/accessor-pairs.js +8 -8
  33. package/lib/rules/array-bracket-newline.js +12 -15
  34. package/lib/rules/array-bracket-spacing.js +12 -12
  35. package/lib/rules/array-callback-return.js +6 -11
  36. package/lib/rules/array-element-newline.js +5 -8
  37. package/lib/rules/arrow-parens.js +0 -1
  38. package/lib/rules/block-scoped-var.js +3 -3
  39. package/lib/rules/block-spacing.js +4 -4
  40. package/lib/rules/camelcase.js +19 -6
  41. package/lib/rules/capitalized-comments.js +0 -7
  42. package/lib/rules/class-methods-use-this.js +3 -3
  43. package/lib/rules/comma-dangle.js +20 -25
  44. package/lib/rules/comma-spacing.js +1 -1
  45. package/lib/rules/computed-property-spacing.js +14 -14
  46. package/lib/rules/consistent-return.js +4 -5
  47. package/lib/rules/consistent-this.js +5 -5
  48. package/lib/rules/constructor-super.js +14 -16
  49. package/lib/rules/curly.js +12 -9
  50. package/lib/rules/default-param-last.js +1 -0
  51. package/lib/rules/dot-location.js +11 -12
  52. package/lib/rules/func-names.js +6 -6
  53. package/lib/rules/function-call-argument-newline.js +8 -6
  54. package/lib/rules/generator-star-spacing.js +4 -9
  55. package/lib/rules/getter-return.js +4 -7
  56. package/lib/rules/grouped-accessor-pairs.js +224 -0
  57. package/lib/rules/indent.js +13 -2
  58. package/lib/rules/index.js +5 -0
  59. package/lib/rules/init-declarations.js +2 -2
  60. package/lib/rules/jsx-quotes.js +1 -1
  61. package/lib/rules/keyword-spacing.js +32 -56
  62. package/lib/rules/lines-around-directive.js +1 -1
  63. package/lib/rules/max-len.js +0 -5
  64. package/lib/rules/max-statements-per-line.js +3 -7
  65. package/lib/rules/multiline-comment-style.js +237 -106
  66. package/lib/rules/multiline-ternary.js +3 -3
  67. package/lib/rules/newline-after-var.js +6 -7
  68. package/lib/rules/newline-before-return.js +8 -9
  69. package/lib/rules/newline-per-chained-call.js +2 -4
  70. package/lib/rules/no-class-assign.js +2 -2
  71. package/lib/rules/no-compare-neg-zero.js +1 -2
  72. package/lib/rules/no-cond-assign.js +14 -4
  73. package/lib/rules/no-confusing-arrow.js +2 -2
  74. package/lib/rules/no-console.js +4 -8
  75. package/lib/rules/no-const-assign.js +1 -1
  76. package/lib/rules/no-constructor-return.js +62 -0
  77. package/lib/rules/no-dupe-args.js +1 -1
  78. package/lib/rules/no-dupe-class-members.js +3 -4
  79. package/lib/rules/no-dupe-else-if.js +122 -0
  80. package/lib/rules/no-dupe-keys.js +6 -5
  81. package/lib/rules/no-duplicate-imports.js +14 -18
  82. package/lib/rules/no-else-return.js +0 -8
  83. package/lib/rules/no-empty-function.js +2 -4
  84. package/lib/rules/no-eval.js +10 -18
  85. package/lib/rules/no-ex-assign.js +1 -1
  86. package/lib/rules/no-extra-bind.js +5 -12
  87. package/lib/rules/no-extra-boolean-cast.js +0 -2
  88. package/lib/rules/no-extra-label.js +4 -9
  89. package/lib/rules/no-extra-parens.js +17 -15
  90. package/lib/rules/no-extra-semi.js +5 -6
  91. package/lib/rules/no-fallthrough.js +6 -6
  92. package/lib/rules/no-func-assign.js +3 -3
  93. package/lib/rules/no-global-assign.js +4 -4
  94. package/lib/rules/no-implicit-coercion.js +10 -10
  95. package/lib/rules/no-implicit-globals.js +90 -8
  96. package/lib/rules/no-implied-eval.js +0 -1
  97. package/lib/rules/no-inline-comments.js +25 -11
  98. package/lib/rules/no-invalid-this.js +17 -5
  99. package/lib/rules/no-labels.js +3 -6
  100. package/lib/rules/no-lone-blocks.js +1 -1
  101. package/lib/rules/no-loop-func.js +6 -11
  102. package/lib/rules/no-magic-numbers.js +6 -6
  103. package/lib/rules/no-misleading-character-class.js +14 -7
  104. package/lib/rules/no-mixed-operators.js +13 -22
  105. package/lib/rules/no-mixed-requires.js +0 -1
  106. package/lib/rules/no-multi-spaces.js +1 -1
  107. package/lib/rules/no-native-reassign.js +4 -4
  108. package/lib/rules/no-octal-escape.js +1 -1
  109. package/lib/rules/no-param-reassign.js +28 -7
  110. package/lib/rules/no-redeclare.js +1 -1
  111. package/lib/rules/no-regex-spaces.js +0 -1
  112. package/lib/rules/no-restricted-imports.js +11 -11
  113. package/lib/rules/no-self-assign.js +12 -13
  114. package/lib/rules/no-sequences.js +3 -3
  115. package/lib/rules/no-setter-return.js +227 -0
  116. package/lib/rules/no-shadow.js +1 -4
  117. package/lib/rules/no-tabs.js +8 -2
  118. package/lib/rules/no-this-before-super.js +12 -13
  119. package/lib/rules/no-trailing-spaces.js +19 -7
  120. package/lib/rules/no-underscore-dangle.js +23 -4
  121. package/lib/rules/no-unmodified-loop-condition.js +16 -29
  122. package/lib/rules/no-unneeded-ternary.js +3 -3
  123. package/lib/rules/no-unreachable.js +7 -7
  124. package/lib/rules/no-unsafe-finally.js +4 -7
  125. package/lib/rules/no-unsafe-negation.js +32 -9
  126. package/lib/rules/no-unused-expressions.js +11 -7
  127. package/lib/rules/no-unused-labels.js +3 -6
  128. package/lib/rules/no-unused-vars.js +22 -29
  129. package/lib/rules/no-use-before-define.js +10 -15
  130. package/lib/rules/no-useless-call.js +4 -4
  131. package/lib/rules/no-useless-computed-key.js +60 -33
  132. package/lib/rules/no-useless-concat.js +4 -4
  133. package/lib/rules/no-useless-constructor.js +14 -22
  134. package/lib/rules/no-useless-escape.js +29 -8
  135. package/lib/rules/no-useless-rename.js +15 -7
  136. package/lib/rules/no-useless-return.js +8 -15
  137. package/lib/rules/no-var.js +12 -25
  138. package/lib/rules/no-warning-comments.js +0 -1
  139. package/lib/rules/no-whitespace-before-property.js +3 -3
  140. package/lib/rules/object-curly-newline.js +7 -10
  141. package/lib/rules/object-curly-spacing.js +21 -22
  142. package/lib/rules/object-shorthand.js +1 -1
  143. package/lib/rules/one-var-declaration-per-line.js +2 -2
  144. package/lib/rules/operator-assignment.js +33 -3
  145. package/lib/rules/padded-blocks.js +1 -1
  146. package/lib/rules/padding-line-between-statements.js +0 -16
  147. package/lib/rules/prefer-arrow-callback.js +6 -6
  148. package/lib/rules/prefer-const.js +27 -28
  149. package/lib/rules/prefer-destructuring.js +1 -7
  150. package/lib/rules/prefer-exponentiation-operator.js +189 -0
  151. package/lib/rules/prefer-named-capture-group.js +0 -1
  152. package/lib/rules/prefer-numeric-literals.js +32 -4
  153. package/lib/rules/prefer-object-spread.js +7 -7
  154. package/lib/rules/prefer-rest-params.js +3 -6
  155. package/lib/rules/prefer-spread.js +4 -4
  156. package/lib/rules/prefer-template.js +5 -6
  157. package/lib/rules/quote-props.js +1 -1
  158. package/lib/rules/quotes.js +5 -6
  159. package/lib/rules/radix.js +5 -10
  160. package/lib/rules/require-await.js +10 -5
  161. package/lib/rules/require-yield.js +2 -2
  162. package/lib/rules/rest-spread-spacing.js +1 -1
  163. package/lib/rules/semi.js +6 -3
  164. package/lib/rules/sort-imports.js +3 -4
  165. package/lib/rules/sort-keys.js +1 -3
  166. package/lib/rules/space-before-blocks.js +1 -2
  167. package/lib/rules/space-in-parens.js +4 -4
  168. package/lib/rules/space-infix-ops.js +6 -6
  169. package/lib/rules/spaced-comment.js +20 -22
  170. package/lib/rules/strict.js +2 -4
  171. package/lib/rules/symbol-description.js +1 -2
  172. package/lib/rules/template-curly-spacing.js +2 -2
  173. package/lib/rules/use-isnan.js +40 -3
  174. package/lib/rules/utils/ast-utils.js +84 -85
  175. package/lib/rules/utils/fix-tracker.js +0 -6
  176. package/lib/rules/utils/lazy-loading-rule-map.js +0 -1
  177. package/lib/rules/vars-on-top.js +11 -11
  178. package/lib/shared/config-ops.js +2 -2
  179. package/lib/shared/runtime-info.js +8 -8
  180. package/lib/shared/traverser.js +2 -0
  181. package/lib/shared/types.js +9 -0
  182. package/lib/source-code/source-code.js +62 -17
  183. package/lib/source-code/token-store/backward-token-comment-cursor.js +5 -5
  184. package/lib/source-code/token-store/backward-token-cursor.js +5 -5
  185. package/lib/source-code/token-store/cursors.js +17 -19
  186. package/lib/source-code/token-store/decorative-cursor.js +1 -1
  187. package/lib/source-code/token-store/filter-cursor.js +2 -2
  188. package/lib/source-code/token-store/forward-token-comment-cursor.js +5 -5
  189. package/lib/source-code/token-store/forward-token-cursor.js +5 -5
  190. package/lib/source-code/token-store/index.js +86 -92
  191. package/lib/source-code/token-store/limit-cursor.js +2 -2
  192. package/lib/source-code/token-store/padded-token-cursor.js +7 -7
  193. package/lib/source-code/token-store/skip-cursor.js +2 -2
  194. package/lib/source-code/token-store/utils.js +9 -13
  195. package/package.json +9 -7
  196. package/lib/cli-engine/ignored-paths.js +0 -362
@@ -28,9 +28,8 @@ const INDEX_MAP = Symbol("indexMap");
28
28
  *
29
29
  * The first/last location of tokens is mapped to the index of the token.
30
30
  * The first/last location of comments is mapped to the index of the next token of each comment.
31
- *
32
- * @param {Token[]} tokens - The array of tokens.
33
- * @param {Comment[]} comments - The array of comments.
31
+ * @param {Token[]} tokens The array of tokens.
32
+ * @param {Comment[]} comments The array of comments.
34
33
  * @returns {Object} The map from locations to indices in `tokens`.
35
34
  * @private
36
35
  */
@@ -62,17 +61,16 @@ function createIndexMap(tokens, comments) {
62
61
 
63
62
  /**
64
63
  * Creates the cursor iterates tokens with options.
65
- *
66
- * @param {CursorFactory} factory - The cursor factory to initialize cursor.
67
- * @param {Token[]} tokens - The array of tokens.
68
- * @param {Comment[]} comments - The array of comments.
69
- * @param {Object} indexMap - The map from locations to indices in `tokens`.
70
- * @param {number} startLoc - The start location of the iteration range.
71
- * @param {number} endLoc - The end location of the iteration range.
72
- * @param {number|Function|Object} [opts=0] - The option object. If this is a number then it's `opts.skip`. If this is a function then it's `opts.filter`.
73
- * @param {boolean} [opts.includeComments=false] - The flag to iterate comments as well.
74
- * @param {Function|null} [opts.filter=null] - The predicate function to choose tokens.
75
- * @param {number} [opts.skip=0] - The count of tokens the cursor skips.
64
+ * @param {CursorFactory} factory The cursor factory to initialize cursor.
65
+ * @param {Token[]} tokens The array of tokens.
66
+ * @param {Comment[]} comments The array of comments.
67
+ * @param {Object} indexMap The map from locations to indices in `tokens`.
68
+ * @param {number} startLoc The start location of the iteration range.
69
+ * @param {number} endLoc The end location of the iteration range.
70
+ * @param {number|Function|Object} [opts=0] The option object. If this is a number then it's `opts.skip`. If this is a function then it's `opts.filter`.
71
+ * @param {boolean} [opts.includeComments=false] The flag to iterate comments as well.
72
+ * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
73
+ * @param {number} [opts.skip=0] The count of tokens the cursor skips.
76
74
  * @returns {Cursor} The created cursor.
77
75
  * @private
78
76
  */
@@ -98,17 +96,16 @@ function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, end
98
96
 
99
97
  /**
100
98
  * Creates the cursor iterates tokens with options.
101
- *
102
- * @param {CursorFactory} factory - The cursor factory to initialize cursor.
103
- * @param {Token[]} tokens - The array of tokens.
104
- * @param {Comment[]} comments - The array of comments.
105
- * @param {Object} indexMap - The map from locations to indices in `tokens`.
106
- * @param {number} startLoc - The start location of the iteration range.
107
- * @param {number} endLoc - The end location of the iteration range.
108
- * @param {number|Function|Object} [opts=0] - The option object. If this is a number then it's `opts.count`. If this is a function then it's `opts.filter`.
109
- * @param {boolean} [opts.includeComments] - The flag to iterate comments as well.
110
- * @param {Function|null} [opts.filter=null] - The predicate function to choose tokens.
111
- * @param {number} [opts.count=0] - The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
99
+ * @param {CursorFactory} factory The cursor factory to initialize cursor.
100
+ * @param {Token[]} tokens The array of tokens.
101
+ * @param {Comment[]} comments The array of comments.
102
+ * @param {Object} indexMap The map from locations to indices in `tokens`.
103
+ * @param {number} startLoc The start location of the iteration range.
104
+ * @param {number} endLoc The end location of the iteration range.
105
+ * @param {number|Function|Object} [opts=0] The option object. If this is a number then it's `opts.count`. If this is a function then it's `opts.filter`.
106
+ * @param {boolean} [opts.includeComments] The flag to iterate comments as well.
107
+ * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
108
+ * @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
112
109
  * @returns {Cursor} The created cursor.
113
110
  * @private
114
111
  */
@@ -138,29 +135,27 @@ function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, en
138
135
  /**
139
136
  * Creates the cursor iterates tokens with options.
140
137
  * This is overload function of the below.
141
- *
142
- * @param {Token[]} tokens - The array of tokens.
143
- * @param {Comment[]} comments - The array of comments.
144
- * @param {Object} indexMap - The map from locations to indices in `tokens`.
145
- * @param {number} startLoc - The start location of the iteration range.
146
- * @param {number} endLoc - The end location of the iteration range.
147
- * @param {Function|Object} opts - The option object. If this is a function then it's `opts.filter`.
148
- * @param {boolean} [opts.includeComments] - The flag to iterate comments as well.
149
- * @param {Function|null} [opts.filter=null] - The predicate function to choose tokens.
150
- * @param {number} [opts.count=0] - The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
138
+ * @param {Token[]} tokens The array of tokens.
139
+ * @param {Comment[]} comments The array of comments.
140
+ * @param {Object} indexMap The map from locations to indices in `tokens`.
141
+ * @param {number} startLoc The start location of the iteration range.
142
+ * @param {number} endLoc The end location of the iteration range.
143
+ * @param {Function|Object} opts The option object. If this is a function then it's `opts.filter`.
144
+ * @param {boolean} [opts.includeComments] The flag to iterate comments as well.
145
+ * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
146
+ * @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
151
147
  * @returns {Cursor} The created cursor.
152
148
  * @private
153
149
  */
154
150
  /**
155
151
  * Creates the cursor iterates tokens with options.
156
- *
157
- * @param {Token[]} tokens - The array of tokens.
158
- * @param {Comment[]} comments - The array of comments.
159
- * @param {Object} indexMap - The map from locations to indices in `tokens`.
160
- * @param {number} startLoc - The start location of the iteration range.
161
- * @param {number} endLoc - The end location of the iteration range.
162
- * @param {number} [beforeCount=0] - The number of tokens before the node to retrieve.
163
- * @param {boolean} [afterCount=0] - The number of tokens after the node to retrieve.
152
+ * @param {Token[]} tokens The array of tokens.
153
+ * @param {Comment[]} comments The array of comments.
154
+ * @param {Object} indexMap The map from locations to indices in `tokens`.
155
+ * @param {number} startLoc The start location of the iteration range.
156
+ * @param {number} endLoc The end location of the iteration range.
157
+ * @param {number} [beforeCount=0] The number of tokens before the node to retrieve.
158
+ * @param {boolean} [afterCount=0] The number of tokens after the node to retrieve.
164
159
  * @returns {Cursor} The created cursor.
165
160
  * @private
166
161
  */
@@ -176,7 +171,7 @@ function createCursorWithPadding(tokens, comments, indexMap, startLoc, endLoc, b
176
171
 
177
172
  /**
178
173
  * Gets comment tokens that are adjacent to the current cursor position.
179
- * @param {Cursor} cursor - A cursor instance.
174
+ * @param {Cursor} cursor A cursor instance.
180
175
  * @returns {Array} An array of comment tokens adjacent to the current cursor position.
181
176
  * @private
182
177
  */
@@ -211,8 +206,8 @@ module.exports = class TokenStore {
211
206
 
212
207
  /**
213
208
  * Initializes this token store.
214
- * @param {Token[]} tokens - The array of tokens.
215
- * @param {Comment[]} comments - The array of comments.
209
+ * @param {Token[]} tokens The array of tokens.
210
+ * @param {Comment[]} comments The array of comments.
216
211
  */
217
212
  constructor(tokens, comments) {
218
213
  this[TOKENS] = tokens;
@@ -226,9 +221,9 @@ module.exports = class TokenStore {
226
221
 
227
222
  /**
228
223
  * Gets the token starting at the specified index.
229
- * @param {number} offset - Index of the start of the token's range.
230
- * @param {Object} [options=0] - The option object.
231
- * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
224
+ * @param {number} offset Index of the start of the token's range.
225
+ * @param {Object} [options=0] The option object.
226
+ * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
232
227
  * @returns {Token|null} The token starting at index, or null if no such token.
233
228
  */
234
229
  getTokenByRangeStart(offset, options) {
@@ -250,11 +245,11 @@ module.exports = class TokenStore {
250
245
 
251
246
  /**
252
247
  * Gets the first token of the given node.
253
- * @param {ASTNode} node - The AST node.
254
- * @param {number|Function|Object} [options=0] - The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
255
- * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
256
- * @param {Function|null} [options.filter=null] - The predicate function to choose tokens.
257
- * @param {number} [options.skip=0] - The count of tokens the cursor skips.
248
+ * @param {ASTNode} node The AST node.
249
+ * @param {number|Function|Object} [options=0] The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
250
+ * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
251
+ * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
252
+ * @param {number} [options.skip=0] The count of tokens the cursor skips.
258
253
  * @returns {Token|null} An object representing the token.
259
254
  */
260
255
  getFirstToken(node, options) {
@@ -271,8 +266,8 @@ module.exports = class TokenStore {
271
266
 
272
267
  /**
273
268
  * Gets the last token of the given node.
274
- * @param {ASTNode} node - The AST node.
275
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
269
+ * @param {ASTNode} node The AST node.
270
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
276
271
  * @returns {Token|null} An object representing the token.
277
272
  */
278
273
  getLastToken(node, options) {
@@ -289,8 +284,8 @@ module.exports = class TokenStore {
289
284
 
290
285
  /**
291
286
  * Gets the token that precedes a given node or token.
292
- * @param {ASTNode|Token|Comment} node - The AST node or token.
293
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
287
+ * @param {ASTNode|Token|Comment} node The AST node or token.
288
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
294
289
  * @returns {Token|null} An object representing the token.
295
290
  */
296
291
  getTokenBefore(node, options) {
@@ -307,8 +302,8 @@ module.exports = class TokenStore {
307
302
 
308
303
  /**
309
304
  * Gets the token that follows a given node or token.
310
- * @param {ASTNode|Token|Comment} node - The AST node or token.
311
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
305
+ * @param {ASTNode|Token|Comment} node The AST node or token.
306
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
312
307
  * @returns {Token|null} An object representing the token.
313
308
  */
314
309
  getTokenAfter(node, options) {
@@ -325,9 +320,9 @@ module.exports = class TokenStore {
325
320
 
326
321
  /**
327
322
  * Gets the first token between two non-overlapping nodes.
328
- * @param {ASTNode|Token|Comment} left - Node before the desired token range.
329
- * @param {ASTNode|Token|Comment} right - Node after the desired token range.
330
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
323
+ * @param {ASTNode|Token|Comment} left Node before the desired token range.
324
+ * @param {ASTNode|Token|Comment} right Node after the desired token range.
325
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
331
326
  * @returns {Token|null} An object representing the token.
332
327
  */
333
328
  getFirstTokenBetween(left, right, options) {
@@ -346,7 +341,7 @@ module.exports = class TokenStore {
346
341
  * Gets the last token between two non-overlapping nodes.
347
342
  * @param {ASTNode|Token|Comment} left Node before the desired token range.
348
343
  * @param {ASTNode|Token|Comment} right Node after the desired token range.
349
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstToken()
344
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
350
345
  * @returns {Token|null} An object representing the token.
351
346
  */
352
347
  getLastTokenBetween(left, right, options) {
@@ -393,11 +388,11 @@ module.exports = class TokenStore {
393
388
 
394
389
  /**
395
390
  * Gets the first `count` tokens of the given node.
396
- * @param {ASTNode} node - The AST node.
397
- * @param {number|Function|Object} [options=0] - The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
398
- * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
399
- * @param {Function|null} [options.filter=null] - The predicate function to choose tokens.
400
- * @param {number} [options.count=0] - The maximum count of tokens the cursor iterates.
391
+ * @param {ASTNode} node The AST node.
392
+ * @param {number|Function|Object} [options=0] The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
393
+ * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
394
+ * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
395
+ * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
401
396
  * @returns {Token[]} Tokens.
402
397
  */
403
398
  getFirstTokens(node, options) {
@@ -414,8 +409,8 @@ module.exports = class TokenStore {
414
409
 
415
410
  /**
416
411
  * Gets the last `count` tokens of the given node.
417
- * @param {ASTNode} node - The AST node.
418
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
412
+ * @param {ASTNode} node The AST node.
413
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
419
414
  * @returns {Token[]} Tokens.
420
415
  */
421
416
  getLastTokens(node, options) {
@@ -432,8 +427,8 @@ module.exports = class TokenStore {
432
427
 
433
428
  /**
434
429
  * Gets the `count` tokens that precedes a given node or token.
435
- * @param {ASTNode|Token|Comment} node - The AST node or token.
436
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
430
+ * @param {ASTNode|Token|Comment} node The AST node or token.
431
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
437
432
  * @returns {Token[]} Tokens.
438
433
  */
439
434
  getTokensBefore(node, options) {
@@ -450,8 +445,8 @@ module.exports = class TokenStore {
450
445
 
451
446
  /**
452
447
  * Gets the `count` tokens that follows a given node or token.
453
- * @param {ASTNode|Token|Comment} node - The AST node or token.
454
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
448
+ * @param {ASTNode|Token|Comment} node The AST node or token.
449
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
455
450
  * @returns {Token[]} Tokens.
456
451
  */
457
452
  getTokensAfter(node, options) {
@@ -468,9 +463,9 @@ module.exports = class TokenStore {
468
463
 
469
464
  /**
470
465
  * Gets the first `count` tokens between two non-overlapping nodes.
471
- * @param {ASTNode|Token|Comment} left - Node before the desired token range.
472
- * @param {ASTNode|Token|Comment} right - Node after the desired token range.
473
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
466
+ * @param {ASTNode|Token|Comment} left Node before the desired token range.
467
+ * @param {ASTNode|Token|Comment} right Node after the desired token range.
468
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
474
469
  * @returns {Token[]} Tokens between left and right.
475
470
  */
476
471
  getFirstTokensBetween(left, right, options) {
@@ -489,7 +484,7 @@ module.exports = class TokenStore {
489
484
  * Gets the last `count` tokens between two non-overlapping nodes.
490
485
  * @param {ASTNode|Token|Comment} left Node before the desired token range.
491
486
  * @param {ASTNode|Token|Comment} right Node after the desired token range.
492
- * @param {number|Function|Object} [options=0] - The option object. Same options as getFirstTokens()
487
+ * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
493
488
  * @returns {Token[]} Tokens between left and right.
494
489
  */
495
490
  getLastTokensBetween(left, right, options) {
@@ -506,18 +501,18 @@ module.exports = class TokenStore {
506
501
 
507
502
  /**
508
503
  * Gets all tokens that are related to the given node.
509
- * @param {ASTNode} node - The AST node.
504
+ * @param {ASTNode} node The AST node.
510
505
  * @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
511
- * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
512
- * @param {Function|null} [options.filter=null] - The predicate function to choose tokens.
513
- * @param {number} [options.count=0] - The maximum count of tokens the cursor iterates.
506
+ * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
507
+ * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
508
+ * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
514
509
  * @returns {Token[]} Array of objects representing tokens.
515
510
  */
516
511
  /**
517
512
  * Gets all tokens that are related to the given node.
518
- * @param {ASTNode} node - The AST node.
519
- * @param {int} [beforeCount=0] - The number of tokens before the node to retrieve.
520
- * @param {int} [afterCount=0] - The number of tokens after the node to retrieve.
513
+ * @param {ASTNode} node The AST node.
514
+ * @param {int} [beforeCount=0] The number of tokens before the node to retrieve.
515
+ * @param {int} [afterCount=0] The number of tokens after the node to retrieve.
521
516
  * @returns {Token[]} Array of objects representing tokens.
522
517
  */
523
518
  getTokens(node, beforeCount, afterCount) {
@@ -537,9 +532,9 @@ module.exports = class TokenStore {
537
532
  * @param {ASTNode|Token|Comment} left Node before the desired token range.
538
533
  * @param {ASTNode|Token|Comment} right Node after the desired token range.
539
534
  * @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
540
- * @param {boolean} [options.includeComments=false] - The flag to iterate comments as well.
541
- * @param {Function|null} [options.filter=null] - The predicate function to choose tokens.
542
- * @param {number} [options.count=0] - The maximum count of tokens the cursor iterates.
535
+ * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
536
+ * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
537
+ * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
543
538
  * @returns {Token[]} Tokens between left and right.
544
539
  */
545
540
  /**
@@ -567,9 +562,8 @@ module.exports = class TokenStore {
567
562
 
568
563
  /**
569
564
  * Checks whether any comments exist or not between the given 2 nodes.
570
- *
571
- * @param {ASTNode} left - The node to check.
572
- * @param {ASTNode} right - The node to check.
565
+ * @param {ASTNode} left The node to check.
566
+ * @param {ASTNode} right The node to check.
573
567
  * @returns {boolean} `true` if one or more comments exist.
574
568
  */
575
569
  commentsExistBetween(left, right) {
@@ -21,8 +21,8 @@ module.exports = class LimitCursor extends DecorativeCursor {
21
21
 
22
22
  /**
23
23
  * Initializes this cursor.
24
- * @param {Cursor} cursor - The cursor to be decorated.
25
- * @param {number} count - The count of tokens this cursor iterates.
24
+ * @param {Cursor} cursor The cursor to be decorated.
25
+ * @param {number} count The count of tokens this cursor iterates.
26
26
  */
27
27
  constructor(cursor, count) {
28
28
  super(cursor);
@@ -22,13 +22,13 @@ module.exports = class PaddedTokenCursor extends ForwardTokenCursor {
22
22
 
23
23
  /**
24
24
  * Initializes this cursor.
25
- * @param {Token[]} tokens - The array of tokens.
26
- * @param {Comment[]} comments - The array of comments.
27
- * @param {Object} indexMap - The map from locations to indices in `tokens`.
28
- * @param {number} startLoc - The start location of the iteration range.
29
- * @param {number} endLoc - The end location of the iteration range.
30
- * @param {number} beforeCount - The number of tokens this cursor iterates before start.
31
- * @param {number} afterCount - The number of tokens this cursor iterates after end.
25
+ * @param {Token[]} tokens The array of tokens.
26
+ * @param {Comment[]} comments The array of comments.
27
+ * @param {Object} indexMap The map from locations to indices in `tokens`.
28
+ * @param {number} startLoc The start location of the iteration range.
29
+ * @param {number} endLoc The end location of the iteration range.
30
+ * @param {number} beforeCount The number of tokens this cursor iterates before start.
31
+ * @param {number} afterCount The number of tokens this cursor iterates after end.
32
32
  */
33
33
  constructor(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
34
34
  super(tokens, comments, indexMap, startLoc, endLoc);
@@ -21,8 +21,8 @@ module.exports = class SkipCursor extends DecorativeCursor {
21
21
 
22
22
  /**
23
23
  * Initializes this cursor.
24
- * @param {Cursor} cursor - The cursor to be decorated.
25
- * @param {number} count - The count of tokens this cursor skips.
24
+ * @param {Cursor} cursor The cursor to be decorated.
25
+ * @param {number} count The count of tokens this cursor skips.
26
26
  */
27
27
  constructor(cursor, count) {
28
28
  super(cursor);
@@ -16,8 +16,7 @@ const lodash = require("lodash");
16
16
 
17
17
  /**
18
18
  * Gets `token.range[0]` from the given token.
19
- *
20
- * @param {Node|Token|Comment} token - The token to get.
19
+ * @param {Node|Token|Comment} token The token to get.
21
20
  * @returns {number} The start location.
22
21
  * @private
23
22
  */
@@ -32,9 +31,8 @@ function getStartLocation(token) {
32
31
  /**
33
32
  * Binary-searches the index of the first token which is after the given location.
34
33
  * If it was not found, this returns `tokens.length`.
35
- *
36
- * @param {(Token|Comment)[]} tokens - It searches the token in this list.
37
- * @param {number} location - The location to search.
34
+ * @param {(Token|Comment)[]} tokens It searches the token in this list.
35
+ * @param {number} location The location to search.
38
36
  * @returns {number} The found index or `tokens.length`.
39
37
  */
40
38
  exports.search = function search(tokens, location) {
@@ -48,10 +46,9 @@ exports.search = function search(tokens, location) {
48
46
  /**
49
47
  * Gets the index of the `startLoc` in `tokens`.
50
48
  * `startLoc` can be the value of `node.range[1]`, so this checks about `startLoc - 1` as well.
51
- *
52
- * @param {(Token|Comment)[]} tokens - The tokens to find an index.
53
- * @param {Object} indexMap - The map from locations to indices.
54
- * @param {number} startLoc - The location to get an index.
49
+ * @param {(Token|Comment)[]} tokens The tokens to find an index.
50
+ * @param {Object} indexMap The map from locations to indices.
51
+ * @param {number} startLoc The location to get an index.
55
52
  * @returns {number} The index.
56
53
  */
57
54
  exports.getFirstIndex = function getFirstIndex(tokens, indexMap, startLoc) {
@@ -77,10 +74,9 @@ exports.getFirstIndex = function getFirstIndex(tokens, indexMap, startLoc) {
77
74
  /**
78
75
  * Gets the index of the `endLoc` in `tokens`.
79
76
  * The information of end locations are recorded at `endLoc - 1` in `indexMap`, so this checks about `endLoc - 1` as well.
80
- *
81
- * @param {(Token|Comment)[]} tokens - The tokens to find an index.
82
- * @param {Object} indexMap - The map from locations to indices.
83
- * @param {number} endLoc - The location to get an index.
77
+ * @param {(Token|Comment)[]} tokens The tokens to find an index.
78
+ * @param {Object} indexMap The map from locations to indices.
79
+ * @param {number} endLoc The location to get an index.
84
80
  * @returns {number} The index.
85
81
  */
86
82
  exports.getLastIndex = function getLastIndex(tokens, indexMap, endLoc) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "6.5.0",
3
+ "version": "6.7.1",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  "main": "./lib/api.js",
10
10
  "scripts": {
11
11
  "test": "node Makefile.js test",
12
+ "test:cli": "mocha",
12
13
  "lint": "node Makefile.js lint",
13
14
  "fix": "node Makefile.js lint -- fix",
14
15
  "fuzz": "node Makefile.js fuzz",
@@ -41,6 +42,7 @@
41
42
  "messages"
42
43
  ],
43
44
  "repository": "eslint/eslint",
45
+ "funding": "https://opencollective.com/eslint",
44
46
  "homepage": "https://eslint.org",
45
47
  "bugs": "https://github.com/eslint/eslint/issues/",
46
48
  "dependencies": {
@@ -51,19 +53,19 @@
51
53
  "debug": "^4.0.1",
52
54
  "doctrine": "^3.0.0",
53
55
  "eslint-scope": "^5.0.0",
54
- "eslint-utils": "^1.4.2",
56
+ "eslint-utils": "^1.4.3",
55
57
  "eslint-visitor-keys": "^1.1.0",
56
- "espree": "^6.1.1",
58
+ "espree": "^6.1.2",
57
59
  "esquery": "^1.0.1",
58
60
  "esutils": "^2.0.2",
59
61
  "file-entry-cache": "^5.0.1",
60
62
  "functional-red-black-tree": "^1.0.1",
61
63
  "glob-parent": "^5.0.0",
62
- "globals": "^11.7.0",
64
+ "globals": "^12.1.0",
63
65
  "ignore": "^4.0.6",
64
66
  "import-fresh": "^3.0.0",
65
67
  "imurmurhash": "^0.1.4",
66
- "inquirer": "^6.4.1",
68
+ "inquirer": "^7.0.0",
67
69
  "is-glob": "^4.0.0",
68
70
  "js-yaml": "^3.13.1",
69
71
  "json-stable-stringify-without-jsonify": "^1.0.1",
@@ -72,7 +74,7 @@
72
74
  "minimatch": "^3.0.4",
73
75
  "mkdirp": "^0.5.1",
74
76
  "natural-compare": "^1.4.0",
75
- "optionator": "^0.8.2",
77
+ "optionator": "^0.8.3",
76
78
  "progress": "^2.0.0",
77
79
  "regexpp": "^2.0.1",
78
80
  "semver": "^6.1.2",
@@ -85,7 +87,7 @@
85
87
  "devDependencies": {
86
88
  "@babel/core": "^7.4.3",
87
89
  "@babel/preset-env": "^7.4.3",
88
- "acorn": "^7.0.0",
90
+ "acorn": "^7.1.0",
89
91
  "babel-loader": "^8.0.5",
90
92
  "chai": "^4.0.1",
91
93
  "cheerio": "^0.22.0",