eslint 8.47.0 → 8.57.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 (118) hide show
  1. package/README.md +18 -13
  2. package/bin/eslint.js +38 -5
  3. package/conf/rule-type-list.json +25 -33
  4. package/lib/api.js +29 -1
  5. package/lib/cli-engine/cli-engine.js +2 -2
  6. package/lib/cli-engine/lint-result-cache.js +18 -6
  7. package/lib/cli.js +36 -6
  8. package/lib/config/flat-config-schema.js +124 -61
  9. package/lib/config/rule-validator.js +2 -1
  10. package/lib/eslint/eslint-helpers.js +9 -11
  11. package/lib/eslint/eslint.js +7 -0
  12. package/lib/eslint/flat-eslint.js +33 -18
  13. package/lib/linter/apply-disable-directives.js +127 -13
  14. package/lib/linter/code-path-analysis/code-path-analyzer.js +32 -24
  15. package/lib/linter/code-path-analysis/code-path-segment.js +52 -24
  16. package/lib/linter/code-path-analysis/code-path-state.js +1108 -243
  17. package/lib/linter/code-path-analysis/code-path.js +128 -33
  18. package/lib/linter/code-path-analysis/fork-context.js +173 -72
  19. package/lib/linter/config-comment-parser.js +36 -2
  20. package/lib/linter/linter.js +183 -82
  21. package/lib/options.js +24 -3
  22. package/lib/rule-tester/flat-rule-tester.js +113 -25
  23. package/lib/rule-tester/rule-tester.js +176 -23
  24. package/lib/rules/array-bracket-newline.js +3 -0
  25. package/lib/rules/array-bracket-spacing.js +3 -0
  26. package/lib/rules/array-callback-return.js +175 -25
  27. package/lib/rules/array-element-newline.js +3 -0
  28. package/lib/rules/arrow-parens.js +3 -0
  29. package/lib/rules/arrow-spacing.js +3 -0
  30. package/lib/rules/block-spacing.js +3 -0
  31. package/lib/rules/brace-style.js +3 -0
  32. package/lib/rules/comma-dangle.js +3 -0
  33. package/lib/rules/comma-spacing.js +3 -0
  34. package/lib/rules/comma-style.js +3 -0
  35. package/lib/rules/computed-property-spacing.js +3 -0
  36. package/lib/rules/consistent-return.js +32 -7
  37. package/lib/rules/constructor-super.js +37 -14
  38. package/lib/rules/dot-location.js +3 -0
  39. package/lib/rules/eol-last.js +3 -0
  40. package/lib/rules/for-direction.js +38 -24
  41. package/lib/rules/func-call-spacing.js +3 -0
  42. package/lib/rules/function-call-argument-newline.js +3 -0
  43. package/lib/rules/function-paren-newline.js +3 -0
  44. package/lib/rules/generator-star-spacing.js +3 -0
  45. package/lib/rules/getter-return.js +33 -8
  46. package/lib/rules/implicit-arrow-linebreak.js +3 -0
  47. package/lib/rules/indent.js +3 -0
  48. package/lib/rules/index.js +1 -0
  49. package/lib/rules/jsx-quotes.js +3 -0
  50. package/lib/rules/key-spacing.js +3 -0
  51. package/lib/rules/keyword-spacing.js +3 -0
  52. package/lib/rules/linebreak-style.js +3 -0
  53. package/lib/rules/lines-around-comment.js +3 -0
  54. package/lib/rules/lines-between-class-members.js +95 -7
  55. package/lib/rules/logical-assignment-operators.js +31 -3
  56. package/lib/rules/max-len.js +3 -0
  57. package/lib/rules/max-statements-per-line.js +3 -0
  58. package/lib/rules/multiline-ternary.js +3 -0
  59. package/lib/rules/new-parens.js +3 -0
  60. package/lib/rules/newline-per-chained-call.js +3 -0
  61. package/lib/rules/no-array-constructor.js +85 -6
  62. package/lib/rules/no-confusing-arrow.js +3 -0
  63. package/lib/rules/no-console.js +74 -2
  64. package/lib/rules/no-extra-parens.js +3 -0
  65. package/lib/rules/no-extra-semi.js +3 -0
  66. package/lib/rules/no-fallthrough.js +42 -14
  67. package/lib/rules/no-floating-decimal.js +3 -0
  68. package/lib/rules/no-invalid-this.js +1 -1
  69. package/lib/rules/no-misleading-character-class.js +65 -15
  70. package/lib/rules/no-mixed-operators.js +3 -0
  71. package/lib/rules/no-mixed-spaces-and-tabs.js +3 -0
  72. package/lib/rules/no-multi-spaces.js +3 -0
  73. package/lib/rules/no-multiple-empty-lines.js +3 -0
  74. package/lib/rules/no-new-object.js +7 -0
  75. package/lib/rules/no-object-constructor.js +117 -0
  76. package/lib/rules/no-promise-executor-return.js +157 -16
  77. package/lib/rules/no-prototype-builtins.js +90 -2
  78. package/lib/rules/no-restricted-imports.js +54 -31
  79. package/lib/rules/no-restricted-properties.js +15 -28
  80. package/lib/rules/no-tabs.js +3 -0
  81. package/lib/rules/no-this-before-super.js +38 -11
  82. package/lib/rules/no-trailing-spaces.js +3 -0
  83. package/lib/rules/no-unreachable-loop.js +47 -12
  84. package/lib/rules/no-unreachable.js +39 -10
  85. package/lib/rules/no-useless-return.js +35 -4
  86. package/lib/rules/no-whitespace-before-property.js +3 -0
  87. package/lib/rules/nonblock-statement-body-position.js +3 -0
  88. package/lib/rules/object-curly-newline.js +3 -0
  89. package/lib/rules/object-curly-spacing.js +3 -0
  90. package/lib/rules/object-property-newline.js +3 -0
  91. package/lib/rules/one-var-declaration-per-line.js +3 -0
  92. package/lib/rules/operator-linebreak.js +3 -0
  93. package/lib/rules/padded-blocks.js +3 -0
  94. package/lib/rules/padding-line-between-statements.js +3 -0
  95. package/lib/rules/quote-props.js +3 -0
  96. package/lib/rules/quotes.js +3 -0
  97. package/lib/rules/require-atomic-updates.js +21 -7
  98. package/lib/rules/rest-spread-spacing.js +3 -0
  99. package/lib/rules/semi-spacing.js +3 -0
  100. package/lib/rules/semi-style.js +3 -0
  101. package/lib/rules/semi.js +3 -0
  102. package/lib/rules/space-before-blocks.js +3 -0
  103. package/lib/rules/space-before-function-paren.js +3 -0
  104. package/lib/rules/space-in-parens.js +3 -0
  105. package/lib/rules/space-infix-ops.js +3 -0
  106. package/lib/rules/space-unary-ops.js +3 -0
  107. package/lib/rules/spaced-comment.js +3 -0
  108. package/lib/rules/switch-colon-spacing.js +3 -0
  109. package/lib/rules/template-curly-spacing.js +3 -0
  110. package/lib/rules/template-tag-spacing.js +3 -0
  111. package/lib/rules/utils/ast-utils.js +111 -1
  112. package/lib/rules/wrap-iife.js +3 -0
  113. package/lib/rules/wrap-regex.js +3 -0
  114. package/lib/rules/yield-star-spacing.js +3 -0
  115. package/lib/shared/severity.js +49 -0
  116. package/lib/source-code/source-code.js +329 -3
  117. package/messages/eslintrc-incompat.js +1 -1
  118. package/package.json +24 -17
