@pobammer-ts/eslint-cease-nonsense-rules 1.3.0 → 1.4.1

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
@@ -10537,6 +10537,21 @@ var IS_FUNCTION_EXPRESSION = new Set([
10537
10537
  TSESTree8.AST_NODE_TYPES.FunctionExpression,
10538
10538
  TSESTree8.AST_NODE_TYPES.ArrowFunctionExpression
10539
10539
  ]);
10540
+ var CONTROL_FLOW_TYPES = new Set([
10541
+ TSESTree8.AST_NODE_TYPES.BlockStatement,
10542
+ TSESTree8.AST_NODE_TYPES.IfStatement,
10543
+ TSESTree8.AST_NODE_TYPES.SwitchStatement,
10544
+ TSESTree8.AST_NODE_TYPES.SwitchCase,
10545
+ TSESTree8.AST_NODE_TYPES.TryStatement,
10546
+ TSESTree8.AST_NODE_TYPES.CatchClause,
10547
+ TSESTree8.AST_NODE_TYPES.WhileStatement,
10548
+ TSESTree8.AST_NODE_TYPES.DoWhileStatement,
10549
+ TSESTree8.AST_NODE_TYPES.ForStatement,
10550
+ TSESTree8.AST_NODE_TYPES.ForInStatement,
10551
+ TSESTree8.AST_NODE_TYPES.ForOfStatement,
10552
+ TSESTree8.AST_NODE_TYPES.LabeledStatement,
10553
+ TSESTree8.AST_NODE_TYPES.WithStatement
10554
+ ]);
10540
10555
  function isTopLevelReturn(node) {
10541
10556
  let parent = ascendPastWrappers(node.parent);
10542
10557
  if (!parent)
@@ -10555,7 +10570,7 @@ function isTopLevelReturn(node) {
10555
10570
  return false;
10556
10571
  if (parent.type === TSESTree8.AST_NODE_TYPES.ReturnStatement) {
10557
10572
  let currentNode = ascendPastWrappers(parent.parent);
10558
- if (currentNode?.type === TSESTree8.AST_NODE_TYPES.BlockStatement)
10573
+ while (currentNode && CONTROL_FLOW_TYPES.has(currentNode.type))
10559
10574
  currentNode = ascendPastWrappers(currentNode.parent);
10560
10575
  if (!currentNode)
10561
10576
  return false;
@@ -10614,6 +10629,25 @@ function isJSXPropValue(node) {
10614
10629
  }
10615
10630
  return parent.type === TSESTree8.AST_NODE_TYPES.JSXAttribute;
10616
10631
  }
10632
+ function isTernaryJSXChild(node) {
10633
+ let current = node.parent;
10634
+ if (!current)
10635
+ return false;
10636
+ let foundTernary = false;
10637
+ while (current && (current.type === TSESTree8.AST_NODE_TYPES.ConditionalExpression || WRAPPER_PARENT_TYPES.has(current.type))) {
10638
+ if (current.type === TSESTree8.AST_NODE_TYPES.ConditionalExpression)
10639
+ foundTernary = true;
10640
+ current = current.parent;
10641
+ }
10642
+ if (!foundTernary || !current)
10643
+ return false;
10644
+ if (current.type !== TSESTree8.AST_NODE_TYPES.JSXExpressionContainer)
10645
+ return false;
10646
+ const containerParent = current.parent;
10647
+ if (!containerParent)
10648
+ return false;
10649
+ return containerParent.type === TSESTree8.AST_NODE_TYPES.JSXElement || containerParent.type === TSESTree8.AST_NODE_TYPES.JSXFragment;
10650
+ }
10617
10651
  var docs3 = {
10618
10652
  description: "Enforce key props on all React elements except top-level returns",
10619
10653
  recommended: true
@@ -10643,6 +10677,8 @@ var requireReactComponentKeys = {
10643
10677
  return;
10644
10678
  if (isJSXPropValue(node))
10645
10679
  return;
10680
+ if (isTernaryJSXChild(node))
10681
+ return;
10646
10682
  if (node.type === TSESTree8.AST_NODE_TYPES.JSXFragment) {
10647
10683
  context.report({
10648
10684
  messageId: "missingKey",
@@ -10823,6 +10859,8 @@ function getHookName2(node) {
10823
10859
  function getMemberExpressionDepth(node) {
10824
10860
  let depth = 0;
10825
10861
  let current = node;
10862
+ if (current.type === TSESTree9.AST_NODE_TYPES.ChainExpression)
10863
+ current = current.expression;
10826
10864
  while (current.type === TSESTree9.AST_NODE_TYPES.MemberExpression) {
10827
10865
  depth += 1;
10828
10866
  current = current.object;
@@ -10831,6 +10869,8 @@ function getMemberExpressionDepth(node) {
10831
10869
  }
10832
10870
  function getRootIdentifier(node) {
10833
10871
  let current = node;
10872
+ if (current.type === TSESTree9.AST_NODE_TYPES.ChainExpression)
10873
+ current = current.expression;
10834
10874
  while (current.type === TSESTree9.AST_NODE_TYPES.MemberExpression)
10835
10875
  current = current.object;
10836
10876
  return current.type === TSESTree9.AST_NODE_TYPES.Identifier ? current : undefined;
@@ -10909,7 +10949,16 @@ function isStableValue(variable, identifierName, stableHooks) {
10909
10949
  function findTopmostMemberExpression(node) {
10910
10950
  let current = node;
10911
10951
  let { parent } = node;
10912
- while (parent?.type === TSESTree9.AST_NODE_TYPES.MemberExpression && parent.object === current) {
10952
+ while (parent) {
10953
+ if (parent.type === TSESTree9.AST_NODE_TYPES.CallExpression && parent.callee === current) {
10954
+ if (current.type === TSESTree9.AST_NODE_TYPES.MemberExpression)
10955
+ return current.object;
10956
+ break;
10957
+ }
10958
+ const isMemberParent = parent.type === TSESTree9.AST_NODE_TYPES.MemberExpression && parent.object === current;
10959
+ const isChainParent = parent.type === TSESTree9.AST_NODE_TYPES.ChainExpression;
10960
+ if (!isMemberParent && !isChainParent)
10961
+ break;
10913
10962
  current = parent;
10914
10963
  parent = parent.parent;
10915
10964
  }
@@ -11030,6 +11079,10 @@ function collectCaptures(node, sourceCode) {
11030
11079
  visit(current.property);
11031
11080
  return;
11032
11081
  }
11082
+ if (current.type === TSESTree9.AST_NODE_TYPES.ChainExpression) {
11083
+ visit(current.expression);
11084
+ return;
11085
+ }
11033
11086
  const keys2 = sourceCode.visitorKeys?.[current.type] ?? [];
11034
11087
  for (const key of keys2) {
11035
11088
  const value = current[key];
@@ -11368,6 +11421,1289 @@ var useExhaustiveDependencies = {
11368
11421
  };
11369
11422
  var use_exhaustive_dependencies_default = useExhaustiveDependencies;
11370
11423
 
11424
+ // src/rules/no-commented-code.ts
11425
+ import path from "node:path";
11426
+
11427
+ // node_modules/oxc-parser/src-js/index.js
11428
+ import { createRequire as createRequire3 } from "node:module";
11429
+
11430
+ // node_modules/oxc-parser/src-js/bindings.js
11431
+ import { createRequire } from "node:module";
11432
+ var require2 = createRequire(import.meta.url);
11433
+ var __dirname2 = new URL(".", import.meta.url).pathname;
11434
+ var { readFileSync } = require2("node:fs");
11435
+ var nativeBinding = null;
11436
+ var loadErrors = [];
11437
+ var isMusl = () => {
11438
+ let musl = false;
11439
+ if (process.platform === "linux") {
11440
+ musl = isMuslFromFilesystem();
11441
+ if (musl === null) {
11442
+ musl = isMuslFromReport();
11443
+ }
11444
+ if (musl === null) {
11445
+ musl = isMuslFromChildProcess();
11446
+ }
11447
+ }
11448
+ return musl;
11449
+ };
11450
+ var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
11451
+ var isMuslFromFilesystem = () => {
11452
+ try {
11453
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
11454
+ } catch {
11455
+ return null;
11456
+ }
11457
+ };
11458
+ var isMuslFromReport = () => {
11459
+ let report = null;
11460
+ if (typeof process.report?.getReport === "function") {
11461
+ process.report.excludeNetwork = true;
11462
+ report = process.report.getReport();
11463
+ }
11464
+ if (!report) {
11465
+ return null;
11466
+ }
11467
+ if (report.header && report.header.glibcVersionRuntime) {
11468
+ return false;
11469
+ }
11470
+ if (Array.isArray(report.sharedObjects)) {
11471
+ if (report.sharedObjects.some(isFileMusl)) {
11472
+ return true;
11473
+ }
11474
+ }
11475
+ return false;
11476
+ };
11477
+ var isMuslFromChildProcess = () => {
11478
+ try {
11479
+ return require2("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
11480
+ } catch (e) {
11481
+ return false;
11482
+ }
11483
+ };
11484
+ function requireNative() {
11485
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
11486
+ try {
11487
+ return require2(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
11488
+ } catch (err) {
11489
+ loadErrors.push(err);
11490
+ }
11491
+ } else if (process.platform === "android") {
11492
+ if (process.arch === "arm64") {
11493
+ try {
11494
+ return require2("./parser.android-arm64.node");
11495
+ } catch (e) {
11496
+ loadErrors.push(e);
11497
+ }
11498
+ try {
11499
+ const binding = require2("@oxc-parser/binding-android-arm64");
11500
+ const bindingPackageVersion = require2("@oxc-parser/binding-android-arm64/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
+ } else if (process.arch === "arm") {
11509
+ try {
11510
+ return require2("./parser.android-arm-eabi.node");
11511
+ } catch (e) {
11512
+ loadErrors.push(e);
11513
+ }
11514
+ try {
11515
+ const binding = require2("@oxc-parser/binding-android-arm-eabi");
11516
+ const bindingPackageVersion = require2("@oxc-parser/binding-android-arm-eabi/package.json").version;
11517
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11518
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11519
+ }
11520
+ return binding;
11521
+ } catch (e) {
11522
+ loadErrors.push(e);
11523
+ }
11524
+ } else {
11525
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
11526
+ }
11527
+ } else if (process.platform === "win32") {
11528
+ if (process.arch === "x64") {
11529
+ if (process.config?.variables?.shlib_suffix === "dll.a" || process.config?.variables?.node_target_type === "shared_library") {
11530
+ try {
11531
+ return require2("./parser.win32-x64-gnu.node");
11532
+ } catch (e) {
11533
+ loadErrors.push(e);
11534
+ }
11535
+ try {
11536
+ const binding = require2("@oxc-parser/binding-win32-x64-gnu");
11537
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-gnu/package.json").version;
11538
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11539
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11540
+ }
11541
+ return binding;
11542
+ } catch (e) {
11543
+ loadErrors.push(e);
11544
+ }
11545
+ } else {
11546
+ try {
11547
+ return require2("./parser.win32-x64-msvc.node");
11548
+ } catch (e) {
11549
+ loadErrors.push(e);
11550
+ }
11551
+ try {
11552
+ const binding = require2("@oxc-parser/binding-win32-x64-msvc");
11553
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-msvc/package.json").version;
11554
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11555
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11556
+ }
11557
+ return binding;
11558
+ } catch (e) {
11559
+ loadErrors.push(e);
11560
+ }
11561
+ }
11562
+ } else if (process.arch === "ia32") {
11563
+ try {
11564
+ return require2("./parser.win32-ia32-msvc.node");
11565
+ } catch (e) {
11566
+ loadErrors.push(e);
11567
+ }
11568
+ try {
11569
+ const binding = require2("@oxc-parser/binding-win32-ia32-msvc");
11570
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-ia32-msvc/package.json").version;
11571
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11572
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11573
+ }
11574
+ return binding;
11575
+ } catch (e) {
11576
+ loadErrors.push(e);
11577
+ }
11578
+ } else if (process.arch === "arm64") {
11579
+ try {
11580
+ return require2("./parser.win32-arm64-msvc.node");
11581
+ } catch (e) {
11582
+ loadErrors.push(e);
11583
+ }
11584
+ try {
11585
+ const binding = require2("@oxc-parser/binding-win32-arm64-msvc");
11586
+ const bindingPackageVersion = require2("@oxc-parser/binding-win32-arm64-msvc/package.json").version;
11587
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11588
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11589
+ }
11590
+ return binding;
11591
+ } catch (e) {
11592
+ loadErrors.push(e);
11593
+ }
11594
+ } else {
11595
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
11596
+ }
11597
+ } else if (process.platform === "darwin") {
11598
+ try {
11599
+ return require2("./parser.darwin-universal.node");
11600
+ } catch (e) {
11601
+ loadErrors.push(e);
11602
+ }
11603
+ try {
11604
+ const binding = require2("@oxc-parser/binding-darwin-universal");
11605
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-universal/package.json").version;
11606
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11607
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11608
+ }
11609
+ return binding;
11610
+ } catch (e) {
11611
+ loadErrors.push(e);
11612
+ }
11613
+ if (process.arch === "x64") {
11614
+ try {
11615
+ return require2("./parser.darwin-x64.node");
11616
+ } catch (e) {
11617
+ loadErrors.push(e);
11618
+ }
11619
+ try {
11620
+ const binding = require2("@oxc-parser/binding-darwin-x64");
11621
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-x64/package.json").version;
11622
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11623
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11624
+ }
11625
+ return binding;
11626
+ } catch (e) {
11627
+ loadErrors.push(e);
11628
+ }
11629
+ } else if (process.arch === "arm64") {
11630
+ try {
11631
+ return require2("./parser.darwin-arm64.node");
11632
+ } catch (e) {
11633
+ loadErrors.push(e);
11634
+ }
11635
+ try {
11636
+ const binding = require2("@oxc-parser/binding-darwin-arm64");
11637
+ const bindingPackageVersion = require2("@oxc-parser/binding-darwin-arm64/package.json").version;
11638
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11639
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11640
+ }
11641
+ return binding;
11642
+ } catch (e) {
11643
+ loadErrors.push(e);
11644
+ }
11645
+ } else {
11646
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
11647
+ }
11648
+ } else if (process.platform === "freebsd") {
11649
+ if (process.arch === "x64") {
11650
+ try {
11651
+ return require2("./parser.freebsd-x64.node");
11652
+ } catch (e) {
11653
+ loadErrors.push(e);
11654
+ }
11655
+ try {
11656
+ const binding = require2("@oxc-parser/binding-freebsd-x64");
11657
+ const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-x64/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
+ } else if (process.arch === "arm64") {
11666
+ try {
11667
+ return require2("./parser.freebsd-arm64.node");
11668
+ } catch (e) {
11669
+ loadErrors.push(e);
11670
+ }
11671
+ try {
11672
+ const binding = require2("@oxc-parser/binding-freebsd-arm64");
11673
+ const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-arm64/package.json").version;
11674
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11675
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11676
+ }
11677
+ return binding;
11678
+ } catch (e) {
11679
+ loadErrors.push(e);
11680
+ }
11681
+ } else {
11682
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
11683
+ }
11684
+ } else if (process.platform === "linux") {
11685
+ if (process.arch === "x64") {
11686
+ if (isMusl()) {
11687
+ try {
11688
+ return require2("./parser.linux-x64-musl.node");
11689
+ } catch (e) {
11690
+ loadErrors.push(e);
11691
+ }
11692
+ try {
11693
+ const binding = require2("@oxc-parser/binding-linux-x64-musl");
11694
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-musl/package.json").version;
11695
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11696
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11697
+ }
11698
+ return binding;
11699
+ } catch (e) {
11700
+ loadErrors.push(e);
11701
+ }
11702
+ } else {
11703
+ try {
11704
+ return require2("./parser.linux-x64-gnu.node");
11705
+ } catch (e) {
11706
+ loadErrors.push(e);
11707
+ }
11708
+ try {
11709
+ const binding = require2("@oxc-parser/binding-linux-x64-gnu");
11710
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-gnu/package.json").version;
11711
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11712
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11713
+ }
11714
+ return binding;
11715
+ } catch (e) {
11716
+ loadErrors.push(e);
11717
+ }
11718
+ }
11719
+ } else if (process.arch === "arm64") {
11720
+ if (isMusl()) {
11721
+ try {
11722
+ return require2("./parser.linux-arm64-musl.node");
11723
+ } catch (e) {
11724
+ loadErrors.push(e);
11725
+ }
11726
+ try {
11727
+ const binding = require2("@oxc-parser/binding-linux-arm64-musl");
11728
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-musl/package.json").version;
11729
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11730
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11731
+ }
11732
+ return binding;
11733
+ } catch (e) {
11734
+ loadErrors.push(e);
11735
+ }
11736
+ } else {
11737
+ try {
11738
+ return require2("./parser.linux-arm64-gnu.node");
11739
+ } catch (e) {
11740
+ loadErrors.push(e);
11741
+ }
11742
+ try {
11743
+ const binding = require2("@oxc-parser/binding-linux-arm64-gnu");
11744
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-gnu/package.json").version;
11745
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11746
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11747
+ }
11748
+ return binding;
11749
+ } catch (e) {
11750
+ loadErrors.push(e);
11751
+ }
11752
+ }
11753
+ } else if (process.arch === "arm") {
11754
+ if (isMusl()) {
11755
+ try {
11756
+ return require2("./parser.linux-arm-musleabihf.node");
11757
+ } catch (e) {
11758
+ loadErrors.push(e);
11759
+ }
11760
+ try {
11761
+ const binding = require2("@oxc-parser/binding-linux-arm-musleabihf");
11762
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-musleabihf/package.json").version;
11763
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11764
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11765
+ }
11766
+ return binding;
11767
+ } catch (e) {
11768
+ loadErrors.push(e);
11769
+ }
11770
+ } else {
11771
+ try {
11772
+ return require2("./parser.linux-arm-gnueabihf.node");
11773
+ } catch (e) {
11774
+ loadErrors.push(e);
11775
+ }
11776
+ try {
11777
+ const binding = require2("@oxc-parser/binding-linux-arm-gnueabihf");
11778
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-gnueabihf/package.json").version;
11779
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11780
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11781
+ }
11782
+ return binding;
11783
+ } catch (e) {
11784
+ loadErrors.push(e);
11785
+ }
11786
+ }
11787
+ } else if (process.arch === "loong64") {
11788
+ if (isMusl()) {
11789
+ try {
11790
+ return require2("./parser.linux-loong64-musl.node");
11791
+ } catch (e) {
11792
+ loadErrors.push(e);
11793
+ }
11794
+ try {
11795
+ const binding = require2("@oxc-parser/binding-linux-loong64-musl");
11796
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-musl/package.json").version;
11797
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11798
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11799
+ }
11800
+ return binding;
11801
+ } catch (e) {
11802
+ loadErrors.push(e);
11803
+ }
11804
+ } else {
11805
+ try {
11806
+ return require2("./parser.linux-loong64-gnu.node");
11807
+ } catch (e) {
11808
+ loadErrors.push(e);
11809
+ }
11810
+ try {
11811
+ const binding = require2("@oxc-parser/binding-linux-loong64-gnu");
11812
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-gnu/package.json").version;
11813
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11814
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11815
+ }
11816
+ return binding;
11817
+ } catch (e) {
11818
+ loadErrors.push(e);
11819
+ }
11820
+ }
11821
+ } else if (process.arch === "riscv64") {
11822
+ if (isMusl()) {
11823
+ try {
11824
+ return require2("./parser.linux-riscv64-musl.node");
11825
+ } catch (e) {
11826
+ loadErrors.push(e);
11827
+ }
11828
+ try {
11829
+ const binding = require2("@oxc-parser/binding-linux-riscv64-musl");
11830
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-musl/package.json").version;
11831
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11832
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11833
+ }
11834
+ return binding;
11835
+ } catch (e) {
11836
+ loadErrors.push(e);
11837
+ }
11838
+ } else {
11839
+ try {
11840
+ return require2("./parser.linux-riscv64-gnu.node");
11841
+ } catch (e) {
11842
+ loadErrors.push(e);
11843
+ }
11844
+ try {
11845
+ const binding = require2("@oxc-parser/binding-linux-riscv64-gnu");
11846
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-gnu/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
+ }
11855
+ } else if (process.arch === "ppc64") {
11856
+ try {
11857
+ return require2("./parser.linux-ppc64-gnu.node");
11858
+ } catch (e) {
11859
+ loadErrors.push(e);
11860
+ }
11861
+ try {
11862
+ const binding = require2("@oxc-parser/binding-linux-ppc64-gnu");
11863
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-ppc64-gnu/package.json").version;
11864
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11865
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11866
+ }
11867
+ return binding;
11868
+ } catch (e) {
11869
+ loadErrors.push(e);
11870
+ }
11871
+ } else if (process.arch === "s390x") {
11872
+ try {
11873
+ return require2("./parser.linux-s390x-gnu.node");
11874
+ } catch (e) {
11875
+ loadErrors.push(e);
11876
+ }
11877
+ try {
11878
+ const binding = require2("@oxc-parser/binding-linux-s390x-gnu");
11879
+ const bindingPackageVersion = require2("@oxc-parser/binding-linux-s390x-gnu/package.json").version;
11880
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11881
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11882
+ }
11883
+ return binding;
11884
+ } catch (e) {
11885
+ loadErrors.push(e);
11886
+ }
11887
+ } else {
11888
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
11889
+ }
11890
+ } else if (process.platform === "openharmony") {
11891
+ if (process.arch === "arm64") {
11892
+ try {
11893
+ return require2("./parser.openharmony-arm64.node");
11894
+ } catch (e) {
11895
+ loadErrors.push(e);
11896
+ }
11897
+ try {
11898
+ const binding = require2("@oxc-parser/binding-openharmony-arm64");
11899
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm64/package.json").version;
11900
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11901
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11902
+ }
11903
+ return binding;
11904
+ } catch (e) {
11905
+ loadErrors.push(e);
11906
+ }
11907
+ } else if (process.arch === "x64") {
11908
+ try {
11909
+ return require2("./parser.openharmony-x64.node");
11910
+ } catch (e) {
11911
+ loadErrors.push(e);
11912
+ }
11913
+ try {
11914
+ const binding = require2("@oxc-parser/binding-openharmony-x64");
11915
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-x64/package.json").version;
11916
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11917
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11918
+ }
11919
+ return binding;
11920
+ } catch (e) {
11921
+ loadErrors.push(e);
11922
+ }
11923
+ } else if (process.arch === "arm") {
11924
+ try {
11925
+ return require2("./parser.openharmony-arm.node");
11926
+ } catch (e) {
11927
+ loadErrors.push(e);
11928
+ }
11929
+ try {
11930
+ const binding = require2("@oxc-parser/binding-openharmony-arm");
11931
+ const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm/package.json").version;
11932
+ if (bindingPackageVersion !== "0.101.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
11933
+ throw new Error(`Native binding package version mismatch, expected 0.101.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
11934
+ }
11935
+ return binding;
11936
+ } catch (e) {
11937
+ loadErrors.push(e);
11938
+ }
11939
+ } else {
11940
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
11941
+ }
11942
+ } else {
11943
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
11944
+ }
11945
+ }
11946
+ nativeBinding = requireNative();
11947
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
11948
+ let wasiBinding = null;
11949
+ let wasiBindingError = null;
11950
+ try {
11951
+ wasiBinding = require2("./parser.wasi.cjs");
11952
+ nativeBinding = wasiBinding;
11953
+ } catch (err) {
11954
+ if (process.env.NAPI_RS_FORCE_WASI) {
11955
+ wasiBindingError = err;
11956
+ }
11957
+ }
11958
+ if (!nativeBinding) {
11959
+ try {
11960
+ wasiBinding = require2("@oxc-parser/binding-wasm32-wasi");
11961
+ nativeBinding = wasiBinding;
11962
+ } catch (err) {
11963
+ if (process.env.NAPI_RS_FORCE_WASI) {
11964
+ wasiBindingError.cause = err;
11965
+ loadErrors.push(err);
11966
+ }
11967
+ }
11968
+ }
11969
+ if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
11970
+ const error2 = new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
11971
+ error2.cause = wasiBindingError;
11972
+ throw error2;
11973
+ }
11974
+ }
11975
+ if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
11976
+ try {
11977
+ nativeBinding = require2("./webcontainer-fallback.cjs");
11978
+ } catch (err) {
11979
+ loadErrors.push(err);
11980
+ }
11981
+ }
11982
+ if (!nativeBinding) {
11983
+ if (loadErrors.length > 0) {
11984
+ 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.", {
11985
+ cause: loadErrors.reduce((err, cur) => {
11986
+ cur.cause = err;
11987
+ return cur;
11988
+ })
11989
+ });
11990
+ }
11991
+ throw new Error(`Failed to load native binding`);
11992
+ }
11993
+ var { Severity, ParseResult, ExportExportNameKind, ExportImportNameKind, ExportLocalNameKind, ImportNameKind, parse: parse3, parseSync, rawTransferSupported } = nativeBinding;
11994
+
11995
+ // node_modules/oxc-parser/src-js/wrap.js
11996
+ function wrap(result) {
11997
+ let program, module3, comments, errors4;
11998
+ return {
11999
+ get program() {
12000
+ if (!program)
12001
+ program = jsonParseAst(result.program);
12002
+ return program;
12003
+ },
12004
+ get module() {
12005
+ if (!module3)
12006
+ module3 = result.module;
12007
+ return module3;
12008
+ },
12009
+ get comments() {
12010
+ if (!comments)
12011
+ comments = result.comments;
12012
+ return comments;
12013
+ },
12014
+ get errors() {
12015
+ if (!errors4)
12016
+ errors4 = result.errors;
12017
+ return errors4;
12018
+ }
12019
+ };
12020
+ }
12021
+ function jsonParseAst(programJson) {
12022
+ const { node: program, fixes } = JSON.parse(programJson);
12023
+ for (const fixPath of fixes) {
12024
+ applyFix(program, fixPath);
12025
+ }
12026
+ return program;
12027
+ }
12028
+ function applyFix(program, fixPath) {
12029
+ let node = program;
12030
+ for (const key of fixPath) {
12031
+ node = node[key];
12032
+ }
12033
+ if (node.bigint) {
12034
+ node.value = BigInt(node.bigint);
12035
+ } else {
12036
+ try {
12037
+ node.value = RegExp(node.regex.pattern, node.regex.flags);
12038
+ } catch {}
12039
+ }
12040
+ }
12041
+
12042
+ // node_modules/oxc-parser/generated/visit/keys.js
12043
+ var { freeze } = Object;
12044
+ var $EMPTY = freeze([]);
12045
+ var DECORATORS__KEY__TYPE_ANNOTATION__VALUE = freeze([
12046
+ "decorators",
12047
+ "key",
12048
+ "typeAnnotation",
12049
+ "value"
12050
+ ]);
12051
+ var LEFT__RIGHT = freeze(["left", "right"]);
12052
+ var ARGUMENT = freeze(["argument"]);
12053
+ var BODY = freeze(["body"]);
12054
+ var LABEL = freeze(["label"]);
12055
+ var CALLEE__TYPE_ARGUMENTS__ARGUMENTS = freeze(["callee", "typeArguments", "arguments"]);
12056
+ var EXPRESSION = freeze(["expression"]);
12057
+ var DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY = freeze([
12058
+ "decorators",
12059
+ "id",
12060
+ "typeParameters",
12061
+ "superClass",
12062
+ "superTypeArguments",
12063
+ "implements",
12064
+ "body"
12065
+ ]);
12066
+ var TEST__CONSEQUENT__ALTERNATE = freeze(["test", "consequent", "alternate"]);
12067
+ var LEFT__RIGHT__BODY = freeze(["left", "right", "body"]);
12068
+ var ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY = freeze([
12069
+ "id",
12070
+ "typeParameters",
12071
+ "params",
12072
+ "returnType",
12073
+ "body"
12074
+ ]);
12075
+ var KEY__VALUE = freeze(["key", "value"]);
12076
+ var LOCAL = freeze(["local"]);
12077
+ var OBJECT__PROPERTY = freeze(["object", "property"]);
12078
+ var DECORATORS__KEY__TYPE_ANNOTATION = freeze(["decorators", "key", "typeAnnotation"]);
12079
+ var EXPRESSION__TYPE_ANNOTATION = freeze(["expression", "typeAnnotation"]);
12080
+ var TYPE_PARAMETERS__PARAMS__RETURN_TYPE = freeze(["typeParameters", "params", "returnType"]);
12081
+ var EXPRESSION__TYPE_ARGUMENTS = freeze(["expression", "typeArguments"]);
12082
+ var MEMBERS = freeze(["members"]);
12083
+ var ID__BODY = freeze(["id", "body"]);
12084
+ var TYPES = freeze(["types"]);
12085
+ var TYPE_ANNOTATION = freeze(["typeAnnotation"]);
12086
+ var PARAMS = freeze(["params"]);
12087
+ var keys_default = freeze({
12088
+ DebuggerStatement: $EMPTY,
12089
+ EmptyStatement: $EMPTY,
12090
+ Literal: $EMPTY,
12091
+ PrivateIdentifier: $EMPTY,
12092
+ Super: $EMPTY,
12093
+ TemplateElement: $EMPTY,
12094
+ ThisExpression: $EMPTY,
12095
+ JSXClosingFragment: $EMPTY,
12096
+ JSXEmptyExpression: $EMPTY,
12097
+ JSXIdentifier: $EMPTY,
12098
+ JSXOpeningFragment: $EMPTY,
12099
+ JSXText: $EMPTY,
12100
+ TSAnyKeyword: $EMPTY,
12101
+ TSBigIntKeyword: $EMPTY,
12102
+ TSBooleanKeyword: $EMPTY,
12103
+ TSIntrinsicKeyword: $EMPTY,
12104
+ TSJSDocUnknownType: $EMPTY,
12105
+ TSNeverKeyword: $EMPTY,
12106
+ TSNullKeyword: $EMPTY,
12107
+ TSNumberKeyword: $EMPTY,
12108
+ TSObjectKeyword: $EMPTY,
12109
+ TSStringKeyword: $EMPTY,
12110
+ TSSymbolKeyword: $EMPTY,
12111
+ TSThisType: $EMPTY,
12112
+ TSUndefinedKeyword: $EMPTY,
12113
+ TSUnknownKeyword: $EMPTY,
12114
+ TSVoidKeyword: $EMPTY,
12115
+ AccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION__VALUE,
12116
+ ArrayExpression: freeze(["elements"]),
12117
+ ArrayPattern: freeze(["decorators", "elements", "typeAnnotation"]),
12118
+ ArrowFunctionExpression: freeze(["typeParameters", "params", "returnType", "body"]),
12119
+ AssignmentExpression: LEFT__RIGHT,
12120
+ AssignmentPattern: freeze(["decorators", "left", "right", "typeAnnotation"]),
12121
+ AwaitExpression: ARGUMENT,
12122
+ BinaryExpression: LEFT__RIGHT,
12123
+ BlockStatement: BODY,
12124
+ BreakStatement: LABEL,
12125
+ CallExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS,
12126
+ CatchClause: freeze(["param", "body"]),
12127
+ ChainExpression: EXPRESSION,
12128
+ ClassBody: BODY,
12129
+ ClassDeclaration: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY,
12130
+ ClassExpression: DECORATORS__ID__TYPE_PARAMETERS__SUPER_CLASS__SUPER_TYPE_ARGUMENTS__IMPLEMENTS__BODY,
12131
+ ConditionalExpression: TEST__CONSEQUENT__ALTERNATE,
12132
+ ContinueStatement: LABEL,
12133
+ Decorator: EXPRESSION,
12134
+ DoWhileStatement: freeze(["body", "test"]),
12135
+ ExportAllDeclaration: freeze(["exported", "source", "attributes"]),
12136
+ ExportDefaultDeclaration: freeze(["declaration"]),
12137
+ ExportNamedDeclaration: freeze(["declaration", "specifiers", "source", "attributes"]),
12138
+ ExportSpecifier: freeze(["local", "exported"]),
12139
+ ExpressionStatement: EXPRESSION,
12140
+ ForInStatement: LEFT__RIGHT__BODY,
12141
+ ForOfStatement: LEFT__RIGHT__BODY,
12142
+ ForStatement: freeze(["init", "test", "update", "body"]),
12143
+ FunctionDeclaration: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
12144
+ FunctionExpression: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
12145
+ Identifier: freeze(["decorators", "typeAnnotation"]),
12146
+ IfStatement: TEST__CONSEQUENT__ALTERNATE,
12147
+ ImportAttribute: KEY__VALUE,
12148
+ ImportDeclaration: freeze(["specifiers", "source", "attributes"]),
12149
+ ImportDefaultSpecifier: LOCAL,
12150
+ ImportExpression: freeze(["source", "options"]),
12151
+ ImportNamespaceSpecifier: LOCAL,
12152
+ ImportSpecifier: freeze(["imported", "local"]),
12153
+ LabeledStatement: freeze(["label", "body"]),
12154
+ LogicalExpression: LEFT__RIGHT,
12155
+ MemberExpression: OBJECT__PROPERTY,
12156
+ MetaProperty: freeze(["meta", "property"]),
12157
+ MethodDefinition: freeze(["decorators", "key", "value"]),
12158
+ NewExpression: CALLEE__TYPE_ARGUMENTS__ARGUMENTS,
12159
+ ObjectExpression: freeze(["properties"]),
12160
+ ObjectPattern: freeze(["decorators", "properties", "typeAnnotation"]),
12161
+ ParenthesizedExpression: EXPRESSION,
12162
+ Program: BODY,
12163
+ Property: KEY__VALUE,
12164
+ PropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION__VALUE,
12165
+ RestElement: freeze(["decorators", "argument", "typeAnnotation"]),
12166
+ ReturnStatement: ARGUMENT,
12167
+ SequenceExpression: freeze(["expressions"]),
12168
+ SpreadElement: ARGUMENT,
12169
+ StaticBlock: BODY,
12170
+ SwitchCase: freeze(["test", "consequent"]),
12171
+ SwitchStatement: freeze(["discriminant", "cases"]),
12172
+ TaggedTemplateExpression: freeze(["tag", "typeArguments", "quasi"]),
12173
+ TemplateLiteral: freeze(["quasis", "expressions"]),
12174
+ ThrowStatement: ARGUMENT,
12175
+ TryStatement: freeze(["block", "handler", "finalizer"]),
12176
+ UnaryExpression: ARGUMENT,
12177
+ UpdateExpression: ARGUMENT,
12178
+ V8IntrinsicExpression: freeze(["name", "arguments"]),
12179
+ VariableDeclaration: freeze(["declarations"]),
12180
+ VariableDeclarator: freeze(["id", "init"]),
12181
+ WhileStatement: freeze(["test", "body"]),
12182
+ WithStatement: freeze(["object", "body"]),
12183
+ YieldExpression: ARGUMENT,
12184
+ JSXAttribute: freeze(["name", "value"]),
12185
+ JSXClosingElement: freeze(["name"]),
12186
+ JSXElement: freeze(["openingElement", "children", "closingElement"]),
12187
+ JSXExpressionContainer: EXPRESSION,
12188
+ JSXFragment: freeze(["openingFragment", "children", "closingFragment"]),
12189
+ JSXMemberExpression: OBJECT__PROPERTY,
12190
+ JSXNamespacedName: freeze(["namespace", "name"]),
12191
+ JSXOpeningElement: freeze(["name", "typeArguments", "attributes"]),
12192
+ JSXSpreadAttribute: ARGUMENT,
12193
+ JSXSpreadChild: EXPRESSION,
12194
+ TSAbstractAccessorProperty: DECORATORS__KEY__TYPE_ANNOTATION,
12195
+ TSAbstractMethodDefinition: KEY__VALUE,
12196
+ TSAbstractPropertyDefinition: DECORATORS__KEY__TYPE_ANNOTATION,
12197
+ TSArrayType: freeze(["elementType"]),
12198
+ TSAsExpression: EXPRESSION__TYPE_ANNOTATION,
12199
+ TSCallSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
12200
+ TSClassImplements: EXPRESSION__TYPE_ARGUMENTS,
12201
+ TSConditionalType: freeze(["checkType", "extendsType", "trueType", "falseType"]),
12202
+ TSConstructSignatureDeclaration: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
12203
+ TSConstructorType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
12204
+ TSDeclareFunction: ID__TYPE_PARAMETERS__PARAMS__RETURN_TYPE__BODY,
12205
+ TSEmptyBodyFunctionExpression: freeze(["id", "typeParameters", "params", "returnType"]),
12206
+ TSEnumBody: MEMBERS,
12207
+ TSEnumDeclaration: ID__BODY,
12208
+ TSEnumMember: freeze(["id", "initializer"]),
12209
+ TSExportAssignment: EXPRESSION,
12210
+ TSExternalModuleReference: EXPRESSION,
12211
+ TSFunctionType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
12212
+ TSImportEqualsDeclaration: freeze(["id", "moduleReference"]),
12213
+ TSImportType: freeze(["argument", "options", "qualifier", "typeArguments"]),
12214
+ TSIndexSignature: freeze(["parameters", "typeAnnotation"]),
12215
+ TSIndexedAccessType: freeze(["objectType", "indexType"]),
12216
+ TSInferType: freeze(["typeParameter"]),
12217
+ TSInstantiationExpression: EXPRESSION__TYPE_ARGUMENTS,
12218
+ TSInterfaceBody: BODY,
12219
+ TSInterfaceDeclaration: freeze(["id", "typeParameters", "extends", "body"]),
12220
+ TSInterfaceHeritage: EXPRESSION__TYPE_ARGUMENTS,
12221
+ TSIntersectionType: TYPES,
12222
+ TSJSDocNonNullableType: TYPE_ANNOTATION,
12223
+ TSJSDocNullableType: TYPE_ANNOTATION,
12224
+ TSLiteralType: freeze(["literal"]),
12225
+ TSMappedType: freeze(["key", "constraint", "nameType", "typeAnnotation"]),
12226
+ TSMethodSignature: freeze(["key", "typeParameters", "params", "returnType"]),
12227
+ TSModuleBlock: BODY,
12228
+ TSModuleDeclaration: ID__BODY,
12229
+ TSNamedTupleMember: freeze(["label", "elementType"]),
12230
+ TSNamespaceExportDeclaration: freeze(["id"]),
12231
+ TSNonNullExpression: EXPRESSION,
12232
+ TSOptionalType: TYPE_ANNOTATION,
12233
+ TSParameterProperty: freeze(["decorators", "parameter"]),
12234
+ TSParenthesizedType: TYPE_ANNOTATION,
12235
+ TSPropertySignature: freeze(["key", "typeAnnotation"]),
12236
+ TSQualifiedName: LEFT__RIGHT,
12237
+ TSRestType: TYPE_ANNOTATION,
12238
+ TSSatisfiesExpression: EXPRESSION__TYPE_ANNOTATION,
12239
+ TSTemplateLiteralType: freeze(["quasis", "types"]),
12240
+ TSTupleType: freeze(["elementTypes"]),
12241
+ TSTypeAliasDeclaration: freeze(["id", "typeParameters", "typeAnnotation"]),
12242
+ TSTypeAnnotation: TYPE_ANNOTATION,
12243
+ TSTypeAssertion: freeze(["typeAnnotation", "expression"]),
12244
+ TSTypeLiteral: MEMBERS,
12245
+ TSTypeOperator: TYPE_ANNOTATION,
12246
+ TSTypeParameter: freeze(["name", "constraint", "default"]),
12247
+ TSTypeParameterDeclaration: PARAMS,
12248
+ TSTypeParameterInstantiation: PARAMS,
12249
+ TSTypePredicate: freeze(["parameterName", "typeAnnotation"]),
12250
+ TSTypeQuery: freeze(["exprName", "typeArguments"]),
12251
+ TSTypeReference: freeze(["typeName", "typeArguments"]),
12252
+ TSUnionType: TYPES
12253
+ });
12254
+ // node_modules/oxc-parser/src-js/visit/index.js
12255
+ import { createRequire as createRequire2 } from "node:module";
12256
+ var walkProgram = null;
12257
+ var addVisitorToCompiled;
12258
+ var createCompiledVisitor;
12259
+ var finalizeCompiledVisitor;
12260
+
12261
+ class Visitor {
12262
+ #compiledVisitor = null;
12263
+ constructor(visitor) {
12264
+ if (walkProgram === null) {
12265
+ const require3 = createRequire2(import.meta.url);
12266
+ ({ walkProgram } = require3("../../generated/visit/walk.js"));
12267
+ ({
12268
+ addVisitorToCompiled,
12269
+ createCompiledVisitor,
12270
+ finalizeCompiledVisitor
12271
+ } = require3("./visitor.js"));
12272
+ }
12273
+ const compiledVisitor = createCompiledVisitor();
12274
+ addVisitorToCompiled(visitor);
12275
+ const needsVisit = finalizeCompiledVisitor();
12276
+ if (needsVisit)
12277
+ this.#compiledVisitor = compiledVisitor;
12278
+ }
12279
+ visit(program) {
12280
+ const compiledVisitor = this.#compiledVisitor;
12281
+ if (compiledVisitor !== null)
12282
+ walkProgram(program, compiledVisitor);
12283
+ }
12284
+ }
12285
+
12286
+ // node_modules/oxc-parser/src-js/index.js
12287
+ var require3 = createRequire3(import.meta.url);
12288
+ var parseSyncRaw = null;
12289
+ var parseRaw;
12290
+ var parseSyncLazy = null;
12291
+ var parseLazy;
12292
+ var LazyVisitor;
12293
+ function loadRawTransfer() {
12294
+ if (parseSyncRaw === null) {
12295
+ ({ parseSyncRaw, parse: parseRaw } = require3("./raw-transfer/eager.js"));
12296
+ }
12297
+ }
12298
+ function loadRawTransferLazy() {
12299
+ if (parseSyncLazy === null) {
12300
+ ({ parseSyncLazy, parse: parseLazy, Visitor: LazyVisitor } = require3("./raw-transfer/lazy.js"));
12301
+ }
12302
+ }
12303
+ function parseSync2(filename, sourceText, options3) {
12304
+ if (options3?.experimentalRawTransfer) {
12305
+ loadRawTransfer();
12306
+ return parseSyncRaw(filename, sourceText, options3);
12307
+ }
12308
+ if (options3?.experimentalLazy) {
12309
+ loadRawTransferLazy();
12310
+ return parseSyncLazy(filename, sourceText, options3);
12311
+ }
12312
+ return wrap(parseSync(filename, sourceText, options3));
12313
+ }
12314
+
12315
+ // src/recognizers/detector.ts
12316
+ function recognize(detector, line) {
12317
+ const matches = detector.scan(line);
12318
+ if (matches === 0)
12319
+ return 0;
12320
+ return 1 - (1 - detector.probability) ** matches;
12321
+ }
12322
+
12323
+ // src/recognizers/code-recognizer.ts
12324
+ var PROBABILITY_THRESHOLD = 0.9;
12325
+ function computeProbability(detectors, line) {
12326
+ let probability = 0;
12327
+ for (const detector of detectors) {
12328
+ const detected = recognize(detector, line);
12329
+ probability = 1 - (1 - probability) * (1 - detected);
12330
+ }
12331
+ return probability;
12332
+ }
12333
+ function isLikelyCode(detectors, line) {
12334
+ return computeProbability(detectors, line) >= PROBABILITY_THRESHOLD;
12335
+ }
12336
+ function hasCodeLines(detectors, lines) {
12337
+ return lines.some((line) => isLikelyCode(detectors, line));
12338
+ }
12339
+
12340
+ // src/recognizers/camel-case-detector.ts
12341
+ function createCamelCaseDetector(probability) {
12342
+ return {
12343
+ probability,
12344
+ scan(line) {
12345
+ for (let index2 = 0;index2 < line.length - 1; index2 += 1) {
12346
+ const current = line.charAt(index2);
12347
+ const next = line.charAt(index2 + 1);
12348
+ if (current === current.toLowerCase() && next === next.toUpperCase() && next !== next.toLowerCase()) {
12349
+ return 1;
12350
+ }
12351
+ }
12352
+ return 0;
12353
+ }
12354
+ };
12355
+ }
12356
+
12357
+ // src/recognizers/contains-detector.ts
12358
+ var WHITESPACE_GLOBAL_REGEX = /\s+/g;
12359
+ var ESCAPE = /[-/\\^$*+?.()|[\]{}]/g;
12360
+ function escapeForRegex(value) {
12361
+ return value.replaceAll(ESCAPE, String.raw`\$&`);
12362
+ }
12363
+ function createContainsDetector(probability, patterns2) {
12364
+ const compiledPatterns = patterns2.map((pattern4) => typeof pattern4 === "string" ? new RegExp(escapeForRegex(pattern4), "g") : new RegExp(pattern4.source, "g"));
12365
+ return {
12366
+ probability,
12367
+ scan(line) {
12368
+ const compressed = line.replace(WHITESPACE_GLOBAL_REGEX, "");
12369
+ let total = 0;
12370
+ for (const pattern4 of compiledPatterns) {
12371
+ pattern4.lastIndex = 0;
12372
+ const matches = compressed.match(pattern4);
12373
+ if (matches)
12374
+ total += matches.length;
12375
+ }
12376
+ return total;
12377
+ }
12378
+ };
12379
+ }
12380
+
12381
+ // src/recognizers/end-with-detector.ts
12382
+ var WHITESPACE_REGEX = /\s/;
12383
+ function createEndWithDetector(probability, endings) {
12384
+ const endingsSet = new Set(endings);
12385
+ return {
12386
+ probability,
12387
+ scan(line) {
12388
+ for (let index2 = line.length - 1;index2 >= 0; index2 -= 1) {
12389
+ const char = line.charAt(index2);
12390
+ if (endingsSet.has(char))
12391
+ return 1;
12392
+ if (!WHITESPACE_REGEX.test(char) && char !== "*" && char !== "/")
12393
+ return 0;
12394
+ }
12395
+ return 0;
12396
+ }
12397
+ };
12398
+ }
12399
+
12400
+ // src/recognizers/keywords-detector.ts
12401
+ var WORD_SPLIT_REGEX = /[ \t(),{}]/;
12402
+ function createKeywordsDetector(probability, keywords) {
12403
+ const keywordsSet = new Set(keywords);
12404
+ return {
12405
+ probability,
12406
+ scan(line) {
12407
+ const words = line.split(WORD_SPLIT_REGEX);
12408
+ let count = 0;
12409
+ for (const word of words)
12410
+ if (keywordsSet.has(word))
12411
+ count += 1;
12412
+ return count;
12413
+ }
12414
+ };
12415
+ }
12416
+
12417
+ // src/recognizers/javascript-footprint.ts
12418
+ var JS_KEYWORDS = [
12419
+ "public",
12420
+ "abstract",
12421
+ "class",
12422
+ "implements",
12423
+ "extends",
12424
+ "return",
12425
+ "throw",
12426
+ "private",
12427
+ "protected",
12428
+ "enum",
12429
+ "continue",
12430
+ "assert",
12431
+ "boolean",
12432
+ "this",
12433
+ "instanceof",
12434
+ "interface",
12435
+ "static",
12436
+ "void",
12437
+ "super",
12438
+ "true",
12439
+ "case:",
12440
+ "let",
12441
+ "const",
12442
+ "var",
12443
+ "async",
12444
+ "await",
12445
+ "break",
12446
+ "yield",
12447
+ "typeof",
12448
+ "import",
12449
+ "export"
12450
+ ];
12451
+ var OPERATORS2 = ["++", "||", "&&", "===", "?.", "??"];
12452
+ var CODE_PATTERNS = [
12453
+ "for(",
12454
+ "if(",
12455
+ "while(",
12456
+ "catch(",
12457
+ "switch(",
12458
+ "try{",
12459
+ "else{",
12460
+ "this.",
12461
+ "window.",
12462
+ /;\s+\/\//,
12463
+ "import '",
12464
+ 'import "',
12465
+ "require("
12466
+ ];
12467
+ var LINE_ENDINGS = ["}", ";", "{"];
12468
+ function createJavaScriptDetectors() {
12469
+ return [
12470
+ createEndWithDetector(0.95, LINE_ENDINGS),
12471
+ createKeywordsDetector(0.7, OPERATORS2),
12472
+ createKeywordsDetector(0.3, JS_KEYWORDS),
12473
+ createContainsDetector(0.95, CODE_PATTERNS),
12474
+ createCamelCaseDetector(0.5)
12475
+ ];
12476
+ }
12477
+
12478
+ // src/rules/no-commented-code.ts
12479
+ var EXCLUDED_STATEMENTS = new Set(["BreakStatement", "LabeledStatement", "ContinueStatement"]);
12480
+ var detectors = createJavaScriptDetectors();
12481
+ function isCommentWithLocation(comment) {
12482
+ return comment.loc !== undefined && comment.range !== undefined;
12483
+ }
12484
+ function areAdjacentLineComments(previous, next, sourceCode) {
12485
+ const previousLine = previous.loc.start.line;
12486
+ const nextLine = next.loc.start.line;
12487
+ if (previousLine + 1 !== nextLine)
12488
+ return false;
12489
+ const commentForApi = {
12490
+ loc: previous.loc,
12491
+ range: previous.range,
12492
+ type: previous.type,
12493
+ value: previous.value
12494
+ };
12495
+ const tokenAfterPrevious = sourceCode.getTokenAfter(commentForApi);
12496
+ return !tokenAfterPrevious || tokenAfterPrevious.loc.start.line > nextLine;
12497
+ }
12498
+ function groupComments(comments, sourceCode) {
12499
+ const groups = new Array;
12500
+ let groupsSize = 0;
12501
+ let currentLineComments = new Array;
12502
+ let size = 0;
12503
+ for (const comment of comments) {
12504
+ if (!isCommentWithLocation(comment))
12505
+ continue;
12506
+ if (comment.type === "Block") {
12507
+ if (size > 0) {
12508
+ groups[groupsSize++] = {
12509
+ comments: currentLineComments,
12510
+ value: currentLineComments.map((c) => c.value).join(`
12511
+ `)
12512
+ };
12513
+ currentLineComments = [];
12514
+ size = 0;
12515
+ }
12516
+ groups[groupsSize++] = {
12517
+ comments: [comment],
12518
+ value: comment.value
12519
+ };
12520
+ } else if (size === 0)
12521
+ currentLineComments[size++] = comment;
12522
+ else {
12523
+ const lastComment = currentLineComments.at(-1);
12524
+ if (lastComment && areAdjacentLineComments(lastComment, comment, sourceCode)) {
12525
+ currentLineComments[size++] = comment;
12526
+ } else {
12527
+ groups[groupsSize++] = {
12528
+ comments: currentLineComments,
12529
+ value: currentLineComments.map(({ value }) => value).join(`
12530
+ `)
12531
+ };
12532
+ currentLineComments = [comment];
12533
+ size = 1;
12534
+ }
12535
+ }
12536
+ }
12537
+ if (size > 0) {
12538
+ groups[groupsSize++] = {
12539
+ comments: currentLineComments,
12540
+ value: currentLineComments.map(({ value }) => value).join(`
12541
+ `)
12542
+ };
12543
+ }
12544
+ return groups;
12545
+ }
12546
+ function injectMissingBraces(value) {
12547
+ const openCount = (value.match(/{/g) ?? []).length;
12548
+ const closeCount = (value.match(/}/g) ?? []).length;
12549
+ const diff2 = openCount - closeCount;
12550
+ if (diff2 > 0)
12551
+ return value + "}".repeat(diff2);
12552
+ if (diff2 < 0)
12553
+ return "{".repeat(-diff2) + value;
12554
+ return value;
12555
+ }
12556
+ function couldBeJsCode(input) {
12557
+ const lines = input.split(`
12558
+ `);
12559
+ return hasCodeLines(detectors, lines);
12560
+ }
12561
+ function isReturnOrThrowExclusion(statement) {
12562
+ if (statement.type !== "ReturnStatement" && statement.type !== "ThrowStatement")
12563
+ return false;
12564
+ return statement.argument === undefined || statement.argument.type === "Identifier";
12565
+ }
12566
+ function isUnaryPlusMinus(expression) {
12567
+ return expression.type === "UnaryExpression" && (expression.operator === "+" || expression.operator === "-");
12568
+ }
12569
+ function isExcludedLiteral(expression) {
12570
+ if (expression.type !== "Literal")
12571
+ return false;
12572
+ return typeof expression.value === "string" || typeof expression.value === "number";
12573
+ }
12574
+ function isRecord2(value) {
12575
+ return typeof value === "object" && value !== undefined;
12576
+ }
12577
+ function isParsedStatement(value) {
12578
+ if (!isRecord2(value))
12579
+ return false;
12580
+ return typeof value.type === "string";
12581
+ }
12582
+ function toParsedStatements(body) {
12583
+ const result = [];
12584
+ for (const item of body) {
12585
+ if (isParsedStatement(item))
12586
+ result.push(item);
12587
+ }
12588
+ return result;
12589
+ }
12590
+ function isExpressionExclusion(statement, codeText) {
12591
+ if (statement.type !== "ExpressionStatement")
12592
+ return false;
12593
+ const expression = statement.expression;
12594
+ if (!expression)
12595
+ return false;
12596
+ if (expression.type === "Identifier")
12597
+ return true;
12598
+ if (expression.type === "SequenceExpression")
12599
+ return true;
12600
+ if (isUnaryPlusMinus(expression))
12601
+ return true;
12602
+ if (isExcludedLiteral(expression))
12603
+ return true;
12604
+ if (!codeText.trimEnd().endsWith(";"))
12605
+ return true;
12606
+ return false;
12607
+ }
12608
+ function isExclusion(statements, codeText) {
12609
+ if (statements.length !== 1)
12610
+ return false;
12611
+ const statement = statements.at(0);
12612
+ if (!statement)
12613
+ return false;
12614
+ if (EXCLUDED_STATEMENTS.has(statement.type))
12615
+ return true;
12616
+ if (isReturnOrThrowExclusion(statement))
12617
+ return true;
12618
+ if (isExpressionExclusion(statement, codeText))
12619
+ return true;
12620
+ return false;
12621
+ }
12622
+ var ALLOWED_PARSE_ERROR_PATTERNS = [/A 'return' statement can only be used within a function body/];
12623
+ function hasOnlyAllowedErrors(errors4) {
12624
+ return errors4.every((error2) => ALLOWED_PARSE_ERROR_PATTERNS.some((pattern4) => pattern4.test(error2.message)));
12625
+ }
12626
+ function isValidParseResult(result) {
12627
+ const hasValidErrors = result.errors.length === 0 || hasOnlyAllowedErrors(result.errors);
12628
+ return hasValidErrors && result.program.body.length > 0;
12629
+ }
12630
+ function tryParse(value, filename) {
12631
+ const ext = path.extname(filename);
12632
+ const parseFilename = `file${ext || ".js"}`;
12633
+ const result = parseSync2(parseFilename, value);
12634
+ if (isValidParseResult(result))
12635
+ return result;
12636
+ if (ext !== ".tsx" && ext !== ".jsx") {
12637
+ const jsxResult = parseSync2("file.tsx", value);
12638
+ if (isValidParseResult(jsxResult))
12639
+ return jsxResult;
12640
+ }
12641
+ return;
12642
+ }
12643
+ function containsCode(value, filename) {
12644
+ if (!couldBeJsCode(value))
12645
+ return false;
12646
+ try {
12647
+ const result = tryParse(value, filename);
12648
+ if (!result)
12649
+ return false;
12650
+ const statements = toParsedStatements(result.program.body);
12651
+ return !isExclusion(statements, value);
12652
+ } catch {
12653
+ return false;
12654
+ }
12655
+ }
12656
+ var noCommentedCode = {
12657
+ create(context) {
12658
+ return {
12659
+ "Program:exit"() {
12660
+ const allComments = context.sourceCode.getAllComments();
12661
+ const groups = groupComments(allComments, context.sourceCode);
12662
+ for (const group of groups) {
12663
+ const trimmedValue = group.value.trim();
12664
+ if (trimmedValue === "}")
12665
+ continue;
12666
+ const balanced = injectMissingBraces(trimmedValue);
12667
+ if (containsCode(balanced, context.filename)) {
12668
+ const firstComment = group.comments.at(0);
12669
+ const lastComment = group.comments.at(-1);
12670
+ if (!firstComment || !lastComment)
12671
+ continue;
12672
+ context.report({
12673
+ loc: {
12674
+ end: lastComment.loc.end,
12675
+ start: firstComment.loc.start
12676
+ },
12677
+ messageId: "commentedCode",
12678
+ suggest: [
12679
+ {
12680
+ desc: "Remove this commented out code",
12681
+ fix(fixer) {
12682
+ return fixer.removeRange([firstComment.range[0], lastComment.range[1]]);
12683
+ }
12684
+ }
12685
+ ]
12686
+ });
12687
+ }
12688
+ }
12689
+ }
12690
+ };
12691
+ },
12692
+ meta: {
12693
+ docs: {
12694
+ description: "Disallow commented-out code",
12695
+ recommended: false
12696
+ },
12697
+ hasSuggestions: true,
12698
+ messages: {
12699
+ commentedCode: "Remove this commented out code."
12700
+ },
12701
+ schema: [],
12702
+ type: "suggestion"
12703
+ }
12704
+ };
12705
+ var no_commented_code_default = noCommentedCode;
12706
+
11371
12707
  // src/rules/use-hook-at-top-level.ts
11372
12708
  import { TSESTree as TSESTree10 } from "@typescript-eslint/types";
11373
12709
  var HOOK_NAME_PATTERN = /^use[A-Z]/;
@@ -11790,6 +13126,7 @@ var rules = {
11790
13126
  "enforce-ianitor-check-type": enforce_ianitor_check_type_default,
11791
13127
  "no-async-constructor": no_async_constructor_default,
11792
13128
  "no-color3-constructor": no_color3_constructor_default,
13129
+ "no-commented-code": no_commented_code_default,
11793
13130
  "no-instance-methods-without-this": no_instance_methods_without_this_default,
11794
13131
  "no-print": no_print_default,
11795
13132
  "no-shorthand-names": no_shorthand_names_default,
@@ -11846,4 +13183,4 @@ export {
11846
13183
  createBanInstancesOptions
11847
13184
  };
11848
13185
 
11849
- //# debugId=734DB8BE5C92D79464756E2164756E21
13186
+ //# debugId=8ED77B08FB4A984564756E2164756E21