oxlint-plugin-eslint 1.72.0 → 1.73.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.
@@ -5798,7 +5798,7 @@ var require_eslint_visitor_keys = /* @__PURE__ */ require_rolldown_runtime.t(((e
5798
5798
  if (isClosingBraceToken(prevToken)) return prevNode.type === "BlockStatement" && prevNode.parent.type === "FunctionExpression" && prevNode.parent.parent.type !== "MethodDefinition" || prevNode.type === "ClassBody" && prevNode.parent.type === "ClassExpression" || prevNode.type === "ObjectExpression";
5799
5799
  if (IDENTIFIER_OR_KEYWORD.has(prevToken.type)) {
5800
5800
  if (prevNode.parent.type === "VariableDeclarator" && !prevNode.parent.init || BREAK_OR_CONTINUE.has(prevNode.parent.type)) return !1;
5801
- let nodeType = NODE_TYPES_BY_KEYWORD[prevToken.value];
5801
+ let keyword = prevToken.value, nodeType = NODE_TYPES_BY_KEYWORD[keyword];
5802
5802
  return prevNode.type !== nodeType;
5803
5803
  }
5804
5804
  return prevToken.type === "String" ? !DECLARATIONS.has(prevNode.parent.type) : !0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-eslint",
3
- "version": "1.72.0",
3
+ "version": "1.73.0",
4
4
  "description": "ESLint's built-in rules as an Oxlint plugin",
5
5
  "keywords": [
6
6
  "eslint",
@@ -54,7 +54,7 @@ var require_jsx_quotes = /* @__PURE__ */ require_rolldown_runtime.t(((exports, m
54
54
  messages: { unexpected: "Unexpected usage of {{description}}." }
55
55
  },
56
56
  create(context) {
57
- let setting = QUOTE_SETTINGS[context.options[0] || "prefer-double"];
57
+ let quoteOption = context.options[0] || "prefer-double", setting = QUOTE_SETTINGS[quoteOption];
58
58
  /**
59
59
  * Checks if the given string literal node uses the expected quotes
60
60
  * @param {ASTNode} node A string literal node.
@@ -39,7 +39,7 @@ var require_no_obj_calls = /* @__PURE__ */ require_rolldown_runtime.t(((exports,
39
39
  create(context) {
40
40
  let sourceCode = context.sourceCode;
41
41
  return { Program(node) {
42
- let tracker = new ReferenceTracker(sourceCode.getScope(node)), traceMap = {};
42
+ let scope = sourceCode.getScope(node), tracker = new ReferenceTracker(scope), traceMap = {};
43
43
  for (let g of nonCallableGlobals) traceMap[g] = {
44
44
  [CALL]: !0,
45
45
  [CONSTRUCT]: !0
@@ -244,8 +244,7 @@ var require_no_useless_assignment = /* @__PURE__ */ require_rolldown_runtime.t((
244
244
  let assignments = scopeStack.assignments, pattern, expression = null;
245
245
  node.type === "VariableDeclarator" ? (pattern = node.id, expression = node.init) : node.type === "AssignmentExpression" ? (pattern = node.left, expression = node.right) : pattern = node.argument;
246
246
  for (let identifier of extractIdentifiersFromPattern(pattern)) {
247
- /** @type {Variable} */
248
- let variable = findVariable(sourceCode.getScope(identifier), identifier);
247
+ let scope = sourceCode.getScope(identifier), variable = findVariable(scope, identifier);
249
248
  if (!variable || variable.scope.type === "global" && variable.defs.length === 0 || scopeStack.scope !== getCodePathStartScope(variable.scope) || variable.eslintUsed || variable.scope.type === "module" && (variable.defs.some((def) => def.type === "Variable" && def.parent.parent.type === "ExportNamedDeclaration" || def.type === "FunctionName" && (def.node.parent.type === "ExportNamedDeclaration" || def.node.parent.type === "ExportDefaultDeclaration") || def.type === "ClassName" && (def.node.parent.type === "ExportNamedDeclaration" || def.node.parent.type === "ExportDefaultDeclaration")) || variable.references.some((reference) => reference.identifier.parent.type === "ExportSpecifier"))) continue;
250
249
  let list = assignments.get(variable);
251
250
  list || (list = [], assignments.set(variable, list)), list.push({
@@ -88,7 +88,7 @@ var require_prefer_exponentiation_operator = /* @__PURE__ */ require_rolldown_ru
88
88
  });
89
89
  }
90
90
  return { Program(node) {
91
- let tracker = new ReferenceTracker(sourceCode.getScope(node)), trackMap = { Math: { pow: { [CALL]: !0 } } };
91
+ let scope = sourceCode.getScope(node), tracker = new ReferenceTracker(scope), trackMap = { Math: { pow: { [CALL]: !0 } } };
92
92
  for (let { node: refNode } of tracker.iterateGlobalReferences(trackMap)) report(refNode);
93
93
  } };
94
94
  }
@@ -92,7 +92,7 @@ var require_prefer_named_capture_group = /* @__PURE__ */ require_rolldown_runtim
92
92
  node.regex && checkRegex(node.regex.pattern, node, node, node.regex.flags);
93
93
  },
94
94
  Program(node) {
95
- let tracker = new ReferenceTracker(sourceCode.getScope(node)), traceMap = { RegExp: {
95
+ let scope = sourceCode.getScope(node), tracker = new ReferenceTracker(scope), traceMap = { RegExp: {
96
96
  [CALL]: !0,
97
97
  [CONSTRUCT]: !0
98
98
  } };
@@ -151,7 +151,7 @@ var require_prefer_object_spread = /* @__PURE__ */ require_rolldown_runtime.t(((
151
151
  create(context) {
152
152
  let sourceCode = context.sourceCode;
153
153
  return { Program(node) {
154
- let tracker = new ReferenceTracker(sourceCode.getScope(node)), trackMap = { Object: { assign: { [CALL]: !0 } } };
154
+ let scope = sourceCode.getScope(node), tracker = new ReferenceTracker(scope), trackMap = { Object: { assign: { [CALL]: !0 } } };
155
155
  for (let { node: refNode } of tracker.iterateGlobalReferences(trackMap)) if (refNode.arguments.length >= 1 && refNode.arguments[0].type === "ObjectExpression" && !hasArraySpread(refNode) && !(refNode.arguments.length > 1 && hasArgumentsWithAccessors(refNode))) {
156
156
  let messageId = refNode.arguments.length === 1 ? "useLiteralMessage" : "useSpreadMessage", fix = defineFixer(refNode, sourceCode);
157
157
  context.report({
@@ -180,7 +180,7 @@ var require_prefer_regex_literals = /* @__PURE__ */ require_rolldown_runtime.t((
180
180
  return (tokenBefore && !canTokensBeAdjacent(tokenBefore, newRegExpValue) && tokenBefore.range[1] === node.range[0] ? " " : "") + newRegExpValue + (tokenAfter && !canTokensBeAdjacent(newRegExpValue, tokenAfter) && node.range[1] === tokenAfter.range[0] ? " " : "");
181
181
  }
182
182
  return { Program(node) {
183
- let tracker = new ReferenceTracker(sourceCode.getScope(node)), traceMap = { RegExp: {
183
+ let scope = sourceCode.getScope(node), tracker = new ReferenceTracker(scope), traceMap = { RegExp: {
184
184
  [CALL]: !0,
185
185
  [CONSTRUCT]: !0
186
186
  } };
@@ -225,11 +225,11 @@ var require_prefer_regex_literals = /* @__PURE__ */ require_rolldown_runtime.t((
225
225
  } else if (hasOnlyStaticStringArguments(refNode)) {
226
226
  let regexContent = getStringValue(refNode.arguments[0]), noFix = !1, flags;
227
227
  if (refNode.arguments[1] && (flags = getStringValue(refNode.arguments[1])), canFixTo(refNode, regexContent, flags) || (noFix = !0), /^[-\w\\[\](){} \t\r\n\v\f!@#$%^&*+=/~`.><?,'"|:;]*$/u.test(regexContent) || (noFix = !0), regexContent && !noFix) {
228
- let charIncrease = 0;
229
- visitRegExpAST(new RegExpParser({ ecmaVersion: regexppEcmaVersion }).parsePattern(regexContent, 0, regexContent.length, {
228
+ let charIncrease = 0, ast = new RegExpParser({ ecmaVersion: regexppEcmaVersion }).parsePattern(regexContent, 0, regexContent.length, {
230
229
  unicode: flags ? flags.includes("u") : !1,
231
230
  unicodeSets: flags ? flags.includes("v") : !1
232
- }), { onCharacterEnter(characterNode) {
231
+ });
232
+ visitRegExpAST(ast, { onCharacterEnter(characterNode) {
233
233
  let escaped = resolveEscapes(characterNode.raw);
234
234
  escaped && (regexContent = regexContent.slice(0, characterNode.start + charIncrease) + escaped + regexContent.slice(characterNode.end + charIncrease), characterNode.raw.length === 1 && (charIncrease += 1));
235
235
  } });
@@ -43,7 +43,8 @@ var require_require_unicode_regexp = /* @__PURE__ */ require_rolldown_runtime.t(
43
43
  let sourceCode = context.sourceCode, [{ requireFlag }] = context.options;
44
44
  return {
45
45
  "Literal[regex]"(node) {
46
- checkFlags(requireFlag, node.regex.flags || "") && context.report({
46
+ let flags = node.regex.flags || "";
47
+ checkFlags(requireFlag, flags) && context.report({
47
48
  messageId: requireFlag === "v" ? "requireVFlag" : "requireUFlag",
48
49
  node,
49
50
  suggest: isValidWithUnicodeFlag(context.languageOptions.ecmaVersion, node.regex.pattern, requireFlag) ? [{