@@ -90,6 +90,21 @@ module.exports = {
90
90
  return Boolean(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends);
91
91
  }
92
92
 
93
+ /**
94
+ * Determines if every segment in a set has been called.
95
+ * @param {Set<CodePathSegment>} segments The segments to search.
96
+ * @returns {boolean} True if every segment has been called; false otherwise.
97
+ */
98
+ function isEverySegmentCalled(segments) {
99
+ for (const segment of segments) {
100
+ if (!isCalled(segment)) {
101
+ return false;
102
+ }
103
+ }
104
+
105
+ return true;
106
+ }
107
+
93
108
  /**
94
109
  * Checks whether or not this is before `super()` is called.
95
110
  * @returns {boolean} `true` if this is before `super()` is called.
@@ -97,7 +112,7 @@ module.exports = {
97
112
  function isBeforeCallOfSuper() {
98
113
  return (
99
114
  isInConstructorOfDerivedClass() &&
100
- !funcInfo.codePath.currentSegments.every(isCalled)
115
+ !isEverySegmentCalled(funcInfo.currentSegments)
101
116
  );
102
117
  }
103
118
 
@@ -108,11 +123,9 @@ module.exports = {
108
123
  * @returns {void}
109
124
  */
110
125
  function setInvalid(node) {
111
- const segments = funcInfo.codePath.currentSegments;
112
-
113
- for (let i = 0; i < segments.length; ++i) {
114
- const segment = segments[i];
126
+ const segments = funcInfo.currentSegments;
115
127
 
128
+ for (const segment of segments) {
116
129
  if (segment.reachable) {
117
130
  segInfoMap[segment.id].invalidNodes.push(node);
118
131
  }
@@ -124,11 +137,9 @@ module.exports = {
124
137
  * @returns {void}
125
138
  */
126
139
  function setSuperCalled() {
127
- const segments = funcInfo.codePath.currentSegments;
128
-
129
- for (let i = 0; i < segments.length; ++i) {
130
- const segment = segments[i];
140
+ const segments = funcInfo.currentSegments;
131
141
 
142
+ for (const segment of segments) {
132
143
  if (segment.reachable) {
133
144
  segInfoMap[segment.id].superCalled = true;
134
145
  }
@@ -156,14 +167,16 @@ module.exports = {
156
167
  classNode.superClass &&
157
168
  !astUtils.isNullOrUndefined(classNode.superClass)
158
169
  ),
159
- codePath
170
+ codePath,
171
+ currentSegments: new Set()
160
172
  };
161
173
  } else {
162
174
  funcInfo = {
163
175
  upper: funcInfo,
164
176
  isConstructor: false,
165
177
  hasExtends: false,
166
- codePath
178
+ codePath,
179
+ currentSegments: new Set()
167
180
  };
168
181
  }
169
182
  },
@@ -211,6 +224,8 @@ module.exports = {
211
224
  * @returns {void}
212
225
  */
213
226
  onCodePathSegmentStart(segment) {
227
+ funcInfo.currentSegments.add(segment);
228
+
214
229
  if (!isInConstructorOfDerivedClass()) {
215
230
  return;
216
231
  }
@@ -225,6 +240,18 @@ module.exports = {
225
240
  };
226
241
  },
227
242
 
243
+ onUnreachableCodePathSegmentStart(segment) {
244
+ funcInfo.currentSegments.add(segment);
245
+ },
246
+
247
+ onUnreachableCodePathSegmentEnd(segment) {
248
+ funcInfo.currentSegments.delete(segment);
249
+ },
250
+
251
+ onCodePathSegmentEnd(segment) {
252
+ funcInfo.currentSegments.delete(segment);
253
+ },
254
+
228
255
  /**
229
256
  * Update information of the code path segment when a code path was
230
257
  * looped.
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Disallow trailing spaces at the end of lines.
3
3
  * @author Nodeca Team <https://github.com/nodeca>
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -17,6 +18,8 @@ const astUtils = require("./utils/ast-utils");
17
18
  /** @type {import('../shared/types').Rule} */
18
19
  module.exports = {
19
20
  meta: {
21
+ deprecated: true,
22
+ replacedBy: [],
20
23
  type: "layout",
21
24
 
22
25
  docs: {
@@ -11,6 +11,22 @@
11
11
 
12
12
  const allLoopTypes = ["WhileStatement", "DoWhileStatement", "ForStatement", "ForInStatement", "ForOfStatement"];
13
13
 
14
+ /**
15
+ * Checks all segments in a set and returns true if any are reachable.
16
+ * @param {Set<CodePathSegment>} segments The segments to check.
17
+ * @returns {boolean} True if any segment is reachable; false otherwise.
18
+ */
19
+ function isAnySegmentReachable(segments) {
20
+
21
+ for (const segment of segments) {
22
+ if (segment.reachable) {
23
+ return true;
24
+ }
25
+ }
26
+
27
+ return false;
28
+ }
29
+
14
30
  /**
15
31
  * Determines whether the given node is the first node in the code path to which a loop statement
16
32
  * 'loops' for the next iteration.
@@ -90,29 +106,36 @@ module.exports = {
90
106
  loopsByTargetSegments = new Map(),
91
107
  loopsToReport = new Set();
92
108
 
93
- let currentCodePath = null;
109
+ const codePathSegments = [];
110
+ let currentCodePathSegments = new Set();
94
111
 
95
112
  return {
96
- onCodePathStart(codePath) {
97
- currentCodePath = codePath;
113
+
114
+ onCodePathStart() {
115
+ codePathSegments.push(currentCodePathSegments);
116
+ currentCodePathSegments = new Set();
98
117
  },
99
118
 
100
119
  onCodePathEnd() {
101
- currentCodePath = currentCodePath.upper;
120
+ currentCodePathSegments = codePathSegments.pop();
102
121
  },
103
122
 
104
- [loopSelector](node) {
123
+ onUnreachableCodePathSegmentStart(segment) {
124
+ currentCodePathSegments.add(segment);
125
+ },
105
126
 
106
- /**
107
- * Ignore unreachable loop statements to avoid unnecessary complexity in the implementation, or false positives otherwise.
108
- * For unreachable segments, the code path analysis does not raise events required for this implementation.
109
- */
110
- if (currentCodePath.currentSegments.some(segment => segment.reachable)) {
111
- loopsToReport.add(node);
112
- }
127
+ onUnreachableCodePathSegmentEnd(segment) {
128
+ currentCodePathSegments.delete(segment);
129
+ },
130
+
131
+ onCodePathSegmentEnd(segment) {
132
+ currentCodePathSegments.delete(segment);
113
133
  },
114
134
 
115
135
  onCodePathSegmentStart(segment, node) {
136
+
137
+ currentCodePathSegments.add(segment);
138
+
116
139
  if (isLoopingTarget(node)) {
117
140
  const loop = node.parent;
118
141
 
@@ -140,6 +163,18 @@ module.exports = {
140
163
  }
141
164
  },
142
165
 
166
+ [loopSelector](node) {
167
+
168
+ /**
169
+ * Ignore unreachable loop statements to avoid unnecessary complexity in the implementation, or false positives otherwise.
170
+ * For unreachable segments, the code path analysis does not raise events required for this implementation.
171
+ */
172
+ if (isAnySegmentReachable(currentCodePathSegments)) {
173
+ loopsToReport.add(node);
174
+ }
175
+ },
176
+
177
+
143
178
  "Program:exit"() {
144
179
  loopsToReport.forEach(
145
180
  node => context.report({ node, messageId: "invalid" })
@@ -24,12 +24,19 @@ function isInitialized(node) {
24
24
  }
25
25
 
26
26
  /**
27
- * Checks whether or not a given code path segment is unreachable.
28
- * @param {CodePathSegment} segment A CodePathSegment to check.
29
- * @returns {boolean} `true` if the segment is unreachable.
27
+ * Checks all segments in a set and returns true if all are unreachable.
28
+ * @param {Set<CodePathSegment>} segments The segments to check.
29
+ * @returns {boolean} True if all segments are unreachable; false otherwise.
30
30
  */
31
- function isUnreachable(segment) {
32
- return !segment.reachable;
31
+ function areAllSegmentsUnreachable(segments) {
32
+
33
+ for (const segment of segments) {
34
+ if (segment.reachable) {
35
+ return false;
36
+ }
37
+ }
38
+
39
+ return true;
33
40
  }
34
41
 
35
42
  /**
@@ -124,7 +131,6 @@ module.exports = {
124
131
  },
125
132
 
126
133
  create(context) {
127
- let currentCodePath = null;
128
134
 
129
135
  /** @type {ConstructorInfo | null} */
130
136
  let constructorInfo = null;
@@ -132,6 +138,12 @@ module.exports = {
132
138
  /** @type {ConsecutiveRange} */
133
139
  const range = new ConsecutiveRange(context.sourceCode);
134
140
 
141
+ /** @type {Array<Set<CodePathSegment>>} */
142
+ const codePathSegments = [];
143
+
144
+ /** @type {Set<CodePathSegment>} */
145
+ let currentCodePathSegments = new Set();
146
+
135
147
  /**
136
148
  * Reports a given node if it's unreachable.
137
149
  * @param {ASTNode} node A statement node to report.
@@ -140,7 +152,7 @@ module.exports = {
140
152
  function reportIfUnreachable(node) {
141
153
  let nextNode = null;
142
154
 
143
- if (node && (node.type === "PropertyDefinition" || currentCodePath.currentSegments.every(isUnreachable))) {
155
+ if (node && (node.type === "PropertyDefinition" || areAllSegmentsUnreachable(currentCodePathSegments))) {
144
156
 
145
157
  // Store this statement to distinguish consecutive statements.
146
158
  if (range.isEmpty) {
@@ -181,12 +193,29 @@ module.exports = {
181
193
  return {
182
194
 
183
195
  // Manages the current code path.
184
- onCodePathStart(codePath) {
185
- currentCodePath = codePath;
196
+ onCodePathStart() {
197
+ codePathSegments.push(currentCodePathSegments);
198
+ currentCodePathSegments = new Set();
186
199
  },
187
200
 
188
201
  onCodePathEnd() {
189
- currentCodePath = currentCodePath.upper;
202
+ currentCodePathSegments = codePathSegments.pop();
203
+ },
204
+
205
+ onUnreachableCodePathSegmentStart(segment) {
206
+ currentCodePathSegments.add(segment);
207
+ },
208
+
209
+ onUnreachableCodePathSegmentEnd(segment) {
210
+ currentCodePathSegments.delete(segment);
211
+ },
212
+
213
+ onCodePathSegmentEnd(segment) {
214
+ currentCodePathSegments.delete(segment);
215
+ },
216
+
217
+ onCodePathSegmentStart(segment) {
218
+ currentCodePathSegments.add(segment);
190
219
  },
191
220
 
192
221
  // Registers for all statement nodes (excludes FunctionDeclaration).
@@ -57,6 +57,22 @@ function isInFinally(node) {
57
57
  return false;
58
58
  }
59
59
 
60
+ /**
61
+ * Checks all segments in a set and returns true if any are reachable.
62
+ * @param {Set<CodePathSegment>} segments The segments to check.
63
+ * @returns {boolean} True if any segment is reachable; false otherwise.
64
+ */
65
+ function isAnySegmentReachable(segments) {
66
+
67
+ for (const segment of segments) {
68
+ if (segment.reachable) {
69
+ return true;
70
+ }
71
+ }
72
+
73
+ return false;
74
+ }
75
+
60
76
  //------------------------------------------------------------------------------
61
77
  // Rule Definition
62
78
  //------------------------------------------------------------------------------
@@ -205,7 +221,6 @@ module.exports = {
205
221
  */
206
222
  function markReturnStatementsOnCurrentSegmentsAsUsed() {
207
223
  scopeInfo
208
- .codePath
209
224
  .currentSegments
210
225
  .forEach(segment => markReturnStatementsOnSegmentAsUsed(segment, new Set()));
211
226
  }
@@ -222,7 +237,8 @@ module.exports = {
222
237
  upper: scopeInfo,
223
238
  uselessReturns: [],
224
239
  traversedTryBlockStatements: [],
225
- codePath
240
+ codePath,
241
+ currentSegments: new Set()
226
242
  };
227
243
  },
228
244
 
@@ -259,6 +275,9 @@ module.exports = {
259
275
  * NOTE: This event is notified for only reachable segments.
260
276
  */
261
277
  onCodePathSegmentStart(segment) {
278
+
279
+ scopeInfo.currentSegments.add(segment);
280
+
262
281
  const info = {
263
282
  uselessReturns: getUselessReturns([], segment.allPrevSegments),
264
283
  returned: false
@@ -268,6 +287,18 @@ module.exports = {
268
287
  segmentInfoMap.set(segment, info);
269
288
  },
270
289
 
290
+ onUnreachableCodePathSegmentStart(segment) {
291
+ scopeInfo.currentSegments.add(segment);
292
+ },
293
+
294
+ onUnreachableCodePathSegmentEnd(segment) {
295
+ scopeInfo.currentSegments.delete(segment);
296
+ },
297
+
298
+ onCodePathSegmentEnd(segment) {
299
+ scopeInfo.currentSegments.delete(segment);
300
+ },
301
+
271
302
  // Adds ReturnStatement node to check whether it's useless or not.
272
303
  ReturnStatement(node) {
273
304
  if (node.argument) {
@@ -279,12 +310,12 @@ module.exports = {
279
310
  isInFinally(node) ||
280
311
 
281
312
  // Ignore `return` statements in unreachable places (https://github.com/eslint/eslint/issues/11647).
282
- !scopeInfo.codePath.currentSegments.some(s => s.reachable)
313
+ !isAnySegmentReachable(scopeInfo.currentSegments)
283
314
  ) {
284
315
  return;
285
316
  }
286
317
 
287
- for (const segment of scopeInfo.codePath.currentSegments) {
318
+ for (const segment of scopeInfo.currentSegments) {
288
319
  const info = segmentInfoMap.get(segment);
289
320
 
290
321
  if (info) {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to disallow whitespace before properties
3
3
  * @author Kai Cataldo
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -17,6 +18,8 @@ const astUtils = require("./utils/ast-utils");
17
18
  /** @type {import('../shared/types').Rule} */
18
19
  module.exports = {
19
20
  meta: {
21
+ deprecated: true,
22
+ replacedBy: [],
20
23
  type: "layout",
21
24
 
22
25
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview enforce the location of single-line statements
3
3
  * @author Teddy Katz
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -13,6 +14,8 @@ const POSITION_SCHEMA = { enum: ["beside", "below", "any"] };
13
14
  /** @type {import('../shared/types').Rule} */
14
15
  module.exports = {
15
16
  meta: {
17
+ deprecated: true,
18
+ replacedBy: [],
16
19
  type: "layout",
17
20
 
18
21
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to require or disallow line breaks inside braces.
3
3
  * @author Toru Nagashima
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -147,6 +148,8 @@ function areLineBreaksRequired(node, options, first, last) {
147
148
  /** @type {import('../shared/types').Rule} */
148
149
  module.exports = {
149
150
  meta: {
151
+ deprecated: true,
152
+ replacedBy: [],
150
153
  type: "layout",
151
154
 
152
155
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Disallows or enforces spaces inside of object literals.
3
3
  * @author Jamund Ferguson
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -13,6 +14,8 @@ const astUtils = require("./utils/ast-utils");
13
14
  /** @type {import('../shared/types').Rule} */
14
15
  module.exports = {
15
16
  meta: {
17
+ deprecated: true,
18
+ replacedBy: [],
16
19
  type: "layout",
17
20
 
18
21
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to enforce placing object properties on separate lines.
3
3
  * @author Vitor Balocco
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -12,6 +13,8 @@
12
13
  /** @type {import('../shared/types').Rule} */
13
14
  module.exports = {
14
15
  meta: {
16
+ deprecated: true,
17
+ replacedBy: [],
15
18
  type: "layout",
16
19
 
17
20
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to check multiple var declarations per line
3
3
  * @author Alberto Rodríguez
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -11,6 +12,8 @@
11
12
  /** @type {import('../shared/types').Rule} */
12
13
  module.exports = {
13
14
  meta: {
15
+ deprecated: true,
16
+ replacedBy: [],
14
17
  type: "suggestion",
15
18
 
16
19
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Operator linebreak - enforces operator linebreak style of two types: after and before
3
3
  * @author Benoît Zugmeyer
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -18,6 +19,8 @@ const astUtils = require("./utils/ast-utils");
18
19
  /** @type {import('../shared/types').Rule} */
19
20
  module.exports = {
20
21
  meta: {
22
+ deprecated: true,
23
+ replacedBy: [],
21
24
  type: "layout",
22
25
 
23
26
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview A rule to ensure blank lines within blocks.
3
3
  * @author Mathias Schreck <https://github.com/lo1tuma>
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -18,6 +19,8 @@ const astUtils = require("./utils/ast-utils");
18
19
  /** @type {import('../shared/types').Rule} */
19
20
  module.exports = {
20
21
  meta: {
22
+ deprecated: true,
23
+ replacedBy: [],
21
24
  type: "layout",
22
25
 
23
26
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to require or disallow newlines between statements
3
3
  * @author Toru Nagashima
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -383,6 +384,8 @@ const StatementTypes = {
383
384
  /** @type {import('../shared/types').Rule} */
384
385
  module.exports = {
385
386
  meta: {
387
+ deprecated: true,
388
+ replacedBy: [],
386
389
  type: "layout",
387
390
 
388
391
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to flag non-quoted property names in object literals.
3
3
  * @author Mathias Bynens <http://mathiasbynens.be/>
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -19,6 +20,8 @@ const keywords = require("./utils/keywords");
19
20
  /** @type {import('../shared/types').Rule} */
20
21
  module.exports = {
21
22
  meta: {
23
+ deprecated: true,
24
+ replacedBy: [],
22
25
  type: "suggestion",
23
26
 
24
27
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview A rule to choose between single and double quote marks
3
3
  * @author Matt DuVall <http://www.mattduvall.com/>, Brandon Payton
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -77,6 +78,8 @@ const AVOID_ESCAPE = "avoid-escape";
77
78
  /** @type {import('../shared/types').Rule} */
78
79
  module.exports = {
79
80
  meta: {
81
+ deprecated: true,
82
+ replacedBy: [],
80
83
  type: "layout",
81
84
 
82
85
  docs: {
@@ -213,7 +213,8 @@ module.exports = {
213
213
  stack = {
214
214
  upper: stack,
215
215
  codePath,
216
- referenceMap: shouldVerify ? createReferenceMap(scope) : null
216
+ referenceMap: shouldVerify ? createReferenceMap(scope) : null,
217
+ currentSegments: new Set()
217
218
  };
218
219
  },
219
220
  onCodePathEnd() {
@@ -223,11 +224,25 @@ module.exports = {
223
224
  // Initialize the segment information.
224
225
  onCodePathSegmentStart(segment) {
225
226
  segmentInfo.initialize(segment);
227
+ stack.currentSegments.add(segment);
226
228
  },
227
229
 
230
+ onUnreachableCodePathSegmentStart(segment) {
231
+ stack.currentSegments.add(segment);
232
+ },
233
+
234
+ onUnreachableCodePathSegmentEnd(segment) {
235
+ stack.currentSegments.delete(segment);
236
+ },
237
+
238
+ onCodePathSegmentEnd(segment) {
239
+ stack.currentSegments.delete(segment);
240
+ },
241
+
242
+
228
243
  // Handle references to prepare verification.
229
244
  Identifier(node) {
230
- const { codePath, referenceMap } = stack;
245
+ const { referenceMap } = stack;
231
246
  const reference = referenceMap && referenceMap.get(node);
232
247
 
233
248
  // Ignore if this is not a valid variable reference.
@@ -240,7 +255,7 @@ module.exports = {
240
255
 
241
256
  // Add a fresh read variable.
242
257
  if (reference.isRead() && !(writeExpr && writeExpr.parent.operator === "=")) {
243
- segmentInfo.markAsRead(codePath.currentSegments, variable);
258
+ segmentInfo.markAsRead(stack.currentSegments, variable);
244
259
  }
245
260
 
246
261
  /*
@@ -267,16 +282,15 @@ module.exports = {
267
282
  * If the reference exists in `outdatedReadVariables` list, report it.
268
283
  */
269
284
  ":expression:exit"(node) {
270
- const { codePath, referenceMap } = stack;
271
285
 
272
286
  // referenceMap exists if this is in a resumable function scope.
273
- if (!referenceMap) {
287
+ if (!stack.referenceMap) {
274
288
  return;
275
289
  }
276
290
 
277
291
  // Mark the read variables on this code path as outdated.
278
292
  if (node.type === "AwaitExpression" || node.type === "YieldExpression") {
279
- segmentInfo.makeOutdated(codePath.currentSegments);
293
+ segmentInfo.makeOutdated(stack.currentSegments);
280
294
  }
281
295
 
282
296
  // Verify.
@@ -288,7 +302,7 @@ module.exports = {
288
302
  for (const reference of references) {
289
303
  const variable = reference.resolved;
290
304
 
291
- if (segmentInfo.isOutdated(codePath.currentSegments, variable)) {
305
+ if (segmentInfo.isOutdated(stack.currentSegments, variable)) {
292
306
  if (node.parent.left === reference.identifier) {
293
307
  context.report({
294
308
  node: node.parent,
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Enforce spacing between rest and spread operators and their expressions.
3
3
  * @author Kai Cataldo
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -12,6 +13,8 @@
12
13
  /** @type {import('../shared/types').Rule} */
13
14
  module.exports = {
14
15
  meta: {
16
+ deprecated: true,
17
+ replacedBy: [],
15
18
  type: "layout",
16
19
 
17
20
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Validates spacing before and after semicolon
3
3
  * @author Mathias Schreck
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -14,6 +15,8 @@ const astUtils = require("./utils/ast-utils");
14
15
  /** @type {import('../shared/types').Rule} */
15
16
  module.exports = {
16
17
  meta: {
18
+ deprecated: true,
19
+ replacedBy: [],
17
20
  type: "layout",
18
21
 
19
22
  docs: {