@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.cjs CHANGED
@@ -49,9 +49,6 @@ __export(src_exports, {
49
49
  });
50
50
  module.exports = __toCommonJS(src_exports);
51
51
 
52
- // src/rules/prefer-zod-enum-validator.ts
53
- var import_utils5 = require("@typescript-eslint/utils");
54
-
55
52
  // src/rules/_eslint-rule.ts
56
53
  var import_utils2 = require("@typescript-eslint/utils");
57
54
 
@@ -538,21 +535,21 @@ function validateExpectedSuggestion(value, exampleId, messageIds) {
538
535
  assertFields(value, ["messageId", "output"], exampleId);
539
536
  }
540
537
  function validateExpectedLocation(value, exampleId) {
541
- if (!isObject(value) || !("line" in value) || !positiveCoordinate(value.line) || !("column" in value) || !positiveCoordinate(value.column)) {
538
+ if (!isObject(value) || !("line" in value) || typeof value.line !== "number" || !positiveCoordinate(value.line) || !("column" in value) || typeof value.column !== "number" || !positiveCoordinate(value.column)) {
542
539
  throw new TypeError(`${exampleId}: expected diagnostic location requires positive integer coordinates`);
543
540
  }
544
541
  if (!("end" in value)) {
545
542
  assertFields(value, ["line", "column"], exampleId);
546
543
  return;
547
544
  }
548
- 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) {
545
+ 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) {
549
546
  throw new TypeError(`${exampleId}: expected diagnostic end point must be complete and ordered`);
550
547
  }
551
548
  assertFields(value.end, ["line", "column"], exampleId);
552
549
  assertFields(value, ["line", "column", "end"], exampleId);
553
550
  }
554
551
  function positiveCoordinate(value) {
555
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
552
+ return Number.isSafeInteger(value) && value >= 1;
556
553
  }
