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
@@ -2,6 +2,7 @@
2
2
  * @fileoverview Rule to ensure newline per method call when chaining calls
3
3
  * @author Rajendra Patil
4
4
  * @author Burak Yigit Kaya
5
+ * @deprecated in ESLint v8.53.0
5
6
  */
6
7
 
7
8
  "use strict";
@@ -15,6 +16,8 @@ const astUtils = require("./utils/ast-utils");
15
16
  /** @type {import('../shared/types').Rule} */
16
17
  module.exports = {
17
18
  meta: {
19
+ deprecated: true,
20
+ replacedBy: [],
18
21
  type: "layout",
19
22
 
20
23
  docs: {
@@ -5,6 +5,18 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const {
13
+ getVariableByName,
14
+ isClosingParenToken,
15
+ isOpeningParenToken,
16
+ isStartOfExpressionStatement,
17
+ needsPrecedingSemicolon
18
+ } = require("./utils/ast-utils");
19
+
8
20
  //------------------------------------------------------------------------------
9
21
  // Rule Definition
10
22
  //------------------------------------------------------------------------------
@@ -20,15 +32,45 @@ module.exports = {
20
32
  url: "https://eslint.org/docs/latest/rules/no-array-constructor"
21
33
  },
22
34
 
35
+ hasSuggestions: true,
36
+
23
37
  schema: [],
24
38
 
25
39
  messages: {
26
- preferLiteral: "The array literal notation [] is preferable."
40
+ preferLiteral: "The array literal notation [] is preferable.",
41
+ useLiteral: "Replace with an array literal.",
42
+ useLiteralAfterSemicolon: "Replace with an array literal, add preceding semicolon."
27
43
  }
28
44
  },
29
45
 
30
46
  create(context) {
31
47
 
48
+ const sourceCode = context.sourceCode;
49
+
50
+ /**
51
+ * Gets the text between the calling parentheses of a CallExpression or NewExpression.
52
+ * @param {ASTNode} node A CallExpression or NewExpression node.
53
+ * @returns {string} The text between the calling parentheses, or an empty string if there are none.
54
+ */
55
+ function getArgumentsText(node) {
56
+ const lastToken = sourceCode.getLastToken(node);
57
+
58
+ if (!isClosingParenToken(lastToken)) {
59
+ return "";
60
+ }
61
+
62
+ let firstToken = node.callee;
63
+
64
+ do {
65
+ firstToken = sourceCode.getTokenAfter(firstToken);
66
+ if (!firstToken || firstToken === lastToken) {
67
+ return "";
68
+ }
69
+ } while (!isOpeningParenToken(firstToken));
70
+
71
+ return sourceCode.text.slice(firstToken.range[1], lastToken.range[0]);
72
+ }
73
+
32
74
  /**
33
75
  * Disallow construction of dense arrays using the Array constructor
34
76
  * @param {ASTNode} node node to evaluate
@@ -37,11 +79,48 @@ module.exports = {
37
79
  */
38
80
  function check(node) {
39
81
  if (
40
- node.arguments.length !== 1 &&
41
- node.callee.type === "Identifier" &&
42
- node.callee.name === "Array"
43
- ) {
44
- context.report({ node, messageId: "preferLiteral" });
82
+ node.callee.type !== "Identifier" ||
83
+ node.callee.name !== "Array" ||
84
+ node.arguments.length === 1 &&
85
+ node.arguments[0].type !== "SpreadElement") {
86
+ return;
87
+ }
88
+
89
+ const variable = getVariableByName(sourceCode.getScope(node), "Array");
90
+
91
+ /*
92
+ * Check if `Array` is a predefined global variable: predefined globals have no declarations,
93
+ * meaning that the `identifiers` list of the variable object is empty.
94
+ */
95
+ if (variable && variable.identifiers.length === 0) {
96
+ const argsText = getArgumentsText(node);
97
+ let fixText;
98
+ let messageId;
99
+
100
+ /*
101
+ * Check if the suggested change should include a preceding semicolon or not.
102
+ * Due to JavaScript's ASI rules, a missing semicolon may be inserted automatically
103
+ * before an expression like `Array()` or `new Array()`, but not when the expression
104
+ * is changed into an array literal like `[]`.
105
+ */
106
+ if (isStartOfExpressionStatement(node) && needsPrecedingSemicolon(sourceCode, node)) {
107
+ fixText = `;[${argsText}]`;
108
+ messageId = "useLiteralAfterSemicolon";
109
+ } else {
110
+ fixText = `[${argsText}]`;
111
+ messageId = "useLiteral";
112
+ }
113
+
114
+ context.report({
115
+ node,
116
+ messageId: "preferLiteral",
117
+ suggest: [
118
+ {
119
+ messageId,
120
+ fix: fixer => fixer.replaceText(node, fixText)
121
+ }
122
+ ]
123
+ });
45
124
  }
46
125
  }
47
126
 
@@ -2,6 +2,7 @@
2
2
  * @fileoverview A rule to warn against using arrow functions when they could be
3
3
  * confused with comparisons
4
4
  * @author Jxck <https://github.com/Jxck>
5
+ * @deprecated in ESLint v8.53.0
5
6
  */
6
7
 
7
8
  "use strict";
@@ -28,6 +29,8 @@ function isConditional(node) {
28
29
  /** @type {import('../shared/types').Rule} */
29
30
  module.exports = {
30
31
  meta: {
32
+ deprecated: true,
33
+ replacedBy: [],
31
34
  type: "suggestion",
32
35
 
33
36
  docs: {
@@ -43,8 +43,11 @@ module.exports = {
43
43
  }
44
44
  ],
45
45
 
46
+ hasSuggestions: true,
47
+
46
48
  messages: {
47
- unexpected: "Unexpected console statement."
49
+ unexpected: "Unexpected console statement.",
50
+ removeConsole: "Remove the console.{{ propertyName }}()."
48
51
  }
49
52
  },
50
53
 
@@ -94,6 +97,64 @@ module.exports = {
94
97
  );
95
98
  }
96
99
 
100
+ /**
101
+ * Checks if removing the ExpressionStatement node will cause ASI to
102
+ * break.
103
+ * eg.
104
+ * foo()
105
+ * console.log();
106
+ * [1, 2, 3].forEach(a => doSomething(a))
107
+ *
108
+ * Removing the console.log(); statement should leave two statements, but
109
+ * here the two statements will become one because [ causes continuation after
110
+ * foo().
111
+ * @param {ASTNode} node The ExpressionStatement node to check.
112
+ * @returns {boolean} `true` if ASI will break after removing the ExpressionStatement
113
+ * node.
114
+ */
115
+ function maybeAsiHazard(node) {
116
+ const SAFE_TOKENS_BEFORE = /^[:;{]$/u; // One of :;{
117
+ const UNSAFE_CHARS_AFTER = /^[-[(/+`]/u; // One of [(/+-`
118
+
119
+ const tokenBefore = sourceCode.getTokenBefore(node);
120
+ const tokenAfter = sourceCode.getTokenAfter(node);
121
+
122
+ return (
123
+ Boolean(tokenAfter) &&
124
+ UNSAFE_CHARS_AFTER.test(tokenAfter.value) &&
125
+ tokenAfter.value !== "++" &&
126
+ tokenAfter.value !== "--" &&
127
+ Boolean(tokenBefore) &&
128
+ !SAFE_TOKENS_BEFORE.test(tokenBefore.value)
129
+ );
130
+ }
131
+
132
+ /**
133
+ * Checks if the MemberExpression node's parent.parent.parent is a
134
+ * Program, BlockStatement, StaticBlock, or SwitchCase node. This check
135
+ * is necessary to avoid providing a suggestion that might cause a syntax error.
136
+ *
137
+ * eg. if (a) console.log(b), removing console.log() here will lead to a
138
+ * syntax error.
139
+ * if (a) { console.log(b) }, removing console.log() here is acceptable.
140
+ *
141
+ * Additionally, it checks if the callee of the CallExpression node is
142
+ * the node itself.
143
+ *
144
+ * eg. foo(console.log), cannot provide a suggestion here.
145
+ * @param {ASTNode} node The MemberExpression node to check.
146
+ * @returns {boolean} `true` if a suggestion can be provided for a node.
147
+ */
148
+ function canProvideSuggestions(node) {
149
+ return (
150
+ node.parent.type === "CallExpression" &&
151
+ node.parent.callee === node &&
152
+ node.parent.parent.type === "ExpressionStatement" &&
153
+ astUtils.STATEMENT_LIST_PARENTS.has(node.parent.parent.parent.type) &&
154
+ !maybeAsiHazard(node.parent.parent)
155
+ );
156
+ }
157
+
97
158
  /**
98
159
  * Reports the given reference as a violation.
99
160
  * @param {eslint-scope.Reference} reference The reference to report.
@@ -102,10 +163,21 @@ module.exports = {
102
163
  function report(reference) {
103
164
  const node = reference.identifier.parent;
104
165
 
166
+ const propertyName = astUtils.getStaticPropertyName(node);
167
+
105
168
  context.report({
106
169
  node,
107
170
  loc: node.loc,
108
- messageId: "unexpected"
171
+ messageId: "unexpected",
172
+ suggest: canProvideSuggestions(node)
173
+ ? [{
174
+ messageId: "removeConsole",
175
+ data: { propertyName },
176
+ fix(fixer) {
177
+ return fixer.remove(node.parent.parent);
178
+ }
179
+ }]
180
+ : []
109
181
  });
110
182
  }
111
183
 
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Disallow parenthesising higher precedence subexpressions.
3
3
  * @author Michael Ficarra
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
  "use strict";
6
7
 
@@ -14,6 +15,8 @@ const astUtils = require("./utils/ast-utils.js");
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: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to flag use of unnecessary semicolons
3
3
  * @author Nicholas C. Zakas
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -19,6 +20,8 @@ const astUtils = require("./utils/ast-utils");
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: {
@@ -16,6 +16,22 @@ const { directivesPattern } = require("../shared/directives");
16
16
 
17
17
  const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu;
18
18
 
19
+ /**
20
+ * Checks all segments in a set and returns true if any are reachable.
21
+ * @param {Set<CodePathSegment>} segments The segments to check.
22
+ * @returns {boolean} True if any segment is reachable; false otherwise.
23
+ */
24
+ function isAnySegmentReachable(segments) {
25
+
26
+ for (const segment of segments) {
27
+ if (segment.reachable) {
28
+ return true;
29
+ }
30
+ }
31
+
32
+ return false;
33
+ }
34
+
19
35
  /**
20
36
  * Checks whether or not a given comment string is really a fallthrough comment and not an ESLint directive.
21
37
  * @param {string} comment The comment string to check.
@@ -51,15 +67,6 @@ function hasFallthroughComment(caseWhichFallsThrough, subsequentCase, context, f
51
67
  return Boolean(comment && isFallThroughComment(comment.value, fallthroughCommentPattern));
52
68
  }
53
69
 
54
- /**
55
- * Checks whether or not a given code path segment is reachable.
56
- * @param {CodePathSegment} segment A CodePathSegment to check.
57
- * @returns {boolean} `true` if the segment is reachable.
58
- */
59
- function isReachable(segment) {
60
- return segment.reachable;
61
- }
62
-
63
70
  /**
64
71
  * Checks whether a node and a token are separated by blank lines
65
72
  * @param {ASTNode} node The node to check
@@ -109,7 +116,8 @@ module.exports = {
109
116
 
110
117
  create(context) {
111
118
  const options = context.options[0] || {};
112
- let currentCodePath = null;
119
+ const codePathSegments = [];
120
+ let currentCodePathSegments = new Set();
113
121
  const sourceCode = context.sourceCode;
114
122
  const allowEmptyCase = options.allowEmptyCase || false;
115
123
 
@@ -126,13 +134,33 @@ module.exports = {
126
134
  fallthroughCommentPattern = DEFAULT_FALLTHROUGH_COMMENT;
127
135
  }
128
136
  return {
129
- onCodePathStart(codePath) {
130
- currentCodePath = codePath;
137
+
138
+ onCodePathStart() {
139
+ codePathSegments.push(currentCodePathSegments);
140
+ currentCodePathSegments = new Set();
131
141
  },
142
+
132
143
  onCodePathEnd() {
133
- currentCodePath = currentCodePath.upper;
144
+ currentCodePathSegments = codePathSegments.pop();
145
+ },
146
+
147
+ onUnreachableCodePathSegmentStart(segment) {
148
+ currentCodePathSegments.add(segment);
149
+ },
150
+
151
+ onUnreachableCodePathSegmentEnd(segment) {
152
+ currentCodePathSegments.delete(segment);
153
+ },
154
+
155
+ onCodePathSegmentStart(segment) {
156
+ currentCodePathSegments.add(segment);
134
157
  },
135
158
 
159
+ onCodePathSegmentEnd(segment) {
160
+ currentCodePathSegments.delete(segment);
161
+ },
162
+
163
+
136
164
  SwitchCase(node) {
137
165
 
138
166
  /*
@@ -157,7 +185,7 @@ module.exports = {
157
185
  * `break`, `return`, or `throw` are unreachable.
158
186
  * And allows empty cases and the last case.
159
187
  */
160
- if (currentCodePath.currentSegments.some(isReachable) &&
188
+ if (isAnySegmentReachable(currentCodePathSegments) &&
161
189
  (node.consequent.length > 0 || (!allowEmptyCase && hasBlankLinesBetween(node, nextToken))) &&
162
190
  node.parent.cases[node.parent.cases.length - 1] !== node) {
163
191
  fallthroughCase = node;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to flag use of a leading/trailing decimal point in a numeric literal
3
3
  * @author James Allardice
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: "suggestion",
22
25
 
23
26
  docs: {
@@ -96,7 +96,7 @@ module.exports = {
96
96
 
97
97
  if (codePath.origin === "program") {
98
98
  const scope = sourceCode.getScope(node);
99
- const features = context.parserOptions.ecmaFeatures || {};
99
+ const features = context.languageOptions.parserOptions.ecmaFeatures || {};
100
100
 
101
101
  // `this` at the top level of scripts always refers to the global object
102
102
  stack.push({
@@ -13,27 +13,34 @@ const { isValidWithUnicodeFlag } = require("./utils/regular-expressions");
13
13
  // Helpers
14
14
  //------------------------------------------------------------------------------
15
15
 
16
+ /**
17
+ * @typedef {import('@eslint-community/regexpp').AST.Character} Character
18
+ * @typedef {import('@eslint-community/regexpp').AST.CharacterClassElement} CharacterClassElement
19
+ */
20
+
16
21
  /**
17
22
  * Iterate character sequences of a given nodes.
18
23
  *
19
24
  * CharacterClassRange syntax can steal a part of character sequence,
20
25
  * so this function reverts CharacterClassRange syntax and restore the sequence.
21
- * @param {import('@eslint-community/regexpp').AST.CharacterClassElement[]} nodes The node list to iterate character sequences.
22
- * @returns {IterableIterator<number[]>} The list of character sequences.
26
+ * @param {CharacterClassElement[]} nodes The node list to iterate character sequences.
27
+ * @returns {IterableIterator<Character[]>} The list of character sequences.
23
28
  */
24
29
  function *iterateCharacterSequence(nodes) {
30
+
31
+ /** @type {Character[]} */
25
32
  let seq = [];
26
33
 
27
34
  for (const node of nodes) {
28
35
  switch (node.type) {
29
36
  case "Character":
30
- seq.push(node.value);
37
+ seq.push(node);
31
38
  break;
32
39
 
33
40
  case "CharacterClassRange":
34
- seq.push(node.min.value);
41
+ seq.push(node.min);
35
42
  yield seq;
36
- seq = [node.max.value];
43
+ seq = [node.max];
37
44
  break;
38
45
 
39
46
  case "CharacterSet":
@@ -55,32 +62,74 @@ function *iterateCharacterSequence(nodes) {
55
62
  }
56
63
  }
57
64
 
65
+
66
+ /**
67
+ * Checks whether the given character node is a Unicode code point escape or not.
68
+ * @param {Character} char the character node to check.
69
+ * @returns {boolean} `true` if the character node is a Unicode code point escape.
70
+ */
71
+ function isUnicodeCodePointEscape(char) {
72
+ return /^\\u\{[\da-f]+\}$/iu.test(char.raw);
73
+ }
74
+
75
+ /**
76
+ * Each function returns `true` if it detects that kind of problem.
77
+ * @type {Record<string, (chars: Character[]) => boolean>}
78
+ */
58
79
  const hasCharacterSequence = {
59
80
  surrogatePairWithoutUFlag(chars) {
60
- return chars.some((c, i) => i !== 0 && isSurrogatePair(chars[i - 1], c));
81
+ return chars.some((c, i) => {
82
+ if (i === 0) {
83
+ return false;
84
+ }
85
+ const c1 = chars[i - 1];
86
+
87
+ return (
88
+ isSurrogatePair(c1.value, c.value) &&
89
+ !isUnicodeCodePointEscape(c1) &&
90
+ !isUnicodeCodePointEscape(c)
91
+ );
92
+ });
93
+ },
94
+
95
+ surrogatePair(chars) {
96
+ return chars.some((c, i) => {
97
+ if (i === 0) {
98
+ return false;
99
+ }
100
+ const c1 = chars[i - 1];
101
+
102
+ return (
103
+ isSurrogatePair(c1.value, c.value) &&
104
+ (
105
+ isUnicodeCodePointEscape(c1) ||
106
+ isUnicodeCodePointEscape(c)
107
+ )
108
+ );
109
+ });
61
110
  },
62
111
 
63
112
  combiningClass(chars) {
64
113
  return chars.some((c, i) => (
65
114
  i !== 0 &&
66
- isCombiningCharacter(c) &&
67
- !isCombiningCharacter(chars[i - 1])
115
+ isCombiningCharacter(c.value) &&
116
+ !isCombiningCharacter(chars[i - 1].value)
68
117
  ));
69
118
  },
70
119
 
71
120
  emojiModifier(chars) {
72
121
  return chars.some((c, i) => (
73
122
  i !== 0 &&
74
- isEmojiModifier(c) &&
75
- !isEmojiModifier(chars[i - 1])
123
+ isEmojiModifier(c.value) &&
124
+ !isEmojiModifier(chars[i - 1].value)
76
125
  ));
77
126
  },
78
127
 
79
128
  regionalIndicatorSymbol(chars) {
80
129
  return chars.some((c, i) => (
81
130
  i !== 0 &&
82
- isRegionalIndicatorSymbol(c) &&
83
- isRegionalIndicatorSymbol(chars[i - 1])
131
+ isRegionalIndicatorSymbol(c.value) &&
132
+ isRegionalIndicatorSymbol(chars[i - 1].value)
84
133
  ));
85
134
  },
86
135
 
@@ -90,9 +139,9 @@ const hasCharacterSequence = {
90
139
  return chars.some((c, i) => (
91
140
  i !== 0 &&
92
141
  i !== lastIndex &&
93
- c === 0x200d &&
94
- chars[i - 1] !== 0x200d &&
95
- chars[i + 1] !== 0x200d
142
+ c.value === 0x200d &&
143
+ chars[i - 1].value !== 0x200d &&
144
+ chars[i + 1].value !== 0x200d
96
145
  ));
97
146
  }
98
147
  };
@@ -120,6 +169,7 @@ module.exports = {
120
169
 
121
170
  messages: {
122
171
  surrogatePairWithoutUFlag: "Unexpected surrogate pair in character class. Use 'u' flag.",
172
+ surrogatePair: "Unexpected surrogate pair in character class.",
123
173
  combiningClass: "Unexpected combined character in character class.",
124
174
  emojiModifier: "Unexpected modified Emoji in character class.",
125
175
  regionalIndicatorSymbol: "Unexpected national flag in character class.",
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to disallow mixed binary operators.
3
3
  * @author Toru Nagashima
4
+ * @deprecated in ESLint v8.53.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -85,6 +86,8 @@ function getChildNode(node) {
85
86
  /** @type {import('../shared/types').Rule} */
86
87
  module.exports = {
87
88
  meta: {
89
+ deprecated: true,
90
+ replacedBy: [],
88
91
  type: "suggestion",
89
92
 
90
93
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Disallow mixed spaces and tabs for indentation
3
3
  * @author Jary Niebur
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: "layout",
15
18
 
16
19
  docs: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Disallow use of multiple spaces.
3
3
  * @author Nicholas C. Zakas
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: {
@@ -2,6 +2,7 @@
2
2
  * @fileoverview Disallows multiple blank lines.
3
3
  * implementation adapted from the no-trailing-spaces rule.
4
4
  * @author Greg Cochard
5
+ * @deprecated in ESLint v8.53.0
5
6
  */
6
7
  "use strict";
7
8
 
@@ -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 A rule to disallow calls to the Object constructor
3
3
  * @author Matt DuVall <http://www.mattduvall.com/>
4
+ * @deprecated in ESLint v8.50.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -26,6 +27,12 @@ module.exports = {
26
27
  url: "https://eslint.org/docs/latest/rules/no-new-object"
27
28
  },
28
29
 
30
+ deprecated: true,
31
+
32
+ replacedBy: [
33
+ "no-object-constructor"
34
+ ],
35
+
29
36
  schema: [],
30
37
 
31
38
  messages: {