@sarj/eslint-plugin 15.17.11 → 15.17.13
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 +853 -522
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +843 -509
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -16411,6 +16411,9 @@ var MODULE_LEVEL_RESHAPERS = /* @__PURE__ */ new Set([
|
|
|
16411
16411
|
"pipe",
|
|
16412
16412
|
"preprocess"
|
|
16413
16413
|
]);
|
|
16414
|
+
function isPreferZodInferModuleReshaper(name) {
|
|
16415
|
+
return MODULE_LEVEL_RESHAPERS.has(name);
|
|
16416
|
+
}
|
|
16414
16417
|
var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
16415
16418
|
"ZodType",
|
|
16416
16419
|
"ZodSchema",
|
|
@@ -16418,6 +16421,9 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
16418
16421
|
"ZodMiniType",
|
|
16419
16422
|
"Schema"
|
|
16420
16423
|
]);
|
|
16424
|
+
function isPreferZodInferTypeConstraintName(name) {
|
|
16425
|
+
return ZOD_TYPE_CONSTRAINTS.has(name);
|
|
16426
|
+
}
|
|
16421
16427
|
var LEAF_NODE_TYPES = {
|
|
16422
16428
|
string: [AST_NODE_TYPES69.TSStringKeyword],
|
|
16423
16429
|
email: [AST_NODE_TYPES69.TSStringKeyword],
|
|
@@ -16593,6 +16599,21 @@ function unwrapNullish(annotation) {
|
|
|
16593
16599
|
}
|
|
16594
16600
|
return { core: rest.length === 0 ? null : annotation, nullable };
|
|
16595
16601
|
}
|
|
16602
|
+
function preferZodInferOwnsDefaultTwin(input) {
|
|
16603
|
+
if (input.constrained || input.reshaped || normalizeSchemaName(input.schemaName) !== normalizeTypeName(input.typeName)) {
|
|
16604
|
+
return false;
|
|
16605
|
+
}
|
|
16606
|
+
const fields = twinSchemaFields(input.initializer, input.zodNamespaces);
|
|
16607
|
+
const members = twinTypeMembers(input.declaration);
|
|
16608
|
+
if (fields === null || members === null || fields.size !== members.size) return false;
|
|
16609
|
+
for (const [name, field] of fields) {
|
|
16610
|
+
const member = members.get(name);
|
|
16611
|
+
if (member === void 0 || field.reshaped || field.optional !== member.optional || field.nullable !== member.nullable || member.readonly || leafAgrees(field, member.annotation) !== true) {
|
|
16612
|
+
return false;
|
|
16613
|
+
}
|
|
16614
|
+
}
|
|
16615
|
+
return true;
|
|
16616
|
+
}
|
|
16596
16617
|
function leafAgrees(field, annotation) {
|
|
16597
16618
|
if (field.domain === null) {
|
|
16598
16619
|
return false;
|
|
@@ -16652,6 +16673,100 @@ function staticStringUnionDomain(node) {
|
|
|
16652
16673
|
const domain = exactDomain(keys);
|
|
16653
16674
|
return domain !== null && domain.size >= 2 ? domain : null;
|
|
16654
16675
|
}
|
|
16676
|
+
function twinCallChain(node, zodNamespaces) {
|
|
16677
|
+
const chain = [];
|
|
16678
|
+
let current = node;
|
|
16679
|
+
while (current.type === AST_NODE_TYPES69.CallExpression) {
|
|
16680
|
+
const callee = current.callee;
|
|
16681
|
+
if (callee.type !== AST_NODE_TYPES69.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES69.Identifier) {
|
|
16682
|
+
return null;
|
|
16683
|
+
}
|
|
16684
|
+
chain.push(current);
|
|
16685
|
+
if (callee.object.type === AST_NODE_TYPES69.Identifier) {
|
|
16686
|
+
return zodNamespaces.has(callee.object.name) ? chain.reverse() : null;
|
|
16687
|
+
}
|
|
16688
|
+
current = callee.object;
|
|
16689
|
+
}
|
|
16690
|
+
return null;
|
|
16691
|
+
}
|
|
16692
|
+
function twinMethodName(call) {
|
|
16693
|
+
const callee = call.callee;
|
|
16694
|
+
return callee.type === AST_NODE_TYPES69.MemberExpression && callee.property.type === AST_NODE_TYPES69.Identifier ? callee.property.name : "";
|
|
16695
|
+
}
|
|
16696
|
+
function twinSchemaFields(initializer, zodNamespaces) {
|
|
16697
|
+
const chain = twinCallChain(initializer, zodNamespaces);
|
|
16698
|
+
if (chain === null || chain.length === 0) return null;
|
|
16699
|
+
const [base, ...rest] = chain;
|
|
16700
|
+
if (base === void 0) return null;
|
|
16701
|
+
const baseMethod = twinMethodName(base);
|
|
16702
|
+
if (baseMethod !== "object" && baseMethod !== "strictObject") return null;
|
|
16703
|
+
if (rest.some((call) => !SHAPE_PRESERVING_METHODS.has(twinMethodName(call)))) return null;
|
|
16704
|
+
const shape = base.arguments[0];
|
|
16705
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES69.ObjectExpression) return null;
|
|
16706
|
+
const fields = /* @__PURE__ */ new Map();
|
|
16707
|
+
for (const property of shape.properties) {
|
|
16708
|
+
if (property.type !== AST_NODE_TYPES69.Property || property.computed) return null;
|
|
16709
|
+
const { key } = property;
|
|
16710
|
+
const name = key.type === AST_NODE_TYPES69.Identifier ? key.name : key.type === AST_NODE_TYPES69.Literal && typeof key.value === "string" ? key.value : null;
|
|
16711
|
+
if (name === null) return null;
|
|
16712
|
+
fields.set(name, twinSchemaField(property.value, zodNamespaces));
|
|
16713
|
+
}
|
|
16714
|
+
return fields.size === 0 ? null : fields;
|
|
16715
|
+
}
|
|
16716
|
+
function twinSchemaField(node, zodNamespaces) {
|
|
16717
|
+
const modifiers = [];
|
|
16718
|
+
let current = node;
|
|
16719
|
+
let leaf = null;
|
|
16720
|
+
let leafCall = null;
|
|
16721
|
+
while (current.type === AST_NODE_TYPES69.CallExpression) {
|
|
16722
|
+
const callee = current.callee;
|
|
16723
|
+
if (callee.type !== AST_NODE_TYPES69.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES69.Identifier) {
|
|
16724
|
+
break;
|
|
16725
|
+
}
|
|
16726
|
+
const receiver = callee.object;
|
|
16727
|
+
if (receiver.type === AST_NODE_TYPES69.Identifier && zodNamespaces.has(receiver.name)) {
|
|
16728
|
+
leaf = callee.property.name;
|
|
16729
|
+
leafCall = current;
|
|
16730
|
+
break;
|
|
16731
|
+
}
|
|
16732
|
+
modifiers.push(callee.property.name);
|
|
16733
|
+
current = receiver;
|
|
16734
|
+
}
|
|
16735
|
+
return {
|
|
16736
|
+
domain: modifiers.every((name) => DOMAIN_PRESERVING_MODIFIERS.has(name)) ? staticZodDomain(leaf, leafCall) : null,
|
|
16737
|
+
leaf,
|
|
16738
|
+
optional: modifiers.some((name) => OPTIONAL_MODIFIERS.has(name)),
|
|
16739
|
+
nullable: modifiers.some((name) => NULLABLE_MODIFIERS.has(name)),
|
|
16740
|
+
reshaped: modifiers.some((name) => RESHAPING_MODIFIERS.has(name))
|
|
16741
|
+
};
|
|
16742
|
+
}
|
|
16743
|
+
function twinTypeMembers(declaration) {
|
|
16744
|
+
let members;
|
|
16745
|
+
if (declaration.type === AST_NODE_TYPES69.TSInterfaceDeclaration) {
|
|
16746
|
+
if (declaration.typeParameters !== void 0 || (declaration.extends?.length ?? 0) > 0) return null;
|
|
16747
|
+
members = declaration.body.body;
|
|
16748
|
+
} else {
|
|
16749
|
+
if (declaration.typeParameters !== void 0 || declaration.typeAnnotation.type !== AST_NODE_TYPES69.TSTypeLiteral) {
|
|
16750
|
+
return null;
|
|
16751
|
+
}
|
|
16752
|
+
members = declaration.typeAnnotation.members;
|
|
16753
|
+
}
|
|
16754
|
+
const result = /* @__PURE__ */ new Map();
|
|
16755
|
+
for (const member of members) {
|
|
16756
|
+
if (member.type !== AST_NODE_TYPES69.TSPropertySignature || member.computed) return null;
|
|
16757
|
+
const { key } = member;
|
|
16758
|
+
const name = key.type === AST_NODE_TYPES69.Identifier ? key.name : key.type === AST_NODE_TYPES69.Literal && typeof key.value === "string" ? key.value : null;
|
|
16759
|
+
if (name === null) return null;
|
|
16760
|
+
const annotation = member.typeAnnotation?.typeAnnotation ?? null;
|
|
16761
|
+
result.set(name, {
|
|
16762
|
+
optional: member.optional === true,
|
|
16763
|
+
nullable: annotation !== null && unwrapNullish(annotation).nullable,
|
|
16764
|
+
readonly: member.readonly === true,
|
|
16765
|
+
annotation
|
|
16766
|
+
});
|
|
16767
|
+
}
|
|
16768
|
+
return result.size === 0 ? null : result;
|
|
16769
|
+
}
|
|
16655
16770
|
function nameTokens(name) {
|
|
16656
16771
|
return name.replace(/([a-z\d])([A-Z])/gu, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/gu, "$1 $2").split(/[^A-Za-z\d]+/u).filter((token) => token !== "").map((token) => token.toLowerCase());
|
|
16657
16772
|
}
|
|
@@ -16708,27 +16823,6 @@ var prefer_zod_infer_default = createRule({
|
|
|
16708
16823
|
const typeDeclarations = [];
|
|
16709
16824
|
const constrainedTypeNames = /* @__PURE__ */ new Set();
|
|
16710
16825
|
const reshapedSchemaNames = /* @__PURE__ */ new Set();
|
|
16711
|
-
function zodCallChain(node) {
|
|
16712
|
-
const chain = [];
|
|
16713
|
-
let current = node;
|
|
16714
|
-
while (current.type === AST_NODE_TYPES69.CallExpression) {
|
|
16715
|
-
const callee = current.callee;
|
|
16716
|
-
if (callee.type !== AST_NODE_TYPES69.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES69.Identifier) {
|
|
16717
|
-
return null;
|
|
16718
|
-
}
|
|
16719
|
-
chain.push(current);
|
|
16720
|
-
const receiver = callee.object;
|
|
16721
|
-
if (receiver.type === AST_NODE_TYPES69.Identifier) {
|
|
16722
|
-
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
16723
|
-
}
|
|
16724
|
-
current = receiver;
|
|
16725
|
-
}
|
|
16726
|
-
return null;
|
|
16727
|
-
}
|
|
16728
|
-
function methodName2(call) {
|
|
16729
|
-
const callee = call.callee;
|
|
16730
|
-
return callee.type === AST_NODE_TYPES69.MemberExpression && callee.property.type === AST_NODE_TYPES69.Identifier ? callee.property.name : "";
|
|
16731
|
-
}
|
|
16732
16826
|
function recordZodImport(node) {
|
|
16733
16827
|
if (!isZodModule(node.source.value)) {
|
|
16734
16828
|
return;
|
|
@@ -16739,42 +16833,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
16739
16833
|
}
|
|
16740
16834
|
}
|
|
16741
16835
|
}
|
|
16742
|
-
function schemaField(node) {
|
|
16743
|
-
const modifiers = [];
|
|
16744
|
-
let current = node;
|
|
16745
|
-
let leaf = null;
|
|
16746
|
-
let leafCall = null;
|
|
16747
|
-
while (current.type === AST_NODE_TYPES69.CallExpression) {
|
|
16748
|
-
const callee = current.callee;
|
|
16749
|
-
if (callee.type !== AST_NODE_TYPES69.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES69.Identifier) {
|
|
16750
|
-
break;
|
|
16751
|
-
}
|
|
16752
|
-
const receiver = callee.object;
|
|
16753
|
-
if (receiver.type === AST_NODE_TYPES69.Identifier && zodNamespaces.has(receiver.name)) {
|
|
16754
|
-
leaf = callee.property.name;
|
|
16755
|
-
leafCall = current;
|
|
16756
|
-
break;
|
|
16757
|
-
}
|
|
16758
|
-
modifiers.push(callee.property.name);
|
|
16759
|
-
current = receiver;
|
|
16760
|
-
}
|
|
16761
|
-
return {
|
|
16762
|
-
domain: modifiers.every(
|
|
16763
|
-
(name) => DOMAIN_PRESERVING_MODIFIERS.has(name)
|
|
16764
|
-
) ? staticZodDomain(leaf, leafCall) : null,
|
|
16765
|
-
leaf,
|
|
16766
|
-
optional: modifiers.some((name) => OPTIONAL_MODIFIERS.has(name)),
|
|
16767
|
-
nullable: modifiers.some((name) => NULLABLE_MODIFIERS.has(name)),
|
|
16768
|
-
reshaped: modifiers.some((name) => RESHAPING_MODIFIERS.has(name))
|
|
16769
|
-
};
|
|
16770
|
-
}
|
|
16771
16836
|
function enumSchemaDomain(init) {
|
|
16772
|
-
const chain =
|
|
16837
|
+
const chain = twinCallChain(init, zodNamespaces);
|
|
16773
16838
|
if (chain === null || chain.length !== 1) {
|
|
16774
16839
|
return null;
|
|
16775
16840
|
}
|
|
16776
16841
|
const [call] = chain;
|
|
16777
|
-
if (call === void 0 ||
|
|
16842
|
+
if (call === void 0 || twinMethodName(call) !== "enum") {
|
|
16778
16843
|
return null;
|
|
16779
16844
|
}
|
|
16780
16845
|
const domain = staticZodDomain("enum", call);
|
|
@@ -16818,112 +16883,26 @@ var prefer_zod_infer_default = createRule({
|
|
|
16818
16883
|
});
|
|
16819
16884
|
}
|
|
16820
16885
|
}
|
|
16821
|
-
function
|
|
16822
|
-
const chain = zodCallChain(init);
|
|
16823
|
-
if (chain === null || chain.length === 0) {
|
|
16824
|
-
return null;
|
|
16825
|
-
}
|
|
16826
|
-
const [base, ...rest] = chain;
|
|
16827
|
-
if (base === void 0) {
|
|
16828
|
-
return null;
|
|
16829
|
-
}
|
|
16830
|
-
const baseMethod = methodName2(base);
|
|
16831
|
-
if (baseMethod !== "object" && baseMethod !== "strictObject") {
|
|
16832
|
-
return null;
|
|
16833
|
-
}
|
|
16834
|
-
if (rest.some((call) => !SHAPE_PRESERVING_METHODS.has(methodName2(call)))) {
|
|
16835
|
-
return null;
|
|
16836
|
-
}
|
|
16837
|
-
const shape = base.arguments[0];
|
|
16838
|
-
if (shape === void 0 || shape.type !== AST_NODE_TYPES69.ObjectExpression) {
|
|
16839
|
-
return null;
|
|
16840
|
-
}
|
|
16841
|
-
const fields = /* @__PURE__ */ new Map();
|
|
16842
|
-
for (const property of shape.properties) {
|
|
16843
|
-
if (property.type !== AST_NODE_TYPES69.Property || property.computed) {
|
|
16844
|
-
return null;
|
|
16845
|
-
}
|
|
16846
|
-
const { key } = property;
|
|
16847
|
-
const name = key.type === AST_NODE_TYPES69.Identifier ? key.name : key.type === AST_NODE_TYPES69.Literal && typeof key.value === "string" ? key.value : null;
|
|
16848
|
-
if (name === null) {
|
|
16849
|
-
return null;
|
|
16850
|
-
}
|
|
16851
|
-
fields.set(name, schemaField(property.value));
|
|
16852
|
-
}
|
|
16853
|
-
return fields.size === 0 ? null : fields;
|
|
16854
|
-
}
|
|
16855
|
-
function typeMembers(members) {
|
|
16856
|
-
const result = /* @__PURE__ */ new Map();
|
|
16857
|
-
for (const member of members) {
|
|
16858
|
-
if (member.type !== AST_NODE_TYPES69.TSPropertySignature || member.computed) {
|
|
16859
|
-
return null;
|
|
16860
|
-
}
|
|
16861
|
-
const { key } = member;
|
|
16862
|
-
const name = key.type === AST_NODE_TYPES69.Identifier ? key.name : key.type === AST_NODE_TYPES69.Literal && typeof key.value === "string" ? key.value : null;
|
|
16863
|
-
if (name === null) {
|
|
16864
|
-
return null;
|
|
16865
|
-
}
|
|
16866
|
-
const annotation = member.typeAnnotation?.typeAnnotation ?? null;
|
|
16867
|
-
result.set(name, {
|
|
16868
|
-
optional: member.optional === true,
|
|
16869
|
-
nullable: annotation !== null && unwrapNullish(annotation).nullable,
|
|
16870
|
-
readonly: member.readonly === true,
|
|
16871
|
-
annotation
|
|
16872
|
-
});
|
|
16873
|
-
}
|
|
16874
|
-
return result.size === 0 ? null : result;
|
|
16875
|
-
}
|
|
16876
|
-
function collectConstrainedNames(node) {
|
|
16886
|
+
function collectConstrainedNames2(node) {
|
|
16877
16887
|
if (node.type === AST_NODE_TYPES69.TSTypeReference) {
|
|
16878
16888
|
if (node.typeName.type === AST_NODE_TYPES69.Identifier) {
|
|
16879
16889
|
constrainedTypeNames.add(node.typeName.name);
|
|
16880
16890
|
}
|
|
16881
16891
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
16882
|
-
|
|
16892
|
+
collectConstrainedNames2(argument);
|
|
16883
16893
|
}
|
|
16884
16894
|
return;
|
|
16885
16895
|
}
|
|
16886
16896
|
if (node.type === AST_NODE_TYPES69.TSArrayType) {
|
|
16887
|
-
|
|
16897
|
+
collectConstrainedNames2(node.elementType);
|
|
16888
16898
|
return;
|
|
16889
16899
|
}
|
|
16890
16900
|
if (node.type === AST_NODE_TYPES69.TSUnionType || node.type === AST_NODE_TYPES69.TSIntersectionType) {
|
|
16891
16901
|
for (const member of node.types) {
|
|
16892
|
-
|
|
16902
|
+
collectConstrainedNames2(member);
|
|
16893
16903
|
}
|
|
16894
16904
|
}
|
|
16895
16905
|
}
|
|
16896
|
-
function isTwin(fields, members) {
|
|
16897
|
-
if (!requireIdenticalShape) {
|
|
16898
|
-
return true;
|
|
16899
|
-
}
|
|
16900
|
-
if (fields.size !== members.size) {
|
|
16901
|
-
return false;
|
|
16902
|
-
}
|
|
16903
|
-
for (const [name, field] of fields) {
|
|
16904
|
-
const member = members.get(name);
|
|
16905
|
-
if (member === void 0) {
|
|
16906
|
-
return false;
|
|
16907
|
-
}
|
|
16908
|
-
if (field.reshaped) {
|
|
16909
|
-
return false;
|
|
16910
|
-
}
|
|
16911
|
-
if (field.optional !== member.optional) {
|
|
16912
|
-
return false;
|
|
16913
|
-
}
|
|
16914
|
-
if (field.nullable !== member.nullable) {
|
|
16915
|
-
return false;
|
|
16916
|
-
}
|
|
16917
|
-
if (member.readonly) {
|
|
16918
|
-
return false;
|
|
16919
|
-
}
|
|
16920
|
-
const agrees = leafAgrees(field, member.annotation);
|
|
16921
|
-
if (agrees !== true) {
|
|
16922
|
-
return false;
|
|
16923
|
-
}
|
|
16924
|
-
}
|
|
16925
|
-
return true;
|
|
16926
|
-
}
|
|
16927
16906
|
return {
|
|
16928
16907
|
Program(node) {
|
|
16929
16908
|
for (const statement of node.body) {
|
|
@@ -16939,9 +16918,9 @@ var prefer_zod_infer_default = createRule({
|
|
|
16939
16918
|
if (node.id.type !== AST_NODE_TYPES69.Identifier || node.init == null || !isModuleLevelConst(node)) {
|
|
16940
16919
|
return;
|
|
16941
16920
|
}
|
|
16942
|
-
const fields =
|
|
16921
|
+
const fields = twinSchemaFields(node.init, zodNamespaces);
|
|
16943
16922
|
if (fields !== null) {
|
|
16944
|
-
schemas.push({ name: node.id.name, fields });
|
|
16923
|
+
schemas.push({ name: node.id.name, fields, initializer: node.init });
|
|
16945
16924
|
}
|
|
16946
16925
|
if (isModuleLevelConst(node)) {
|
|
16947
16926
|
const domain = enumSchemaDomain(node.init);
|
|
@@ -16953,7 +16932,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
16953
16932
|
},
|
|
16954
16933
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
16955
16934
|
"MemberExpression[computed=false]"(node) {
|
|
16956
|
-
if (node.object.type === AST_NODE_TYPES69.Identifier && node.property.type === AST_NODE_TYPES69.Identifier &&
|
|
16935
|
+
if (node.object.type === AST_NODE_TYPES69.Identifier && node.property.type === AST_NODE_TYPES69.Identifier && isPreferZodInferModuleReshaper(node.property.name)) {
|
|
16957
16936
|
reshapedSchemaNames.add(node.object.name);
|
|
16958
16937
|
}
|
|
16959
16938
|
},
|
|
@@ -16961,11 +16940,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
16961
16940
|
TSTypeReference(node) {
|
|
16962
16941
|
const { typeName } = node;
|
|
16963
16942
|
const referenced = typeName.type === AST_NODE_TYPES69.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES69.TSQualifiedName && typeName.right.type === AST_NODE_TYPES69.Identifier ? typeName.right.name : null;
|
|
16964
|
-
if (referenced === null || !
|
|
16943
|
+
if (referenced === null || !isPreferZodInferTypeConstraintName(referenced)) {
|
|
16965
16944
|
return;
|
|
16966
16945
|
}
|
|
16967
16946
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
16968
|
-
|
|
16947
|
+
collectConstrainedNames2(argument);
|
|
16969
16948
|
}
|
|
16970
16949
|
},
|
|
16971
16950
|
TSInterfaceDeclaration(node) {
|
|
@@ -16973,9 +16952,9 @@ var prefer_zod_infer_default = createRule({
|
|
|
16973
16952
|
if (node.typeParameters !== void 0 || (node.extends?.length ?? 0) > 0) {
|
|
16974
16953
|
return;
|
|
16975
16954
|
}
|
|
16976
|
-
const members =
|
|
16955
|
+
const members = twinTypeMembers(node);
|
|
16977
16956
|
if (members !== null) {
|
|
16978
|
-
typeDeclarations.push({ name: node.id.name, node: node.id, members });
|
|
16957
|
+
typeDeclarations.push({ declaration: node, name: node.id.name, node: node.id, members });
|
|
16979
16958
|
}
|
|
16980
16959
|
recordLiteralUnions(
|
|
16981
16960
|
node.body.body,
|
|
@@ -16997,9 +16976,9 @@ var prefer_zod_infer_default = createRule({
|
|
|
16997
16976
|
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES69.TSTypeLiteral) {
|
|
16998
16977
|
return;
|
|
16999
16978
|
}
|
|
17000
|
-
const members =
|
|
16979
|
+
const members = twinTypeMembers(node);
|
|
17001
16980
|
if (members !== null) {
|
|
17002
|
-
typeDeclarations.push({ name: node.id.name, node: node.id, members });
|
|
16981
|
+
typeDeclarations.push({ declaration: node, name: node.id.name, node: node.id, members });
|
|
17003
16982
|
}
|
|
17004
16983
|
recordLiteralUnions(
|
|
17005
16984
|
node.typeAnnotation.members,
|
|
@@ -17028,7 +17007,15 @@ var prefer_zod_infer_default = createRule({
|
|
|
17028
17007
|
if (schema === void 0 || reshapedSchemaNames.has(schema.name)) {
|
|
17029
17008
|
continue;
|
|
17030
17009
|
}
|
|
17031
|
-
if (!
|
|
17010
|
+
if (requireIdenticalShape ? !preferZodInferOwnsDefaultTwin({
|
|
17011
|
+
constrained: constrainedTypeNames.has(declaration.name),
|
|
17012
|
+
declaration: declaration.declaration,
|
|
17013
|
+
initializer: schema.initializer,
|
|
17014
|
+
reshaped: reshapedSchemaNames.has(schema.name),
|
|
17015
|
+
schemaName: schema.name,
|
|
17016
|
+
typeName: declaration.name,
|
|
17017
|
+
zodNamespaces
|
|
17018
|
+
}) : false) {
|
|
17032
17019
|
continue;
|
|
17033
17020
|
}
|
|
17034
17021
|
twinTypeNames.add(declaration.name);
|
|
@@ -17092,12 +17079,355 @@ var prefer_zod_infer_default = createRule({
|
|
|
17092
17079
|
}
|
|
17093
17080
|
});
|
|
17094
17081
|
|
|
17095
|
-
// src/rules/
|
|
17082
|
+
// src/rules/prefer-zod-parse-output-type.ts
|
|
17096
17083
|
import {
|
|
17097
|
-
|
|
17098
|
-
|
|
17084
|
+
AST_NODE_TYPES as AST_NODE_TYPES70,
|
|
17085
|
+
ESLintUtils as ESLintUtils7
|
|
17099
17086
|
} from "@typescript-eslint/utils";
|
|
17100
17087
|
import ts5 from "typescript";
|
|
17088
|
+
var PREFER_ZOD_PARSE_OUTPUT_TYPE_DOCUMENTATION = {
|
|
17089
|
+
summary: "Derive a function's return contract from the local Zod schema whose parsed output it returns.",
|
|
17090
|
+
rationale: "A hand-written contract can drift from the runtime-validated value even while each declaration remains locally valid.",
|
|
17091
|
+
remediation: "Export or colocate the schema and derive the contract with `z.output<typeof Schema>`.",
|
|
17092
|
+
category: "correctness",
|
|
17093
|
+
autofix: "none",
|
|
17094
|
+
limitations: [
|
|
17095
|
+
"Requires TypeScript type information and a direct return of a module-level local Zod object schema's `.parse()` result.",
|
|
17096
|
+
"Same-module name-correlated twins that `prefer-zod-infer` can prove are left to that established rule; this companion owns richer or renamed same-module and cross-module contracts proven by parse-return data flow.",
|
|
17097
|
+
"Only a single plain non-generic object interface or object type alias with exact property keys and bidirectional assignability is reported.",
|
|
17098
|
+
"Nullish conditional branches are followed; aliases, assignments, helper calls, imported schemas, and other indirect data flow are intentionally excluded.",
|
|
17099
|
+
"Contracts returned from more than one distinct local schema are excluded because no single schema has unambiguous ownership.",
|
|
17100
|
+
"Readonly, augmented, indexed, callable, generated, constrained, any, unknown, and never contracts are excluded rather than guessed.",
|
|
17101
|
+
"The rule is report-only because moving or exporting a schema changes module ownership and requires human review."
|
|
17102
|
+
],
|
|
17103
|
+
examples: [
|
|
17104
|
+
{
|
|
17105
|
+
id: "schema-derived-return",
|
|
17106
|
+
title: "Derive the validated return contract",
|
|
17107
|
+
outcome: "no-match",
|
|
17108
|
+
files: [
|
|
17109
|
+
{
|
|
17110
|
+
path: "src/row.ts",
|
|
17111
|
+
source: 'import { z } from "zod"; const RowSchema = z.object({ id: z.string() }); type Row = z.output<typeof RowSchema>; function load(): Row { return RowSchema.parse({}); }'
|
|
17112
|
+
}
|
|
17113
|
+
],
|
|
17114
|
+
focusPath: "src/row.ts",
|
|
17115
|
+
expectedCount: 0,
|
|
17116
|
+
public: true
|
|
17117
|
+
},
|
|
17118
|
+
{
|
|
17119
|
+
id: "hand-written-parsed-return",
|
|
17120
|
+
title: "Do not hand-write the parsed return shape",
|
|
17121
|
+
outcome: "match",
|
|
17122
|
+
files: [
|
|
17123
|
+
{
|
|
17124
|
+
path: "src/contracts.ts",
|
|
17125
|
+
source: "export interface ParsedRow { id: string }"
|
|
17126
|
+
},
|
|
17127
|
+
{
|
|
17128
|
+
path: "src/row.ts",
|
|
17129
|
+
source: 'import { z } from "zod"; import type { ParsedRow } from "./contracts.js"; const RowSchema = z.object({ id: z.string() }); function load(): ParsedRow { return RowSchema.parse({}); }'
|
|
17130
|
+
}
|
|
17131
|
+
],
|
|
17132
|
+
focusPath: "src/row.ts",
|
|
17133
|
+
expectedCount: 1,
|
|
17134
|
+
public: true
|
|
17135
|
+
}
|
|
17136
|
+
]
|
|
17137
|
+
};
|
|
17138
|
+
function isModuleLevelConst2(node) {
|
|
17139
|
+
const declaration = node.parent;
|
|
17140
|
+
if (declaration.type !== AST_NODE_TYPES70.VariableDeclaration || declaration.kind !== "const") {
|
|
17141
|
+
return false;
|
|
17142
|
+
}
|
|
17143
|
+
const container = declaration.parent;
|
|
17144
|
+
return container.type === AST_NODE_TYPES70.Program || container.type === AST_NODE_TYPES70.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES70.Program;
|
|
17145
|
+
}
|
|
17146
|
+
function isLocalZodObjectSchema(node, namespaces) {
|
|
17147
|
+
let current = node;
|
|
17148
|
+
while (current.type === AST_NODE_TYPES70.CallExpression) {
|
|
17149
|
+
const { callee } = current;
|
|
17150
|
+
if (callee.type !== AST_NODE_TYPES70.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES70.Identifier) {
|
|
17151
|
+
return false;
|
|
17152
|
+
}
|
|
17153
|
+
if (callee.object.type === AST_NODE_TYPES70.Identifier) {
|
|
17154
|
+
return namespaces.has(callee.object.name) && (callee.property.name === "object" || callee.property.name === "strictObject");
|
|
17155
|
+
}
|
|
17156
|
+
current = callee.object;
|
|
17157
|
+
}
|
|
17158
|
+
return false;
|
|
17159
|
+
}
|
|
17160
|
+
function parsedReturnCandidate(node) {
|
|
17161
|
+
const { callee } = node;
|
|
17162
|
+
if (callee.type !== AST_NODE_TYPES70.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES70.Identifier || callee.property.type !== AST_NODE_TYPES70.Identifier || callee.property.name !== "parse") {
|
|
17163
|
+
return null;
|
|
17164
|
+
}
|
|
17165
|
+
const owner = directReturnOwner(node);
|
|
17166
|
+
const annotation = owner?.returnType?.typeAnnotation;
|
|
17167
|
+
if (annotation === void 0) return null;
|
|
17168
|
+
const typeReference = returnContractReference(annotation);
|
|
17169
|
+
if (typeReference === null || typeReference.typeName.type !== AST_NODE_TYPES70.Identifier) {
|
|
17170
|
+
return null;
|
|
17171
|
+
}
|
|
17172
|
+
return {
|
|
17173
|
+
call: node,
|
|
17174
|
+
schema: callee.object,
|
|
17175
|
+
typeName: typeReference.typeName.name,
|
|
17176
|
+
typeReference
|
|
17177
|
+
};
|
|
17178
|
+
}
|
|
17179
|
+
function directReturnOwner(node) {
|
|
17180
|
+
let current = node;
|
|
17181
|
+
while (current.parent !== void 0) {
|
|
17182
|
+
const parent = current.parent;
|
|
17183
|
+
if (parent.type === AST_NODE_TYPES70.ReturnStatement) {
|
|
17184
|
+
return parent.argument === current ? enclosingFunction4(parent) : null;
|
|
17185
|
+
}
|
|
17186
|
+
if (parent.type === AST_NODE_TYPES70.ArrowFunctionExpression && parent.expression && parent.body === current) {
|
|
17187
|
+
return parent;
|
|
17188
|
+
}
|
|
17189
|
+
if (parent.type === AST_NODE_TYPES70.AwaitExpression && parent.argument === current) {
|
|
17190
|
+
current = parent;
|
|
17191
|
+
continue;
|
|
17192
|
+
}
|
|
17193
|
+
if (parent.type === AST_NODE_TYPES70.ConditionalExpression) {
|
|
17194
|
+
const parsedWhenTrue = parent.consequent === current && isNullishExpression(parent.alternate);
|
|
17195
|
+
const parsedWhenFalse = parent.alternate === current && isNullishExpression(parent.consequent);
|
|
17196
|
+
if (parsedWhenTrue || parsedWhenFalse) {
|
|
17197
|
+
current = parent;
|
|
17198
|
+
continue;
|
|
17199
|
+
}
|
|
17200
|
+
}
|
|
17201
|
+
return null;
|
|
17202
|
+
}
|
|
17203
|
+
return null;
|
|
17204
|
+
}
|
|
17205
|
+
function isNullishExpression(node) {
|
|
17206
|
+
return node.type === AST_NODE_TYPES70.Literal && node.value === null || node.type === AST_NODE_TYPES70.Identifier && node.name === "undefined";
|
|
17207
|
+
}
|
|
17208
|
+
function enclosingFunction4(node) {
|
|
17209
|
+
let current = node.parent;
|
|
17210
|
+
while (current !== void 0) {
|
|
17211
|
+
if (current.type === AST_NODE_TYPES70.ArrowFunctionExpression || current.type === AST_NODE_TYPES70.FunctionDeclaration || current.type === AST_NODE_TYPES70.FunctionExpression) {
|
|
17212
|
+
return current;
|
|
17213
|
+
}
|
|
17214
|
+
current = current.parent;
|
|
17215
|
+
}
|
|
17216
|
+
return null;
|
|
17217
|
+
}
|
|
17218
|
+
function returnContractReference(node) {
|
|
17219
|
+
if (node.type === AST_NODE_TYPES70.TSUnionType) {
|
|
17220
|
+
const substantive = node.types.filter(
|
|
17221
|
+
(member) => member.type !== AST_NODE_TYPES70.TSNullKeyword && member.type !== AST_NODE_TYPES70.TSUndefinedKeyword
|
|
17222
|
+
);
|
|
17223
|
+
const [only] = substantive;
|
|
17224
|
+
return substantive.length === 1 && only !== void 0 ? returnContractReference(only) : null;
|
|
17225
|
+
}
|
|
17226
|
+
if (node.type === AST_NODE_TYPES70.TSTypeReference && node.typeName.type === AST_NODE_TYPES70.Identifier && node.typeName.name === "Promise") {
|
|
17227
|
+
const parameters = node.typeArguments?.params ?? [];
|
|
17228
|
+
const [only] = parameters;
|
|
17229
|
+
return parameters.length === 1 && only !== void 0 ? returnContractReference(only) : null;
|
|
17230
|
+
}
|
|
17231
|
+
return node.type === AST_NODE_TYPES70.TSTypeReference && node.typeName.type === AST_NODE_TYPES70.Identifier && (node.typeArguments?.params.length ?? 0) === 0 ? node : null;
|
|
17232
|
+
}
|
|
17233
|
+
function recordZodNamespaces(node, namespaces) {
|
|
17234
|
+
for (const statement of node.body) {
|
|
17235
|
+
if (statement.type !== AST_NODE_TYPES70.ImportDeclaration || !isZodModule(statement.source.value)) {
|
|
17236
|
+
continue;
|
|
17237
|
+
}
|
|
17238
|
+
for (const specifier of statement.specifiers) {
|
|
17239
|
+
if (specifier.type === AST_NODE_TYPES70.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES70.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES70.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES70.Identifier && specifier.imported.name === "z") {
|
|
17240
|
+
namespaces.add(specifier.local.name);
|
|
17241
|
+
}
|
|
17242
|
+
}
|
|
17243
|
+
}
|
|
17244
|
+
}
|
|
17245
|
+
function collectConstrainedNames(node, names) {
|
|
17246
|
+
if (node.type === AST_NODE_TYPES70.TSTypeReference) {
|
|
17247
|
+
if (node.typeName.type === AST_NODE_TYPES70.Identifier) names.add(node.typeName.name);
|
|
17248
|
+
for (const argument of node.typeArguments?.params ?? []) {
|
|
17249
|
+
collectConstrainedNames(argument, names);
|
|
17250
|
+
}
|
|
17251
|
+
return;
|
|
17252
|
+
}
|
|
17253
|
+
if (node.type === AST_NODE_TYPES70.TSArrayType) {
|
|
17254
|
+
collectConstrainedNames(node.elementType, names);
|
|
17255
|
+
return;
|
|
17256
|
+
}
|
|
17257
|
+
if (node.type === AST_NODE_TYPES70.TSUnionType || node.type === AST_NODE_TYPES70.TSIntersectionType) {
|
|
17258
|
+
for (const member of node.types) collectConstrainedNames(member, names);
|
|
17259
|
+
}
|
|
17260
|
+
}
|
|
17261
|
+
function reportCandidates(context, services, schemas, candidates, zodNamespaces, reshapedSchemas, constrainedTypeNames) {
|
|
17262
|
+
const checker = services.program.getTypeChecker();
|
|
17263
|
+
const schemaSymbols = /* @__PURE__ */ new Map();
|
|
17264
|
+
for (const schema of schemas) {
|
|
17265
|
+
const tsIdentifier = services.esTreeNodeToTSNodeMap.get(schema.identifier);
|
|
17266
|
+
const symbol = checker.getSymbolAtLocation(tsIdentifier);
|
|
17267
|
+
if (symbol !== void 0) schemaSymbols.set(symbol, schema);
|
|
17268
|
+
}
|
|
17269
|
+
const eligible2 = [];
|
|
17270
|
+
const reported = /* @__PURE__ */ new Set();
|
|
17271
|
+
for (const candidate2 of candidates) {
|
|
17272
|
+
const tsSchema = services.esTreeNodeToTSNodeMap.get(candidate2.schema);
|
|
17273
|
+
const schemaSymbol = checker.getSymbolAtLocation(tsSchema);
|
|
17274
|
+
if (schemaSymbol === void 0) continue;
|
|
17275
|
+
const schema = schemaSymbols.get(schemaSymbol);
|
|
17276
|
+
if (schema === void 0) continue;
|
|
17277
|
+
const tsReference = services.esTreeNodeToTSNodeMap.get(candidate2.typeReference);
|
|
17278
|
+
const contract = checker.getTypeAtLocation(tsReference);
|
|
17279
|
+
const contractSymbol = contract.aliasSymbol ?? contract.getSymbol();
|
|
17280
|
+
if (contractSymbol === void 0) continue;
|
|
17281
|
+
const declaration = handWrittenObjectDeclaration(contractSymbol);
|
|
17282
|
+
if (declaration === null || declaration.getSourceFile().isDeclarationFile) continue;
|
|
17283
|
+
const source = declaration.getSourceFile();
|
|
17284
|
+
if (isGeneratedFile(source.fileName, source.text)) continue;
|
|
17285
|
+
const tsCall = services.esTreeNodeToTSNodeMap.get(candidate2.call);
|
|
17286
|
+
const parsed = checker.getTypeAtLocation(tsCall);
|
|
17287
|
+
const constrained = constrainedTypeNames.has(candidate2.typeName) || (parsed.aliasSymbol ?? parsed.getSymbol()) === contractSymbol;
|
|
17288
|
+
if (constrained) continue;
|
|
17289
|
+
if (declaration.getSourceFile() === tsSchema.getSourceFile()) {
|
|
17290
|
+
const estreeDeclaration = services.tsNodeToESTreeNodeMap.get(declaration);
|
|
17291
|
+
if ((estreeDeclaration.type === AST_NODE_TYPES70.TSInterfaceDeclaration || estreeDeclaration.type === AST_NODE_TYPES70.TSTypeAliasDeclaration) && preferZodInferOwnsDefaultTwin({
|
|
17292
|
+
constrained,
|
|
17293
|
+
declaration: estreeDeclaration,
|
|
17294
|
+
initializer: schema.initializer,
|
|
17295
|
+
reshaped: reshapedSchemas.has(schema.name),
|
|
17296
|
+
schemaName: schema.name,
|
|
17297
|
+
typeName: candidate2.typeName,
|
|
17298
|
+
zodNamespaces
|
|
17299
|
+
})) {
|
|
17300
|
+
continue;
|
|
17301
|
+
}
|
|
17302
|
+
}
|
|
17303
|
+
if (!exactObjectTypes(
|
|
17304
|
+
checker,
|
|
17305
|
+
checker.getNonNullableType(parsed),
|
|
17306
|
+
checker.getNonNullableType(contract)
|
|
17307
|
+
)) {
|
|
17308
|
+
continue;
|
|
17309
|
+
}
|
|
17310
|
+
eligible2.push({ candidate: candidate2, contractSymbol, schema, schemaSymbol });
|
|
17311
|
+
}
|
|
17312
|
+
const schemasByContract = /* @__PURE__ */ new Map();
|
|
17313
|
+
for (const { contractSymbol, schemaSymbol } of eligible2) {
|
|
17314
|
+
const contractSchemas = schemasByContract.get(contractSymbol) ?? /* @__PURE__ */ new Set();
|
|
17315
|
+
contractSchemas.add(schemaSymbol);
|
|
17316
|
+
schemasByContract.set(contractSymbol, contractSchemas);
|
|
17317
|
+
}
|
|
17318
|
+
for (const { candidate: candidate2, contractSymbol, schema } of eligible2) {
|
|
17319
|
+
if (reported.has(contractSymbol) || schemasByContract.get(contractSymbol)?.size !== 1) continue;
|
|
17320
|
+
reported.add(contractSymbol);
|
|
17321
|
+
context.report({
|
|
17322
|
+
node: candidate2.typeReference,
|
|
17323
|
+
messageId: "handWrittenParsedOutput",
|
|
17324
|
+
data: { schemaName: schema.name, typeName: candidate2.typeName }
|
|
17325
|
+
});
|
|
17326
|
+
}
|
|
17327
|
+
}
|
|
17328
|
+
function handWrittenObjectDeclaration(symbol) {
|
|
17329
|
+
const declarations = symbol.getDeclarations() ?? [];
|
|
17330
|
+
const [declaration] = declarations;
|
|
17331
|
+
if (declarations.length !== 1 || declaration === void 0) return null;
|
|
17332
|
+
const plainMembers = (members) => members.length > 0 && members.every(
|
|
17333
|
+
(member) => ts5.isPropertySignature(member) && member.type !== void 0 && member.modifiers?.some((modifier) => modifier.kind === ts5.SyntaxKind.ReadonlyKeyword) !== true
|
|
17334
|
+
);
|
|
17335
|
+
if (ts5.isInterfaceDeclaration(declaration) && declaration.typeParameters === void 0 && declaration.heritageClauses === void 0 && plainMembers(declaration.members)) {
|
|
17336
|
+
return declaration;
|
|
17337
|
+
}
|
|
17338
|
+
if (ts5.isTypeAliasDeclaration(declaration) && declaration.typeParameters === void 0 && ts5.isTypeLiteralNode(declaration.type) && plainMembers(declaration.type.members)) {
|
|
17339
|
+
return declaration;
|
|
17340
|
+
}
|
|
17341
|
+
return null;
|
|
17342
|
+
}
|
|
17343
|
+
function exactObjectTypes(checker, parsed, contract) {
|
|
17344
|
+
const unsafeFlags = ts5.TypeFlags.Any | ts5.TypeFlags.Unknown | ts5.TypeFlags.Never;
|
|
17345
|
+
if ((parsed.flags & unsafeFlags) !== 0 || (contract.flags & unsafeFlags) !== 0) return false;
|
|
17346
|
+
if (checker.getIndexInfosOfType(parsed).length > 0 || checker.getIndexInfosOfType(contract).length > 0 || checker.getSignaturesOfType(parsed, ts5.SignatureKind.Call).length > 0 || checker.getSignaturesOfType(contract, ts5.SignatureKind.Call).length > 0) {
|
|
17347
|
+
return false;
|
|
17348
|
+
}
|
|
17349
|
+
const names = (type) => checker.getPropertiesOfType(type).map((property) => property.getName()).sort();
|
|
17350
|
+
const parsedNames = names(parsed);
|
|
17351
|
+
const contractNames = names(contract);
|
|
17352
|
+
return parsedNames.length > 0 && parsedNames.length === contractNames.length && parsedNames.every((name, index) => name === contractNames[index]) && checker.isTypeAssignableTo(parsed, contract) && checker.isTypeAssignableTo(contract, parsed);
|
|
17353
|
+
}
|
|
17354
|
+
var prefer_zod_parse_output_type_default = createRule({
|
|
17355
|
+
name: "prefer-zod-parse-output-type",
|
|
17356
|
+
documentation: PREFER_ZOD_PARSE_OUTPUT_TYPE_DOCUMENTATION,
|
|
17357
|
+
meta: {
|
|
17358
|
+
type: "problem",
|
|
17359
|
+
docs: {
|
|
17360
|
+
description: "Derive a function's return contract from the local Zod schema whose parsed output it returns."
|
|
17361
|
+
},
|
|
17362
|
+
schema: [],
|
|
17363
|
+
messages: {
|
|
17364
|
+
handWrittenParsedOutput: "`{{typeName}}` exactly restates the validated output returned by `{{schemaName}}.parse()`. Export or colocate the schema and derive the contract with `z.output<typeof {{schemaName}}>` so the runtime and compile-time shapes cannot drift."
|
|
17365
|
+
}
|
|
17366
|
+
},
|
|
17367
|
+
defaultOptions: [],
|
|
17368
|
+
create(context) {
|
|
17369
|
+
if (isTestFile(context.filename) || isStoryFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
17370
|
+
return {};
|
|
17371
|
+
}
|
|
17372
|
+
let services;
|
|
17373
|
+
try {
|
|
17374
|
+
services = ESLintUtils7.getParserServices(context);
|
|
17375
|
+
} catch {
|
|
17376
|
+
services = null;
|
|
17377
|
+
}
|
|
17378
|
+
if (services === null) return {};
|
|
17379
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
17380
|
+
const constrainedTypeNames = /* @__PURE__ */ new Set();
|
|
17381
|
+
const reshapedSchemas = /* @__PURE__ */ new Set();
|
|
17382
|
+
const schemas = [];
|
|
17383
|
+
const candidates = [];
|
|
17384
|
+
return {
|
|
17385
|
+
Program(node) {
|
|
17386
|
+
recordZodNamespaces(node, namespaces);
|
|
17387
|
+
},
|
|
17388
|
+
VariableDeclarator(node) {
|
|
17389
|
+
if (node.id.type === AST_NODE_TYPES70.Identifier && node.init !== null && isModuleLevelConst2(node) && isLocalZodObjectSchema(node.init, namespaces)) {
|
|
17390
|
+
schemas.push({ identifier: node.id, initializer: node.init, name: node.id.name });
|
|
17391
|
+
}
|
|
17392
|
+
},
|
|
17393
|
+
CallExpression(node) {
|
|
17394
|
+
const candidate2 = parsedReturnCandidate(node);
|
|
17395
|
+
if (candidate2 !== null) candidates.push(candidate2);
|
|
17396
|
+
},
|
|
17397
|
+
"MemberExpression[computed=false]"(node) {
|
|
17398
|
+
if (node.object.type === AST_NODE_TYPES70.Identifier && node.property.type === AST_NODE_TYPES70.Identifier && isPreferZodInferModuleReshaper(node.property.name)) {
|
|
17399
|
+
reshapedSchemas.add(node.object.name);
|
|
17400
|
+
}
|
|
17401
|
+
},
|
|
17402
|
+
TSTypeReference(node) {
|
|
17403
|
+
const { typeName } = node;
|
|
17404
|
+
const name = typeName.type === AST_NODE_TYPES70.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES70.TSQualifiedName && typeName.right.type === AST_NODE_TYPES70.Identifier ? typeName.right.name : null;
|
|
17405
|
+
if (name === null || !isPreferZodInferTypeConstraintName(name)) return;
|
|
17406
|
+
for (const argument of node.typeArguments?.params ?? []) {
|
|
17407
|
+
collectConstrainedNames(argument, constrainedTypeNames);
|
|
17408
|
+
}
|
|
17409
|
+
},
|
|
17410
|
+
"Program:exit"() {
|
|
17411
|
+
reportCandidates(
|
|
17412
|
+
context,
|
|
17413
|
+
services,
|
|
17414
|
+
schemas,
|
|
17415
|
+
candidates,
|
|
17416
|
+
namespaces,
|
|
17417
|
+
reshapedSchemas,
|
|
17418
|
+
constrainedTypeNames
|
|
17419
|
+
);
|
|
17420
|
+
}
|
|
17421
|
+
};
|
|
17422
|
+
}
|
|
17423
|
+
});
|
|
17424
|
+
|
|
17425
|
+
// src/rules/require-assert-never.ts
|
|
17426
|
+
import {
|
|
17427
|
+
ESLintUtils as ESLintUtils8,
|
|
17428
|
+
AST_NODE_TYPES as AST_NODE_TYPES71
|
|
17429
|
+
} from "@typescript-eslint/utils";
|
|
17430
|
+
import ts6 from "typescript";
|
|
17101
17431
|
var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
17102
17432
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
17103
17433
|
rationale: "An empty default silently accepts new union members instead of making the compiler identify the missing case.",
|
|
@@ -17110,14 +17440,14 @@ var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
|
17110
17440
|
]
|
|
17111
17441
|
};
|
|
17112
17442
|
var isRuntimeHandlingStatement = (statement) => {
|
|
17113
|
-
if (statement.type ===
|
|
17114
|
-
if (statement.type ===
|
|
17443
|
+
if (statement.type === AST_NODE_TYPES71.EmptyStatement) return false;
|
|
17444
|
+
if (statement.type === AST_NODE_TYPES71.BreakStatement) {
|
|
17115
17445
|
return statement.label !== null;
|
|
17116
17446
|
}
|
|
17117
|
-
if (statement.type ===
|
|
17447
|
+
if (statement.type === AST_NODE_TYPES71.TSTypeAliasDeclaration || statement.type === AST_NODE_TYPES71.TSInterfaceDeclaration) {
|
|
17118
17448
|
return false;
|
|
17119
17449
|
}
|
|
17120
|
-
if (statement.type ===
|
|
17450
|
+
if (statement.type === AST_NODE_TYPES71.BlockStatement) {
|
|
17121
17451
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
17122
17452
|
}
|
|
17123
17453
|
return true;
|
|
@@ -17133,7 +17463,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
17133
17463
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
17134
17464
|
}
|
|
17135
17465
|
const only = defaultCase.consequent[0];
|
|
17136
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
17466
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES71.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
17137
17467
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
17138
17468
|
}
|
|
17139
17469
|
return false;
|
|
@@ -17145,7 +17475,7 @@ function isExhaustiveFiniteSwitch(node, services) {
|
|
|
17145
17475
|
const constituents = discriminantType.isUnion() ? discriminantType.types : [discriminantType];
|
|
17146
17476
|
if (!discriminantType.isUnion() || constituents.length < 2) return false;
|
|
17147
17477
|
if (constituents.every(
|
|
17148
|
-
(constituent) => (constituent.flags &
|
|
17478
|
+
(constituent) => (constituent.flags & ts6.TypeFlags.BooleanLiteral) !== 0
|
|
17149
17479
|
)) {
|
|
17150
17480
|
return false;
|
|
17151
17481
|
}
|
|
@@ -17167,7 +17497,7 @@ function isExhaustiveFiniteSwitch(node, services) {
|
|
|
17167
17497
|
return [...expected].every((key) => handled.has(key));
|
|
17168
17498
|
}
|
|
17169
17499
|
function finiteTypeKey(type, checker) {
|
|
17170
|
-
const finiteFlags =
|
|
17500
|
+
const finiteFlags = ts6.TypeFlags.StringLiteral | ts6.TypeFlags.NumberLiteral | ts6.TypeFlags.BooleanLiteral | ts6.TypeFlags.EnumLiteral | ts6.TypeFlags.UniqueESSymbol | ts6.TypeFlags.Null | ts6.TypeFlags.Undefined;
|
|
17171
17501
|
return (type.flags & finiteFlags) !== 0 ? checker.typeToString(type) : null;
|
|
17172
17502
|
}
|
|
17173
17503
|
var require_assert_never_default = createRule({
|
|
@@ -17187,7 +17517,7 @@ var require_assert_never_default = createRule({
|
|
|
17187
17517
|
create(context) {
|
|
17188
17518
|
let services;
|
|
17189
17519
|
try {
|
|
17190
|
-
services =
|
|
17520
|
+
services = ESLintUtils8.getParserServices(context);
|
|
17191
17521
|
} catch {
|
|
17192
17522
|
services = null;
|
|
17193
17523
|
}
|
|
@@ -17214,7 +17544,7 @@ var require_assert_never_default = createRule({
|
|
|
17214
17544
|
});
|
|
17215
17545
|
|
|
17216
17546
|
// src/rules/require-fetch-timeout.ts
|
|
17217
|
-
import { AST_NODE_TYPES as
|
|
17547
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES72, ASTUtils as ASTUtils40 } from "@typescript-eslint/utils";
|
|
17218
17548
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
17219
17549
|
summary: "Require an explicit abort signal on locally analyzable global fetch calls.",
|
|
17220
17550
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -17241,14 +17571,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
17241
17571
|
return false;
|
|
17242
17572
|
}
|
|
17243
17573
|
function initProvablyLacksSignal(init) {
|
|
17244
|
-
if (init.type !==
|
|
17574
|
+
if (init.type !== AST_NODE_TYPES72.ObjectExpression) {
|
|
17245
17575
|
return false;
|
|
17246
17576
|
}
|
|
17247
17577
|
for (const prop of init.properties) {
|
|
17248
|
-
if (prop.type ===
|
|
17578
|
+
if (prop.type === AST_NODE_TYPES72.SpreadElement) {
|
|
17249
17579
|
return false;
|
|
17250
17580
|
}
|
|
17251
|
-
if (prop.key.type ===
|
|
17581
|
+
if (prop.key.type === AST_NODE_TYPES72.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES72.Literal && prop.key.value === "signal") {
|
|
17252
17582
|
return false;
|
|
17253
17583
|
}
|
|
17254
17584
|
if (prop.computed) {
|
|
@@ -17258,7 +17588,7 @@ function initProvablyLacksSignal(init) {
|
|
|
17258
17588
|
return true;
|
|
17259
17589
|
}
|
|
17260
17590
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
17261
|
-
return node.type ===
|
|
17591
|
+
return node.type === AST_NODE_TYPES72.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES72.TemplateLiteral || node.type === AST_NODE_TYPES72.NewExpression && node.callee.type === AST_NODE_TYPES72.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
17262
17592
|
}
|
|
17263
17593
|
var require_fetch_timeout_default = createRule({
|
|
17264
17594
|
name: "require-fetch-timeout",
|
|
@@ -17300,10 +17630,10 @@ var require_fetch_timeout_default = createRule({
|
|
|
17300
17630
|
return variable === null || variable.defs.length === 0;
|
|
17301
17631
|
}
|
|
17302
17632
|
function isGlobalFetchCall2(callee) {
|
|
17303
|
-
if (callee.type ===
|
|
17633
|
+
if (callee.type === AST_NODE_TYPES72.Identifier) {
|
|
17304
17634
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
17305
17635
|
}
|
|
17306
|
-
return callee.type ===
|
|
17636
|
+
return callee.type === AST_NODE_TYPES72.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES72.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES72.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
17307
17637
|
}
|
|
17308
17638
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
17309
17639
|
const variable = ASTUtils40.findVariable(
|
|
@@ -17312,14 +17642,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
17312
17642
|
);
|
|
17313
17643
|
if (variable?.defs.length !== 1) return false;
|
|
17314
17644
|
const definition = variable.defs[0];
|
|
17315
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
17645
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== AST_NODE_TYPES72.ObjectExpression || !initProvablyLacksSignal(definition.node.init)) {
|
|
17316
17646
|
return false;
|
|
17317
17647
|
}
|
|
17318
17648
|
for (const reference of variable.references) {
|
|
17319
17649
|
const ref = reference.identifier;
|
|
17320
17650
|
if (ref === identifier || ref === definition.name) continue;
|
|
17321
17651
|
const member = ref.parent;
|
|
17322
|
-
if (member.type !==
|
|
17652
|
+
if (member.type !== AST_NODE_TYPES72.MemberExpression || member.object !== ref || member.computed || member.property.type !== AST_NODE_TYPES72.Identifier || member.property.name === "signal" || member.parent.type !== AST_NODE_TYPES72.AssignmentExpression || member.parent.left !== member) {
|
|
17323
17653
|
return false;
|
|
17324
17654
|
}
|
|
17325
17655
|
}
|
|
@@ -17327,13 +17657,13 @@ var require_fetch_timeout_default = createRule({
|
|
|
17327
17657
|
}
|
|
17328
17658
|
function isForwardedRequest(argument) {
|
|
17329
17659
|
let value = argument;
|
|
17330
|
-
if (value.type ===
|
|
17660
|
+
if (value.type === AST_NODE_TYPES72.Identifier) {
|
|
17331
17661
|
const binding = ASTUtils40.findVariable(context.sourceCode.getScope(value), value.name);
|
|
17332
17662
|
const definition = binding?.defs.length === 1 ? binding.defs[0] : void 0;
|
|
17333
17663
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || binding?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
17334
17664
|
value = definition.node.init;
|
|
17335
17665
|
}
|
|
17336
|
-
return value.type ===
|
|
17666
|
+
return value.type === AST_NODE_TYPES72.NewExpression && value.callee.type === AST_NODE_TYPES72.Identifier && value.callee.name === "Request" && resolvesToGlobal(value.callee);
|
|
17337
17667
|
}
|
|
17338
17668
|
return {
|
|
17339
17669
|
CallExpression(node) {
|
|
@@ -17344,7 +17674,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
17344
17674
|
if (first !== void 0 && (node.arguments.length === 1 && !isInlineUrl(first, resolvesToGlobal) || isForwardedRequest(first))) {
|
|
17345
17675
|
return;
|
|
17346
17676
|
}
|
|
17347
|
-
if (init === void 0 || initProvablyLacksSignal(init) || init.type ===
|
|
17677
|
+
if (init === void 0 || initProvablyLacksSignal(init) || init.type === AST_NODE_TYPES72.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
17348
17678
|
context.report({ node, messageId: "missingSignal" });
|
|
17349
17679
|
}
|
|
17350
17680
|
}
|
|
@@ -17353,7 +17683,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
17353
17683
|
});
|
|
17354
17684
|
|
|
17355
17685
|
// src/rules/require-interface-for-exported-class.ts
|
|
17356
|
-
import { AST_NODE_TYPES as
|
|
17686
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES73 } from "@typescript-eslint/utils";
|
|
17357
17687
|
var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
17358
17688
|
summary: "Require exported concrete classes with public behavior to declare a contract.",
|
|
17359
17689
|
rationale: "An explicit contract names the intended public capability separately from implementation details. TypeScript already supports structural compatibility; this is an architecture policy, not a prerequisite for substitution.",
|
|
@@ -17399,23 +17729,23 @@ var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
|
17399
17729
|
};
|
|
17400
17730
|
function hasPublicInstanceBehavior(node) {
|
|
17401
17731
|
return node.body.body.some((member) => {
|
|
17402
|
-
if (member.type ===
|
|
17403
|
-
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !==
|
|
17732
|
+
if (member.type === AST_NODE_TYPES73.MethodDefinition) {
|
|
17733
|
+
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !== AST_NODE_TYPES73.PrivateIdentifier;
|
|
17404
17734
|
}
|
|
17405
|
-
if (member.type !==
|
|
17735
|
+
if (member.type !== AST_NODE_TYPES73.PropertyDefinition || member.static)
|
|
17406
17736
|
return false;
|
|
17407
|
-
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type ===
|
|
17408
|
-
return member.value?.type ===
|
|
17737
|
+
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type === AST_NODE_TYPES73.PrivateIdentifier) return false;
|
|
17738
|
+
return member.value?.type === AST_NODE_TYPES73.ArrowFunctionExpression || member.value?.type === AST_NODE_TYPES73.FunctionExpression || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES73.TSFunctionType;
|
|
17409
17739
|
});
|
|
17410
17740
|
}
|
|
17411
17741
|
function classBindings(statement) {
|
|
17412
|
-
const declaration = statement.type ===
|
|
17413
|
-
if (declaration?.type ===
|
|
17742
|
+
const declaration = statement.type === AST_NODE_TYPES73.ExportNamedDeclaration ? statement.declaration : statement;
|
|
17743
|
+
if (declaration?.type === AST_NODE_TYPES73.ClassDeclaration) {
|
|
17414
17744
|
return declaration.id === null ? [] : [{ declaration, name: declaration.id.name }];
|
|
17415
17745
|
}
|
|
17416
|
-
if (declaration?.type !==
|
|
17746
|
+
if (declaration?.type !== AST_NODE_TYPES73.VariableDeclaration) return [];
|
|
17417
17747
|
return declaration.declarations.flatMap(
|
|
17418
|
-
(item) => item.id.type ===
|
|
17748
|
+
(item) => item.id.type === AST_NODE_TYPES73.Identifier && item.init?.type === AST_NODE_TYPES73.ClassExpression ? [{ declaration: item.init, name: item.id.name }] : []
|
|
17419
17749
|
);
|
|
17420
17750
|
}
|
|
17421
17751
|
var require_interface_for_exported_class_default = createRule({
|
|
@@ -17446,7 +17776,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
17446
17776
|
}
|
|
17447
17777
|
const exported = /* @__PURE__ */ new Map();
|
|
17448
17778
|
for (const statement of program.body) {
|
|
17449
|
-
if (statement.type ===
|
|
17779
|
+
if (statement.type === AST_NODE_TYPES73.ExportNamedDeclaration) {
|
|
17450
17780
|
for (const binding of classBindings(statement)) {
|
|
17451
17781
|
exported.set(binding.declaration, binding.name);
|
|
17452
17782
|
}
|
|
@@ -17455,18 +17785,18 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
17455
17785
|
if (specifier.exportKind === "type") continue;
|
|
17456
17786
|
const candidate2 = classes.get(specifier.local.name);
|
|
17457
17787
|
if (candidate2 === void 0) continue;
|
|
17458
|
-
const exportedName = specifier.exported.type ===
|
|
17788
|
+
const exportedName = specifier.exported.type === AST_NODE_TYPES73.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
17459
17789
|
exported.set(candidate2, exportedName);
|
|
17460
17790
|
}
|
|
17461
17791
|
continue;
|
|
17462
17792
|
}
|
|
17463
|
-
if (statement.type !==
|
|
17464
|
-
if (statement.declaration.type ===
|
|
17793
|
+
if (statement.type !== AST_NODE_TYPES73.ExportDefaultDeclaration) continue;
|
|
17794
|
+
if (statement.declaration.type === AST_NODE_TYPES73.ClassDeclaration || statement.declaration.type === AST_NODE_TYPES73.ClassExpression) {
|
|
17465
17795
|
exported.set(
|
|
17466
17796
|
statement.declaration,
|
|
17467
17797
|
statement.declaration.id?.name ?? "default"
|
|
17468
17798
|
);
|
|
17469
|
-
} else if (statement.declaration.type ===
|
|
17799
|
+
} else if (statement.declaration.type === AST_NODE_TYPES73.Identifier) {
|
|
17470
17800
|
const candidate2 = classes.get(statement.declaration.name);
|
|
17471
17801
|
if (candidate2 !== void 0) {
|
|
17472
17802
|
exported.set(candidate2, statement.declaration.name);
|
|
@@ -17474,7 +17804,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
17474
17804
|
}
|
|
17475
17805
|
}
|
|
17476
17806
|
for (const [declaration, exportedName] of exported) {
|
|
17477
|
-
const extendsLocalAbstractBase = declaration.superClass?.type ===
|
|
17807
|
+
const extendsLocalAbstractBase = declaration.superClass?.type === AST_NODE_TYPES73.Identifier && abstractBases.has(declaration.superClass.name);
|
|
17478
17808
|
if (declaration.abstract || declaration.implements.length > 0 || extendsLocalAbstractBase || !hasPublicInstanceBehavior(declaration)) continue;
|
|
17479
17809
|
context.report({
|
|
17480
17810
|
node: declaration.id ?? declaration,
|
|
@@ -17488,7 +17818,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
17488
17818
|
});
|
|
17489
17819
|
|
|
17490
17820
|
// src/rules/require-port-for-service.ts
|
|
17491
|
-
import { AST_NODE_TYPES as
|
|
17821
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES74 } from "@typescript-eslint/utils";
|
|
17492
17822
|
var REQUIRE_PORT_FOR_SERVICE_DOCUMENTATION = {
|
|
17493
17823
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
17494
17824
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -17513,45 +17843,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
17513
17843
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
17514
17844
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
17515
17845
|
var staticMemberName6 = (member) => {
|
|
17516
|
-
if (member.property.type ===
|
|
17517
|
-
if (!member.computed && member.property.type ===
|
|
17518
|
-
return member.computed && member.property.type ===
|
|
17846
|
+
if (member.property.type === AST_NODE_TYPES74.PrivateIdentifier) return `#${member.property.name}`;
|
|
17847
|
+
if (!member.computed && member.property.type === AST_NODE_TYPES74.Identifier) return member.property.name;
|
|
17848
|
+
return member.computed && member.property.type === AST_NODE_TYPES74.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
17519
17849
|
};
|
|
17520
17850
|
var detachedValueExports = (program) => {
|
|
17521
17851
|
const names = /* @__PURE__ */ new Set();
|
|
17522
17852
|
for (const statement of program.body) {
|
|
17523
|
-
if (statement.type ===
|
|
17853
|
+
if (statement.type === AST_NODE_TYPES74.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
17524
17854
|
for (const specifier of statement.specifiers) {
|
|
17525
17855
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
17526
17856
|
}
|
|
17527
|
-
} else if (statement.type ===
|
|
17857
|
+
} else if (statement.type === AST_NODE_TYPES74.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES74.Identifier) {
|
|
17528
17858
|
names.add(statement.declaration.name);
|
|
17529
|
-
} else if (statement.type ===
|
|
17859
|
+
} else if (statement.type === AST_NODE_TYPES74.TSExportAssignment && statement.expression.type === AST_NODE_TYPES74.Identifier) {
|
|
17530
17860
|
names.add(statement.expression.name);
|
|
17531
17861
|
}
|
|
17532
17862
|
}
|
|
17533
17863
|
return names;
|
|
17534
17864
|
};
|
|
17535
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
17865
|
+
var isExportedClass2 = (node, detached) => node.parent.type === AST_NODE_TYPES74.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES74.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
17536
17866
|
var readTypeReference = (annotation) => {
|
|
17537
|
-
if (annotation?.type ===
|
|
17867
|
+
if (annotation?.type === AST_NODE_TYPES74.TSUnionType) {
|
|
17538
17868
|
const members = annotation.types.filter(
|
|
17539
|
-
(member) => member.type !==
|
|
17869
|
+
(member) => member.type !== AST_NODE_TYPES74.TSUndefinedKeyword && member.type !== AST_NODE_TYPES74.TSNullKeyword
|
|
17540
17870
|
);
|
|
17541
17871
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
17542
17872
|
}
|
|
17543
|
-
if (annotation === void 0 || annotation.type !==
|
|
17873
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES74.TSTypeReference) return null;
|
|
17544
17874
|
const { typeName } = annotation;
|
|
17545
|
-
const rightmost = typeName.type ===
|
|
17875
|
+
const rightmost = typeName.type === AST_NODE_TYPES74.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES74.TSQualifiedName ? typeName.right.name : null;
|
|
17546
17876
|
if (rightmost === null) return null;
|
|
17547
17877
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
17548
17878
|
};
|
|
17549
|
-
var qualifiedName = (name) => name.type ===
|
|
17879
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES74.Identifier ? name.name : name.type === AST_NODE_TYPES74.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
17550
17880
|
var propertySignatureTypes = (members) => {
|
|
17551
17881
|
const types = /* @__PURE__ */ new Map();
|
|
17552
17882
|
for (const member of members) {
|
|
17553
|
-
if (member.type !==
|
|
17554
|
-
if (member.computed || member.key.type !==
|
|
17883
|
+
if (member.type !== AST_NODE_TYPES74.TSPropertySignature) continue;
|
|
17884
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES74.Identifier) continue;
|
|
17555
17885
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
17556
17886
|
if (reference === null) continue;
|
|
17557
17887
|
types.set(member.key.name, reference);
|
|
@@ -17562,18 +17892,18 @@ var fileTypeIndex = (program) => {
|
|
|
17562
17892
|
const objects = /* @__PURE__ */ new Map();
|
|
17563
17893
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
17564
17894
|
for (const statement of program.body) {
|
|
17565
|
-
const declaration = statement.type ===
|
|
17566
|
-
if (declaration?.type ===
|
|
17895
|
+
const declaration = statement.type === AST_NODE_TYPES74.ExportNamedDeclaration ? statement.declaration : statement;
|
|
17896
|
+
if (declaration?.type === AST_NODE_TYPES74.TSInterfaceDeclaration) {
|
|
17567
17897
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
17568
17898
|
continue;
|
|
17569
17899
|
}
|
|
17570
|
-
if (declaration?.type !==
|
|
17900
|
+
if (declaration?.type !== AST_NODE_TYPES74.TSTypeAliasDeclaration) continue;
|
|
17571
17901
|
const aliased = declaration.typeAnnotation;
|
|
17572
|
-
if (aliased.type ===
|
|
17902
|
+
if (aliased.type === AST_NODE_TYPES74.TSFunctionType || aliased.type === AST_NODE_TYPES74.TSConstructorType) {
|
|
17573
17903
|
functionAliases.add(declaration.id.name);
|
|
17574
17904
|
continue;
|
|
17575
17905
|
}
|
|
17576
|
-
const literals = aliased.type ===
|
|
17906
|
+
const literals = aliased.type === AST_NODE_TYPES74.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES74.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES74.TSTypeLiteral) : [];
|
|
17577
17907
|
if (literals.length === 0) continue;
|
|
17578
17908
|
const merged = /* @__PURE__ */ new Map();
|
|
17579
17909
|
for (const literal of literals) {
|
|
@@ -17602,10 +17932,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
17602
17932
|
while (pending.length > 0) {
|
|
17603
17933
|
const current = pending.pop();
|
|
17604
17934
|
if (current === void 0) break;
|
|
17605
|
-
if (current.type ===
|
|
17606
|
-
const expression = current.type ===
|
|
17607
|
-
const storedField = expression?.type ===
|
|
17608
|
-
if (expression?.type !==
|
|
17935
|
+
if (current.type === AST_NODE_TYPES74.ArrowFunctionExpression || current.type === AST_NODE_TYPES74.FunctionExpression || current.type === AST_NODE_TYPES74.FunctionDeclaration || current.type === AST_NODE_TYPES74.ClassExpression || current.type === AST_NODE_TYPES74.ClassDeclaration) continue;
|
|
17936
|
+
const expression = current.type === AST_NODE_TYPES74.ExpressionStatement ? current.expression : null;
|
|
17937
|
+
const storedField = expression?.type === AST_NODE_TYPES74.AssignmentExpression && expression.left.type === AST_NODE_TYPES74.MemberExpression && expression.left.object.type === AST_NODE_TYPES74.ThisExpression ? staticMemberName6(expression.left) : null;
|
|
17938
|
+
if (expression?.type !== AST_NODE_TYPES74.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== AST_NODE_TYPES74.MemberExpression || expression.left.object.type !== AST_NODE_TYPES74.ThisExpression || storedField === null) {
|
|
17609
17939
|
for (const key of Object.keys(current)) {
|
|
17610
17940
|
if (key === "parent") continue;
|
|
17611
17941
|
const value = current[key];
|
|
@@ -17618,14 +17948,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
17618
17948
|
continue;
|
|
17619
17949
|
}
|
|
17620
17950
|
let source = expression.right;
|
|
17621
|
-
while (source.type ===
|
|
17622
|
-
if (source.type ===
|
|
17951
|
+
while (source.type === AST_NODE_TYPES74.TSNonNullExpression || source.type === AST_NODE_TYPES74.TSAsExpression || source.type === AST_NODE_TYPES74.TSSatisfiesExpression || source.type === AST_NODE_TYPES74.TSTypeAssertion) source = source.expression;
|
|
17952
|
+
if (source.type === AST_NODE_TYPES74.NewExpression) {
|
|
17623
17953
|
constructedFields += 1;
|
|
17624
|
-
} else if (source.type ===
|
|
17954
|
+
} else if (source.type === AST_NODE_TYPES74.Identifier) {
|
|
17625
17955
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
17626
17956
|
fields.add(storedField);
|
|
17627
17957
|
storedFieldsFrom.set(source.name, fields);
|
|
17628
|
-
} else if (source.type ===
|
|
17958
|
+
} else if (source.type === AST_NODE_TYPES74.MemberExpression && source.object.type === AST_NODE_TYPES74.Identifier) {
|
|
17629
17959
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
17630
17960
|
fields.add(storedField);
|
|
17631
17961
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -17643,7 +17973,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
17643
17973
|
const collaborators = [];
|
|
17644
17974
|
for (const parameter of ctor.value.params) {
|
|
17645
17975
|
for (const reference of parameterCollaborators(parameter, declared, storedMemberFieldsFrom)) {
|
|
17646
|
-
const fields = parameter.type ===
|
|
17976
|
+
const fields = parameter.type === AST_NODE_TYPES74.TSParameterProperty ? [reference.name] : reference.fields.length > 0 ? reference.fields : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
17647
17977
|
if (fields.length === 0) continue;
|
|
17648
17978
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
17649
17979
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -17658,8 +17988,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
17658
17988
|
};
|
|
17659
17989
|
var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
17660
17990
|
let target = parameter;
|
|
17661
|
-
if (target.type ===
|
|
17662
|
-
if (target.type ===
|
|
17991
|
+
if (target.type === AST_NODE_TYPES74.AssignmentPattern) target = target.left;
|
|
17992
|
+
if (target.type === AST_NODE_TYPES74.ObjectPattern) {
|
|
17663
17993
|
return objectPatternCollaborators(target, declared);
|
|
17664
17994
|
}
|
|
17665
17995
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -17668,9 +17998,9 @@ var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
|
17668
17998
|
};
|
|
17669
17999
|
var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
17670
18000
|
let target = annotated;
|
|
17671
|
-
if (target.type ===
|
|
17672
|
-
if (target.type ===
|
|
17673
|
-
if (target.type !==
|
|
18001
|
+
if (target.type === AST_NODE_TYPES74.TSParameterProperty) target = target.parameter;
|
|
18002
|
+
if (target.type === AST_NODE_TYPES74.AssignmentPattern) target = target.left;
|
|
18003
|
+
if (target.type !== AST_NODE_TYPES74.Identifier) return [];
|
|
17674
18004
|
const members = bagMemberTypes(target.typeAnnotation?.typeAnnotation, declared);
|
|
17675
18005
|
if (members === null) return [];
|
|
17676
18006
|
const storedMembers = storedMemberFieldsFrom.get(target.name);
|
|
@@ -17686,9 +18016,9 @@ var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
|
17686
18016
|
};
|
|
17687
18017
|
var namedParameterCollaborator = (annotated) => {
|
|
17688
18018
|
let target = annotated;
|
|
17689
|
-
if (target.type ===
|
|
17690
|
-
if (target.type ===
|
|
17691
|
-
if (target.type !==
|
|
18019
|
+
if (target.type === AST_NODE_TYPES74.TSParameterProperty) target = target.parameter;
|
|
18020
|
+
if (target.type === AST_NODE_TYPES74.AssignmentPattern) target = target.left;
|
|
18021
|
+
if (target.type !== AST_NODE_TYPES74.Identifier) return null;
|
|
17692
18022
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
17693
18023
|
if (reference === null) return null;
|
|
17694
18024
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -17700,11 +18030,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
17700
18030
|
if (members === null) return [];
|
|
17701
18031
|
const collaborators = [];
|
|
17702
18032
|
for (const property of pattern.properties) {
|
|
17703
|
-
if (property.type !==
|
|
17704
|
-
if (property.key.type !==
|
|
18033
|
+
if (property.type !== AST_NODE_TYPES74.Property || property.computed) continue;
|
|
18034
|
+
if (property.key.type !== AST_NODE_TYPES74.Identifier) continue;
|
|
17705
18035
|
const key = property.key.name;
|
|
17706
|
-
const bound = property.value.type ===
|
|
17707
|
-
if (bound.type !==
|
|
18036
|
+
const bound = property.value.type === AST_NODE_TYPES74.AssignmentPattern ? property.value.left : property.value;
|
|
18037
|
+
if (bound.type !== AST_NODE_TYPES74.Identifier) continue;
|
|
17708
18038
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
17709
18039
|
const reference = members.get(key);
|
|
17710
18040
|
if (reference === void 0) continue;
|
|
@@ -17714,21 +18044,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
17714
18044
|
};
|
|
17715
18045
|
var bagMemberTypes = (annotation, declared) => {
|
|
17716
18046
|
if (annotation === void 0) return null;
|
|
17717
|
-
if (annotation.type ===
|
|
18047
|
+
if (annotation.type === AST_NODE_TYPES74.TSTypeLiteral) {
|
|
17718
18048
|
return propertySignatureTypes(annotation.members);
|
|
17719
18049
|
}
|
|
17720
|
-
if (annotation.type !==
|
|
18050
|
+
if (annotation.type !== AST_NODE_TYPES74.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES74.Identifier) {
|
|
17721
18051
|
return null;
|
|
17722
18052
|
}
|
|
17723
18053
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
17724
18054
|
};
|
|
17725
18055
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
17726
|
-
if (node.type ===
|
|
18056
|
+
if (node.type === AST_NODE_TYPES74.CallExpression) {
|
|
17727
18057
|
const { callee } = node;
|
|
17728
|
-
if (callee.type ===
|
|
17729
|
-
return callee.type ===
|
|
18058
|
+
if (callee.type === AST_NODE_TYPES74.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
18059
|
+
return callee.type === AST_NODE_TYPES74.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES74.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
17730
18060
|
}
|
|
17731
|
-
return node.type ===
|
|
18061
|
+
return node.type === AST_NODE_TYPES74.TSTypeReference && node.typeName.type === AST_NODE_TYPES74.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
17732
18062
|
});
|
|
17733
18063
|
var subtreeHas = (root, found) => {
|
|
17734
18064
|
let hit = false;
|
|
@@ -17755,19 +18085,19 @@ var invokedInstanceField = (call) => {
|
|
|
17755
18085
|
const direct = instanceField(call.callee);
|
|
17756
18086
|
if (direct !== null) return direct;
|
|
17757
18087
|
let callee = call.callee;
|
|
17758
|
-
while (callee.type ===
|
|
17759
|
-
return callee.type ===
|
|
18088
|
+
while (callee.type === AST_NODE_TYPES74.ChainExpression || callee.type === AST_NODE_TYPES74.TSAsExpression || callee.type === AST_NODE_TYPES74.TSNonNullExpression || callee.type === AST_NODE_TYPES74.TSSatisfiesExpression || callee.type === AST_NODE_TYPES74.TSTypeAssertion) callee = callee.expression;
|
|
18089
|
+
return callee.type === AST_NODE_TYPES74.MemberExpression ? instanceField(callee.object) : null;
|
|
17760
18090
|
};
|
|
17761
18091
|
var instanceField = (candidate2) => {
|
|
17762
18092
|
let node = candidate2;
|
|
17763
|
-
while (node.type ===
|
|
17764
|
-
return node.type ===
|
|
18093
|
+
while (node.type === AST_NODE_TYPES74.ChainExpression || node.type === AST_NODE_TYPES74.TSAsExpression || node.type === AST_NODE_TYPES74.TSNonNullExpression || node.type === AST_NODE_TYPES74.TSSatisfiesExpression || node.type === AST_NODE_TYPES74.TSTypeAssertion) node = node.expression;
|
|
18094
|
+
return node.type === AST_NODE_TYPES74.MemberExpression && node.object.type === AST_NODE_TYPES74.ThisExpression ? staticMemberName6(node) : null;
|
|
17765
18095
|
};
|
|
17766
18096
|
var behaviorallyInvokedFields = (body2) => {
|
|
17767
18097
|
const invoked = /* @__PURE__ */ new Set();
|
|
17768
18098
|
const visit = (current) => {
|
|
17769
|
-
if (current.type ===
|
|
17770
|
-
if (current.type ===
|
|
18099
|
+
if (current.type === AST_NODE_TYPES74.ClassDeclaration || current.type === AST_NODE_TYPES74.ClassExpression || current.type === AST_NODE_TYPES74.FunctionDeclaration || current.type === AST_NODE_TYPES74.FunctionExpression) return;
|
|
18100
|
+
if (current.type === AST_NODE_TYPES74.CallExpression) {
|
|
17771
18101
|
const field = invokedInstanceField(current);
|
|
17772
18102
|
if (field !== null) invoked.add(field);
|
|
17773
18103
|
}
|
|
@@ -17780,14 +18110,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
17780
18110
|
}
|
|
17781
18111
|
};
|
|
17782
18112
|
for (const member of body2.body) {
|
|
17783
|
-
if (member.type ===
|
|
17784
|
-
if (member.type ===
|
|
18113
|
+
if (member.type === AST_NODE_TYPES74.StaticBlock || member.static) continue;
|
|
18114
|
+
if (member.type === AST_NODE_TYPES74.MethodDefinition) {
|
|
17785
18115
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
17786
18116
|
continue;
|
|
17787
18117
|
}
|
|
17788
|
-
if (member.type !==
|
|
18118
|
+
if (member.type !== AST_NODE_TYPES74.PropertyDefinition || member.value === null) continue;
|
|
17789
18119
|
visit(
|
|
17790
|
-
member.value.type ===
|
|
18120
|
+
member.value.type === AST_NODE_TYPES74.ArrowFunctionExpression ? member.value.body : member.value
|
|
17791
18121
|
);
|
|
17792
18122
|
}
|
|
17793
18123
|
return invoked;
|
|
@@ -17807,25 +18137,25 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
17807
18137
|
var fileInterfaceNames = (program) => {
|
|
17808
18138
|
const names = [];
|
|
17809
18139
|
for (const statement of program.body) {
|
|
17810
|
-
const declaration = statement.type ===
|
|
17811
|
-
if (declaration?.type ===
|
|
18140
|
+
const declaration = statement.type === AST_NODE_TYPES74.ExportNamedDeclaration ? statement.declaration : statement;
|
|
18141
|
+
if (declaration?.type === AST_NODE_TYPES74.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
17812
18142
|
}
|
|
17813
18143
|
return names;
|
|
17814
18144
|
};
|
|
17815
18145
|
var publicMethodNames = (body2, functionAliases) => {
|
|
17816
18146
|
const names = [];
|
|
17817
18147
|
for (const member of body2.body) {
|
|
17818
|
-
if (member.type ===
|
|
18148
|
+
if (member.type === AST_NODE_TYPES74.PropertyDefinition) {
|
|
17819
18149
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
17820
|
-
if (member.key.type ===
|
|
17821
|
-
if (member.value?.type !==
|
|
18150
|
+
if (member.key.type === AST_NODE_TYPES74.PrivateIdentifier) continue;
|
|
18151
|
+
if (member.value?.type !== AST_NODE_TYPES74.ArrowFunctionExpression && member.value?.type !== AST_NODE_TYPES74.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES74.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES74.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === AST_NODE_TYPES74.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
17822
18152
|
names.push(declaredMemberName(member) ?? "\u2026");
|
|
17823
18153
|
continue;
|
|
17824
18154
|
}
|
|
17825
|
-
if (member.type !==
|
|
18155
|
+
if (member.type !== AST_NODE_TYPES74.MethodDefinition) continue;
|
|
17826
18156
|
if (member.kind !== "method" || member.static) continue;
|
|
17827
18157
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
17828
|
-
if (member.key.type ===
|
|
18158
|
+
if (member.key.type === AST_NODE_TYPES74.PrivateIdentifier) continue;
|
|
17829
18159
|
names.push(declaredMemberName(member) ?? "\u2026");
|
|
17830
18160
|
}
|
|
17831
18161
|
return names;
|
|
@@ -17833,13 +18163,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
17833
18163
|
var isFluentConstructionObject = (node, getText) => {
|
|
17834
18164
|
if (node.id === null) return false;
|
|
17835
18165
|
const methods = node.body.body.filter(
|
|
17836
|
-
(member) => member.type ===
|
|
18166
|
+
(member) => member.type === AST_NODE_TYPES74.MethodDefinition && member.kind === "method" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.value.body !== null
|
|
17837
18167
|
);
|
|
17838
18168
|
if (methods.length === 0) return false;
|
|
17839
18169
|
return methods.every((member) => {
|
|
17840
18170
|
const result = member.value.returnType?.typeAnnotation;
|
|
17841
18171
|
if (result === void 0) return false;
|
|
17842
|
-
const returnsOwnType = result.type ===
|
|
18172
|
+
const returnsOwnType = result.type === AST_NODE_TYPES74.TSTypeReference && result.typeName.type === AST_NODE_TYPES74.Identifier && result.typeName.name === node.id?.name;
|
|
17843
18173
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
17844
18174
|
});
|
|
17845
18175
|
};
|
|
@@ -17847,10 +18177,10 @@ function localClassAbstractness(program) {
|
|
|
17847
18177
|
const classes = /* @__PURE__ */ new Map();
|
|
17848
18178
|
const parents = /* @__PURE__ */ new Map();
|
|
17849
18179
|
for (const statement of program.body) {
|
|
17850
|
-
const declaration = statement.type ===
|
|
17851
|
-
if (declaration?.type ===
|
|
18180
|
+
const declaration = statement.type === AST_NODE_TYPES74.ExportNamedDeclaration || statement.type === AST_NODE_TYPES74.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
18181
|
+
if (declaration?.type === AST_NODE_TYPES74.ClassDeclaration && declaration.id !== null) {
|
|
17852
18182
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
17853
|
-
if (declaration.superClass?.type ===
|
|
18183
|
+
if (declaration.superClass?.type === AST_NODE_TYPES74.Identifier) {
|
|
17854
18184
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
17855
18185
|
}
|
|
17856
18186
|
}
|
|
@@ -17868,8 +18198,8 @@ function localClassAbstractness(program) {
|
|
|
17868
18198
|
return classes;
|
|
17869
18199
|
}
|
|
17870
18200
|
function declaredMemberName(member) {
|
|
17871
|
-
if (!member.computed && member.key.type ===
|
|
17872
|
-
if (member.key.type ===
|
|
18201
|
+
if (!member.computed && member.key.type === AST_NODE_TYPES74.Identifier) return member.key.name;
|
|
18202
|
+
if (member.key.type === AST_NODE_TYPES74.Literal && typeof member.key.value === "string") return member.key.value;
|
|
17873
18203
|
return null;
|
|
17874
18204
|
}
|
|
17875
18205
|
function localInterfaceSurfaces(program) {
|
|
@@ -17877,45 +18207,45 @@ function localInterfaceSurfaces(program) {
|
|
|
17877
18207
|
const parents = /* @__PURE__ */ new Map();
|
|
17878
18208
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
17879
18209
|
for (const statement of program.body) {
|
|
17880
|
-
const declaration = statement.type ===
|
|
17881
|
-
if (declaration?.type ===
|
|
18210
|
+
const declaration = statement.type === AST_NODE_TYPES74.ExportNamedDeclaration ? statement.declaration : statement;
|
|
18211
|
+
if (declaration?.type === AST_NODE_TYPES74.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === AST_NODE_TYPES74.TSFunctionType || declaration.typeAnnotation.type === AST_NODE_TYPES74.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
17882
18212
|
}
|
|
17883
18213
|
for (const statement of program.body) {
|
|
17884
|
-
const declaration = statement.type ===
|
|
17885
|
-
if (declaration?.type ===
|
|
18214
|
+
const declaration = statement.type === AST_NODE_TYPES74.ExportNamedDeclaration ? statement.declaration : statement;
|
|
18215
|
+
if (declaration?.type === AST_NODE_TYPES74.TSTypeAliasDeclaration) {
|
|
17886
18216
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
17887
|
-
const parts = declaration.typeAnnotation.type ===
|
|
18217
|
+
const parts = declaration.typeAnnotation.type === AST_NODE_TYPES74.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
17888
18218
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
17889
18219
|
for (const part of parts) {
|
|
17890
|
-
if (part.type ===
|
|
18220
|
+
if (part.type === AST_NODE_TYPES74.TSTypeReference && part.typeName.type === AST_NODE_TYPES74.Identifier) {
|
|
17891
18221
|
inherited.push(part.typeName.name);
|
|
17892
18222
|
continue;
|
|
17893
18223
|
}
|
|
17894
|
-
if (part.type !==
|
|
18224
|
+
if (part.type !== AST_NODE_TYPES74.TSTypeLiteral) continue;
|
|
17895
18225
|
for (const member of part.members) {
|
|
17896
|
-
if (member.type !==
|
|
18226
|
+
if (member.type !== AST_NODE_TYPES74.TSMethodSignature && member.type !== AST_NODE_TYPES74.TSPropertySignature) continue;
|
|
17897
18227
|
const name = declaredMemberName(member);
|
|
17898
18228
|
if (name === null) continue;
|
|
17899
|
-
if (member.type ===
|
|
18229
|
+
if (member.type === AST_NODE_TYPES74.TSMethodSignature) {
|
|
17900
18230
|
callables2.add(name);
|
|
17901
18231
|
continue;
|
|
17902
18232
|
}
|
|
17903
|
-
if (member.type !==
|
|
18233
|
+
if (member.type !== AST_NODE_TYPES74.TSPropertySignature) continue;
|
|
17904
18234
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
17905
|
-
if (annotation?.type ===
|
|
18235
|
+
if (annotation?.type === AST_NODE_TYPES74.TSFunctionType || annotation?.type === AST_NODE_TYPES74.TSTypeReference && annotation.typeName.type === AST_NODE_TYPES74.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(name);
|
|
17906
18236
|
}
|
|
17907
18237
|
}
|
|
17908
18238
|
interfaces.set(declaration.id.name, callables2);
|
|
17909
18239
|
parents.set(declaration.id.name, inherited);
|
|
17910
18240
|
continue;
|
|
17911
18241
|
}
|
|
17912
|
-
if (declaration?.type !==
|
|
18242
|
+
if (declaration?.type !== AST_NODE_TYPES74.TSInterfaceDeclaration) continue;
|
|
17913
18243
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
17914
18244
|
for (const member of declaration.body.body) {
|
|
17915
|
-
if (member.type !==
|
|
18245
|
+
if (member.type !== AST_NODE_TYPES74.TSMethodSignature && member.type !== AST_NODE_TYPES74.TSPropertySignature) continue;
|
|
17916
18246
|
const name = declaredMemberName(member);
|
|
17917
18247
|
if (name === null) continue;
|
|
17918
|
-
if (member.type ===
|
|
18248
|
+
if (member.type === AST_NODE_TYPES74.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES74.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES74.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === AST_NODE_TYPES74.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(name);
|
|
17919
18249
|
}
|
|
17920
18250
|
interfaces.set(declaration.id.name, callables);
|
|
17921
18251
|
parents.set(
|
|
@@ -17923,7 +18253,7 @@ function localInterfaceSurfaces(program) {
|
|
|
17923
18253
|
[
|
|
17924
18254
|
...parents.get(declaration.id.name) ?? [],
|
|
17925
18255
|
...declaration.extends.flatMap(
|
|
17926
|
-
(heritage) => heritage.expression.type ===
|
|
18256
|
+
(heritage) => heritage.expression.type === AST_NODE_TYPES74.Identifier ? [heritage.expression.name] : ["*"]
|
|
17927
18257
|
)
|
|
17928
18258
|
]
|
|
17929
18259
|
);
|
|
@@ -17950,7 +18280,7 @@ function localInterfaceSurfaces(program) {
|
|
|
17950
18280
|
}
|
|
17951
18281
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
17952
18282
|
if (node.superClass !== null) {
|
|
17953
|
-
if (node.superClass.type !==
|
|
18283
|
+
if (node.superClass.type !== AST_NODE_TYPES74.Identifier) return true;
|
|
17954
18284
|
const localAbstract = classes.get(node.superClass.name);
|
|
17955
18285
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
17956
18286
|
}
|
|
@@ -17962,7 +18292,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
17962
18292
|
if (node.implements.length === 0) return false;
|
|
17963
18293
|
const combined = /* @__PURE__ */ new Set();
|
|
17964
18294
|
for (const implementation of node.implements) {
|
|
17965
|
-
if (implementation.expression.type !==
|
|
18295
|
+
if (implementation.expression.type !== AST_NODE_TYPES74.Identifier) return true;
|
|
17966
18296
|
const name = implementation.expression.name;
|
|
17967
18297
|
const localAbstract = classes.get(name);
|
|
17968
18298
|
if (localAbstract === true) return true;
|
|
@@ -18005,7 +18335,7 @@ var require_port_for_service_default = createRule({
|
|
|
18005
18335
|
if (node.abstract === true) return;
|
|
18006
18336
|
if (node.decorators.length > 0) return;
|
|
18007
18337
|
const ctor = node.body.body.find(
|
|
18008
|
-
(member) => member.type ===
|
|
18338
|
+
(member) => member.type === AST_NODE_TYPES74.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
18009
18339
|
);
|
|
18010
18340
|
if (ctor === void 0) return;
|
|
18011
18341
|
const constructorFacts = readConstructor(
|
|
@@ -18040,7 +18370,7 @@ var require_port_for_service_default = createRule({
|
|
|
18040
18370
|
});
|
|
18041
18371
|
|
|
18042
18372
|
// src/rules/require-sql-access-class.ts
|
|
18043
|
-
import { AST_NODE_TYPES as
|
|
18373
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES75, ASTUtils as ASTUtils41 } from "@typescript-eslint/utils";
|
|
18044
18374
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
18045
18375
|
"all",
|
|
18046
18376
|
"batch",
|
|
@@ -18135,9 +18465,9 @@ var REQUIRE_SQL_ACCESS_CLASS_DOCUMENTATION = {
|
|
|
18135
18465
|
]
|
|
18136
18466
|
};
|
|
18137
18467
|
function memberName6(node) {
|
|
18138
|
-
if (!node.computed && node.property.type ===
|
|
18468
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES75.Identifier)
|
|
18139
18469
|
return node.property.name;
|
|
18140
|
-
if (node.computed && node.property.type ===
|
|
18470
|
+
if (node.computed && node.property.type === AST_NODE_TYPES75.Literal && typeof node.property.value === "string")
|
|
18141
18471
|
return node.property.value;
|
|
18142
18472
|
return null;
|
|
18143
18473
|
}
|
|
@@ -18149,89 +18479,89 @@ function isDatabaseOperation(method, receiver) {
|
|
|
18149
18479
|
return BUILDER_SHORT_TERMINALS.has(method) && expressionCallsBuilder(receiver);
|
|
18150
18480
|
}
|
|
18151
18481
|
function databaseReceiver(node) {
|
|
18152
|
-
if (node.type ===
|
|
18482
|
+
if (node.type === AST_NODE_TYPES75.Identifier)
|
|
18153
18483
|
return DATABASE_NAMES.test(node.name);
|
|
18154
|
-
if (node.type !==
|
|
18484
|
+
if (node.type !== AST_NODE_TYPES75.MemberExpression) return false;
|
|
18155
18485
|
const name = memberName6(node);
|
|
18156
18486
|
return name === "DB" || name !== null && DATABASE_NAMES.test(name);
|
|
18157
18487
|
}
|
|
18158
18488
|
function databaseRootMember(node) {
|
|
18159
18489
|
let current = node;
|
|
18160
18490
|
for (; ; ) {
|
|
18161
|
-
if (current.type ===
|
|
18491
|
+
if (current.type === AST_NODE_TYPES75.ChainExpression) {
|
|
18162
18492
|
current = current.expression;
|
|
18163
18493
|
continue;
|
|
18164
18494
|
}
|
|
18165
|
-
if (current.type ===
|
|
18495
|
+
if (current.type === AST_NODE_TYPES75.TSAsExpression || current.type === AST_NODE_TYPES75.TSNonNullExpression || current.type === AST_NODE_TYPES75.TSTypeAssertion) {
|
|
18166
18496
|
current = current.expression;
|
|
18167
18497
|
continue;
|
|
18168
18498
|
}
|
|
18169
|
-
if (current.type ===
|
|
18170
|
-
if (current.callee.type !==
|
|
18499
|
+
if (current.type === AST_NODE_TYPES75.CallExpression) {
|
|
18500
|
+
if (current.callee.type !== AST_NODE_TYPES75.MemberExpression) return null;
|
|
18171
18501
|
current = current.callee.object;
|
|
18172
18502
|
continue;
|
|
18173
18503
|
}
|
|
18174
|
-
if (current.type ===
|
|
18175
|
-
if (current.object.type ===
|
|
18504
|
+
if (current.type === AST_NODE_TYPES75.MemberExpression) {
|
|
18505
|
+
if (current.object.type === AST_NODE_TYPES75.ThisExpression)
|
|
18176
18506
|
return memberName6(current);
|
|
18177
18507
|
current = current.object;
|
|
18178
18508
|
continue;
|
|
18179
18509
|
}
|
|
18180
|
-
return current.type ===
|
|
18510
|
+
return current.type === AST_NODE_TYPES75.Identifier ? current.name : null;
|
|
18181
18511
|
}
|
|
18182
18512
|
}
|
|
18183
18513
|
function expressionHasDatabaseMarker(node) {
|
|
18184
18514
|
let current = node;
|
|
18185
18515
|
for (; ; ) {
|
|
18186
|
-
if (current.type ===
|
|
18516
|
+
if (current.type === AST_NODE_TYPES75.ChainExpression) {
|
|
18187
18517
|
current = current.expression;
|
|
18188
18518
|
continue;
|
|
18189
18519
|
}
|
|
18190
|
-
if (current.type ===
|
|
18520
|
+
if (current.type === AST_NODE_TYPES75.TSAsExpression || current.type === AST_NODE_TYPES75.TSNonNullExpression || current.type === AST_NODE_TYPES75.TSTypeAssertion) {
|
|
18191
18521
|
current = current.expression;
|
|
18192
18522
|
continue;
|
|
18193
18523
|
}
|
|
18194
|
-
if (current.type ===
|
|
18195
|
-
if (current.callee.type !==
|
|
18524
|
+
if (current.type === AST_NODE_TYPES75.CallExpression) {
|
|
18525
|
+
if (current.callee.type !== AST_NODE_TYPES75.MemberExpression) return false;
|
|
18196
18526
|
current = current.callee.object;
|
|
18197
18527
|
continue;
|
|
18198
18528
|
}
|
|
18199
|
-
if (current.type ===
|
|
18529
|
+
if (current.type === AST_NODE_TYPES75.MemberExpression) {
|
|
18200
18530
|
const name = memberName6(current);
|
|
18201
18531
|
if (name === "DB" || name !== null && DATABASE_NAMES.test(name))
|
|
18202
18532
|
return true;
|
|
18203
18533
|
current = current.object;
|
|
18204
18534
|
continue;
|
|
18205
18535
|
}
|
|
18206
|
-
return current.type ===
|
|
18536
|
+
return current.type === AST_NODE_TYPES75.Identifier && DATABASE_NAMES.test(current.name);
|
|
18207
18537
|
}
|
|
18208
18538
|
}
|
|
18209
18539
|
function expressionCallsBuilder(node) {
|
|
18210
18540
|
let current = node;
|
|
18211
18541
|
for (; ; ) {
|
|
18212
|
-
if (current.type ===
|
|
18542
|
+
if (current.type === AST_NODE_TYPES75.ChainExpression) {
|
|
18213
18543
|
current = current.expression;
|
|
18214
18544
|
continue;
|
|
18215
18545
|
}
|
|
18216
|
-
if (current.type ===
|
|
18546
|
+
if (current.type === AST_NODE_TYPES75.TSAsExpression || current.type === AST_NODE_TYPES75.TSNonNullExpression || current.type === AST_NODE_TYPES75.TSTypeAssertion) {
|
|
18217
18547
|
current = current.expression;
|
|
18218
18548
|
continue;
|
|
18219
18549
|
}
|
|
18220
|
-
if (current.type ===
|
|
18221
|
-
if (current.callee.type !==
|
|
18550
|
+
if (current.type === AST_NODE_TYPES75.CallExpression) {
|
|
18551
|
+
if (current.callee.type !== AST_NODE_TYPES75.MemberExpression) return false;
|
|
18222
18552
|
const name = memberName6(current.callee);
|
|
18223
18553
|
if (name !== null && BUILDER_METHODS.has(name)) return true;
|
|
18224
18554
|
current = current.callee.object;
|
|
18225
18555
|
continue;
|
|
18226
18556
|
}
|
|
18227
|
-
if (current.type !==
|
|
18557
|
+
if (current.type !== AST_NODE_TYPES75.MemberExpression) return false;
|
|
18228
18558
|
current = current.object;
|
|
18229
18559
|
}
|
|
18230
18560
|
}
|
|
18231
18561
|
function owningClass2(node) {
|
|
18232
18562
|
let current = node.parent;
|
|
18233
18563
|
while (current != null) {
|
|
18234
|
-
if (current.type ===
|
|
18564
|
+
if (current.type === AST_NODE_TYPES75.ClassDeclaration || current.type === AST_NODE_TYPES75.ClassExpression)
|
|
18235
18565
|
return current;
|
|
18236
18566
|
current = current.parent;
|
|
18237
18567
|
}
|
|
@@ -18240,25 +18570,25 @@ function owningClass2(node) {
|
|
|
18240
18570
|
function injectedMembers(owner) {
|
|
18241
18571
|
const injected = /* @__PURE__ */ new Set();
|
|
18242
18572
|
const constructor = owner.body.body.find(
|
|
18243
|
-
(member) => member.type ===
|
|
18573
|
+
(member) => member.type === AST_NODE_TYPES75.MethodDefinition && member.kind === "constructor"
|
|
18244
18574
|
);
|
|
18245
18575
|
if (constructor === void 0) return injected;
|
|
18246
18576
|
const parameters = /* @__PURE__ */ new Set();
|
|
18247
18577
|
for (const parameter of constructor.value.params) {
|
|
18248
18578
|
for (const name of parameterNames(parameter)) parameters.add(name);
|
|
18249
|
-
if (parameter.type !==
|
|
18250
|
-
const value = parameter.parameter.type ===
|
|
18251
|
-
if (value.type ===
|
|
18579
|
+
if (parameter.type !== AST_NODE_TYPES75.TSParameterProperty) continue;
|
|
18580
|
+
const value = parameter.parameter.type === AST_NODE_TYPES75.AssignmentPattern ? parameter.parameter.left : parameter.parameter;
|
|
18581
|
+
if (value.type === AST_NODE_TYPES75.Identifier) injected.add(value.name);
|
|
18252
18582
|
}
|
|
18253
18583
|
const body2 = constructor.value.body;
|
|
18254
18584
|
if (body2 === null) return injected;
|
|
18255
18585
|
for (const statement of body2.body) {
|
|
18256
|
-
if (statement.type !==
|
|
18586
|
+
if (statement.type !== AST_NODE_TYPES75.ExpressionStatement || statement.expression.type !== AST_NODE_TYPES75.AssignmentExpression || statement.expression.operator !== "=") continue;
|
|
18257
18587
|
const { left, right } = statement.expression;
|
|
18258
|
-
if (left.type !==
|
|
18588
|
+
if (left.type !== AST_NODE_TYPES75.MemberExpression) continue;
|
|
18259
18589
|
const target = thisRootMember(left);
|
|
18260
18590
|
if (target === null) continue;
|
|
18261
|
-
const source = right.type ===
|
|
18591
|
+
const source = right.type === AST_NODE_TYPES75.Identifier ? right.name : right.type === AST_NODE_TYPES75.MemberExpression && right.object.type === AST_NODE_TYPES75.Identifier ? right.object.name : null;
|
|
18262
18592
|
if (source !== null && parameters.has(source)) injected.add(target);
|
|
18263
18593
|
}
|
|
18264
18594
|
return injected;
|
|
@@ -18266,26 +18596,26 @@ function injectedMembers(owner) {
|
|
|
18266
18596
|
function thisRootMember(node) {
|
|
18267
18597
|
let current = node;
|
|
18268
18598
|
let root = null;
|
|
18269
|
-
while (current.type ===
|
|
18599
|
+
while (current.type === AST_NODE_TYPES75.MemberExpression) {
|
|
18270
18600
|
const name = memberName6(current);
|
|
18271
18601
|
if (name === null) return null;
|
|
18272
18602
|
root = name;
|
|
18273
18603
|
current = current.object;
|
|
18274
18604
|
}
|
|
18275
|
-
return current.type ===
|
|
18605
|
+
return current.type === AST_NODE_TYPES75.ThisExpression ? root : null;
|
|
18276
18606
|
}
|
|
18277
18607
|
function parameterNames(parameter) {
|
|
18278
18608
|
let value = parameter;
|
|
18279
|
-
if (value.type ===
|
|
18280
|
-
if (value.type ===
|
|
18281
|
-
if (value.type ===
|
|
18282
|
-
if (value.type !==
|
|
18609
|
+
if (value.type === AST_NODE_TYPES75.TSParameterProperty) value = value.parameter;
|
|
18610
|
+
if (value.type === AST_NODE_TYPES75.AssignmentPattern) value = value.left;
|
|
18611
|
+
if (value.type === AST_NODE_TYPES75.Identifier) return /* @__PURE__ */ new Set([value.name]);
|
|
18612
|
+
if (value.type !== AST_NODE_TYPES75.ObjectPattern) return /* @__PURE__ */ new Set();
|
|
18283
18613
|
return new Set(
|
|
18284
18614
|
value.properties.flatMap((property) => {
|
|
18285
|
-
if (property.type ===
|
|
18286
|
-
return property.argument.type ===
|
|
18287
|
-
const target = property.value.type ===
|
|
18288
|
-
return target.type ===
|
|
18615
|
+
if (property.type === AST_NODE_TYPES75.RestElement)
|
|
18616
|
+
return property.argument.type === AST_NODE_TYPES75.Identifier ? [property.argument.name] : [];
|
|
18617
|
+
const target = property.value.type === AST_NODE_TYPES75.AssignmentPattern ? property.value.left : property.value;
|
|
18618
|
+
return target.type === AST_NODE_TYPES75.Identifier ? [target.name] : [];
|
|
18289
18619
|
})
|
|
18290
18620
|
);
|
|
18291
18621
|
}
|
|
@@ -18309,17 +18639,17 @@ var require_sql_access_class_default = createRule({
|
|
|
18309
18639
|
function knownNonDatabase(node, seen = /* @__PURE__ */ new Set()) {
|
|
18310
18640
|
if (seen.has(node)) return false;
|
|
18311
18641
|
seen.add(node);
|
|
18312
|
-
if (node.type ===
|
|
18642
|
+
if (node.type === AST_NODE_TYPES75.Identifier) {
|
|
18313
18643
|
const binding = ASTUtils41.findVariable(context.sourceCode.getScope(node), node.name);
|
|
18314
18644
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
18315
18645
|
const definition = binding.defs[0];
|
|
18316
18646
|
return definition?.type === "Variable" && definition.node.init !== null && knownNonDatabase(definition.node.init, seen);
|
|
18317
18647
|
}
|
|
18318
|
-
return node.type ===
|
|
18648
|
+
return node.type === AST_NODE_TYPES75.NewExpression && node.callee.type === AST_NODE_TYPES75.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(node.callee.name) && (ASTUtils41.findVariable(context.sourceCode.getScope(node.callee), node.callee.name)?.defs.length ?? 0) === 0;
|
|
18319
18649
|
}
|
|
18320
18650
|
return {
|
|
18321
18651
|
CallExpression(node) {
|
|
18322
|
-
if (node.callee.type !==
|
|
18652
|
+
if (node.callee.type !== AST_NODE_TYPES75.MemberExpression)
|
|
18323
18653
|
return;
|
|
18324
18654
|
const method = memberName6(node.callee);
|
|
18325
18655
|
if (knownNonDatabase(node.callee.object)) return;
|
|
@@ -18337,7 +18667,7 @@ var require_sql_access_class_default = createRule({
|
|
|
18337
18667
|
});
|
|
18338
18668
|
|
|
18339
18669
|
// src/rules/require-static-next-matcher.ts
|
|
18340
|
-
import { AST_NODE_TYPES as
|
|
18670
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES76 } from "@typescript-eslint/utils";
|
|
18341
18671
|
var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
18342
18672
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
18343
18673
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -18352,34 +18682,34 @@ var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
|
18352
18682
|
};
|
|
18353
18683
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
18354
18684
|
function unwrapExpression3(node) {
|
|
18355
|
-
if (node.type ===
|
|
18685
|
+
if (node.type === AST_NODE_TYPES76.TSAsExpression || node.type === AST_NODE_TYPES76.TSSatisfiesExpression || node.type === AST_NODE_TYPES76.TSNonNullExpression || node.type === AST_NODE_TYPES76.TSTypeAssertion) {
|
|
18356
18686
|
return unwrapExpression3(node.expression);
|
|
18357
18687
|
}
|
|
18358
18688
|
return node;
|
|
18359
18689
|
}
|
|
18360
18690
|
function isStaticValue(node) {
|
|
18361
18691
|
const value = unwrapExpression3(node);
|
|
18362
|
-
if (value.type ===
|
|
18692
|
+
if (value.type === AST_NODE_TYPES76.Literal) {
|
|
18363
18693
|
return true;
|
|
18364
18694
|
}
|
|
18365
|
-
if (value.type ===
|
|
18695
|
+
if (value.type === AST_NODE_TYPES76.TemplateLiteral) {
|
|
18366
18696
|
return value.expressions.length === 0;
|
|
18367
18697
|
}
|
|
18368
|
-
if (value.type ===
|
|
18698
|
+
if (value.type === AST_NODE_TYPES76.ArrayExpression) {
|
|
18369
18699
|
return value.elements.every(
|
|
18370
|
-
(element) => element !== null && element.type !==
|
|
18700
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES76.SpreadElement && isStaticValue(element)
|
|
18371
18701
|
);
|
|
18372
18702
|
}
|
|
18373
|
-
if (value.type ===
|
|
18703
|
+
if (value.type === AST_NODE_TYPES76.ObjectExpression) {
|
|
18374
18704
|
return value.properties.every(
|
|
18375
|
-
(property) => property.type ===
|
|
18705
|
+
(property) => property.type === AST_NODE_TYPES76.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES76.AssignmentPattern && isStaticValue(property.value)
|
|
18376
18706
|
);
|
|
18377
18707
|
}
|
|
18378
18708
|
return false;
|
|
18379
18709
|
}
|
|
18380
18710
|
function propertyName5(property) {
|
|
18381
18711
|
if (property.computed) return null;
|
|
18382
|
-
if (property.key.type ===
|
|
18712
|
+
if (property.key.type === AST_NODE_TYPES76.Identifier) return property.key.name;
|
|
18383
18713
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
18384
18714
|
}
|
|
18385
18715
|
var require_static_next_matcher_default = createRule({
|
|
@@ -18402,19 +18732,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
18402
18732
|
}
|
|
18403
18733
|
return {
|
|
18404
18734
|
ExportNamedDeclaration(node) {
|
|
18405
|
-
if (node.declaration?.type !==
|
|
18735
|
+
if (node.declaration?.type !== AST_NODE_TYPES76.VariableDeclaration) {
|
|
18406
18736
|
return;
|
|
18407
18737
|
}
|
|
18408
18738
|
for (const declaration of node.declaration.declarations) {
|
|
18409
|
-
if (declaration.id.type !==
|
|
18739
|
+
if (declaration.id.type !== AST_NODE_TYPES76.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
18410
18740
|
continue;
|
|
18411
18741
|
}
|
|
18412
18742
|
const config = unwrapExpression3(declaration.init);
|
|
18413
|
-
if (config.type !==
|
|
18743
|
+
if (config.type !== AST_NODE_TYPES76.ObjectExpression) {
|
|
18414
18744
|
continue;
|
|
18415
18745
|
}
|
|
18416
18746
|
for (const property of config.properties) {
|
|
18417
|
-
if (property.type !==
|
|
18747
|
+
if (property.type !== AST_NODE_TYPES76.Property || propertyName5(property) !== "matcher" || property.value.type === AST_NODE_TYPES76.AssignmentPattern) {
|
|
18418
18748
|
continue;
|
|
18419
18749
|
}
|
|
18420
18750
|
if (!isStaticValue(property.value)) {
|
|
@@ -18566,7 +18896,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
18566
18896
|
|
|
18567
18897
|
// src/rules/require-zod-form-validation.ts
|
|
18568
18898
|
import {
|
|
18569
|
-
AST_NODE_TYPES as
|
|
18899
|
+
AST_NODE_TYPES as AST_NODE_TYPES77,
|
|
18570
18900
|
ASTUtils as ASTUtils43
|
|
18571
18901
|
} from "@typescript-eslint/utils";
|
|
18572
18902
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
@@ -18594,14 +18924,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
18594
18924
|
var zodReceiverRoot = (node) => {
|
|
18595
18925
|
let current = node;
|
|
18596
18926
|
while (true) {
|
|
18597
|
-
if (current.type ===
|
|
18927
|
+
if (current.type === AST_NODE_TYPES77.Identifier) {
|
|
18598
18928
|
return current;
|
|
18599
18929
|
}
|
|
18600
|
-
if (current.type ===
|
|
18930
|
+
if (current.type === AST_NODE_TYPES77.CallExpression) {
|
|
18601
18931
|
current = current.callee;
|
|
18602
18932
|
continue;
|
|
18603
18933
|
}
|
|
18604
|
-
if (current.type ===
|
|
18934
|
+
if (current.type === AST_NODE_TYPES77.MemberExpression) {
|
|
18605
18935
|
current = current.object;
|
|
18606
18936
|
continue;
|
|
18607
18937
|
}
|
|
@@ -18610,12 +18940,12 @@ var zodReceiverRoot = (node) => {
|
|
|
18610
18940
|
};
|
|
18611
18941
|
var isFormDataMethodCall = (node) => {
|
|
18612
18942
|
let current = node;
|
|
18613
|
-
if (current.type ===
|
|
18943
|
+
if (current.type === AST_NODE_TYPES77.AwaitExpression) {
|
|
18614
18944
|
current = current.argument;
|
|
18615
18945
|
}
|
|
18616
|
-
if (current.type !==
|
|
18946
|
+
if (current.type !== AST_NODE_TYPES77.CallExpression) return false;
|
|
18617
18947
|
const callee = current.callee;
|
|
18618
|
-
return callee.type ===
|
|
18948
|
+
return callee.type === AST_NODE_TYPES77.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES77.Identifier && callee.property.name === "formData";
|
|
18619
18949
|
};
|
|
18620
18950
|
var require_zod_form_validation_default = createRule({
|
|
18621
18951
|
name: "require-zod-form-validation",
|
|
@@ -18646,16 +18976,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
18646
18976
|
return false;
|
|
18647
18977
|
}
|
|
18648
18978
|
const definition = binding.defs[0];
|
|
18649
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
18979
|
+
if (definition?.type !== "Variable" || definition.node.type !== AST_NODE_TYPES77.VariableDeclarator) {
|
|
18650
18980
|
return false;
|
|
18651
18981
|
}
|
|
18652
18982
|
const init = definition.node.init;
|
|
18653
|
-
return init?.type ===
|
|
18983
|
+
return init?.type === AST_NODE_TYPES77.ObjectExpression || init?.type === AST_NODE_TYPES77.ArrayExpression || init?.type === AST_NODE_TYPES77.Literal || init?.type === AST_NODE_TYPES77.ArrowFunctionExpression || init?.type === AST_NODE_TYPES77.FunctionExpression;
|
|
18654
18984
|
};
|
|
18655
18985
|
const isZodParseCall = (node) => {
|
|
18656
|
-
if (node.type !==
|
|
18986
|
+
if (node.type !== AST_NODE_TYPES77.CallExpression) return false;
|
|
18657
18987
|
const callee = node.callee;
|
|
18658
|
-
if (callee.type !==
|
|
18988
|
+
if (callee.type !== AST_NODE_TYPES77.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES77.Identifier || !ZOD_PARSE_METHODS.has(callee.property.name)) {
|
|
18659
18989
|
return false;
|
|
18660
18990
|
}
|
|
18661
18991
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -18664,14 +18994,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
18664
18994
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
18665
18995
|
};
|
|
18666
18996
|
const isFormSourceIdentifier = (node) => {
|
|
18667
|
-
if (node.type !==
|
|
18997
|
+
if (node.type !== AST_NODE_TYPES77.Identifier) return false;
|
|
18668
18998
|
const conventionalName = /formdata/i.test(node.name);
|
|
18669
18999
|
let scope = context.sourceCode.getScope(node);
|
|
18670
19000
|
while (scope !== null) {
|
|
18671
19001
|
const variable = scope.set.get(node.name);
|
|
18672
19002
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
18673
19003
|
const def = variable.defs[0];
|
|
18674
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
19004
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES77.VariableDeclarator && def.node.init !== null) {
|
|
18675
19005
|
return isFormDataMethodCall(def.node.init);
|
|
18676
19006
|
}
|
|
18677
19007
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -18682,8 +19012,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
18682
19012
|
};
|
|
18683
19013
|
const isFormDataGetCall = (node) => {
|
|
18684
19014
|
const callee = node.callee;
|
|
18685
|
-
if (callee.type !==
|
|
18686
|
-
if (callee.property.type !==
|
|
19015
|
+
if (callee.type !== AST_NODE_TYPES77.MemberExpression) return false;
|
|
19016
|
+
if (callee.property.type !== AST_NODE_TYPES77.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
18687
19017
|
return false;
|
|
18688
19018
|
}
|
|
18689
19019
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -18692,15 +19022,15 @@ var require_zod_form_validation_default = createRule({
|
|
|
18692
19022
|
let parent = node.parent;
|
|
18693
19023
|
while (parent !== null && parent !== void 0) {
|
|
18694
19024
|
if (isZodParseCall(parent)) return parent;
|
|
18695
|
-
if (parent.type ===
|
|
19025
|
+
if (parent.type === AST_NODE_TYPES77.CallExpression && parent.callee.type === AST_NODE_TYPES77.Identifier && ["Number", "String", "Boolean"].includes(parent.callee.name) && parent.arguments.length === 1 && (resolvedBinding(parent.callee)?.defs.length ?? 0) === 0) {
|
|
18696
19026
|
parent = parent.parent;
|
|
18697
19027
|
continue;
|
|
18698
19028
|
}
|
|
18699
|
-
if (parent.type ===
|
|
19029
|
+
if (parent.type === AST_NODE_TYPES77.CallExpression && parent.callee.type === AST_NODE_TYPES77.MemberExpression && !parent.callee.computed && parent.callee.object.type === AST_NODE_TYPES77.Identifier && parent.callee.object.name === "Object" && parent.callee.property.type === AST_NODE_TYPES77.Identifier && parent.callee.property.name === "fromEntries" && (resolvedBinding(parent.callee.object)?.defs.length ?? 0) === 0) {
|
|
18700
19030
|
parent = parent.parent;
|
|
18701
19031
|
continue;
|
|
18702
19032
|
}
|
|
18703
|
-
if (parent.type ===
|
|
19033
|
+
if (parent.type === AST_NODE_TYPES77.CallExpression || parent.type === AST_NODE_TYPES77.NewExpression || parent.type === AST_NODE_TYPES77.TaggedTemplateExpression || parent.type === AST_NODE_TYPES77.ArrowFunctionExpression || parent.type === AST_NODE_TYPES77.FunctionExpression || parent.type === AST_NODE_TYPES77.FunctionDeclaration) return null;
|
|
18704
19034
|
parent = parent.parent;
|
|
18705
19035
|
}
|
|
18706
19036
|
return null;
|
|
@@ -18708,16 +19038,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
18708
19038
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
18709
19039
|
const isInstanceofNarrowing = (node) => {
|
|
18710
19040
|
const parent = node.parent;
|
|
18711
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
19041
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES77.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES77.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
18712
19042
|
};
|
|
18713
19043
|
const boundDeclarator = (node) => {
|
|
18714
19044
|
let current = node;
|
|
18715
19045
|
let parent = current.parent;
|
|
18716
|
-
while ((parent.type ===
|
|
19046
|
+
while ((parent.type === AST_NODE_TYPES77.TSAsExpression || parent.type === AST_NODE_TYPES77.TSSatisfiesExpression || parent.type === AST_NODE_TYPES77.TSNonNullExpression || parent.type === AST_NODE_TYPES77.ChainExpression) && parent.expression === current) {
|
|
18717
19047
|
current = parent;
|
|
18718
19048
|
parent = current.parent;
|
|
18719
19049
|
}
|
|
18720
|
-
if (parent.type ===
|
|
19050
|
+
if (parent.type === AST_NODE_TYPES77.VariableDeclarator && parent.init === current && parent.id.type === AST_NODE_TYPES77.Identifier) {
|
|
18721
19051
|
return parent;
|
|
18722
19052
|
}
|
|
18723
19053
|
return null;
|
|
@@ -18726,7 +19056,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
18726
19056
|
let current = node;
|
|
18727
19057
|
while (current.parent !== void 0) {
|
|
18728
19058
|
const parent = current.parent;
|
|
18729
|
-
if (parent.type ===
|
|
19059
|
+
if (parent.type === AST_NODE_TYPES77.BlockStatement || parent.type === AST_NODE_TYPES77.Program) {
|
|
18730
19060
|
return current;
|
|
18731
19061
|
}
|
|
18732
19062
|
current = parent;
|
|
@@ -18735,12 +19065,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
18735
19065
|
};
|
|
18736
19066
|
const zodParseMethod = (call) => {
|
|
18737
19067
|
const callee = call.callee;
|
|
18738
|
-
return callee.type ===
|
|
19068
|
+
return callee.type === AST_NODE_TYPES77.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES77.Identifier ? callee.property.name : null;
|
|
18739
19069
|
};
|
|
18740
19070
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
18741
19071
|
let current = node.parent;
|
|
18742
19072
|
while (current !== void 0 && current !== statement) {
|
|
18743
|
-
if (current.type ===
|
|
19073
|
+
if (current.type === AST_NODE_TYPES77.LogicalExpression || current.type === AST_NODE_TYPES77.ConditionalExpression) {
|
|
18744
19074
|
return true;
|
|
18745
19075
|
}
|
|
18746
19076
|
current = current.parent;
|
|
@@ -18750,7 +19080,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
18750
19080
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
18751
19081
|
let current = node.parent;
|
|
18752
19082
|
while (current !== void 0 && current !== statement) {
|
|
18753
|
-
if (current.type ===
|
|
19083
|
+
if (current.type === AST_NODE_TYPES77.AwaitExpression) return true;
|
|
18754
19084
|
current = current.parent;
|
|
18755
19085
|
}
|
|
18756
19086
|
return false;
|
|
@@ -18763,7 +19093,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
18763
19093
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
18764
19094
|
return null;
|
|
18765
19095
|
}
|
|
18766
|
-
if (validationStatement.type !==
|
|
19096
|
+
if (validationStatement.type !== AST_NODE_TYPES77.VariableDeclaration && validationStatement.type !== AST_NODE_TYPES77.ExpressionStatement) {
|
|
18767
19097
|
return null;
|
|
18768
19098
|
}
|
|
18769
19099
|
const method = zodParseMethod(parse2);
|
|
@@ -18775,16 +19105,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
18775
19105
|
};
|
|
18776
19106
|
const isSafePrevalidationInspection = (identifier) => {
|
|
18777
19107
|
const parent = identifier.parent;
|
|
18778
|
-
if (parent.type ===
|
|
19108
|
+
if (parent.type === AST_NODE_TYPES77.UnaryExpression && parent.operator === "typeof") {
|
|
18779
19109
|
return true;
|
|
18780
19110
|
}
|
|
18781
|
-
if (parent.type !==
|
|
19111
|
+
if (parent.type !== AST_NODE_TYPES77.BinaryExpression || parent.left !== identifier) {
|
|
18782
19112
|
return false;
|
|
18783
19113
|
}
|
|
18784
19114
|
if (parent.operator === "instanceof") {
|
|
18785
|
-
return parent.right.type ===
|
|
19115
|
+
return parent.right.type === AST_NODE_TYPES77.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
18786
19116
|
}
|
|
18787
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
19117
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === AST_NODE_TYPES77.Literal && parent.right.value === null || parent.right.type === AST_NODE_TYPES77.Identifier && parent.right.name === "undefined");
|
|
18788
19118
|
};
|
|
18789
19119
|
const isDescendantOf = (node, ancestor) => {
|
|
18790
19120
|
let current = node;
|
|
@@ -18795,23 +19125,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
18795
19125
|
return false;
|
|
18796
19126
|
};
|
|
18797
19127
|
const blockTerminates = (node) => {
|
|
18798
|
-
if (node.type ===
|
|
19128
|
+
if (node.type === AST_NODE_TYPES77.ReturnStatement || node.type === AST_NODE_TYPES77.ThrowStatement) {
|
|
18799
19129
|
return true;
|
|
18800
19130
|
}
|
|
18801
|
-
if (node.type !==
|
|
19131
|
+
if (node.type !== AST_NODE_TYPES77.BlockStatement || node.body.length === 0) return false;
|
|
18802
19132
|
const last = node.body.at(-1);
|
|
18803
19133
|
return last !== void 0 && blockTerminates(last);
|
|
18804
19134
|
};
|
|
18805
19135
|
const narrowingIf = (identifier) => {
|
|
18806
19136
|
const comparison = identifier.parent;
|
|
18807
|
-
if (comparison?.type !==
|
|
19137
|
+
if (comparison?.type !== AST_NODE_TYPES77.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== AST_NODE_TYPES77.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
18808
19138
|
return null;
|
|
18809
19139
|
}
|
|
18810
19140
|
const maybeNegation = comparison.parent;
|
|
18811
|
-
const negated = maybeNegation?.type ===
|
|
19141
|
+
const negated = maybeNegation?.type === AST_NODE_TYPES77.UnaryExpression && maybeNegation.operator === "!";
|
|
18812
19142
|
const test = negated ? maybeNegation : comparison;
|
|
18813
19143
|
const branch = test.parent;
|
|
18814
|
-
return branch?.type ===
|
|
19144
|
+
return branch?.type === AST_NODE_TYPES77.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
18815
19145
|
};
|
|
18816
19146
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
18817
19147
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -18831,7 +19161,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
18831
19161
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
18832
19162
|
if (variable === void 0) return false;
|
|
18833
19163
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
18834
|
-
(identifier) => identifier.type ===
|
|
19164
|
+
(identifier) => identifier.type === AST_NODE_TYPES77.Identifier
|
|
18835
19165
|
);
|
|
18836
19166
|
if (references.length === 0) return false;
|
|
18837
19167
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -18857,7 +19187,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
18857
19187
|
ImportDeclaration(node) {
|
|
18858
19188
|
if (!isZodModule(node.source.value)) return;
|
|
18859
19189
|
for (const specifier of node.specifiers) {
|
|
18860
|
-
if (specifier.type ===
|
|
19190
|
+
if (specifier.type === AST_NODE_TYPES77.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES77.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES77.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES77.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
18861
19191
|
const binding = resolvedBinding(specifier.local);
|
|
18862
19192
|
if (binding !== null) zodBindings.add(binding);
|
|
18863
19193
|
}
|
|
@@ -18947,7 +19277,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
18947
19277
|
});
|
|
18948
19278
|
|
|
18949
19279
|
// src/rules/stepdown.ts
|
|
18950
|
-
import { AST_NODE_TYPES as
|
|
19280
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES78, ASTUtils as ASTUtils44 } from "@typescript-eslint/utils";
|
|
18951
19281
|
var STEPDOWN_DOCUMENTATION = {
|
|
18952
19282
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
18953
19283
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -18965,7 +19295,7 @@ var STEPDOWN_DOCUMENTATION = {
|
|
|
18965
19295
|
]
|
|
18966
19296
|
};
|
|
18967
19297
|
function isFunction(node) {
|
|
18968
|
-
return node.type ===
|
|
19298
|
+
return node.type === AST_NODE_TYPES78.ArrowFunctionExpression || node.type === AST_NODE_TYPES78.FunctionDeclaration || node.type === AST_NODE_TYPES78.FunctionExpression;
|
|
18969
19299
|
}
|
|
18970
19300
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true) {
|
|
18971
19301
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -19060,8 +19390,8 @@ function moduleScope(context, program) {
|
|
|
19060
19390
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
19061
19391
|
const overloadNames = new Set(
|
|
19062
19392
|
program.body.flatMap((statement) => {
|
|
19063
|
-
const node = statement.type ===
|
|
19064
|
-
return node?.type ===
|
|
19393
|
+
const node = statement.type === AST_NODE_TYPES78.ExportNamedDeclaration ? statement.declaration : statement;
|
|
19394
|
+
return node?.type === AST_NODE_TYPES78.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
19065
19395
|
})
|
|
19066
19396
|
);
|
|
19067
19397
|
const exported = exportedNames(program);
|
|
@@ -19085,7 +19415,7 @@ function moduleScope(context, program) {
|
|
|
19085
19415
|
const nearestFunction2 = [...ancestors].reverse().find(isFunction);
|
|
19086
19416
|
const parent = identifier.parent;
|
|
19087
19417
|
const callerDefinition = nearestFunction2 === void 0 ? void 0 : byFunction.get(nearestFunction2);
|
|
19088
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
19418
|
+
if (callerDefinition === void 0 || parent.type !== AST_NODE_TYPES78.CallExpression || parent.callee !== identifier) {
|
|
19089
19419
|
pinned.add(definition.name);
|
|
19090
19420
|
continue;
|
|
19091
19421
|
}
|
|
@@ -19100,38 +19430,38 @@ function moduleScope(context, program) {
|
|
|
19100
19430
|
function exportedNames(program) {
|
|
19101
19431
|
const names = /* @__PURE__ */ new Set();
|
|
19102
19432
|
for (const statement of program.body) {
|
|
19103
|
-
if (statement.type !==
|
|
19104
|
-
if (statement.declaration?.type ===
|
|
19433
|
+
if (statement.type !== AST_NODE_TYPES78.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
19434
|
+
if (statement.declaration?.type === AST_NODE_TYPES78.FunctionDeclaration && statement.declaration.id !== null) {
|
|
19105
19435
|
names.add(statement.declaration.id.name);
|
|
19106
19436
|
}
|
|
19107
|
-
if (statement.declaration?.type ===
|
|
19437
|
+
if (statement.declaration?.type === AST_NODE_TYPES78.VariableDeclaration) {
|
|
19108
19438
|
for (const declarator of statement.declaration.declarations) {
|
|
19109
|
-
if (declarator.id.type ===
|
|
19439
|
+
if (declarator.id.type === AST_NODE_TYPES78.Identifier) names.add(declarator.id.name);
|
|
19110
19440
|
}
|
|
19111
19441
|
}
|
|
19112
19442
|
for (const specifier of statement.specifiers) {
|
|
19113
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
19443
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES78.Identifier) {
|
|
19114
19444
|
names.add(specifier.local.name);
|
|
19115
19445
|
}
|
|
19116
19446
|
}
|
|
19117
19447
|
}
|
|
19118
19448
|
for (const statement of program.body) {
|
|
19119
|
-
if (statement.type ===
|
|
19120
|
-
if (statement.type ===
|
|
19449
|
+
if (statement.type === AST_NODE_TYPES78.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES78.Identifier) names.add(statement.declaration.name);
|
|
19450
|
+
if (statement.type === AST_NODE_TYPES78.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES78.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
19121
19451
|
}
|
|
19122
19452
|
return names;
|
|
19123
19453
|
}
|
|
19124
19454
|
function moduleDefinitions(program) {
|
|
19125
19455
|
const definitions = [];
|
|
19126
19456
|
for (const statement of program.body) {
|
|
19127
|
-
const node = statement.type ===
|
|
19128
|
-
if (node?.type ===
|
|
19457
|
+
const node = statement.type === AST_NODE_TYPES78.ExportNamedDeclaration || statement.type === AST_NODE_TYPES78.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
19458
|
+
if (node?.type === AST_NODE_TYPES78.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
19129
19459
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
19130
19460
|
continue;
|
|
19131
19461
|
}
|
|
19132
|
-
if (node?.type !==
|
|
19462
|
+
if (node?.type !== AST_NODE_TYPES78.VariableDeclaration || node.kind !== "const") continue;
|
|
19133
19463
|
for (const declarator of node.declarations) {
|
|
19134
|
-
if (declarator.id.type ===
|
|
19464
|
+
if (declarator.id.type === AST_NODE_TYPES78.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
19135
19465
|
definitions.push({
|
|
19136
19466
|
name: declarator.id.name,
|
|
19137
19467
|
node: declarator,
|
|
@@ -19144,21 +19474,21 @@ function moduleDefinitions(program) {
|
|
|
19144
19474
|
return definitions;
|
|
19145
19475
|
}
|
|
19146
19476
|
function methodName(node) {
|
|
19147
|
-
if (node.key.type ===
|
|
19148
|
-
return !node.computed && node.key.type ===
|
|
19477
|
+
if (node.key.type === AST_NODE_TYPES78.PrivateIdentifier) return `#${node.key.name}`;
|
|
19478
|
+
return !node.computed && node.key.type === AST_NODE_TYPES78.Identifier ? node.key.name : null;
|
|
19149
19479
|
}
|
|
19150
19480
|
function referencedMethod(context, node, classVariables) {
|
|
19151
|
-
const objectVariable = node.object.type ===
|
|
19481
|
+
const objectVariable = node.object.type === AST_NODE_TYPES78.Identifier ? ASTUtils44.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
19152
19482
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
19153
|
-
if (node.object.type !==
|
|
19154
|
-
if (node.property.type ===
|
|
19155
|
-
if (!node.computed && node.property.type ===
|
|
19156
|
-
return node.computed && node.property.type ===
|
|
19483
|
+
if (node.object.type !== AST_NODE_TYPES78.ThisExpression && !isClassReference) return null;
|
|
19484
|
+
if (node.property.type === AST_NODE_TYPES78.PrivateIdentifier) return `#${node.property.name}`;
|
|
19485
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES78.Identifier) return node.property.name;
|
|
19486
|
+
return node.computed && node.property.type === AST_NODE_TYPES78.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
19157
19487
|
}
|
|
19158
19488
|
function referencedPropertyName(node) {
|
|
19159
|
-
if (node.property.type ===
|
|
19160
|
-
if (!node.computed && node.property.type ===
|
|
19161
|
-
return node.computed && node.property.type ===
|
|
19489
|
+
if (node.property.type === AST_NODE_TYPES78.PrivateIdentifier) return `#${node.property.name}`;
|
|
19490
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES78.Identifier) return node.property.name;
|
|
19491
|
+
return node.computed && node.property.type === AST_NODE_TYPES78.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
19162
19492
|
}
|
|
19163
19493
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
19164
19494
|
visit(node, nestedFunction);
|
|
@@ -19174,7 +19504,7 @@ function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
19174
19504
|
}
|
|
19175
19505
|
function classScope(context, node, computedReferenceNames) {
|
|
19176
19506
|
const methods = node.body.body.filter(
|
|
19177
|
-
(member) => member.type ===
|
|
19507
|
+
(member) => member.type === AST_NODE_TYPES78.MethodDefinition
|
|
19178
19508
|
);
|
|
19179
19509
|
const counts = /* @__PURE__ */ new Map();
|
|
19180
19510
|
for (const method of methods) {
|
|
@@ -19182,8 +19512,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
19182
19512
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
19183
19513
|
}
|
|
19184
19514
|
for (const member of node.body.body) {
|
|
19185
|
-
if (member.type !==
|
|
19186
|
-
const name = !member.computed && member.key.type ===
|
|
19515
|
+
if (member.type !== AST_NODE_TYPES78.TSAbstractMethodDefinition) continue;
|
|
19516
|
+
const name = !member.computed && member.key.type === AST_NODE_TYPES78.Identifier ? member.key.name : null;
|
|
19187
19517
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
19188
19518
|
}
|
|
19189
19519
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -19192,7 +19522,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
19192
19522
|
});
|
|
19193
19523
|
const definitions = methods.flatMap((method) => {
|
|
19194
19524
|
const name = methodName(method);
|
|
19195
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
19525
|
+
const isPrivate = method.accessibility === "private" || method.key.type === AST_NODE_TYPES78.PrivateIdentifier;
|
|
19196
19526
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
19197
19527
|
});
|
|
19198
19528
|
if (definitions.length === 0) return;
|
|
@@ -19204,7 +19534,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
19204
19534
|
const internal = ASTUtils44.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
19205
19535
|
if (internal !== null) classVariables.add(internal);
|
|
19206
19536
|
}
|
|
19207
|
-
if (node.type ===
|
|
19537
|
+
if (node.type === AST_NODE_TYPES78.ClassExpression && node.parent.type === AST_NODE_TYPES78.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES78.Identifier) {
|
|
19208
19538
|
const outer = ASTUtils44.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
19209
19539
|
if (outer !== null) classVariables.add(outer);
|
|
19210
19540
|
}
|
|
@@ -19221,26 +19551,26 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
19221
19551
|
}
|
|
19222
19552
|
const thisValue = (value) => {
|
|
19223
19553
|
let current = value;
|
|
19224
|
-
while (current?.type ===
|
|
19225
|
-
return current?.type ===
|
|
19554
|
+
while (current?.type === AST_NODE_TYPES78.TSAsExpression || current?.type === AST_NODE_TYPES78.TSSatisfiesExpression || current?.type === AST_NODE_TYPES78.TSNonNullExpression) current = current.expression;
|
|
19555
|
+
return current?.type === AST_NODE_TYPES78.ThisExpression;
|
|
19226
19556
|
};
|
|
19227
19557
|
const collectAlias = (current, nestedFunction) => {
|
|
19228
|
-
if (nestedFunction || current.type !==
|
|
19229
|
-
if (current.type ===
|
|
19230
|
-
const binding = current.type ===
|
|
19231
|
-
const value = current.type ===
|
|
19558
|
+
if (nestedFunction || current.type !== AST_NODE_TYPES78.VariableDeclarator && current.type !== AST_NODE_TYPES78.AssignmentPattern) return;
|
|
19559
|
+
if (current.type === AST_NODE_TYPES78.VariableDeclarator && (current.parent.type !== AST_NODE_TYPES78.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
19560
|
+
const binding = current.type === AST_NODE_TYPES78.VariableDeclarator ? current.id : current.left;
|
|
19561
|
+
const value = current.type === AST_NODE_TYPES78.VariableDeclarator ? current.init : current.right;
|
|
19232
19562
|
if (!thisValue(value)) return;
|
|
19233
|
-
if (binding.type ===
|
|
19563
|
+
if (binding.type === AST_NODE_TYPES78.ObjectPattern) {
|
|
19234
19564
|
for (const property of binding.properties) {
|
|
19235
|
-
if (property.type ===
|
|
19565
|
+
if (property.type === AST_NODE_TYPES78.RestElement) {
|
|
19236
19566
|
for (const name of privateNames) pinned.add(name);
|
|
19237
|
-
} else if (property.key.type ===
|
|
19567
|
+
} else if (property.key.type === AST_NODE_TYPES78.Identifier && privateNames.has(property.key.name)) {
|
|
19238
19568
|
pinned.add(property.key.name);
|
|
19239
19569
|
}
|
|
19240
19570
|
}
|
|
19241
19571
|
return;
|
|
19242
19572
|
}
|
|
19243
|
-
if (binding.type !==
|
|
19573
|
+
if (binding.type !== AST_NODE_TYPES78.Identifier) return;
|
|
19244
19574
|
const variable = ASTUtils44.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
19245
19575
|
if (variable !== null) {
|
|
19246
19576
|
methodClassVariables.add(variable);
|
|
@@ -19254,16 +19584,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
19254
19584
|
walk(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
19255
19585
|
}
|
|
19256
19586
|
const visitCall = (current, nestedFunction) => {
|
|
19257
|
-
if (current.type ===
|
|
19587
|
+
if (current.type === AST_NODE_TYPES78.VariableDeclarator && current.id.type === AST_NODE_TYPES78.ObjectPattern && thisValue(current.init)) {
|
|
19258
19588
|
for (const property of current.id.properties) {
|
|
19259
|
-
if (property.type ===
|
|
19589
|
+
if (property.type === AST_NODE_TYPES78.RestElement) {
|
|
19260
19590
|
for (const name of privateNames) pinned.add(name);
|
|
19261
19591
|
continue;
|
|
19262
19592
|
}
|
|
19263
|
-
if (property.type ===
|
|
19593
|
+
if (property.type === AST_NODE_TYPES78.Property && property.key.type === AST_NODE_TYPES78.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
19264
19594
|
}
|
|
19265
19595
|
}
|
|
19266
|
-
if (current.type !==
|
|
19596
|
+
if (current.type !== AST_NODE_TYPES78.MemberExpression) return;
|
|
19267
19597
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
19268
19598
|
if (target === null) {
|
|
19269
19599
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -19271,12 +19601,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
19271
19601
|
return;
|
|
19272
19602
|
}
|
|
19273
19603
|
if (!privateNames.has(target)) return;
|
|
19274
|
-
const objectVariable = current.object.type ===
|
|
19604
|
+
const objectVariable = current.object.type === AST_NODE_TYPES78.Identifier ? ASTUtils44.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
19275
19605
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
19276
19606
|
pinned.add(target);
|
|
19277
19607
|
return;
|
|
19278
19608
|
}
|
|
19279
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
19609
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== AST_NODE_TYPES78.CallExpression || current.parent.callee !== current) {
|
|
19280
19610
|
pinned.add(target);
|
|
19281
19611
|
return;
|
|
19282
19612
|
}
|
|
@@ -19296,9 +19626,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
19296
19626
|
}
|
|
19297
19627
|
}
|
|
19298
19628
|
for (const member of node.body.body) {
|
|
19299
|
-
if (member.type ===
|
|
19629
|
+
if (member.type === AST_NODE_TYPES78.MethodDefinition || member.type === AST_NODE_TYPES78.TSAbstractMethodDefinition) continue;
|
|
19300
19630
|
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
19301
|
-
if (current.type !==
|
|
19631
|
+
if (current.type !== AST_NODE_TYPES78.MemberExpression) return;
|
|
19302
19632
|
const target = referencedMethod(context, current, classVariables);
|
|
19303
19633
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
19304
19634
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -19320,12 +19650,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
19320
19650
|
}
|
|
19321
19651
|
function isClassRuntimeBarrier(member) {
|
|
19322
19652
|
switch (member.type) {
|
|
19323
|
-
case
|
|
19653
|
+
case AST_NODE_TYPES78.StaticBlock:
|
|
19324
19654
|
return true;
|
|
19325
|
-
case
|
|
19326
|
-
case
|
|
19655
|
+
case AST_NODE_TYPES78.PropertyDefinition:
|
|
19656
|
+
case AST_NODE_TYPES78.AccessorProperty:
|
|
19327
19657
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
19328
|
-
case
|
|
19658
|
+
case AST_NODE_TYPES78.MethodDefinition:
|
|
19329
19659
|
return member.computed || member.decorators.length > 0;
|
|
19330
19660
|
default:
|
|
19331
19661
|
return false;
|
|
@@ -19357,7 +19687,7 @@ var stepdown_default = createRule({
|
|
|
19357
19687
|
moduleScope(context, program);
|
|
19358
19688
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
19359
19689
|
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
19360
|
-
if (node.type ===
|
|
19690
|
+
if (node.type === AST_NODE_TYPES78.MemberExpression && node.computed && node.property.type === AST_NODE_TYPES78.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
19361
19691
|
});
|
|
19362
19692
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
19363
19693
|
}
|
|
@@ -19366,7 +19696,7 @@ var stepdown_default = createRule({
|
|
|
19366
19696
|
});
|
|
19367
19697
|
|
|
19368
19698
|
// src/rules/source-coupled-test.ts
|
|
19369
|
-
import { AST_NODE_TYPES as
|
|
19699
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES79, ASTUtils as ASTUtils45 } from "@typescript-eslint/utils";
|
|
19370
19700
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|py|[cm]?[jt]s)$/iu;
|
|
19371
19701
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
19372
19702
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -19435,21 +19765,21 @@ var SOURCE_COUPLED_TEST_DOCUMENTATION = {
|
|
|
19435
19765
|
]
|
|
19436
19766
|
};
|
|
19437
19767
|
function staticMemberName7(node) {
|
|
19438
|
-
if (!node.computed && node.property.type ===
|
|
19439
|
-
if (node.computed && node.property.type ===
|
|
19768
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES79.Identifier) return node.property.name;
|
|
19769
|
+
if (node.computed && node.property.type === AST_NODE_TYPES79.Literal && typeof node.property.value === "string") return node.property.value;
|
|
19440
19770
|
return null;
|
|
19441
19771
|
}
|
|
19442
19772
|
function unwrap7(node) {
|
|
19443
|
-
if (node.type ===
|
|
19444
|
-
if (node.type ===
|
|
19445
|
-
if (node.type ===
|
|
19773
|
+
if (node.type === AST_NODE_TYPES79.AwaitExpression) return unwrap7(node.argument);
|
|
19774
|
+
if (node.type === AST_NODE_TYPES79.ChainExpression) return unwrap7(node.expression);
|
|
19775
|
+
if (node.type === AST_NODE_TYPES79.TSAsExpression || node.type === AST_NODE_TYPES79.TSNonNullExpression || node.type === AST_NODE_TYPES79.TSTypeAssertion) return unwrap7(node.expression);
|
|
19446
19776
|
return node;
|
|
19447
19777
|
}
|
|
19448
19778
|
function stringValue(node) {
|
|
19449
19779
|
const current = unwrap7(node);
|
|
19450
|
-
if (current.type ===
|
|
19451
|
-
if (current.type ===
|
|
19452
|
-
if (current.type ===
|
|
19780
|
+
if (current.type === AST_NODE_TYPES79.Literal && typeof current.value === "string") return current.value;
|
|
19781
|
+
if (current.type === AST_NODE_TYPES79.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
19782
|
+
if (current.type === AST_NODE_TYPES79.BinaryExpression && current.operator === "+") {
|
|
19453
19783
|
const left = stringValue(current.left);
|
|
19454
19784
|
const right = stringValue(current.right);
|
|
19455
19785
|
return left === null || right === null ? null : left + right;
|
|
@@ -19461,7 +19791,7 @@ function importSource(node) {
|
|
|
19461
19791
|
}
|
|
19462
19792
|
function requireSource(node) {
|
|
19463
19793
|
const current = unwrap7(node);
|
|
19464
|
-
if (current.type !==
|
|
19794
|
+
if (current.type !== AST_NODE_TYPES79.CallExpression || current.callee.type !== AST_NODE_TYPES79.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === AST_NODE_TYPES79.SpreadElement) return null;
|
|
19465
19795
|
return stringValue(current.arguments[0]);
|
|
19466
19796
|
}
|
|
19467
19797
|
function newScope() {
|
|
@@ -19506,37 +19836,37 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
19506
19836
|
const current = unwrap7(node);
|
|
19507
19837
|
const value = stringValue(current);
|
|
19508
19838
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
19509
|
-
if (current.type ===
|
|
19510
|
-
if (current.type ===
|
|
19839
|
+
if (current.type === AST_NODE_TYPES79.Identifier) return visible("paths", current);
|
|
19840
|
+
if (current.type === AST_NODE_TYPES79.CallExpression || current.type === AST_NODE_TYPES79.NewExpression) {
|
|
19511
19841
|
const callee = current.callee;
|
|
19512
19842
|
const first = current.arguments[0];
|
|
19513
|
-
if (first === void 0 || first.type ===
|
|
19514
|
-
if (current.type ===
|
|
19515
|
-
if (callee.type ===
|
|
19843
|
+
if (first === void 0 || first.type === AST_NODE_TYPES79.SpreadElement) return false;
|
|
19844
|
+
if (current.type === AST_NODE_TYPES79.NewExpression && callee.type === AST_NODE_TYPES79.Identifier && callee.name === "URL" && (bindingOf(callee)?.defs.length ?? 0) === 0) return sourcePath(first);
|
|
19845
|
+
if (callee.type === AST_NODE_TYPES79.Identifier && bindingOf(callee)?.defs.some((definition) => definition.node.type === AST_NODE_TYPES79.ImportSpecifier && definition.node.imported.type === AST_NODE_TYPES79.Identifier && definition.node.imported.name === "fileURLToPath" && definition.node.parent.type === AST_NODE_TYPES79.ImportDeclaration && ["node:url", "url"].includes(String(definition.node.parent.source.value)))) return sourcePath(first);
|
|
19516
19846
|
}
|
|
19517
19847
|
return false;
|
|
19518
19848
|
};
|
|
19519
19849
|
const rawRead = (node) => {
|
|
19520
19850
|
const current = unwrap7(node);
|
|
19521
|
-
if (current.type !==
|
|
19851
|
+
if (current.type !== AST_NODE_TYPES79.CallExpression || current.arguments.length === 0) return false;
|
|
19522
19852
|
const callee = unwrap7(current.callee);
|
|
19523
|
-
if (callee.type ===
|
|
19853
|
+
if (callee.type === AST_NODE_TYPES79.Identifier) {
|
|
19524
19854
|
return visible("fsReaders", callee) && sourcePath(current.arguments[0]);
|
|
19525
19855
|
}
|
|
19526
|
-
if (callee.type !==
|
|
19856
|
+
if (callee.type !== AST_NODE_TYPES79.MemberExpression) return false;
|
|
19527
19857
|
const name2 = staticMemberName7(callee);
|
|
19528
19858
|
const object = unwrap7(callee.object);
|
|
19529
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
19859
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === AST_NODE_TYPES79.Identifier && visible("fsObjects", object) && sourcePath(current.arguments[0]);
|
|
19530
19860
|
};
|
|
19531
19861
|
const rawOrigins = (node) => {
|
|
19532
19862
|
const current = unwrap7(node);
|
|
19533
|
-
if (current.type ===
|
|
19863
|
+
if (current.type === AST_NODE_TYPES79.Identifier) return visibleRawOrigins(current);
|
|
19534
19864
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
19535
|
-
if (current.type ===
|
|
19536
|
-
if (current.type ===
|
|
19537
|
-
if (current.type !==
|
|
19865
|
+
if (current.type === AST_NODE_TYPES79.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
19866
|
+
if (current.type === AST_NODE_TYPES79.MemberExpression && staticMemberName7(current) === "length") return rawOrigins(current.object);
|
|
19867
|
+
if (current.type !== AST_NODE_TYPES79.CallExpression) return /* @__PURE__ */ new Set();
|
|
19538
19868
|
const callee = unwrap7(current.callee);
|
|
19539
|
-
if (callee.type !==
|
|
19869
|
+
if (callee.type !== AST_NODE_TYPES79.MemberExpression) return /* @__PURE__ */ new Set();
|
|
19540
19870
|
const name2 = staticMemberName7(callee);
|
|
19541
19871
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(callee.object) : /* @__PURE__ */ new Set();
|
|
19542
19872
|
};
|
|
@@ -19544,32 +19874,32 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
19544
19874
|
const current = unwrap7(node);
|
|
19545
19875
|
const direct = rawOrigins(current);
|
|
19546
19876
|
if (direct.size > 0) return direct;
|
|
19547
|
-
if (current.type ===
|
|
19548
|
-
if (current.type ===
|
|
19549
|
-
if (current.type !==
|
|
19877
|
+
if (current.type === AST_NODE_TYPES79.BinaryExpression || current.type === AST_NODE_TYPES79.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
19878
|
+
if (current.type === AST_NODE_TYPES79.UnaryExpression) return evidenceOrigins(current.argument);
|
|
19879
|
+
if (current.type !== AST_NODE_TYPES79.CallExpression) return /* @__PURE__ */ new Set();
|
|
19550
19880
|
const callee = unwrap7(current.callee);
|
|
19551
|
-
if (callee.type !==
|
|
19881
|
+
if (callee.type !== AST_NODE_TYPES79.MemberExpression) return /* @__PURE__ */ new Set();
|
|
19552
19882
|
const name2 = staticMemberName7(callee);
|
|
19553
19883
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(callee.object);
|
|
19554
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
19884
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES79.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
19555
19885
|
return /* @__PURE__ */ new Set();
|
|
19556
19886
|
};
|
|
19557
19887
|
const rawAssertionOrigins = (node) => {
|
|
19558
19888
|
const callee = unwrap7(node.callee);
|
|
19559
|
-
if (callee.type ===
|
|
19560
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
19889
|
+
if (callee.type === AST_NODE_TYPES79.Identifier && callee.name === "assert") {
|
|
19890
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES79.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
19561
19891
|
}
|
|
19562
|
-
if (callee.type !==
|
|
19892
|
+
if (callee.type !== AST_NODE_TYPES79.MemberExpression) return /* @__PURE__ */ new Set();
|
|
19563
19893
|
const matcher = staticMemberName7(callee);
|
|
19564
19894
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
19565
19895
|
let receiver = unwrap7(callee.object);
|
|
19566
|
-
while (receiver.type ===
|
|
19567
|
-
if (receiver.type ===
|
|
19896
|
+
while (receiver.type === AST_NODE_TYPES79.MemberExpression && EXPECT_MODIFIERS2.has(staticMemberName7(receiver) ?? "")) receiver = unwrap7(receiver.object);
|
|
19897
|
+
if (receiver.type === AST_NODE_TYPES79.CallExpression && receiver.callee.type === AST_NODE_TYPES79.Identifier && receiver.callee.name === "expect") {
|
|
19568
19898
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
19569
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
19899
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === AST_NODE_TYPES79.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
19570
19900
|
}
|
|
19571
|
-
if (receiver.type !==
|
|
19572
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
19901
|
+
if (receiver.type !== AST_NODE_TYPES79.Identifier || receiver.name !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
19902
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES79.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
19573
19903
|
};
|
|
19574
19904
|
const declare = (node, state) => {
|
|
19575
19905
|
const name2 = bindingOf(node);
|
|
@@ -19591,7 +19921,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
19591
19921
|
};
|
|
19592
19922
|
const sourceCollection = (node) => {
|
|
19593
19923
|
const current = unwrap7(node);
|
|
19594
|
-
return current.type ===
|
|
19924
|
+
return current.type === AST_NODE_TYPES79.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== AST_NODE_TYPES79.SpreadElement && sourcePath(element));
|
|
19595
19925
|
};
|
|
19596
19926
|
const enterFunction = () => {
|
|
19597
19927
|
scopes.push(newScope());
|
|
@@ -19604,8 +19934,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
19604
19934
|
const source = importSource(node);
|
|
19605
19935
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
19606
19936
|
for (const specifier of node.specifiers) {
|
|
19607
|
-
if (specifier.type ===
|
|
19608
|
-
const imported = specifier.imported.type ===
|
|
19937
|
+
if (specifier.type === AST_NODE_TYPES79.ImportSpecifier) {
|
|
19938
|
+
const imported = specifier.imported.type === AST_NODE_TYPES79.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
19609
19939
|
if (FS_READERS.has(imported)) declare(specifier.local, { fsReader: true });
|
|
19610
19940
|
} else {
|
|
19611
19941
|
declare(specifier.local, { fsObject: true });
|
|
@@ -19618,30 +19948,30 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
19618
19948
|
if (node.init === null) return;
|
|
19619
19949
|
const required = requireSource(node.init);
|
|
19620
19950
|
const initializer = unwrap7(node.init);
|
|
19621
|
-
if (required !== null && initializer.type ===
|
|
19622
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
19951
|
+
if (required !== null && initializer.type === AST_NODE_TYPES79.CallExpression && initializer.callee.type === AST_NODE_TYPES79.Identifier && (bindingOf(initializer.callee)?.defs.length ?? 0) > 0) return;
|
|
19952
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === AST_NODE_TYPES79.Identifier) {
|
|
19623
19953
|
declare(node.id, { fsObject: true });
|
|
19624
19954
|
return;
|
|
19625
19955
|
}
|
|
19626
|
-
if (node.id.type ===
|
|
19956
|
+
if (node.id.type === AST_NODE_TYPES79.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
19627
19957
|
for (const property of node.id.properties) {
|
|
19628
|
-
if (property.type !==
|
|
19629
|
-
const key = property.key.type ===
|
|
19958
|
+
if (property.type !== AST_NODE_TYPES79.Property || property.value.type !== AST_NODE_TYPES79.Identifier) continue;
|
|
19959
|
+
const key = property.key.type === AST_NODE_TYPES79.Identifier ? property.key.name : property.key.type === AST_NODE_TYPES79.Literal ? String(property.key.value) : "";
|
|
19630
19960
|
if (FS_READERS.has(key)) declare(property.value, { fsReader: true });
|
|
19631
19961
|
}
|
|
19632
19962
|
return;
|
|
19633
19963
|
}
|
|
19634
|
-
if (node.id.type !==
|
|
19964
|
+
if (node.id.type !== AST_NODE_TYPES79.Identifier) return;
|
|
19635
19965
|
declare(node.id, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
19636
19966
|
},
|
|
19637
19967
|
AssignmentExpression(node) {
|
|
19638
|
-
if (node.left.type ===
|
|
19968
|
+
if (node.left.type === AST_NODE_TYPES79.Identifier) declare(node.left, {});
|
|
19639
19969
|
},
|
|
19640
19970
|
ForOfStatement(node) {
|
|
19641
19971
|
const right = unwrap7(node.right);
|
|
19642
|
-
const collection = right.type ===
|
|
19643
|
-
const left = node.left.type ===
|
|
19644
|
-
if (collection && left?.type ===
|
|
19972
|
+
const collection = right.type === AST_NODE_TYPES79.Identifier && visible("collections", right);
|
|
19973
|
+
const left = node.left.type === AST_NODE_TYPES79.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
19974
|
+
if (collection && left?.type === AST_NODE_TYPES79.Identifier) declare(left, { path: true });
|
|
19645
19975
|
},
|
|
19646
19976
|
CallExpression(node) {
|
|
19647
19977
|
const origins = rawAssertionOrigins(node);
|
|
@@ -19660,7 +19990,7 @@ var source_coupled_test_default = createSourceCoupledRule(
|
|
|
19660
19990
|
);
|
|
19661
19991
|
|
|
19662
19992
|
// src/rules/sole-export-matches-filename.ts
|
|
19663
|
-
import { AST_NODE_TYPES as
|
|
19993
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES80 } from "@typescript-eslint/utils";
|
|
19664
19994
|
var SOLE_EXPORT_MATCHES_FILENAME_DOCUMENTATION = {
|
|
19665
19995
|
summary: "Match a module filename to its sole named public runtime export.",
|
|
19666
19996
|
rationale: "When a module owns one runtime responsibility, matching names make that responsibility directly discoverable.",
|
|
@@ -19704,10 +20034,10 @@ function kebabCase(name) {
|
|
|
19704
20034
|
function declarationExport(statement) {
|
|
19705
20035
|
const declaration = statement.declaration;
|
|
19706
20036
|
if (declaration === null || declaration.declare === true) return [];
|
|
19707
|
-
if (declaration.type ===
|
|
19708
|
-
if (declaration.type !==
|
|
20037
|
+
if (declaration.type === AST_NODE_TYPES80.ClassDeclaration || declaration.type === AST_NODE_TYPES80.FunctionDeclaration || declaration.type === AST_NODE_TYPES80.TSEnumDeclaration) return declaration.id === null ? [] : [{ name: declaration.id.name, node: declaration }];
|
|
20038
|
+
if (declaration.type !== AST_NODE_TYPES80.VariableDeclaration) return [];
|
|
19709
20039
|
return declaration.declarations.flatMap(
|
|
19710
|
-
(item) => item.id.type ===
|
|
20040
|
+
(item) => item.id.type === AST_NODE_TYPES80.Identifier ? [{ name: item.id.name, node: item }] : []
|
|
19711
20041
|
);
|
|
19712
20042
|
}
|
|
19713
20043
|
var sole_export_matches_filename_default = createRule({
|
|
@@ -19731,32 +20061,32 @@ var sole_export_matches_filename_default = createRule({
|
|
|
19731
20061
|
const exports = [];
|
|
19732
20062
|
const publicExports = /* @__PURE__ */ new Set();
|
|
19733
20063
|
for (const statement of program.body) {
|
|
19734
|
-
if (statement.type ===
|
|
19735
|
-
if (statement.type ===
|
|
20064
|
+
if (statement.type === AST_NODE_TYPES80.ExportAllDeclaration || statement.type === AST_NODE_TYPES80.ExportNamedDeclaration && statement.source !== null) return;
|
|
20065
|
+
if (statement.type === AST_NODE_TYPES80.ExportDefaultDeclaration) {
|
|
19736
20066
|
publicExports.add("default");
|
|
19737
20067
|
const declaration2 = statement.declaration;
|
|
19738
|
-
if ((declaration2.type ===
|
|
20068
|
+
if ((declaration2.type === AST_NODE_TYPES80.ClassDeclaration || declaration2.type === AST_NODE_TYPES80.FunctionDeclaration) && declaration2.id !== null) exports.push({ name: declaration2.id.name, node: declaration2 });
|
|
19739
20069
|
else return;
|
|
19740
20070
|
}
|
|
19741
|
-
if (statement.type !==
|
|
20071
|
+
if (statement.type !== AST_NODE_TYPES80.ExportNamedDeclaration) continue;
|
|
19742
20072
|
const declaration = statement.declaration;
|
|
19743
|
-
if (declaration !== null && "id" in declaration && declaration.id?.type ===
|
|
20073
|
+
if (declaration !== null && "id" in declaration && declaration.id?.type === AST_NODE_TYPES80.Identifier) {
|
|
19744
20074
|
publicExports.add(declaration.id.name);
|
|
19745
20075
|
}
|
|
19746
|
-
if (declaration?.type ===
|
|
19747
|
-
if (declaration.declarations.some((item) => item.id.type !==
|
|
20076
|
+
if (declaration?.type === AST_NODE_TYPES80.VariableDeclaration) {
|
|
20077
|
+
if (declaration.declarations.some((item) => item.id.type !== AST_NODE_TYPES80.Identifier)) return;
|
|
19748
20078
|
for (const item of declaration.declarations) {
|
|
19749
|
-
if (item.id.type ===
|
|
20079
|
+
if (item.id.type === AST_NODE_TYPES80.Identifier) publicExports.add(item.id.name);
|
|
19750
20080
|
}
|
|
19751
20081
|
}
|
|
19752
20082
|
for (const specifier of statement.specifiers) {
|
|
19753
|
-
const exported = specifier.exported.type ===
|
|
20083
|
+
const exported = specifier.exported.type === AST_NODE_TYPES80.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
19754
20084
|
publicExports.add(String(exported));
|
|
19755
20085
|
}
|
|
19756
20086
|
if (statement.exportKind === "type") continue;
|
|
19757
20087
|
exports.push(...declarationExport(statement));
|
|
19758
20088
|
for (const specifier of statement.specifiers) {
|
|
19759
|
-
const exported = specifier.exported.type ===
|
|
20089
|
+
const exported = specifier.exported.type === AST_NODE_TYPES80.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
19760
20090
|
publicExports.add(String(exported));
|
|
19761
20091
|
if (specifier.exportKind === "type") continue;
|
|
19762
20092
|
if (exported === "default") exports.push({ name: specifier.local.name, node: specifier });
|
|
@@ -19768,7 +20098,7 @@ var sole_export_matches_filename_default = createRule({
|
|
|
19768
20098
|
const only = [...unique.values()][0];
|
|
19769
20099
|
if (only === void 0) return;
|
|
19770
20100
|
if (only.name === "onRouterTransitionStart" && /(?:^|\/)instrumentation-client\.[jt]s$/u.test(normalizedFilename)) return;
|
|
19771
|
-
if (only.name === "collections" && /(?:^|\/)src\/content\.config\.(?:ts|js|mjs)$/u.test(normalizedFilename) && program.body.some((statement) => statement.type ===
|
|
20101
|
+
if (only.name === "collections" && /(?:^|\/)src\/content\.config\.(?:ts|js|mjs)$/u.test(normalizedFilename) && program.body.some((statement) => statement.type === AST_NODE_TYPES80.ImportDeclaration && statement.source.value === "astro:content")) return;
|
|
19772
20102
|
const exportedStem = kebabCase(only.name);
|
|
19773
20103
|
if (exportedStem === "") return;
|
|
19774
20104
|
const expected = `${fileStem.startsWith("_") ? "_" : ""}${exportedStem}`;
|
|
@@ -19819,7 +20149,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
19819
20149
|
|
|
19820
20150
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
19821
20151
|
import {
|
|
19822
|
-
AST_NODE_TYPES as
|
|
20152
|
+
AST_NODE_TYPES as AST_NODE_TYPES81,
|
|
19823
20153
|
ASTUtils as ASTUtils46
|
|
19824
20154
|
} from "@typescript-eslint/utils";
|
|
19825
20155
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
@@ -19953,18 +20283,18 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
19953
20283
|
"superRefine",
|
|
19954
20284
|
"transform"
|
|
19955
20285
|
]);
|
|
19956
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
20286
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES81.Identifier ? callee.property.name : null;
|
|
19957
20287
|
var calleeChainRoot2 = (node) => {
|
|
19958
20288
|
let current = node;
|
|
19959
20289
|
for (; ; ) {
|
|
19960
|
-
if (current.type ===
|
|
20290
|
+
if (current.type === AST_NODE_TYPES81.Identifier) {
|
|
19961
20291
|
return current;
|
|
19962
20292
|
}
|
|
19963
|
-
if (current.type ===
|
|
20293
|
+
if (current.type === AST_NODE_TYPES81.MemberExpression) {
|
|
19964
20294
|
current = current.object;
|
|
19965
20295
|
continue;
|
|
19966
20296
|
}
|
|
19967
|
-
if (current.type ===
|
|
20297
|
+
if (current.type === AST_NODE_TYPES81.CallExpression) {
|
|
19968
20298
|
current = current.callee;
|
|
19969
20299
|
continue;
|
|
19970
20300
|
}
|
|
@@ -19975,13 +20305,13 @@ var chainMemberNames2 = (node) => {
|
|
|
19975
20305
|
const names = [];
|
|
19976
20306
|
let current = node;
|
|
19977
20307
|
for (; ; ) {
|
|
19978
|
-
if (current.type ===
|
|
19979
|
-
if (current.computed || current.property.type !==
|
|
20308
|
+
if (current.type === AST_NODE_TYPES81.MemberExpression) {
|
|
20309
|
+
if (current.computed || current.property.type !== AST_NODE_TYPES81.Identifier) return [];
|
|
19980
20310
|
names.push(current.property.name);
|
|
19981
20311
|
current = current.object;
|
|
19982
20312
|
continue;
|
|
19983
20313
|
}
|
|
19984
|
-
if (current.type ===
|
|
20314
|
+
if (current.type === AST_NODE_TYPES81.CallExpression) {
|
|
19985
20315
|
current = current.callee;
|
|
19986
20316
|
continue;
|
|
19987
20317
|
}
|
|
@@ -19992,16 +20322,16 @@ var chainMemberNames2 = (node) => {
|
|
|
19992
20322
|
};
|
|
19993
20323
|
var unwrapExpression4 = (node) => {
|
|
19994
20324
|
let current = node;
|
|
19995
|
-
while (current.type ===
|
|
20325
|
+
while (current.type === AST_NODE_TYPES81.TSAsExpression || current.type === AST_NODE_TYPES81.TSSatisfiesExpression || current.type === AST_NODE_TYPES81.TSNonNullExpression || current.type === AST_NODE_TYPES81.TSTypeAssertion) {
|
|
19996
20326
|
current = current.expression;
|
|
19997
20327
|
}
|
|
19998
20328
|
return current;
|
|
19999
20329
|
};
|
|
20000
20330
|
var isModuleDeclarator = (node) => {
|
|
20001
20331
|
const declaration = node.parent;
|
|
20002
|
-
if (declaration.type !==
|
|
20332
|
+
if (declaration.type !== AST_NODE_TYPES81.VariableDeclaration) return false;
|
|
20003
20333
|
const owner = declaration.parent;
|
|
20004
|
-
return owner.type ===
|
|
20334
|
+
return owner.type === AST_NODE_TYPES81.Program || owner.type === AST_NODE_TYPES81.ExportNamedDeclaration && owner.parent.type === AST_NODE_TYPES81.Program;
|
|
20005
20335
|
};
|
|
20006
20336
|
var require_pascal_case_zod_schema_name_default = createRule({
|
|
20007
20337
|
name: "require-pascal-case-zod-schema-name",
|
|
@@ -20042,8 +20372,8 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
20042
20372
|
}
|
|
20043
20373
|
function isConfirmedSchema(expression) {
|
|
20044
20374
|
const init = unwrapExpression4(expression);
|
|
20045
|
-
if (init.type ===
|
|
20046
|
-
if (init.type !==
|
|
20375
|
+
if (init.type === AST_NODE_TYPES81.Identifier) return isSchemaBinding(init);
|
|
20376
|
+
if (init.type !== AST_NODE_TYPES81.CallExpression || init.callee.type !== AST_NODE_TYPES81.MemberExpression) {
|
|
20047
20377
|
return false;
|
|
20048
20378
|
}
|
|
20049
20379
|
const terminal = terminalMethodName(init.callee);
|
|
@@ -20063,7 +20393,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
20063
20393
|
ImportDeclaration(node) {
|
|
20064
20394
|
if (!isZodModule(node.source.value)) return;
|
|
20065
20395
|
for (const specifier of node.specifiers) {
|
|
20066
|
-
if (specifier.type ===
|
|
20396
|
+
if (specifier.type === AST_NODE_TYPES81.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES81.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES81.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES81.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
20067
20397
|
recordZodBinding(specifier.local);
|
|
20068
20398
|
}
|
|
20069
20399
|
}
|
|
@@ -20072,7 +20402,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
20072
20402
|
if (!isModuleDeclarator(node)) return;
|
|
20073
20403
|
const init = node.init;
|
|
20074
20404
|
if (init === null || init === void 0) return;
|
|
20075
|
-
if (node.id.type !==
|
|
20405
|
+
if (node.id.type !== AST_NODE_TYPES81.Identifier) return;
|
|
20076
20406
|
if (!isConfirmedSchema(init)) return;
|
|
20077
20407
|
const binding = resolvedBinding(node.id);
|
|
20078
20408
|
if (binding !== null) schemaBindings.add(binding);
|
|
@@ -20251,6 +20581,7 @@ var RULES = {
|
|
|
20251
20581
|
"prefer-whole-object-assertion": prefer_whole_object_assertion_default,
|
|
20252
20582
|
"repeated-static-call-cases": repeated_static_call_cases_default,
|
|
20253
20583
|
"prefer-zod-infer": prefer_zod_infer_default,
|
|
20584
|
+
"prefer-zod-parse-output-type": prefer_zod_parse_output_type_default,
|
|
20254
20585
|
"require-assert-never": require_assert_never_default,
|
|
20255
20586
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
20256
20587
|
"require-interface-for-exported-class": require_interface_for_exported_class_default,
|
|
@@ -20266,7 +20597,7 @@ var RULES = {
|
|
|
20266
20597
|
};
|
|
20267
20598
|
var meta = {
|
|
20268
20599
|
name: "@sarj/eslint-plugin",
|
|
20269
|
-
version: "15.17.
|
|
20600
|
+
version: "15.17.13"
|
|
20270
20601
|
};
|
|
20271
20602
|
var APPLICATION_ONLY_RULES = [];
|
|
20272
20603
|
var LIBRARY_IMPORT_POLICY = ["error", {
|
|
@@ -20289,6 +20620,7 @@ var ADVISORY_RULES = [
|
|
|
20289
20620
|
"@sarj/prefer-shared-zod-enum",
|
|
20290
20621
|
"@sarj/prefer-switch-for-repeated-equality",
|
|
20291
20622
|
"@sarj/prefer-whole-object-assertion",
|
|
20623
|
+
"@sarj/prefer-zod-parse-output-type",
|
|
20292
20624
|
"@sarj/require-interface-for-exported-class",
|
|
20293
20625
|
"@sarj/require-sql-access-class",
|
|
20294
20626
|
"@sarj/sole-export-matches-filename"
|
|
@@ -20370,6 +20702,7 @@ var RECOMMENDED_RULES = {
|
|
|
20370
20702
|
"@sarj/prefer-whole-object-assertion": "warn",
|
|
20371
20703
|
"@sarj/repeated-static-call-cases": "error",
|
|
20372
20704
|
"@sarj/prefer-zod-infer": "error",
|
|
20705
|
+
"@sarj/prefer-zod-parse-output-type": "warn",
|
|
20373
20706
|
"@sarj/require-assert-never": "error",
|
|
20374
20707
|
"@sarj/require-fetch-timeout": "error",
|
|
20375
20708
|
"@sarj/require-interface-for-exported-class": "warn",
|
|
@@ -20467,6 +20800,7 @@ var STRICT_RULES = {
|
|
|
20467
20800
|
"@sarj/prefer-whole-object-assertion": "warn",
|
|
20468
20801
|
"@sarj/repeated-static-call-cases": "error",
|
|
20469
20802
|
"@sarj/prefer-zod-infer": "error",
|
|
20803
|
+
"@sarj/prefer-zod-parse-output-type": "warn",
|
|
20470
20804
|
"@sarj/require-assert-never": "error",
|
|
20471
20805
|
"@sarj/require-fetch-timeout": "error",
|
|
20472
20806
|
"@sarj/require-interface-for-exported-class": "warn",
|