557
554
  function assertFields(value, expected, exampleId) {
558
555
  const fields2 = Object.keys(value);
@@ -704,6 +701,56 @@ function commentLineEnd(sourceText, start) {
704
701
  return end === -1 ? sourceText.length : start + end;
705
702
  }
706
703
 
704
+ // src/rules/no-explicit-type-predicate.ts
705
+ var NO_EXPLICIT_TYPE_PREDICATE_DOCUMENTATION = {
706
+ defaultLevel: "warning",
707
+ summary: "Use compiler-checked narrowing instead of handwritten type predicates.",
708
+ 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.",
709
+ 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.",
710
+ category: "maintainability",
711
+ autofix: "none",
712
+ requiresTypeInformation: false,
713
+ limitations: [
714
+ "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.",
715
+ "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.",
716
+ "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.",
717
+ "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."
718
+ ],
719
+ references: [
720
+ "https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions",
721
+ "https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#inferred-type-predicates",
722
+ "https://zod.dev/basics"
723
+ ],
724
+ examples: [
725
+ { 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 },
726
+ { 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 },
727
+ { 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 },
728
+ { 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 }
729
+ ]
730
+ };
731
+ var no_explicit_type_predicate_default = createRule({
732
+ name: "no-explicit-type-predicate",
733
+ documentation: NO_EXPLICIT_TYPE_PREDICATE_DOCUMENTATION,
734
+ meta: {
735
+ type: "suggestion",
736
+ docs: { description: NO_EXPLICIT_TYPE_PREDICATE_DOCUMENTATION.summary },
737
+ schema: [],
738
+ 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." }
739
+ },
740
+ defaultOptions: [],
741
+ create(context) {
742
+ if (isGeneratedFile(context, context.sourceCode.text)) return {};
743
+ return {
744
+ TSTypePredicate(node) {
745
+ if (node.typeAnnotation != null) context.report({ node, messageId: "noExplicitTypePredicate" });
746
+ }
747
+ };
748
+ }
749
+ });
750
+
751
+ // src/rules/prefer-zod-enum-validator.ts
752
+ var import_utils5 = require("@typescript-eslint/utils");
753
+
707
754
  // src/rules/_static-string.ts
708
755
  var import_utils4 = require("@typescript-eslint/utils");
709
756
 
@@ -3705,7 +3752,7 @@ function fixtureConstructor(source, value) {
3705
3752
  const use = value.params[1];
3706
3753
  if (use?.type !== import_utils29.AST_NODE_TYPES.Identifier) return null;
3707
3754
  const binding3 = stableBinding(source, use);
3708
- const calls = scopeNodes(value.body, source).filter((node) => node.type === import_utils29.AST_NODE_TYPES.CallExpression && !node.optional && node.arguments.length === 1 && node.callee.type === import_utils29.AST_NODE_TYPES.Identifier && stableBinding(source, node.callee) === binding3);
3755
+ const calls = scopeNodes(value.body, source).filter((node) => node.type === import_utils29.AST_NODE_TYPES.CallExpression).filter((node) => !node.optional && node.arguments.length === 1 && node.callee.type === import_utils29.AST_NODE_TYPES.Identifier && stableBinding(source, node.callee) === binding3);
3709
3756
  if (calls.length !== 1 || binding3 === null) return null;
3710
3757
  const argument = calls[0]?.arguments[0];
3711
3758
  return argument === void 0 || argument.type === import_utils29.AST_NODE_TYPES.SpreadElement ? null : newConstructor(source, argument);
@@ -3728,17 +3775,12 @@ function scopeNodes(root, source) {
3728
3775
  if (node === void 0) continue;
3729
3776
  result.push(node);
3730
3777
  if (node !== root && (node.type === import_utils29.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils29.AST_NODE_TYPES.FunctionExpression || node.type === import_utils29.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils29.AST_NODE_TYPES.ClassDeclaration || node.type === import_utils29.AST_NODE_TYPES.ClassExpression)) continue;
3731
- for (const key of source.visitorKeys[node.type] ?? []) {
3732
- const value = Reflect.get(node, key);
3733
- if (Array.isArray(value)) pending.push(...value.filter(isNode2));
3734
- else if (isNode2(value)) pending.push(value);
3735
- }
3778
+ forEachAstChild(node, source.visitorKeys, (child) => {
3779
+ pending.push(child);
3780
+ });
3736
3781
  }
3737
3782
  return result;
3738
3783
  }
3739
- function isNode2(value) {
3740
- return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
3741
- }
3742
3784
  function testApiCallee(expression) {
3743
3785
  let node = unwrapExpression(expression);
3744
3786
  while (node.type === import_utils29.AST_NODE_TYPES.MemberExpression && !node.optional && TEST_MODIFIERS.has(import_utils29.ASTUtils.getPropertyName(node) ?? "")) node = unwrapExpression(node.object);
@@ -6305,7 +6347,7 @@ function isSearchParamReceiver(call, services) {
6305
6347
  // package.json
6306
6348
  var package_default = {
6307
6349
  name: "@sarj/eslint-plugin",
6308
- version: "18.2.1",
6350
+ version: "18.3.0",
6309
6351
  packageManager: "npm@12.2.1",
6310
6352
  description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
6311
6353
  type: "module",
@@ -6951,7 +6993,7 @@ function existingFactoryContractFix(sourceCode, candidate2) {
6951
6993
  const contract = contractStatement?.type === import_utils48.AST_NODE_TYPES.ExportNamedDeclaration ? contractStatement.declaration : null;
6952
6994
  const implementation = classStatement?.type === import_utils48.AST_NODE_TYPES.ExportNamedDeclaration ? classStatement.declaration : classStatement;
6953
6995
  const factory = factoryStatement?.type === import_utils48.AST_NODE_TYPES.ExportNamedDeclaration ? factoryStatement.declaration : null;
6954
- if (contract?.type !== import_utils48.AST_NODE_TYPES.TSTypeAliasDeclaration || worker?.type !== import_utils48.AST_NODE_TYPES.TSInterfaceDeclaration || implementation?.type !== import_utils48.AST_NODE_TYPES.ClassDeclaration || implementation !== candidate2 || !ordinaryClass(implementation) || !ordinaryFactory(factory))
6996
+ if (contract?.type !== import_utils48.AST_NODE_TYPES.TSTypeAliasDeclaration || worker?.type !== import_utils48.AST_NODE_TYPES.TSInterfaceDeclaration || implementation?.type !== import_utils48.AST_NODE_TYPES.ClassDeclaration || implementation !== candidate2 || !ordinaryClass(implementation) || factory?.type !== import_utils48.AST_NODE_TYPES.FunctionDeclaration || !ordinaryFactory(factory))
6955
6997
  return null;
6956
6998
  const operation2 = contractOperation(contract);
6957
6999
  if (operation2 === null || interfaceOperation(worker) !== operation2)
@@ -6970,7 +7012,7 @@ function ordinaryClass(node) {
6970
7012
  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;
6971
7013
  }
6972
7014
  function ordinaryFactory(node) {
6973
- return node?.type === import_utils48.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.params.length === 1 && node.body.body.length === 1;
7015
+ return node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.params.length === 1 && node.body.body.length === 1;
6974
7016
  }
6975
7017
  function interfaceOperation(node) {
6976
7018
  return !node.declare && node.extends.length === 0 && node.typeParameters === void 0 ? singletonOperation(node.body.body) : null;
@@ -7543,8 +7585,8 @@ var publicMethodNames = (body3, functionAliases) => {
7543
7585
  };
7544
7586
  var isFluentConstructionObject = (node, getText) => {
7545
7587
  if (node.id === null) return false;
7546
- const methods = node.body.body.filter(
7547
- (member3) => member3.type === import_utils49.AST_NODE_TYPES.MethodDefinition && member3.kind === "method" && !member3.static && member3.accessibility !== "private" && member3.accessibility !== "protected" && member3.value.body !== null
7588
+ const methods = node.body.body.filter((member3) => member3.type === import_utils49.AST_NODE_TYPES.MethodDefinition).filter(
7589
+ (member3) => member3.kind === "method" && !member3.static && member3.accessibility !== "private" && member3.accessibility !== "protected" && member3.value.body !== null
7548
7590
  );
7549
7591
  if (methods.length === 0) return false;
7550
7592
  return methods.every((member3) => {
@@ -7708,7 +7750,7 @@ var require_port_for_service_default = createRule({
7708
7750
  const ctor = node.body.body.find(
7709
7751
  (member3) => member3.type === import_utils49.AST_NODE_TYPES.MethodDefinition && member3.kind === "constructor" && member3.value.body !== null && member3.value.body !== void 0
7710
7752
  );
7711
- if (ctor === void 0) return;
7753
+ if (ctor?.type !== import_utils49.AST_NODE_TYPES.MethodDefinition) return;
7712
7754
  const constructorFacts = readConstructor(
7713
7755
  ctor,
7714
7756
  objectTypes,
@@ -7775,7 +7817,7 @@ function createServiceOperationResolver(program) {
7775
7817
  const ctor = node.body.body.find(
7776
7818
  (member3) => member3.type === import_utils49.AST_NODE_TYPES.MethodDefinition && member3.kind === "constructor" && member3.value.body !== null
7777
7819
  );
7778
- if (ctor === void 0) return [];
7820
+ if (ctor?.type !== import_utils49.AST_NODE_TYPES.MethodDefinition) return [];
7779
7821
  const declared = () => declaredTypes ??= fileTypeIndex(program);
7780
7822
  const facts = readConstructor(
7781
7823
  ctor,
@@ -9350,7 +9392,7 @@ function ordinaryHostReference(reference) {
9350
9392
  }
9351
9393
 
9352
9394
  // src/rules/no-contradictory-type-predicate.ts
9353
- var RUNTIME_KINDS = /* @__PURE__ */ new Set(["string", "number", "bigint", "boolean", "symbol", "undefined", "object", "function"]);
9395
+ var RUNTIME_KINDS = ["string", "number", "bigint", "boolean", "symbol", "undefined", "object", "function"];
9354
9396
  var PRIMITIVE_KINDS = [
9355
9397
  [import_typescript23.default.TypeFlags.String, "string"],
9356
9398
  [import_typescript23.default.TypeFlags.Number, "number"],
@@ -9429,7 +9471,7 @@ var no_contradictory_type_predicate_default = createRule({
9429
9471
  if (hasSeparatePredicateContract(services.esTreeNodeToTSNodeMap.get(node), checker)) return;
9430
9472
  const parameter = node.params.find((candidate2) => candidate2.type === import_utils59.AST_NODE_TYPES.Identifier && candidate2.name === name);
9431
9473
  const expression = singleReturn(node);
9432
- if (parameter?.typeAnnotation === void 0 || expression === void 0) return;
9474
+ if (parameter?.type !== import_utils59.AST_NODE_TYPES.Identifier || parameter.typeAnnotation === void 0 || expression === void 0) return;
9433
9475
  const check = typeofCheck(expression);
9434
9476
  if (check !== void 0 && !sameParameter(parameter, check.parameter, context.sourceCode)) return;
9435
9477
  const input = checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(check?.parameter ?? parameter));
@@ -9520,15 +9562,13 @@ function typeofCheck(expression) {
9520
9562
  if (value.type !== import_utils59.AST_NODE_TYPES.BinaryExpression || value.operator !== "===" && value.operator !== "==") return void 0;
9521
9563
  for (const [tested, expected] of [[value.left, value.right], [value.right, value.left]]) {
9522
9564
  const operand = unwrapExpression(tested);
9523
- const kind = staticString(expected);
9524
- if (operand.type !== import_utils59.AST_NODE_TYPES.UnaryExpression || operand.operator !== "typeof" || operand.argument.type !== import_utils59.AST_NODE_TYPES.Identifier || kind === null || !isRuntimeKind(kind)) continue;
9565
+ const expectedKind = staticString(expected);
9566
+ const kind = RUNTIME_KINDS.find((candidate2) => candidate2 === expectedKind);
9567
+ if (operand.type !== import_utils59.AST_NODE_TYPES.UnaryExpression || operand.operator !== "typeof" || operand.argument.type !== import_utils59.AST_NODE_TYPES.Identifier || kind === void 0) continue;
9525
9568
  return { parameter: operand.argument, kind };
9526
9569
  }
9527
9570
  return void 0;
9528
9571
  }
9529
- function isRuntimeKind(value) {
9530
- return RUNTIME_KINDS.has(value);
9531
- }
9532
9572
  function sameParameter(declared, tested, sourceCode) {
9533
9573
  const parameter = import_utils59.ASTUtils.findVariable(sourceCode.getScope(declared), declared.name);
9534
9574
  return parameter !== null && parameter === import_utils59.ASTUtils.findVariable(sourceCode.getScope(tested), tested.name);
@@ -9577,9 +9617,9 @@ var import_utils60 = require("@typescript-eslint/utils");
9577
9617
  var import_typescript24 = __toESM(require("typescript"), 1);
9578
9618
  function uuidPredicateWitness(expression, parameter, sourceCode, services) {
9579
9619
  const success = unwrapExpression(expression);
9580
- if (!member(success, "success")) return void 0;
9620
+ if (success.type !== import_utils60.AST_NODE_TYPES.MemberExpression || !member(success, "success")) return void 0;
9581
9621
  const parse2 = unwrapExpression(success.object);
9582
- if (parse2.type !== import_utils60.AST_NODE_TYPES.CallExpression || parse2.optional || parse2.arguments.length !== 1 || !member(parse2.callee, "safeParse")) return void 0;
9622
+ if (parse2.type !== import_utils60.AST_NODE_TYPES.CallExpression || parse2.optional || parse2.arguments.length !== 1 || parse2.callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression || !member(parse2.callee, "safeParse")) return void 0;
9583
9623
  const argument = parse2.arguments[0];
9584
9624
  if (argument === void 0 || unwrapExpression(argument).type !== import_utils60.AST_NODE_TYPES.Identifier) return void 0;
9585
9625
  const value = unwrapExpression(argument);
@@ -9598,13 +9638,13 @@ function binding(node, sourceCode) {
9598
9638
  return import_utils60.ASTUtils.findVariable(sourceCode.getScope(node), node.name);
9599
9639
  }
9600
9640
  function member(node, name) {
9601
- return node?.type === import_utils60.AST_NODE_TYPES.MemberExpression && !node.optional && !node.computed && node.property.type === import_utils60.AST_NODE_TYPES.Identifier && node.property.name === name;
9641
+ return !node.optional && !node.computed && node.property.type === import_utils60.AST_NODE_TYPES.Identifier && node.property.name === name;
9602
9642
  }
9603
9643
  function uuidNamespace(initializer, sourceCode, services) {
9604
- if (!noArguments(initializer) || !member(initializer.callee, "uuid")) return null;
9644
+ if (initializer.type !== import_utils60.AST_NODE_TYPES.CallExpression || !noArguments(initializer) || initializer.callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression || !member(initializer.callee, "uuid")) return null;
9605
9645
  let receiver = unwrapExpression(initializer.callee.object);
9606
9646
  let legacy = false;
9607
- if (noArguments(receiver) && member(receiver.callee, "string")) {
9647
+ if (receiver.type === import_utils60.AST_NODE_TYPES.CallExpression && noArguments(receiver) && receiver.callee.type === import_utils60.AST_NODE_TYPES.MemberExpression && member(receiver.callee, "string")) {
9608
9648
  receiver = unwrapExpression(receiver.callee.object);
9609
9649
  legacy = true;
9610
9650
  }
@@ -9620,7 +9660,7 @@ function uuidNamespace(initializer, sourceCode, services) {
9620
9660
  return namespace ?? null;
9621
9661
  }
9622
9662
  function noArguments(node) {
9623
- return node.type === import_utils60.AST_NODE_TYPES.CallExpression && !node.optional && node.arguments.length === 0;
9663
+ return !node.optional && node.arguments.length === 0;
9624
9664
  }
9625
9665
  function installedZod(node, services) {
9626
9666
  const checker = services.program.getTypeChecker();
@@ -9640,7 +9680,7 @@ function closedSchema(schema) {
9640
9680
  const receiver = outerExpression(reference.identifier);
9641
9681
  const property = receiver.parent;
9642
9682
  if (property?.type === import_utils60.AST_NODE_TYPES.ExportSpecifier && property.local === receiver) return true;
9643
- if (!member(property, "safeParse") || property.object !== receiver) return false;
9683
+ if (property?.type !== import_utils60.AST_NODE_TYPES.MemberExpression || !member(property, "safeParse") || property.object !== receiver) return false;
9644
9684
  const call = property.parent;
9645
9685
  return call?.type === import_utils60.AST_NODE_TYPES.CallExpression && call.callee === property && !call.optional && call.arguments.length === 1 && call.arguments[0]?.type !== import_utils60.AST_NODE_TYPES.SpreadElement;
9646
9686
  });
@@ -10106,10 +10146,10 @@ function literalSelectorFix(sourceCode, parameter) {
10106
10146
  if (sourceCode.ast.body.length !== 4 || sourceCode.getAllComments().length > 0)
10107
10147
  return null;
10108
10148
  const [first, second, declaration, statement] = sourceCode.ast.body;
10109
- if (!isLiteralOperation(first) || !isLiteralOperation(second) || declaration?.type !== import_utils63.AST_NODE_TYPES.VariableDeclaration || declaration.declare || declaration.kind !== "const" || declaration.declarations.length !== 1 || statement?.type !== import_utils63.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration?.type !== import_utils63.AST_NODE_TYPES.FunctionDeclaration)
10149
+ if (first?.type !== import_utils63.AST_NODE_TYPES.FunctionDeclaration || !isLiteralOperation(first) || second?.type !== import_utils63.AST_NODE_TYPES.FunctionDeclaration || !isLiteralOperation(second) || declaration?.type !== import_utils63.AST_NODE_TYPES.VariableDeclaration || declaration.declare || declaration.kind !== "const" || declaration.declarations.length !== 1 || statement?.type !== import_utils63.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration?.type !== import_utils63.AST_NODE_TYPES.FunctionDeclaration)
10110
10150
  return null;
10111
10151
  const binding3 = declaration.declarations[0];
10112
- if (binding3?.id.type !== import_utils63.AST_NODE_TYPES.Identifier || binding3.id.typeAnnotation !== void 0 || !isSelector(binding3.init, parameter))
10152
+ if (binding3?.id.type !== import_utils63.AST_NODE_TYPES.Identifier || binding3.id.typeAnnotation !== void 0 || binding3.init?.type !== import_utils63.AST_NODE_TYPES.ArrowFunctionExpression || binding3.init.body.type !== import_utils63.AST_NODE_TYPES.ConditionalExpression || !isSelector(binding3.init, parameter))
10113
10153
  return null;
10114
10154
  const branch = binding3.init.body;
10115
10155
  const whenTrue = operation(sourceCode, branch.consequent, first, second);
@@ -10131,13 +10171,12 @@ function literalSelectorFix(sourceCode, parameter) {
10131
10171
  ];
10132
10172
  }
10133
10173
  function isLiteralOperation(node) {
10134
- if (node?.type !== import_utils63.AST_NODE_TYPES.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)
10174
+ 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)
10135
10175
  return false;
10136
10176
  const returned2 = node.body.body[0];
10137
10177
  return returned2?.type === import_utils63.AST_NODE_TYPES.ReturnStatement && returned2.argument?.type === import_utils63.AST_NODE_TYPES.Literal && typeof returned2.argument.value === "string";
10138
10178
  }
10139
10179
  function isSelector(node, parameter) {
10140
- if (node?.type !== import_utils63.AST_NODE_TYPES.ArrowFunctionExpression) return false;
10141
10180
  const actual = node.params[0];
10142
10181
  return actual?.type === import_utils63.AST_NODE_TYPES.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 === import_utils63.AST_NODE_TYPES.TSBooleanKeyword && node.body.type === import_utils63.AST_NODE_TYPES.ConditionalExpression && node.body.test === parameter;
10143
10182
  }
@@ -11964,10 +12003,6 @@ var import_utils77 = require("@typescript-eslint/utils");
11964
12003
  var TEST_CALLERS = /* @__PURE__ */ new Set(["it", "test"]);
11965
12004
  var ASSERTION_NAMES = /* @__PURE__ */ new Set(["assert", "expect"]);
11966
12005
  var TEST_MODIFIERS2 = /* @__PURE__ */ new Set(["concurrent", "fails", "only", "sequential", "skip"]);
11967
- var FUNCTION_TYPES = /* @__PURE__ */ new Set([
11968
- import_utils77.AST_NODE_TYPES.FunctionExpression,
11969
- import_utils77.AST_NODE_TYPES.ArrowFunctionExpression
11970
- ]);
11971
12006
  var OMITTED_AST_KEYS = /* @__PURE__ */ new Set([
11972
12007
  "end",
11973
12008
  "loc",
@@ -12149,7 +12184,7 @@ function testBody(call, sourceCode) {
12149
12184
  return null;
12150
12185
  }
12151
12186
  const callback = call.arguments.map(unwrapExpression).find(
12152
- (argument) => argument.type !== import_utils77.AST_NODE_TYPES.SpreadElement && FUNCTION_TYPES.has(argument.type)
12187
+ (argument) => argument.type === import_utils77.AST_NODE_TYPES.FunctionExpression || argument.type === import_utils77.AST_NODE_TYPES.ArrowFunctionExpression
12153
12188
  );
12154
12189
  if (callback === void 0 || call.arguments.length !== 2 || containsInlineSnapshot(callback.body)) {
12155
12190
  return null;
@@ -15443,7 +15478,7 @@ function uuidModule(sourceCode, kind) {
15443
15478
  const native = statements[offset + 1];
15444
15479
  const legacy = statements[offset + 2];
15445
15480
  const exported = statements[offset + 3];
15446
- if (imported !== null && imported?.type !== import_utils93.AST_NODE_TYPES.ImportDeclaration || declaration?.type !== import_utils93.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare || declaration.declarations.length !== 1 || !stringFunction(native) || !stringFunction(legacy) || exported?.type !== import_utils93.AST_NODE_TYPES.ExportNamedDeclaration || exported.specifiers.length !== 0 || exported.source !== null || !arrayFunction(exported.declaration))
15481
+ if (imported !== null && imported?.type !== import_utils93.AST_NODE_TYPES.ImportDeclaration || declaration?.type !== import_utils93.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare || declaration.declarations.length !== 1 || native?.type !== import_utils93.AST_NODE_TYPES.FunctionDeclaration || !stringFunction(native) || legacy?.type !== import_utils93.AST_NODE_TYPES.FunctionDeclaration || !stringFunction(legacy) || exported?.type !== import_utils93.AST_NODE_TYPES.ExportNamedDeclaration || exported.specifiers.length !== 0 || exported.source !== null || exported.declaration?.type !== import_utils93.AST_NODE_TYPES.FunctionDeclaration || !arrayFunction(exported.declaration))
15447
15482
  return null;
15448
15483
  const provider = declaration.declarations[0];
15449
15484
  if (provider === void 0 || !nativeProvider(sourceCode, provider) || !providerRead(sourceCode, returned(native), provider) || !exportedReads(
@@ -15465,7 +15500,7 @@ function arrayFunction(node) {
15465
15500
  return annotation?.type === import_utils93.AST_NODE_TYPES.TSArrayType && annotation.elementType.type === import_utils93.AST_NODE_TYPES.TSStringKeyword;
15466
15501
  }
15467
15502
  function ordinaryFunction(node) {
15468
- return node?.type === import_utils93.AST_NODE_TYPES.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 === import_utils93.AST_NODE_TYPES.ReturnStatement && node.body.body[0].argument !== null;
15503
+ 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 === import_utils93.AST_NODE_TYPES.ReturnStatement && node.body.body[0].argument !== null;
15469
15504
  }
15470
15505
  function returned(node) {
15471
15506
  const statement = node.body.body[0];
@@ -15477,14 +15512,14 @@ function nativeProvider(sourceCode, node) {
15477
15512
  if (node.id.type !== import_utils93.AST_NODE_TYPES.Identifier || node.id.typeAnnotation !== void 0)
15478
15513
  return false;
15479
15514
  const call = node.init;
15480
- if (call?.type !== import_utils93.AST_NODE_TYPES.CallExpression || call.optional || call.typeArguments !== void 0 || call.arguments.length !== 1 || !member2(call.callee, "bind") || !member2(call.callee.object, "randomUUID"))
15515
+ if (call?.type !== import_utils93.AST_NODE_TYPES.CallExpression || call.optional || call.typeArguments !== void 0 || call.arguments.length !== 1 || call.callee.type !== import_utils93.AST_NODE_TYPES.MemberExpression || !member2(call.callee, "bind") || call.callee.object.type !== import_utils93.AST_NODE_TYPES.MemberExpression || !member2(call.callee.object, "randomUUID"))
15481
15516
  return false;
15482
15517
  const receiver = call.callee.object.object;
15483
15518
  const argument = call.arguments[0];
15484
15519
  return receiver.type === import_utils93.AST_NODE_TYPES.Identifier && receiver.name === "crypto" && argument?.type === import_utils93.AST_NODE_TYPES.Identifier && argument.name === "crypto" && (import_utils93.ASTUtils.findVariable(sourceCode.getScope(receiver), "crypto")?.defs.length ?? 0) === 0 && (import_utils93.ASTUtils.findVariable(sourceCode.getScope(argument), "crypto")?.defs.length ?? 0) === 0;
15485
15520
  }
15486
15521
  function member2(node, property) {
15487
- return node.type === import_utils93.AST_NODE_TYPES.MemberExpression && !node.computed && !node.optional && node.property.type === import_utils93.AST_NODE_TYPES.Identifier && node.property.name === property;
15522
+ return !node.computed && !node.optional && node.property.type === import_utils93.AST_NODE_TYPES.Identifier && node.property.name === property;
15488
15523
  }
15489
15524
  function providerRead(sourceCode, node, declaration) {
15490
15525
  return node.type === import_utils93.AST_NODE_TYPES.CallExpression && !node.optional && node.typeArguments === void 0 && node.arguments.length === 0 && node.callee.type === import_utils93.AST_NODE_TYPES.Identifier && sameBinding2(sourceCode, node.callee, declaration);
@@ -15513,7 +15548,7 @@ function exportedReads(sourceCode, node, native, legacy, imported) {
15513
15548
  return nilImport !== void 0 && sameBinding2(sourceCode, nil, nilImport);
15514
15549
  }
15515
15550
  function isUuidRecipe(sourceCode, node, reported) {
15516
- if (node.type !== import_utils93.AST_NODE_TYPES.CallExpression || node.optional || node.typeArguments !== void 0 || !member2(node.callee, "replace") || node.callee.object.type !== import_utils93.AST_NODE_TYPES.Literal || node.callee.object.value !== UUID_TEMPLATE || node.arguments.length !== IMPORT_COUNT)
15551
+ if (node.type !== import_utils93.AST_NODE_TYPES.CallExpression || node.optional || node.typeArguments !== void 0 || node.callee.type !== import_utils93.AST_NODE_TYPES.MemberExpression || !member2(node.callee, "replace") || node.callee.object.type !== import_utils93.AST_NODE_TYPES.Literal || node.callee.object.value !== UUID_TEMPLATE || node.arguments.length !== IMPORT_COUNT)
15517
15552
  return false;
15518
15553
  const [pattern, callback] = node.arguments;
15519
15554
  if (pattern?.type !== import_utils93.AST_NODE_TYPES.Literal || !("regex" in pattern) || pattern.regex.pattern !== "[xy]" || pattern.regex.flags !== "g" || callback?.type !== import_utils93.AST_NODE_TYPES.ArrowFunctionExpression || callback.async || callback.typeParameters !== void 0 || callback.returnType !== void 0 || callback.params.length !== 1 || callback.params[0]?.type !== import_utils93.AST_NODE_TYPES.Identifier || callback.params[0].typeAnnotation !== void 0 || callback.params[0].optional || callback.body.type !== import_utils93.AST_NODE_TYPES.BlockStatement || callback.body.body.length !== IMPORT_COUNT)
@@ -16062,8 +16097,8 @@ function serverActionErrorResults(sourceCode) {
16062
16097
  if (nodes.some((node) => node.type === import_utils98.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils98.AST_NODE_TYPES.Identifier && node.callee.name === "eval")) return [];
16063
16098
  const analysis = new ActionResults(sourceCode);
16064
16099
  const actionSet = new Set(actions);
16065
- return nodes.filter((node) => {
16066
- if (node.type !== import_utils98.AST_NODE_TYPES.ReturnStatement || node.argument === null) return false;
16100
+ return nodes.filter((node) => node.type === import_utils98.AST_NODE_TYPES.ReturnStatement).filter((node) => {
16101
+ if (node.argument === null) return false;
16067
16102
  const owner = functionOwner(node);
16068
16103
  return owner !== null && actionSet.has(owner) && escapingActionReturn(node, owner, sourceCode) && analysis.payload(node.argument, owner);
16069
16104
  });
@@ -17045,7 +17080,7 @@ function existingDomainComparisonFix(sourceCode, comparison2) {
17045
17080
  if (comparison2.operator !== "===" || sourceCode.ast.body.length !== 2 || sourceCode.getAllComments().length !== 0)
17046
17081
  return null;
17047
17082
  const [comparator, exported] = sourceCode.ast.body;
17048
- if (!isOrdinary(comparator) || comparator.id === null || exported?.type !== import_utils101.AST_NODE_TYPES.ExportNamedDeclaration || exported.exportKind !== "value" || !isOrdinary(exported.declaration))
17083
+ if (comparator?.type !== import_utils101.AST_NODE_TYPES.FunctionDeclaration || !isOrdinary(comparator) || comparator.id === null || exported?.type !== import_utils101.AST_NODE_TYPES.ExportNamedDeclaration || exported.exportKind !== "value" || exported.declaration?.type !== import_utils101.AST_NODE_TYPES.FunctionDeclaration || !isOrdinary(exported.declaration))
17049
17084
  return null;
17050
17085
  const fields2 = comparatorFields(comparator);
17051
17086
  const elements = callerElements(exported.declaration);
@@ -17064,7 +17099,7 @@ function existingDomainComparisonFix(sourceCode, comparison2) {
17064
17099
  );
17065
17100
  }
17066
17101
  function isOrdinary(node) {
17067
- return node?.type === import_utils101.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.body.body.length === 1;
17102
+ return node.id !== null && !node.declare && !node.async && !node.generator && node.typeParameters === void 0 && node.body.body.length === 1;
17068
17103
  }
17069
17104
  function comparatorFields(node) {
17070
17105
  const [left, right] = node.params;
@@ -18296,7 +18331,7 @@ function reportClass(context, services, owner) {
18296
18331
  if (contract === null) return;
18297
18332
  const groups = /* @__PURE__ */ new Map();
18298
18333
  for (const member3 of owner.body.body) {
18299
- if (!candidate(member3)) continue;
18334
+ if (member3.type !== import_utils109.AST_NODE_TYPES.MethodDefinition || !candidate(member3)) continue;
18300
18335
  const name = convertibleMemberName(member3);
18301
18336
  if (name === null || contract.has(name)) continue;
18302
18337
  if (member3.accessibility === "private" || member3.key.type === import_utils109.AST_NODE_TYPES.PrivateIdentifier) continue;
@@ -18316,7 +18351,7 @@ function reportClass(context, services, owner) {
18316
18351
  }
18317
18352
  }
18318
18353
  function candidate(member3) {
18319
- return member3.type === import_utils109.AST_NODE_TYPES.MethodDefinition && member3.kind !== "constructor" && !member3.static && member3.accessibility !== "protected" && !member3.override && !member3.computed && member3.key.type === import_utils109.AST_NODE_TYPES.Identifier && member3.value.body !== null;
18354
+ return member3.kind !== "constructor" && !member3.static && member3.accessibility !== "protected" && !member3.override && !member3.computed && member3.key.type === import_utils109.AST_NODE_TYPES.Identifier && member3.value.body !== null;
18320
18355
  }
18321
18356
  function interfaceNames(services, owner) {
18322
18357
  const tsOwner = services.esTreeNodeToTSNodeMap.get(owner);
@@ -18488,7 +18523,7 @@ var SINGLE_STATEMENT_HOSTS = /* @__PURE__ */ new Set([
18488
18523
  import_utils111.AST_NODE_TYPES.IfStatement,
18489
18524
  import_utils111.AST_NODE_TYPES.WhileStatement
18490
18525
  ]);
18491
- var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
18526
+ var FUNCTION_TYPES = /* @__PURE__ */ new Set([
18492
18527
  import_utils111.AST_NODE_TYPES.ArrowFunctionExpression,
18493
18528
  import_utils111.AST_NODE_TYPES.FunctionDeclaration,
18494
18529
  import_utils111.AST_NODE_TYPES.FunctionExpression
@@ -18518,7 +18553,7 @@ function fallbackFollowsTry(tryStatement) {
18518
18553
  return last?.type === import_utils111.AST_NODE_TYPES.ReturnStatement && hasFollowingStatement(tryStatement);
18519
18554
  }
18520
18555
  function hasFollowingStatement(node) {
18521
- for (let current = node; current !== void 0 && !FUNCTION_TYPES2.has(current.type); current = current.parent) {
18556
+ for (let current = node; current !== void 0 && !FUNCTION_TYPES.has(current.type); current = current.parent) {
18522
18557
  const slot = statementSlot(current);
18523
18558
  if (slot !== null && slot.index < slot.list.length - 1) return true;
18524
18559
  }
@@ -18606,7 +18641,7 @@ var no_log_only_catch_default = createRule({
18606
18641
  function hasFollowingCoercionCheck(owner, left, coercion) {
18607
18642
  let current = owner;
18608
18643
  let slot = statementSlot(current);
18609
- while (slot === null && current.parent !== void 0 && !FUNCTION_TYPES2.has(current.parent.type)) {
18644
+ while (slot === null && current.parent !== void 0 && !FUNCTION_TYPES.has(current.parent.type)) {
18610
18645
  current = current.parent;
18611
18646
  slot = statementSlot(current);
18612
18647
  }
@@ -18691,7 +18726,7 @@ var TEST_NAMES = /* @__PURE__ */ new Set(["it", "test"]);
18691
18726
  var TEST_MODIFIERS3 = /* @__PURE__ */ new Set(["concurrent", "fails", "only", "sequential", "skip"]);
18692
18727
  var TEST_BUILDERS = /* @__PURE__ */ new Set(["each", "for", "runIf", "skipIf"]);
18693
18728
  var ASSERTION_NAMES2 = /* @__PURE__ */ new Set(["assert", "assertType", "expect", "expectTypeOf"]);
18694
- var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([import_utils112.AST_NODE_TYPES.ArrowFunctionExpression, import_utils112.AST_NODE_TYPES.FunctionExpression, import_utils112.AST_NODE_TYPES.FunctionDeclaration]);
18729
+ var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([import_utils112.AST_NODE_TYPES.ArrowFunctionExpression, import_utils112.AST_NODE_TYPES.FunctionExpression, import_utils112.AST_NODE_TYPES.FunctionDeclaration]);
18695
18730
  function staticMemberName3(node) {
18696
18731
  if (!node.computed && node.property.type === import_utils112.AST_NODE_TYPES.Identifier) return node.property.name;
18697
18732
  if (node.computed && node.property.type === import_utils112.AST_NODE_TYPES.Literal && typeof node.property.value === "string") return node.property.value;
@@ -18704,7 +18739,6 @@ function rootIdentifier2(callee) {
18704
18739
  return null;
18705
18740
  }
18706
18741
  function isDirectTestCallback(node, context) {
18707
- if (node.type !== import_utils112.AST_NODE_TYPES.ArrowFunctionExpression && node.type !== import_utils112.AST_NODE_TYPES.FunctionExpression) return false;
18708
18742
  const call = directArgumentCall(node);
18709
18743
  if (call === null) return false;
18710
18744
  const root = testRoot(call.callee);
@@ -18724,12 +18758,12 @@ function testRoot(callee) {
18724
18758
  return modifier !== null && TEST_MODIFIERS3.has(modifier) ? testRoot(callee.object) : null;
18725
18759
  }
18726
18760
  function nearestFunction(node) {
18727
- for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) if (FUNCTION_TYPES3.has(current.type)) return current;
18761
+ for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) if (FUNCTION_TYPES2.has(current.type)) return current;
18728
18762
  return null;
18729
18763
  }
18730
18764
  function walkOwnScope(node, predicate) {
18731
18765
  if (predicate(node)) return true;
18732
- return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES3.has(child.type) && walkOwnScope(child, predicate));
18766
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES2.has(child.type) && walkOwnScope(child, predicate));
18733
18767
  }
18734
18768
  function isAssertion(node, context) {
18735
18769
  if (node.type !== import_utils112.AST_NODE_TYPES.CallExpression) return false;
@@ -18821,7 +18855,7 @@ var no_bare_return_from_test_catch_default = createRule({
18821
18855
  ReturnStatement(node) {
18822
18856
  if (node.argument !== null) return;
18823
18857
  const owner = nearestFunction(node);
18824
- if (owner === null || !isDirectTestCallback(owner, context)) return;
18858
+ if (owner?.type !== import_utils112.AST_NODE_TYPES.ArrowFunctionExpression && owner?.type !== import_utils112.AST_NODE_TYPES.FunctionExpression || !isDirectTestCallback(owner, context)) return;
18825
18859
  let catchClause = null;
18826
18860
  for (let current = node.parent; current !== owner; current = current?.parent) {
18827
18861
  if (current?.type === import_utils112.AST_NODE_TYPES.CatchClause) {
@@ -19451,7 +19485,7 @@ function labeledTupleObjectFix(sourceCode, annotation) {
19451
19485
  if (sourceCode.ast.body.length !== 2 || sourceCode.getAllComments().length > 0)
19452
19486
  return null;
19453
19487
  const [helper, statement] = sourceCode.ast.body;
19454
- if (!isOrdinary2(helper) || statement?.type !== import_utils117.AST_NODE_TYPES.ExportNamedDeclaration || !isOrdinary2(statement.declaration) || helper.returnType?.typeAnnotation !== annotation)
19488
+ if (helper?.type !== import_utils117.AST_NODE_TYPES.FunctionDeclaration || !isOrdinary2(helper) || statement?.type !== import_utils117.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration?.type !== import_utils117.AST_NODE_TYPES.FunctionDeclaration || !isOrdinary2(statement.declaration) || helper.returnType?.typeAnnotation !== annotation)
19455
19489
  return null;
19456
19490
  const caller = statement.declaration;
19457
19491
  const fields2 = tupleFields(helper);
@@ -19476,7 +19510,7 @@ function labeledTupleObjectFix(sourceCode, annotation) {
19476
19510
  ];
19477
19511
  }
19478
19512
  function isOrdinary2(node) {
19479
- return node?.type === import_utils117.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && !node.declare && !node.async && !node.generator && node.params.length === 0 && node.typeParameters === void 0;
19513
+ return node.id !== null && !node.declare && !node.async && !node.generator && node.params.length === 0 && node.typeParameters === void 0;
19480
19514
  }
19481
19515
  function tupleFields(helper) {
19482
19516
  const tuple = helper.returnType?.typeAnnotation;
@@ -20804,7 +20838,7 @@ var PREVIEW_LENGTH = 40;
20804
20838
  var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
20805
20839
  var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
20806
20840
  var URL_PATH_RE = /^\/(?=[^\s]*[A-Za-z0-9])[A-Za-z0-9._~!$&'()*+,;=:@%/?#{}\u005B\u005D-]+$/;
20807
- var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
20841
+ var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
20808
20842
  import_utils124.AST_NODE_TYPES.FunctionDeclaration,
20809
20843
  import_utils124.AST_NODE_TYPES.FunctionExpression,
20810
20844
  import_utils124.AST_NODE_TYPES.ArrowFunctionExpression
@@ -20878,7 +20912,7 @@ function preview(value) {
20878
20912
  }
20879
20913
  function enclosingFunction4(node) {
20880
20914
  for (let current = node.parent; current != null; current = current.parent) {
20881
- if (FUNCTION_TYPES4.has(current.type)) {
20915
+ if (FUNCTION_TYPES3.has(current.type)) {
20882
20916
  return current;
20883
20917
  }
20884
20918
  }
@@ -22343,9 +22377,6 @@ function isSentinelArgument(arg) {
22343
22377
  function isFunctionNode(node) {
22344
22378
  return node.type === import_utils132.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils132.AST_NODE_TYPES.FunctionExpression || node.type === import_utils132.AST_NODE_TYPES.ArrowFunctionExpression;
22345
22379
  }
22346
- function isNode3(value) {
22347
- return typeof value === "object" && value !== null && typeof value.type === "string";
22348
- }
22349
22380
  function walkWithinScope(node, visit) {
22350
22381
  let found = false;
22351
22382
  const recurse = (current) => {
@@ -22472,7 +22503,7 @@ function enclosingFunctionName(node) {
22472
22503
  let current = node.parent;
22473
22504
  while (current !== void 0 && current !== null) {
22474
22505
  if (isFunctionNode(current)) {
22475
- if ("id" in current && isNode3(current.id) && current.id.type === import_utils132.AST_NODE_TYPES.Identifier) {
22506
+ if ("id" in current && current.id !== null && current.id.type === import_utils132.AST_NODE_TYPES.Identifier) {
22476
22507
  return current.id.name;
22477
22508
  }
22478
22509
  const parent = current.parent;
@@ -22573,7 +22604,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
22573
22604
  function enclosingFunctionBody(node) {
22574
22605
  let current = node.parent;
22575
22606
  while (current !== void 0 && current !== null) {
22576
- if (isFunctionNode(current) && "body" in current && isNode3(current.body) && current.body.type === import_utils132.AST_NODE_TYPES.BlockStatement) {
22607
+ if (isFunctionNode(current) && current.body?.type === import_utils132.AST_NODE_TYPES.BlockStatement) {
22577
22608
  return current.body;
22578
22609
  }
22579
22610
  current = current.parent;
@@ -22980,7 +23011,7 @@ var TEST_CALLERS2 = /* @__PURE__ */ new Set([
22980
23011
  "beforeEach",
22981
23012
  "afterEach"
22982
23013
  ]);
22983
- var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
23014
+ var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
22984
23015
  import_utils134.AST_NODE_TYPES.FunctionDeclaration,
22985
23016
  import_utils134.AST_NODE_TYPES.FunctionExpression,
22986
23017
  import_utils134.AST_NODE_TYPES.ArrowFunctionExpression
@@ -23015,7 +23046,7 @@ function isHelperSleep(node) {
23015
23046
  }
23016
23047
  function nearestEnclosingFunction(node) {
23017
23048
  for (let current = node.parent; current != null; current = current.parent) {
23018
- if (!FUNCTION_TYPES5.has(current.type)) {
23049
+ if (!FUNCTION_TYPES4.has(current.type)) {
23019
23050
  continue;
23020
23051
  }
23021
23052
  const grandparent = current.parent;
@@ -26020,7 +26051,7 @@ var ASSERTION_ROOTS = /* @__PURE__ */ new Set([
26020
26051
  "expect",
26021
26052
  "expectTypeOf"
26022
26053
  ]);
26023
- var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
26054
+ var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
26024
26055
  import_utils150.AST_NODE_TYPES.FunctionDeclaration,
26025
26056
  import_utils150.AST_NODE_TYPES.FunctionExpression,
26026
26057
  import_utils150.AST_NODE_TYPES.ArrowFunctionExpression
@@ -26055,7 +26086,7 @@ function isTestCaller(callee, isFrameworkTest) {
26055
26086
  }
26056
26087
  function nearestEnclosingFunction2(node) {
26057
26088
  for (let current = node.parent; current != null; current = current.parent) {
26058
- if (FUNCTION_TYPES6.has(current.type)) {
26089
+ if (FUNCTION_TYPES5.has(current.type)) {
26059
26090
  return current;
26060
26091
  }
26061
26092
  }
@@ -26088,7 +26119,7 @@ function walkOwnScope2(node, predicate) {
26088
26119
  if (predicate(node)) {
26089
26120
  return true;
26090
26121
  }
26091
- return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES6.has(child.type) && walkOwnScope2(child, predicate));
26122
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES5.has(child.type) && walkOwnScope2(child, predicate));
26092
26123
  }
26093
26124
  function isAssertion2(node, isFrameworkAssertion) {
26094
26125
  if (node.type !== import_utils150.AST_NODE_TYPES.CallExpression) return false;
@@ -26101,7 +26132,7 @@ function opensSubtest(node, callbackParameters) {
26101
26132
  }
26102
26133
  const callee = unwrapExpression(node.callee);
26103
26134
  return callee.type === import_utils150.AST_NODE_TYPES.MemberExpression && staticMemberName6(callee) === "test" && callee.object.type === import_utils150.AST_NODE_TYPES.Identifier && callbackParameters.has(callee.object.name) && node.arguments.some(
26104
- (argument) => argument.type !== import_utils150.AST_NODE_TYPES.SpreadElement && FUNCTION_TYPES6.has(argument.type)
26135
+ (argument) => argument.type !== import_utils150.AST_NODE_TYPES.SpreadElement && FUNCTION_TYPES5.has(argument.type)
26105
26136
  );
26106
26137
  }
26107
26138
  var LOOP_CARRIED_CONTROL = /* @__PURE__ */ new Set([
@@ -26467,7 +26498,7 @@ var PREFER_ECMASCRIPT_PRIVATE_MEMBERS_DOCUMENTATION = {
26467
26498
  function reportClass2(context, owner, services) {
26468
26499
  const groups = /* @__PURE__ */ new Map();
26469
26500
  for (const member3 of owner.body.body) {
26470
- if (!isConvertible(member3)) continue;
26501
+ if (member3.type !== import_utils153.AST_NODE_TYPES.MethodDefinition && member3.type !== import_utils153.AST_NODE_TYPES.PropertyDefinition && member3.type !== import_utils153.AST_NODE_TYPES.AccessorProperty || !isConvertible(member3)) continue;
26471
26502
  const name = convertibleMemberName(member3);
26472
26503
  if (name === null) continue;
26473
26504
  const members = groups.get(name) ?? [];
@@ -26486,7 +26517,6 @@ function reportClass2(context, owner, services) {
26486
26517
  }
26487
26518
  }
26488
26519
  function isConvertible(member3) {
26489
- if (member3.type !== import_utils153.AST_NODE_TYPES.MethodDefinition && member3.type !== import_utils153.AST_NODE_TYPES.PropertyDefinition && member3.type !== import_utils153.AST_NODE_TYPES.AccessorProperty) return false;
26490
26520
  return member3.accessibility === "private" && !(member3.type === import_utils153.AST_NODE_TYPES.MethodDefinition && member3.kind === "constructor") && !member3.computed && member3.key.type === import_utils153.AST_NODE_TYPES.Identifier && member3.decorators.length === 0 && !("declare" in member3 && member3.declare) && !member3.override && !(member3.type === import_utils153.AST_NODE_TYPES.MethodDefinition && member3.value.body === null);
26491
26521
  }
26492
26522
  var prefer_ecmascript_private_members_default = createRule({
@@ -28178,7 +28208,7 @@ var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
28178
28208
  // Object-ish escape hatches
28179
28209
  "assign"
28180
28210
  ]);
28181
- var FUNCTION_TYPES7 = /* @__PURE__ */ new Set([
28211
+ var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
28182
28212
  import_utils162.AST_NODE_TYPES.FunctionDeclaration,
28183
28213
  import_utils162.AST_NODE_TYPES.FunctionExpression,
28184
28214
  import_utils162.AST_NODE_TYPES.ArrowFunctionExpression
@@ -28200,8 +28230,8 @@ function unwrap3(node) {
28200
28230
  return node;
28201
28231
  }
28202
28232
  var HAS_STATEFUL_FLAG_RE = /[gy]/;
28203
- function isRegexLiteral(node) {
28204
- return node.type === import_utils162.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
28233
+ function literalRegex(node) {
28234
+ return node.type === import_utils162.AST_NODE_TYPES.Literal && "regex" in node ? node.regex : void 0;
28205
28235
  }
28206
28236
  function isLiteralOnly(node, depth) {
28207
28237
  if (depth > MAX_LITERAL_DEPTH) {
@@ -28210,7 +28240,7 @@ function isLiteralOnly(node, depth) {
28210
28240
  const inner = unwrap3(node);
28211
28241
  switch (inner.type) {
28212
28242
  case import_utils162.AST_NODE_TYPES.Literal: {
28213
- return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
28243
+ return !HAS_STATEFUL_FLAG_RE.test(literalRegex(inner)?.flags ?? "");
28214
28244
  }
28215
28245
  case import_utils162.AST_NODE_TYPES.TemplateLiteral: {
28216
28246
  return inner.expressions.length === 0;
@@ -28244,11 +28274,12 @@ function isLiteralOnly(node, depth) {
28244
28274
  }
28245
28275
  function classify(init, checkRegex, sourceCode) {
28246
28276
  const node = unwrapObjectFreeze(init, sourceCode);
28247
- if (isRegexLiteral(node)) {
28277
+ const regex = literalRegex(node);
28278
+ if (regex !== void 0) {
28248
28279
  if (!checkRegex) {
28249
28280
  return null;
28250
28281
  }
28251
- if (HAS_STATEFUL_FLAG_RE.test(node.regex.flags)) {
28282
+ if (HAS_STATEFUL_FLAG_RE.test(regex.flags)) {
28252
28283
  return null;
28253
28284
  }
28254
28285
  return { kind: "regex", size: 1 };
@@ -28275,7 +28306,7 @@ function unwrapObjectFreeze(node, sourceCode) {
28275
28306
  function enclosingFunction5(node) {
28276
28307
  let current = node.parent;
28277
28308
  while (current !== void 0 && current !== null) {
28278
- if (FUNCTION_TYPES7.has(current.type)) {
28309
+ if (FUNCTION_TYPES6.has(current.type)) {
28279
28310
  return current;
28280
28311
  }
28281
28312
  current = current.parent;
@@ -28579,7 +28610,7 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
28579
28610
  "i18n",
28580
28611
  "intl"
28581
28612
  ]);
28582
- var FUNCTION_TYPES8 = /* @__PURE__ */ new Set([
28613
+ var FUNCTION_TYPES7 = /* @__PURE__ */ new Set([
28583
28614
  import_utils163.AST_NODE_TYPES.ArrowFunctionExpression,
28584
28615
  import_utils163.AST_NODE_TYPES.FunctionDeclaration,
28585
28616
  import_utils163.AST_NODE_TYPES.FunctionExpression
@@ -28605,7 +28636,7 @@ function outermostEnclosingFunction(node) {
28605
28636
  let outermost;
28606
28637
  let current = node.parent ?? void 0;
28607
28638
  while (current !== void 0) {
28608
- if (FUNCTION_TYPES8.has(current.type)) {
28639
+ if (FUNCTION_TYPES7.has(current.type)) {
28609
28640
  outermost = current;
28610
28641
  }
28611
28642
  current = current.parent ?? void 0;
@@ -28628,7 +28659,7 @@ function subtreeSome(root, predicate, skipDeferredFunctions = false) {
28628
28659
  if (typeof candidate2.type !== "string") {
28629
28660
  return;
28630
28661
  }
28631
- if (skipDeferredFunctions && FUNCTION_TYPES8.has(candidate2.type)) return;
28662
+ if (skipDeferredFunctions && FUNCTION_TYPES7.has(candidate2.type)) return;
28632
28663
  if (predicate(candidate2)) {
28633
28664
  found = true;
28634
28665
  return;
@@ -28743,7 +28774,7 @@ var prefer_module_level_schema_default = createRule({
28743
28774
  function isCovered(node) {
28744
28775
  let current = node.parent ?? void 0;
28745
28776
  while (current !== void 0) {
28746
- if (current !== node && isZodCall(current) && current.callee.type === import_utils163.AST_NODE_TYPES.MemberExpression && import_utils163.ASTUtils.getPropertyName(current.callee) !== null && factories.has(import_utils163.ASTUtils.getPropertyName(current.callee) ?? "")) {
28777
+ if (current !== node && current.type === import_utils163.AST_NODE_TYPES.CallExpression && isZodCall(current) && current.callee.type === import_utils163.AST_NODE_TYPES.MemberExpression && import_utils163.ASTUtils.getPropertyName(current.callee) !== null && factories.has(import_utils163.ASTUtils.getPropertyName(current.callee) ?? "")) {
28747
28778
  return true;
28748
28779
  }
28749
28780
  if (current.type === import_utils163.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils163.AST_NODE_TYPES.Identifier && memoCallees.has(current.callee.name) || current.callee.type === import_utils163.AST_NODE_TYPES.MemberExpression && import_utils163.ASTUtils.getPropertyName(current.callee) !== null && memoCallees.has(import_utils163.ASTUtils.getPropertyName(current.callee) ?? ""))) {
@@ -28999,7 +29030,7 @@ var I18N_RECEIVER_NAMES2 = /* @__PURE__ */ new Set([
28999
29030
  "i18n",
29000
29031
  "intl"
29001
29032
  ]);
29002
- var FUNCTION_TYPES9 = /* @__PURE__ */ new Set([
29033
+ var FUNCTION_TYPES8 = /* @__PURE__ */ new Set([
29003
29034
  import_utils164.AST_NODE_TYPES.ArrowFunctionExpression,
29004
29035
  import_utils164.AST_NODE_TYPES.FunctionDeclaration,
29005
29036
  import_utils164.AST_NODE_TYPES.FunctionExpression
@@ -29047,7 +29078,7 @@ function outermostEnclosingFunction2(node) {
29047
29078
  let outermost;
29048
29079
  let current = node.parent ?? void 0;
29049
29080
  while (current !== void 0) {
29050
- if (FUNCTION_TYPES9.has(current.type)) outermost = current;
29081
+ if (FUNCTION_TYPES8.has(current.type)) outermost = current;
29051
29082
  current = current.parent ?? void 0;
29052
29083
  }
29053
29084
  return outermost;
@@ -29066,7 +29097,7 @@ function subtreeSome2(root, predicate, skipDeferredFunctions = false) {
29066
29097
  }
29067
29098
  const candidate2 = value;
29068
29099
  if (typeof candidate2.type !== "string") return;
29069
- if (skipDeferredFunctions && FUNCTION_TYPES9.has(candidate2.type)) return;
29100
+ if (skipDeferredFunctions && FUNCTION_TYPES8.has(candidate2.type)) return;
29070
29101
  if (predicate(candidate2)) {
29071
29102
  found = true;
29072
29103
  return;
@@ -29212,7 +29243,7 @@ var prefer_module_level_refined_schema_default = createRule({
29212
29243
  let current = node;
29213
29244
  while (current.parent != null) {
29214
29245
  current = current.parent;
29215
- if (FUNCTION_TYPES9.has(current.type)) return false;
29246
+ if (FUNCTION_TYPES8.has(current.type)) return false;
29216
29247
  if (current.type === import_utils164.AST_NODE_TYPES.CallExpression && (factoryName(current, FACTORIES) !== null || factoryName(current, COMPOSITE_FACTORIES) !== null))
29217
29248
  return true;
29218
29249
  }
@@ -31077,7 +31108,7 @@ var prefer_non_nullable_collection_default = createRule({
31077
31108
  const bindingProperty = parameter.properties.find(
31078
31109
  (entry) => entry.type === import_utils174.AST_NODE_TYPES.Property && !entry.computed && import_utils174.ASTUtils.getPropertyName(entry) === property.name
31079
31110
  );
31080
- if (bindingProperty === void 0) continue;
31111
+ if (bindingProperty?.type !== import_utils174.AST_NODE_TYPES.Property) continue;
31081
31112
  const value = bindingProperty.value;
31082
31113
  const binding3 = value.type === import_utils174.AST_NODE_TYPES.AssignmentPattern ? value.left : value;
31083
31114
  if (binding3.type !== import_utils174.AST_NODE_TYPES.Identifier) {
@@ -35890,7 +35921,7 @@ function injectedMembers(owner) {
35890
35921
  const constructor = owner.body.body.find(
35891
35922
  (member3) => member3.type === import_utils191.AST_NODE_TYPES.MethodDefinition && member3.kind === "constructor"
35892
35923
  );
35893
- if (constructor === void 0) return injected;
35924
+ if (constructor?.type !== import_utils191.AST_NODE_TYPES.MethodDefinition) return injected;
35894
35925
  const parameters = /* @__PURE__ */ new Set();
35895
35926
  for (const parameter of constructor.value.params) {
35896
35927
  for (const name of parameterNames(parameter)) parameters.add(name);
@@ -38624,6 +38655,7 @@ var RETIRED_RULES = {
38624
38655
 
38625
38656
  // src/index.ts
38626
38657
  var RULES = {
38658
+ "no-explicit-type-predicate": no_explicit_type_predicate_default,
38627
38659
  "prefer-zod-enum-validator": prefer_zod_enum_validator_default,
38628
38660
  "no-growing-array-spread-in-loop": no_growing_array_spread_in_loop_default,
38629
38661
  "no-logical-or-fallback": no_logical_or_fallback_default,
@@ -38806,6 +38838,7 @@ var RULE_POLICY = {
38806
38838
  "@sarj/no-invalid-typed-mutation": ["error", "both"],
38807
38839
  "@sarj/no-contradictory-type-predicate": ["error", "both"],
38808
38840
  "@sarj/no-partial-type-predicate": ["error", "both"],
38841
+ "@sarj/no-explicit-type-predicate": ["warn", "both"],
38809
38842
  "@sarj/no-boolean-selector-parameter": ["warn", "both"],
38810
38843
  "@sarj/no-invalid-zod-custom-parse": ["error", "both"],
38811
38844
  "@sarj/no-contradictory-overload-return": ["error", "both"],