@pobammer-ts/eslint-cease-nonsense-rules 1.2.4 → 1.4.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.
package/dist/index.js CHANGED
@@ -8420,6 +8420,214 @@ var enforceIanitorCheckType = createRule({
8420
8420
  });
8421
8421
  var enforce_ianitor_check_type_default = enforceIanitorCheckType;
8422
8422
 
8423
+ // src/rules/no-async-constructor.ts
8424
+ import { AST_NODE_TYPES } from "@typescript-eslint/types";
8425
+ var PROMISE_CHAIN_METHODS = new Set(["then", "catch", "finally"]);
8426
+ function isNode(value) {
8427
+ return typeof value === "object" && value !== null && "type" in value;
8428
+ }
8429
+ function hasDynamicProperties(_node) {
8430
+ return true;
8431
+ }
8432
+ function getAsyncMethodNames(classBody) {
8433
+ const asyncMethods = new Set;
8434
+ for (const element of classBody.body) {
8435
+ if (element.type !== AST_NODE_TYPES.MethodDefinition)
8436
+ continue;
8437
+ if (element.kind !== "method")
8438
+ continue;
8439
+ if (!element.value.async)
8440
+ continue;
8441
+ if (element.key.type === AST_NODE_TYPES.Identifier)
8442
+ asyncMethods.add(element.key.name);
8443
+ }
8444
+ return asyncMethods;
8445
+ }
8446
+ function isPromiseChainCall(node) {
8447
+ if (node.callee.type !== AST_NODE_TYPES.MemberExpression)
8448
+ return false;
8449
+ const { property } = node.callee;
8450
+ if (property.type !== AST_NODE_TYPES.Identifier)
8451
+ return false;
8452
+ return PROMISE_CHAIN_METHODS.has(property.name);
8453
+ }
8454
+ function isAsyncIIFE(node) {
8455
+ const { callee } = node;
8456
+ if (callee.type === AST_NODE_TYPES.ArrowFunctionExpression && callee.async)
8457
+ return true;
8458
+ if (callee.type === AST_NODE_TYPES.FunctionExpression && callee.async)
8459
+ return true;
8460
+ return false;
8461
+ }
8462
+ function isThisAsyncMethodCall(node, asyncMethods) {
8463
+ const { callee } = node;
8464
+ if (callee.type !== AST_NODE_TYPES.MemberExpression)
8465
+ return;
8466
+ if (callee.object.type !== AST_NODE_TYPES.ThisExpression)
8467
+ return;
8468
+ if (callee.property.type !== AST_NODE_TYPES.Identifier)
8469
+ return;
8470
+ const methodName = callee.property.name;
8471
+ return asyncMethods.has(methodName) ? methodName : undefined;
8472
+ }
8473
+ function isAssignedToThisProperty(node, parent) {
8474
+ if (!parent)
8475
+ return false;
8476
+ if (parent.type !== AST_NODE_TYPES.AssignmentExpression)
8477
+ return false;
8478
+ if (parent.right !== node)
8479
+ return false;
8480
+ const { left } = parent;
8481
+ return left.type === AST_NODE_TYPES.MemberExpression && left.object.type === AST_NODE_TYPES.ThisExpression;
8482
+ }
8483
+ function getLocalVariableAssignment(node, parent) {
8484
+ if (!parent)
8485
+ return;
8486
+ if (parent.type !== AST_NODE_TYPES.VariableDeclarator)
8487
+ return;
8488
+ if (parent.init !== node)
8489
+ return;
8490
+ if (parent.id.type !== AST_NODE_TYPES.Identifier)
8491
+ return;
8492
+ return parent.id.name;
8493
+ }
8494
+ function isExpressionStatement(parent) {
8495
+ return parent?.type === AST_NODE_TYPES.ExpressionStatement;
8496
+ }
8497
+ function checkAsyncMethodCall(current, parent, asyncMethods) {
8498
+ const asyncMethodName = isThisAsyncMethodCall(current, asyncMethods);
8499
+ if (asyncMethodName === undefined)
8500
+ return;
8501
+ if (isAssignedToThisProperty(current, parent))
8502
+ return;
8503
+ if (isExpressionStatement(parent)) {
8504
+ return {
8505
+ data: { methodName: asyncMethodName },
8506
+ messageId: "unhandledAsyncCall",
8507
+ node: current
8508
+ };
8509
+ }
8510
+ const variableName = getLocalVariableAssignment(current, parent);
8511
+ if (variableName !== undefined) {
8512
+ return {
8513
+ data: { variableName },
8514
+ messageId: "orphanedPromise",
8515
+ node: current
8516
+ };
8517
+ }
8518
+ return;
8519
+ }
8520
+ function isNonIIFEFunction(node, parent) {
8521
+ if (node.type !== AST_NODE_TYPES.ArrowFunctionExpression && node.type !== AST_NODE_TYPES.FunctionExpression) {
8522
+ return false;
8523
+ }
8524
+ if (parent?.type === AST_NODE_TYPES.CallExpression && parent.callee === node) {
8525
+ return false;
8526
+ }
8527
+ return true;
8528
+ }
8529
+ function findConstructorViolations(constructorBody, asyncMethods) {
8530
+ const violations = new Array;
8531
+ let size = 0;
8532
+ const visited2 = new WeakSet;
8533
+ const parentMap = new WeakMap;
8534
+ function traverse(current) {
8535
+ if (visited2.has(current))
8536
+ return;
8537
+ visited2.add(current);
8538
+ const parent = parentMap.get(current);
8539
+ if (isNonIIFEFunction(current, parent))
8540
+ return;
8541
+ if (current.type === AST_NODE_TYPES.AwaitExpression) {
8542
+ violations[size++] = { messageId: "awaitInConstructor", node: current };
8543
+ }
8544
+ if (current.type === AST_NODE_TYPES.CallExpression) {
8545
+ if (isPromiseChainCall(current)) {
8546
+ violations[size++] = { messageId: "promiseChainInConstructor", node: current };
8547
+ }
8548
+ if (isAsyncIIFE(current))
8549
+ violations[size++] = { messageId: "asyncIifeInConstructor", node: current };
8550
+ const asyncViolation = checkAsyncMethodCall(current, parent, asyncMethods);
8551
+ if (asyncViolation)
8552
+ violations[size++] = asyncViolation;
8553
+ }
8554
+ if (!hasDynamicProperties(current))
8555
+ return;
8556
+ for (const key in current) {
8557
+ const childValue = current[key];
8558
+ if (childValue === undefined)
8559
+ continue;
8560
+ if (Array.isArray(childValue)) {
8561
+ for (const item of childValue) {
8562
+ if (!isNode(item))
8563
+ continue;
8564
+ parentMap.set(item, current);
8565
+ traverse(item);
8566
+ }
8567
+ continue;
8568
+ }
8569
+ if (!isNode(childValue))
8570
+ continue;
8571
+ parentMap.set(childValue, current);
8572
+ traverse(childValue);
8573
+ }
8574
+ }
8575
+ traverse(constructorBody);
8576
+ return violations;
8577
+ }
8578
+ function reportViolation(context, violation) {
8579
+ if (violation.data) {
8580
+ context.report({
8581
+ data: violation.data,
8582
+ messageId: violation.messageId,
8583
+ node: violation.node
8584
+ });
8585
+ return;
8586
+ }
8587
+ context.report({
8588
+ messageId: violation.messageId,
8589
+ node: violation.node
8590
+ });
8591
+ }
8592
+ var noAsyncConstructor = {
8593
+ create(context) {
8594
+ return {
8595
+ "MethodDefinition[kind='constructor']"(node) {
8596
+ const constructorValue = node.value;
8597
+ if (constructorValue.type !== AST_NODE_TYPES.FunctionExpression)
8598
+ return;
8599
+ const { body } = constructorValue;
8600
+ if (body.type !== AST_NODE_TYPES.BlockStatement)
8601
+ return;
8602
+ const classNode = node.parent;
8603
+ if (classNode.type !== AST_NODE_TYPES.ClassBody)
8604
+ return;
8605
+ const asyncMethods = getAsyncMethodNames(classNode);
8606
+ const violations = findConstructorViolations(body, asyncMethods);
8607
+ for (const violation of violations)
8608
+ reportViolation(context, violation);
8609
+ }
8610
+ };
8611
+ },
8612
+ defaultOptions: [],
8613
+ meta: {
8614
+ docs: {
8615
+ description: "Disallow asynchronous operations inside class constructors. Constructors return immediately, " + "so async work causes race conditions, unhandled rejections, and incomplete object states.",
8616
+ recommended: true
8617
+ },
8618
+ messages: {
8619
+ asyncIifeInConstructor: "Refactor this asynchronous operation outside of the constructor. " + "Async IIFEs create unhandled promises and incomplete object state.",
8620
+ awaitInConstructor: "Refactor this asynchronous operation outside of the constructor. " + "Using 'await' in a constructor causes the class to be instantiated before the async operation completes.",
8621
+ orphanedPromise: "Refactor this asynchronous operation outside of the constructor. " + "Promise assigned to '{{variableName}}' is never consumed - errors will be silently swallowed.",
8622
+ promiseChainInConstructor: "Refactor this asynchronous operation outside of the constructor. " + "Promise chains (.then/.catch/.finally) in constructors lead to race conditions.",
8623
+ unhandledAsyncCall: "Refactor this asynchronous operation outside of the constructor. " + "Calling async method '{{methodName}}' without handling its result creates uncontrolled async behavior."
8624
+ },
8625
+ schema: [],
8626
+ type: "problem"
8627
+ }
8628
+ };
8629
+ var no_async_constructor_default = noAsyncConstructor;
8630
+
8423
8631
  // src/rules/no-color3-constructor.ts
8424
8632
  import { TSESTree as TSESTree4 } from "@typescript-eslint/types";
