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
package/lib/cli.js CHANGED
@@ -20,7 +20,8 @@ const fs = require("fs"),
20
20
  mkdirp = require("mkdirp"),
21
21
  { CLIEngine } = require("./cli-engine"),
22
22
  options = require("./options"),
23
- log = require("./shared/logging");
23
+ log = require("./shared/logging"),
24
+ RuntimeInfo = require("./shared/runtime-info");
24
25
 
25
26
  const debug = require("debug")("eslint:cli");
26
27
 
@@ -159,13 +160,18 @@ const cli = {
159
160
  }
160
161
 
161
162
  const files = currentOptions._;
162
-
163
163
  const useStdin = typeof text === "string";
164
164
 
165
- if (currentOptions.version) { // version from package.json
166
-
167
- log.info(`v${require("../package.json").version}`);
168
-
165
+ if (currentOptions.version) {
166
+ log.info(RuntimeInfo.version());
167
+ } else if (currentOptions.envInfo) {
168
+ try {
169
+ log.info(RuntimeInfo.environment());
170
+ return 0;
171
+ } catch (err) {
172
+ log.error(err.message);
173
+ return 2;
174
+ }
169
175
  } else if (currentOptions.printConfig) {
170
176
  if (files.length) {
171
177
  log.error("The --print-config option must be used with exactly one file name.");
@@ -177,17 +183,13 @@ const cli = {
177
183
  }
178
184
 
179
185
  const engine = new CLIEngine(translateOptions(currentOptions));
180
-
181
186
  const fileConfig = engine.getConfigForFile(currentOptions.printConfig);
182
187
 
183
188
  log.info(JSON.stringify(fileConfig, null, " "));
184
189
  return 0;
185
190
  } else if (currentOptions.help || (!files.length && !useStdin)) {
186
-
187
191
  log.info(options.generateHelp());
188
-
189
192
  } else {
190
-
191
193
  debug(`Running on ${useStdin ? "text" : "files"}`);
192
194
 
193
195
  if (currentOptions.fix && currentOptions.fixDryRun) {
@@ -227,9 +229,8 @@ const cli = {
227
229
 
228
230
  return (report.errorCount || tooManyWarnings) ? 1 : 0;
229
231
  }
230
- return 2;
231
-
232
232
 
233
+ return 2;
233
234
  }
234
235
 
235
236
  return 0;
@@ -31,7 +31,6 @@ const MAX_CONFIG_COMBINATIONS = 17, // 16 combinations + 1 for severity only
31
31
 
32
32
  /**
33
33
  * Information about a rule configuration, in the context of a Registry.
34
- *
35
34
  * @typedef {Object} registryItem
36
35
  * @param {ruleConfig} config A valid configuration for the rule
37
36
  * @param {number} specificity The number of elements in the ruleConfig array
@@ -70,6 +69,7 @@ function makeRegistryItems(rulesConfig) {
70
69
  */
71
70
  class Registry {
72
71
 
72
+ // eslint-disable-next-line jsdoc/require-description
73
73
  /**
74
74
  * @param {rulesConfig} [rulesConfig] Hash of rule names and arrays of possible configurations
75
75
  */
@@ -82,7 +82,6 @@ class Registry {
82
82
  *
83
83
  * It will set the registry's `rule` property to an object having rule names
84
84
  * as keys and an array of registryItems as values.
85
- *
86
85
  * @returns {void}
87
86
  */
88
87
  populateFromCoreRules() {
@@ -101,7 +100,6 @@ class Registry {
101
100
  * configurations.
102
101
  *
103
102
  * The length of the returned array will be <= MAX_CONFIG_COMBINATIONS.
104
- *
105
103
  * @returns {Object[]} "rules" configurations to use for linting
106
104
  */
107
105
  buildRuleSets() {
@@ -114,7 +112,6 @@ class Registry {
114
112
  *
115
113
  * This is broken out into its own function so that it doesn't need to be
116
114
  * created inside of the while loop.
117
- *
118
115
  * @param {string} rule The ruleId to add.
119
116
  * @returns {void}
120
117
  */
@@ -162,7 +159,6 @@ class Registry {
162
159
  *
163
160
  * Note: this also removes rule configurations which were not linted
164
161
  * (meaning, they have an undefined errorCount).
165
- *
166
162
  * @returns {void}
167
163
  */
168
164
  stripFailingConfigs() {
@@ -185,7 +181,6 @@ class Registry {
185
181
 
186
182
  /**
187
183
  * Removes rule configurations which were not included in a ruleSet
188
- *
189
184
  * @returns {void}
190
185
  */
191
186
  stripExtraConfigs() {
@@ -204,7 +199,6 @@ class Registry {
204
199
  * Creates a registry of rules which had no error-free configs.
205
200
  * The new registry is intended to be analyzed to determine whether its rules
206
201
  * should be disabled or set to warning.
207
- *
208
202
  * @returns {Registry} A registry of failing rules.
209
203
  */
210
204
  getFailingRulesRegistry() {
@@ -225,7 +219,6 @@ class Registry {
225
219
  /**
226
220
  * Create an eslint config for any rules which only have one configuration
227
221
  * in the registry.
228
- *
229
222
  * @returns {Object} An eslint config with rules section populated
230
223
  */
231
224
  createConfig() {
@@ -243,7 +236,6 @@ class Registry {
243
236
 
244
237
  /**
245
238
  * Return a cloned registry containing only configs with a desired specificity
246
- *
247
239
  * @param {number} specificity Only keep configs with this specificity
248
240
  * @returns {Registry} A registry of rules
249
241
  */
@@ -261,7 +253,6 @@ class Registry {
261
253
 
262
254
  /**
263
255
  * Lint SourceCodes against all configurations in the registry, and record results
264
- *
265
256
  * @param {Object[]} sourceCodes SourceCode objects for each filename
266
257
  * @param {Object} config ESLint config object
267
258
  * @param {progressCallback} [cb] Optional callback for reporting execution status
@@ -327,7 +318,6 @@ class Registry {
327
318
  *
328
319
  * This will return a new config with `"extends": "eslint:recommended"` and
329
320
  * only the rules which have configurations different from the recommended config.
330
- *
331
321
  * @param {Object} config config object
332
322
  * @returns {Object} config object using `"extends": "eslint:recommended"`
333
323
  */
@@ -23,7 +23,6 @@ const debug = require("debug")("eslint:config-file");
23
23
  * Determines sort order for object keys for json-stable-stringify
24
24
  *
25
25
  * see: https://github.com/samn/json-stable-stringify#cmp
26
- *
27
26
  * @param {Object} a The first comparison object ({key: akey, value: avalue})
28
27
  * @param {Object} b The second comparison object ({key: bkey, value: bvalue})
29
28
  * @returns {number} 1 or -1, used in stringify cmp method
@@ -147,7 +147,6 @@ function getModulesList(config, installESLint) {
147
147
  *
148
148
  * Note: This clones the config object and returns a new config to avoid mutating
149
149
  * the original config parameter.
150
- *
151
150
  * @param {Object} answers answers received from inquirer
152
151
  * @param {Object} config config object
153
152
  * @returns {Object} config object with configured rules
@@ -33,7 +33,6 @@ function explodeArray(xs) {
33
33
  *
34
34
  * For example:
35
35
  * combineArrays([a, [b, c]], [x, y]); // -> [[a, x], [a, y], [b, c, x], [b, c, y]]
36
- *
37
36
  * @param {Array} arr1 The first array to combine.
38
37
  * @param {Array} arr2 The second array to combine.
39
38
  * @returns {Array} A mixture of the elements of the first and second arrays.
@@ -71,7 +70,6 @@ function combineArrays(arr1, arr2) {
71
70
  * [{before: true}, {before: false}],
72
71
  * [{after: true}, {after: false}]
73
72
  * ]
74
- *
75
73
  * @param {Object[]} objects Array of objects, each with one property/value pair
76
74
  * @returns {Array[]} Array of arrays of objects grouped by property
77
75
  */
@@ -98,8 +96,7 @@ function groupByProperty(objects) {
98
96
  * element in the array is the severity, and is the only required element.
99
97
  * Configs may also have one or more additional elements to specify rule
100
98
  * configuration or options.
101
- *
102
- * @typedef {array|number} ruleConfig
99
+ * @typedef {Array|number} ruleConfig
103
100
  * @param {number} 0 The rule's severity (0, 1, 2).
104
101
  */
105
102
 
@@ -134,7 +131,6 @@ function groupByProperty(objects) {
134
131
  * {before: false, after: true},
135
132
  * {before: false, after: false}
136
133
  * ]
137
- *
138
134
  * @param {Object[]} objArr1 Single key/value objects, all with the same key
139
135
  * @param {Object[]} objArr2 Single key/value objects, all with another key
140
136
  * @returns {Object[]} Combined objects for each combination of input properties and values
@@ -178,6 +174,7 @@ function combinePropertyObjects(objArr1, objArr2) {
178
174
  */
179
175
  class RuleConfigSet {
180
176
 
177
+ // eslint-disable-next-line jsdoc/require-description
181
178
  /**
182
179
  * @param {ruleConfig[]} configs Valid rule configurations
183
180
  */
@@ -185,7 +182,7 @@ class RuleConfigSet {
185
182
 
186
183
  /**
187
184
  * Stored valid rule configurations for this instance
188
- * @type {array}
185
+ * @type {Array}
189
186
  */
190
187
  this.ruleConfigs = configs || [];
191
188
  }
@@ -193,7 +190,6 @@ class RuleConfigSet {
193
190
  /**
194
191
  * Add a severity level to the front of all configs in the instance.
195
192
  * This should only be called after all configs have been added to the instance.
196
- *
197
193
  * @returns {void}
198
194
  */
199
195
  addErrorSeverity() {
@@ -21,7 +21,6 @@ const fs = require("fs"),
21
21
  /**
22
22
  * Find the closest package.json file, starting at process.cwd (by default),
23
23
  * and working up to root.
24
- *
25
24
  * @param {string} [startDir=process.cwd()] Starting directory
26
25
  * @returns {string} Absolute path to closest package.json file
27
26
  */
@@ -88,7 +87,6 @@ function fetchPeerDependencies(packageName) {
88
87
 
89
88
  /**
90
89
  * Check whether node modules are include in a project's package.json.
91
- *
92
90
  * @param {string[]} packages Array of node module names
93
91
  * @param {Object} opt Options Object
94
92
  * @param {boolean} opt.dependencies Set to true to check for direct dependencies
@@ -136,7 +134,6 @@ function check(packages, opt) {
136
134
  * package.json.
137
135
  *
138
136
  * Convenience wrapper around check().
139
- *
140
137
  * @param {string[]} packages Array of node modules to check.
141
138
  * @param {string} rootDir The directory contianing a package.json
142
139
  * @returns {Object} An object whose keys are the module names
@@ -151,7 +148,6 @@ function checkDeps(packages, rootDir) {
151
148
  * package.json.
152
149
  *
153
150
  * Convenience wrapper around check().
154
- *
155
151
  * @param {string[]} packages Array of node modules to check.
156
152
  * @returns {Object} An object whose keys are the module names
157
153
  * and values are booleans indicating installation.
@@ -162,8 +158,7 @@ function checkDevDeps(packages) {
162
158
 
163
159
  /**
164
160
  * Check whether package.json is found in current path.
165
- *
166
- * @param {string=} startDir Starting directory
161
+ * @param {string} [startDir] Starting directory
167
162
  * @returns {boolean} Whether a package.json is found in current path.
168
163
  */
169
164
  function checkPackageJson(startDir) {
@@ -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) {