@sarj/eslint-plugin 18.2.1 → 18.3.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
@@ -1,6 +1,3 @@
1
- // src/rules/prefer-zod-enum-validator.ts
2
- import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/utils";
3
-
4
1
  // src/rules/_eslint-rule.ts
5
2
  import { ESLintUtils } from "@typescript-eslint/utils";
6
3
 
@@ -487,21 +484,21 @@ function validateExpectedSuggestion(value, exampleId, messageIds) {
487
484
  assertFields(value, ["messageId", "output"], exampleId);
488
485
  }
489
486
  function validateExpectedLocation(value, exampleId) {
490
- if (!isObject(value) || !("line" in value) || !positiveCoordinate(value.line) || !("column" in value) || !positiveCoordinate(value.column)) {
487
+ if (!isObject(value) || !("line" in value) || typeof value.line !== "number" || !positiveCoordinate(value.line) || !("column" in value) || typeof value.column !== "number" || !positiveCoordinate(value.column)) {
491
488
  throw new TypeError(`${exampleId}: expected diagnostic location requires positive integer coordinates`);
492
489
  }
493
490
  if (!("end" in value)) {
494
491
  assertFields(value, ["line", "column"], exampleId);
495
492
  return;
496
493
  }
497
- if (!isObject(value.end) || !("line" in value.end) || !positiveCoordinate(value.end.line) || !("column" in value.end) || !positiveCoordinate(value.end.column) || value.end.line < value.line || value.end.line === value.line && value.end.column < value.column) {
494
+ if (!isObject(value.end) || !("line" in value.end) || typeof value.end.line !== "number" || !positiveCoordinate(value.end.line) || !("column" in value.end) || typeof value.end.column !== "number" || !positiveCoordinate(value.end.column) || value.end.line < value.line || value.end.line === value.line && value.end.column < value.column) {
498
495
  throw new TypeError(`${exampleId}: expected diagnostic end point must be complete and ordered`);
499
496
  }
500
497
  assertFields(value.end, ["line", "column"], exampleId);
501
498
  assertFields(value, ["line", "column", "end"], exampleId);
502
499
  }
503
500
  function positiveCoordinate(value) {
504
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
501
+ return Number.isSafeInteger(value) && value >= 1;
505
502
  }
506
503
  function assertFields(value, expected, exampleId) {
507
504
  const fields2 = Object.keys(value);
@@ -653,6 +650,56 @@ function commentLineEnd(sourceText, start) {
653
650
  return end === -1 ? sourceText.length : start + end;
654
651
  }
655
652
 
653
+ // src/rules/no-explicit-type-predicate.ts
654
+ var NO_EXPLICIT_TYPE_PREDICATE_DOCUMENTATION = {
655
+ defaultLevel: "warning",
656
+ summary: "Use compiler-checked narrowing instead of handwritten type predicates.",
657
+ rationale: "TypeScript trusts an explicit value is Type annotation without proving that its implementation recognizes that type in both branches. A stale or partial predicate can make callers read properties that do not exist. Direct discriminator checks and inferred predicates keep narrowing tied to the implementation.",
658
+ remediation: "For owned variants, check the discriminated union's tag directly or let TypeScript infer a simple discriminator helper or null filter. Parse unknown external data with a specific schema and consume its validated value or discriminated result. Do not replace a predicate with a cast or a schema boolean wrapper that repeats the same unchecked type claim. If a native API cannot express the required static contract, isolate that boundary and use an exact-rule local suppression explaining the constraint.",
659
+ category: "maintainability",
660
+ autofix: "none",
661
+ requiresTypeInformation: false,
662
+ limitations: [
663
+ "This is an explicit design policy, including otherwise correct handwritten predicates. Reports every authored TypeScript is predicate, including asserts value is Type, method and callback annotations, function types, overloads, ambient signatures and predicates inside casts or satisfies expressions.",
664
+ "Direct discriminator checks, compiler-inferred predicates, ordinary boolean returns and plain asserts condition remain valid. A tag on unknown input does not validate its payload. Imported library guard calls and imported predicate types are not redeclarations and are not inspected.",
665
+ "Shared generated, vendored and declaration-file exclusions apply. Maintained test implementations remain checked; strings, comments and JSDoc text are not TypeScript predicate nodes. There is no exemption based on helper names, imports or body shape.",
666
+ "No automatic fix or suggestion removes an annotation: public and callback contracts, overloads, both narrowing branches, emitted declarations and existing TypeScript versions may depend on it. Review callers and preserve intentional runtime behavior when migrating. Existing partial and contradictory predicate rules retain their separate correctness checks."
667
+ ],
668
+ references: [
669
+ "https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions",
670
+ "https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#inferred-type-predicates",
671
+ "https://zod.dev/basics"
672
+ ],
673
+ examples: [
674
+ { id: "manual-predicate", title: "Avoid an unchecked narrowing annotation", outcome: "match", files: [{ path: "src/job.ts", source: "type Job = { kind: 'queued'; queue: string } | { kind: 'done'; result: string }; type Done = Extract<Job, {kind: 'done'}>; function isDone(job: Job): job is Done { return job.kind === 'done'; } function render(job: Job) { return isDone(job) ? job.result : job.queue; }" }], focusPath: "src/job.ts", expectedCount: 1, public: true },
675
+ { id: "direct-discriminator", title: "Let the compiler narrow the tagged union", outcome: "no-match", files: [{ path: "src/job.ts", source: "type Job = { kind: 'queued'; queue: string } | { kind: 'done'; result: string }; function render(job: Job) { return job.kind === 'done' ? job.result : job.queue; }" }], focusPath: "src/job.ts", expectedCount: 0, public: true },
676
+ { id: "inferred-predicate", scenarioId: "inference", title: "Infer a discriminator helper from its body", outcome: "no-match", files: [{ path: "src/job.ts", source: "type Job = { kind: 'queued'; queue: string } | { kind: 'done'; result: string }; const isDone = (job: Job) => job.kind === 'done';" }], focusPath: "src/job.ts", expectedCount: 0, public: true },
677
+ { id: "written-predicate", scenarioId: "inference", title: "A written predicate remains an unchecked promise", outcome: "match", files: [{ path: "src/job.ts", source: "type Job = { kind: 'queued'; queue: string } | { kind: 'done'; result: string }; type Done = Extract<Job, {kind: 'done'}>; const isDone = (job: Job): job is Done => job.kind === 'done';" }], focusPath: "src/job.ts", expectedCount: 1, public: true }
678
+ ]
679
+ };
680
+ var no_explicit_type_predicate_default = createRule({
681
+ name: "no-explicit-type-predicate",
682
+ documentation: NO_EXPLICIT_TYPE_PREDICATE_DOCUMENTATION,
683
+ meta: {
684
+ type: "suggestion",
685
+ docs: { description: NO_EXPLICIT_TYPE_PREDICATE_DOCUMENTATION.summary },
686
+ schema: [],
687
+ messages: { noExplicitTypePredicate: "Replace this handwritten type predicate with a direct discriminator check or compiler-inferred narrowing. Parse unknown data with a schema and consume the validated result; preserve required external callable contracts." }
688
+ },
689
+ defaultOptions: [],
690
+ create(context) {
691
+ if (isGeneratedFile(context, context.sourceCode.text)) return {};
692
+ return {
693
+ TSTypePredicate(node) {
694
+ if (node.typeAnnotation != null) context.report({ node, messageId: "noExplicitTypePredicate" });
695
+ }
696
+ };
697
+ }
698
+ });
699
+
700
+ // src/rules/prefer-zod-enum-validator.ts
701
+ import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/utils";
702
+
656
703
  // src/rules/_static-string.ts
657
704
  import { AST_NODE_TYPES as AST_NODE_TYPES3, ASTUtils } from "@typescript-eslint/utils";
658
705
 
@@ -3663,7 +3710,7 @@ function fixtureConstructor(source, value) {
3663
3710
  const use = value.params[1];
3664
3711
  if (use?.type !== AST_NODE_TYPES27.Identifier) return null;
3665
3712
  const binding3 = stableBinding(source, use);
3666
- const calls = scopeNodes(value.body, source).filter((node) => node.type === AST_NODE_TYPES27.CallExpression && !node.optional && node.arguments.length === 1 && node.callee.type === AST_NODE_TYPES27.Identifier && stableBinding(source, node.callee) === binding3);
3713
+ const calls = scopeNodes(value.body, source).filter((node) => node.type === AST_NODE_TYPES27.CallExpression).filter((node) => !node.optional && node.arguments.length === 1 && node.callee.type === AST_NODE_TYPES27.Identifier && stableBinding(source, node.callee) === binding3);
3667
3714
  if (calls.length !== 1 || binding3 === null) return null;
3668
3715
  const argument = calls[0]?.arguments[0];
3669
3716
  return argument === void 0 || argument.type === AST_NODE_TYPES27.SpreadElement ? null : newConstructor(source, argument);
@@ -3686,17 +3733,12 @@ function scopeNodes(root, source) {
3686
3733
  if (node === void 0) continue;
3687
3734
  result.push(node);
3688
3735
  if (node !== root && (node.type === AST_NODE_TYPES27.ArrowFunctionExpression || node.type === AST_NODE_TYPES27.FunctionExpression || node.type === AST_NODE_TYPES27.FunctionDeclaration || node.type === AST_NODE_TYPES27.ClassDeclaration || node.type === AST_NODE_TYPES27.ClassExpression)) continue;
3689
- for (const key of source.visitorKeys[node.type] ?? []) {
3690
- const value = Reflect.get(node, key);
3691
- if (Array.isArray(value)) pending.push(...value.filter(isNode2));
3692
- else if (isNode2(value)) pending.push(value);
3693
- }
3736
+ forEachAstChild(node, source.visitorKeys, (child) => {
3737
+ pending.push(child);
3738
+ });
3694
3739
  }
3695
3740
  return result;
3696
3741
  }
3697
- function isNode2(value) {
3698
- return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
3699
- }
3700
3742
  function testApiCallee(expression) {
3701
3743
  let node = unwrapExpression(expression);
3702
3744
  while (node.type === AST_NODE_TYPES27.MemberExpression && !node.optional && TEST_MODIFIERS.has(ASTUtils14.getPropertyName(node) ?? "")) node = unwrapExpression(node.object);
@@ -6266,7 +6308,7 @@ function isSearchParamReceiver(call, services) {
6266
6308
  // package.json
6267
6309
  var package_default = {
6268
6310
  name: "@sarj/eslint-plugin",
6269
- version: "18.2.1",
6311
+ version: "18.3.0",
6270
6312
  packageManager: "npm@12.2.1",
6271
6313
  description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
6272
6314
  type: "module",
@@ -6912,7 +6954,7 @@ function existingFactoryContractFix(sourceCode, candidate2) {
6912
6954
  const contract = contractStatement?.type === AST_NODE_TYPES46.ExportNamedDeclaration ? contractStatement.declaration : null;
6913
6955
  const implementation = classStatement?.type === AST_NODE_TYPES46.ExportNamedDeclaration ? classStatement.declaration : classStatement;
6914
6956
  const factory = factoryStatement?.type === AST_NODE_TYPES46.ExportNamedDeclaration ? factoryStatement.declaration : null;
6915
- if (contract?.type !== AST_NODE_TYPES46.TSTypeAliasDeclaration || worker?.type !== AST_NODE_TYPES46.TSInterfaceDeclaration || implementation?.type !== AST_NODE_TYPES46.ClassDeclaration || implementation !== candidate2 || !ordinaryClass(implementation) || !ordinaryFactory(factory))
6957
+ if (contract?.type !== AST_NODE_TYPES46.TSTypeAliasDeclaration || worker?.type !== AST_NODE_TYPES46.TSInterfaceDeclaration || implementation?.type !== AST_NODE_TYPES46.ClassDeclaration || implementation !== candidate2 || !ordinaryClass(implementation) || factory?.type !== AST_NODE_TYPES46.FunctionDeclaration || !ordinaryFactory(factory))
6916
6958
  return null;
6917
6959
  const operation2 = contractOperation(contract);
6918
6960
  if (operation2 === null || interfaceOperation(worker) !== operation2)
@@ -6931,7 +6973,7 @@ function ordinaryClass(node) {
6931
6973
  return node.id !== null && !node.declare && !node.abstract && node.decorators.length === 0 && node.superClass === null && node.implements.length === 0 && node.typeParameters === void 0 && node.body.body.length === 2;
6932
6974
  }
6933
6975
  function ordinaryFactory(node) {
6934
- return node?.type === AST_NODE_TYPES46.FunctionDeclaration && node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.params.length === 1 && node.body.body.length === 1;
6976
+ return node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.params.length === 1 && node.body.body.length === 1;
6935
6977
  }
6936
6978
  function interfaceOperation(node) {
6937
6979
  return !node.declare && node.extends.length === 0 && node.typeParameters === void 0 ? singletonOperation(node.body.body) : null;
@@ -7507,8 +7549,8 @@ var publicMethodNames = (body3, functionAliases) => {
7507
7549
  };
7508
7550
  var isFluentConstructionObject = (node, getText) => {
7509
7551
  if (node.id === null) return false;
7510
- const methods = node.body.body.filter(
7511
- (member3) => member3.type === AST_NODE_TYPES47.MethodDefinition && member3.kind === "method" && !member3.static && member3.accessibility !== "private" && member3.accessibility !== "protected" && member3.value.body !== null
7552
+ const methods = node.body.body.filter((member3) => member3.type === AST_NODE_TYPES47.MethodDefinition).filter(
7553
+ (member3) => member3.kind === "method" && !member3.static && member3.accessibility !== "private" && member3.accessibility !== "protected" && member3.value.body !== null
7512
7554
  );
7513
7555
  if (methods.length === 0) return false;
7514
7556
  return methods.every((member3) => {
@@ -7672,7 +7714,7 @@ var require_port_for_service_default = createRule({
7672
7714
  const ctor = node.body.body.find(
7673
7715
  (member3) => member3.type === AST_NODE_TYPES47.MethodDefinition && member3.kind === "constructor" && member3.value.body !== null && member3.value.body !== void 0
7674
7716
  );
7675
- if (ctor === void 0) return;
7717
+ if (ctor?.type !== AST_NODE_TYPES47.MethodDefinition) return;
7676
7718
  const constructorFacts = readConstructor(
7677
7719
  ctor,
7678
7720
  objectTypes,
@@ -7739,7 +7781,7 @@ function createServiceOperationResolver(program) {
7739
7781
  const ctor = node.body.body.find(
7740
7782
  (member3) => member3.type === AST_NODE_TYPES47.MethodDefinition && member3.kind === "constructor" && member3.value.body !== null
7741
7783
  );
7742
- if (ctor === void 0) return [];
7784
+ if (ctor?.type !== AST_NODE_TYPES47.MethodDefinition) return [];
7743
7785
  const declared = () => declaredTypes ??= fileTypeIndex(program);
7744
7786
  const facts = readConstructor(
7745
7787
  ctor,
@@ -9314,7 +9356,7 @@ function ordinaryHostReference(reference) {
9314
9356
  }
9315
9357
 
9316
9358
  // src/rules/no-contradictory-type-predicate.ts
9317
- var RUNTIME_KINDS = /* @__PURE__ */ new Set(["string", "number", "bigint", "boolean", "symbol", "undefined", "object", "function"]);
9359
+ var RUNTIME_KINDS = ["string", "number", "bigint", "boolean", "symbol", "undefined", "object", "function"];
9318
9360
  var PRIMITIVE_KINDS = [
9319
9361
  [ts24.TypeFlags.String, "string"],
9320
9362
  [ts24.TypeFlags.Number, "number"],
@@ -9393,7 +9435,7 @@ var no_contradictory_type_predicate_default = createRule({
9393
9435
  if (hasSeparatePredicateContract(services.esTreeNodeToTSNodeMap.get(node), checker)) return;
9394
9436
  const parameter = node.params.find((candidate2) => candidate2.type === AST_NODE_TYPES56.Identifier && candidate2.name === name);
9395
9437
  const expression = singleReturn(node);
9396
- if (parameter?.typeAnnotation === void 0 || expression === void 0) return;
9438
+ if (parameter?.type !== AST_NODE_TYPES56.Identifier || parameter.typeAnnotation === void 0 || expression === void 0) return;
9397
9439
  const check = typeofCheck(expression);
9398
9440
  if (check !== void 0 && !sameParameter(parameter, check.parameter, context.sourceCode)) return;
9399
9441
  const input = checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(check?.parameter ?? parameter));
@@ -9484,15 +9526,13 @@ function typeofCheck(expression) {
9484
9526
  if (value.type !== AST_NODE_TYPES56.BinaryExpression || value.operator !== "===" && value.operator !== "==") return void 0;
9485
9527
  for (const [tested, expected] of [[value.left, value.right], [value.right, value.left]]) {
9486
9528
  const operand = unwrapExpression(tested);
9487
- const kind = staticString(expected);
9488
- if (operand.type !== AST_NODE_TYPES56.UnaryExpression || operand.operator !== "typeof" || operand.argument.type !== AST_NODE_TYPES56.Identifier || kind === null || !isRuntimeKind(kind)) continue;
9529
+ const expectedKind = staticString(expected);
9530
+ const kind = RUNTIME_KINDS.find((candidate2) => candidate2 === expectedKind);
9531
+ if (operand.type !== AST_NODE_TYPES56.UnaryExpression || operand.operator !== "typeof" || operand.argument.type !== AST_NODE_TYPES56.Identifier || kind === void 0) continue;
9489
9532
  return { parameter: operand.argument, kind };
9490
9533
  }
9491
9534
  return void 0;
9492
9535
  }
9493
- function isRuntimeKind(value) {
9494
- return RUNTIME_KINDS.has(value);
9495
- }
9496
9536
  function sameParameter(declared, tested, sourceCode) {
9497
9537
  const parameter = ASTUtils35.findVariable(sourceCode.getScope(declared), declared.name);
9498
9538
  return parameter !== null && parameter === ASTUtils35.findVariable(sourceCode.getScope(tested), tested.name);
@@ -9541,9 +9581,9 @@ import { AST_NODE_TYPES as AST_NODE_TYPES57, ASTUtils as ASTUtils36 } from "@typ
9541
9581
  import ts25 from "typescript";
9542
9582
  function uuidPredicateWitness(expression, parameter, sourceCode, services) {
9543
9583
  const success = unwrapExpression(expression);
9544
- if (!member(success, "success")) return void 0;
9584
+ if (success.type !== AST_NODE_TYPES57.MemberExpression || !member(success, "success")) return void 0;
9545
9585
  const parse2 = unwrapExpression(success.object);
9546
- if (parse2.type !== AST_NODE_TYPES57.CallExpression || parse2.optional || parse2.arguments.length !== 1 || !member(parse2.callee, "safeParse")) return void 0;
9586
+ if (parse2.type !== AST_NODE_TYPES57.CallExpression || parse2.optional || parse2.arguments.length !== 1 || parse2.callee.type !== AST_NODE_TYPES57.MemberExpression || !member(parse2.callee, "safeParse")) return void 0;
9547
9587
  const argument = parse2.arguments[0];
9548
9588
  if (argument === void 0 || unwrapExpression(argument).type !== AST_NODE_TYPES57.Identifier) return void 0;
9549
9589
  const value = unwrapExpression(argument);
@@ -9562,13 +9602,13 @@ function binding(node, sourceCode) {
9562
9602
  return ASTUtils36.findVariable(sourceCode.getScope(node), node.name);
9563
9603
  }
9564
9604
  function member(node, name) {
9565
- return node?.type === AST_NODE_TYPES57.MemberExpression && !node.optional && !node.computed && node.property.type === AST_NODE_TYPES57.Identifier && node.property.name === name;
9605
+ return !node.optional && !node.computed && node.property.type === AST_NODE_TYPES57.Identifier && node.property.name === name;
9566
9606
  }
9567
9607
  function uuidNamespace(initializer, sourceCode, services) {
9568
- if (!noArguments(initializer) || !member(initializer.callee, "uuid")) return null;
9608
+ if (initializer.type !== AST_NODE_TYPES57.CallExpression || !noArguments(initializer) || initializer.callee.type !== AST_NODE_TYPES57.MemberExpression || !member(initializer.callee, "uuid")) return null;
9569
9609
  let receiver = unwrapExpression(initializer.callee.object);
9570
9610
  let legacy = false;
9571
- if (noArguments(receiver) && member(receiver.callee, "string")) {
9611
+ if (receiver.type === AST_NODE_TYPES57.CallExpression && noArguments(receiver) && receiver.callee.type === AST_NODE_TYPES57.MemberExpression && member(receiver.callee, "string")) {
9572
9612
  receiver = unwrapExpression(receiver.callee.object);
9573
9613
  legacy = true;
9574
9614
  }
@@ -9584,7 +9624,7 @@ function uuidNamespace(initializer, sourceCode, services) {
9584
9624
  return namespace ?? null;
9585
9625
  }
9586
9626
  function noArguments(node) {
9587
- return node.type === AST_NODE_TYPES57.CallExpression && !node.optional && node.arguments.length === 0;
9627
+ return !node.optional && node.arguments.length === 0;
9588
9628
  }
9589
9629
  function installedZod(node, services) {
9590
9630
  const checker = services.program.getTypeChecker();
@@ -9604,7 +9644,7 @@ function closedSchema(schema) {
9604
9644
  const receiver = outerExpression(reference.identifier);
9605
9645
  const property = receiver.parent;
9606
9646
  if (property?.type === AST_NODE_TYPES57.ExportSpecifier && property.local === receiver) return true;
9607
- if (!member(property, "safeParse") || property.object !== receiver) return false;
9647
+ if (property?.type !== AST_NODE_TYPES57.MemberExpression || !member(property, "safeParse") || property.object !== receiver) return false;
9608
9648
  const call = property.parent;
9609
9649
  return call?.type === AST_NODE_TYPES57.CallExpression && call.callee === property && !call.optional && call.arguments.length === 1 && call.arguments[0]?.type !== AST_NODE_TYPES57.SpreadElement;
9610
9650
  });
@@ -10070,10 +10110,10 @@ function literalSelectorFix(sourceCode, parameter) {
10070
10110
  if (sourceCode.ast.body.length !== 4 || sourceCode.getAllComments().length > 0)
10071
10111
  return null;
10072
10112
  const [first, second, declaration, statement] = sourceCode.ast.body;
10073
- if (!isLiteralOperation(first) || !isLiteralOperation(second) || declaration?.type !== AST_NODE_TYPES60.VariableDeclaration || declaration.declare || declaration.kind !== "const" || declaration.declarations.length !== 1 || statement?.type !== AST_NODE_TYPES60.ExportNamedDeclaration || statement.declaration?.type !== AST_NODE_TYPES60.FunctionDeclaration)
10113
+ if (first?.type !== AST_NODE_TYPES60.FunctionDeclaration || !isLiteralOperation(first) || second?.type !== AST_NODE_TYPES60.FunctionDeclaration || !isLiteralOperation(second) || declaration?.type !== AST_NODE_TYPES60.VariableDeclaration || declaration.declare || declaration.kind !== "const" || declaration.declarations.length !== 1 || statement?.type !== AST_NODE_TYPES60.ExportNamedDeclaration || statement.declaration?.type !== AST_NODE_TYPES60.FunctionDeclaration)
10074
10114
  return null;
10075
10115
  const binding3 = declaration.declarations[0];
10076
- if (binding3?.id.type !== AST_NODE_TYPES60.Identifier || binding3.id.typeAnnotation !== void 0 || !isSelector(binding3.init, parameter))
10116
+ if (binding3?.id.type !== AST_NODE_TYPES60.Identifier || binding3.id.typeAnnotation !== void 0 || binding3.init?.type !== AST_NODE_TYPES60.ArrowFunctionExpression || binding3.init.body.type !== AST_NODE_TYPES60.ConditionalExpression || !isSelector(binding3.init, parameter))
10077
10117
  return null;
10078
10118
  const branch = binding3.init.body;
10079
10119
  const whenTrue = operation(sourceCode, branch.consequent, first, second);
@@ -10095,13 +10135,12 @@ function literalSelectorFix(sourceCode, parameter) {
10095
10135
  ];
10096
10136
  }
10097
10137
  function isLiteralOperation(node) {
10098
- if (node?.type !== AST_NODE_TYPES60.FunctionDeclaration || node.id === null || node.declare || node.async || node.generator || node.params.length !== 0 || node.typeParameters !== void 0 || node.returnType !== void 0 || node.body.body.length !== 1)
10138
+ if (node.id === null || node.declare || node.async || node.generator || node.params.length !== 0 || node.typeParameters !== void 0 || node.returnType !== void 0 || node.body.body.length !== 1)
10099
10139
  return false;
10100
10140
  const returned2 = node.body.body[0];
10101
10141
  return returned2?.type === AST_NODE_TYPES60.ReturnStatement && returned2.argument?.type === AST_NODE_TYPES60.Literal && typeof returned2.argument.value === "string";
10102
10142
  }
10103
10143
  function isSelector(node, parameter) {
10104
- if (node?.type !== AST_NODE_TYPES60.ArrowFunctionExpression) return false;
10105
10144
  const actual = node.params[0];
10106
10145
  return actual?.type === AST_NODE_TYPES60.Identifier && actual.name === parameter.name && !node.async && node.typeParameters === void 0 && node.returnType === void 0 && node.params.length === 1 && !actual.optional && actual.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES60.TSBooleanKeyword && node.body.type === AST_NODE_TYPES60.ConditionalExpression && node.body.test === parameter;
10107
10146
  }
@@ -11928,10 +11967,6 @@ import { AST_NODE_TYPES as AST_NODE_TYPES74 } from "@typescript-eslint/utils";
11928
11967
  var TEST_CALLERS = /* @__PURE__ */ new Set(["it", "test"]);
11929
11968
  var ASSERTION_NAMES = /* @__PURE__ */ new Set(["assert", "expect"]);
11930
11969
  var TEST_MODIFIERS2 = /* @__PURE__ */ new Set(["concurrent", "fails", "only", "sequential", "skip"]);
11931
- var FUNCTION_TYPES = /* @__PURE__ */ new Set([
11932
- AST_NODE_TYPES74.FunctionExpression,
11933
- AST_NODE_TYPES74.ArrowFunctionExpression
11934
- ]);
11935
11970
  var OMITTED_AST_KEYS = /* @__PURE__ */ new Set([
11936
11971
  "end",
11937
11972
  "loc",
@@ -12113,7 +12148,7 @@ function testBody(call, sourceCode) {
12113
12148
  return null;
12114
12149
  }
12115
12150
  const callback = call.arguments.map(unwrapExpression).find(
12116
- (argument) => argument.type !== AST_NODE_TYPES74.SpreadElement && FUNCTION_TYPES.has(argument.type)
12151
+ (argument) => argument.type === AST_NODE_TYPES74.FunctionExpression || argument.type === AST_NODE_TYPES74.ArrowFunctionExpression
12117
12152
  );
12118
12153
  if (callback === void 0 || call.arguments.length !== 2 || containsInlineSnapshot(callback.body)) {
12119
12154
  return null;
@@ -15407,7 +15442,7 @@ function uuidModule(sourceCode, kind) {
15407
15442
  const native = statements[offset + 1];
15408
15443
  const legacy = statements[offset + 2];
15409
15444
  const exported = statements[offset + 3];
15410
- if (imported !== null && imported?.type !== AST_NODE_TYPES87.ImportDeclaration || declaration?.type !== AST_NODE_TYPES87.VariableDeclaration || declaration.kind !== "const" || declaration.declare || declaration.declarations.length !== 1 || !stringFunction(native) || !stringFunction(legacy) || exported?.type !== AST_NODE_TYPES87.ExportNamedDeclaration || exported.specifiers.length !== 0 || exported.source !== null || !arrayFunction(exported.declaration))
15445
+ if (imported !== null && imported?.type !== AST_NODE_TYPES87.ImportDeclaration || declaration?.type !== AST_NODE_TYPES87.VariableDeclaration || declaration.kind !== "const" || declaration.declare || declaration.declarations.length !== 1 || native?.type !== AST_NODE_TYPES87.FunctionDeclaration || !stringFunction(native) || legacy?.type !== AST_NODE_TYPES87.FunctionDeclaration || !stringFunction(legacy) || exported?.type !== AST_NODE_TYPES87.ExportNamedDeclaration || exported.specifiers.length !== 0 || exported.source !== null || exported.declaration?.type !== AST_NODE_TYPES87.FunctionDeclaration || !arrayFunction(exported.declaration))
15411
15446
  return null;
15412
15447
  const provider = declaration.declarations[0];
15413
15448
  if (provider === void 0 || !nativeProvider(sourceCode, provider) || !providerRead(sourceCode, returned(native), provider) || !exportedReads(
@@ -15429,7 +15464,7 @@ function arrayFunction(node) {
15429
15464
  return annotation?.type === AST_NODE_TYPES87.TSArrayType && annotation.elementType.type === AST_NODE_TYPES87.TSStringKeyword;
15430
15465
  }
15431
15466
  function ordinaryFunction(node) {
15432
- return node?.type === AST_NODE_TYPES87.FunctionDeclaration && node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.params.length === 0 && node.body.body.length === 1 && node.body.body[0]?.type === AST_NODE_TYPES87.ReturnStatement && node.body.body[0].argument !== null;
15467
+ return node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.params.length === 0 && node.body.body.length === 1 && node.body.body[0]?.type === AST_NODE_TYPES87.ReturnStatement && node.body.body[0].argument !== null;
15433
15468
  }
15434
15469
  function returned(node) {
15435
15470
  const statement = node.body.body[0];
@@ -15441,14 +15476,14 @@ function nativeProvider(sourceCode, node) {
15441
15476
  if (node.id.type !== AST_NODE_TYPES87.Identifier || node.id.typeAnnotation !== void 0)
15442
15477
  return false;
15443
15478
  const call = node.init;
15444
- if (call?.type !== AST_NODE_TYPES87.CallExpression || call.optional || call.typeArguments !== void 0 || call.arguments.length !== 1 || !member2(call.callee, "bind") || !member2(call.callee.object, "randomUUID"))
15479
+ if (call?.type !== AST_NODE_TYPES87.CallExpression || call.optional || call.typeArguments !== void 0 || call.arguments.length !== 1 || call.callee.type !== AST_NODE_TYPES87.MemberExpression || !member2(call.callee, "bind") || call.callee.object.type !== AST_NODE_TYPES87.MemberExpression || !member2(call.callee.object, "randomUUID"))
15445
15480
  return false;
15446
15481
  const receiver = call.callee.object.object;
15447
15482
  const argument = call.arguments[0];
15448
15483
  return receiver.type === AST_NODE_TYPES87.Identifier && receiver.name === "crypto" && argument?.type === AST_NODE_TYPES87.Identifier && argument.name === "crypto" && (ASTUtils49.findVariable(sourceCode.getScope(receiver), "crypto")?.defs.length ?? 0) === 0 && (ASTUtils49.findVariable(sourceCode.getScope(argument), "crypto")?.defs.length ?? 0) === 0;
15449
15484
  }
15450
15485
  function member2(node, property) {
15451
- return node.type === AST_NODE_TYPES87.MemberExpression && !node.computed && !node.optional && node.property.type === AST_NODE_TYPES87.Identifier && node.property.name === property;
15486
+ return !node.computed && !node.optional && node.property.type === AST_NODE_TYPES87.Identifier && node.property.name === property;
15452
15487
  }
15453
15488
  function providerRead(sourceCode, node, declaration) {
15454
15489
  return node.type === AST_NODE_TYPES87.CallExpression && !node.optional && node.typeArguments === void 0 && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES87.Identifier && sameBinding2(sourceCode, node.callee, declaration);
@@ -15477,7 +15512,7 @@ function exportedReads(sourceCode, node, native, legacy, imported) {
15477
15512
  return nilImport !== void 0 && sameBinding2(sourceCode, nil, nilImport);
15478
15513
  }
15479
15514
  function isUuidRecipe(sourceCode, node, reported) {
15480
- if (node.type !== AST_NODE_TYPES87.CallExpression || node.optional || node.typeArguments !== void 0 || !member2(node.callee, "replace") || node.callee.object.type !== AST_NODE_TYPES87.Literal || node.callee.object.value !== UUID_TEMPLATE || node.arguments.length !== IMPORT_COUNT)
15515
+ if (node.type !== AST_NODE_TYPES87.CallExpression || node.optional || node.typeArguments !== void 0 || node.callee.type !== AST_NODE_TYPES87.MemberExpression || !member2(node.callee, "replace") || node.callee.object.type !== AST_NODE_TYPES87.Literal || node.callee.object.value !== UUID_TEMPLATE || node.arguments.length !== IMPORT_COUNT)
15481
15516
  return false;
15482
15517
  const [pattern, callback] = node.arguments;
15483
15518
  if (pattern?.type !== AST_NODE_TYPES87.Literal || !("regex" in pattern) || pattern.regex.pattern !== "[xy]" || pattern.regex.flags !== "g" || callback?.type !== AST_NODE_TYPES87.ArrowFunctionExpression || callback.async || callback.typeParameters !== void 0 || callback.returnType !== void 0 || callback.params.length !== 1 || callback.params[0]?.type !== AST_NODE_TYPES87.Identifier || callback.params[0].typeAnnotation !== void 0 || callback.params[0].optional || callback.body.type !== AST_NODE_TYPES87.BlockStatement || callback.body.body.length !== IMPORT_COUNT)
@@ -16029,8 +16064,8 @@ function serverActionErrorResults(sourceCode) {
16029
16064
  if (nodes.some((node) => node.type === AST_NODE_TYPES91.CallExpression && node.callee.type === AST_NODE_TYPES91.Identifier && node.callee.name === "eval")) return [];
16030
16065
  const analysis = new ActionResults(sourceCode);
16031
16066
  const actionSet = new Set(actions);
16032
- return nodes.filter((node) => {
16033
- if (node.type !== AST_NODE_TYPES91.ReturnStatement || node.argument === null) return false;
16067
+ return nodes.filter((node) => node.type === AST_NODE_TYPES91.ReturnStatement).filter((node) => {
16068
+ if (node.argument === null) return false;
16034
16069
  const owner = functionOwner(node);
16035
16070
  return owner !== null && actionSet.has(owner) && escapingActionReturn(node, owner, sourceCode) && analysis.payload(node.argument, owner);
16036
16071
  });
@@ -17012,7 +17047,7 @@ function existingDomainComparisonFix(sourceCode, comparison2) {
17012
17047
  if (comparison2.operator !== "===" || sourceCode.ast.body.length !== 2 || sourceCode.getAllComments().length !== 0)
17013
17048
  return null;
17014
17049
  const [comparator, exported] = sourceCode.ast.body;
17015
- if (!isOrdinary(comparator) || comparator.id === null || exported?.type !== AST_NODE_TYPES93.ExportNamedDeclaration || exported.exportKind !== "value" || !isOrdinary(exported.declaration))
17050
+ if (comparator?.type !== AST_NODE_TYPES93.FunctionDeclaration || !isOrdinary(comparator) || comparator.id === null || exported?.type !== AST_NODE_TYPES93.ExportNamedDeclaration || exported.exportKind !== "value" || exported.declaration?.type !== AST_NODE_TYPES93.FunctionDeclaration || !isOrdinary(exported.declaration))
17016
17051
  return null;
17017
17052
  const fields2 = comparatorFields(comparator);
17018
17053
  const elements = callerElements(exported.declaration);
@@ -17031,7 +17066,7 @@ function existingDomainComparisonFix(sourceCode, comparison2) {
17031
17066
  );
17032
17067
  }
17033
17068
  function isOrdinary(node) {
17034
- return node?.type === AST_NODE_TYPES93.FunctionDeclaration && node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.body.body.length === 1;
17069
+ return node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.body.body.length === 1;
17035
17070
  }
17036
17071
  function comparatorFields(node) {
17037
17072
  const [left, right] = node.params;
@@ -18269,7 +18304,7 @@ function reportClass(context, services, owner) {
18269
18304
  if (contract === null) return;
18270
18305
  const groups = /* @__PURE__ */ new Map();
18271
18306
  for (const member3 of owner.body.body) {
18272
- if (!candidate(member3)) continue;
18307
+ if (member3.type !== AST_NODE_TYPES100.MethodDefinition || !candidate(member3)) continue;
18273
18308
  const name = convertibleMemberName(member3);
18274
18309
  if (name === null || contract.has(name)) continue;
18275
18310
  if (member3.accessibility === "private" || member3.key.type === AST_NODE_TYPES100.PrivateIdentifier) continue;
@@ -18289,7 +18324,7 @@ function reportClass(context, services, owner) {
18289
18324
  }
18290
18325
  }
18291
18326
  function candidate(member3) {
18292
- return member3.type === AST_NODE_TYPES100.MethodDefinition && member3.kind !== "constructor" && !member3.static && member3.accessibility !== "protected" && !member3.override && !member3.computed && member3.key.type === AST_NODE_TYPES100.Identifier && member3.value.body !== null;
18327
+ return member3.kind !== "constructor" && !member3.static && member3.accessibility !== "protected" && !member3.override && !member3.computed && member3.key.type === AST_NODE_TYPES100.Identifier && member3.value.body !== null;
18293
18328
  }
18294
18329
  function interfaceNames(services, owner) {
18295
18330
  const tsOwner = services.esTreeNodeToTSNodeMap.get(owner);
@@ -18461,7 +18496,7 @@ var SINGLE_STATEMENT_HOSTS = /* @__PURE__ */ new Set([
18461
18496
  AST_NODE_TYPES102.IfStatement,
18462
18497
  AST_NODE_TYPES102.WhileStatement
18463
18498
  ]);
18464
- var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
18499
+ var FUNCTION_TYPES = /* @__PURE__ */ new Set([
18465
18500
  AST_NODE_TYPES102.ArrowFunctionExpression,
18466
18501
  AST_NODE_TYPES102.FunctionDeclaration,
18467
18502
  AST_NODE_TYPES102.FunctionExpression
@@ -18491,7 +18526,7 @@ function fallbackFollowsTry(tryStatement) {
18491
18526
  return last?.type === AST_NODE_TYPES102.ReturnStatement && hasFollowingStatement(tryStatement);
18492
18527
  }
18493
18528
  function hasFollowingStatement(node) {
18494
- for (let current = node; current !== void 0 && !FUNCTION_TYPES2.has(current.type); current = current.parent) {
18529
+ for (let current = node; current !== void 0 && !FUNCTION_TYPES.has(current.type); current = current.parent) {
18495
18530
  const slot = statementSlot(current);
18496
18531
  if (slot !== null && slot.index < slot.list.length - 1) return true;
18497
18532
  }
@@ -18579,7 +18614,7 @@ var no_log_only_catch_default = createRule({
18579
18614
  function hasFollowingCoercionCheck(owner, left, coercion) {
18580
18615
  let current = owner;
18581
18616
  let slot = statementSlot(current);
18582
- while (slot === null && current.parent !== void 0 && !FUNCTION_TYPES2.has(current.parent.type)) {
18617
+ while (slot === null && current.parent !== void 0 && !FUNCTION_TYPES.has(current.parent.type)) {
18583
18618
  current = current.parent;
18584
18619
  slot = statementSlot(current);
18585
18620
  }
@@ -18664,7 +18699,7 @@ var TEST_NAMES = /* @__PURE__ */ new Set(["it", "test"]);
18664
18699
  var TEST_MODIFIERS3 = /* @__PURE__ */ new Set(["concurrent", "fails", "only", "sequential", "skip"]);
18665
18700
  var TEST_BUILDERS = /* @__PURE__ */ new Set(["each", "for", "runIf", "skipIf"]);
18666
18701
  var ASSERTION_NAMES2 = /* @__PURE__ */ new Set(["assert", "assertType", "expect", "expectTypeOf"]);
18667
- var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([AST_NODE_TYPES103.ArrowFunctionExpression, AST_NODE_TYPES103.FunctionExpression, AST_NODE_TYPES103.FunctionDeclaration]);
18702
+ var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([AST_NODE_TYPES103.ArrowFunctionExpression, AST_NODE_TYPES103.FunctionExpression, AST_NODE_TYPES103.FunctionDeclaration]);
18668
18703
  function staticMemberName3(node) {
18669
18704
  if (!node.computed && node.property.type === AST_NODE_TYPES103.Identifier) return node.property.name;
18670
18705
  if (node.computed && node.property.type === AST_NODE_TYPES103.Literal && typeof node.property.value === "string") return node.property.value;
@@ -18677,7 +18712,6 @@ function rootIdentifier2(callee) {
18677
18712
  return null;
18678
18713
  }
18679
18714
  function isDirectTestCallback(node, context) {
18680
- if (node.type !== AST_NODE_TYPES103.ArrowFunctionExpression && node.type !== AST_NODE_TYPES103.FunctionExpression) return false;
18681
18715
  const call = directArgumentCall(node);
18682
18716
  if (call === null) return false;
18683
18717
  const root = testRoot(call.callee);
@@ -18697,12 +18731,12 @@ function testRoot(callee) {
18697
18731
  return modifier !== null && TEST_MODIFIERS3.has(modifier) ? testRoot(callee.object) : null;
18698
18732
  }
18699
18733
  function nearestFunction(node) {
18700
- for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) if (FUNCTION_TYPES3.has(current.type)) return current;
18734
+ for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) if (FUNCTION_TYPES2.has(current.type)) return current;
18701
18735
  return null;
18702
18736
  }
18703
18737
  function walkOwnScope(node, predicate) {
18704
18738
  if (predicate(node)) return true;
18705
- return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES3.has(child.type) && walkOwnScope(child, predicate));
18739
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES2.has(child.type) && walkOwnScope(child, predicate));
18706
18740
  }
18707
18741
  function isAssertion(node, context) {
18708
18742
  if (node.type !== AST_NODE_TYPES103.CallExpression) return false;
@@ -18794,7 +18828,7 @@ var no_bare_return_from_test_catch_default = createRule({
18794
18828
  ReturnStatement(node) {
18795
18829
  if (node.argument !== null) return;
18796
18830
  const owner = nearestFunction(node);
18797
- if (owner === null || !isDirectTestCallback(owner, context)) return;
18831
+ if (owner?.type !== AST_NODE_TYPES103.ArrowFunctionExpression && owner?.type !== AST_NODE_TYPES103.FunctionExpression || !isDirectTestCallback(owner, context)) return;
18798
18832
  let catchClause = null;
18799
18833
  for (let current = node.parent; current !== owner; current = current?.parent) {
18800
18834
  if (current?.type === AST_NODE_TYPES103.CatchClause) {
@@ -19424,7 +19458,7 @@ function labeledTupleObjectFix(sourceCode, annotation) {
19424
19458
  if (sourceCode.ast.body.length !== 2 || sourceCode.getAllComments().length > 0)
19425
19459
  return null;
19426
19460
  const [helper, statement] = sourceCode.ast.body;
19427
- if (!isOrdinary2(helper) || statement?.type !== AST_NODE_TYPES107.ExportNamedDeclaration || !isOrdinary2(statement.declaration) || helper.returnType?.typeAnnotation !== annotation)
19461
+ if (helper?.type !== AST_NODE_TYPES107.FunctionDeclaration || !isOrdinary2(helper) || statement?.type !== AST_NODE_TYPES107.ExportNamedDeclaration || statement.declaration?.type !== AST_NODE_TYPES107.FunctionDeclaration || !isOrdinary2(statement.declaration) || helper.returnType?.typeAnnotation !== annotation)
19428
19462
  return null;
19429
19463
  const caller = statement.declaration;
19430
19464
  const fields2 = tupleFields(helper);
@@ -19449,7 +19483,7 @@ function labeledTupleObjectFix(sourceCode, annotation) {
19449
19483
  ];
19450
19484
  }
19451
19485
  function isOrdinary2(node) {
19452
- return node?.type === AST_NODE_TYPES107.FunctionDeclaration && node.id !== null && !node.declare && !node.async && !node.generator && node.params.length === 0 && node.typeParameters === void 0;
19486
+ return node.id !== null && !node.declare && !node.async && !node.generator && node.params.length === 0 && node.typeParameters === void 0;
19453
19487
  }
19454
19488
  function tupleFields(helper) {
19455
19489
  const tuple = helper.returnType?.typeAnnotation;
@@ -20780,7 +20814,7 @@ var PREVIEW_LENGTH = 40;
20780
20814
  var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
20781
20815
  var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
20782
20816
  var URL_PATH_RE = /^\/(?=[^\s]*[A-Za-z0-9])[A-Za-z0-9._~!$&'()*+,;=:@%/?#{}\u005B\u005D-]+$/;
20783
- var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
20817
+ var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
20784
20818
  AST_NODE_TYPES114.FunctionDeclaration,
20785
20819
  AST_NODE_TYPES114.FunctionExpression,
20786
20820
  AST_NODE_TYPES114.ArrowFunctionExpression
@@ -20854,7 +20888,7 @@ function preview(value) {
20854
20888
  }
20855
20889
  function enclosingFunction4(node) {
20856
20890
  for (let current = node.parent; current != null; current = current.parent) {
20857
- if (FUNCTION_TYPES4.has(current.type)) {
20891
+ if (FUNCTION_TYPES3.has(current.type)) {
20858
20892
  return current;
20859
20893
  }
20860
20894
  }
@@ -22319,9 +22353,6 @@ function isSentinelArgument(arg) {
22319
22353
  function isFunctionNode(node) {
22320
22354
  return node.type === AST_NODE_TYPES119.FunctionDeclaration || node.type === AST_NODE_TYPES119.FunctionExpression || node.type === AST_NODE_TYPES119.ArrowFunctionExpression;
22321
22355
  }
22322
- function isNode3(value) {
22323
- return typeof value === "object" && value !== null && typeof value.type === "string";
22324
- }
22325
22356
  function walkWithinScope(node, visit) {
22326
22357
  let found = false;
22327
22358
  const recurse = (current) => {
@@ -22448,7 +22479,7 @@ function enclosingFunctionName(node) {
22448
22479
  let current = node.parent;
22449
22480
  while (current !== void 0 && current !== null) {
22450
22481
  if (isFunctionNode(current)) {
22451
- if ("id" in current && isNode3(current.id) && current.id.type === AST_NODE_TYPES119.Identifier) {
22482
+ if ("id" in current && current.id !== null && current.id.type === AST_NODE_TYPES119.Identifier) {
22452
22483
  return current.id.name;
22453
22484
  }
22454
22485
  const parent = current.parent;
@@ -22549,7 +22580,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
22549
22580
  function enclosingFunctionBody(node) {
22550
22581
  let current = node.parent;
22551
22582
  while (current !== void 0 && current !== null) {
22552
- if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === AST_NODE_TYPES119.BlockStatement) {
22583
+ if (isFunctionNode(current) && current.body?.type === AST_NODE_TYPES119.BlockStatement) {
22553
22584
  return current.body;
22554
22585
  }
22555
22586
  current = current.parent;
@@ -22956,7 +22987,7 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
22956
22987
  "beforeEach",
22957
22988
  "afterEach"
22958
22989
  ]);
22959
- var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
22990
+ var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
22960
22991
  AST_NODE_TYPES121.FunctionDeclaration,
22961
22992
  AST_NODE_TYPES121.FunctionExpression,
22962
22993
  AST_NODE_TYPES121.ArrowFunctionExpression
@@ -22991,7 +23022,7 @@ function isHelperSleep(node) {
22991
23022
  }
22992
23023
  function nearestEnclosingFunction(node) {
22993
23024
  for (let current = node.parent; current != null; current = current.parent) {
22994
- if (!FUNCTION_TYPES5.has(current.type)) {
23025
+ if (!FUNCTION_TYPES4.has(current.type)) {
22995
23026
  continue;
22996
23027
  }
22997
23028
  const grandparent = current.parent;
@@ -25998,7 +26029,7 @@ var ASSERTION_ROOTS = /* @__PURE__ */ new Set([
25998
26029
  "expect",
25999
26030
  "expectTypeOf"
26000
26031
  ]);
26001
- var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
26032
+ var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
26002
26033
  AST_NODE_TYPES135.FunctionDeclaration,
26003
26034
  AST_NODE_TYPES135.FunctionExpression,
26004
26035
  AST_NODE_TYPES135.ArrowFunctionExpression
@@ -26033,7 +26064,7 @@ function isTestCaller(callee, isFrameworkTest) {
26033
26064
  }
26034
26065
  function nearestEnclosingFunction2(node) {
26035
26066
  for (let current = node.parent; current != null; current = current.parent) {
26036
- if (FUNCTION_TYPES6.has(current.type)) {
26067
+ if (FUNCTION_TYPES5.has(current.type)) {
26037
26068
  return current;
26038
26069
  }
26039
26070
  }
@@ -26066,7 +26097,7 @@ function walkOwnScope2(node, predicate) {
26066
26097
  if (predicate(node)) {
26067
26098
  return true;
26068
26099
  }
26069
- return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES6.has(child.type) && walkOwnScope2(child, predicate));
26100
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES5.has(child.type) && walkOwnScope2(child, predicate));
26070
26101
  }
26071
26102
  function isAssertion2(node, isFrameworkAssertion) {
26072
26103
  if (node.type !== AST_NODE_TYPES135.CallExpression) return false;
@@ -26079,7 +26110,7 @@ function opensSubtest(node, callbackParameters) {
26079
26110
  }
26080
26111
  const callee = unwrapExpression(node.callee);
26081
26112
  return callee.type === AST_NODE_TYPES135.MemberExpression && staticMemberName6(callee) === "test" && callee.object.type === AST_NODE_TYPES135.Identifier && callbackParameters.has(callee.object.name) && node.arguments.some(
26082
- (argument) => argument.type !== AST_NODE_TYPES135.SpreadElement && FUNCTION_TYPES6.has(argument.type)
26113
+ (argument) => argument.type !== AST_NODE_TYPES135.SpreadElement && FUNCTION_TYPES5.has(argument.type)
26083
26114
  );
26084
26115
  }
26085
26116
  var LOOP_CARRIED_CONTROL = /* @__PURE__ */ new Set([
@@ -26445,7 +26476,7 @@ var PREFER_ECMASCRIPT_PRIVATE_MEMBERS_DOCUMENTATION = {
26445
26476
  function reportClass2(context, owner, services) {
26446
26477
  const groups = /* @__PURE__ */ new Map();
26447
26478
  for (const member3 of owner.body.body) {
26448
- if (!isConvertible(member3)) continue;
26479
+ if (member3.type !== AST_NODE_TYPES138.MethodDefinition && member3.type !== AST_NODE_TYPES138.PropertyDefinition && member3.type !== AST_NODE_TYPES138.AccessorProperty || !isConvertible(member3)) continue;
26449
26480
  const name = convertibleMemberName(member3);
26450
26481
  if (name === null) continue;
26451
26482
  const members = groups.get(name) ?? [];
@@ -26464,7 +26495,6 @@ function reportClass2(context, owner, services) {
26464
26495
  }
26465
26496
  }
26466
26497
  function isConvertible(member3) {
26467
- if (member3.type !== AST_NODE_TYPES138.MethodDefinition && member3.type !== AST_NODE_TYPES138.PropertyDefinition && member3.type !== AST_NODE_TYPES138.AccessorProperty) return false;
26468
26498
  return member3.accessibility === "private" && !(member3.type === AST_NODE_TYPES138.MethodDefinition && member3.kind === "constructor") && !member3.computed && member3.key.type === AST_NODE_TYPES138.Identifier && member3.decorators.length === 0 && !("declare" in member3 && member3.declare) && !member3.override && !(member3.type === AST_NODE_TYPES138.MethodDefinition && member3.value.body === null);
26469
26499
  }
26470
26500
  var prefer_ecmascript_private_members_default = createRule({
@@ -28159,7 +28189,7 @@ var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
28159
28189
  // Object-ish escape hatches
28160
28190
  "assign"
28161
28191
  ]);
28162
- var FUNCTION_TYPES7 = /* @__PURE__ */ new Set([
28192
+ var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
28163
28193
  AST_NODE_TYPES146.FunctionDeclaration,
28164
28194
  AST_NODE_TYPES146.FunctionExpression,
28165
28195
  AST_NODE_TYPES146.ArrowFunctionExpression
@@ -28181,8 +28211,8 @@ function unwrap3(node) {
28181
28211
  return node;
28182
28212
  }
28183
28213
  var HAS_STATEFUL_FLAG_RE = /[gy]/;
28184
- function isRegexLiteral(node) {
28185
- return node.type === AST_NODE_TYPES146.Literal && "regex" in node && node.regex !== void 0;
28214
+ function literalRegex(node) {
28215
+ return node.type === AST_NODE_TYPES146.Literal && "regex" in node ? node.regex : void 0;
28186
28216
  }
28187
28217
  function isLiteralOnly(node, depth) {
28188
28218
  if (depth > MAX_LITERAL_DEPTH) {
@@ -28191,7 +28221,7 @@ function isLiteralOnly(node, depth) {
28191
28221
  const inner = unwrap3(node);
28192
28222
  switch (inner.type) {
28193
28223
  case AST_NODE_TYPES146.Literal: {
28194
- return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
28224
+ return !HAS_STATEFUL_FLAG_RE.test(literalRegex(inner)?.flags ?? "");
28195
28225
  }
28196
28226
  case AST_NODE_TYPES146.TemplateLiteral: {
28197
28227
  return inner.expressions.length === 0;
@@ -28225,11 +28255,12 @@ function isLiteralOnly(node, depth) {
28225
28255
  }
28226
28256
  function classify(init, checkRegex, sourceCode) {
28227
28257
  const node = unwrapObjectFreeze(init, sourceCode);
28228
- if (isRegexLiteral(node)) {
28258
+ const regex = literalRegex(node);
28259
+ if (regex !== void 0) {
28229
28260
  if (!checkRegex) {
28230
28261
  return null;
28231
28262
  }
28232
- if (HAS_STATEFUL_FLAG_RE.test(node.regex.flags)) {
28263
+ if (HAS_STATEFUL_FLAG_RE.test(regex.flags)) {
28233
28264
  return null;
28234
28265
  }
28235
28266
  return { kind: "regex", size: 1 };
@@ -28256,7 +28287,7 @@ function unwrapObjectFreeze(node, sourceCode) {
28256
28287
  function enclosingFunction5(node) {
28257
28288
  let current = node.parent;
28258
28289
  while (current !== void 0 && current !== null) {
28259
- if (FUNCTION_TYPES7.has(current.type)) {
28290
+ if (FUNCTION_TYPES6.has(current.type)) {
28260
28291
  return current;
28261
28292
  }
28262
28293
  current = current.parent;
@@ -28560,7 +28591,7 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
28560
28591
  "i18n",
28561
28592
  "intl"
28562
28593
  ]);
28563
- var FUNCTION_TYPES8 = /* @__PURE__ */ new Set([
28594
+ var FUNCTION_TYPES7 = /* @__PURE__ */ new Set([
28564
28595
  AST_NODE_TYPES147.ArrowFunctionExpression,
28565
28596
  AST_NODE_TYPES147.FunctionDeclaration,
28566
28597
  AST_NODE_TYPES147.FunctionExpression
@@ -28586,7 +28617,7 @@ function outermostEnclosingFunction(node) {
28586
28617
  let outermost;
28587
28618
  let current = node.parent ?? void 0;
28588
28619
  while (current !== void 0) {
28589
- if (FUNCTION_TYPES8.has(current.type)) {
28620
+ if (FUNCTION_TYPES7.has(current.type)) {
28590
28621
  outermost = current;
28591
28622
  }
28592
28623
  current = current.parent ?? void 0;
@@ -28609,7 +28640,7 @@ function subtreeSome(root, predicate, skipDeferredFunctions = false) {
28609
28640
  if (typeof candidate2.type !== "string") {
28610
28641
  return;
28611
28642
  }
28612
- if (skipDeferredFunctions && FUNCTION_TYPES8.has(candidate2.type)) return;
28643
+ if (skipDeferredFunctions && FUNCTION_TYPES7.has(candidate2.type)) return;
28613
28644
  if (predicate(candidate2)) {
28614
28645
  found = true;
28615
28646
  return;
@@ -28724,7 +28755,7 @@ var prefer_module_level_schema_default = createRule({
28724
28755
  function isCovered(node) {
28725
28756
  let current = node.parent ?? void 0;
28726
28757
  while (current !== void 0) {
28727
- if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES147.MemberExpression && ASTUtils94.getPropertyName(current.callee) !== null && factories.has(ASTUtils94.getPropertyName(current.callee) ?? "")) {
28758
+ if (current !== node && current.type === AST_NODE_TYPES147.CallExpression && isZodCall(current) && current.callee.type === AST_NODE_TYPES147.MemberExpression && ASTUtils94.getPropertyName(current.callee) !== null && factories.has(ASTUtils94.getPropertyName(current.callee) ?? "")) {
28728
28759
  return true;
28729
28760
  }
28730
28761
  if (current.type === AST_NODE_TYPES147.CallExpression && (current.callee.type === AST_NODE_TYPES147.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES147.MemberExpression && ASTUtils94.getPropertyName(current.callee) !== null && memoCallees.has(ASTUtils94.getPropertyName(current.callee) ?? ""))) {
@@ -28983,7 +29014,7 @@ var I18N_RECEIVER_NAMES2 = /* @__PURE__ */ new Set([
28983
29014
  "i18n",
28984
29015
  "intl"
28985
29016
  ]);
28986
- var FUNCTION_TYPES9 = /* @__PURE__ */ new Set([
29017
+ var FUNCTION_TYPES8 = /* @__PURE__ */ new Set([
28987
29018
  AST_NODE_TYPES148.ArrowFunctionExpression,
28988
29019
  AST_NODE_TYPES148.FunctionDeclaration,
28989
29020
  AST_NODE_TYPES148.FunctionExpression
@@ -29031,7 +29062,7 @@ function outermostEnclosingFunction2(node) {
29031
29062
  let outermost;
29032
29063
  let current = node.parent ?? void 0;
29033
29064
  while (current !== void 0) {
29034
- if (FUNCTION_TYPES9.has(current.type)) outermost = current;
29065
+ if (FUNCTION_TYPES8.has(current.type)) outermost = current;
29035
29066
  current = current.parent ?? void 0;
29036
29067
  }
29037
29068
  return outermost;
@@ -29050,7 +29081,7 @@ function subtreeSome2(root, predicate, skipDeferredFunctions = false) {
29050
29081
  }
29051
29082
  const candidate2 = value;
29052
29083
  if (typeof candidate2.type !== "string") return;
29053
- if (skipDeferredFunctions && FUNCTION_TYPES9.has(candidate2.type)) return;
29084
+ if (skipDeferredFunctions && FUNCTION_TYPES8.has(candidate2.type)) return;
29054
29085
  if (predicate(candidate2)) {
29055
29086
  found = true;
29056
29087
  return;
@@ -29196,7 +29227,7 @@ var prefer_module_level_refined_schema_default = createRule({
29196
29227
  let current = node;
29197
29228
  while (current.parent != null) {
29198
29229
  current = current.parent;
29199
- if (FUNCTION_TYPES9.has(current.type)) return false;
29230
+ if (FUNCTION_TYPES8.has(current.type)) return false;
29200
29231
  if (current.type === AST_NODE_TYPES148.CallExpression && (factoryName(current, FACTORIES) !== null || factoryName(current, COMPOSITE_FACTORIES) !== null))
29201
29232
  return true;
29202
29233
  }
@@ -31072,7 +31103,7 @@ var prefer_non_nullable_collection_default = createRule({
31072
31103
  const bindingProperty = parameter.properties.find(
31073
31104
  (entry) => entry.type === AST_NODE_TYPES158.Property && !entry.computed && ASTUtils102.getPropertyName(entry) === property.name
31074
31105
  );
31075
- if (bindingProperty === void 0) continue;
31106
+ if (bindingProperty?.type !== AST_NODE_TYPES158.Property) continue;
31076
31107
  const value = bindingProperty.value;
31077
31108
  const binding3 = value.type === AST_NODE_TYPES158.AssignmentPattern ? value.left : value;
31078
31109
  if (binding3.type !== AST_NODE_TYPES158.Identifier) {
@@ -35885,7 +35916,7 @@ function injectedMembers(owner) {
35885
35916
  const constructor = owner.body.body.find(
35886
35917
  (member3) => member3.type === AST_NODE_TYPES174.MethodDefinition && member3.kind === "constructor"
35887
35918
  );
35888
- if (constructor === void 0) return injected;
35919
+ if (constructor?.type !== AST_NODE_TYPES174.MethodDefinition) return injected;
35889
35920
  const parameters = /* @__PURE__ */ new Set();
35890
35921
  for (const parameter of constructor.value.params) {
35891
35922
  for (const name of parameterNames(parameter)) parameters.add(name);
@@ -38628,6 +38659,7 @@ var RETIRED_RULES = {
38628
38659
 
38629
38660
  // src/index.ts
38630
38661
  var RULES = {
38662
+ "no-explicit-type-predicate": no_explicit_type_predicate_default,
38631
38663
  "prefer-zod-enum-validator": prefer_zod_enum_validator_default,
38632
38664
  "no-growing-array-spread-in-loop": no_growing_array_spread_in_loop_default,
38633
38665
  "no-logical-or-fallback": no_logical_or_fallback_default,
@@ -38810,6 +38842,7 @@ var RULE_POLICY = {
38810
38842
  "@sarj/no-invalid-typed-mutation": ["error", "both"],
38811
38843
  "@sarj/no-contradictory-type-predicate": ["error", "both"],
38812
38844
  "@sarj/no-partial-type-predicate": ["error", "both"],
38845
+ "@sarj/no-explicit-type-predicate": ["warn", "both"],
38813
38846
  "@sarj/no-boolean-selector-parameter": ["warn", "both"],
38814
38847
  "@sarj/no-invalid-zod-custom-parse": ["error", "both"],
38815
38848
  "@sarj/no-contradictory-overload-return": ["error", "both"],