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
@@ -0,0 +1,163 @@
1
+ /**
2
+ * @fileoverview Utility to get information about the execution environment.
3
+ * @author Kai Cataldo
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const path = require("path");
13
+ const spawn = require("cross-spawn");
14
+ const { isEmpty } = require("lodash");
15
+ const log = require("../shared/logging");
16
+ const packageJson = require("../../package.json");
17
+
18
+ //------------------------------------------------------------------------------
19
+ // Helpers
20
+ //------------------------------------------------------------------------------
21
+
22
+ /**
23
+ * Generates and returns execution environment information.
24
+ * @returns {string} A string that contains execution environment information.
25
+ */
26
+ function environment() {
27
+ const cache = new Map();
28
+
29
+ /**
30
+ * Checks if a path is a child of a directory.
31
+ * @param {string} parentPath The parent path to check.
32
+ * @param {string} childPath The path to check.
33
+ * @returns {boolean} Whether or not the given path is a child of a directory.
34
+ */
35
+ function isChildOfDirectory(parentPath, childPath) {
36
+ return !path.relative(parentPath, childPath).startsWith("..");
37
+ }
38
+
39
+ /**
40
+ * Synchronously executes a shell command and formats the result.
41
+ * @param {string} cmd The command to execute.
42
+ * @param {Array} args The arguments to be executed with the command.
43
+ * @returns {string} The version returned by the command.
44
+ */
45
+ function execCommand(cmd, args) {
46
+ const key = [cmd, ...args].join(" ");
47
+
48
+ if (cache.has(key)) {
49
+ return cache.get(key);
50
+ }
51
+
52
+ const process = spawn.sync(cmd, args, { encoding: "utf8" });
53
+
54
+ if (process.error) {
55
+ throw process.error;
56
+ }
57
+
58
+ const result = process.stdout.trim();
59
+
60
+ cache.set(key, result);
61
+ return result;
62
+ }
63
+
64
+ /**
65
+ * Normalizes a version number.
66
+ * @param {string} versionStr The string to normalize.
67
+ * @returns {string} The normalized version number.
68
+ */
69
+ function normalizeVersionStr(versionStr) {
70
+ return versionStr.startsWith("v") ? versionStr : `v${versionStr}`;
71
+ }
72
+
73
+ /**
74
+ * Gets bin version.
75
+ * @param {string} bin The bin to check.
76
+ * @returns {string} The normalized version returned by the command.
77
+ */
78
+ function getBinVersion(bin) {
79
+ const binArgs = ["--version"];
80
+
81
+ try {
82
+ return normalizeVersionStr(execCommand(bin, binArgs));
83
+ } catch (e) {
84
+ log.error(`Error finding ${bin} version running the command \`${bin} ${binArgs.join(" ")}\``);
85
+ throw e;
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Gets installed npm package version.
91
+ * @param {string} pkg The package to check.
92
+ * @param {boolean} global Whether to check globally or not.
93
+ * @returns {string} The normalized version returned by the command.
94
+ */
95
+ function getNpmPackageVersion(pkg, { global = false } = {}) {
96
+ const npmBinArgs = ["bin", "-g"];
97
+ const npmLsArgs = ["ls", "--depth=0", "--json", "eslint"];
98
+
99
+ if (global) {
100
+ npmLsArgs.push("-g");
101
+ }
102
+
103
+ try {
104
+ const parsedStdout = JSON.parse(execCommand("npm", npmLsArgs));
105
+
106
+ /*
107
+ * Checking globally returns an empty JSON object, while local checks
108
+ * include the name and version of the local project.
109
+ */
110
+ if (isEmpty(parsedStdout) || !(parsedStdout.dependencies && parsedStdout.dependencies.eslint)) {
111
+ return "Not found";
112
+ }
113
+
114
+ const [, processBinPath] = process.argv;
115
+ let npmBinPath;
116
+
117
+ try {
118
+ npmBinPath = execCommand("npm", npmBinArgs);
119
+ } catch (e) {
120
+ log.error(`Error finding npm binary path when running command \`npm ${npmBinArgs.join(" ")}\``);
121
+ throw e;
122
+ }
123
+
124
+ const isGlobal = isChildOfDirectory(npmBinPath, processBinPath);
125
+ let pkgVersion = parsedStdout.dependencies.eslint.version;
126
+
127
+ if ((global && isGlobal) || (!global && !isGlobal)) {
128
+ pkgVersion += " (Currently used)";
129
+ }
130
+
131
+ return normalizeVersionStr(pkgVersion);
132
+ } catch (e) {
133
+ log.error(`Error finding ${pkg} version running the command \`npm ${npmLsArgs.join(" ")}\``);
134
+ throw e;
135
+ }
136
+ }
137
+
138
+ return [
139
+ "Environment Info:",
140
+ "",
141
+ `Node version: ${getBinVersion("node")}`,
142
+ `npm version: ${getBinVersion("npm")}`,
143
+ `Local ESLint version: ${getNpmPackageVersion("eslint", { global: false })}`,
144
+ `Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}`
145
+ ].join("\n");
146
+ }
147
+
148
+ /**
149
+ * Returns version of currently executing ESLint.
150
+ * @returns {string} The version from the currently executing ESLint's package.json.
151
+ */
152
+ function version() {
153
+ return `v${packageJson.version}`;
154
+ }
155
+
156
+ //------------------------------------------------------------------------------
157
+ // Public Interface
158
+ //------------------------------------------------------------------------------
159
+
160
+ module.exports = {
161
+ environment,
162
+ version
163
+ };
@@ -65,6 +65,7 @@ class Traverser {
65
65
  this._leave = null;
66
66
  }
67
67
 
68
+ // eslint-disable-next-line jsdoc/require-description
68
69
  /**
69
70
  * @returns {ASTNode} The current node.
70
71
  */
@@ -72,6 +73,7 @@ class Traverser {
72
73
  return this._current;
73
74
  }
74
75
 
76
+ // eslint-disable-next-line jsdoc/require-description
75
77
  /**
76
78
  * @returns {ASTNode[]} The ancestor nodes.
77
79
  */
@@ -86,14 +86,13 @@ class SourceCode extends TokenStore {
86
86
 
87
87
  /**
88
88
  * Represents parsed source code.
89
- * @param {string|Object} textOrConfig - The source code text or config object.
90
- * @param {string} textOrConfig.text - The source code text.
91
- * @param {ASTNode} textOrConfig.ast - The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
92
- * @param {Object|null} textOrConfig.parserServices - The parser services.
93
- * @param {ScopeManager|null} textOrConfig.scopeManager - The scope of this source code.
94
- * @param {Object|null} textOrConfig.visitorKeys - The visitor keys to traverse AST.
95
- * @param {ASTNode} [astIfNoConfig] - The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
96
- * @constructor
89
+ * @param {string|Object} textOrConfig The source code text or config object.
90
+ * @param {string} textOrConfig.text The source code text.
91
+ * @param {ASTNode} textOrConfig.ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
92
+ * @param {Object|null} textOrConfig.parserServices The parser services.
93
+ * @param {ScopeManager|null} textOrConfig.scopeManager The scope of this source code.
94
+ * @param {Object|null} textOrConfig.visitorKeys The visitor keys to traverse AST.
95
+ * @param {ASTNode} [astIfNoConfig] The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
97
96
  */
98
97
  constructor(textOrConfig, astIfNoConfig) {
99
98
  let text, ast, parserServices, scopeManager, visitorKeys;
@@ -206,9 +205,9 @@ class SourceCode extends TokenStore {
206
205
 
207
206
  /**
208
207
  * Gets the source code for the given node.
209
- * @param {ASTNode=} node The AST node to get the text for.
210
- * @param {int=} beforeCount The number of characters before the node to retrieve.
211
- * @param {int=} afterCount The number of characters after the node to retrieve.
208
+ * @param {ASTNode} [node] The AST node to get the text for.
209
+ * @param {int} [beforeCount] The number of characters before the node to retrieve.
210
+ * @param {int} [afterCount] The number of characters after the node to retrieve.
212
211
  * @returns {string} The text representing the AST node.
213
212
  * @public
214
213
  */
@@ -424,7 +423,7 @@ class SourceCode extends TokenStore {
424
423
  isSpaceBetweenTokens(first, second) {
425
424
  const text = this.text.slice(first.range[1], second.range[0]);
426
425
 
427
- return /\s/u.test(text.replace(/\/\*.*?\*\//gu, ""));
426
+ return /\s/u.test(text.replace(/\/\*.*?\*\//gus, ""));
428
427
  }
429
428
 
430
429
  /**
@@ -22,11 +22,11 @@ module.exports = class BackwardTokenCommentCursor extends Cursor {
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.
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
30
  */
31
31
  constructor(tokens, comments, indexMap, startLoc, endLoc) {
32
32
  super();
@@ -22,11 +22,11 @@ module.exports = class BackwardTokenCursor extends Cursor {
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.
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
30
  */
31
31
  constructor(tokens, comments, indexMap, startLoc, endLoc) {
32
32
  super();
@@ -28,8 +28,8 @@ class CursorFactory {
28
28
 
29
29
  /**
30
30
  * Initializes this cursor.
31
- * @param {Function} TokenCursor - The class of the cursor which iterates tokens only.
32
- * @param {Function} TokenCommentCursor - The class of the cursor which iterates the mix of tokens and comments.
31
+ * @param {Function} TokenCursor The class of the cursor which iterates tokens only.
32
+ * @param {Function} TokenCommentCursor The class of the cursor which iterates the mix of tokens and comments.
33
33
  */
34
34
  constructor(TokenCursor, TokenCommentCursor) {
35
35
  this.TokenCursor = TokenCursor;
@@ -38,13 +38,12 @@ class CursorFactory {
38
38
 
39
39
  /**
40
40
  * Creates a base cursor instance that can be decorated by createCursor.
41
- *
42
- * @param {Token[]} tokens - The array of tokens.
43
- * @param {Comment[]} comments - The array of comments.
44
- * @param {Object} indexMap - The map from locations to indices in `tokens`.
45
- * @param {number} startLoc - The start location of the iteration range.
46
- * @param {number} endLoc - The end location of the iteration range.
47
- * @param {boolean} includeComments - The flag to iterate comments as well.
41
+ * @param {Token[]} tokens The array of tokens.
42
+ * @param {Comment[]} comments The array of comments.
43
+ * @param {Object} indexMap The map from locations to indices in `tokens`.
44
+ * @param {number} startLoc The start location of the iteration range.
45
+ * @param {number} endLoc The end location of the iteration range.
46
+ * @param {boolean} includeComments The flag to iterate comments as well.
48
47
  * @returns {Cursor} The created base cursor.
49
48
  */
50
49
  createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments) {
@@ -55,16 +54,15 @@ class CursorFactory {
55
54
 
56
55
  /**
57
56
  * Creates a cursor that iterates tokens with normalized options.
58
- *
59
- * @param {Token[]} tokens - The array of tokens.
60
- * @param {Comment[]} comments - The array of comments.
61
- * @param {Object} indexMap - The map from locations to indices in `tokens`.
62
- * @param {number} startLoc - The start location of the iteration range.
63
- * @param {number} endLoc - The end location of the iteration range.
64
- * @param {boolean} includeComments - The flag to iterate comments as well.
65
- * @param {Function|null} filter - The predicate function to choose tokens.
66
- * @param {number} skip - The count of tokens the cursor skips.
67
- * @param {number} count - The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
57
+ * @param {Token[]} tokens The array of tokens.
58
+ * @param {Comment[]} comments The array of comments.
59
+ * @param {Object} indexMap The map from locations to indices in `tokens`.
60
+ * @param {number} startLoc The start location of the iteration range.
61
+ * @param {number} endLoc The end location of the iteration range.
62
+ * @param {boolean} includeComments The flag to iterate comments as well.
63
+ * @param {Function|null} filter The predicate function to choose tokens.
64
+ * @param {number} skip The count of tokens the cursor skips.
65
+ * @param {number} count The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
68
66
  * @returns {Cursor} The created cursor.
69
67
  */
70
68
  createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, count) {
@@ -21,7 +21,7 @@ module.exports = class DecorativeCursor extends Cursor {
21
21
 
22
22
  /**
23
23
  * Initializes this cursor.
24
- * @param {Cursor} cursor - The cursor to be decorated.
24
+ * @param {Cursor} cursor The cursor to be decorated.
25
25
  */
26
26
  constructor(cursor) {
27
27
  super();
@@ -21,8 +21,8 @@ module.exports = class FilterCursor extends DecorativeCursor {
21
21
 
22
22
  /**
23
23
  * Initializes this cursor.
24
- * @param {Cursor} cursor - The cursor to be decorated.
25
- * @param {Function} predicate - The predicate function to decide tokens this cursor iterates.
24
+ * @param {Cursor} cursor The cursor to be decorated.
25
+ * @param {Function} predicate The predicate function to decide tokens this cursor iterates.
26
26
  */
27
27
  constructor(cursor, predicate) {
28
28
  super(cursor);
@@ -22,11 +22,11 @@ module.exports = class ForwardTokenCommentCursor extends Cursor {
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.
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
30
  */
31
31
  constructor(tokens, comments, indexMap, startLoc, endLoc) {
32
32
  super();
@@ -22,11 +22,11 @@ module.exports = class ForwardTokenCursor extends Cursor {
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.
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
30
  */
31
31
  constructor(tokens, comments, indexMap, startLoc, endLoc) {
32
32
  super();