8425
8633
  var isNumericLiteralNode = Compile(build_default.Object({
@@ -8496,7 +8704,7 @@ var noColor3Constructor = {
8496
8704
  var no_color3_constructor_default = noColor3Constructor;
8497
8705
 
8498
8706
  // src/rules/no-instance-methods-without-this.ts
8499
- import { AST_NODE_TYPES } from "@typescript-eslint/types";
8707
+ import { AST_NODE_TYPES as AST_NODE_TYPES2 } from "@typescript-eslint/types";
8500
8708
  var DEFAULT_OPTIONS = {
8501
8709
  checkPrivate: true,
8502
8710
  checkProtected: true,
@@ -8526,19 +8734,19 @@ function shouldCheckMethod(node, options3) {
8526
8734
  return false;
8527
8735
  return true;
8528
8736
  }
8529
- function isNode(value) {
8737
+ function isNode2(value) {
8530
8738
  return typeof value === "object" && value !== null && "type" in value;
8531
8739
  }
8532
- function hasDynamicProperties(_node) {
8740
+ function hasDynamicProperties2(_node) {
8533
8741
  return true;
8534
8742
  }
8535
8743
  function traverseForThis(currentNode, visited2) {
8536
8744
  if (visited2.has(currentNode))
8537
8745
  return false;
8538
8746
  visited2.add(currentNode);
8539
- if (currentNode.type === AST_NODE_TYPES.ThisExpression || currentNode.type === AST_NODE_TYPES.Super)
8747
+ if (currentNode.type === AST_NODE_TYPES2.ThisExpression || currentNode.type === AST_NODE_TYPES2.Super)
8540
8748
  return true;
8541
- if (!hasDynamicProperties(currentNode))
8749
+ if (!hasDynamicProperties2(currentNode))
8542
8750
  return false;
8543
8751
  for (const key in currentNode) {
8544
8752
  const childValue = currentNode[key];
@@ -8546,18 +8754,18 @@ function traverseForThis(currentNode, visited2) {
8546
8754
  continue;
8547
8755
  if (Array.isArray(childValue)) {
8548
8756
  for (const item of childValue)
8549
- if (isNode(item) && traverseForThis(item, visited2))
8757
+ if (isNode2(item) && traverseForThis(item, visited2))
8550
8758
  return true;
8551
8759
  continue;
8552
8760
  }
8553
- if (isNode(childValue) && traverseForThis(childValue, visited2))
8761
+ if (isNode2(childValue) && traverseForThis(childValue, visited2))
8554
8762
  return true;
8555
8763
  }
8556
8764
  return false;
8557
8765
  }
8558
8766
  function methodUsesThis(node) {
8559
8767
  const value = node.value;
8560
- if (value === undefined || value.type !== AST_NODE_TYPES.FunctionExpression)
8768
+ if (value === undefined || value.type !== AST_NODE_TYPES2.FunctionExpression)
8561
8769
  return false;
8562
8770
  return traverseForThis(value, new WeakSet);
8563
8771
  }
@@ -8571,7 +8779,7 @@ var noInstanceMethodsWithoutThis = {
8571
8779
  return;
8572
8780
  if (methodUsesThis(node))
8573
8781
  return;
8574
- const methodName = node.key.type === AST_NODE_TYPES.Identifier ? node.key.name : "unknown";
8782
+ const methodName = node.key.type === AST_NODE_TYPES2.Identifier ? node.key.name : "unknown";
8575
8783
  context.report({
8576
8784
  data: { methodName },
8577
8785
  messageId: "noInstanceMethodWithoutThis",
@@ -8769,13 +8977,13 @@ var noWarn = {
8769
8977
  var no_warn_default = noWarn;
8770
8978
 
8771
8979
  // src/rules/prefer-sequence-overloads.ts
8772
- import { AST_NODE_TYPES as AST_NODE_TYPES2 } from "@typescript-eslint/types";
8980
+ import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/types";
8773
8981
  var sequenceDescriptors = [
8774
8982
  { keypointName: "ColorSequenceKeypoint", sequenceName: "ColorSequence" },
8775
8983
  { keypointName: "NumberSequenceKeypoint", sequenceName: "NumberSequence" }
8776
8984
  ];
8777
8985
  function isSequenceIdentifier(node) {
8778
- if (node.type !== AST_NODE_TYPES2.Identifier)
8986
+ if (node.type !== AST_NODE_TYPES3.Identifier)
8779
8987
  return false;
8780
8988
  for (const { sequenceName } of sequenceDescriptors)
8781
8989
  if (sequenceName === node.name)
@@ -8789,16 +8997,16 @@ function findDescriptor(sequenceName) {
8789
8997
  return;
8790
8998
  }
8791
8999
  var isNumericLiteral = Compile(build_default.Object({
8792
- type: build_default.Literal(AST_NODE_TYPES2.Literal),
9000
+ type: build_default.Literal(AST_NODE_TYPES3.Literal),
8793
9001
  value: build_default.Number()
8794
9002
  }));
8795
9003
  function isExpressionArgument(argument) {
8796
- return argument !== undefined && argument.type !== AST_NODE_TYPES2.SpreadElement;
9004
+ return argument !== undefined && argument.type !== AST_NODE_TYPES3.SpreadElement;
8797
9005
  }
8798
9006
  function extractKeypoint(element, descriptor) {
8799
- if (element === undefined || element.type !== AST_NODE_TYPES2.NewExpression)
9007
+ if (element === undefined || element.type !== AST_NODE_TYPES3.NewExpression)
8800
9008
  return;
8801
- if (element.callee.type !== AST_NODE_TYPES2.Identifier || element.callee.name !== descriptor.keypointName)
9009
+ if (element.callee.type !== AST_NODE_TYPES3.Identifier || element.callee.name !== descriptor.keypointName)
8802
9010
  return;
8803
9011
  if (element.arguments.length !== 2)
8804
9012
  return;
@@ -8828,7 +9036,7 @@ var preferSequenceOverloads = {
8828
9036
  if (descriptor === undefined || node.arguments.length !== 1)
8829
9037
  return;
8830
9038
  const [argument] = node.arguments;
8831
- if (argument === undefined || argument.type !== AST_NODE_TYPES2.ArrayExpression || argument.elements.length !== 2)
9039
+ if (argument === undefined || argument.type !== AST_NODE_TYPES3.ArrayExpression || argument.elements.length !== 2)
8832
9040
  return;
8833
9041
  const firstElement = argument.elements[0] ?? undefined;
8834
9042
  const secondElement = argument.elements[1] ?? undefined;
@@ -9368,7 +9576,7 @@ var requireNamedEffectFunctions = {
9368
9576
  var require_named_effect_functions_default = requireNamedEffectFunctions;
9369
9577
 
9370
9578
  // src/rules/require-paired-calls.ts
9371
- import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/types";
9579
+ import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/types";
9372
9580
  var isStringArray = Compile(build_default.Readonly(build_default.Array(build_default.String())));
9373
9581
  var isPairConfiguration = Compile(build_default.Readonly(build_default.Object({
9374
9582
  alternatives: build_default.Optional(isStringArray),
@@ -9386,20 +9594,20 @@ var isRuleOptions3 = Compile(build_default.Partial(build_default.Readonly(build_
9386
9594
  pairs: build_default.Readonly(build_default.Array(isPairConfiguration))
9387
9595
  }))));
9388
9596
  var LOOP_NODE_TYPES = new Set([
9389
- AST_NODE_TYPES3.DoWhileStatement,
9390
- AST_NODE_TYPES3.ForInStatement,
9391
- AST_NODE_TYPES3.ForOfStatement,
9392
- AST_NODE_TYPES3.ForStatement,
9393
- AST_NODE_TYPES3.WhileStatement
9597
+ AST_NODE_TYPES4.DoWhileStatement,
9598
+ AST_NODE_TYPES4.ForInStatement,
9599
+ AST_NODE_TYPES4.ForOfStatement,
9600
+ AST_NODE_TYPES4.ForStatement,
9601
+ AST_NODE_TYPES4.WhileStatement
9394
9602
  ]);
9395
9603
  var DEFAULT_ROBLOX_YIELDING_FUNCTIONS = ["task.wait", "wait", "*.WaitForChild", "*.*Async"];
9396
9604
  function getCallName(node) {
9397
9605
  const { callee } = node;
9398
- if (callee.type === AST_NODE_TYPES3.Identifier)
9606
+ if (callee.type === AST_NODE_TYPES4.Identifier)
9399
9607
  return callee.name;
9400
- if (callee.type === AST_NODE_TYPES3.MemberExpression) {
9401
- const object3 = callee.object.type === AST_NODE_TYPES3.Identifier ? callee.object.name : undefined;
9402
- const property = callee.property.type === AST_NODE_TYPES3.Identifier ? callee.property.name : undefined;
9608
+ if (callee.type === AST_NODE_TYPES4.MemberExpression) {
9609
+ const object3 = callee.object.type === AST_NODE_TYPES4.Identifier ? callee.object.name : undefined;
9610
+ const property = callee.property.type === AST_NODE_TYPES4.Identifier ? callee.property.name : undefined;
9403
9611
  if (object3 !== undefined && property !== undefined)
9404
9612
  return `${object3}.${property}`;
9405
9613
  }
@@ -9435,12 +9643,12 @@ function isLoopLikeStatement(node) {
9435
9643
  return LOOP_NODE_TYPES.has(node.type);
9436
9644
  }
9437
9645
  function isSwitchStatement(node) {
9438
- return node?.type === AST_NODE_TYPES3.SwitchStatement;
9646
+ return node?.type === AST_NODE_TYPES4.SwitchStatement;
9439
9647
  }
9440
9648
  function findLabeledStatementBody(label, startingNode) {
9441
9649
  let current = startingNode;
9442
9650
  while (current) {
9443
- if (current.type === AST_NODE_TYPES3.LabeledStatement && current.label.name === label.name)
9651
+ if (current.type === AST_NODE_TYPES4.LabeledStatement && current.label.name === label.name)
9444
9652
  return current.body;
9445
9653
  current = current.parent ?? undefined;
9446
9654
  }
@@ -9693,7 +9901,7 @@ var rule = {
9693
9901
  function onIfConsequentExit(node) {
9694
9902
  const consequentNode = node;
9695
9903
  const parent = consequentNode.parent;
9696
- if (parent?.type === AST_NODE_TYPES3.IfStatement) {
9904
+ if (parent?.type === AST_NODE_TYPES4.IfStatement) {
9697
9905
  const branches = branchStacks.get(parent) ?? [];
9698
9906
  branches.push(cloneStack());
9699
9907
  branchStacks.set(parent, branches);
@@ -9708,7 +9916,7 @@ var rule = {
9708
9916
  function onIfAlternateExit(node) {
9709
9917
  const alternateNode = node;
9710
9918
  const parent = alternateNode.parent;
9711
- if (parent?.type === AST_NODE_TYPES3.IfStatement) {
9919
+ if (parent?.type === AST_NODE_TYPES4.IfStatement) {
9712
9920
  const branches = branchStacks.get(parent) ?? [];
9713
9921
  branches.push(cloneStack());
9714
9922
  branchStacks.set(parent, branches);
@@ -9757,7 +9965,7 @@ var rule = {
9757
9965
  function onTryBlockExit(node) {
9758
9966
  const blockNode = node;
9759
9967
  const { parent } = blockNode;
9760
- if (parent?.type === AST_NODE_TYPES3.TryStatement) {
9968
+ if (parent?.type === AST_NODE_TYPES4.TryStatement) {
9761
9969
  const branches = branchStacks.get(parent) ?? [];
9762
9970
  branches.push(cloneStack());
9763
9971
  branchStacks.set(parent, branches);
@@ -9776,7 +9984,7 @@ var rule = {
9776
9984
  function onCatchClauseExit(node) {
9777
9985
  const catchNode = node;
9778
9986
  const { parent } = catchNode;
9779
- if (parent?.type === AST_NODE_TYPES3.TryStatement) {
9987
+ if (parent?.type === AST_NODE_TYPES4.TryStatement) {
9780
9988
  const branches = branchStacks.get(parent) ?? [];
9781
9989
  branches.push(cloneStack());
9782
9990
  branchStacks.set(parent, branches);
@@ -9839,7 +10047,7 @@ var rule = {
9839
10047
  function onSwitchCaseExit(node) {
9840
10048
  const caseNode = node;
9841
10049
  const { parent } = caseNode;
9842
- if (parent?.type === AST_NODE_TYPES3.SwitchStatement) {
10050
+ if (parent?.type === AST_NODE_TYPES4.SwitchStatement) {
9843
10051
  const branches = branchStacks.get(parent) ?? [];
9844
10052
  branches.push(cloneStack());
9845
10053
  branchStacks.set(parent, branches);
@@ -9870,7 +10078,7 @@ var rule = {
9870
10078
  for (const { opener, config, node: node2 } of openerStack) {
9871
10079
  const validClosers = getValidClosers(config);
9872
10080
  const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
9873
- const statementType = statementNode.type === AST_NODE_TYPES3.ReturnStatement ? "return" : "throw";
10081
+ const statementType = statementNode.type === AST_NODE_TYPES4.ReturnStatement ? "return" : "throw";
9874
10082
  const lineNumber = statementNode.loc?.start.line ?? 0;
9875
10083
  context.report({
9876
10084
  data: {
@@ -9887,7 +10095,7 @@ var rule = {
9887
10095
  const statementNode = node;
9888
10096
  if (openerStack.length === 0)
9889
10097
  return;
9890
- const targetLoop = statementNode.type === AST_NODE_TYPES3.ContinueStatement ? resolveContinueTargetLoop(statementNode) : resolveBreakTargetLoop(statementNode);
10098
+ const targetLoop = statementNode.type === AST_NODE_TYPES4.ContinueStatement ? resolveContinueTargetLoop(statementNode) : resolveBreakTargetLoop(statementNode);
9891
10099
  if (!targetLoop)
9892
10100
  return;
9893
10101
  for (const { node: openerNode, config, opener, loopAncestors } of openerStack) {
@@ -9895,7 +10103,7 @@ var rule = {
9895
10103
  continue;
9896
10104
  const validClosers = getValidClosers(config);
9897
10105
  const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
9898
- const statementType = statementNode.type === AST_NODE_TYPES3.BreakStatement ? "break" : "continue";
10106
+ const statementType = statementNode.type === AST_NODE_TYPES4.BreakStatement ? "break" : "continue";
9899
10107
  const lineNumber = statementNode.loc?.start.line ?? 0;
9900
10108
  context.report({
9901
10109
  data: {
@@ -10033,7 +10241,7 @@ var rule = {
10033
10241
  continue;
10034
10242
  const validClosers = getValidClosers(config);
10035
10243
  const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
10036
- const asyncType = asyncNode.type === AST_NODE_TYPES3.AwaitExpression ? "await" : "yield";
10244
+ const asyncType = asyncNode.type === AST_NODE_TYPES4.AwaitExpression ? "await" : "yield";
10037
10245
  context.report({
10038
10246
  data: { asyncType, closer, opener },
10039
10247
  messageId: "asyncViolation",
@@ -11160,6 +11368,1289 @@ var useExhaustiveDependencies = {
11160
11368
  };
11161
11369
  var use_exhaustive_dependencies_default = useExhaustiveDependencies;
11162
11370
 
11371
+ // src/rules/no-commented-code.ts
11372
+ import path from "node:path";
11373
+
11374
+ // node_modules/oxc-parser/src-js/index.js
11375
+ import { createRequire as createRequire3 } from "node:module";
11376
+
11377
+ // node_modules/oxc-parser/src-js/bindings.js
11378
+ import { createRequire } from "node:module";
11379
+ var require2 = createRequire(import.meta.url);
11380
+ var __dirname2 = new URL(".", import.meta.url).pathname;
11381
+ var { readFileSync } = require2("node:fs");
11382
+ var nativeBinding = null;
11383
+ var loadErrors = [];
11384
+ var isMusl = () => {
11385
+ let musl = false;
11386
+ if (process.platform === "linux") {
11387
+ musl = isMuslFromFilesystem();
11388
+ if (musl === null) {
11389
+ musl = isMuslFromReport();
11390
+ }
11391
+ if (musl === null) {
11392
+ musl = isMuslFromChildProcess();
11393
+ }
11394
+ }
11395
+ return musl;
11396
+ };
11397
+ var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
11398
+ var isMuslFromFilesystem = () => {
11399
+ try {
11400
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
11401
+ } catch {
11402
+ return null;
11403
+ }
11404
+ };
11405
+ var isMuslFromReport = () => {
11406
+ let report = null;
11407
+ if (typeof process.report?.getReport === "function") {
11408
+ process.report.excludeNetwork = true;
11409
+ report = process.report.getReport();
11410
+ }
11411
+ if (!report) {
11412
+ return null;
11413
+ }
11414
+ if (report.header && report.header.glibcVersionRuntime) {
11415
+ return false;
11416
+ }
11417
+ if (Array.isArray(report.sharedObjects)) {
11418
+ if (report.sharedObjects.some(isFileMusl)) {
11419
+ return true;
11420
+ }
11421
+ }
11422
+ return false;
11423
+ };
11424
+ var isMuslFromChildProcess = () => {
11425
+ try {
11426
+ return require2("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
11427
+ } catch (e) {
11428
+ return false;
11429
+ }
11430
+ };
11431
+ function requireNative() {
11432
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
11433
+ try {
11434
+ return require2(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
11435
+ } catch (err) {
11436
+ loadErrors.push(err);
11437
+ }
11438
+ } else if (process.platform === "android") {
11439
+ if (process.arch === "arm64") {
11440
+ try {
11441
+ return require2("./parser.android-arm64.node");
11442
+ } catch (e) {
11443
+ loadErrors.push(e);
11444
+ }
11445
+ try {
11446
+ const binding = require2("@oxc-parser/binding-android-arm64");
11447
+ const bindingPackageVersion = require2("@oxc-parser/binding-android-arm64/package.json").version;
11448
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11449
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11450
+ }
11451
+ return binding;
11452
+ } catch (e) {
11453
+ loadErrors.push(e);
11454
+ }
11455
+ } else if (process.arch === "arm") {
11456
+ try {
11457
+ return require2("./parser.android-arm-eabi.node");
11458
+ } catch (e) {
11459
+ loadErrors.push(e);
11460
+ }
11461
+ try {
11462
+ const binding = require2("@oxc-parser/binding-android-arm-eabi");
11463
+ const bindingPackageVersion = require2("@oxc-parser/binding-android-arm-eabi/package.json").version;
11464
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11465
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11466
+ }
11467
+ return binding;
11468
+ } catch (e) {
11469
+ loadErrors.push(e);
11470
+ }
11471
+ } else {
11472
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
11473
+ }
11474
+ } else if (process.platform === "win32") {
11475
+ if (process.arch === "x64") {
11476
+ if (process.config?.variables?.shlib_suffix === "dll.a" || process.config?.variables?.node_target_type === "shared_library") {
11477
+ try {
11478
+ return require2("./parser.win32-x64-gnu.node");
11479
+ } catch (e) {
11480
+ loadErrors.push(e);
11481
+ }
11482
+ try {
11483
+ const binding = require2("@oxc-parser/binding-win32-x64-gnu");
11484
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-gnu/package.json").version;
11485
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11486
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11487
+ }
11488
+ return binding;
11489
+ } catch (e) {
11490
+ loadErrors.push(e);
11491
+ }
11492
+ } else {
11493
+ try {
11494
+ return require2("./parser.win32-x64-msvc.node");
11495
+ } catch (e) {
11496
+ loadErrors.push(e);
11497
+ }
11498
+ try {
11499
+ const binding = require2("@oxc-parser/binding-win32-x64-msvc");
11500
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-msvc/package.json").version;
11501
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11502
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11503
+ }
11504
+ return binding;
11505
+ } catch (e) {
11506
+ loadErrors.push(e);
11507
+ }
11508
+ }
11509
+ } else if (process.arch === "ia32") {
11510
+ try {
11511
+ return require2("./parser.win32-ia32-msvc.node");
11512
+ } catch (e) {
11513
+ loadErrors.push(e);
11514
+ }
11515
+ try {
11516
+ const binding = require2("@oxc-parser/binding-win32-ia32-msvc");
11517
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-ia32-msvc/package.json").version;
11518
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11519
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11520
+ }
11521
+ return binding;
11522
+ } catch (e) {
11523
+ loadErrors.push(e);
11524
+ }
11525
+ } else if (process.arch === "arm64") {
11526
+ try {
11527
+ return require2("./parser.win32-arm64-msvc.node");
11528
+ } catch (e) {
11529
+ loadErrors.push(e);
11530
+ }
11531
+ try {
11532
+ const binding = require2("@oxc-parser/binding-win32-arm64-msvc");
11533
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-arm64-msvc/package.json").version;
11534
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11535
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11536
+ }
11537
+ return binding;
11538
+ } catch (e) {
11539
+ loadErrors.push(e);
11540
+ }
11541
+ } else {
11542
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
11543
+ }
11544
+ } else if (process.platform === "darwin") {
11545
+ try {
11546
+ return require2("./parser.darwin-universal.node");
11547
+ } catch (e) {
11548
+ loadErrors.push(e);
11549
+ }
11550
+ try {
11551
+ const binding = require2("@oxc-parser/binding-darwin-universal");
11552
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-universal/package.json").version;
11553
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11554
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11555
+ }
11556
+ return binding;
11557
+ } catch (e) {
11558
+ loadErrors.push(e);
11559
+ }
11560
+ if (process.arch === "x64") {
11561
+ try {
11562
+ return require2("./parser.darwin-x64.node");
11563
+ } catch (e) {
11564
+ loadErrors.push(e);
11565
+ }
11566
+ try {
11567
+ const binding = require2("@oxc-parser/binding-darwin-x64");
11568
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-x64/package.json").version;
11569
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11570
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11571
+ }
11572
+ return binding;
11573
+ } catch (e) {
11574
+ loadErrors.push(e);
11575
+ }
11576
+ } else if (process.arch === "arm64") {
11577
+ try {
11578
+ return require2("./parser.darwin-arm64.node");
11579
+ } catch (e) {
11580
+ loadErrors.push(e);
11581
+ }
11582
+ try {
11583
+ const binding = require2("@oxc-parser/binding-darwin-arm64");
11584
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-arm64/package.json").version;
11585
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11586
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11587
+ }
11588
+ return binding;
11589
+ } catch (e) {
11590
+ loadErrors.push(e);
11591
+ }
11592
+ } else {
11593
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
11594
+ }
11595
+ } else if (process.platform === "freebsd") {
11596
+ if (process.arch === "x64") {
11597
+ try {
11598
+ return require2("./parser.freebsd-x64.node");
11599
+ } catch (e) {
11600
+ loadErrors.push(e);
11601
+ }
11602
+ try {
11603
+ const binding = require2("@oxc-parser/binding-freebsd-x64");
11604
+ const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-x64/package.json").version;
11605
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11606
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11607
+ }
11608
+ return binding;
11609
+ } catch (e) {
11610
+ loadErrors.push(e);
11611
+ }
11612
+ } else if (process.arch === "arm64") {
11613
+ try {
11614
+ return require2("./parser.freebsd-arm64.node");
11615
+ } catch (e) {
11616
+ loadErrors.push(e);
11617
+ }
11618
+ try {
11619
+ const binding = require2("@oxc-parser/binding-freebsd-arm64");
11620
+ const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-arm64/package.json").version;
11621
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11622
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11623
+ }
11624
+ return binding;
11625
+ } catch (e) {
11626
+ loadErrors.push(e);
11627
+ }
11628
+ } else {
11629
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
11630
+ }
11631
+ } else if (process.platform === "linux") {
11632
+ if (process.arch === "x64") {
11633
+ if (isMusl()) {
11634
+ try {
11635
+ return require2("./parser.linux-x64-musl.node");
11636
+ } catch (e) {
11637
+ loadErrors.push(e);
11638
+ }
11639
+ try {
11640
+ const binding = require2("@oxc-parser/binding-linux-x64-musl");
11641
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-musl/package.json").version;
11642
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11643
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11644
+ }
11645
+ return binding;
11646
+ } catch (e) {
11647
+ loadErrors.push(e);
11648
+ }
11649
+ } else {
11650
+ try {
11651
+ return require2("./parser.linux-x64-gnu.node");
11652
+ } catch (e) {
11653
+ loadErrors.push(e);
11654
+ }
11655
+ try {
11656
+ const binding = require2("@oxc-parser/binding-linux-x64-gnu");
11657
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-gnu/package.json").version;
11658
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11659
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11660
+ }
11661
+ return binding;
11662
+ } catch (e) {
11663
+ loadErrors.push(e);
11664
+ }
11665
+ }
11666
+ } else if (process.arch === "arm64") {
11667
+ if (isMusl()) {
11668
+ try {
11669
+ return require2("./parser.linux-arm64-musl.node");
11670
+ } catch (e) {
11671
+ loadErrors.push(e);
11672
+ }
11673
+ try {
11674
+ const binding = require2("@oxc-parser/binding-linux-arm64-musl");
11675
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-musl/package.json").version;
11676
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11677
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11678
+ }
11679
+ return binding;
11680
+ } catch (e) {
11681
+ loadErrors.push(e);
11682
+ }
11683
+ } else {
11684
+ try {
11685
+ return require2("./parser.linux-arm64-gnu.node");
11686
+ } catch (e) {
11687
+ loadErrors.push(e);
11688
+ }
11689
+ try {
11690
+ const binding = require2("@oxc-parser/binding-linux-arm64-gnu");
11691
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-gnu/package.json").version;
11692
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11693
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11694
+ }
11695
+ return binding;
11696
+ } catch (e) {
11697
+ loadErrors.push(e);
11698
+ }
11699
+ }
11700
+ } else if (process.arch === "arm") {
11701
+ if (isMusl()) {
11702
+ try {
11703
+ return require2("./parser.linux-arm-musleabihf.node");
11704
+ } catch (e) {
11705
+ loadErrors.push(e);
11706
+ }
11707
+ try {
11708
+ const binding = require2("@oxc-parser/binding-linux-arm-musleabihf");
11709
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-musleabihf/package.json").version;
11710
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11711
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11712
+ }
11713
+ return binding;
11714
+ } catch (e) {
11715
+ loadErrors.push(e);
11716
+ }
11717
+ } else {
11718
+ try {
11719
+ return require2("./parser.linux-arm-gnueabihf.node");
11720
+ } catch (e) {
11721
+ loadErrors.push(e);
11722
+ }
11723
+ try {
11724
+ const binding = require2("@oxc-parser/binding-linux-arm-gnueabihf");
11725
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-gnueabihf/package.json").version;
11726
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11727
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11728
+ }
11729
+ return binding;
11730
+ } catch (e) {
11731
+ loadErrors.push(e);
11732
+ }
11733
+ }
11734
+ } else if (process.arch === "loong64") {
11735
+ if (isMusl()) {
11736
+ try {
11737
+ return require2("./parser.linux-loong64-musl.node");
11738
+ } catch (e) {
11739
+ loadErrors.push(e);
11740
+ }
11741
+ try {
11742
+ const binding = require2("@oxc-parser/binding-linux-loong64-musl");
11743
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-musl/package.json").version;
11744
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11745
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11746
+ }
11747
+ return binding;
11748
+ } catch (e) {
11749
+ loadErrors.push(e);
11750
+ }
11751
+ } else {
11752
+ try {
11753
+ return require2("./parser.linux-loong64-gnu.node");
11754
+ } catch (e) {
11755
+ loadErrors.push(e);
11756
+ }
11757
+ try {
11758
+ const binding = require2("@oxc-parser/binding-linux-loong64-gnu");
11759
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-gnu/package.json").version;
11760
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11761
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11762
+ }
11763
+ return binding;
11764
+ } catch (e) {
11765
+ loadErrors.push(e);
11766
+ }
11767
+ }
11768
+ } else if (process.arch === "riscv64") {
11769
+ if (isMusl()) {
11770
+ try {
11771
+ return require2("./parser.linux-riscv64-musl.node");
11772
+ } catch (e) {
11773
+ loadErrors.push(e);
11774
+ }
11775
+ try {
11776
+ const binding = require2("@oxc-parser/binding-linux-riscv64-musl");
11777
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-musl/package.json").version;
11778
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11779
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11780
+ }
11781
+ return binding;
11782
+ } catch (e) {
11783
+ loadErrors.push(e);
11784
+ }
11785
+ } else {
11786
+ try {
11787
+ return require2("./parser.linux-riscv64-gnu.node");
11788
+ } catch (e) {
11789
+ loadErrors.push(e);
11790
+ }
11791
+ try {
11792
+ const binding = require2("@oxc-parser/binding-linux-riscv64-gnu");
11793
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-gnu/package.json").version;
11794
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11795
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11796
+ }
11797
+ return binding;
11798
+ } catch (e) {
11799
+ loadErrors.push(e);
11800
+ }
11801
+ }
11802
+ } else if (process.arch === "ppc64") {
11803
+ try {
11804
+ return require2("./parser.linux-ppc64-gnu.node");
11805
+ } catch (e) {
11806
+ loadErrors.push(e);
11807
+ }
11808
+ try {
11809
+ const binding = require2("@oxc-parser/binding-linux-ppc64-gnu");
11810
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-ppc64-gnu/package.json").version;
11811
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11812
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11813
+ }
11814
+ return binding;
11815
+ } catch (e) {
11816
+ loadErrors.push(e);
11817
+ }
11818
+ } else if (process.arch === "s390x") {
11819
+ try {
11820
+ return require2("./parser.linux-s390x-gnu.node");
11821
+ } catch (e) {
11822
+ loadErrors.push(e);
11823
+ }
11824
+ try {
11825
+ const binding = require2("@oxc-parser/binding-linux-s390x-gnu");
11826
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-s390x-gnu/package.json").version;
11827
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11828
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11829
+ }
11830
+ return binding;
11831
+ } catch (e) {
11832
+ loadErrors.push(e);
11833
+ }
11834
+ } else {
11835
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
11836
+ }
11837
+ } else if (process.platform === "openharmony") {
11838
+ if (process.arch === "arm64") {
11839
+ try {
11840
+ return require2("./parser.openharmony-arm64.node");
11841
+ } catch (e) {
11842
+ loadErrors.push(e);
11843
+ }
11844
+ try {
11845
+ const binding = require2("@oxc-parser/binding-openharmony-arm64");
11846
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm64/package.json").version;
11847
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11848
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11849
+ }
11850
+ return binding;
11851
+ } catch (e) {
11852
+ loadErrors.push(e);
11853
+ }
11854
+ } else if (process.arch === "x64") {
11855
+ try {
11856
+ return require2("./parser.openharmony-x64.node");
11857
+ } catch (e) {
11858
+ loadErrors.push(e);
11859
+ }
11860
+ try {
11861
+ const binding = require2("@oxc-parser/binding-openharmony-x64");
11862
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-x64/package.json").version;
11863
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11864
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11865
+ }
11866
+ return binding;
11867
+ } catch (e) {
11868
+ loadErrors.push(e);
11869
+ }
11870
+ } else if (process.arch === "arm") {
11871
+ try {
11872
+ return require2("./parser.openharmony-arm.node");
11873
+ } catch (e) {
11874
+ loadErrors.push(e);
11875
+ }
11876
+ try {
11877
+ const binding = require2("@oxc-parser/binding-openharmony-arm");
11878
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm/package.json").version;
11879
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11880
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11881
+ }
11882
+ return binding;
11883
+ } catch (e) {
11884
+ loadErrors.push(e);
11885
+ }
11886
+ } else {
11887
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
11888
+ }
11889
+ } else {
11890
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
11891
+ }
11892
+ }
11893
+ nativeBinding = requireNative();
11894
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
11895
+ let wasiBinding = null;
11896
+ let wasiBindingError = null;
11897
+ try {
11898
+ wasiBinding = require2("./parser.wasi.cjs");
11899
+ nativeBinding = wasiBinding;
11900
+ } catch (err) {
11901
+ if (process.env.NAPI_RS_FORCE_WASI) {
11902
+ wasiBindingError = err;
11903
+ }
11904
+ }
11905
+ if (!nativeBinding) {
11906
+ try {
11907
+ wasiBinding = require2("@oxc-parser/binding-wasm32-wasi");
11908
+ nativeBinding = wasiBinding;
11909
+ } catch (err) {
11910
+ if (process.env.NAPI_RS_FORCE_WASI) {
11911
+ wasiBindingError.cause = err;
11912
+ loadErrors.push(err);
11913
+ }
11914
+ }
11915
+ }
11916
+ if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
11917
+ const error2 = new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
11918
+ error2.cause = wasiBindingError;
11919
+ throw error2;
11920
+ }
11921
+ }
11922
+ if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
11923
+ try {
11924
+ nativeBinding = require2("./webcontainer-fallback.cjs");
11925
+ } catch (err) {
11926
+ loadErrors.push(err);
11927
+ }
11928
+ }
11929
+ if (!nativeBinding) {
11930
+ if (loadErrors.length > 0) {
11931
+ throw new Error(`Cannot find native binding. ` + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + "Please try `npm i` again after removing both package-lock.json and node_modules directory.", {
11932
+ cause: loadErrors.reduce((err, cur) => {
11933
+ cur.cause = err;
11934
+ return cur;
11935
+ })
11936
+ });
11937
+ }
11938
+ throw new Error(`Failed to load native binding`);
11939
+ }
11940
+ var { Severity, ParseResult, ExportExportNameKind, ExportImportNameKind, ExportLocalNameKind, ImportNameKind, parse: parse3, parseSync, rawTransferSupported } = nativeBinding;
11941
+
11942
+ // node_modules/oxc-parser/src-js/wrap.js
11943
+ function wrap(result) {
11944
+ let program, module3, comments, errors4;
11945
+ return {
11946
+ get program() {
11947
+ if (!program)
11948
+ program = jsonParseAst(result.program);
11949
+ return program;
11950
+ },
11951
+ get module() {
11952
+ if (!module3)
11953
+ module3 = result.module;
11954
+ return module3;
11955
+ },
11956
+ get comments() {
11957
+ if (!comments)
11958
+ comments = result.comments;
11959
+ return comments;
11960
+ },
11961
+ get errors() {
11962
+ if (!errors4)
11963
+ errors4 = result.errors;
11964
+ return errors4;
11965
+ }
11966
+ };
11967
+ }
11968
+ function jsonParseAst(programJson) {
11969
+ const { node: program, fixes } = JSON.parse(programJson);
11970
+ for (const fixPath of fixes) {
11971
+ applyFix(program, fixPath);
11972
+ }
11973
+ return program;
11974
+ }
11975
+ function applyFix(program, fixPath) {
11976
+ let node = program;
11977
+ for (const key of fixPath) {
11978
+ node = node[key];
11979
+ }
11980
+ if (node.bigint) {
11981
+ node.value = BigInt(node.bigint);
11982
+ } else {
11983
+ try {
11984
+ node.value = RegExp(node.regex.pattern, node.regex.flags);
11985
+ } catch {}
11986
+ }
11987
+ }
11988
+
11989
+ // node_modules/oxc-parser/generated/visit/keys.js
11990
+ var { freeze } = Object;
11991
+ var $EMPTY = freeze([]);
11992
+ var DECORATORS__KEY__TYPE_ANNOTATION__VALUE = freeze([
11993
+ "decorators",
11994
+ "key",
11995
+ "typeAnnotation",
11996
+ "value"
11997
+ ]);
11998
+ var LEFT__RIGHT = freeze(["left", "right"]);
11999
+ var ARGUMENT = freeze(["argument"]);
12000
+ var BODY = freeze(["body"]);
12001
+ var LABEL = freeze(["label"]);
12002
+ var CALLEE__TYPE_ARGUMENTS__ARGUMENTS = freeze(["callee", "typeArguments", "arguments"]);
12003
+ var EXPRESSION = freeze(["expression"]);
12004
+ var DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY = freeze([
12005
+ "decorators",
12006
+ "id",
12007
+ "typeParameters",
12008
+ "superClass",
12009
+ "superTypeArguments",
12010
+ "implements",
12011
+ "body"
12012
+ ]);
12013
+ var TEST__CONSEQUENT__ALTERNATE = freeze(["test", "consequent", "alternate"]);
12014
+ var LEFT__RIGHT__BODY = freeze(["left", "right", "body"]);
12015
+ var ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY = freeze([
12016
+ "id",
12017
+ "typeParameters",
12018
+ "params",
12019
+ "returnType",
12020
+ "body"
12021
+ ]);
12022
+ var KEY__VALUE = freeze(["key", "value"]);
12023
+ var LOCAL = freeze(["local"]);
12024
+ var OBJECT__PROPERTY = freeze(["object", "property"]);
12025
+ var DECORATORS__KEY__TYPE_ANNOTATION = freeze(["decorators", "key", "typeAnnotation"]);
12026
+ var EXPRESSION__TYPE_ANNOTATION = freeze(["expression", "typeAnnotation"]);
12027
+ var TYPE_PARAMETERS__PARAMS__RETURN_TYPE = freeze(["typeParameters", "params", "returnType"]);
12028
+ var EXPRESSION__TYPE_ARGUMENTS = freeze(["expression", "typeArguments"]);
12029
+ var MEMBERS = freeze(["members"]);
12030
+ var ID__BODY = freeze(["id", "body"]);
12031
+ var TYPES = freeze(["types"]);
12032
+ var TYPE_ANNOTATION = freeze(["typeAnnotation"]);
12033
+ var PARAMS = freeze(["params"]);
12034
+ var keys_default = freeze({
12035
+ DebuggerStatement: $EMPTY,
12036
+ EmptyStatement: $EMPTY,
12037
+ Literal: $EMPTY,
12038
+ PrivateIdentifier: $EMPTY,
12039
+ Super: $EMPTY,
12040
+ TemplateElement: $EMPTY,
12041
+ ThisExpression: $EMPTY,
12042
+ JSXClosingFragment: $EMPTY,
12043
+ JSXEmptyExpression: $EMPTY,
12044
+ JSXIdentifier: $EMPTY,
12045
+ JSXOpeningFragment: $EMPTY,
12046
+ JSXText: $EMPTY,
12047
+ TSAnyKeyword: $EMPTY,
12048
+ TSBigIntKeyword: $EMPTY,
12049
+ TSBooleanKeyword: $EMPTY,
12050
+ TSIntrinsicKeyword: $EMPTY,
12051
+ TSJSDocUnknownType: $EMPTY,
12052
+ TSNeverKeyword: $EMPTY,
12053
+ TSNullKeyword: $EMPTY,
12054
+ TSNumberKeyword: $EMPTY,
12055
+ TSObjectKeyword: $EMPTY,
12056
+ TSStringKeyword: $EMPTY,
12057
+ TSSymbolKeyword: $EMPTY,
12058
+ TSThisType: $EMPTY,
12059
+ TSUndefinedKeyword: $EMPTY,
12060
+ TSUnknownKeyword: $EMPTY,
12061
+ TSVoidKeyword: $EMPTY,
12062
+ AccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION__VALUE,
12063
+ ArrayExpression: freeze(["elements"]),
12064
+ ArrayPattern: freeze(["decorators", "elements", "typeAnnotation"]),
12065
+ ArrowFunctionExpression: freeze(["typeParameters", "params", "returnType", "body"]),
12066
+ AssignmentExpression: LEFT__RIGHT,
12067
+ AssignmentPattern: freeze(["decorators", "left", "right", "typeAnnotation"]),
12068
+ AwaitExpression: ARGUMENT,
12069
+ BinaryExpression: LEFT__RIGHT,
12070
+ BlockStatement: BODY,
12071
+ BreakStatement: LABEL,
12072
+ CallExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS,
12073
+ CatchClause: freeze(["param", "body"]),
12074
+ ChainExpression: EXPRESSION,
12075
+ ClassBody: BODY,
12076
+ ClassDeclaration: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY,
12077
+ ClassExpression: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY,
12078
+ ConditionalExpression: TEST__CONSEQUENT__ALTERNATE,
12079
+ ContinueStatement: LABEL,
12080
+ Decorator: EXPRESSION,
12081
+ DoWhileStatement: freeze(["body", "test"]),
12082
+ ExportAllDeclaration: freeze(["exported", "source", "attributes"]),
12083
+ ExportDefaultDeclaration: freeze(["declaration"]),
12084
+ ExportNamedDeclaration: freeze(["declaration", "specifiers", "source", "attributes"]),
12085
+ ExportSpecifier: freeze(["local", "exported"]),
12086
+ ExpressionStatement: EXPRESSION,
12087
+ ForInStatement: LEFT__RIGHT__BODY,
12088
+ ForOfStatement: LEFT__RIGHT__BODY,
12089
+ ForStatement: freeze(["init", "test", "update", "body"]),
12090
+ FunctionDeclaration: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
12091
+ FunctionExpression: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
12092
+ Identifier: freeze(["decorators", "typeAnnotation"]),
12093
+ IfStatement: TEST__CONSEQUENT__ALTERNATE,
12094
+ ImportAttribute: KEY__VALUE,
12095
+ ImportDeclaration: freeze(["specifiers", "source", "attributes"]),
12096
+ ImportDefaultSpecifier: LOCAL,
12097
+ ImportExpression: freeze(["source", "options"]),
12098
+ ImportNamespaceSpecifier: LOCAL,
12099
+ ImportSpecifier: freeze(["imported", "local"]),
12100
+ LabeledStatement: freeze(["label", "body"]),
12101
+ LogicalExpression: LEFT__RIGHT,
12102
+ MemberExpression: OBJECT__PROPERTY,
12103
+ MetaProperty: freeze(["meta", "property"]),
12104
+ MethodDefinition: freeze(["decorators", "key", "value"]),
12105
+ NewExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS,
12106
+ ObjectExpression: freeze(["properties"]),
12107
+ ObjectPattern: freeze(["decorators", "properties", "typeAnnotation"]),
12108
+ ParenthesizedExpression: EXPRESSION,
12109
+ Program: BODY,
12110
+ Property: KEY__VALUE,
12111
+ PropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION__VALUE,
12112
+ RestElement: freeze(["decorators", "argument", "typeAnnotation"]),
12113
+ ReturnStatement: ARGUMENT,
12114
+ SequenceExpression: freeze(["expressions"]),
12115
+ SpreadElement: ARGUMENT,
12116
+ StaticBlock: BODY,
12117
+ SwitchCase: freeze(["test", "consequent"]),
12118
+ SwitchStatement: freeze(["discriminant", "cases"]),
12119
+ TaggedTemplateExpression: freeze(["tag", "typeArguments", "quasi"]),
12120
+ TemplateLiteral: freeze(["quasis", "expressions"]),
12121
+ ThrowStatement: ARGUMENT,
12122
+ TryStatement: freeze(["block", "handler", "finalizer"]),
12123
+ UnaryExpression: ARGUMENT,
12124
+ UpdateExpression: ARGUMENT,
12125
+ V8IntrinsicExpression: freeze(["name", "arguments"]),
12126
+ VariableDeclaration: freeze(["declarations"]),
12127
+ VariableDeclarator: freeze(["id", "init"]),
12128
+ WhileStatement: freeze(["test", "body"]),
12129
+ WithStatement: freeze(["object", "body"]),
12130
+ YieldExpression: ARGUMENT,
12131
+ JSXAttribute: freeze(["name", "value"]),
12132
+ JSXClosingElement: freeze(["name"]),
12133
+ JSXElement: freeze(["openingElement", "children", "closingElement"]),
12134
+ JSXExpressionContainer: EXPRESSION,
12135
+ JSXFragment: freeze(["openingFragment", "children", "closingFragment"]),
12136
+ JSXMemberExpression: OBJECT__PROPERTY,
12137
+ JSXNamespacedName: freeze(["namespace", "name"]),
12138
+ JSXOpeningElement: freeze(["name", "typeArguments", "attributes"]),
12139
+ JSXSpreadAttribute: ARGUMENT,
12140
+ JSXSpreadChild: EXPRESSION,
12141
+ TSAbstractAccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION,
12142
+ TSAbstractMethodDefinition: KEY__VALUE,
12143
+ TSAbstractPropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION,
12144
+ TSArrayType: freeze(["elementType"]),
12145
+ TSAsExpression: EXPRESSION__TYPE_ANNOTATION,
12146
+ TSCallSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
12147
+ TSClassImplements: EXPRESSION__TYPE_ARGUMENTS,
12148
+ TSConditionalType: freeze(["checkType", "extendsType", "trueType", "falseType"]),
12149
+ TSConstructSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
12150
+ TSConstructorType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
12151
+ TSDeclareFunction: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
12152
+ TSEmptyBodyFunctionExpression: freeze(["id", "typeParameters", "params", "returnType"]),
12153
+ TSEnumBody: MEMBERS,
12154
+ TSEnumDeclaration: ID__BODY,
12155
+ TSEnumMember: freeze(["id", "initializer"]),
12156
+ TSExportAssignment: EXPRESSION,
12157
+ TSExternalModuleReference: EXPRESSION,
12158
+ TSFunctionType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
12159
+ TSImportEqualsDeclaration: freeze(["id", "moduleReference"]),
12160
+ TSImportType: freeze(["argument", "options", "qualifier", "typeArguments"]),
12161
+ TSIndexSignature: freeze(["parameters", "typeAnnotation"]),
12162
+ TSIndexedAccessType: freeze(["objectType", "indexType"]),
12163
+ TSInferType: freeze(["typeParameter"]),
12164
+ TSInstantiationExpression: EXPRESSION__TYPE_ARGUMENTS,
12165
+ TSInterfaceBody: BODY,
12166
+ TSInterfaceDeclaration: freeze(["id", "typeParameters", "extends", "body"]),
12167
+ TSInterfaceHeritage: EXPRESSION__TYPE_ARGUMENTS,
12168
+ TSIntersectionType: TYPES,
12169
+ TSJSDocNonNullableType: TYPE_ANNOTATION,
12170
+ TSJSDocNullableType: TYPE_ANNOTATION,
12171
+ TSLiteralType: freeze(["literal"]),
12172
+ TSMappedType: freeze(["key", "constraint", "nameType", "typeAnnotation"]),
12173
+ TSMethodSignature: freeze(["key", "typeParameters", "params", "returnType"]),
12174
+ TSModuleBlock: BODY,
12175
+ TSModuleDeclaration: ID__BODY,
12176
+ TSNamedTupleMember: freeze(["label", "elementType"]),
12177
+ TSNamespaceExportDeclaration: freeze(["id"]),
12178
+ TSNonNullExpression: EXPRESSION,
12179
+ TSOptionalType: TYPE_ANNOTATION,
12180
+ TSParameterProperty: freeze(["decorators", "parameter"]),
12181
+ TSParenthesizedType: TYPE_ANNOTATION,
12182
+ TSPropertySignature: freeze(["key", "typeAnnotation"]),
12183
+ TSQualifiedName: LEFT__RIGHT,
12184
+ TSRestType: TYPE_ANNOTATION,
12185
+ TSSatisfiesExpression: EXPRESSION__TYPE_ANNOTATION,
12186
+ TSTemplateLiteralType: freeze(["quasis", "types"]),
12187
+ TSTupleType: freeze(["elementTypes"]),
12188
+ TSTypeAliasDeclaration: freeze(["id", "typeParameters", "typeAnnotation"]),
12189
+ TSTypeAnnotation: TYPE_ANNOTATION,
12190
+ TSTypeAssertion: freeze(["typeAnnotation", "expression"]),
12191
+ TSTypeLiteral: MEMBERS,
12192
+ TSTypeOperator: TYPE_ANNOTATION,
12193
+ TSTypeParameter: freeze(["name", "constraint", "default"]),
12194
+ TSTypeParameterDeclaration: PARAMS,
12195
+ TSTypeParameterInstantiation: PARAMS,
12196
+ TSTypePredicate: freeze(["parameterName", "typeAnnotation"]),
12197
+ TSTypeQuery: freeze(["exprName", "typeArguments"]),
12198
+ TSTypeReference: freeze(["typeName", "typeArguments"]),
12199
+ TSUnionType: TYPES
12200
+ });
12201
+ // node_modules/oxc-parser/src-js/visit/index.js
12202
+ import { createRequire as createRequire2 } from "node:module";
12203
+ var walkProgram = null;
12204
+ var addVisitorToCompiled;
12205
+ var createCompiledVisitor;
12206
+ var finalizeCompiledVisitor;
12207
+
12208
+ class Visitor {
12209
+ #compiledVisitor = null;
12210
+ constructor(visitor) {
12211
+ if (walkProgram === null) {
12212
+ const require3 = createRequire2(import.meta.url);
12213
+ ({ walkProgram } = require3("../../generated/visit/walk.js"));
12214
+ ({
12215
+ addVisitorToCompiled,
12216
+ createCompiledVisitor,
12217
+ finalizeCompiledVisitor
12218
+ } = require3("./visitor.js"));
12219
+ }
12220
+ const compiledVisitor = createCompiledVisitor();
12221
+ addVisitorToCompiled(visitor);
12222
+ const needsVisit = finalizeCompiledVisitor();
12223
+ if (needsVisit)
12224
+ this.#compiledVisitor = compiledVisitor;
12225
+ }
12226
+ visit(program) {
12227
+ const compiledVisitor = this.#compiledVisitor;
12228
+ if (compiledVisitor !== null)
12229
+ walkProgram(program, compiledVisitor);
12230
+ }
12231
+ }
12232
+
12233
+ // node_modules/oxc-parser/src-js/index.js
12234
+ var require3 = createRequire3(import.meta.url);
12235
+ var parseSyncRaw = null;
12236
+ var parseRaw;
12237
+ var parseSyncLazy = null;
12238
+ var parseLazy;
12239
+ var LazyVisitor;
12240
+ function loadRawTransfer() {
12241
+ if (parseSyncRaw === null) {
12242
+ ({ parseSyncRaw, parse: parseRaw } = require3("./raw-transfer/eager.js"));
12243
+ }
12244
+ }
12245
+ function loadRawTransferLazy() {
12246
+ if (parseSyncLazy === null) {
12247
+ ({ parseSyncLazy, parse: parseLazy, Visitor: LazyVisitor } = require3("./raw-transfer/lazy.js"));
12248
+ }
12249
+ }
12250
+ function parseSync2(filename, sourceText, options3) {
12251
+ if (options3?.experimentalRawTransfer) {
12252
+ loadRawTransfer();
12253
+ return parseSyncRaw(filename, sourceText, options3);
12254
+ }
12255
+ if (options3?.experimentalLazy) {
12256
+ loadRawTransferLazy();
12257
+ return parseSyncLazy(filename, sourceText, options3);
12258
+ }
12259
+ return wrap(parseSync(filename, sourceText, options3));
12260
+ }
12261
+
12262
+ // src/recognizers/detector.ts
12263
+ function recognize(detector, line) {
12264
+ const matches = detector.scan(line);
12265
+ if (matches === 0)
12266
+ return 0;
12267
+ return 1 - (1 - detector.probability) ** matches;
12268
+ }
12269
+
12270
+ // src/recognizers/code-recognizer.ts
12271
+ var PROBABILITY_THRESHOLD = 0.9;
12272
+ function computeProbability(detectors, line) {
12273
+ let probability = 0;
12274
+ for (const detector of detectors) {
12275
+ const detected = recognize(detector, line);
12276
+ probability = 1 - (1 - probability) * (1 - detected);
12277
+ }
12278
+ return probability;
12279
+ }
12280
+ function isLikelyCode(detectors, line) {
12281
+ return computeProbability(detectors, line) >= PROBABILITY_THRESHOLD;
12282
+ }
12283
+ function hasCodeLines(detectors, lines) {
12284
+ return lines.some((line) => isLikelyCode(detectors, line));
12285
+ }
12286
+
12287
+ // src/recognizers/camel-case-detector.ts
12288
+ function createCamelCaseDetector(probability) {
12289
+ return {
12290
+ probability,
12291
+ scan(line) {
12292
+ for (let index2 = 0;index2 < line.length - 1; index2 += 1) {
12293
+ const current = line.charAt(index2);
12294
+ const next = line.charAt(index2 + 1);
12295
+ if (current === current.toLowerCase() && next === next.toUpperCase() && next !== next.toLowerCase()) {
12296
+ return 1;
12297
+ }
12298
+ }
12299
+ return 0;
12300
+ }
12301
+ };
12302
+ }
12303
+
12304
+ // src/recognizers/contains-detector.ts
12305
+ var WHITESPACE_GLOBAL_REGEX = /\s+/g;
12306
+ var ESCAPE = /[-/\\^$*+?.()|[\]{}]/g;
12307
+ function escapeForRegex(value) {
12308
+ return value.replaceAll(ESCAPE, String.raw`\$&`);
12309
+ }
12310
+ function createContainsDetector(probability, patterns2) {
12311
+ const compiledPatterns = patterns2.map((pattern4) => typeof pattern4 === "string" ? new RegExp(escapeForRegex(pattern4), "g") : new RegExp(pattern4.source, "g"));
12312
+ return {
12313
+ probability,
12314
+ scan(line) {
12315
+ const compressed = line.replace(WHITESPACE_GLOBAL_REGEX, "");
12316
+ let total = 0;
12317
+ for (const pattern4 of compiledPatterns) {
12318
+ pattern4.lastIndex = 0;
12319
+ const matches = compressed.match(pattern4);
12320
+ if (matches)
12321
+ total += matches.length;
12322
+ }
12323
+ return total;
12324
+ }
12325
+ };
12326
+ }
12327
+
12328
+ // src/recognizers/end-with-detector.ts
12329
+ var WHITESPACE_REGEX = /\s/;
12330
+ function createEndWithDetector(probability, endings) {
12331
+ const endingsSet = new Set(endings);
12332
+ return {
12333
+ probability,
12334
+ scan(line) {
12335
+ for (let index2 = line.length - 1;index2 >= 0; index2 -= 1) {
12336
+ const char = line.charAt(index2);
12337
+ if (endingsSet.has(char))
12338
+ return 1;
12339
+ if (!WHITESPACE_REGEX.test(char) && char !== "*" && char !== "/")
12340
+ return 0;
12341
+ }
12342
+ return 0;
12343
+ }
12344
+ };
12345
+ }
12346
+
12347
+ // src/recognizers/keywords-detector.ts
12348
+ var WORD_SPLIT_REGEX = /[ \t(),{}]/;
12349
+ function createKeywordsDetector(probability, keywords) {
12350
+ const keywordsSet = new Set(keywords);
12351
+ return {
12352
+ probability,
12353
+ scan(line) {
12354
+ const words = line.split(WORD_SPLIT_REGEX);
12355
+ let count = 0;
12356
+ for (const word of words)
12357
+ if (keywordsSet.has(word))
12358
+ count += 1;
12359
+ return count;
12360
+ }
12361
+ };
12362
+ }
12363
+
12364
+ // src/recognizers/javascript-footprint.ts
12365
+ var JS_KEYWORDS = [
12366
+ "public",
12367
+ "abstract",
12368
+ "class",
12369
+ "implements",
12370
+ "extends",
12371
+ "return",
12372
+ "throw",
12373
+ "private",
12374
+ "protected",
12375
+ "enum",
12376
+ "continue",
12377
+ "assert",
12378
+ "boolean",
12379
+ "this",
12380
+ "instanceof",
12381
+ "interface",
12382
+ "static",
12383
+ "void",
12384
+ "super",
12385
+ "true",
12386
+ "case:",
12387
+ "let",
12388
+ "const",
12389
+ "var",
12390
+ "async",
12391
+ "await",
12392
+ "break",
12393
+ "yield",
12394
+ "typeof",
12395
+ "import",
12396
+ "export"
12397
+ ];
12398
+ var OPERATORS2 = ["++", "||", "&&", "===", "?.", "??"];
12399
+ var CODE_PATTERNS = [
12400
+ "for(",
12401
+ "if(",
12402
+ "while(",
12403
+ "catch(",
12404
+ "switch(",
12405
+ "try{",
12406
+ "else{",
12407
+ "this.",
12408
+ "window.",
12409
+ /;\s+\/\//,
12410
+ "import '",
12411
+ 'import "',
12412
+ "require("
12413
+ ];
12414
+ var LINE_ENDINGS = ["}", ";", "{"];
12415
+ function createJavaScriptDetectors() {
12416
+ return [
12417
+ createEndWithDetector(0.95, LINE_ENDINGS),
12418
+ createKeywordsDetector(0.7, OPERATORS2),
12419
+ createKeywordsDetector(0.3, JS_KEYWORDS),
12420
+ createContainsDetector(0.95, CODE_PATTERNS),
12421
+ createCamelCaseDetector(0.5)
12422
+ ];
12423
+ }
12424
+
12425
+ // src/rules/no-commented-code.ts
12426
+ var EXCLUDED_STATEMENTS = new Set(["BreakStatement", "LabeledStatement", "ContinueStatement"]);
12427
+ var detectors = createJavaScriptDetectors();
12428
+ function isCommentWithLocation(comment) {
12429
+ return comment.loc !== undefined && comment.range !== undefined;
12430
+ }
12431
+ function areAdjacentLineComments(previous, next, sourceCode) {
12432
+ const previousLine = previous.loc.start.line;
12433
+ const nextLine = next.loc.start.line;
12434
+ if (previousLine + 1 !== nextLine)
12435
+ return false;
12436
+ const commentForApi = {
12437
+ loc: previous.loc,
12438
+ range: previous.range,
12439
+ type: previous.type,
12440
+ value: previous.value
12441
+ };
12442
+ const tokenAfterPrevious = sourceCode.getTokenAfter(commentForApi);
12443
+ return !tokenAfterPrevious || tokenAfterPrevious.loc.start.line > nextLine;
12444
+ }
12445
+ function groupComments(comments, sourceCode) {
12446
+ const groups = new Array;
12447
+ let groupsSize = 0;
12448
+ let currentLineComments = new Array;
12449
+ let size = 0;
12450
+ for (const comment of comments) {
12451
+ if (!isCommentWithLocation(comment))
12452
+ continue;
12453
+ if (comment.type === "Block") {
12454
+ if (size > 0) {
12455
+ groups[groupsSize++] = {
12456
+ comments: currentLineComments,
12457
+ value: currentLineComments.map((c) => c.value).join(`
12458
+ `)
12459
+ };
12460
+ currentLineComments = [];
12461
+ size = 0;
12462
+ }
12463
+ groups[groupsSize++] = {
12464
+ comments: [comment],
12465
+ value: comment.value
12466
+ };
12467
+ } else if (size === 0)
12468
+ currentLineComments[size++] = comment;
12469
+ else {
12470
+ const lastComment = currentLineComments.at(-1);
12471
+ if (lastComment && areAdjacentLineComments(lastComment, comment, sourceCode)) {
12472
+ currentLineComments[size++] = comment;
12473
+ } else {
12474
+ groups[groupsSize++] = {
12475
+ comments: currentLineComments,
12476
+ value: currentLineComments.map(({ value }) => value).join(`
12477
+ `)
12478
+ };
12479
+ currentLineComments = [comment];
12480
+ size = 1;
12481
+ }
12482
+ }
12483
+ }
12484
+ if (size > 0) {
12485
+ groups[groupsSize++] = {
12486
+ comments: currentLineComments,
12487
+ value: currentLineComments.map(({ value }) => value).join(`
12488
+ `)
12489
+ };
12490
+ }
12491
+ return groups;
12492
+ }
12493
+ function injectMissingBraces(value) {
12494
+ const openCount = (value.match(/{/g) ?? []).length;
12495
+ const closeCount = (value.match(/}/g) ?? []).length;
12496
+ const diff2 = openCount - closeCount;
12497
+ if (diff2 > 0)
12498
+ return value + "}".repeat(diff2);
12499
+ if (diff2 < 0)
12500
+ return "{".repeat(-diff2) + value;
12501
+ return value;
12502
+ }
12503
+ function couldBeJsCode(input) {
12504
+ const lines = input.split(`
12505
+ `);
12506
+ return hasCodeLines(detectors, lines);
12507
+ }
12508
+ function isReturnOrThrowExclusion(statement) {
12509
+ if (statement.type !== "ReturnStatement" && statement.type !== "ThrowStatement")
12510
+ return false;
12511
+ return statement.argument === undefined || statement.argument.type === "Identifier";
12512
+ }
12513
+ function isUnaryPlusMinus(expression) {
12514
+ return expression.type === "UnaryExpression" && (expression.operator === "+" || expression.operator === "-");
12515
+ }
12516
+ function isExcludedLiteral(expression) {
12517
+ if (expression.type !== "Literal")
12518
+ return false;
12519
+ return typeof expression.value === "string" || typeof expression.value === "number";
12520
+ }
12521
+ function isRecord2(value) {
12522
+ return typeof value === "object" && value !== undefined;
12523
+ }
12524
+ function isParsedStatement(value) {
12525
+ if (!isRecord2(value))
12526
+ return false;
12527
+ return typeof value.type === "string";
12528
+ }
12529
+ function toParsedStatements(body) {
12530
+ const result = [];
12531
+ for (const item of body) {
12532
+ if (isParsedStatement(item))
12533
+ result.push(item);
12534
+ }
12535
+ return result;
12536
+ }
12537
+ function isExpressionExclusion(statement, codeText) {
12538
+ if (statement.type !== "ExpressionStatement")
12539
+ return false;
12540
+ const expression = statement.expression;
12541
+ if (!expression)
12542
+ return false;
12543
+ if (expression.type === "Identifier")
12544
+ return true;
12545
+ if (expression.type === "SequenceExpression")
12546
+ return true;
12547
+ if (isUnaryPlusMinus(expression))
12548
+ return true;
12549
+ if (isExcludedLiteral(expression))
12550
+ return true;
12551
+ if (!codeText.trimEnd().endsWith(";"))
12552
+ return true;
12553
+ return false;
12554
+ }
12555
+ function isExclusion(statements, codeText) {
12556
+ if (statements.length !== 1)
12557
+ return false;
12558
+ const statement = statements.at(0);
12559
+ if (!statement)
12560
+ return false;
12561
+ if (EXCLUDED_STATEMENTS.has(statement.type))
12562
+ return true;
12563
+ if (isReturnOrThrowExclusion(statement))
12564
+ return true;
12565
+ if (isExpressionExclusion(statement, codeText))
12566
+ return true;
12567
+ return false;
12568
+ }
12569
+ var ALLOWED_PARSE_ERROR_PATTERNS = [/A 'return' statement can only be used within a function body/];
12570
+ function hasOnlyAllowedErrors(errors4) {
12571
+ return errors4.every((error2) => ALLOWED_PARSE_ERROR_PATTERNS.some((pattern4) => pattern4.test(error2.message)));
12572
+ }
12573
+ function isValidParseResult(result) {
12574
+ const hasValidErrors = result.errors.length === 0 || hasOnlyAllowedErrors(result.errors);
12575
+ return hasValidErrors && result.program.body.length > 0;
12576
+ }
12577
+ function tryParse(value, filename) {
12578
+ const ext = path.extname(filename);
12579
+ const parseFilename = `file${ext || ".js"}`;
12580
+ const result = parseSync2(parseFilename, value);
12581
+ if (isValidParseResult(result))
12582
+ return result;
12583
+ if (ext !== ".tsx" && ext !== ".jsx") {
12584
+ const jsxResult = parseSync2("file.tsx", value);
12585
+ if (isValidParseResult(jsxResult))
12586
+ return jsxResult;
12587
+ }
12588
+ return;
12589
+ }
12590
+ function containsCode(value, filename) {
12591
+ if (!couldBeJsCode(value))
12592
+ return false;
12593
+ try {
12594
+ const result = tryParse(value, filename);
12595
+ if (!result)
12596
+ return false;
12597
+ const statements = toParsedStatements(result.program.body);
12598
+ return !isExclusion(statements, value);
12599
+ } catch {
12600
+ return false;
12601
+ }
12602
+ }
12603
+ var noCommentedCode = {
12604
+ create(context) {
12605
+ return {
12606
+ "Program:exit"() {
12607
+ const allComments = context.sourceCode.getAllComments();
12608
+ const groups = groupComments(allComments, context.sourceCode);
12609
+ for (const group of groups) {
12610
+ const trimmedValue = group.value.trim();
12611
+ if (trimmedValue === "}")
12612
+ continue;
12613
+ const balanced = injectMissingBraces(trimmedValue);
12614
+ if (containsCode(balanced, context.filename)) {
12615
+ const firstComment = group.comments.at(0);
12616
+ const lastComment = group.comments.at(-1);
12617
+ if (!firstComment || !lastComment)
12618
+ continue;
12619
+ context.report({
12620
+ loc: {
12621
+ end: lastComment.loc.end,
12622
+ start: firstComment.loc.start
12623
+ },
12624
+ messageId: "commentedCode",
12625
+ suggest: [
12626
+ {
12627
+ desc: "Remove this commented out code",
12628
+ fix(fixer) {
12629
+ return fixer.removeRange([firstComment.range[0], lastComment.range[1]]);
12630
+ }
12631
+ }
12632
+ ]
12633
+ });
12634
+ }
12635
+ }
12636
+ }
12637
+ };
12638
+ },
12639
+ meta: {
12640
+ docs: {
12641
+ description: "Disallow commented-out code",
12642
+ recommended: false
12643
+ },
12644
+ hasSuggestions: true,
12645
+ messages: {
12646
+ commentedCode: "Remove this commented out code."
12647
+ },
12648
+ schema: [],
12649
+ type: "suggestion"
12650
+ }
12651
+ };
12652
+ var no_commented_code_default = noCommentedCode;
12653
+
11163
12654
  // src/rules/use-hook-at-top-level.ts
11164
12655
  import { TSESTree as TSESTree10 } from "@typescript-eslint/types";
11165
12656
  var HOOK_NAME_PATTERN = /^use[A-Z]/;
@@ -11580,7 +13071,9 @@ var rules = {
11580
13071
  "ban-instances": ban_instances_default,
11581
13072
  "ban-react-fc": ban_react_fc_default,
11582
13073
  "enforce-ianitor-check-type": enforce_ianitor_check_type_default,
13074
+ "no-async-constructor": no_async_constructor_default,
11583
13075
  "no-color3-constructor": no_color3_constructor_default,
13076
+ "no-commented-code": no_commented_code_default,
11584
13077
  "no-instance-methods-without-this": no_instance_methods_without_this_default,
11585
13078
  "no-print": no_print_default,
11586
13079
  "no-shorthand-names": no_shorthand_names_default,
@@ -11602,6 +13095,7 @@ var recommended = {
11602
13095
  rules: {
11603
13096
  "cease-nonsense/ban-react-fc": "error",
11604
13097
  "cease-nonsense/enforce-ianitor-check-type": "error",
13098
+ "cease-nonsense/no-async-constructor": "error",
11605
13099
  "cease-nonsense/no-color3-constructor": "error",
11606
13100
  "cease-nonsense/no-instance-methods-without-this": "error",
11607
13101
  "cease-nonsense/no-print": "error",
@@ -11636,4 +13130,4 @@ export {
11636
13130
  createBanInstancesOptions
11637
13131
  };
11638
13132
 
11639
- //# debugId=42A0B9F9085ECD6764756E2164756E21
13133
+ //# debugId=F981FE172662E0F564756E2164756E21