@sarj/eslint-plugin 15.16.0 → 15.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1005 -733
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +980 -708
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -11695,8 +11695,268 @@ var prefer_module_level_schema_default = createRule({
|
|
|
11695
11695
|
}
|
|
11696
11696
|
});
|
|
11697
11697
|
|
|
11698
|
-
// src/rules/prefer-
|
|
11698
|
+
// src/rules/prefer-module-level-refined-schema.ts
|
|
11699
11699
|
var import_utils66 = require("@typescript-eslint/utils");
|
|
11700
|
+
var FACTORIES = /* @__PURE__ */ new Set([
|
|
11701
|
+
"array",
|
|
11702
|
+
"bigint",
|
|
11703
|
+
"boolean",
|
|
11704
|
+
"date",
|
|
11705
|
+
"number",
|
|
11706
|
+
"string"
|
|
11707
|
+
]);
|
|
11708
|
+
var REFINEMENTS = /* @__PURE__ */ new Set([
|
|
11709
|
+
"brand",
|
|
11710
|
+
"check",
|
|
11711
|
+
"email",
|
|
11712
|
+
"finite",
|
|
11713
|
+
"int",
|
|
11714
|
+
"length",
|
|
11715
|
+
"max",
|
|
11716
|
+
"min",
|
|
11717
|
+
"multipleOf",
|
|
11718
|
+
"nonempty",
|
|
11719
|
+
"positive",
|
|
11720
|
+
"regex",
|
|
11721
|
+
"refine",
|
|
11722
|
+
"safe",
|
|
11723
|
+
"superRefine",
|
|
11724
|
+
"transform",
|
|
11725
|
+
"trim",
|
|
11726
|
+
"url",
|
|
11727
|
+
"uuid"
|
|
11728
|
+
]);
|
|
11729
|
+
var PREFER_MODULE_LEVEL_REFINED_SCHEMA_DOCUMENTATION = {
|
|
11730
|
+
summary: "Declare closed, refined Zod scalar and array schemas at module scope.",
|
|
11731
|
+
rationale: "A closed validation pipeline created inside a function is rebuilt on every invocation and obscures a reusable constraint.",
|
|
11732
|
+
remediation: "Move the validation schema to module scope and call parse on the shared schema.",
|
|
11733
|
+
category: "performance",
|
|
11734
|
+
limitations: ["Only direct Zod scalar/array chains with at least two refinement methods and no non-literal arguments are reported."],
|
|
11735
|
+
examples: [
|
|
11736
|
+
{ id: "module-refinement", title: "Share the validation schema", outcome: "no-match", files: [{ path: "src/options.ts", source: "import { z } from 'zod'; const BatchSize = z.number().int().min(1).max(1000); export function parse(value: unknown) { return BatchSize.parse(value); }" }], focusPath: "src/options.ts", expectedCount: 0, public: true },
|
|
11737
|
+
{ id: "local-refinement", title: "Do not rebuild a closed validation chain", outcome: "match", files: [{ path: "src/options.ts", source: "import { z } from 'zod'; export function parse(value: unknown) { return z.number().int().min(1).max(1000).parse(value); }" }], focusPath: "src/options.ts", expectedCount: 1, public: true }
|
|
11738
|
+
]
|
|
11739
|
+
};
|
|
11740
|
+
function enclosingFunction4(node) {
|
|
11741
|
+
let current = node.parent ?? void 0;
|
|
11742
|
+
while (current !== void 0) {
|
|
11743
|
+
if ([import_utils66.AST_NODE_TYPES.ArrowFunctionExpression, import_utils66.AST_NODE_TYPES.FunctionDeclaration, import_utils66.AST_NODE_TYPES.FunctionExpression].includes(current.type)) return current;
|
|
11744
|
+
current = current.parent ?? void 0;
|
|
11745
|
+
}
|
|
11746
|
+
return void 0;
|
|
11747
|
+
}
|
|
11748
|
+
function collectReferences2(scope, output) {
|
|
11749
|
+
output.push(...scope.references);
|
|
11750
|
+
for (const child of scope.childScopes) collectReferences2(child, output);
|
|
11751
|
+
}
|
|
11752
|
+
var prefer_module_level_refined_schema_default = createRule({
|
|
11753
|
+
name: "prefer-module-level-refined-schema",
|
|
11754
|
+
documentation: PREFER_MODULE_LEVEL_REFINED_SCHEMA_DOCUMENTATION,
|
|
11755
|
+
meta: { type: "suggestion", docs: { description: "Declare closed, refined Zod scalar and array schemas at module scope." }, schema: [], messages: { hoistRefinedSchema: "Move this closed refined Zod schema to module scope and reuse it for parsing." } },
|
|
11756
|
+
defaultOptions: [],
|
|
11757
|
+
create(context) {
|
|
11758
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
11759
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
11760
|
+
return {
|
|
11761
|
+
ImportDeclaration(node) {
|
|
11762
|
+
if (!isZodModule(node.source.value)) return;
|
|
11763
|
+
for (const specifier of node.specifiers) if (specifier.type === import_utils66.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils66.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils66.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils66.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") namespaces.add(specifier.local.name);
|
|
11764
|
+
},
|
|
11765
|
+
CallExpression(node) {
|
|
11766
|
+
const enclosing = enclosingFunction4(node);
|
|
11767
|
+
if (enclosing === void 0 || node.parent?.type !== import_utils66.AST_NODE_TYPES.MemberExpression || node.parent.object !== node) return;
|
|
11768
|
+
if (node.callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.object.type !== import_utils66.AST_NODE_TYPES.Identifier || !namespaces.has(node.callee.object.name) || node.callee.property.type !== import_utils66.AST_NODE_TYPES.Identifier || !FACTORIES.has(node.callee.property.name)) return;
|
|
11769
|
+
let current = node;
|
|
11770
|
+
let refinements = 0;
|
|
11771
|
+
while (current.parent?.type === import_utils66.AST_NODE_TYPES.MemberExpression && current.parent.object === current && !current.parent.computed && current.parent.property.type === import_utils66.AST_NODE_TYPES.Identifier && current.parent.parent?.type === import_utils66.AST_NODE_TYPES.CallExpression && current.parent.parent.callee === current.parent) {
|
|
11772
|
+
const call = current.parent.parent;
|
|
11773
|
+
if (["parse", "parseAsync", "safeParse", "safeParseAsync"].includes(current.parent.property.name)) break;
|
|
11774
|
+
if (REFINEMENTS.has(current.parent.property.name)) refinements += 1;
|
|
11775
|
+
current = call;
|
|
11776
|
+
}
|
|
11777
|
+
if (refinements < 2) return;
|
|
11778
|
+
const references = [];
|
|
11779
|
+
collectReferences2(context.sourceCode.getScope(current), references);
|
|
11780
|
+
const [start, end] = current.range;
|
|
11781
|
+
const [functionStart, functionEnd] = enclosing.range;
|
|
11782
|
+
for (const reference of references) {
|
|
11783
|
+
const [referenceStart] = reference.identifier.range;
|
|
11784
|
+
if (referenceStart < start || referenceStart >= end || reference.resolved === null) continue;
|
|
11785
|
+
for (const definition of reference.resolved.defs) {
|
|
11786
|
+
if (definition.type === "ImportBinding") continue;
|
|
11787
|
+
if (definition.node.type === import_utils66.AST_NODE_TYPES.VariableDeclarator && definition.node.parent.type === import_utils66.AST_NODE_TYPES.VariableDeclaration && definition.node.parent.kind !== "const") return;
|
|
11788
|
+
const [definitionStart, definitionEnd] = definition.node.range;
|
|
11789
|
+
if (definitionStart >= start && definitionEnd <= end) continue;
|
|
11790
|
+
if (definitionStart >= functionStart && definitionEnd <= functionEnd) return;
|
|
11791
|
+
}
|
|
11792
|
+
}
|
|
11793
|
+
context.report({ node, messageId: "hoistRefinedSchema" });
|
|
11794
|
+
}
|
|
11795
|
+
};
|
|
11796
|
+
}
|
|
11797
|
+
});
|
|
11798
|
+
|
|
11799
|
+
// src/rules/prefer-multi-value-zod-literal.ts
|
|
11800
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
11801
|
+
var PREFER_MULTI_VALUE_ZOD_LITERAL_DOCUMENTATION = {
|
|
11802
|
+
summary: "Use the Zod 4 multi-value literal API instead of a union of literal schemas.",
|
|
11803
|
+
rationale: "One multi-value literal expresses the same closed value domain without repeated schema wrappers.",
|
|
11804
|
+
remediation: "Replace the union with z.literal([value1, value2, ...]).",
|
|
11805
|
+
category: "maintainability",
|
|
11806
|
+
limitations: [
|
|
11807
|
+
"Bare `zod` imports are analyzed only when the rule option explicitly declares `zodMajorVersion: 4`; `zod/v4` imports are self-declaring."
|
|
11808
|
+
],
|
|
11809
|
+
examples: [
|
|
11810
|
+
{
|
|
11811
|
+
id: "multi-value",
|
|
11812
|
+
title: "Use one multi-value literal",
|
|
11813
|
+
outcome: "no-match",
|
|
11814
|
+
files: [
|
|
11815
|
+
{
|
|
11816
|
+
path: "src/schema.ts",
|
|
11817
|
+
source: "import { z } from 'zod'; export const Version = z.literal([1, 2, 3]);"
|
|
11818
|
+
}
|
|
11819
|
+
],
|
|
11820
|
+
focusPath: "src/schema.ts",
|
|
11821
|
+
expectedCount: 0,
|
|
11822
|
+
public: true
|
|
11823
|
+
},
|
|
11824
|
+
{
|
|
11825
|
+
id: "literal-union",
|
|
11826
|
+
title: "Avoid repeated literal wrappers",
|
|
11827
|
+
outcome: "match",
|
|
11828
|
+
files: [
|
|
11829
|
+
{
|
|
11830
|
+
path: "src/schema.ts",
|
|
11831
|
+
source: "import { z } from 'zod'; export const Version = z.union([z.literal(1), z.literal(2), z.literal(3)]);"
|
|
11832
|
+
}
|
|
11833
|
+
],
|
|
11834
|
+
focusPath: "src/schema.ts",
|
|
11835
|
+
expectedCount: 1,
|
|
11836
|
+
public: true
|
|
11837
|
+
}
|
|
11838
|
+
]
|
|
11839
|
+
};
|
|
11840
|
+
function memberCall(node, object, method) {
|
|
11841
|
+
return node.callee.type === import_utils67.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils67.AST_NODE_TYPES.Identifier && node.callee.object.name === object && node.callee.property.type === import_utils67.AST_NODE_TYPES.Identifier && node.callee.property.name === method;
|
|
11842
|
+
}
|
|
11843
|
+
var prefer_multi_value_zod_literal_default = createRule({
|
|
11844
|
+
name: "prefer-multi-value-zod-literal",
|
|
11845
|
+
documentation: PREFER_MULTI_VALUE_ZOD_LITERAL_DOCUMENTATION,
|
|
11846
|
+
meta: {
|
|
11847
|
+
type: "suggestion",
|
|
11848
|
+
docs: {
|
|
11849
|
+
description: "Use the Zod 4 multi-value literal API instead of a union of literal schemas."
|
|
11850
|
+
},
|
|
11851
|
+
schema: [
|
|
11852
|
+
{
|
|
11853
|
+
type: "object",
|
|
11854
|
+
additionalProperties: false,
|
|
11855
|
+
properties: {
|
|
11856
|
+
zodMajorVersion: { type: "integer", minimum: 4, maximum: 4 }
|
|
11857
|
+
}
|
|
11858
|
+
}
|
|
11859
|
+
],
|
|
11860
|
+
messages: {
|
|
11861
|
+
useMultiValueLiteral: "Replace this literal-schema union with `{{zod}}.literal([\u2026])`."
|
|
11862
|
+
}
|
|
11863
|
+
},
|
|
11864
|
+
defaultOptions: [{}],
|
|
11865
|
+
create(context, [options]) {
|
|
11866
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text))
|
|
11867
|
+
return {};
|
|
11868
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
11869
|
+
const zod4Namespaces = /* @__PURE__ */ new Set();
|
|
11870
|
+
return {
|
|
11871
|
+
ImportDeclaration(node) {
|
|
11872
|
+
if (!isZodModule(node.source.value)) return;
|
|
11873
|
+
for (const specifier of node.specifiers) {
|
|
11874
|
+
if (specifier.type === import_utils67.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils67.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils67.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils67.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
11875
|
+
namespaces.add(specifier.local.name);
|
|
11876
|
+
if (node.source.value === "zod/v4" || node.source.value.startsWith("zod/v4/"))
|
|
11877
|
+
zod4Namespaces.add(specifier.local.name);
|
|
11878
|
+
}
|
|
11879
|
+
}
|
|
11880
|
+
},
|
|
11881
|
+
CallExpression(node) {
|
|
11882
|
+
const namespace = [...namespaces].find(
|
|
11883
|
+
(name) => memberCall(node, name, "union")
|
|
11884
|
+
);
|
|
11885
|
+
if (namespace === void 0 || options?.zodMajorVersion !== 4 && !zod4Namespaces.has(namespace) || node.arguments.length !== 1)
|
|
11886
|
+
return;
|
|
11887
|
+
const [argument] = node.arguments;
|
|
11888
|
+
if (argument?.type !== import_utils67.AST_NODE_TYPES.ArrayExpression || argument.elements.length < 3 || argument.elements.some((element) => {
|
|
11889
|
+
if (element === null || element.type !== import_utils67.AST_NODE_TYPES.CallExpression || !memberCall(element, namespace, "literal") || element.arguments.length !== 1)
|
|
11890
|
+
return true;
|
|
11891
|
+
const [value] = element.arguments;
|
|
11892
|
+
return value === void 0 || value.type === import_utils67.AST_NODE_TYPES.SpreadElement || ![
|
|
11893
|
+
import_utils67.AST_NODE_TYPES.Literal,
|
|
11894
|
+
import_utils67.AST_NODE_TYPES.TemplateLiteral
|
|
11895
|
+
].includes(value.type);
|
|
11896
|
+
}))
|
|
11897
|
+
return;
|
|
11898
|
+
context.report({
|
|
11899
|
+
node,
|
|
11900
|
+
messageId: "useMultiValueLiteral",
|
|
11901
|
+
data: { zod: namespace }
|
|
11902
|
+
});
|
|
11903
|
+
}
|
|
11904
|
+
};
|
|
11905
|
+
}
|
|
11906
|
+
});
|
|
11907
|
+
|
|
11908
|
+
// src/rules/prefer-named-callback-domain.ts
|
|
11909
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
11910
|
+
var PREFER_NAMED_CALLBACK_DOMAIN_DOCUMENTATION = {
|
|
11911
|
+
summary: "Name literal-union domains used by callbacks in exported contracts.",
|
|
11912
|
+
rationale: "An inline callback domain hides a reusable vocabulary at the point where callers and implementations must agree.",
|
|
11913
|
+
remediation: "Extract the literal union to a named type and use that type in the callback parameter.",
|
|
11914
|
+
category: "maintainability",
|
|
11915
|
+
limitations: ["Only callback types nested in an exported type alias or exported interface are reported."],
|
|
11916
|
+
examples: [
|
|
11917
|
+
{ id: "named-domain", title: "Name the callback domain", outcome: "no-match", files: [{ path: "src/options.ts", source: "export type Boundary = 'seeded' | 'queued'; export interface Options { done?: (boundary: Boundary) => void; }" }], focusPath: "src/options.ts", expectedCount: 0, public: true },
|
|
11918
|
+
{ id: "inline-domain", title: "Do not inline a public callback domain", outcome: "match", files: [{ path: "src/options.ts", source: "export interface Options { done?: (boundary: 'seeded' | 'queued') => void; }" }], focusPath: "src/options.ts", expectedCount: 1, public: true }
|
|
11919
|
+
]
|
|
11920
|
+
};
|
|
11921
|
+
function isLiteralUnion(node) {
|
|
11922
|
+
return node.type === import_utils68.AST_NODE_TYPES.TSUnionType && node.types.length >= 2 && node.types.every((part) => part.type === import_utils68.AST_NODE_TYPES.TSLiteralType);
|
|
11923
|
+
}
|
|
11924
|
+
function exportedContract(node) {
|
|
11925
|
+
let current = node;
|
|
11926
|
+
while (current !== void 0) {
|
|
11927
|
+
if (current.type === import_utils68.AST_NODE_TYPES.ExportNamedDeclaration) return true;
|
|
11928
|
+
if (current.type === import_utils68.AST_NODE_TYPES.Program) return false;
|
|
11929
|
+
current = current.parent ?? void 0;
|
|
11930
|
+
}
|
|
11931
|
+
return false;
|
|
11932
|
+
}
|
|
11933
|
+
var prefer_named_callback_domain_default = createRule({
|
|
11934
|
+
name: "prefer-named-callback-domain",
|
|
11935
|
+
documentation: PREFER_NAMED_CALLBACK_DOMAIN_DOCUMENTATION,
|
|
11936
|
+
meta: {
|
|
11937
|
+
type: "suggestion",
|
|
11938
|
+
docs: { description: "Name literal-union domains used by callbacks in exported contracts." },
|
|
11939
|
+
schema: [],
|
|
11940
|
+
messages: { nameCallbackDomain: "Extract this inline callback literal union to a named domain type." }
|
|
11941
|
+
},
|
|
11942
|
+
defaultOptions: [],
|
|
11943
|
+
create(context) {
|
|
11944
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
11945
|
+
return {
|
|
11946
|
+
TSFunctionType(node) {
|
|
11947
|
+
if (!exportedContract(node)) return;
|
|
11948
|
+
for (const parameter of node.params) {
|
|
11949
|
+
if (parameter.type !== import_utils68.AST_NODE_TYPES.TSParameterProperty && parameter.typeAnnotation !== void 0 && isLiteralUnion(parameter.typeAnnotation.typeAnnotation)) {
|
|
11950
|
+
context.report({ node: parameter.typeAnnotation.typeAnnotation, messageId: "nameCallbackDomain" });
|
|
11951
|
+
}
|
|
11952
|
+
}
|
|
11953
|
+
}
|
|
11954
|
+
};
|
|
11955
|
+
}
|
|
11956
|
+
});
|
|
11957
|
+
|
|
11958
|
+
// src/rules/prefer-named-complex-return-type.ts
|
|
11959
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
11700
11960
|
var PREFER_NAMED_COMPLEX_RETURN_TYPE_DOCUMENTATION = {
|
|
11701
11961
|
summary: "Prefer a named contract for structurally complex function return types.",
|
|
11702
11962
|
rationale: "A large inline return annotation hides a reusable domain concept and makes signatures difficult to scan.",
|
|
@@ -11712,7 +11972,7 @@ var PREFER_NAMED_COMPLEX_RETURN_TYPE_DOCUMENTATION = {
|
|
|
11712
11972
|
]
|
|
11713
11973
|
};
|
|
11714
11974
|
function unwrap4(node) {
|
|
11715
|
-
if (node.type ===
|
|
11975
|
+
if (node.type === import_utils69.AST_NODE_TYPES.TSTypeReference && node.typeArguments?.params.length === 1) {
|
|
11716
11976
|
const [inner] = node.typeArguments.params;
|
|
11717
11977
|
if (inner !== void 0) return unwrap4(inner);
|
|
11718
11978
|
}
|
|
@@ -11726,9 +11986,9 @@ function report(context, node) {
|
|
|
11726
11986
|
}
|
|
11727
11987
|
function isComplex(node) {
|
|
11728
11988
|
const type = unwrap4(node);
|
|
11729
|
-
if (type.type ===
|
|
11730
|
-
if (type.type !==
|
|
11731
|
-
return type.types.every((member) => unwrap4(member).type ===
|
|
11989
|
+
if (type.type === import_utils69.AST_NODE_TYPES.TSTypeLiteral) return type.members.length >= 3;
|
|
11990
|
+
if (type.type !== import_utils69.AST_NODE_TYPES.TSUnionType || type.types.length < 3) return false;
|
|
11991
|
+
return type.types.every((member) => unwrap4(member).type === import_utils69.AST_NODE_TYPES.TSTypeLiteral);
|
|
11732
11992
|
}
|
|
11733
11993
|
var prefer_named_complex_return_type_default = createRule({
|
|
11734
11994
|
name: "prefer-named-complex-return-type",
|
|
@@ -11755,7 +12015,7 @@ var prefer_named_complex_return_type_default = createRule({
|
|
|
11755
12015
|
});
|
|
11756
12016
|
|
|
11757
12017
|
// src/rules/prefer-native-random-uuid.ts
|
|
11758
|
-
var
|
|
12018
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
11759
12019
|
var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
|
|
11760
12020
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
11761
12021
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -11769,7 +12029,7 @@ var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
|
|
|
11769
12029
|
]
|
|
11770
12030
|
};
|
|
11771
12031
|
function requireUuid(node) {
|
|
11772
|
-
return node?.type ===
|
|
12032
|
+
return node?.type === import_utils70.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils70.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === import_utils70.AST_NODE_TYPES.Literal && node.arguments[0].value === "uuid";
|
|
11773
12033
|
}
|
|
11774
12034
|
var prefer_native_random_uuid_default = createRule({
|
|
11775
12035
|
name: "prefer-native-random-uuid",
|
|
@@ -11791,7 +12051,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
11791
12051
|
const directBindings = /* @__PURE__ */ new Set();
|
|
11792
12052
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
11793
12053
|
function resolve(identifier) {
|
|
11794
|
-
return
|
|
12054
|
+
return import_utils70.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
11795
12055
|
}
|
|
11796
12056
|
function record(identifier, destination) {
|
|
11797
12057
|
const variable = resolve(identifier);
|
|
@@ -11813,37 +12073,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
11813
12073
|
ImportDeclaration(node) {
|
|
11814
12074
|
if (node.source.value !== "uuid") return;
|
|
11815
12075
|
for (const specifier of node.specifiers) {
|
|
11816
|
-
if (specifier.type ===
|
|
12076
|
+
if (specifier.type === import_utils70.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils70.AST_NODE_TYPES.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
11817
12077
|
record(specifier.local, directBindings);
|
|
11818
|
-
} else if (specifier.type ===
|
|
12078
|
+
} else if (specifier.type === import_utils70.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
11819
12079
|
record(specifier.local, namespaceBindings);
|
|
11820
12080
|
}
|
|
11821
12081
|
}
|
|
11822
12082
|
},
|
|
11823
12083
|
VariableDeclarator(node) {
|
|
11824
12084
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
11825
|
-
if (node.init?.type !==
|
|
12085
|
+
if (node.init?.type !== import_utils70.AST_NODE_TYPES.CallExpression || node.init.callee.type !== import_utils70.AST_NODE_TYPES.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
11826
12086
|
return;
|
|
11827
12087
|
}
|
|
11828
|
-
if (node.id.type ===
|
|
12088
|
+
if (node.id.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
11829
12089
|
record(node.id, namespaceBindings);
|
|
11830
12090
|
return;
|
|
11831
12091
|
}
|
|
11832
|
-
if (node.id.type !==
|
|
12092
|
+
if (node.id.type !== import_utils70.AST_NODE_TYPES.ObjectPattern) return;
|
|
11833
12093
|
for (const property of node.id.properties) {
|
|
11834
|
-
if (property.type ===
|
|
12094
|
+
if (property.type === import_utils70.AST_NODE_TYPES.Property && !property.computed && (property.key.type === import_utils70.AST_NODE_TYPES.Identifier && property.key.name === "v4" || property.key.type === import_utils70.AST_NODE_TYPES.Literal && property.key.value === "v4") && property.value.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
11835
12095
|
record(property.value, directBindings);
|
|
11836
12096
|
}
|
|
11837
12097
|
}
|
|
11838
12098
|
},
|
|
11839
12099
|
"CallExpression:exit"(node) {
|
|
11840
12100
|
if (node.arguments.length !== 0) return;
|
|
11841
|
-
if (node.callee.type ===
|
|
12101
|
+
if (node.callee.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
11842
12102
|
const variable2 = resolve(node.callee);
|
|
11843
12103
|
if (variable2 !== null && directBindings.has(variable2)) report2(node);
|
|
11844
12104
|
return;
|
|
11845
12105
|
}
|
|
11846
|
-
if (node.callee.type !==
|
|
12106
|
+
if (node.callee.type !== import_utils70.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.object.type !== import_utils70.AST_NODE_TYPES.Identifier || node.callee.property.type !== import_utils70.AST_NODE_TYPES.Identifier || node.callee.property.name !== "v4") {
|
|
11847
12107
|
return;
|
|
11848
12108
|
}
|
|
11849
12109
|
const variable = resolve(node.callee.object);
|
|
@@ -11854,7 +12114,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
11854
12114
|
});
|
|
11855
12115
|
|
|
11856
12116
|
// src/rules/prefer-node-crypto-hash.ts
|
|
11857
|
-
var
|
|
12117
|
+
var import_utils71 = require("@typescript-eslint/utils");
|
|
11858
12118
|
var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
11859
12119
|
summary: "Prefer the modern one-shot node:crypto hash API when streaming state is unnecessary.",
|
|
11860
12120
|
rationale: "A createHash-update-digest chain allocates mutable streaming state for a single in-memory value; Node's built-in hash function expresses the one-shot operation directly and can use its optimized fast path.",
|
|
@@ -11870,33 +12130,33 @@ var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
|
11870
12130
|
]
|
|
11871
12131
|
};
|
|
11872
12132
|
function memberName3(node) {
|
|
11873
|
-
if (!node.computed && node.property.type ===
|
|
11874
|
-
if (node.computed && node.property.type ===
|
|
12133
|
+
if (!node.computed && node.property.type === import_utils71.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
12134
|
+
if (node.computed && node.property.type === import_utils71.AST_NODE_TYPES.Literal && typeof node.property.value === "string") {
|
|
11875
12135
|
return node.property.value;
|
|
11876
12136
|
}
|
|
11877
12137
|
return null;
|
|
11878
12138
|
}
|
|
11879
12139
|
function isCryptoLoader(node, resolve) {
|
|
11880
|
-
if (node.type !==
|
|
12140
|
+
if (node.type !== import_utils71.AST_NODE_TYPES.CallExpression || node.arguments.length !== 1) return false;
|
|
11881
12141
|
const [argument] = node.arguments;
|
|
11882
|
-
if (argument === void 0 || argument.type ===
|
|
12142
|
+
if (argument === void 0 || argument.type === import_utils71.AST_NODE_TYPES.SpreadElement || !isCryptoSpecifier(argument)) {
|
|
11883
12143
|
return false;
|
|
11884
12144
|
}
|
|
11885
|
-
if (node.callee.type ===
|
|
12145
|
+
if (node.callee.type === import_utils71.AST_NODE_TYPES.Identifier) {
|
|
11886
12146
|
return node.callee.name === "require" && isUnshadowedBuiltinIdentifier(node.callee, resolve);
|
|
11887
12147
|
}
|
|
11888
|
-
return node.callee.type ===
|
|
12148
|
+
return node.callee.type === import_utils71.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils71.AST_NODE_TYPES.Identifier && node.callee.object.name === "process" && isUnshadowedBuiltinIdentifier(node.callee.object, resolve) && memberName3(node.callee) === "getBuiltinModule";
|
|
11889
12149
|
}
|
|
11890
12150
|
function isCryptoSpecifier(node) {
|
|
11891
|
-
return node.type ===
|
|
12151
|
+
return node.type === import_utils71.AST_NODE_TYPES.Literal && (node.value === "crypto" || node.value === "node:crypto");
|
|
11892
12152
|
}
|
|
11893
12153
|
function isUnshadowedBuiltinIdentifier(identifier, resolve) {
|
|
11894
12154
|
const variable = resolve(identifier);
|
|
11895
12155
|
return variable === null || variable.defs.length === 0;
|
|
11896
12156
|
}
|
|
11897
12157
|
function propertyName3(node) {
|
|
11898
|
-
if (!node.computed && node.key.type ===
|
|
11899
|
-
if (node.key.type ===
|
|
12158
|
+
if (!node.computed && node.key.type === import_utils71.AST_NODE_TYPES.Identifier) return node.key.name;
|
|
12159
|
+
if (node.key.type === import_utils71.AST_NODE_TYPES.Literal && typeof node.key.value === "string") {
|
|
11900
12160
|
return node.key.value;
|
|
11901
12161
|
}
|
|
11902
12162
|
return null;
|
|
@@ -11910,7 +12170,7 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
11910
12170
|
const directBindings = /* @__PURE__ */ new Set();
|
|
11911
12171
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
11912
12172
|
function resolve(identifier) {
|
|
11913
|
-
return
|
|
12173
|
+
return import_utils71.ASTUtils.findVariable(
|
|
11914
12174
|
context.sourceCode.getScope(identifier),
|
|
11915
12175
|
identifier.name
|
|
11916
12176
|
);
|
|
@@ -11923,9 +12183,9 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
11923
12183
|
ImportDeclaration(node) {
|
|
11924
12184
|
if (node.source.value !== "crypto" && node.source.value !== "node:crypto") return;
|
|
11925
12185
|
for (const specifier of node.specifiers) {
|
|
11926
|
-
if (specifier.type ===
|
|
12186
|
+
if (specifier.type === import_utils71.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils71.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
11927
12187
|
record(specifier.local, namespaceBindings);
|
|
11928
|
-
} else if (specifier.type ===
|
|
12188
|
+
} else if (specifier.type === import_utils71.AST_NODE_TYPES.ImportSpecifier && importedName5(specifier.imported) === "createHash") {
|
|
11929
12189
|
record(specifier.local, directBindings);
|
|
11930
12190
|
}
|
|
11931
12191
|
}
|
|
@@ -11934,13 +12194,13 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
11934
12194
|
if (node.parent.kind !== "const" || node.init === null || !isCryptoLoader(node.init, resolve)) {
|
|
11935
12195
|
return;
|
|
11936
12196
|
}
|
|
11937
|
-
if (node.id.type ===
|
|
12197
|
+
if (node.id.type === import_utils71.AST_NODE_TYPES.Identifier) {
|
|
11938
12198
|
record(node.id, namespaceBindings);
|
|
11939
12199
|
return;
|
|
11940
12200
|
}
|
|
11941
|
-
if (node.id.type !==
|
|
12201
|
+
if (node.id.type !== import_utils71.AST_NODE_TYPES.ObjectPattern) return;
|
|
11942
12202
|
for (const property of node.id.properties) {
|
|
11943
|
-
if (property.type ===
|
|
12203
|
+
if (property.type === import_utils71.AST_NODE_TYPES.Property && propertyName3(property) === "createHash" && property.value.type === import_utils71.AST_NODE_TYPES.Identifier) {
|
|
11944
12204
|
record(property.value, directBindings);
|
|
11945
12205
|
}
|
|
11946
12206
|
}
|
|
@@ -11948,10 +12208,10 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
11948
12208
|
CallExpression(node) {
|
|
11949
12209
|
if (!isMemberCall(node, "digest")) return;
|
|
11950
12210
|
const update = node.callee.object;
|
|
11951
|
-
if (update.type !==
|
|
12211
|
+
if (update.type !== import_utils71.AST_NODE_TYPES.CallExpression || update.arguments.length !== 1 || !isMemberCall(update, "update"))
|
|
11952
12212
|
return;
|
|
11953
12213
|
const create = update.callee.object;
|
|
11954
|
-
if (create.type !==
|
|
12214
|
+
if (create.type !== import_utils71.AST_NODE_TYPES.CallExpression || create.arguments.length !== 1 || create.arguments[0]?.type !== import_utils71.AST_NODE_TYPES.Literal || typeof create.arguments[0].value !== "string" || !isCreateHashCall(
|
|
11955
12215
|
create,
|
|
11956
12216
|
directBindings,
|
|
11957
12217
|
namespaceBindings,
|
|
@@ -11964,27 +12224,27 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
11964
12224
|
}
|
|
11965
12225
|
});
|
|
11966
12226
|
function importedName5(node) {
|
|
11967
|
-
return node.type ===
|
|
12227
|
+
return node.type === import_utils71.AST_NODE_TYPES.Identifier ? node.name : node.value;
|
|
11968
12228
|
}
|
|
11969
12229
|
function isMemberCall(node, name) {
|
|
11970
|
-
return node.callee.type ===
|
|
12230
|
+
return node.callee.type === import_utils71.AST_NODE_TYPES.MemberExpression && memberName3(node.callee) === name;
|
|
11971
12231
|
}
|
|
11972
12232
|
function isCreateHashCall(node, directBindings, namespaceBindings, resolve) {
|
|
11973
|
-
if (node.callee.type ===
|
|
12233
|
+
if (node.callee.type === import_utils71.AST_NODE_TYPES.Identifier) {
|
|
11974
12234
|
const variable2 = resolve(node.callee);
|
|
11975
12235
|
return variable2 !== null && directBindings.has(variable2);
|
|
11976
12236
|
}
|
|
11977
|
-
if (node.callee.type !==
|
|
12237
|
+
if (node.callee.type !== import_utils71.AST_NODE_TYPES.MemberExpression || memberName3(node.callee) !== "createHash") {
|
|
11978
12238
|
return false;
|
|
11979
12239
|
}
|
|
11980
12240
|
if (isCryptoLoader(node.callee.object, resolve)) return true;
|
|
11981
|
-
if (node.callee.object.type !==
|
|
12241
|
+
if (node.callee.object.type !== import_utils71.AST_NODE_TYPES.Identifier) return false;
|
|
11982
12242
|
const variable = resolve(node.callee.object);
|
|
11983
12243
|
return variable !== null && namespaceBindings.has(variable);
|
|
11984
12244
|
}
|
|
11985
12245
|
|
|
11986
12246
|
// src/rules/prefer-node-fs-promises.ts
|
|
11987
|
-
var
|
|
12247
|
+
var import_utils72 = require("@typescript-eslint/utils");
|
|
11988
12248
|
var PREFER_NODE_FS_PROMISES_DOCUMENTATION = {
|
|
11989
12249
|
summary: "Prefer promise-based Node.js filesystem APIs over synchronous calls in production modules.",
|
|
11990
12250
|
rationale: "Synchronous filesystem work blocks the event loop and can stall unrelated daemon, server, and worker tasks.",
|
|
@@ -12001,30 +12261,30 @@ var PREFER_NODE_FS_PROMISES_DOCUMENTATION = {
|
|
|
12001
12261
|
]
|
|
12002
12262
|
};
|
|
12003
12263
|
function memberName4(node) {
|
|
12004
|
-
if (!node.computed && node.property.type ===
|
|
12005
|
-
if (node.computed && node.property.type ===
|
|
12264
|
+
if (!node.computed && node.property.type === import_utils72.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
12265
|
+
if (node.computed && node.property.type === import_utils72.AST_NODE_TYPES.Literal && typeof node.property.value === "string") {
|
|
12006
12266
|
return node.property.value;
|
|
12007
12267
|
}
|
|
12008
12268
|
return null;
|
|
12009
12269
|
}
|
|
12010
12270
|
function unwrapAwait2(node) {
|
|
12011
|
-
return node.type ===
|
|
12271
|
+
return node.type === import_utils72.AST_NODE_TYPES.AwaitExpression ? node.argument : node;
|
|
12012
12272
|
}
|
|
12013
12273
|
function isFsLoader(node) {
|
|
12014
12274
|
const expression = unwrapAwait2(node);
|
|
12015
|
-
if (expression.type ===
|
|
12016
|
-
if (expression.type !==
|
|
12275
|
+
if (expression.type === import_utils72.AST_NODE_TYPES.ImportExpression) return isFsSpecifier(expression.source);
|
|
12276
|
+
if (expression.type !== import_utils72.AST_NODE_TYPES.CallExpression || expression.arguments.length !== 1) return false;
|
|
12017
12277
|
const [argument] = expression.arguments;
|
|
12018
|
-
if (argument === void 0 || argument.type ===
|
|
12019
|
-
if (expression.callee.type ===
|
|
12020
|
-
return expression.callee.type ===
|
|
12278
|
+
if (argument === void 0 || argument.type === import_utils72.AST_NODE_TYPES.SpreadElement || !isFsSpecifier(argument)) return false;
|
|
12279
|
+
if (expression.callee.type === import_utils72.AST_NODE_TYPES.Identifier) return expression.callee.name === "require";
|
|
12280
|
+
return expression.callee.type === import_utils72.AST_NODE_TYPES.MemberExpression && expression.callee.object.type === import_utils72.AST_NODE_TYPES.Identifier && expression.callee.object.name === "process" && memberName4(expression.callee) === "getBuiltinModule";
|
|
12021
12281
|
}
|
|
12022
12282
|
function isFsSpecifier(node) {
|
|
12023
|
-
return node.type ===
|
|
12283
|
+
return node.type === import_utils72.AST_NODE_TYPES.Literal && (node.value === "node:fs" || node.value === "fs");
|
|
12024
12284
|
}
|
|
12025
12285
|
function propertyName4(node) {
|
|
12026
|
-
if (!node.computed && node.key.type ===
|
|
12027
|
-
if (node.key.type ===
|
|
12286
|
+
if (!node.computed && node.key.type === import_utils72.AST_NODE_TYPES.Identifier) return node.key.name;
|
|
12287
|
+
if (node.key.type === import_utils72.AST_NODE_TYPES.Literal && typeof node.key.value === "string") return node.key.value;
|
|
12028
12288
|
return null;
|
|
12029
12289
|
}
|
|
12030
12290
|
var prefer_node_fs_promises_default = createRule({
|
|
@@ -12049,11 +12309,11 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
12049
12309
|
if (node.source.value !== "node:fs" && node.source.value !== "fs") return;
|
|
12050
12310
|
const synchronousImports = [];
|
|
12051
12311
|
for (const specifier of node.specifiers) {
|
|
12052
|
-
if (specifier.type ===
|
|
12312
|
+
if (specifier.type === import_utils72.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils72.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
12053
12313
|
namespaces.add(specifier.local.name);
|
|
12054
12314
|
continue;
|
|
12055
12315
|
}
|
|
12056
|
-
if (specifier.type ===
|
|
12316
|
+
if (specifier.type === import_utils72.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils72.AST_NODE_TYPES.Identifier && specifier.imported.name.endsWith("Sync")) synchronousImports.push(specifier.imported.name);
|
|
12057
12317
|
}
|
|
12058
12318
|
if (synchronousImports.length > 0) {
|
|
12059
12319
|
context.report({
|
|
@@ -12064,15 +12324,15 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
12064
12324
|
}
|
|
12065
12325
|
},
|
|
12066
12326
|
VariableDeclarator(node) {
|
|
12067
|
-
if (node.init === null || !isFsLoader(node.init) && (node.init.type !==
|
|
12327
|
+
if (node.init === null || !isFsLoader(node.init) && (node.init.type !== import_utils72.AST_NODE_TYPES.Identifier || !namespaces.has(node.init.name)))
|
|
12068
12328
|
return;
|
|
12069
|
-
if (node.id.type ===
|
|
12329
|
+
if (node.id.type === import_utils72.AST_NODE_TYPES.Identifier) {
|
|
12070
12330
|
namespaces.add(node.id.name);
|
|
12071
12331
|
return;
|
|
12072
12332
|
}
|
|
12073
|
-
if (node.id.type !==
|
|
12333
|
+
if (node.id.type !== import_utils72.AST_NODE_TYPES.ObjectPattern) return;
|
|
12074
12334
|
const synchronousImports = node.id.properties.flatMap((property) => {
|
|
12075
|
-
if (property.type !==
|
|
12335
|
+
if (property.type !== import_utils72.AST_NODE_TYPES.Property) return [];
|
|
12076
12336
|
const name = propertyName4(property);
|
|
12077
12337
|
return name?.endsWith("Sync") === true ? [name] : [];
|
|
12078
12338
|
});
|
|
@@ -12088,7 +12348,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
12088
12348
|
const name = memberName4(node);
|
|
12089
12349
|
if (name?.endsWith("Sync") !== true) return;
|
|
12090
12350
|
const object = unwrapAwait2(node.object);
|
|
12091
|
-
if (object.type ===
|
|
12351
|
+
if (object.type === import_utils72.AST_NODE_TYPES.Identifier && namespaces.has(object.name) || isFsLoader(object)) {
|
|
12092
12352
|
context.report({ node, messageId: "preferAsyncFs", data: { name } });
|
|
12093
12353
|
}
|
|
12094
12354
|
}
|
|
@@ -12097,7 +12357,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
12097
12357
|
});
|
|
12098
12358
|
|
|
12099
12359
|
// src/rules/prefer-non-nullable-collection.ts
|
|
12100
|
-
var
|
|
12360
|
+
var import_utils73 = require("@typescript-eslint/utils");
|
|
12101
12361
|
var PREFER_NON_NULLABLE_COLLECTION_DOCUMENTATION = {
|
|
12102
12362
|
summary: "Suggest non-null arrays only when local control flow proves the nullish state is equivalent to an empty collection.",
|
|
12103
12363
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
@@ -12113,33 +12373,33 @@ var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
|
12113
12373
|
function propertyName5(node) {
|
|
12114
12374
|
const key = node.key;
|
|
12115
12375
|
if (node.computed) return null;
|
|
12116
|
-
if (key.type ===
|
|
12117
|
-
if (key.type ===
|
|
12376
|
+
if (key.type === import_utils73.AST_NODE_TYPES.Identifier) return key.name;
|
|
12377
|
+
if (key.type === import_utils73.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
12118
12378
|
return null;
|
|
12119
12379
|
}
|
|
12120
12380
|
function isArrayType(node) {
|
|
12121
|
-
if (node.type ===
|
|
12122
|
-
return node.type ===
|
|
12381
|
+
if (node.type === import_utils73.AST_NODE_TYPES.TSArrayType) return true;
|
|
12382
|
+
return node.type === import_utils73.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils73.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
12123
12383
|
}
|
|
12124
12384
|
function nullableProperty(node) {
|
|
12125
12385
|
if (node.optional) return null;
|
|
12126
12386
|
const name = propertyName5(node);
|
|
12127
12387
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
12128
|
-
if (name === null || annotation?.type !==
|
|
12388
|
+
if (name === null || annotation?.type !== import_utils73.AST_NODE_TYPES.TSUnionType) return null;
|
|
12129
12389
|
const concrete = annotation.types.filter(
|
|
12130
|
-
(member) => member.type !==
|
|
12390
|
+
(member) => member.type !== import_utils73.AST_NODE_TYPES.TSNullKeyword && member.type !== import_utils73.AST_NODE_TYPES.TSUndefinedKeyword
|
|
12131
12391
|
);
|
|
12132
12392
|
if (concrete.length === 0 || !concrete.every(isArrayType)) return null;
|
|
12133
|
-
const acceptsNull = annotation.types.some((member) => member.type ===
|
|
12393
|
+
const acceptsNull = annotation.types.some((member) => member.type === import_utils73.AST_NODE_TYPES.TSNullKeyword);
|
|
12134
12394
|
const acceptsUndefined = annotation.types.some(
|
|
12135
|
-
(member) => member.type ===
|
|
12395
|
+
(member) => member.type === import_utils73.AST_NODE_TYPES.TSUndefinedKeyword
|
|
12136
12396
|
);
|
|
12137
12397
|
if (!acceptsNull && !acceptsUndefined) return null;
|
|
12138
12398
|
return { name, node, acceptsNull, acceptsUndefined };
|
|
12139
12399
|
}
|
|
12140
12400
|
function shapeProperties(members) {
|
|
12141
12401
|
return members.flatMap((member) => {
|
|
12142
|
-
if (member.type !==
|
|
12402
|
+
if (member.type !== import_utils73.AST_NODE_TYPES.TSPropertySignature) return [];
|
|
12143
12403
|
const property = nullableProperty(member);
|
|
12144
12404
|
return property === null ? [] : [property];
|
|
12145
12405
|
});
|
|
@@ -12147,14 +12407,14 @@ function shapeProperties(members) {
|
|
|
12147
12407
|
function typeIndex(program) {
|
|
12148
12408
|
const index = /* @__PURE__ */ new Map();
|
|
12149
12409
|
for (const statement of program.body) {
|
|
12150
|
-
const exported = statement.type ===
|
|
12410
|
+
const exported = statement.type === import_utils73.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
12151
12411
|
const declaration = exported ? statement.declaration : statement;
|
|
12152
|
-
if (declaration?.type ===
|
|
12412
|
+
if (declaration?.type === import_utils73.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
12153
12413
|
index.set(declaration.id.name, {
|
|
12154
12414
|
exported,
|
|
12155
12415
|
properties: shapeProperties(declaration.body.body)
|
|
12156
12416
|
});
|
|
12157
|
-
} else if (declaration?.type ===
|
|
12417
|
+
} else if (declaration?.type === import_utils73.AST_NODE_TYPES.TSTypeAliasDeclaration && declaration.typeAnnotation.type === import_utils73.AST_NODE_TYPES.TSTypeLiteral) {
|
|
12158
12418
|
index.set(declaration.id.name, {
|
|
12159
12419
|
exported,
|
|
12160
12420
|
properties: shapeProperties(declaration.typeAnnotation.members)
|
|
@@ -12164,42 +12424,42 @@ function typeIndex(program) {
|
|
|
12164
12424
|
return index;
|
|
12165
12425
|
}
|
|
12166
12426
|
function emptyArray(node) {
|
|
12167
|
-
return node.type ===
|
|
12427
|
+
return node.type === import_utils73.AST_NODE_TYPES.ArrayExpression && node.elements.length === 0;
|
|
12168
12428
|
}
|
|
12169
12429
|
function sameAccess(node, access) {
|
|
12170
12430
|
if (access.kind === "identifier") {
|
|
12171
|
-
return node.type ===
|
|
12431
|
+
return node.type === import_utils73.AST_NODE_TYPES.Identifier && node.name === access.name;
|
|
12172
12432
|
}
|
|
12173
|
-
return node.type ===
|
|
12433
|
+
return node.type === import_utils73.AST_NODE_TYPES.MemberExpression && !node.computed && node.object.type === import_utils73.AST_NODE_TYPES.Identifier && node.object.name === access.object && node.property.type === import_utils73.AST_NODE_TYPES.Identifier && node.property.name === access.property;
|
|
12174
12434
|
}
|
|
12175
12435
|
function isNullGuard(node, access) {
|
|
12176
|
-
if (node.type ===
|
|
12177
|
-
if (node.type !==
|
|
12436
|
+
if (node.type === import_utils73.AST_NODE_TYPES.UnaryExpression && node.operator === "!" && (sameAccess(node.argument, access) || optionalMemberLengthOf(node.argument, access))) return true;
|
|
12437
|
+
if (node.type !== import_utils73.AST_NODE_TYPES.BinaryExpression || !["==", "==="].includes(node.operator)) {
|
|
12178
12438
|
return false;
|
|
12179
12439
|
}
|
|
12180
|
-
const nullish = (value) => value.type ===
|
|
12440
|
+
const nullish = (value) => value.type === import_utils73.AST_NODE_TYPES.Literal && value.value === null || value.type === import_utils73.AST_NODE_TYPES.Identifier && value.name === "undefined";
|
|
12181
12441
|
return sameAccess(node.left, access) && nullish(node.right) || sameAccess(node.right, access) && nullish(node.left);
|
|
12182
12442
|
}
|
|
12183
12443
|
function isEmptyGuard(node, access) {
|
|
12184
|
-
if (node.type ===
|
|
12185
|
-
if (node.type !==
|
|
12444
|
+
if (node.type === import_utils73.AST_NODE_TYPES.UnaryExpression && node.operator === "!" && memberLengthOf(node.argument, access)) return true;
|
|
12445
|
+
if (node.type !== import_utils73.AST_NODE_TYPES.BinaryExpression || !["==", "===", "<="].includes(node.operator)) {
|
|
12186
12446
|
return false;
|
|
12187
12447
|
}
|
|
12188
|
-
const zero = (value) => value.type ===
|
|
12448
|
+
const zero = (value) => value.type === import_utils73.AST_NODE_TYPES.Literal && value.value === 0;
|
|
12189
12449
|
return memberLengthOf(node.left, access) && zero(node.right) || memberLengthOf(node.right, access) && zero(node.left);
|
|
12190
12450
|
}
|
|
12191
12451
|
function memberLengthOf(node, access) {
|
|
12192
|
-
const target = node.type ===
|
|
12193
|
-
return target.type ===
|
|
12452
|
+
const target = node.type === import_utils73.AST_NODE_TYPES.ChainExpression ? node.expression : node;
|
|
12453
|
+
return target.type === import_utils73.AST_NODE_TYPES.MemberExpression && !target.computed && target.property.type === import_utils73.AST_NODE_TYPES.Identifier && target.property.name === "length" && sameAccess(target.object, access);
|
|
12194
12454
|
}
|
|
12195
12455
|
function optionalMemberLengthOf(node, access) {
|
|
12196
|
-
return node.type ===
|
|
12456
|
+
return node.type === import_utils73.AST_NODE_TYPES.ChainExpression && node.expression.type === import_utils73.AST_NODE_TYPES.MemberExpression && node.expression.optional && memberLengthOf(node, access);
|
|
12197
12457
|
}
|
|
12198
12458
|
function hasEquivalentLeadingGuard(fn, access, visitorKeys) {
|
|
12199
|
-
if (fn.body.type !==
|
|
12459
|
+
if (fn.body.type !== import_utils73.AST_NODE_TYPES.BlockStatement) return false;
|
|
12200
12460
|
const first = fn.body.body[0];
|
|
12201
|
-
if (first?.type !==
|
|
12202
|
-
const terminating = first.consequent.type ===
|
|
12461
|
+
if (first?.type !== import_utils73.AST_NODE_TYPES.IfStatement) return false;
|
|
12462
|
+
const terminating = first.consequent.type === import_utils73.AST_NODE_TYPES.ReturnStatement || first.consequent.type === import_utils73.AST_NODE_TYPES.ThrowStatement || first.consequent.type === import_utils73.AST_NODE_TYPES.BlockStatement && first.consequent.body.length === 1 && (first.consequent.body[0]?.type === import_utils73.AST_NODE_TYPES.ReturnStatement || first.consequent.body[0]?.type === import_utils73.AST_NODE_TYPES.ThrowStatement);
|
|
12203
12463
|
if (!terminating) return false;
|
|
12204
12464
|
if (contains(first.consequent, visitorKeys, (node) => sameAccess(node, access))) return false;
|
|
12205
12465
|
return contains(first.test, visitorKeys, (node) => isNullGuard(node, access)) && contains(first.test, visitorKeys, (node) => isEmptyGuard(node, access));
|
|
@@ -12217,29 +12477,29 @@ function contains(node, visitorKeys, predicate) {
|
|
|
12217
12477
|
function belongsToFunction(node, fn) {
|
|
12218
12478
|
let current = node;
|
|
12219
12479
|
while (current !== void 0 && current !== fn) {
|
|
12220
|
-
if (current !== node && (current.type ===
|
|
12480
|
+
if (current !== node && (current.type === import_utils73.AST_NODE_TYPES.ArrowFunctionExpression || current.type === import_utils73.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils73.AST_NODE_TYPES.FunctionExpression)) return false;
|
|
12221
12481
|
current = current.parent;
|
|
12222
12482
|
}
|
|
12223
12483
|
return current === fn;
|
|
12224
12484
|
}
|
|
12225
12485
|
function directlyCoalesced(node) {
|
|
12226
12486
|
const parent = node.parent;
|
|
12227
|
-
return parent?.type ===
|
|
12487
|
+
return parent?.type === import_utils73.AST_NODE_TYPES.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
12228
12488
|
}
|
|
12229
12489
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
12230
|
-
const variable =
|
|
12490
|
+
const variable = import_utils73.ASTUtils.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
12231
12491
|
if (variable === null || variable.references.length === 0) return false;
|
|
12232
12492
|
return variable.references.every(
|
|
12233
12493
|
(reference) => belongsToFunction(reference.identifier, fn) && directlyCoalesced(reference.identifier)
|
|
12234
12494
|
);
|
|
12235
12495
|
}
|
|
12236
12496
|
function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
12237
|
-
const variable =
|
|
12497
|
+
const variable = import_utils73.ASTUtils.findVariable(context.sourceCode.getScope(object), object.name);
|
|
12238
12498
|
if (variable === null) return false;
|
|
12239
12499
|
const accesses = variable.references.flatMap((reference) => {
|
|
12240
12500
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
12241
12501
|
const parent = reference.identifier.parent;
|
|
12242
|
-
if (parent?.type ===
|
|
12502
|
+
if (parent?.type === import_utils73.AST_NODE_TYPES.MemberExpression && !parent.computed && parent.object === reference.identifier && parent.property.type === import_utils73.AST_NODE_TYPES.Identifier && parent.property.name === property) return [parent];
|
|
12243
12503
|
return [];
|
|
12244
12504
|
});
|
|
12245
12505
|
return accesses.length > 0 && accesses.every((access) => access !== null && directlyCoalesced(access));
|
|
@@ -12265,8 +12525,8 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
12265
12525
|
let shapes = /* @__PURE__ */ new Map();
|
|
12266
12526
|
const evidence = /* @__PURE__ */ new Map();
|
|
12267
12527
|
function propertiesFor(annotation) {
|
|
12268
|
-
if (annotation?.type ===
|
|
12269
|
-
if (annotation?.type ===
|
|
12528
|
+
if (annotation?.type === import_utils73.AST_NODE_TYPES.TSTypeLiteral) return shapeProperties(annotation.members);
|
|
12529
|
+
if (annotation?.type === import_utils73.AST_NODE_TYPES.TSTypeReference && annotation.typeName.type === import_utils73.AST_NODE_TYPES.Identifier) {
|
|
12270
12530
|
const shape = shapes.get(annotation.typeName.name);
|
|
12271
12531
|
return shape?.exported === false ? shape.properties : [];
|
|
12272
12532
|
}
|
|
@@ -12279,21 +12539,21 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
12279
12539
|
}
|
|
12280
12540
|
function checkFunction(fn) {
|
|
12281
12541
|
for (const rawParameter of fn.params) {
|
|
12282
|
-
const parameter = rawParameter.type ===
|
|
12283
|
-
if (parameter.type ===
|
|
12542
|
+
const parameter = rawParameter.type === import_utils73.AST_NODE_TYPES.AssignmentPattern ? rawParameter.left : rawParameter;
|
|
12543
|
+
if (parameter.type === import_utils73.AST_NODE_TYPES.ObjectPattern) {
|
|
12284
12544
|
const properties2 = propertiesFor(parameter.typeAnnotation?.typeAnnotation);
|
|
12285
12545
|
for (const property of properties2) {
|
|
12286
12546
|
const bindingProperty = parameter.properties.find(
|
|
12287
|
-
(entry) => entry.type ===
|
|
12547
|
+
(entry) => entry.type === import_utils73.AST_NODE_TYPES.Property && !entry.computed && entry.key.type === import_utils73.AST_NODE_TYPES.Identifier && entry.key.name === property.name
|
|
12288
12548
|
);
|
|
12289
12549
|
if (bindingProperty === void 0) continue;
|
|
12290
12550
|
const value = bindingProperty.value;
|
|
12291
|
-
const binding = value.type ===
|
|
12292
|
-
if (binding.type !==
|
|
12551
|
+
const binding = value.type === import_utils73.AST_NODE_TYPES.AssignmentPattern ? value.left : value;
|
|
12552
|
+
if (binding.type !== import_utils73.AST_NODE_TYPES.Identifier) {
|
|
12293
12553
|
record(property, false);
|
|
12294
12554
|
continue;
|
|
12295
12555
|
}
|
|
12296
|
-
if (value.type ===
|
|
12556
|
+
if (value.type === import_utils73.AST_NODE_TYPES.AssignmentPattern && emptyArray(value.right) && property.acceptsUndefined && !property.acceptsNull) {
|
|
12297
12557
|
record(property, true);
|
|
12298
12558
|
continue;
|
|
12299
12559
|
}
|
|
@@ -12305,7 +12565,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
12305
12565
|
}
|
|
12306
12566
|
continue;
|
|
12307
12567
|
}
|
|
12308
|
-
if (parameter.type !==
|
|
12568
|
+
if (parameter.type !== import_utils73.AST_NODE_TYPES.Identifier) continue;
|
|
12309
12569
|
const properties = propertiesFor(parameter.typeAnnotation?.typeAnnotation);
|
|
12310
12570
|
for (const property of properties) {
|
|
12311
12571
|
const access = {
|
|
@@ -12342,7 +12602,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
12342
12602
|
});
|
|
12343
12603
|
|
|
12344
12604
|
// src/rules/prefer-nullish-filter-predicate.ts
|
|
12345
|
-
var
|
|
12605
|
+
var import_utils74 = require("@typescript-eslint/utils");
|
|
12346
12606
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
12347
12607
|
var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
12348
12608
|
summary: "Prefer an explicit nullish predicate when `filter(Boolean)` removes only nullish values but does not narrow the result type.",
|
|
@@ -12386,7 +12646,7 @@ var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
|
12386
12646
|
]
|
|
12387
12647
|
};
|
|
12388
12648
|
function isUnshadowedBoolean(node, context) {
|
|
12389
|
-
const variable =
|
|
12649
|
+
const variable = import_utils74.ASTUtils.findVariable(context.sourceCode.getScope(node), node.name);
|
|
12390
12650
|
return variable === null || variable.defs.length === 0;
|
|
12391
12651
|
}
|
|
12392
12652
|
function isBuiltinArrayFilter(node, services) {
|
|
@@ -12445,7 +12705,7 @@ function isProvablyTruthy(type, checker) {
|
|
|
12445
12705
|
}
|
|
12446
12706
|
function availableParameterName(node, context) {
|
|
12447
12707
|
for (const name of ["value", "item", "element", "candidate"]) {
|
|
12448
|
-
if (
|
|
12708
|
+
if (import_utils74.ASTUtils.findVariable(context.sourceCode.getScope(node), name) === null) return name;
|
|
12449
12709
|
}
|
|
12450
12710
|
return null;
|
|
12451
12711
|
}
|
|
@@ -12467,7 +12727,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
12467
12727
|
if (isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
12468
12728
|
let services;
|
|
12469
12729
|
try {
|
|
12470
|
-
services =
|
|
12730
|
+
services = import_utils74.ESLintUtils.getParserServices(context);
|
|
12471
12731
|
} catch {
|
|
12472
12732
|
services = null;
|
|
12473
12733
|
}
|
|
@@ -12476,7 +12736,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
12476
12736
|
CallExpression(node) {
|
|
12477
12737
|
const callee = node.callee;
|
|
12478
12738
|
const callback = node.arguments[0];
|
|
12479
|
-
if (node.arguments.length !== 1 || callback?.type !==
|
|
12739
|
+
if (node.arguments.length !== 1 || callback?.type !== import_utils74.AST_NODE_TYPES.Identifier || callback.name !== "Boolean" || callee.type !== import_utils74.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils74.AST_NODE_TYPES.Identifier || callee.property.name !== "filter" || !isUnshadowedBoolean(callback, context) || !isBuiltinArrayFilter(callee, services)) return;
|
|
12480
12740
|
const elementType = arrayElementType(callee.object, services);
|
|
12481
12741
|
const checker = services.program.getTypeChecker();
|
|
12482
12742
|
if (elementType === null || !isNullishPlusTruthy(elementType, checker)) return;
|
|
@@ -12498,7 +12758,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
12498
12758
|
});
|
|
12499
12759
|
|
|
12500
12760
|
// src/rules/prefer-await-in-async-return.ts
|
|
12501
|
-
var
|
|
12761
|
+
var import_utils75 = require("@typescript-eslint/utils");
|
|
12502
12762
|
var ts4 = __toESM(require("typescript"), 1);
|
|
12503
12763
|
var PREFER_AWAIT_IN_ASYNC_RETURN_DOCUMENTATION = {
|
|
12504
12764
|
summary: "Prefer explicit `await` when an async function directly returns one typed Promise `.then` transform.",
|
|
@@ -12540,10 +12800,10 @@ var PREFER_AWAIT_IN_ASYNC_RETURN_DOCUMENTATION = {
|
|
|
12540
12800
|
};
|
|
12541
12801
|
function directAsyncReturnOwner(node) {
|
|
12542
12802
|
const parent = node.parent;
|
|
12543
|
-
if (parent.type ===
|
|
12803
|
+
if (parent.type === import_utils75.AST_NODE_TYPES.ArrowFunctionExpression && parent.body === node) {
|
|
12544
12804
|
return parent.async && !parent.generator ? parent : null;
|
|
12545
12805
|
}
|
|
12546
|
-
if (parent.type !==
|
|
12806
|
+
if (parent.type !== import_utils75.AST_NODE_TYPES.ReturnStatement || parent.argument !== node) {
|
|
12547
12807
|
return null;
|
|
12548
12808
|
}
|
|
12549
12809
|
let owner = parent.parent;
|
|
@@ -12553,15 +12813,15 @@ function directAsyncReturnOwner(node) {
|
|
|
12553
12813
|
return owner !== void 0 && owner.async && !owner.generator ? owner : null;
|
|
12554
12814
|
}
|
|
12555
12815
|
function isRuntimeFunction(node) {
|
|
12556
|
-
return node.type ===
|
|
12816
|
+
return node.type === import_utils75.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils75.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils75.AST_NODE_TYPES.FunctionExpression;
|
|
12557
12817
|
}
|
|
12558
12818
|
function promiseThenReceiver(node) {
|
|
12559
12819
|
const callee = node.callee;
|
|
12560
|
-
if (callee.type !==
|
|
12820
|
+
if (callee.type !== import_utils75.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.property.type !== import_utils75.AST_NODE_TYPES.Identifier || callee.property.name !== "then" || node.optional || node.arguments.length !== 1) {
|
|
12561
12821
|
return null;
|
|
12562
12822
|
}
|
|
12563
12823
|
const callback = node.arguments[0];
|
|
12564
|
-
if (callback === void 0 || callback.type !==
|
|
12824
|
+
if (callback === void 0 || callback.type !== import_utils75.AST_NODE_TYPES.ArrowFunctionExpression && callback.type !== import_utils75.AST_NODE_TYPES.FunctionExpression) {
|
|
12565
12825
|
return null;
|
|
12566
12826
|
}
|
|
12567
12827
|
return callee.object;
|
|
@@ -12602,32 +12862,32 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
12602
12862
|
create(context) {
|
|
12603
12863
|
let services;
|
|
12604
12864
|
try {
|
|
12605
|
-
services =
|
|
12865
|
+
services = import_utils75.ESLintUtils.getParserServices(context);
|
|
12606
12866
|
} catch {
|
|
12607
12867
|
services = null;
|
|
12608
12868
|
}
|
|
12609
12869
|
if (services === null) return {};
|
|
12610
12870
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
12611
12871
|
const rememberFrameworkLoader = (identifier) => {
|
|
12612
|
-
const variable =
|
|
12872
|
+
const variable = import_utils75.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
12613
12873
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
12614
12874
|
};
|
|
12615
12875
|
const isFrameworkLoaderCallback = (owner) => {
|
|
12616
12876
|
const parent = owner.parent;
|
|
12617
|
-
if (parent.type !==
|
|
12618
|
-
const variable =
|
|
12877
|
+
if (parent.type !== import_utils75.AST_NODE_TYPES.CallExpression || parent.arguments[0] !== owner || parent.callee.type !== import_utils75.AST_NODE_TYPES.Identifier) return false;
|
|
12878
|
+
const variable = import_utils75.ASTUtils.findVariable(context.sourceCode.getScope(parent.callee), parent.callee.name);
|
|
12619
12879
|
return variable !== null && frameworkLoaders.has(variable);
|
|
12620
12880
|
};
|
|
12621
12881
|
return {
|
|
12622
12882
|
ImportDeclaration(node) {
|
|
12623
12883
|
if (node.source.value === "react") {
|
|
12624
12884
|
for (const specifier of node.specifiers) {
|
|
12625
|
-
if (specifier.type ===
|
|
12885
|
+
if (specifier.type === import_utils75.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils75.AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value) === "lazy") rememberFrameworkLoader(specifier.local);
|
|
12626
12886
|
}
|
|
12627
12887
|
}
|
|
12628
12888
|
if (node.source.value === "next/dynamic") {
|
|
12629
12889
|
for (const specifier of node.specifiers) {
|
|
12630
|
-
if (specifier.type ===
|
|
12890
|
+
if (specifier.type === import_utils75.AST_NODE_TYPES.ImportDefaultSpecifier) rememberFrameworkLoader(specifier.local);
|
|
12631
12891
|
}
|
|
12632
12892
|
}
|
|
12633
12893
|
},
|
|
@@ -12645,7 +12905,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
12645
12905
|
});
|
|
12646
12906
|
|
|
12647
12907
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
12648
|
-
var
|
|
12908
|
+
var import_utils76 = require("@typescript-eslint/utils");
|
|
12649
12909
|
var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
12650
12910
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
12651
12911
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -12660,9 +12920,9 @@ var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
|
12660
12920
|
var unwrap5 = (node) => {
|
|
12661
12921
|
let current = node;
|
|
12662
12922
|
while (current !== null && current !== void 0) {
|
|
12663
|
-
if (current.type ===
|
|
12923
|
+
if (current.type === import_utils76.AST_NODE_TYPES.TSAsExpression || current.type === import_utils76.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils76.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils76.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
12664
12924
|
current = current.expression;
|
|
12665
|
-
} else if (current.type ===
|
|
12925
|
+
} else if (current.type === import_utils76.AST_NODE_TYPES.ChainExpression) {
|
|
12666
12926
|
current = current.expression;
|
|
12667
12927
|
} else {
|
|
12668
12928
|
break;
|
|
@@ -12677,23 +12937,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
12677
12937
|
]);
|
|
12678
12938
|
var isSchemaParseReference = (node) => {
|
|
12679
12939
|
const inner = unwrap5(node);
|
|
12680
|
-
return inner !== null && inner.type ===
|
|
12940
|
+
return inner !== null && inner.type === import_utils76.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils76.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
12681
12941
|
};
|
|
12682
12942
|
var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
12683
12943
|
let current = unwrap5(node);
|
|
12684
12944
|
if (current === null) return false;
|
|
12685
|
-
if (current.type ===
|
|
12945
|
+
if (current.type === import_utils76.AST_NODE_TYPES.AwaitExpression) {
|
|
12686
12946
|
current = unwrap5(current.argument);
|
|
12687
12947
|
}
|
|
12688
|
-
if (current === null || current.type !==
|
|
12948
|
+
if (current === null || current.type !== import_utils76.AST_NODE_TYPES.CallExpression) {
|
|
12689
12949
|
return false;
|
|
12690
12950
|
}
|
|
12691
12951
|
const callee = unwrap5(current.callee);
|
|
12692
|
-
if (callee === null || callee.type !==
|
|
12952
|
+
if (callee === null || callee.type !== import_utils76.AST_NODE_TYPES.MemberExpression) {
|
|
12693
12953
|
return false;
|
|
12694
12954
|
}
|
|
12695
12955
|
const property = unwrap5(callee.property);
|
|
12696
|
-
if (property === null || property.type !==
|
|
12956
|
+
if (property === null || property.type !== import_utils76.AST_NODE_TYPES.Identifier) {
|
|
12697
12957
|
return false;
|
|
12698
12958
|
}
|
|
12699
12959
|
if (property.name === "json") {
|
|
@@ -12703,17 +12963,17 @@ var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
|
12703
12963
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
12704
12964
|
}
|
|
12705
12965
|
const object = unwrap5(callee.object);
|
|
12706
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
12966
|
+
return property.name === "parse" && object !== null && object.type === import_utils76.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
12707
12967
|
};
|
|
12708
12968
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
12709
12969
|
var isDirectLocalFileRead = (node) => {
|
|
12710
12970
|
let current = unwrap5(node);
|
|
12711
|
-
if (current?.type ===
|
|
12971
|
+
if (current?.type === import_utils76.AST_NODE_TYPES.AwaitExpression) {
|
|
12712
12972
|
current = unwrap5(current.argument);
|
|
12713
12973
|
}
|
|
12714
|
-
if (current?.type !==
|
|
12974
|
+
if (current?.type !== import_utils76.AST_NODE_TYPES.CallExpression) return false;
|
|
12715
12975
|
const callee = unwrap5(current.callee);
|
|
12716
|
-
const name = callee?.type ===
|
|
12976
|
+
const name = callee?.type === import_utils76.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils76.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils76.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
12717
12977
|
return name !== null && FILE_READ_RE.test(name);
|
|
12718
12978
|
};
|
|
12719
12979
|
var isLocalFileRead = (node) => {
|
|
@@ -12740,15 +13000,15 @@ var isLocalFileRead = (node) => {
|
|
|
12740
13000
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
12741
13001
|
var isInsideAssertion = (node) => {
|
|
12742
13002
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12743
|
-
if (current.type !==
|
|
13003
|
+
if (current.type !== import_utils76.AST_NODE_TYPES.CallExpression) continue;
|
|
12744
13004
|
let callee = current.callee;
|
|
12745
|
-
while (callee.type ===
|
|
13005
|
+
while (callee.type === import_utils76.AST_NODE_TYPES.MemberExpression) {
|
|
12746
13006
|
callee = callee.object;
|
|
12747
13007
|
}
|
|
12748
|
-
if (callee.type ===
|
|
13008
|
+
if (callee.type === import_utils76.AST_NODE_TYPES.CallExpression) {
|
|
12749
13009
|
callee = callee.callee;
|
|
12750
13010
|
}
|
|
12751
|
-
if (callee.type ===
|
|
13011
|
+
if (callee.type === import_utils76.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
12752
13012
|
return true;
|
|
12753
13013
|
}
|
|
12754
13014
|
}
|
|
@@ -12767,22 +13027,22 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
12767
13027
|
var isValidationRead = (node) => {
|
|
12768
13028
|
let current = node;
|
|
12769
13029
|
let parent = current.parent;
|
|
12770
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
13030
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils76.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils76.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils76.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils76.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils76.AST_NODE_TYPES.ChainExpression)) {
|
|
12771
13031
|
current = parent;
|
|
12772
13032
|
parent = parent.parent;
|
|
12773
13033
|
}
|
|
12774
13034
|
if (parent === null || parent === void 0) return false;
|
|
12775
|
-
if (parent.type ===
|
|
13035
|
+
if (parent.type === import_utils76.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
12776
13036
|
return true;
|
|
12777
13037
|
}
|
|
12778
|
-
if (parent.type !==
|
|
13038
|
+
if (parent.type !== import_utils76.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
12779
13039
|
return false;
|
|
12780
13040
|
}
|
|
12781
13041
|
const callee = parent.callee;
|
|
12782
|
-
if (callee.type ===
|
|
13042
|
+
if (callee.type === import_utils76.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils76.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils76.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
12783
13043
|
return parent.arguments.length === 1;
|
|
12784
13044
|
}
|
|
12785
|
-
return callee.type ===
|
|
13045
|
+
return callee.type === import_utils76.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
12786
13046
|
};
|
|
12787
13047
|
var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
12788
13048
|
"bigint",
|
|
@@ -12793,13 +13053,13 @@ var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
|
12793
13053
|
"undefined"
|
|
12794
13054
|
]);
|
|
12795
13055
|
var bindingValidationPolarity = (test, bindingName) => {
|
|
12796
|
-
if (test.type ===
|
|
13056
|
+
if (test.type === import_utils76.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
12797
13057
|
const inner = bindingValidationPolarity(test.argument, bindingName);
|
|
12798
13058
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
12799
13059
|
}
|
|
12800
|
-
if (test.type ===
|
|
12801
|
-
const typeofName = (node) => node.type ===
|
|
12802
|
-
const literalType = (node) => node.type ===
|
|
13060
|
+
if (test.type === import_utils76.AST_NODE_TYPES.BinaryExpression) {
|
|
13061
|
+
const typeofName = (node) => node.type === import_utils76.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && node.argument.type === import_utils76.AST_NODE_TYPES.Identifier ? node.argument.name : null;
|
|
13062
|
+
const literalType = (node) => node.type === import_utils76.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value) ? node.value : null;
|
|
12803
13063
|
const matches = typeofName(test.left) === bindingName && literalType(test.right) !== null || typeofName(test.right) === bindingName && literalType(test.left) !== null;
|
|
12804
13064
|
if (!matches) return null;
|
|
12805
13065
|
if (test.operator === "===" || test.operator === "==") {
|
|
@@ -12807,9 +13067,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
12807
13067
|
}
|
|
12808
13068
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
12809
13069
|
}
|
|
12810
|
-
return test.type ===
|
|
13070
|
+
return test.type === import_utils76.AST_NODE_TYPES.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === import_utils76.AST_NODE_TYPES.Identifier && test.arguments[0].name === bindingName && test.callee.type === import_utils76.AST_NODE_TYPES.MemberExpression && !test.callee.computed && test.callee.object.type === import_utils76.AST_NODE_TYPES.Identifier && test.callee.object.name === "Array" && test.callee.property.type === import_utils76.AST_NODE_TYPES.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
12811
13071
|
};
|
|
12812
|
-
var plainMemberAccess = (node) => node.type ===
|
|
13072
|
+
var plainMemberAccess = (node) => node.type === import_utils76.AST_NODE_TYPES.MemberExpression && !node.computed && node.object.type === import_utils76.AST_NODE_TYPES.Identifier && node.property.type === import_utils76.AST_NODE_TYPES.Identifier ? { object: node.object.name, property: node.property.name } : null;
|
|
12813
13073
|
var isSamePlainMember = (node, access) => {
|
|
12814
13074
|
const candidate2 = plainMemberAccess(node);
|
|
12815
13075
|
return candidate2 !== null && candidate2.object === access.object && candidate2.property === access.property;
|
|
@@ -12817,19 +13077,19 @@ var isSamePlainMember = (node, access) => {
|
|
|
12817
13077
|
var nodeWithin2 = (node, container) => node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
12818
13078
|
var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
12819
13079
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12820
|
-
if (current.type ===
|
|
13080
|
+
if (current.type === import_utils76.AST_NODE_TYPES.ConditionalExpression) {
|
|
12821
13081
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
12822
13082
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
12823
13083
|
return true;
|
|
12824
13084
|
}
|
|
12825
13085
|
}
|
|
12826
|
-
if (current.type ===
|
|
13086
|
+
if (current.type === import_utils76.AST_NODE_TYPES.IfStatement) {
|
|
12827
13087
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
12828
13088
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
12829
13089
|
return true;
|
|
12830
13090
|
}
|
|
12831
13091
|
}
|
|
12832
|
-
if (current.type ===
|
|
13092
|
+
if (current.type === import_utils76.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils76.AST_NODE_TYPES.FunctionExpression || current.type === import_utils76.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
12833
13093
|
return false;
|
|
12834
13094
|
}
|
|
12835
13095
|
}
|
|
@@ -12837,32 +13097,32 @@ var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
|
12837
13097
|
};
|
|
12838
13098
|
var isMemberUseWithinValidatedBranch = (node, access) => {
|
|
12839
13099
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12840
|
-
if (current.type ===
|
|
13100
|
+
if (current.type === import_utils76.AST_NODE_TYPES.ConditionalExpression) {
|
|
12841
13101
|
const polarity = memberValidationPolarity(current.test, access);
|
|
12842
13102
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
12843
13103
|
return true;
|
|
12844
13104
|
}
|
|
12845
13105
|
}
|
|
12846
|
-
if (current.type ===
|
|
13106
|
+
if (current.type === import_utils76.AST_NODE_TYPES.IfStatement) {
|
|
12847
13107
|
const polarity = memberValidationPolarity(current.test, access);
|
|
12848
13108
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
12849
13109
|
return true;
|
|
12850
13110
|
}
|
|
12851
13111
|
}
|
|
12852
|
-
if (current.type ===
|
|
13112
|
+
if (current.type === import_utils76.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils76.AST_NODE_TYPES.FunctionExpression || current.type === import_utils76.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
12853
13113
|
return false;
|
|
12854
13114
|
}
|
|
12855
13115
|
}
|
|
12856
13116
|
return false;
|
|
12857
13117
|
};
|
|
12858
13118
|
var memberValidationPolarity = (test, access) => {
|
|
12859
|
-
if (test.type ===
|
|
13119
|
+
if (test.type === import_utils76.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
12860
13120
|
const inner = memberValidationPolarity(test.argument, access);
|
|
12861
13121
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
12862
13122
|
}
|
|
12863
|
-
if (test.type ===
|
|
12864
|
-
const isMatchingTypeof = (node) => node.type ===
|
|
12865
|
-
const isPrimitiveType = (node) => node.type ===
|
|
13123
|
+
if (test.type === import_utils76.AST_NODE_TYPES.BinaryExpression) {
|
|
13124
|
+
const isMatchingTypeof = (node) => node.type === import_utils76.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && isSamePlainMember(node.argument, access);
|
|
13125
|
+
const isPrimitiveType = (node) => node.type === import_utils76.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value);
|
|
12866
13126
|
if (!(isMatchingTypeof(test.left) && isPrimitiveType(test.right) || isMatchingTypeof(test.right) && isPrimitiveType(test.left))) {
|
|
12867
13127
|
return null;
|
|
12868
13128
|
}
|
|
@@ -12871,15 +13131,15 @@ var memberValidationPolarity = (test, access) => {
|
|
|
12871
13131
|
}
|
|
12872
13132
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
12873
13133
|
}
|
|
12874
|
-
return test.type ===
|
|
13134
|
+
return test.type === import_utils76.AST_NODE_TYPES.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== import_utils76.AST_NODE_TYPES.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === import_utils76.AST_NODE_TYPES.MemberExpression && !test.callee.computed && test.callee.object.type === import_utils76.AST_NODE_TYPES.Identifier && test.callee.object.name === "Array" && test.callee.property.type === import_utils76.AST_NODE_TYPES.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
12875
13135
|
};
|
|
12876
13136
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
12877
13137
|
const isValidationReference = (identifier) => {
|
|
12878
13138
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12879
|
-
if ((current.type ===
|
|
13139
|
+
if ((current.type === import_utils76.AST_NODE_TYPES.BinaryExpression || current.type === import_utils76.AST_NODE_TYPES.CallExpression || current.type === import_utils76.AST_NODE_TYPES.UnaryExpression) && bindingValidationPolarity(current, identifier.name) !== null) {
|
|
12880
13140
|
return true;
|
|
12881
13141
|
}
|
|
12882
|
-
if (current.type !==
|
|
13142
|
+
if (current.type !== import_utils76.AST_NODE_TYPES.UnaryExpression && current.type !== import_utils76.AST_NODE_TYPES.MemberExpression && current.type !== import_utils76.AST_NODE_TYPES.CallExpression) {
|
|
12883
13143
|
return false;
|
|
12884
13144
|
}
|
|
12885
13145
|
}
|
|
@@ -12887,7 +13147,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12887
13147
|
};
|
|
12888
13148
|
const isGuardedUse = (identifier) => {
|
|
12889
13149
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12890
|
-
if (current.type ===
|
|
13150
|
+
if (current.type === import_utils76.AST_NODE_TYPES.ConditionalExpression) {
|
|
12891
13151
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
12892
13152
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
12893
13153
|
return true;
|
|
@@ -12896,7 +13156,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12896
13156
|
return true;
|
|
12897
13157
|
}
|
|
12898
13158
|
}
|
|
12899
|
-
if (current.type ===
|
|
13159
|
+
if (current.type === import_utils76.AST_NODE_TYPES.IfStatement) {
|
|
12900
13160
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
12901
13161
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
12902
13162
|
return true;
|
|
@@ -12905,14 +13165,14 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12905
13165
|
return true;
|
|
12906
13166
|
}
|
|
12907
13167
|
}
|
|
12908
|
-
if (current.type ===
|
|
13168
|
+
if (current.type === import_utils76.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils76.AST_NODE_TYPES.FunctionExpression || current.type === import_utils76.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
12909
13169
|
return false;
|
|
12910
13170
|
}
|
|
12911
13171
|
}
|
|
12912
13172
|
return false;
|
|
12913
13173
|
};
|
|
12914
13174
|
const declarator = member.parent;
|
|
12915
|
-
if (declarator.type !==
|
|
13175
|
+
if (declarator.type !== import_utils76.AST_NODE_TYPES.VariableDeclarator || declarator.init !== member || declarator.id.type !== import_utils76.AST_NODE_TYPES.Identifier || declarator.parent.type !== import_utils76.AST_NODE_TYPES.VariableDeclaration || declarator.parent.kind !== "const") {
|
|
12916
13176
|
return false;
|
|
12917
13177
|
}
|
|
12918
13178
|
const extracted = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -12920,7 +13180,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12920
13180
|
let hasValueUse = false;
|
|
12921
13181
|
for (const reference of extracted.references) {
|
|
12922
13182
|
const identifier = reference.identifier;
|
|
12923
|
-
if (identifier.type !==
|
|
13183
|
+
if (identifier.type !== import_utils76.AST_NODE_TYPES.Identifier) return false;
|
|
12924
13184
|
if (nodeWithin2(identifier, declarator)) continue;
|
|
12925
13185
|
if (isValidationReference(identifier)) continue;
|
|
12926
13186
|
hasValueUse = true;
|
|
@@ -12933,17 +13193,17 @@ var isGuardTestPosition = (node) => {
|
|
|
12933
13193
|
let parent = current.parent;
|
|
12934
13194
|
while (parent !== void 0 && parent !== null) {
|
|
12935
13195
|
switch (parent.type) {
|
|
12936
|
-
case
|
|
12937
|
-
case
|
|
12938
|
-
case
|
|
13196
|
+
case import_utils76.AST_NODE_TYPES.UnaryExpression:
|
|
13197
|
+
case import_utils76.AST_NODE_TYPES.LogicalExpression:
|
|
13198
|
+
case import_utils76.AST_NODE_TYPES.ChainExpression:
|
|
12939
13199
|
current = parent;
|
|
12940
13200
|
parent = parent.parent;
|
|
12941
13201
|
continue;
|
|
12942
|
-
case
|
|
12943
|
-
case
|
|
12944
|
-
case
|
|
12945
|
-
case
|
|
12946
|
-
case
|
|
13202
|
+
case import_utils76.AST_NODE_TYPES.IfStatement:
|
|
13203
|
+
case import_utils76.AST_NODE_TYPES.ConditionalExpression:
|
|
13204
|
+
case import_utils76.AST_NODE_TYPES.WhileStatement:
|
|
13205
|
+
case import_utils76.AST_NODE_TYPES.DoWhileStatement:
|
|
13206
|
+
case import_utils76.AST_NODE_TYPES.ForStatement:
|
|
12947
13207
|
return parent.test === current;
|
|
12948
13208
|
default:
|
|
12949
13209
|
return false;
|
|
@@ -12953,7 +13213,7 @@ var isGuardTestPosition = (node) => {
|
|
|
12953
13213
|
};
|
|
12954
13214
|
var unvalidatedVariableRef = (node, scope, tracked) => {
|
|
12955
13215
|
const unwrapped = unwrap5(node);
|
|
12956
|
-
if (unwrapped === null || unwrapped.type !==
|
|
13216
|
+
if (unwrapped === null || unwrapped.type !== import_utils76.AST_NODE_TYPES.Identifier) {
|
|
12957
13217
|
return null;
|
|
12958
13218
|
}
|
|
12959
13219
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -12982,7 +13242,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12982
13242
|
const localFileTextVariables = /* @__PURE__ */ new Set();
|
|
12983
13243
|
const localFileTextRef = (node, scope) => {
|
|
12984
13244
|
const unwrapped = unwrap5(node);
|
|
12985
|
-
if (unwrapped?.type !==
|
|
13245
|
+
if (unwrapped?.type !== import_utils76.AST_NODE_TYPES.Identifier) return null;
|
|
12986
13246
|
const variable = findVariable2(scope, unwrapped.name);
|
|
12987
13247
|
return variable !== null && localFileTextVariables.has(variable) ? variable : null;
|
|
12988
13248
|
};
|
|
@@ -13051,7 +13311,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
13051
13311
|
return {
|
|
13052
13312
|
VariableDeclarator(node) {
|
|
13053
13313
|
const scope = context.sourceCode.getScope(node);
|
|
13054
|
-
if (node.id.type ===
|
|
13314
|
+
if (node.id.type === import_utils76.AST_NODE_TYPES.Identifier) {
|
|
13055
13315
|
const variable = context.sourceCode.getDeclaredVariables(node)[0];
|
|
13056
13316
|
if (variable !== void 0) {
|
|
13057
13317
|
updateLocalFileText(variable, node.init, scope);
|
|
@@ -13059,7 +13319,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
13059
13319
|
trackInitializer(node, scope);
|
|
13060
13320
|
return;
|
|
13061
13321
|
}
|
|
13062
|
-
if (node.id.type ===
|
|
13322
|
+
if (node.id.type === import_utils76.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils76.AST_NODE_TYPES.ArrayPattern) {
|
|
13063
13323
|
if (isRawPayloadSource(
|
|
13064
13324
|
node.init,
|
|
13065
13325
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
@@ -13076,7 +13336,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
13076
13336
|
},
|
|
13077
13337
|
AssignmentExpression(node) {
|
|
13078
13338
|
const scope = context.sourceCode.getScope(node);
|
|
13079
|
-
if (node.left.type ===
|
|
13339
|
+
if (node.left.type === import_utils76.AST_NODE_TYPES.Identifier) {
|
|
13080
13340
|
const variable = findVariable2(scope, node.left.name);
|
|
13081
13341
|
if (variable === null) return;
|
|
13082
13342
|
const isLocalText = (candidate2) => localFileTextRef(candidate2, scope) !== null;
|
|
@@ -13090,7 +13350,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
13090
13350
|
}
|
|
13091
13351
|
return;
|
|
13092
13352
|
}
|
|
13093
|
-
if (node.left.type ===
|
|
13353
|
+
if (node.left.type === import_utils76.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils76.AST_NODE_TYPES.ArrayPattern) {
|
|
13094
13354
|
if (isRawPayloadSource(
|
|
13095
13355
|
node.right,
|
|
13096
13356
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
@@ -13110,15 +13370,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
13110
13370
|
}
|
|
13111
13371
|
},
|
|
13112
13372
|
CallExpression(node) {
|
|
13113
|
-
if (node.callee.type !==
|
|
13373
|
+
if (node.callee.type !== import_utils76.AST_NODE_TYPES.Identifier) return;
|
|
13114
13374
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
13115
13375
|
return;
|
|
13116
13376
|
}
|
|
13117
13377
|
const scope = context.sourceCode.getScope(node);
|
|
13118
13378
|
for (const arg of node.arguments) {
|
|
13119
|
-
if (arg.type ===
|
|
13379
|
+
if (arg.type === import_utils76.AST_NODE_TYPES.SpreadElement) continue;
|
|
13120
13380
|
const unwrapped = unwrap5(arg);
|
|
13121
|
-
if (unwrapped === null || unwrapped.type !==
|
|
13381
|
+
if (unwrapped === null || unwrapped.type !== import_utils76.AST_NODE_TYPES.Identifier) {
|
|
13122
13382
|
continue;
|
|
13123
13383
|
}
|
|
13124
13384
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -13135,14 +13395,14 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
13135
13395
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
13136
13396
|
)) {
|
|
13137
13397
|
const parent = node.parent;
|
|
13138
|
-
if (parent.type ===
|
|
13398
|
+
if (parent.type === import_utils76.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils76.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
13139
13399
|
return;
|
|
13140
13400
|
}
|
|
13141
13401
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
13142
13402
|
return;
|
|
13143
13403
|
}
|
|
13144
|
-
const variable = obj?.type ===
|
|
13145
|
-
if (variable !== null && obj?.type ===
|
|
13404
|
+
const variable = obj?.type === import_utils76.AST_NODE_TYPES.Identifier ? unvalidatedVariableRef(obj, scope, unvalidatedVariables) : null;
|
|
13405
|
+
if (variable !== null && obj?.type === import_utils76.AST_NODE_TYPES.Identifier) {
|
|
13146
13406
|
if (isUseWithinValidatedBranch(node, obj.name)) {
|
|
13147
13407
|
return;
|
|
13148
13408
|
}
|
|
@@ -13162,7 +13422,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
13162
13422
|
});
|
|
13163
13423
|
|
|
13164
13424
|
// src/rules/prefer-shared-zod-enum.ts
|
|
13165
|
-
var
|
|
13425
|
+
var import_utils77 = require("@typescript-eslint/utils");
|
|
13166
13426
|
var PREFER_SHARED_ZOD_ENUM_DOCUMENTATION = {
|
|
13167
13427
|
summary: "Give literal Zod enum domains one reusable module-level schema.",
|
|
13168
13428
|
rationale: "Inline or repeated literal domains hide a reusable contract and allow equivalent fields to drift independently.",
|
|
@@ -13176,24 +13436,24 @@ var PREFER_SHARED_ZOD_ENUM_DOCUMENTATION = {
|
|
|
13176
13436
|
};
|
|
13177
13437
|
function literalDomain(node) {
|
|
13178
13438
|
const [argument] = node.arguments;
|
|
13179
|
-
if (argument?.type !==
|
|
13439
|
+
if (argument?.type !== import_utils77.AST_NODE_TYPES.ArrayExpression || argument.elements.length < 2) return null;
|
|
13180
13440
|
const values = [];
|
|
13181
13441
|
for (const element of argument.elements) {
|
|
13182
|
-
if (element?.type !==
|
|
13442
|
+
if (element?.type !== import_utils77.AST_NODE_TYPES.Literal || typeof element.value !== "string") return null;
|
|
13183
13443
|
values.push(element.value);
|
|
13184
13444
|
}
|
|
13185
13445
|
return values;
|
|
13186
13446
|
}
|
|
13187
13447
|
function isModuleLevelNamedSchema(node) {
|
|
13188
13448
|
let current = node;
|
|
13189
|
-
while (current.parent?.type ===
|
|
13449
|
+
while (current.parent?.type === import_utils77.AST_NODE_TYPES.MemberExpression && current.parent.object === current) {
|
|
13190
13450
|
current = current.parent;
|
|
13191
|
-
if (current.parent?.type ===
|
|
13451
|
+
if (current.parent?.type === import_utils77.AST_NODE_TYPES.CallExpression && current.parent.callee === current) current = current.parent;
|
|
13192
13452
|
}
|
|
13193
13453
|
const declarator = current.parent;
|
|
13194
|
-
if (declarator?.type !==
|
|
13454
|
+
if (declarator?.type !== import_utils77.AST_NODE_TYPES.VariableDeclarator || declarator.init !== current || declarator.id.type !== import_utils77.AST_NODE_TYPES.Identifier || declarator.parent.type !== import_utils77.AST_NODE_TYPES.VariableDeclaration) return false;
|
|
13195
13455
|
const declarationParent = declarator.parent.parent;
|
|
13196
|
-
return declarationParent.type ===
|
|
13456
|
+
return declarationParent.type === import_utils77.AST_NODE_TYPES.Program || declarationParent.type === import_utils77.AST_NODE_TYPES.ExportNamedDeclaration && declarationParent.parent.type === import_utils77.AST_NODE_TYPES.Program;
|
|
13197
13457
|
}
|
|
13198
13458
|
var prefer_shared_zod_enum_default = createRule({
|
|
13199
13459
|
name: "prefer-shared-zod-enum",
|
|
@@ -13215,11 +13475,11 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
13215
13475
|
ImportDeclaration(node) {
|
|
13216
13476
|
if (!isZodModule(node.source.value)) return;
|
|
13217
13477
|
for (const specifier of node.specifiers) {
|
|
13218
|
-
if (specifier.type ===
|
|
13478
|
+
if (specifier.type === import_utils77.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils77.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils77.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils77.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") zodBindings.add(specifier.local.name);
|
|
13219
13479
|
}
|
|
13220
13480
|
},
|
|
13221
13481
|
CallExpression(node) {
|
|
13222
|
-
if (node.callee.type !==
|
|
13482
|
+
if (node.callee.type !== import_utils77.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.object.type !== import_utils77.AST_NODE_TYPES.Identifier || !zodBindings.has(node.callee.object.name) || node.callee.property.type !== import_utils77.AST_NODE_TYPES.Identifier || node.callee.property.name !== "enum") return;
|
|
13223
13483
|
const domain = literalDomain(node);
|
|
13224
13484
|
if (domain === null) return;
|
|
13225
13485
|
const key = JSON.stringify(domain);
|
|
@@ -13233,7 +13493,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
13233
13493
|
});
|
|
13234
13494
|
|
|
13235
13495
|
// src/rules/prefer-switch-for-repeated-equality.ts
|
|
13236
|
-
var
|
|
13496
|
+
var import_utils78 = require("@typescript-eslint/utils");
|
|
13237
13497
|
var PREFER_SWITCH_FOR_REPEATED_EQUALITY_DOCUMENTATION = {
|
|
13238
13498
|
summary: "Prefer switch over long if/else-if chains that compare one value for strict equality.",
|
|
13239
13499
|
rationale: "A switch makes finite dispatch cases visually uniform and easier to extend without duplicating the discriminant.",
|
|
@@ -13250,17 +13510,17 @@ var PREFER_SWITCH_FOR_REPEATED_EQUALITY_DOCUMENTATION = {
|
|
|
13250
13510
|
]
|
|
13251
13511
|
};
|
|
13252
13512
|
function discriminantText(sourceCode, test) {
|
|
13253
|
-
if (test.type !==
|
|
13513
|
+
if (test.type !== import_utils78.AST_NODE_TYPES.BinaryExpression || test.operator !== "===") return null;
|
|
13254
13514
|
const leftIsCase = isCaseValue(test.left);
|
|
13255
13515
|
const rightIsCase = isCaseValue(test.right);
|
|
13256
13516
|
if (leftIsCase === rightIsCase) return null;
|
|
13257
13517
|
return sourceCode.getText(leftIsCase ? test.right : test.left);
|
|
13258
13518
|
}
|
|
13259
13519
|
function isCaseValue(node) {
|
|
13260
|
-
if (node.type ===
|
|
13261
|
-
if (node.type ===
|
|
13262
|
-
if (node.type !==
|
|
13263
|
-
return node.property.type ===
|
|
13520
|
+
if (node.type === import_utils78.AST_NODE_TYPES.Literal) return true;
|
|
13521
|
+
if (node.type === import_utils78.AST_NODE_TYPES.Identifier) return /^[A-Z][A-Z0-9_]*$/u.test(node.name);
|
|
13522
|
+
if (node.type !== import_utils78.AST_NODE_TYPES.MemberExpression || node.computed) return false;
|
|
13523
|
+
return node.property.type === import_utils78.AST_NODE_TYPES.Identifier && (node.object.type === import_utils78.AST_NODE_TYPES.Identifier || isCaseValue(node.object));
|
|
13264
13524
|
}
|
|
13265
13525
|
var prefer_switch_for_repeated_equality_default = createRule({
|
|
13266
13526
|
name: "prefer-switch-for-repeated-equality",
|
|
@@ -13277,12 +13537,12 @@ var prefer_switch_for_repeated_equality_default = createRule({
|
|
|
13277
13537
|
create(context) {
|
|
13278
13538
|
return {
|
|
13279
13539
|
IfStatement(node) {
|
|
13280
|
-
if (node.parent.type ===
|
|
13540
|
+
if (node.parent.type === import_utils78.AST_NODE_TYPES.IfStatement && node.parent.alternate === node) return;
|
|
13281
13541
|
const first = discriminantText(context.sourceCode, node.test);
|
|
13282
13542
|
if (first === null) return;
|
|
13283
13543
|
let count = 1;
|
|
13284
13544
|
let current = node.alternate;
|
|
13285
|
-
while (current?.type ===
|
|
13545
|
+
while (current?.type === import_utils78.AST_NODE_TYPES.IfStatement) {
|
|
13286
13546
|
if (discriminantText(context.sourceCode, current.test) !== first) return;
|
|
13287
13547
|
count += 1;
|
|
13288
13548
|
current = current.alternate;
|
|
@@ -13296,7 +13556,7 @@ var prefer_switch_for_repeated_equality_default = createRule({
|
|
|
13296
13556
|
});
|
|
13297
13557
|
|
|
13298
13558
|
// src/rules/prefer-semantic-colors.ts
|
|
13299
|
-
var
|
|
13559
|
+
var import_utils79 = require("@typescript-eslint/utils");
|
|
13300
13560
|
var import_fs = require("fs");
|
|
13301
13561
|
var import_path = require("path");
|
|
13302
13562
|
|
|
@@ -13408,7 +13668,7 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
13408
13668
|
var isInsideSvg = (node) => {
|
|
13409
13669
|
let current = node.parent;
|
|
13410
13670
|
while (current !== void 0 && current !== null) {
|
|
13411
|
-
if (current.type ===
|
|
13671
|
+
if (current.type === import_utils79.AST_NODE_TYPES.JSXElement) {
|
|
13412
13672
|
const name = jsxElementName(current);
|
|
13413
13673
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
13414
13674
|
}
|
|
@@ -13418,8 +13678,8 @@ var isInsideSvg = (node) => {
|
|
|
13418
13678
|
};
|
|
13419
13679
|
function jsxElementName(node) {
|
|
13420
13680
|
const name = node.openingElement.name;
|
|
13421
|
-
if (name.type ===
|
|
13422
|
-
if (name.type ===
|
|
13681
|
+
if (name.type === import_utils79.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
13682
|
+
if (name.type === import_utils79.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils79.AST_NODE_TYPES.JSXIdentifier) {
|
|
13423
13683
|
return name.property.name;
|
|
13424
13684
|
}
|
|
13425
13685
|
return null;
|
|
@@ -13445,7 +13705,7 @@ function isSvgLikeElementName(name) {
|
|
|
13445
13705
|
var isInsideIconFactoryPath = (node) => {
|
|
13446
13706
|
let current = node.parent;
|
|
13447
13707
|
while (current !== void 0 && current !== null) {
|
|
13448
|
-
if (current.type ===
|
|
13708
|
+
if (current.type === import_utils79.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils79.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils79.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils79.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
13449
13709
|
return true;
|
|
13450
13710
|
}
|
|
13451
13711
|
current = current.parent;
|
|
@@ -13579,12 +13839,12 @@ var expandWorkspaceGlob = (root, glob) => {
|
|
|
13579
13839
|
return (0, import_fs.readdirSync)(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => (0, import_path.join)(parent, entry.name));
|
|
13580
13840
|
};
|
|
13581
13841
|
var propName = (key) => {
|
|
13582
|
-
if (key.type ===
|
|
13583
|
-
if (key.type ===
|
|
13842
|
+
if (key.type === import_utils79.AST_NODE_TYPES.Identifier) return key.name;
|
|
13843
|
+
if (key.type === import_utils79.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
13584
13844
|
return null;
|
|
13585
13845
|
};
|
|
13586
13846
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
13587
|
-
if (statement.type !==
|
|
13847
|
+
if (statement.type !== import_utils79.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils79.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils79.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
13588
13848
|
return false;
|
|
13589
13849
|
}
|
|
13590
13850
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -13637,27 +13897,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13637
13897
|
const checkClassNode = (node) => {
|
|
13638
13898
|
if (node === null) return;
|
|
13639
13899
|
switch (node.type) {
|
|
13640
|
-
case
|
|
13900
|
+
case import_utils79.AST_NODE_TYPES.Literal:
|
|
13641
13901
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
13642
13902
|
break;
|
|
13643
|
-
case
|
|
13903
|
+
case import_utils79.AST_NODE_TYPES.TemplateLiteral:
|
|
13644
13904
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
13645
13905
|
break;
|
|
13646
|
-
case
|
|
13906
|
+
case import_utils79.AST_NODE_TYPES.ArrayExpression:
|
|
13647
13907
|
for (const element of node.elements) {
|
|
13648
|
-
if (element !== null && element.type !==
|
|
13908
|
+
if (element !== null && element.type !== import_utils79.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
13649
13909
|
}
|
|
13650
13910
|
break;
|
|
13651
|
-
case
|
|
13911
|
+
case import_utils79.AST_NODE_TYPES.ObjectExpression:
|
|
13652
13912
|
for (const property of node.properties) {
|
|
13653
|
-
if (property.type ===
|
|
13913
|
+
if (property.type === import_utils79.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
13654
13914
|
}
|
|
13655
13915
|
break;
|
|
13656
|
-
case
|
|
13916
|
+
case import_utils79.AST_NODE_TYPES.ConditionalExpression:
|
|
13657
13917
|
checkClassNode(node.consequent);
|
|
13658
13918
|
checkClassNode(node.alternate);
|
|
13659
13919
|
break;
|
|
13660
|
-
case
|
|
13920
|
+
case import_utils79.AST_NODE_TYPES.LogicalExpression:
|
|
13661
13921
|
checkClassNode(node.right);
|
|
13662
13922
|
break;
|
|
13663
13923
|
default:
|
|
@@ -13665,32 +13925,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13665
13925
|
}
|
|
13666
13926
|
};
|
|
13667
13927
|
const checkColorValueNode = (node) => {
|
|
13668
|
-
if (node.type ===
|
|
13928
|
+
if (node.type === import_utils79.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
13669
13929
|
report2(node, "inlineColor", { value: node.value });
|
|
13670
13930
|
}
|
|
13671
13931
|
};
|
|
13672
13932
|
return {
|
|
13673
13933
|
"JSXAttribute[name.name='className']"(node) {
|
|
13674
13934
|
if (node.value === null) return;
|
|
13675
|
-
if (node.value.type ===
|
|
13676
|
-
else if (node.value.type ===
|
|
13677
|
-
if (node.value.expression.type !==
|
|
13935
|
+
if (node.value.type === import_utils79.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
13936
|
+
else if (node.value.type === import_utils79.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
13937
|
+
if (node.value.expression.type !== import_utils79.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
13678
13938
|
checkClassNode(node.value.expression);
|
|
13679
13939
|
}
|
|
13680
13940
|
}
|
|
13681
13941
|
},
|
|
13682
13942
|
CallExpression(node) {
|
|
13683
|
-
if (node.callee.type ===
|
|
13943
|
+
if (node.callee.type === import_utils79.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils79.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
13684
13944
|
importsEmailOrPdfRenderer = true;
|
|
13685
13945
|
}
|
|
13686
|
-
if (node.callee.type ===
|
|
13946
|
+
if (node.callee.type === import_utils79.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
13687
13947
|
for (const arg of node.arguments) {
|
|
13688
|
-
if (arg.type !==
|
|
13948
|
+
if (arg.type !== import_utils79.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
13689
13949
|
}
|
|
13690
13950
|
}
|
|
13691
13951
|
},
|
|
13692
13952
|
VariableDeclarator(node) {
|
|
13693
|
-
if (node.id.type ===
|
|
13953
|
+
if (node.id.type === import_utils79.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
13694
13954
|
checkClassNode(node.init);
|
|
13695
13955
|
}
|
|
13696
13956
|
},
|
|
@@ -13700,9 +13960,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13700
13960
|
},
|
|
13701
13961
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
13702
13962
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
13703
|
-
if (node.value?.type !==
|
|
13963
|
+
if (node.value?.type !== import_utils79.AST_NODE_TYPES.Literal) return;
|
|
13704
13964
|
const owner = node.parent.name;
|
|
13705
|
-
if (owner.type ===
|
|
13965
|
+
if (owner.type === import_utils79.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
13706
13966
|
return;
|
|
13707
13967
|
}
|
|
13708
13968
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -13716,7 +13976,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13716
13976
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
13717
13977
|
},
|
|
13718
13978
|
ImportExpression(node) {
|
|
13719
|
-
if (node.source.type ===
|
|
13979
|
+
if (node.source.type === import_utils79.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
13720
13980
|
importsEmailOrPdfRenderer = true;
|
|
13721
13981
|
}
|
|
13722
13982
|
},
|
|
@@ -13729,7 +13989,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13729
13989
|
});
|
|
13730
13990
|
|
|
13731
13991
|
// src/rules/prefer-server-actions.ts
|
|
13732
|
-
var
|
|
13992
|
+
var import_utils80 = require("@typescript-eslint/utils");
|
|
13733
13993
|
var PREFER_SERVER_ACTIONS_DOCUMENTATION = {
|
|
13734
13994
|
summary: "Prefer Next.js Server Actions over /api/* mutations.",
|
|
13735
13995
|
rationale: "Server Actions preserve typed application calls and avoid an internal JSON request-response boundary.",
|
|
@@ -13918,7 +14178,7 @@ var prefer_server_actions_default = createRule({
|
|
|
13918
14178
|
});
|
|
13919
14179
|
|
|
13920
14180
|
// src/rules/prefer-whole-object-assertion.ts
|
|
13921
|
-
var
|
|
14181
|
+
var import_utils81 = require("@typescript-eslint/utils");
|
|
13922
14182
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
13923
14183
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
13924
14184
|
["toBeNull", "null"],
|
|
@@ -13943,11 +14203,11 @@ var PREFER_WHOLE_OBJECT_ASSERTION_DOCUMENTATION = {
|
|
|
13943
14203
|
};
|
|
13944
14204
|
function literalText(node, getText) {
|
|
13945
14205
|
switch (node.type) {
|
|
13946
|
-
case
|
|
14206
|
+
case import_utils81.AST_NODE_TYPES.Literal:
|
|
13947
14207
|
return "regex" in node ? null : getText(node);
|
|
13948
|
-
case
|
|
14208
|
+
case import_utils81.AST_NODE_TYPES.TemplateLiteral:
|
|
13949
14209
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
13950
|
-
case
|
|
14210
|
+
case import_utils81.AST_NODE_TYPES.UnaryExpression:
|
|
13951
14211
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
13952
14212
|
default:
|
|
13953
14213
|
return null;
|
|
@@ -13955,15 +14215,15 @@ function literalText(node, getText) {
|
|
|
13955
14215
|
}
|
|
13956
14216
|
function isPureReceiver(node) {
|
|
13957
14217
|
switch (node.type) {
|
|
13958
|
-
case
|
|
13959
|
-
case
|
|
14218
|
+
case import_utils81.AST_NODE_TYPES.Identifier:
|
|
14219
|
+
case import_utils81.AST_NODE_TYPES.ThisExpression:
|
|
13960
14220
|
return true;
|
|
13961
|
-
case
|
|
14221
|
+
case import_utils81.AST_NODE_TYPES.MemberExpression:
|
|
13962
14222
|
if (node.optional) {
|
|
13963
14223
|
return false;
|
|
13964
14224
|
}
|
|
13965
14225
|
if (node.computed) {
|
|
13966
|
-
return node.property.type ===
|
|
14226
|
+
return node.property.type === import_utils81.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
13967
14227
|
}
|
|
13968
14228
|
return isPureReceiver(node.object);
|
|
13969
14229
|
default:
|
|
@@ -13971,7 +14231,7 @@ function isPureReceiver(node) {
|
|
|
13971
14231
|
}
|
|
13972
14232
|
}
|
|
13973
14233
|
function literalIndex(node) {
|
|
13974
|
-
if (node.type !==
|
|
14234
|
+
if (node.type !== import_utils81.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
13975
14235
|
return null;
|
|
13976
14236
|
}
|
|
13977
14237
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -13979,8 +14239,8 @@ function literalIndex(node) {
|
|
|
13979
14239
|
function propertyAccess(node) {
|
|
13980
14240
|
const path = [];
|
|
13981
14241
|
let current = node;
|
|
13982
|
-
while (current.type ===
|
|
13983
|
-
if (current.property.type !==
|
|
14242
|
+
while (current.type === import_utils81.AST_NODE_TYPES.MemberExpression && !current.computed && !current.optional) {
|
|
14243
|
+
if (current.property.type !== import_utils81.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(current.property.name) || LITERAL_KEY_HAZARDS.has(current.property.name)) return null;
|
|
13984
14244
|
path.unshift(current.property.name);
|
|
13985
14245
|
current = current.object;
|
|
13986
14246
|
}
|
|
@@ -14008,24 +14268,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
14008
14268
|
}
|
|
14009
14269
|
const { sourceCode } = context;
|
|
14010
14270
|
function parseAssertion(statement) {
|
|
14011
|
-
if (statement.type !==
|
|
14271
|
+
if (statement.type !== import_utils81.AST_NODE_TYPES.ExpressionStatement) {
|
|
14012
14272
|
return null;
|
|
14013
14273
|
}
|
|
14014
14274
|
const call = statement.expression;
|
|
14015
|
-
if (call.type !==
|
|
14275
|
+
if (call.type !== import_utils81.AST_NODE_TYPES.CallExpression) {
|
|
14016
14276
|
return null;
|
|
14017
14277
|
}
|
|
14018
14278
|
const callee = call.callee;
|
|
14019
|
-
if (callee.type !==
|
|
14279
|
+
if (callee.type !== import_utils81.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils81.AST_NODE_TYPES.Identifier) {
|
|
14020
14280
|
return null;
|
|
14021
14281
|
}
|
|
14022
14282
|
const matcher = callee.property.name;
|
|
14023
14283
|
const expectCall = callee.object;
|
|
14024
|
-
if (expectCall.type !==
|
|
14284
|
+
if (expectCall.type !== import_utils81.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils81.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
14025
14285
|
return null;
|
|
14026
14286
|
}
|
|
14027
14287
|
const actual = expectCall.arguments[0];
|
|
14028
|
-
if (actual === void 0 || actual.type !==
|
|
14288
|
+
if (actual === void 0 || actual.type !== import_utils81.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
14029
14289
|
return null;
|
|
14030
14290
|
}
|
|
14031
14291
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -14054,7 +14314,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
14054
14314
|
return null;
|
|
14055
14315
|
}
|
|
14056
14316
|
const expected = call.arguments[0];
|
|
14057
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
14317
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils81.AST_NODE_TYPES.SpreadElement) {
|
|
14058
14318
|
return null;
|
|
14059
14319
|
}
|
|
14060
14320
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -14195,7 +14455,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
14195
14455
|
});
|
|
14196
14456
|
|
|
14197
14457
|
// src/rules/repeated-static-call-cases.ts
|
|
14198
|
-
var
|
|
14458
|
+
var import_utils82 = require("@typescript-eslint/utils");
|
|
14199
14459
|
var REPEATED_STATIC_CALL_CASES_DOCUMENTATION = {
|
|
14200
14460
|
summary: "Report three or more consecutive literal call assertions that should be independently named test cases.",
|
|
14201
14461
|
rationale: "Copy-pasted cases obscure the input table and stop later cases from being reported after the first failure.",
|
|
@@ -14216,67 +14476,67 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
14216
14476
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
14217
14477
|
var MIN_CASES2 = 3;
|
|
14218
14478
|
function staticMemberName5(node) {
|
|
14219
|
-
if (!node.computed && node.property.type ===
|
|
14220
|
-
if (node.computed && node.property.type ===
|
|
14479
|
+
if (!node.computed && node.property.type === import_utils82.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
14480
|
+
if (node.computed && node.property.type === import_utils82.AST_NODE_TYPES.Literal && typeof node.property.value === "string") return node.property.value;
|
|
14221
14481
|
return null;
|
|
14222
14482
|
}
|
|
14223
14483
|
function importedName6(identifier, context, modules) {
|
|
14224
|
-
const variable =
|
|
14484
|
+
const variable = import_utils82.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
14225
14485
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
14226
14486
|
for (const definition of variable.defs) {
|
|
14227
|
-
if (definition.node.type !==
|
|
14487
|
+
if (definition.node.type !== import_utils82.AST_NODE_TYPES.ImportSpecifier) continue;
|
|
14228
14488
|
const declaration = definition.node.parent;
|
|
14229
|
-
if (declaration.type !==
|
|
14489
|
+
if (declaration.type !== import_utils82.AST_NODE_TYPES.ImportDeclaration || typeof declaration.source.value !== "string" || !modules.has(declaration.source.value)) continue;
|
|
14230
14490
|
const imported = definition.node.imported;
|
|
14231
|
-
return imported.type ===
|
|
14491
|
+
return imported.type === import_utils82.AST_NODE_TYPES.Identifier ? imported.name : String(imported.value);
|
|
14232
14492
|
}
|
|
14233
14493
|
return null;
|
|
14234
14494
|
}
|
|
14235
14495
|
function isDirectTestCallback2(node, context) {
|
|
14236
|
-
if (node.type !==
|
|
14496
|
+
if (node.type !== import_utils82.AST_NODE_TYPES.ArrowFunctionExpression && node.type !== import_utils82.AST_NODE_TYPES.FunctionExpression) return false;
|
|
14237
14497
|
const call = node.parent;
|
|
14238
|
-
if (call?.type !==
|
|
14498
|
+
if (call?.type !== import_utils82.AST_NODE_TYPES.CallExpression || !call.arguments.includes(node)) return false;
|
|
14239
14499
|
const root = testRoot2(call.callee);
|
|
14240
14500
|
return root !== null && TEST_NAMES2.has(importedName6(root, context, TEST_MODULES4) ?? "");
|
|
14241
14501
|
}
|
|
14242
14502
|
function testRoot2(callee) {
|
|
14243
|
-
if (callee.type ===
|
|
14244
|
-
if (callee.type !==
|
|
14503
|
+
if (callee.type === import_utils82.AST_NODE_TYPES.Identifier) return callee;
|
|
14504
|
+
if (callee.type !== import_utils82.AST_NODE_TYPES.MemberExpression) return null;
|
|
14245
14505
|
const modifier = staticMemberName5(callee);
|
|
14246
14506
|
return modifier !== null && TEST_MODIFIERS4.has(modifier) ? testRoot2(callee.object) : null;
|
|
14247
14507
|
}
|
|
14248
14508
|
function isStatic(node) {
|
|
14249
|
-
if (node.type ===
|
|
14509
|
+
if (node.type === import_utils82.AST_NODE_TYPES.TSAsExpression || node.type === import_utils82.AST_NODE_TYPES.TSTypeAssertion || node.type === import_utils82.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils82.AST_NODE_TYPES.TSNonNullExpression) return isStatic(node.expression);
|
|
14250
14510
|
switch (node.type) {
|
|
14251
|
-
case
|
|
14511
|
+
case import_utils82.AST_NODE_TYPES.Literal:
|
|
14252
14512
|
return true;
|
|
14253
|
-
case
|
|
14513
|
+
case import_utils82.AST_NODE_TYPES.TemplateLiteral:
|
|
14254
14514
|
return node.expressions.length === 0;
|
|
14255
|
-
case
|
|
14515
|
+
case import_utils82.AST_NODE_TYPES.UnaryExpression:
|
|
14256
14516
|
return (node.operator === "+" || node.operator === "-") && isStatic(node.argument);
|
|
14257
|
-
case
|
|
14258
|
-
return node.elements.every((item) => item !== null && item.type !==
|
|
14259
|
-
case
|
|
14260
|
-
return node.properties.every((property) => property.type ===
|
|
14517
|
+
case import_utils82.AST_NODE_TYPES.ArrayExpression:
|
|
14518
|
+
return node.elements.every((item) => item !== null && item.type !== import_utils82.AST_NODE_TYPES.SpreadElement && isStatic(item));
|
|
14519
|
+
case import_utils82.AST_NODE_TYPES.ObjectExpression:
|
|
14520
|
+
return node.properties.every((property) => property.type === import_utils82.AST_NODE_TYPES.Property && !property.computed && property.kind === "init" && property.value.type !== import_utils82.AST_NODE_TYPES.AssignmentPattern && isStatic(property.value));
|
|
14261
14521
|
default:
|
|
14262
14522
|
return false;
|
|
14263
14523
|
}
|
|
14264
14524
|
}
|
|
14265
14525
|
function staticShape(node) {
|
|
14266
|
-
if (node.type ===
|
|
14526
|
+
if (node.type === import_utils82.AST_NODE_TYPES.TSAsExpression || node.type === import_utils82.AST_NODE_TYPES.TSTypeAssertion || node.type === import_utils82.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils82.AST_NODE_TYPES.TSNonNullExpression) return staticShape(node.expression);
|
|
14267
14527
|
switch (node.type) {
|
|
14268
|
-
case
|
|
14528
|
+
case import_utils82.AST_NODE_TYPES.Literal:
|
|
14269
14529
|
return `literal:${typeof node.value}`;
|
|
14270
|
-
case
|
|
14530
|
+
case import_utils82.AST_NODE_TYPES.TemplateLiteral:
|
|
14271
14531
|
return "template";
|
|
14272
|
-
case
|
|
14532
|
+
case import_utils82.AST_NODE_TYPES.UnaryExpression:
|
|
14273
14533
|
return `unary:${node.operator}:${staticShape(node.argument)}`;
|
|
14274
|
-
case
|
|
14275
|
-
return `array(${node.elements.map((item) => item === null || item.type ===
|
|
14276
|
-
case
|
|
14534
|
+
case import_utils82.AST_NODE_TYPES.ArrayExpression:
|
|
14535
|
+
return `array(${node.elements.map((item) => item === null || item.type === import_utils82.AST_NODE_TYPES.SpreadElement ? "invalid" : staticShape(item)).join(",")})`;
|
|
14536
|
+
case import_utils82.AST_NODE_TYPES.ObjectExpression:
|
|
14277
14537
|
return `object(${node.properties.map((property) => {
|
|
14278
|
-
if (property.type !==
|
|
14279
|
-
const key = property.key.type ===
|
|
14538
|
+
if (property.type !== import_utils82.AST_NODE_TYPES.Property || property.computed || property.value.type === import_utils82.AST_NODE_TYPES.AssignmentPattern) return "invalid";
|
|
14539
|
+
const key = property.key.type === import_utils82.AST_NODE_TYPES.Identifier ? property.key.name : String(property.key.value);
|
|
14280
14540
|
return `${key}:${staticShape(property.value)}`;
|
|
14281
14541
|
}).join(",")})`;
|
|
14282
14542
|
default:
|
|
@@ -14284,16 +14544,16 @@ function staticShape(node) {
|
|
|
14284
14544
|
}
|
|
14285
14545
|
}
|
|
14286
14546
|
function assertionShape(statement, context) {
|
|
14287
|
-
if (statement.type !==
|
|
14547
|
+
if (statement.type !== import_utils82.AST_NODE_TYPES.ExpressionStatement || statement.expression.type !== import_utils82.AST_NODE_TYPES.CallExpression) return null;
|
|
14288
14548
|
const matcherCall = statement.expression;
|
|
14289
|
-
if (matcherCall.callee.type !==
|
|
14549
|
+
if (matcherCall.callee.type !== import_utils82.AST_NODE_TYPES.MemberExpression || matcherCall.callee.computed || matcherCall.callee.property.type !== import_utils82.AST_NODE_TYPES.Identifier || matcherCall.arguments.length !== 1) return null;
|
|
14290
14550
|
const matcher = matcherCall.callee.property.name;
|
|
14291
14551
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
14292
14552
|
const chain = expectCallFromMatcher(matcherCall.callee);
|
|
14293
|
-
if (chain === null || chain.call.callee.type !==
|
|
14553
|
+
if (chain === null || chain.call.callee.type !== import_utils82.AST_NODE_TYPES.Identifier || importedName6(chain.call.callee, context, ASSERTION_MODULES3) !== "expect" || chain.call.arguments.length !== 1) return null;
|
|
14294
14554
|
const observed = chain.call.arguments[0];
|
|
14295
14555
|
const expected = matcherCall.arguments[0];
|
|
14296
|
-
if (observed?.type !==
|
|
14556
|
+
if (observed?.type !== import_utils82.AST_NODE_TYPES.CallExpression || observed.callee.type !== import_utils82.AST_NODE_TYPES.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === import_utils82.AST_NODE_TYPES.SpreadElement || !isStatic(arg)) || expected?.type === import_utils82.AST_NODE_TYPES.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
14297
14557
|
const skeleton = `${observed.callee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
14298
14558
|
const values = [...observed.arguments, expected].map((item) => context.sourceCode.getText(item)).join("\0");
|
|
14299
14559
|
return { statement, skeleton, values };
|
|
@@ -14301,13 +14561,13 @@ function assertionShape(statement, context) {
|
|
|
14301
14561
|
function expectCallFromMatcher(node) {
|
|
14302
14562
|
const modifiers = [];
|
|
14303
14563
|
let receiver = node.object;
|
|
14304
|
-
while (receiver.type ===
|
|
14564
|
+
while (receiver.type === import_utils82.AST_NODE_TYPES.MemberExpression) {
|
|
14305
14565
|
const modifier = staticMemberName5(receiver);
|
|
14306
14566
|
if (modifier === null || !EXPECT_MODIFIERS.has(modifier)) return null;
|
|
14307
14567
|
modifiers.unshift(modifier);
|
|
14308
14568
|
receiver = receiver.object;
|
|
14309
14569
|
}
|
|
14310
|
-
return receiver.type ===
|
|
14570
|
+
return receiver.type === import_utils82.AST_NODE_TYPES.CallExpression ? { call: receiver, modifiers } : null;
|
|
14311
14571
|
}
|
|
14312
14572
|
var repeated_static_call_cases_default = createRule({
|
|
14313
14573
|
name: "repeated-static-call-cases",
|
|
@@ -14327,7 +14587,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
14327
14587
|
return {
|
|
14328
14588
|
"CallExpression > ArrowFunctionExpression, CallExpression > FunctionExpression"(node) {
|
|
14329
14589
|
const call = node.parent;
|
|
14330
|
-
if (call?.type ===
|
|
14590
|
+
if (call?.type === import_utils82.AST_NODE_TYPES.CallExpression) {
|
|
14331
14591
|
const duplicate = duplicateTestBodyCandidate(call, sourceCode);
|
|
14332
14592
|
if (duplicate !== null && duplicate.body === node) {
|
|
14333
14593
|
const groups = duplicateGroups.get(duplicate.container) ?? /* @__PURE__ */ new Map();
|
|
@@ -14337,7 +14597,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
14337
14597
|
duplicateGroups.set(duplicate.container, groups);
|
|
14338
14598
|
}
|
|
14339
14599
|
}
|
|
14340
|
-
if (!isDirectTestCallback2(node, context) || node.body.type !==
|
|
14600
|
+
if (!isDirectTestCallback2(node, context) || node.body.type !== import_utils82.AST_NODE_TYPES.BlockStatement) return;
|
|
14341
14601
|
let run = [];
|
|
14342
14602
|
const flush = () => {
|
|
14343
14603
|
if (run.length >= MIN_CASES2 && new Set(run.map((item) => item.values)).size > 1) {
|
|
@@ -14378,7 +14638,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
14378
14638
|
});
|
|
14379
14639
|
|
|
14380
14640
|
// src/rules/prefer-zod-infer.ts
|
|
14381
|
-
var
|
|
14641
|
+
var import_utils83 = require("@typescript-eslint/utils");
|
|
14382
14642
|
var PREFER_ZOD_INFER_DOCUMENTATION = {
|
|
14383
14643
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
14384
14644
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -14431,47 +14691,47 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
14431
14691
|
"Schema"
|
|
14432
14692
|
]);
|
|
14433
14693
|
var LEAF_NODE_TYPES = {
|
|
14434
|
-
string: [
|
|
14435
|
-
email: [
|
|
14436
|
-
url: [
|
|
14437
|
-
uuid: [
|
|
14438
|
-
ulid: [
|
|
14439
|
-
cuid: [
|
|
14440
|
-
cuid2: [
|
|
14441
|
-
nanoid: [
|
|
14442
|
-
iso: [
|
|
14443
|
-
number: [
|
|
14444
|
-
int: [
|
|
14445
|
-
float32: [
|
|
14446
|
-
float64: [
|
|
14447
|
-
boolean: [
|
|
14448
|
-
bigint: [
|
|
14449
|
-
symbol: [
|
|
14450
|
-
any: [
|
|
14451
|
-
unknown: [
|
|
14452
|
-
never: [
|
|
14453
|
-
void: [
|
|
14454
|
-
null: [
|
|
14455
|
-
undefined: [
|
|
14456
|
-
literal: [
|
|
14457
|
-
date: [
|
|
14458
|
-
array: [
|
|
14459
|
-
tuple: [
|
|
14460
|
-
object: [
|
|
14461
|
-
strictObject: [
|
|
14462
|
-
looseObject: [
|
|
14463
|
-
record: [
|
|
14464
|
-
map: [
|
|
14465
|
-
set: [
|
|
14466
|
-
promise: [
|
|
14467
|
-
enum: [
|
|
14468
|
-
nativeEnum: [
|
|
14469
|
-
union: [
|
|
14470
|
-
discriminatedUnion: [
|
|
14471
|
-
intersection: [
|
|
14694
|
+
string: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14695
|
+
email: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14696
|
+
url: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14697
|
+
uuid: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14698
|
+
ulid: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14699
|
+
cuid: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14700
|
+
cuid2: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14701
|
+
nanoid: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14702
|
+
iso: [import_utils83.AST_NODE_TYPES.TSStringKeyword],
|
|
14703
|
+
number: [import_utils83.AST_NODE_TYPES.TSNumberKeyword],
|
|
14704
|
+
int: [import_utils83.AST_NODE_TYPES.TSNumberKeyword],
|
|
14705
|
+
float32: [import_utils83.AST_NODE_TYPES.TSNumberKeyword],
|
|
14706
|
+
float64: [import_utils83.AST_NODE_TYPES.TSNumberKeyword],
|
|
14707
|
+
boolean: [import_utils83.AST_NODE_TYPES.TSBooleanKeyword],
|
|
14708
|
+
bigint: [import_utils83.AST_NODE_TYPES.TSBigIntKeyword],
|
|
14709
|
+
symbol: [import_utils83.AST_NODE_TYPES.TSSymbolKeyword],
|
|
14710
|
+
any: [import_utils83.AST_NODE_TYPES.TSAnyKeyword],
|
|
14711
|
+
unknown: [import_utils83.AST_NODE_TYPES.TSUnknownKeyword],
|
|
14712
|
+
never: [import_utils83.AST_NODE_TYPES.TSNeverKeyword],
|
|
14713
|
+
void: [import_utils83.AST_NODE_TYPES.TSVoidKeyword],
|
|
14714
|
+
null: [import_utils83.AST_NODE_TYPES.TSNullKeyword],
|
|
14715
|
+
undefined: [import_utils83.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
14716
|
+
literal: [import_utils83.AST_NODE_TYPES.TSLiteralType],
|
|
14717
|
+
date: [import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14718
|
+
array: [import_utils83.AST_NODE_TYPES.TSArrayType, import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14719
|
+
tuple: [import_utils83.AST_NODE_TYPES.TSTupleType],
|
|
14720
|
+
object: [import_utils83.AST_NODE_TYPES.TSTypeLiteral, import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14721
|
+
strictObject: [import_utils83.AST_NODE_TYPES.TSTypeLiteral, import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14722
|
+
looseObject: [import_utils83.AST_NODE_TYPES.TSTypeLiteral, import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14723
|
+
record: [import_utils83.AST_NODE_TYPES.TSTypeReference, import_utils83.AST_NODE_TYPES.TSTypeLiteral],
|
|
14724
|
+
map: [import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14725
|
+
set: [import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14726
|
+
promise: [import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14727
|
+
enum: [import_utils83.AST_NODE_TYPES.TSUnionType, import_utils83.AST_NODE_TYPES.TSTypeReference, import_utils83.AST_NODE_TYPES.TSLiteralType],
|
|
14728
|
+
nativeEnum: [import_utils83.AST_NODE_TYPES.TSUnionType, import_utils83.AST_NODE_TYPES.TSTypeReference, import_utils83.AST_NODE_TYPES.TSLiteralType],
|
|
14729
|
+
union: [import_utils83.AST_NODE_TYPES.TSUnionType, import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14730
|
+
discriminatedUnion: [import_utils83.AST_NODE_TYPES.TSUnionType, import_utils83.AST_NODE_TYPES.TSTypeReference],
|
|
14731
|
+
intersection: [import_utils83.AST_NODE_TYPES.TSIntersectionType, import_utils83.AST_NODE_TYPES.TSTypeReference]
|
|
14472
14732
|
};
|
|
14473
14733
|
function primitiveLiteralKey(node) {
|
|
14474
|
-
if (node.type !==
|
|
14734
|
+
if (node.type !== import_utils83.AST_NODE_TYPES.Literal) {
|
|
14475
14735
|
return null;
|
|
14476
14736
|
}
|
|
14477
14737
|
if (node.value === null) {
|
|
@@ -14503,13 +14763,13 @@ function staticZodDomain(leaf, call) {
|
|
|
14503
14763
|
}
|
|
14504
14764
|
if (leaf === "literal") {
|
|
14505
14765
|
const [argument] = call.arguments;
|
|
14506
|
-
if (argument === void 0 || argument.type ===
|
|
14766
|
+
if (argument === void 0 || argument.type === import_utils83.AST_NODE_TYPES.SpreadElement) {
|
|
14507
14767
|
return null;
|
|
14508
14768
|
}
|
|
14509
|
-
if (argument.type ===
|
|
14769
|
+
if (argument.type === import_utils83.AST_NODE_TYPES.ArrayExpression) {
|
|
14510
14770
|
return exactDomain(
|
|
14511
14771
|
argument.elements.map(
|
|
14512
|
-
(element) => element === null || element.type ===
|
|
14772
|
+
(element) => element === null || element.type === import_utils83.AST_NODE_TYPES.SpreadElement ? null : primitiveLiteralKey(element)
|
|
14513
14773
|
)
|
|
14514
14774
|
);
|
|
14515
14775
|
}
|
|
@@ -14517,13 +14777,13 @@ function staticZodDomain(leaf, call) {
|
|
|
14517
14777
|
}
|
|
14518
14778
|
if (leaf === "enum") {
|
|
14519
14779
|
const [argument] = call.arguments;
|
|
14520
|
-
if (argument === void 0 || argument.type ===
|
|
14780
|
+
if (argument === void 0 || argument.type === import_utils83.AST_NODE_TYPES.SpreadElement) {
|
|
14521
14781
|
return null;
|
|
14522
14782
|
}
|
|
14523
|
-
if (argument.type ===
|
|
14783
|
+
if (argument.type === import_utils83.AST_NODE_TYPES.ArrayExpression) {
|
|
14524
14784
|
return exactDomain(
|
|
14525
14785
|
argument.elements.map((element) => {
|
|
14526
|
-
if (element === null || element.type ===
|
|
14786
|
+
if (element === null || element.type === import_utils83.AST_NODE_TYPES.SpreadElement) {
|
|
14527
14787
|
return null;
|
|
14528
14788
|
}
|
|
14529
14789
|
const key = primitiveLiteralKey(element);
|
|
@@ -14531,10 +14791,10 @@ function staticZodDomain(leaf, call) {
|
|
|
14531
14791
|
})
|
|
14532
14792
|
);
|
|
14533
14793
|
}
|
|
14534
|
-
if (argument.type ===
|
|
14794
|
+
if (argument.type === import_utils83.AST_NODE_TYPES.ObjectExpression) {
|
|
14535
14795
|
return exactDomain(
|
|
14536
14796
|
argument.properties.map((property) => {
|
|
14537
|
-
if (property.type !==
|
|
14797
|
+
if (property.type !== import_utils83.AST_NODE_TYPES.Property || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
14538
14798
|
return null;
|
|
14539
14799
|
}
|
|
14540
14800
|
const key = primitiveLiteralKey(property.value);
|
|
@@ -14561,15 +14821,15 @@ function sameDomain(left, right) {
|
|
|
14561
14821
|
return true;
|
|
14562
14822
|
}
|
|
14563
14823
|
function isExportedDeclaration(node) {
|
|
14564
|
-
return node.parent?.type ===
|
|
14824
|
+
return node.parent?.type === import_utils83.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
14565
14825
|
}
|
|
14566
14826
|
function isModuleLevelConst(node) {
|
|
14567
14827
|
const declaration = node.parent;
|
|
14568
|
-
if (declaration.type !==
|
|
14828
|
+
if (declaration.type !== import_utils83.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const") {
|
|
14569
14829
|
return false;
|
|
14570
14830
|
}
|
|
14571
14831
|
const container = declaration.parent;
|
|
14572
|
-
return container.type ===
|
|
14832
|
+
return container.type === import_utils83.AST_NODE_TYPES.Program || container.type === import_utils83.AST_NODE_TYPES.ExportNamedDeclaration && container.parent.type === import_utils83.AST_NODE_TYPES.Program;
|
|
14573
14833
|
}
|
|
14574
14834
|
function normalizeSchemaName(name) {
|
|
14575
14835
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -14578,20 +14838,20 @@ function normalizeTypeName(name) {
|
|
|
14578
14838
|
return name.replace(/Type$/, "").toLowerCase();
|
|
14579
14839
|
}
|
|
14580
14840
|
function unwrapNullish(annotation) {
|
|
14581
|
-
if (annotation.type !==
|
|
14841
|
+
if (annotation.type !== import_utils83.AST_NODE_TYPES.TSUnionType) {
|
|
14582
14842
|
return {
|
|
14583
14843
|
core: annotation,
|
|
14584
|
-
nullable: annotation.type ===
|
|
14844
|
+
nullable: annotation.type === import_utils83.AST_NODE_TYPES.TSNullKeyword
|
|
14585
14845
|
};
|
|
14586
14846
|
}
|
|
14587
14847
|
const rest = [];
|
|
14588
14848
|
let nullable = false;
|
|
14589
14849
|
for (const member of annotation.types) {
|
|
14590
|
-
if (member.type ===
|
|
14850
|
+
if (member.type === import_utils83.AST_NODE_TYPES.TSNullKeyword) {
|
|
14591
14851
|
nullable = true;
|
|
14592
14852
|
continue;
|
|
14593
14853
|
}
|
|
14594
|
-
if (member.type ===
|
|
14854
|
+
if (member.type === import_utils83.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
14595
14855
|
continue;
|
|
14596
14856
|
}
|
|
14597
14857
|
rest.push(member);
|
|
@@ -14625,18 +14885,18 @@ function leafAgrees(field, annotation) {
|
|
|
14625
14885
|
return null;
|
|
14626
14886
|
}
|
|
14627
14887
|
if (leaf === "date") {
|
|
14628
|
-
return core.type ===
|
|
14888
|
+
return core.type === import_utils83.AST_NODE_TYPES.TSTypeReference && core.typeName.type === import_utils83.AST_NODE_TYPES.Identifier && core.typeName.name === "Date";
|
|
14629
14889
|
}
|
|
14630
14890
|
return expected.includes(core.type);
|
|
14631
14891
|
}
|
|
14632
14892
|
function typeLiteralDomain(annotation) {
|
|
14633
|
-
const members = annotation.type ===
|
|
14893
|
+
const members = annotation.type === import_utils83.AST_NODE_TYPES.TSUnionType ? annotation.types : [annotation];
|
|
14634
14894
|
const keys = [];
|
|
14635
14895
|
for (const member of members) {
|
|
14636
|
-
if (member.type ===
|
|
14896
|
+
if (member.type === import_utils83.AST_NODE_TYPES.TSNullKeyword) {
|
|
14637
14897
|
continue;
|
|
14638
14898
|
}
|
|
14639
|
-
if (member.type !==
|
|
14899
|
+
if (member.type !== import_utils83.AST_NODE_TYPES.TSLiteralType) {
|
|
14640
14900
|
return null;
|
|
14641
14901
|
}
|
|
14642
14902
|
keys.push(primitiveLiteralKey(member.literal));
|
|
@@ -14644,11 +14904,11 @@ function typeLiteralDomain(annotation) {
|
|
|
14644
14904
|
return exactDomain(keys);
|
|
14645
14905
|
}
|
|
14646
14906
|
function staticStringUnionDomain(node) {
|
|
14647
|
-
if (node.type !==
|
|
14907
|
+
if (node.type !== import_utils83.AST_NODE_TYPES.TSUnionType) {
|
|
14648
14908
|
return null;
|
|
14649
14909
|
}
|
|
14650
14910
|
const keys = node.types.map((member) => {
|
|
14651
|
-
if (member.type !==
|
|
14911
|
+
if (member.type !== import_utils83.AST_NODE_TYPES.TSLiteralType) {
|
|
14652
14912
|
return null;
|
|
14653
14913
|
}
|
|
14654
14914
|
const key = primitiveLiteralKey(member.literal);
|
|
@@ -14716,14 +14976,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14716
14976
|
function zodCallChain(node) {
|
|
14717
14977
|
const chain = [];
|
|
14718
14978
|
let current = node;
|
|
14719
|
-
while (current.type ===
|
|
14979
|
+
while (current.type === import_utils83.AST_NODE_TYPES.CallExpression) {
|
|
14720
14980
|
const callee = current.callee;
|
|
14721
|
-
if (callee.type !==
|
|
14981
|
+
if (callee.type !== import_utils83.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils83.AST_NODE_TYPES.Identifier) {
|
|
14722
14982
|
return null;
|
|
14723
14983
|
}
|
|
14724
14984
|
chain.push(current);
|
|
14725
14985
|
const receiver = callee.object;
|
|
14726
|
-
if (receiver.type ===
|
|
14986
|
+
if (receiver.type === import_utils83.AST_NODE_TYPES.Identifier) {
|
|
14727
14987
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
14728
14988
|
}
|
|
14729
14989
|
current = receiver;
|
|
@@ -14732,14 +14992,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14732
14992
|
}
|
|
14733
14993
|
function methodName2(call) {
|
|
14734
14994
|
const callee = call.callee;
|
|
14735
|
-
return callee.type ===
|
|
14995
|
+
return callee.type === import_utils83.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils83.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
14736
14996
|
}
|
|
14737
14997
|
function recordZodImport(node) {
|
|
14738
14998
|
if (!isZodModule(node.source.value)) {
|
|
14739
14999
|
return;
|
|
14740
15000
|
}
|
|
14741
15001
|
for (const specifier of node.specifiers) {
|
|
14742
|
-
if (specifier.type ===
|
|
15002
|
+
if (specifier.type === import_utils83.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils83.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils83.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils83.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
14743
15003
|
zodNamespaces.add(specifier.local.name);
|
|
14744
15004
|
}
|
|
14745
15005
|
}
|
|
@@ -14749,13 +15009,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
14749
15009
|
let current = node;
|
|
14750
15010
|
let leaf = null;
|
|
14751
15011
|
let leafCall = null;
|
|
14752
|
-
while (current.type ===
|
|
15012
|
+
while (current.type === import_utils83.AST_NODE_TYPES.CallExpression) {
|
|
14753
15013
|
const callee = current.callee;
|
|
14754
|
-
if (callee.type !==
|
|
15014
|
+
if (callee.type !== import_utils83.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils83.AST_NODE_TYPES.Identifier) {
|
|
14755
15015
|
break;
|
|
14756
15016
|
}
|
|
14757
15017
|
const receiver = callee.object;
|
|
14758
|
-
if (receiver.type ===
|
|
15018
|
+
if (receiver.type === import_utils83.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
14759
15019
|
leaf = callee.property.name;
|
|
14760
15020
|
leafCall = current;
|
|
14761
15021
|
break;
|
|
@@ -14786,20 +15046,20 @@ var prefer_zod_infer_default = createRule({
|
|
|
14786
15046
|
return domain instanceof Set && domain.size >= 2 ? domain : null;
|
|
14787
15047
|
}
|
|
14788
15048
|
function inferredSchemaName(node) {
|
|
14789
|
-
if (node.type !==
|
|
15049
|
+
if (node.type !== import_utils83.AST_NODE_TYPES.TSTypeReference || node.typeName.type !== import_utils83.AST_NODE_TYPES.TSQualifiedName || node.typeName.left.type !== import_utils83.AST_NODE_TYPES.Identifier || !zodNamespaces.has(node.typeName.left.name) || node.typeName.right.name !== "infer") {
|
|
14790
15050
|
return null;
|
|
14791
15051
|
}
|
|
14792
15052
|
const arguments_ = node.typeArguments?.params ?? [];
|
|
14793
15053
|
const [argument] = arguments_;
|
|
14794
|
-
return arguments_.length === 1 && argument?.type ===
|
|
15054
|
+
return arguments_.length === 1 && argument?.type === import_utils83.AST_NODE_TYPES.TSTypeQuery && argument.exprName.type === import_utils83.AST_NODE_TYPES.Identifier ? argument.exprName.name : null;
|
|
14795
15055
|
}
|
|
14796
15056
|
function recordLiteralUnions(members, owner, ownerName, exported) {
|
|
14797
15057
|
for (const member of members) {
|
|
14798
|
-
if (member.type !==
|
|
15058
|
+
if (member.type !== import_utils83.AST_NODE_TYPES.TSPropertySignature || member.computed || member.optional || member.readonly || member.typeAnnotation === void 0) {
|
|
14799
15059
|
continue;
|
|
14800
15060
|
}
|
|
14801
15061
|
const key = member.key;
|
|
14802
|
-
const propertyName7 = key.type ===
|
|
15062
|
+
const propertyName7 = key.type === import_utils83.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils83.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
14803
15063
|
if (propertyName7 === null) {
|
|
14804
15064
|
continue;
|
|
14805
15065
|
}
|
|
@@ -14809,7 +15069,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14809
15069
|
}
|
|
14810
15070
|
const annotation = member.typeAnnotation.typeAnnotation;
|
|
14811
15071
|
const domain = staticStringUnionDomain(annotation);
|
|
14812
|
-
if (domain === null || annotation.type !==
|
|
15072
|
+
if (domain === null || annotation.type !== import_utils83.AST_NODE_TYPES.TSUnionType) {
|
|
14813
15073
|
continue;
|
|
14814
15074
|
}
|
|
14815
15075
|
literalUnionOccurrences.push({
|
|
@@ -14840,16 +15100,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
14840
15100
|
return null;
|
|
14841
15101
|
}
|
|
14842
15102
|
const shape = base.arguments[0];
|
|
14843
|
-
if (shape === void 0 || shape.type !==
|
|
15103
|
+
if (shape === void 0 || shape.type !== import_utils83.AST_NODE_TYPES.ObjectExpression) {
|
|
14844
15104
|
return null;
|
|
14845
15105
|
}
|
|
14846
15106
|
const fields = /* @__PURE__ */ new Map();
|
|
14847
15107
|
for (const property of shape.properties) {
|
|
14848
|
-
if (property.type !==
|
|
15108
|
+
if (property.type !== import_utils83.AST_NODE_TYPES.Property || property.computed) {
|
|
14849
15109
|
return null;
|
|
14850
15110
|
}
|
|
14851
15111
|
const { key } = property;
|
|
14852
|
-
const name = key.type ===
|
|
15112
|
+
const name = key.type === import_utils83.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils83.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
14853
15113
|
if (name === null) {
|
|
14854
15114
|
return null;
|
|
14855
15115
|
}
|
|
@@ -14860,11 +15120,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
14860
15120
|
function typeMembers(members) {
|
|
14861
15121
|
const result = /* @__PURE__ */ new Map();
|
|
14862
15122
|
for (const member of members) {
|
|
14863
|
-
if (member.type !==
|
|
15123
|
+
if (member.type !== import_utils83.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
14864
15124
|
return null;
|
|
14865
15125
|
}
|
|
14866
15126
|
const { key } = member;
|
|
14867
|
-
const name = key.type ===
|
|
15127
|
+
const name = key.type === import_utils83.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils83.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
14868
15128
|
if (name === null) {
|
|
14869
15129
|
return null;
|
|
14870
15130
|
}
|
|
@@ -14879,8 +15139,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
14879
15139
|
return result.size === 0 ? null : result;
|
|
14880
15140
|
}
|
|
14881
15141
|
function collectConstrainedNames(node) {
|
|
14882
|
-
if (node.type ===
|
|
14883
|
-
if (node.typeName.type ===
|
|
15142
|
+
if (node.type === import_utils83.AST_NODE_TYPES.TSTypeReference) {
|
|
15143
|
+
if (node.typeName.type === import_utils83.AST_NODE_TYPES.Identifier) {
|
|
14884
15144
|
constrainedTypeNames.add(node.typeName.name);
|
|
14885
15145
|
}
|
|
14886
15146
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -14888,11 +15148,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
14888
15148
|
}
|
|
14889
15149
|
return;
|
|
14890
15150
|
}
|
|
14891
|
-
if (node.type ===
|
|
15151
|
+
if (node.type === import_utils83.AST_NODE_TYPES.TSArrayType) {
|
|
14892
15152
|
collectConstrainedNames(node.elementType);
|
|
14893
15153
|
return;
|
|
14894
15154
|
}
|
|
14895
|
-
if (node.type ===
|
|
15155
|
+
if (node.type === import_utils83.AST_NODE_TYPES.TSUnionType || node.type === import_utils83.AST_NODE_TYPES.TSIntersectionType) {
|
|
14896
15156
|
for (const member of node.types) {
|
|
14897
15157
|
collectConstrainedNames(member);
|
|
14898
15158
|
}
|
|
@@ -14936,7 +15196,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14936
15196
|
return {
|
|
14937
15197
|
Program(node) {
|
|
14938
15198
|
for (const statement of node.body) {
|
|
14939
|
-
if (statement.type ===
|
|
15199
|
+
if (statement.type === import_utils83.AST_NODE_TYPES.ImportDeclaration) {
|
|
14940
15200
|
recordZodImport(statement);
|
|
14941
15201
|
}
|
|
14942
15202
|
}
|
|
@@ -14945,7 +15205,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14945
15205
|
recordZodImport(node);
|
|
14946
15206
|
},
|
|
14947
15207
|
VariableDeclarator(node) {
|
|
14948
|
-
if (node.id.type !==
|
|
15208
|
+
if (node.id.type !== import_utils83.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
14949
15209
|
return;
|
|
14950
15210
|
}
|
|
14951
15211
|
const fields = schemaFields(node.init);
|
|
@@ -14962,14 +15222,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14962
15222
|
},
|
|
14963
15223
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
14964
15224
|
"MemberExpression[computed=false]"(node) {
|
|
14965
|
-
if (node.object.type ===
|
|
15225
|
+
if (node.object.type === import_utils83.AST_NODE_TYPES.Identifier && node.property.type === import_utils83.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
14966
15226
|
reshapedSchemaNames.add(node.object.name);
|
|
14967
15227
|
}
|
|
14968
15228
|
},
|
|
14969
15229
|
/** Records every type argument carried by a Zod constraint. */
|
|
14970
15230
|
TSTypeReference(node) {
|
|
14971
15231
|
const { typeName } = node;
|
|
14972
|
-
const referenced = typeName.type ===
|
|
15232
|
+
const referenced = typeName.type === import_utils83.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils83.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils83.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
14973
15233
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
14974
15234
|
return;
|
|
14975
15235
|
}
|
|
@@ -15001,7 +15261,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
15001
15261
|
typeName: node.id.name
|
|
15002
15262
|
});
|
|
15003
15263
|
}
|
|
15004
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
15264
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils83.AST_NODE_TYPES.TSTypeLiteral) {
|
|
15005
15265
|
return;
|
|
15006
15266
|
}
|
|
15007
15267
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -15100,7 +15360,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
15100
15360
|
});
|
|
15101
15361
|
|
|
15102
15362
|
// src/rules/require-assert-never.ts
|
|
15103
|
-
var
|
|
15363
|
+
var import_utils84 = require("@typescript-eslint/utils");
|
|
15104
15364
|
var import_typescript2 = __toESM(require("typescript"), 1);
|
|
15105
15365
|
var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
15106
15366
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
@@ -15113,14 +15373,14 @@ var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
|
15113
15373
|
]
|
|
15114
15374
|
};
|
|
15115
15375
|
var isRuntimeHandlingStatement = (statement) => {
|
|
15116
|
-
if (statement.type ===
|
|
15117
|
-
if (statement.type ===
|
|
15376
|
+
if (statement.type === import_utils84.AST_NODE_TYPES.EmptyStatement) return false;
|
|
15377
|
+
if (statement.type === import_utils84.AST_NODE_TYPES.BreakStatement) {
|
|
15118
15378
|
return statement.label !== null;
|
|
15119
15379
|
}
|
|
15120
|
-
if (statement.type ===
|
|
15380
|
+
if (statement.type === import_utils84.AST_NODE_TYPES.TSTypeAliasDeclaration || statement.type === import_utils84.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
15121
15381
|
return false;
|
|
15122
15382
|
}
|
|
15123
|
-
if (statement.type ===
|
|
15383
|
+
if (statement.type === import_utils84.AST_NODE_TYPES.BlockStatement) {
|
|
15124
15384
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
15125
15385
|
}
|
|
15126
15386
|
return true;
|
|
@@ -15136,7 +15396,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
15136
15396
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
15137
15397
|
}
|
|
15138
15398
|
const only = defaultCase.consequent[0];
|
|
15139
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
15399
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils84.AST_NODE_TYPES.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
15140
15400
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
15141
15401
|
}
|
|
15142
15402
|
return false;
|
|
@@ -15192,7 +15452,7 @@ var require_assert_never_default = createRule({
|
|
|
15192
15452
|
create(context) {
|
|
15193
15453
|
let services;
|
|
15194
15454
|
try {
|
|
15195
|
-
services =
|
|
15455
|
+
services = import_utils84.ESLintUtils.getParserServices(context);
|
|
15196
15456
|
} catch {
|
|
15197
15457
|
services = null;
|
|
15198
15458
|
}
|
|
@@ -15219,7 +15479,7 @@ var require_assert_never_default = createRule({
|
|
|
15219
15479
|
});
|
|
15220
15480
|
|
|
15221
15481
|
// src/rules/require-fetch-timeout.ts
|
|
15222
|
-
var
|
|
15482
|
+
var import_utils85 = require("@typescript-eslint/utils");
|
|
15223
15483
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
15224
15484
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
15225
15485
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -15245,14 +15505,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
15245
15505
|
return false;
|
|
15246
15506
|
}
|
|
15247
15507
|
function initProvablyLacksSignal(init) {
|
|
15248
|
-
if (init.type !==
|
|
15508
|
+
if (init.type !== import_utils85.AST_NODE_TYPES.ObjectExpression) {
|
|
15249
15509
|
return false;
|
|
15250
15510
|
}
|
|
15251
15511
|
for (const prop of init.properties) {
|
|
15252
|
-
if (prop.type ===
|
|
15512
|
+
if (prop.type === import_utils85.AST_NODE_TYPES.SpreadElement) {
|
|
15253
15513
|
return false;
|
|
15254
15514
|
}
|
|
15255
|
-
if (prop.key.type ===
|
|
15515
|
+
if (prop.key.type === import_utils85.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils85.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
15256
15516
|
return false;
|
|
15257
15517
|
}
|
|
15258
15518
|
if (prop.computed) {
|
|
@@ -15262,7 +15522,7 @@ function initProvablyLacksSignal(init) {
|
|
|
15262
15522
|
return true;
|
|
15263
15523
|
}
|
|
15264
15524
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
15265
|
-
return node.type ===
|
|
15525
|
+
return node.type === import_utils85.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils85.AST_NODE_TYPES.TemplateLiteral || node.type === import_utils85.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils85.AST_NODE_TYPES.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
15266
15526
|
}
|
|
15267
15527
|
var require_fetch_timeout_default = createRule({
|
|
15268
15528
|
name: "require-fetch-timeout",
|
|
@@ -15300,30 +15560,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
15300
15560
|
}
|
|
15301
15561
|
function resolvesToGlobal(identifier) {
|
|
15302
15562
|
const scope = context.sourceCode.getScope(identifier);
|
|
15303
|
-
const variable =
|
|
15563
|
+
const variable = import_utils85.ASTUtils.findVariable(scope, identifier.name);
|
|
15304
15564
|
return variable === null || variable.defs.length === 0;
|
|
15305
15565
|
}
|
|
15306
15566
|
function isGlobalFetchCall2(callee) {
|
|
15307
|
-
if (callee.type ===
|
|
15567
|
+
if (callee.type === import_utils85.AST_NODE_TYPES.Identifier) {
|
|
15308
15568
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
15309
15569
|
}
|
|
15310
|
-
return callee.type ===
|
|
15570
|
+
return callee.type === import_utils85.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils85.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils85.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
15311
15571
|
}
|
|
15312
15572
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
15313
|
-
const variable =
|
|
15573
|
+
const variable = import_utils85.ASTUtils.findVariable(
|
|
15314
15574
|
context.sourceCode.getScope(identifier),
|
|
15315
15575
|
identifier.name
|
|
15316
15576
|
);
|
|
15317
15577
|
if (variable?.defs.length !== 1) return false;
|
|
15318
15578
|
const definition = variable.defs[0];
|
|
15319
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
15579
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== import_utils85.AST_NODE_TYPES.ObjectExpression || !initProvablyLacksSignal(definition.node.init)) {
|
|
15320
15580
|
return false;
|
|
15321
15581
|
}
|
|
15322
15582
|
for (const reference of variable.references) {
|
|
15323
15583
|
const ref = reference.identifier;
|
|
15324
15584
|
if (ref === identifier || ref === definition.name) continue;
|
|
15325
15585
|
const member = ref.parent;
|
|
15326
|
-
if (member.type !==
|
|
15586
|
+
if (member.type !== import_utils85.AST_NODE_TYPES.MemberExpression || member.object !== ref || member.computed || member.property.type !== import_utils85.AST_NODE_TYPES.Identifier || member.property.name === "signal" || member.parent.type !== import_utils85.AST_NODE_TYPES.AssignmentExpression || member.parent.left !== member) {
|
|
15327
15587
|
return false;
|
|
15328
15588
|
}
|
|
15329
15589
|
}
|
|
@@ -15338,7 +15598,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
15338
15598
|
if (node.arguments.length === 1 && first !== void 0 && !isInlineUrl(first, resolvesToGlobal)) {
|
|
15339
15599
|
return;
|
|
15340
15600
|
}
|
|
15341
|
-
if (init === void 0 || initProvablyLacksSignal(init) || init.type ===
|
|
15601
|
+
if (init === void 0 || initProvablyLacksSignal(init) || init.type === import_utils85.AST_NODE_TYPES.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
15342
15602
|
context.report({ node, messageId: "missingSignal" });
|
|
15343
15603
|
}
|
|
15344
15604
|
}
|
|
@@ -15347,7 +15607,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
15347
15607
|
});
|
|
15348
15608
|
|
|
15349
15609
|
// src/rules/require-interface-for-exported-class.ts
|
|
15350
|
-
var
|
|
15610
|
+
var import_utils86 = require("@typescript-eslint/utils");
|
|
15351
15611
|
var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
15352
15612
|
summary: "Require exported concrete classes with public behavior to declare a contract.",
|
|
15353
15613
|
rationale: "Consumers coupled only to a concrete class cannot substitute implementations or state the supported public capability independently of implementation details.",
|
|
@@ -15391,23 +15651,23 @@ var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
|
15391
15651
|
};
|
|
15392
15652
|
function hasPublicInstanceBehavior(node) {
|
|
15393
15653
|
return node.body.body.some((member) => {
|
|
15394
|
-
if (member.type ===
|
|
15395
|
-
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !==
|
|
15654
|
+
if (member.type === import_utils86.AST_NODE_TYPES.MethodDefinition) {
|
|
15655
|
+
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !== import_utils86.AST_NODE_TYPES.PrivateIdentifier;
|
|
15396
15656
|
}
|
|
15397
|
-
if (member.type !==
|
|
15657
|
+
if (member.type !== import_utils86.AST_NODE_TYPES.PropertyDefinition || member.static)
|
|
15398
15658
|
return false;
|
|
15399
|
-
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type ===
|
|
15400
|
-
return member.value?.type ===
|
|
15659
|
+
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type === import_utils86.AST_NODE_TYPES.PrivateIdentifier) return false;
|
|
15660
|
+
return member.value?.type === import_utils86.AST_NODE_TYPES.ArrowFunctionExpression || member.value?.type === import_utils86.AST_NODE_TYPES.FunctionExpression || member.typeAnnotation?.typeAnnotation.type === import_utils86.AST_NODE_TYPES.TSFunctionType;
|
|
15401
15661
|
});
|
|
15402
15662
|
}
|
|
15403
15663
|
function classBindings(statement) {
|
|
15404
|
-
const declaration = statement.type ===
|
|
15405
|
-
if (declaration?.type ===
|
|
15664
|
+
const declaration = statement.type === import_utils86.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15665
|
+
if (declaration?.type === import_utils86.AST_NODE_TYPES.ClassDeclaration) {
|
|
15406
15666
|
return declaration.id === null ? [] : [{ declaration, name: declaration.id.name }];
|
|
15407
15667
|
}
|
|
15408
|
-
if (declaration?.type !==
|
|
15668
|
+
if (declaration?.type !== import_utils86.AST_NODE_TYPES.VariableDeclaration) return [];
|
|
15409
15669
|
return declaration.declarations.flatMap(
|
|
15410
|
-
(item) => item.id.type ===
|
|
15670
|
+
(item) => item.id.type === import_utils86.AST_NODE_TYPES.Identifier && item.init?.type === import_utils86.AST_NODE_TYPES.ClassExpression ? [{ declaration: item.init, name: item.id.name }] : []
|
|
15411
15671
|
);
|
|
15412
15672
|
}
|
|
15413
15673
|
var require_interface_for_exported_class_default = createRule({
|
|
@@ -15438,7 +15698,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
15438
15698
|
}
|
|
15439
15699
|
const exported = /* @__PURE__ */ new Map();
|
|
15440
15700
|
for (const statement of program.body) {
|
|
15441
|
-
if (statement.type ===
|
|
15701
|
+
if (statement.type === import_utils86.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
15442
15702
|
for (const binding of classBindings(statement)) {
|
|
15443
15703
|
exported.set(binding.declaration, binding.name);
|
|
15444
15704
|
}
|
|
@@ -15447,18 +15707,18 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
15447
15707
|
if (specifier.exportKind === "type") continue;
|
|
15448
15708
|
const candidate2 = classes.get(specifier.local.name);
|
|
15449
15709
|
if (candidate2 === void 0) continue;
|
|
15450
|
-
const exportedName = specifier.exported.type ===
|
|
15710
|
+
const exportedName = specifier.exported.type === import_utils86.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
15451
15711
|
exported.set(candidate2, exportedName);
|
|
15452
15712
|
}
|
|
15453
15713
|
continue;
|
|
15454
15714
|
}
|
|
15455
|
-
if (statement.type !==
|
|
15456
|
-
if (statement.declaration.type ===
|
|
15715
|
+
if (statement.type !== import_utils86.AST_NODE_TYPES.ExportDefaultDeclaration) continue;
|
|
15716
|
+
if (statement.declaration.type === import_utils86.AST_NODE_TYPES.ClassDeclaration || statement.declaration.type === import_utils86.AST_NODE_TYPES.ClassExpression) {
|
|
15457
15717
|
exported.set(
|
|
15458
15718
|
statement.declaration,
|
|
15459
15719
|
statement.declaration.id?.name ?? "default"
|
|
15460
15720
|
);
|
|
15461
|
-
} else if (statement.declaration.type ===
|
|
15721
|
+
} else if (statement.declaration.type === import_utils86.AST_NODE_TYPES.Identifier) {
|
|
15462
15722
|
const candidate2 = classes.get(statement.declaration.name);
|
|
15463
15723
|
if (candidate2 !== void 0) {
|
|
15464
15724
|
exported.set(candidate2, statement.declaration.name);
|
|
@@ -15466,7 +15726,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
15466
15726
|
}
|
|
15467
15727
|
}
|
|
15468
15728
|
for (const [declaration, exportedName] of exported) {
|
|
15469
|
-
const extendsLocalAbstractBase = declaration.superClass?.type ===
|
|
15729
|
+
const extendsLocalAbstractBase = declaration.superClass?.type === import_utils86.AST_NODE_TYPES.Identifier && abstractBases.has(declaration.superClass.name);
|
|
15470
15730
|
if (declaration.abstract || declaration.implements.length > 0 || extendsLocalAbstractBase || !hasPublicInstanceBehavior(declaration)) continue;
|
|
15471
15731
|
context.report({
|
|
15472
15732
|
node: declaration.id ?? declaration,
|
|
@@ -15480,7 +15740,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
15480
15740
|
});
|
|
15481
15741
|
|
|
15482
15742
|
// src/rules/require-port-for-service.ts
|
|
15483
|
-
var
|
|
15743
|
+
var import_utils87 = require("@typescript-eslint/utils");
|
|
15484
15744
|
var REQUIRE_PORT_FOR_SERVICE_DOCUMENTATION = {
|
|
15485
15745
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
15486
15746
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -15505,45 +15765,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
15505
15765
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
15506
15766
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
15507
15767
|
var staticMemberName6 = (member) => {
|
|
15508
|
-
if (member.property.type ===
|
|
15509
|
-
if (!member.computed && member.property.type ===
|
|
15510
|
-
return member.computed && member.property.type ===
|
|
15768
|
+
if (member.property.type === import_utils87.AST_NODE_TYPES.PrivateIdentifier) return `#${member.property.name}`;
|
|
15769
|
+
if (!member.computed && member.property.type === import_utils87.AST_NODE_TYPES.Identifier) return member.property.name;
|
|
15770
|
+
return member.computed && member.property.type === import_utils87.AST_NODE_TYPES.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
15511
15771
|
};
|
|
15512
15772
|
var detachedValueExports = (program) => {
|
|
15513
15773
|
const names = /* @__PURE__ */ new Set();
|
|
15514
15774
|
for (const statement of program.body) {
|
|
15515
|
-
if (statement.type ===
|
|
15775
|
+
if (statement.type === import_utils87.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
15516
15776
|
for (const specifier of statement.specifiers) {
|
|
15517
15777
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
15518
15778
|
}
|
|
15519
|
-
} else if (statement.type ===
|
|
15779
|
+
} else if (statement.type === import_utils87.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils87.AST_NODE_TYPES.Identifier) {
|
|
15520
15780
|
names.add(statement.declaration.name);
|
|
15521
|
-
} else if (statement.type ===
|
|
15781
|
+
} else if (statement.type === import_utils87.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils87.AST_NODE_TYPES.Identifier) {
|
|
15522
15782
|
names.add(statement.expression.name);
|
|
15523
15783
|
}
|
|
15524
15784
|
}
|
|
15525
15785
|
return names;
|
|
15526
15786
|
};
|
|
15527
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
15787
|
+
var isExportedClass2 = (node, detached) => node.parent.type === import_utils87.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils87.AST_NODE_TYPES.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
15528
15788
|
var readTypeReference = (annotation) => {
|
|
15529
|
-
if (annotation?.type ===
|
|
15789
|
+
if (annotation?.type === import_utils87.AST_NODE_TYPES.TSUnionType) {
|
|
15530
15790
|
const members = annotation.types.filter(
|
|
15531
|
-
(member) => member.type !==
|
|
15791
|
+
(member) => member.type !== import_utils87.AST_NODE_TYPES.TSUndefinedKeyword && member.type !== import_utils87.AST_NODE_TYPES.TSNullKeyword
|
|
15532
15792
|
);
|
|
15533
15793
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
15534
15794
|
}
|
|
15535
|
-
if (annotation === void 0 || annotation.type !==
|
|
15795
|
+
if (annotation === void 0 || annotation.type !== import_utils87.AST_NODE_TYPES.TSTypeReference) return null;
|
|
15536
15796
|
const { typeName } = annotation;
|
|
15537
|
-
const rightmost = typeName.type ===
|
|
15797
|
+
const rightmost = typeName.type === import_utils87.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils87.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
15538
15798
|
if (rightmost === null) return null;
|
|
15539
15799
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
15540
15800
|
};
|
|
15541
|
-
var qualifiedName = (name) => name.type ===
|
|
15801
|
+
var qualifiedName = (name) => name.type === import_utils87.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils87.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
15542
15802
|
var propertySignatureTypes = (members) => {
|
|
15543
15803
|
const types = /* @__PURE__ */ new Map();
|
|
15544
15804
|
for (const member of members) {
|
|
15545
|
-
if (member.type !==
|
|
15546
|
-
if (member.computed || member.key.type !==
|
|
15805
|
+
if (member.type !== import_utils87.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15806
|
+
if (member.computed || member.key.type !== import_utils87.AST_NODE_TYPES.Identifier) continue;
|
|
15547
15807
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
15548
15808
|
if (reference === null) continue;
|
|
15549
15809
|
types.set(member.key.name, reference);
|
|
@@ -15554,18 +15814,18 @@ var fileTypeIndex = (program) => {
|
|
|
15554
15814
|
const objects = /* @__PURE__ */ new Map();
|
|
15555
15815
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
15556
15816
|
for (const statement of program.body) {
|
|
15557
|
-
const declaration = statement.type ===
|
|
15558
|
-
if (declaration?.type ===
|
|
15817
|
+
const declaration = statement.type === import_utils87.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15818
|
+
if (declaration?.type === import_utils87.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
15559
15819
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
15560
15820
|
continue;
|
|
15561
15821
|
}
|
|
15562
|
-
if (declaration?.type !==
|
|
15822
|
+
if (declaration?.type !== import_utils87.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
15563
15823
|
const aliased = declaration.typeAnnotation;
|
|
15564
|
-
if (aliased.type ===
|
|
15824
|
+
if (aliased.type === import_utils87.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils87.AST_NODE_TYPES.TSConstructorType) {
|
|
15565
15825
|
functionAliases.add(declaration.id.name);
|
|
15566
15826
|
continue;
|
|
15567
15827
|
}
|
|
15568
|
-
const literals = aliased.type ===
|
|
15828
|
+
const literals = aliased.type === import_utils87.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils87.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils87.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
15569
15829
|
if (literals.length === 0) continue;
|
|
15570
15830
|
const merged = /* @__PURE__ */ new Map();
|
|
15571
15831
|
for (const literal of literals) {
|
|
@@ -15594,10 +15854,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
15594
15854
|
while (pending.length > 0) {
|
|
15595
15855
|
const current = pending.pop();
|
|
15596
15856
|
if (current === void 0) break;
|
|
15597
|
-
if (current.type ===
|
|
15598
|
-
const expression = current.type ===
|
|
15599
|
-
const storedField = expression?.type ===
|
|
15600
|
-
if (expression?.type !==
|
|
15857
|
+
if (current.type === import_utils87.AST_NODE_TYPES.ArrowFunctionExpression || current.type === import_utils87.AST_NODE_TYPES.FunctionExpression || current.type === import_utils87.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils87.AST_NODE_TYPES.ClassExpression || current.type === import_utils87.AST_NODE_TYPES.ClassDeclaration) continue;
|
|
15858
|
+
const expression = current.type === import_utils87.AST_NODE_TYPES.ExpressionStatement ? current.expression : null;
|
|
15859
|
+
const storedField = expression?.type === import_utils87.AST_NODE_TYPES.AssignmentExpression && expression.left.type === import_utils87.AST_NODE_TYPES.MemberExpression && expression.left.object.type === import_utils87.AST_NODE_TYPES.ThisExpression ? staticMemberName6(expression.left) : null;
|
|
15860
|
+
if (expression?.type !== import_utils87.AST_NODE_TYPES.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== import_utils87.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils87.AST_NODE_TYPES.ThisExpression || storedField === null) {
|
|
15601
15861
|
for (const key of Object.keys(current)) {
|
|
15602
15862
|
if (key === "parent") continue;
|
|
15603
15863
|
const value = current[key];
|
|
@@ -15610,14 +15870,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
15610
15870
|
continue;
|
|
15611
15871
|
}
|
|
15612
15872
|
let source = expression.right;
|
|
15613
|
-
while (source.type ===
|
|
15614
|
-
if (source.type ===
|
|
15873
|
+
while (source.type === import_utils87.AST_NODE_TYPES.TSNonNullExpression || source.type === import_utils87.AST_NODE_TYPES.TSAsExpression || source.type === import_utils87.AST_NODE_TYPES.TSSatisfiesExpression || source.type === import_utils87.AST_NODE_TYPES.TSTypeAssertion) source = source.expression;
|
|
15874
|
+
if (source.type === import_utils87.AST_NODE_TYPES.NewExpression) {
|
|
15615
15875
|
constructedFields += 1;
|
|
15616
|
-
} else if (source.type ===
|
|
15876
|
+
} else if (source.type === import_utils87.AST_NODE_TYPES.Identifier) {
|
|
15617
15877
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
15618
15878
|
fields.add(storedField);
|
|
15619
15879
|
storedFieldsFrom.set(source.name, fields);
|
|
15620
|
-
} else if (source.type ===
|
|
15880
|
+
} else if (source.type === import_utils87.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils87.AST_NODE_TYPES.Identifier) {
|
|
15621
15881
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
15622
15882
|
fields.add(storedField);
|
|
15623
15883
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -15635,7 +15895,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
15635
15895
|
const collaborators = [];
|
|
15636
15896
|
for (const parameter of ctor.value.params) {
|
|
15637
15897
|
for (const reference of parameterCollaborators(parameter, declared, storedMemberFieldsFrom)) {
|
|
15638
|
-
const fields = parameter.type ===
|
|
15898
|
+
const fields = parameter.type === import_utils87.AST_NODE_TYPES.TSParameterProperty ? [reference.name] : reference.fields.length > 0 ? reference.fields : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
15639
15899
|
if (fields.length === 0) continue;
|
|
15640
15900
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
15641
15901
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -15650,8 +15910,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
15650
15910
|
};
|
|
15651
15911
|
var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
15652
15912
|
let target = parameter;
|
|
15653
|
-
if (target.type ===
|
|
15654
|
-
if (target.type ===
|
|
15913
|
+
if (target.type === import_utils87.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15914
|
+
if (target.type === import_utils87.AST_NODE_TYPES.ObjectPattern) {
|
|
15655
15915
|
return objectPatternCollaborators(target, declared);
|
|
15656
15916
|
}
|
|
15657
15917
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -15660,9 +15920,9 @@ var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
|
15660
15920
|
};
|
|
15661
15921
|
var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
15662
15922
|
let target = annotated;
|
|
15663
|
-
if (target.type ===
|
|
15664
|
-
if (target.type ===
|
|
15665
|
-
if (target.type !==
|
|
15923
|
+
if (target.type === import_utils87.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
15924
|
+
if (target.type === import_utils87.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15925
|
+
if (target.type !== import_utils87.AST_NODE_TYPES.Identifier) return [];
|
|
15666
15926
|
const members = bagMemberTypes(target.typeAnnotation?.typeAnnotation, declared);
|
|
15667
15927
|
if (members === null) return [];
|
|
15668
15928
|
const storedMembers = storedMemberFieldsFrom.get(target.name);
|
|
@@ -15678,9 +15938,9 @@ var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
|
15678
15938
|
};
|
|
15679
15939
|
var namedParameterCollaborator = (annotated) => {
|
|
15680
15940
|
let target = annotated;
|
|
15681
|
-
if (target.type ===
|
|
15682
|
-
if (target.type ===
|
|
15683
|
-
if (target.type !==
|
|
15941
|
+
if (target.type === import_utils87.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
15942
|
+
if (target.type === import_utils87.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15943
|
+
if (target.type !== import_utils87.AST_NODE_TYPES.Identifier) return null;
|
|
15684
15944
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
15685
15945
|
if (reference === null) return null;
|
|
15686
15946
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -15692,11 +15952,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
15692
15952
|
if (members === null) return [];
|
|
15693
15953
|
const collaborators = [];
|
|
15694
15954
|
for (const property of pattern.properties) {
|
|
15695
|
-
if (property.type !==
|
|
15696
|
-
if (property.key.type !==
|
|
15955
|
+
if (property.type !== import_utils87.AST_NODE_TYPES.Property || property.computed) continue;
|
|
15956
|
+
if (property.key.type !== import_utils87.AST_NODE_TYPES.Identifier) continue;
|
|
15697
15957
|
const key = property.key.name;
|
|
15698
|
-
const bound = property.value.type ===
|
|
15699
|
-
if (bound.type !==
|
|
15958
|
+
const bound = property.value.type === import_utils87.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
15959
|
+
if (bound.type !== import_utils87.AST_NODE_TYPES.Identifier) continue;
|
|
15700
15960
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
15701
15961
|
const reference = members.get(key);
|
|
15702
15962
|
if (reference === void 0) continue;
|
|
@@ -15706,21 +15966,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
15706
15966
|
};
|
|
15707
15967
|
var bagMemberTypes = (annotation, declared) => {
|
|
15708
15968
|
if (annotation === void 0) return null;
|
|
15709
|
-
if (annotation.type ===
|
|
15969
|
+
if (annotation.type === import_utils87.AST_NODE_TYPES.TSTypeLiteral) {
|
|
15710
15970
|
return propertySignatureTypes(annotation.members);
|
|
15711
15971
|
}
|
|
15712
|
-
if (annotation.type !==
|
|
15972
|
+
if (annotation.type !== import_utils87.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils87.AST_NODE_TYPES.Identifier) {
|
|
15713
15973
|
return null;
|
|
15714
15974
|
}
|
|
15715
15975
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
15716
15976
|
};
|
|
15717
15977
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
15718
|
-
if (node.type ===
|
|
15978
|
+
if (node.type === import_utils87.AST_NODE_TYPES.CallExpression) {
|
|
15719
15979
|
const { callee } = node;
|
|
15720
|
-
if (callee.type ===
|
|
15721
|
-
return callee.type ===
|
|
15980
|
+
if (callee.type === import_utils87.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
15981
|
+
return callee.type === import_utils87.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils87.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
15722
15982
|
}
|
|
15723
|
-
return node.type ===
|
|
15983
|
+
return node.type === import_utils87.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils87.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
15724
15984
|
});
|
|
15725
15985
|
var subtreeHas = (root, found) => {
|
|
15726
15986
|
let hit = false;
|
|
@@ -15747,19 +16007,19 @@ var invokedInstanceField = (call) => {
|
|
|
15747
16007
|
const direct = instanceField(call.callee);
|
|
15748
16008
|
if (direct !== null) return direct;
|
|
15749
16009
|
let callee = call.callee;
|
|
15750
|
-
while (callee.type ===
|
|
15751
|
-
return callee.type ===
|
|
16010
|
+
while (callee.type === import_utils87.AST_NODE_TYPES.ChainExpression || callee.type === import_utils87.AST_NODE_TYPES.TSAsExpression || callee.type === import_utils87.AST_NODE_TYPES.TSNonNullExpression || callee.type === import_utils87.AST_NODE_TYPES.TSSatisfiesExpression || callee.type === import_utils87.AST_NODE_TYPES.TSTypeAssertion) callee = callee.expression;
|
|
16011
|
+
return callee.type === import_utils87.AST_NODE_TYPES.MemberExpression ? instanceField(callee.object) : null;
|
|
15752
16012
|
};
|
|
15753
16013
|
var instanceField = (candidate2) => {
|
|
15754
16014
|
let node = candidate2;
|
|
15755
|
-
while (node.type ===
|
|
15756
|
-
return node.type ===
|
|
16015
|
+
while (node.type === import_utils87.AST_NODE_TYPES.ChainExpression || node.type === import_utils87.AST_NODE_TYPES.TSAsExpression || node.type === import_utils87.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils87.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils87.AST_NODE_TYPES.TSTypeAssertion) node = node.expression;
|
|
16016
|
+
return node.type === import_utils87.AST_NODE_TYPES.MemberExpression && node.object.type === import_utils87.AST_NODE_TYPES.ThisExpression ? staticMemberName6(node) : null;
|
|
15757
16017
|
};
|
|
15758
16018
|
var behaviorallyInvokedFields = (body2) => {
|
|
15759
16019
|
const invoked = /* @__PURE__ */ new Set();
|
|
15760
16020
|
const visit = (current) => {
|
|
15761
|
-
if (current.type ===
|
|
15762
|
-
if (current.type ===
|
|
16021
|
+
if (current.type === import_utils87.AST_NODE_TYPES.ClassDeclaration || current.type === import_utils87.AST_NODE_TYPES.ClassExpression || current.type === import_utils87.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils87.AST_NODE_TYPES.FunctionExpression) return;
|
|
16022
|
+
if (current.type === import_utils87.AST_NODE_TYPES.CallExpression) {
|
|
15763
16023
|
const field = invokedInstanceField(current);
|
|
15764
16024
|
if (field !== null) invoked.add(field);
|
|
15765
16025
|
}
|
|
@@ -15772,14 +16032,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
15772
16032
|
}
|
|
15773
16033
|
};
|
|
15774
16034
|
for (const member of body2.body) {
|
|
15775
|
-
if (member.type ===
|
|
15776
|
-
if (member.type ===
|
|
16035
|
+
if (member.type === import_utils87.AST_NODE_TYPES.StaticBlock || member.static) continue;
|
|
16036
|
+
if (member.type === import_utils87.AST_NODE_TYPES.MethodDefinition) {
|
|
15777
16037
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
15778
16038
|
continue;
|
|
15779
16039
|
}
|
|
15780
|
-
if (member.type !==
|
|
16040
|
+
if (member.type !== import_utils87.AST_NODE_TYPES.PropertyDefinition || member.value === null) continue;
|
|
15781
16041
|
visit(
|
|
15782
|
-
member.value.type ===
|
|
16042
|
+
member.value.type === import_utils87.AST_NODE_TYPES.ArrowFunctionExpression ? member.value.body : member.value
|
|
15783
16043
|
);
|
|
15784
16044
|
}
|
|
15785
16045
|
return invoked;
|
|
@@ -15799,26 +16059,26 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
15799
16059
|
var fileInterfaceNames = (program) => {
|
|
15800
16060
|
const names = [];
|
|
15801
16061
|
for (const statement of program.body) {
|
|
15802
|
-
const declaration = statement.type ===
|
|
15803
|
-
if (declaration?.type ===
|
|
16062
|
+
const declaration = statement.type === import_utils87.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
16063
|
+
if (declaration?.type === import_utils87.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
15804
16064
|
}
|
|
15805
16065
|
return names;
|
|
15806
16066
|
};
|
|
15807
16067
|
var publicMethodNames = (body2, functionAliases) => {
|
|
15808
16068
|
const names = [];
|
|
15809
16069
|
for (const member of body2.body) {
|
|
15810
|
-
if (member.type ===
|
|
16070
|
+
if (member.type === import_utils87.AST_NODE_TYPES.PropertyDefinition) {
|
|
15811
16071
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
15812
|
-
if (member.key.type ===
|
|
15813
|
-
if (member.value?.type !==
|
|
15814
|
-
names.push(member.key.type ===
|
|
16072
|
+
if (member.key.type === import_utils87.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
16073
|
+
if (member.value?.type !== import_utils87.AST_NODE_TYPES.ArrowFunctionExpression && member.value?.type !== import_utils87.AST_NODE_TYPES.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== import_utils87.AST_NODE_TYPES.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === import_utils87.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils87.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
16074
|
+
names.push(member.key.type === import_utils87.AST_NODE_TYPES.Identifier ? member.key.name : "\u2026");
|
|
15815
16075
|
continue;
|
|
15816
16076
|
}
|
|
15817
|
-
if (member.type !==
|
|
16077
|
+
if (member.type !== import_utils87.AST_NODE_TYPES.MethodDefinition) continue;
|
|
15818
16078
|
if (member.kind !== "method" || member.static) continue;
|
|
15819
16079
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
15820
|
-
if (member.key.type ===
|
|
15821
|
-
if (member.key.type ===
|
|
16080
|
+
if (member.key.type === import_utils87.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
16081
|
+
if (member.key.type === import_utils87.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
15822
16082
|
else names.push("\u2026");
|
|
15823
16083
|
}
|
|
15824
16084
|
return names;
|
|
@@ -15826,13 +16086,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
15826
16086
|
var isFluentConstructionObject = (node, getText) => {
|
|
15827
16087
|
if (node.id === null) return false;
|
|
15828
16088
|
const methods = node.body.body.filter(
|
|
15829
|
-
(member) => member.type ===
|
|
16089
|
+
(member) => member.type === import_utils87.AST_NODE_TYPES.MethodDefinition && member.kind === "method" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.value.body !== null
|
|
15830
16090
|
);
|
|
15831
16091
|
if (methods.length === 0) return false;
|
|
15832
16092
|
return methods.every((member) => {
|
|
15833
16093
|
const result = member.value.returnType?.typeAnnotation;
|
|
15834
16094
|
if (result === void 0) return false;
|
|
15835
|
-
const returnsOwnType = result.type ===
|
|
16095
|
+
const returnsOwnType = result.type === import_utils87.AST_NODE_TYPES.TSTypeReference && result.typeName.type === import_utils87.AST_NODE_TYPES.Identifier && result.typeName.name === node.id?.name;
|
|
15836
16096
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
15837
16097
|
});
|
|
15838
16098
|
};
|
|
@@ -15840,10 +16100,10 @@ function localClassAbstractness(program) {
|
|
|
15840
16100
|
const classes = /* @__PURE__ */ new Map();
|
|
15841
16101
|
const parents = /* @__PURE__ */ new Map();
|
|
15842
16102
|
for (const statement of program.body) {
|
|
15843
|
-
const declaration = statement.type ===
|
|
15844
|
-
if (declaration?.type ===
|
|
16103
|
+
const declaration = statement.type === import_utils87.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils87.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
16104
|
+
if (declaration?.type === import_utils87.AST_NODE_TYPES.ClassDeclaration && declaration.id !== null) {
|
|
15845
16105
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
15846
|
-
if (declaration.superClass?.type ===
|
|
16106
|
+
if (declaration.superClass?.type === import_utils87.AST_NODE_TYPES.Identifier) {
|
|
15847
16107
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
15848
16108
|
}
|
|
15849
16109
|
}
|
|
@@ -15865,43 +16125,43 @@ function localInterfaceSurfaces(program) {
|
|
|
15865
16125
|
const parents = /* @__PURE__ */ new Map();
|
|
15866
16126
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
15867
16127
|
for (const statement of program.body) {
|
|
15868
|
-
const declaration = statement.type ===
|
|
15869
|
-
if (declaration?.type ===
|
|
16128
|
+
const declaration = statement.type === import_utils87.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
16129
|
+
if (declaration?.type === import_utils87.AST_NODE_TYPES.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === import_utils87.AST_NODE_TYPES.TSFunctionType || declaration.typeAnnotation.type === import_utils87.AST_NODE_TYPES.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
15870
16130
|
}
|
|
15871
16131
|
for (const statement of program.body) {
|
|
15872
|
-
const declaration = statement.type ===
|
|
15873
|
-
if (declaration?.type ===
|
|
16132
|
+
const declaration = statement.type === import_utils87.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
16133
|
+
if (declaration?.type === import_utils87.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
15874
16134
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
15875
|
-
const parts = declaration.typeAnnotation.type ===
|
|
16135
|
+
const parts = declaration.typeAnnotation.type === import_utils87.AST_NODE_TYPES.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
15876
16136
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
15877
16137
|
for (const part of parts) {
|
|
15878
|
-
if (part.type ===
|
|
16138
|
+
if (part.type === import_utils87.AST_NODE_TYPES.TSTypeReference && part.typeName.type === import_utils87.AST_NODE_TYPES.Identifier) {
|
|
15879
16139
|
inherited.push(part.typeName.name);
|
|
15880
16140
|
continue;
|
|
15881
16141
|
}
|
|
15882
|
-
if (part.type !==
|
|
16142
|
+
if (part.type !== import_utils87.AST_NODE_TYPES.TSTypeLiteral) continue;
|
|
15883
16143
|
for (const member of part.members) {
|
|
15884
|
-
if (member.type !==
|
|
15885
|
-
if (member.computed || member.key.type !==
|
|
15886
|
-
if (member.type ===
|
|
16144
|
+
if (member.type !== import_utils87.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils87.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
16145
|
+
if (member.computed || member.key.type !== import_utils87.AST_NODE_TYPES.Identifier) continue;
|
|
16146
|
+
if (member.type === import_utils87.AST_NODE_TYPES.TSMethodSignature) {
|
|
15887
16147
|
callables2.add(member.key.name);
|
|
15888
16148
|
continue;
|
|
15889
16149
|
}
|
|
15890
|
-
if (member.type !==
|
|
16150
|
+
if (member.type !== import_utils87.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15891
16151
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
15892
|
-
if (annotation?.type ===
|
|
16152
|
+
if (annotation?.type === import_utils87.AST_NODE_TYPES.TSFunctionType || annotation?.type === import_utils87.AST_NODE_TYPES.TSTypeReference && annotation.typeName.type === import_utils87.AST_NODE_TYPES.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(member.key.name);
|
|
15893
16153
|
}
|
|
15894
16154
|
}
|
|
15895
16155
|
interfaces.set(declaration.id.name, callables2);
|
|
15896
16156
|
parents.set(declaration.id.name, inherited);
|
|
15897
16157
|
continue;
|
|
15898
16158
|
}
|
|
15899
|
-
if (declaration?.type !==
|
|
16159
|
+
if (declaration?.type !== import_utils87.AST_NODE_TYPES.TSInterfaceDeclaration) continue;
|
|
15900
16160
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
15901
16161
|
for (const member of declaration.body.body) {
|
|
15902
|
-
if (member.type !==
|
|
15903
|
-
if (member.computed || member.key.type !==
|
|
15904
|
-
if (member.type ===
|
|
16162
|
+
if (member.type !== import_utils87.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils87.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
16163
|
+
if (member.computed || member.key.type !== import_utils87.AST_NODE_TYPES.Identifier) continue;
|
|
16164
|
+
if (member.type === import_utils87.AST_NODE_TYPES.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === import_utils87.AST_NODE_TYPES.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === import_utils87.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils87.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(member.key.name);
|
|
15905
16165
|
}
|
|
15906
16166
|
interfaces.set(declaration.id.name, callables);
|
|
15907
16167
|
parents.set(
|
|
@@ -15909,7 +16169,7 @@ function localInterfaceSurfaces(program) {
|
|
|
15909
16169
|
[
|
|
15910
16170
|
...parents.get(declaration.id.name) ?? [],
|
|
15911
16171
|
...declaration.extends.flatMap(
|
|
15912
|
-
(heritage) => heritage.expression.type ===
|
|
16172
|
+
(heritage) => heritage.expression.type === import_utils87.AST_NODE_TYPES.Identifier ? [heritage.expression.name] : ["*"]
|
|
15913
16173
|
)
|
|
15914
16174
|
]
|
|
15915
16175
|
);
|
|
@@ -15936,7 +16196,7 @@ function localInterfaceSurfaces(program) {
|
|
|
15936
16196
|
}
|
|
15937
16197
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
15938
16198
|
if (node.superClass !== null) {
|
|
15939
|
-
if (node.superClass.type !==
|
|
16199
|
+
if (node.superClass.type !== import_utils87.AST_NODE_TYPES.Identifier) return true;
|
|
15940
16200
|
const localAbstract = classes.get(node.superClass.name);
|
|
15941
16201
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
15942
16202
|
}
|
|
@@ -15948,7 +16208,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
15948
16208
|
if (node.implements.length === 0) return false;
|
|
15949
16209
|
const combined = /* @__PURE__ */ new Set();
|
|
15950
16210
|
for (const implementation of node.implements) {
|
|
15951
|
-
if (implementation.expression.type !==
|
|
16211
|
+
if (implementation.expression.type !== import_utils87.AST_NODE_TYPES.Identifier) return true;
|
|
15952
16212
|
const name = implementation.expression.name;
|
|
15953
16213
|
const localAbstract = classes.get(name);
|
|
15954
16214
|
if (localAbstract === true) return true;
|
|
@@ -15991,7 +16251,7 @@ var require_port_for_service_default = createRule({
|
|
|
15991
16251
|
if (node.abstract === true) return;
|
|
15992
16252
|
if (node.decorators.length > 0) return;
|
|
15993
16253
|
const ctor = node.body.body.find(
|
|
15994
|
-
(member) => member.type ===
|
|
16254
|
+
(member) => member.type === import_utils87.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
15995
16255
|
);
|
|
15996
16256
|
if (ctor === void 0) return;
|
|
15997
16257
|
const constructorFacts = readConstructor(
|
|
@@ -16026,7 +16286,7 @@ var require_port_for_service_default = createRule({
|
|
|
16026
16286
|
});
|
|
16027
16287
|
|
|
16028
16288
|
// src/rules/require-sql-access-class.ts
|
|
16029
|
-
var
|
|
16289
|
+
var import_utils88 = require("@typescript-eslint/utils");
|
|
16030
16290
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
16031
16291
|
"all",
|
|
16032
16292
|
"batch",
|
|
@@ -16120,9 +16380,9 @@ var REQUIRE_SQL_ACCESS_CLASS_DOCUMENTATION = {
|
|
|
16120
16380
|
]
|
|
16121
16381
|
};
|
|
16122
16382
|
function memberName5(node) {
|
|
16123
|
-
if (!node.computed && node.property.type ===
|
|
16383
|
+
if (!node.computed && node.property.type === import_utils88.AST_NODE_TYPES.Identifier)
|
|
16124
16384
|
return node.property.name;
|
|
16125
|
-
if (node.computed && node.property.type ===
|
|
16385
|
+
if (node.computed && node.property.type === import_utils88.AST_NODE_TYPES.Literal && typeof node.property.value === "string")
|
|
16126
16386
|
return node.property.value;
|
|
16127
16387
|
return null;
|
|
16128
16388
|
}
|
|
@@ -16134,89 +16394,89 @@ function isDatabaseOperation(method, receiver) {
|
|
|
16134
16394
|
return BUILDER_SHORT_TERMINALS.has(method) && expressionCallsBuilder(receiver);
|
|
16135
16395
|
}
|
|
16136
16396
|
function databaseReceiver(node) {
|
|
16137
|
-
if (node.type ===
|
|
16397
|
+
if (node.type === import_utils88.AST_NODE_TYPES.Identifier)
|
|
16138
16398
|
return DATABASE_NAMES.test(node.name);
|
|
16139
|
-
if (node.type !==
|
|
16399
|
+
if (node.type !== import_utils88.AST_NODE_TYPES.MemberExpression) return false;
|
|
16140
16400
|
const name = memberName5(node);
|
|
16141
16401
|
return name === "DB" || name !== null && DATABASE_NAMES.test(name);
|
|
16142
16402
|
}
|
|
16143
16403
|
function databaseRootMember(node) {
|
|
16144
16404
|
let current = node;
|
|
16145
16405
|
for (; ; ) {
|
|
16146
|
-
if (current.type ===
|
|
16406
|
+
if (current.type === import_utils88.AST_NODE_TYPES.ChainExpression) {
|
|
16147
16407
|
current = current.expression;
|
|
16148
16408
|
continue;
|
|
16149
16409
|
}
|
|
16150
|
-
if (current.type ===
|
|
16410
|
+
if (current.type === import_utils88.AST_NODE_TYPES.TSAsExpression || current.type === import_utils88.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils88.AST_NODE_TYPES.TSTypeAssertion) {
|
|
16151
16411
|
current = current.expression;
|
|
16152
16412
|
continue;
|
|
16153
16413
|
}
|
|
16154
|
-
if (current.type ===
|
|
16155
|
-
if (current.callee.type !==
|
|
16414
|
+
if (current.type === import_utils88.AST_NODE_TYPES.CallExpression) {
|
|
16415
|
+
if (current.callee.type !== import_utils88.AST_NODE_TYPES.MemberExpression) return null;
|
|
16156
16416
|
current = current.callee.object;
|
|
16157
16417
|
continue;
|
|
16158
16418
|
}
|
|
16159
|
-
if (current.type ===
|
|
16160
|
-
if (current.object.type ===
|
|
16419
|
+
if (current.type === import_utils88.AST_NODE_TYPES.MemberExpression) {
|
|
16420
|
+
if (current.object.type === import_utils88.AST_NODE_TYPES.ThisExpression)
|
|
16161
16421
|
return memberName5(current);
|
|
16162
16422
|
current = current.object;
|
|
16163
16423
|
continue;
|
|
16164
16424
|
}
|
|
16165
|
-
return current.type ===
|
|
16425
|
+
return current.type === import_utils88.AST_NODE_TYPES.Identifier ? current.name : null;
|
|
16166
16426
|
}
|
|
16167
16427
|
}
|
|
16168
16428
|
function expressionHasDatabaseMarker(node) {
|
|
16169
16429
|
let current = node;
|
|
16170
16430
|
for (; ; ) {
|
|
16171
|
-
if (current.type ===
|
|
16431
|
+
if (current.type === import_utils88.AST_NODE_TYPES.ChainExpression) {
|
|
16172
16432
|
current = current.expression;
|
|
16173
16433
|
continue;
|
|
16174
16434
|
}
|
|
16175
|
-
if (current.type ===
|
|
16435
|
+
if (current.type === import_utils88.AST_NODE_TYPES.TSAsExpression || current.type === import_utils88.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils88.AST_NODE_TYPES.TSTypeAssertion) {
|
|
16176
16436
|
current = current.expression;
|
|
16177
16437
|
continue;
|
|
16178
16438
|
}
|
|
16179
|
-
if (current.type ===
|
|
16180
|
-
if (current.callee.type !==
|
|
16439
|
+
if (current.type === import_utils88.AST_NODE_TYPES.CallExpression) {
|
|
16440
|
+
if (current.callee.type !== import_utils88.AST_NODE_TYPES.MemberExpression) return false;
|
|
16181
16441
|
current = current.callee.object;
|
|
16182
16442
|
continue;
|
|
16183
16443
|
}
|
|
16184
|
-
if (current.type ===
|
|
16444
|
+
if (current.type === import_utils88.AST_NODE_TYPES.MemberExpression) {
|
|
16185
16445
|
const name = memberName5(current);
|
|
16186
16446
|
if (name === "DB" || name !== null && DATABASE_NAMES.test(name))
|
|
16187
16447
|
return true;
|
|
16188
16448
|
current = current.object;
|
|
16189
16449
|
continue;
|
|
16190
16450
|
}
|
|
16191
|
-
return current.type ===
|
|
16451
|
+
return current.type === import_utils88.AST_NODE_TYPES.Identifier && DATABASE_NAMES.test(current.name);
|
|
16192
16452
|
}
|
|
16193
16453
|
}
|
|
16194
16454
|
function expressionCallsBuilder(node) {
|
|
16195
16455
|
let current = node;
|
|
16196
16456
|
for (; ; ) {
|
|
16197
|
-
if (current.type ===
|
|
16457
|
+
if (current.type === import_utils88.AST_NODE_TYPES.ChainExpression) {
|
|
16198
16458
|
current = current.expression;
|
|
16199
16459
|
continue;
|
|
16200
16460
|
}
|
|
16201
|
-
if (current.type ===
|
|
16461
|
+
if (current.type === import_utils88.AST_NODE_TYPES.TSAsExpression || current.type === import_utils88.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils88.AST_NODE_TYPES.TSTypeAssertion) {
|
|
16202
16462
|
current = current.expression;
|
|
16203
16463
|
continue;
|
|
16204
16464
|
}
|
|
16205
|
-
if (current.type ===
|
|
16206
|
-
if (current.callee.type !==
|
|
16465
|
+
if (current.type === import_utils88.AST_NODE_TYPES.CallExpression) {
|
|
16466
|
+
if (current.callee.type !== import_utils88.AST_NODE_TYPES.MemberExpression) return false;
|
|
16207
16467
|
const name = memberName5(current.callee);
|
|
16208
16468
|
if (name !== null && BUILDER_METHODS.has(name)) return true;
|
|
16209
16469
|
current = current.callee.object;
|
|
16210
16470
|
continue;
|
|
16211
16471
|
}
|
|
16212
|
-
if (current.type !==
|
|
16472
|
+
if (current.type !== import_utils88.AST_NODE_TYPES.MemberExpression) return false;
|
|
16213
16473
|
current = current.object;
|
|
16214
16474
|
}
|
|
16215
16475
|
}
|
|
16216
16476
|
function owningClass2(node) {
|
|
16217
16477
|
let current = node.parent;
|
|
16218
16478
|
while (current != null) {
|
|
16219
|
-
if (current.type ===
|
|
16479
|
+
if (current.type === import_utils88.AST_NODE_TYPES.ClassDeclaration || current.type === import_utils88.AST_NODE_TYPES.ClassExpression)
|
|
16220
16480
|
return current;
|
|
16221
16481
|
current = current.parent;
|
|
16222
16482
|
}
|
|
@@ -16225,25 +16485,25 @@ function owningClass2(node) {
|
|
|
16225
16485
|
function injectedMembers(owner) {
|
|
16226
16486
|
const injected = /* @__PURE__ */ new Set();
|
|
16227
16487
|
const constructor = owner.body.body.find(
|
|
16228
|
-
(member) => member.type ===
|
|
16488
|
+
(member) => member.type === import_utils88.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
16229
16489
|
);
|
|
16230
16490
|
if (constructor === void 0) return injected;
|
|
16231
16491
|
const parameters = /* @__PURE__ */ new Set();
|
|
16232
16492
|
for (const parameter of constructor.value.params) {
|
|
16233
16493
|
for (const name of parameterNames(parameter)) parameters.add(name);
|
|
16234
|
-
if (parameter.type !==
|
|
16235
|
-
const value = parameter.parameter.type ===
|
|
16236
|
-
if (value.type ===
|
|
16494
|
+
if (parameter.type !== import_utils88.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
16495
|
+
const value = parameter.parameter.type === import_utils88.AST_NODE_TYPES.AssignmentPattern ? parameter.parameter.left : parameter.parameter;
|
|
16496
|
+
if (value.type === import_utils88.AST_NODE_TYPES.Identifier) injected.add(value.name);
|
|
16237
16497
|
}
|
|
16238
16498
|
const body2 = constructor.value.body;
|
|
16239
16499
|
if (body2 === null) return injected;
|
|
16240
16500
|
for (const statement of body2.body) {
|
|
16241
|
-
if (statement.type !==
|
|
16501
|
+
if (statement.type !== import_utils88.AST_NODE_TYPES.ExpressionStatement || statement.expression.type !== import_utils88.AST_NODE_TYPES.AssignmentExpression || statement.expression.operator !== "=") continue;
|
|
16242
16502
|
const { left, right } = statement.expression;
|
|
16243
|
-
if (left.type !==
|
|
16503
|
+
if (left.type !== import_utils88.AST_NODE_TYPES.MemberExpression) continue;
|
|
16244
16504
|
const target = thisRootMember(left);
|
|
16245
16505
|
if (target === null) continue;
|
|
16246
|
-
const source = right.type ===
|
|
16506
|
+
const source = right.type === import_utils88.AST_NODE_TYPES.Identifier ? right.name : right.type === import_utils88.AST_NODE_TYPES.MemberExpression && right.object.type === import_utils88.AST_NODE_TYPES.Identifier ? right.object.name : null;
|
|
16247
16507
|
if (source !== null && parameters.has(source)) injected.add(target);
|
|
16248
16508
|
}
|
|
16249
16509
|
return injected;
|
|
@@ -16251,26 +16511,26 @@ function injectedMembers(owner) {
|
|
|
16251
16511
|
function thisRootMember(node) {
|
|
16252
16512
|
let current = node;
|
|
16253
16513
|
let root = null;
|
|
16254
|
-
while (current.type ===
|
|
16514
|
+
while (current.type === import_utils88.AST_NODE_TYPES.MemberExpression) {
|
|
16255
16515
|
const name = memberName5(current);
|
|
16256
16516
|
if (name === null) return null;
|
|
16257
16517
|
root = name;
|
|
16258
16518
|
current = current.object;
|
|
16259
16519
|
}
|
|
16260
|
-
return current.type ===
|
|
16520
|
+
return current.type === import_utils88.AST_NODE_TYPES.ThisExpression ? root : null;
|
|
16261
16521
|
}
|
|
16262
16522
|
function parameterNames(parameter) {
|
|
16263
16523
|
let value = parameter;
|
|
16264
|
-
if (value.type ===
|
|
16265
|
-
if (value.type ===
|
|
16266
|
-
if (value.type ===
|
|
16267
|
-
if (value.type !==
|
|
16524
|
+
if (value.type === import_utils88.AST_NODE_TYPES.TSParameterProperty) value = value.parameter;
|
|
16525
|
+
if (value.type === import_utils88.AST_NODE_TYPES.AssignmentPattern) value = value.left;
|
|
16526
|
+
if (value.type === import_utils88.AST_NODE_TYPES.Identifier) return /* @__PURE__ */ new Set([value.name]);
|
|
16527
|
+
if (value.type !== import_utils88.AST_NODE_TYPES.ObjectPattern) return /* @__PURE__ */ new Set();
|
|
16268
16528
|
return new Set(
|
|
16269
16529
|
value.properties.flatMap((property) => {
|
|
16270
|
-
if (property.type ===
|
|
16271
|
-
return property.argument.type ===
|
|
16272
|
-
const target = property.value.type ===
|
|
16273
|
-
return target.type ===
|
|
16530
|
+
if (property.type === import_utils88.AST_NODE_TYPES.RestElement)
|
|
16531
|
+
return property.argument.type === import_utils88.AST_NODE_TYPES.Identifier ? [property.argument.name] : [];
|
|
16532
|
+
const target = property.value.type === import_utils88.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
16533
|
+
return target.type === import_utils88.AST_NODE_TYPES.Identifier ? [target.name] : [];
|
|
16274
16534
|
})
|
|
16275
16535
|
);
|
|
16276
16536
|
}
|
|
@@ -16293,7 +16553,7 @@ var require_sql_access_class_default = createRule({
|
|
|
16293
16553
|
return {};
|
|
16294
16554
|
return {
|
|
16295
16555
|
CallExpression(node) {
|
|
16296
|
-
if (node.callee.type !==
|
|
16556
|
+
if (node.callee.type !== import_utils88.AST_NODE_TYPES.MemberExpression)
|
|
16297
16557
|
return;
|
|
16298
16558
|
const method = memberName5(node.callee);
|
|
16299
16559
|
if (method === null || !isDatabaseOperation(method, node.callee.object))
|
|
@@ -16310,7 +16570,7 @@ var require_sql_access_class_default = createRule({
|
|
|
16310
16570
|
});
|
|
16311
16571
|
|
|
16312
16572
|
// src/rules/require-static-next-matcher.ts
|
|
16313
|
-
var
|
|
16573
|
+
var import_utils89 = require("@typescript-eslint/utils");
|
|
16314
16574
|
var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
16315
16575
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
16316
16576
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -16323,34 +16583,34 @@ var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
|
16323
16583
|
};
|
|
16324
16584
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
16325
16585
|
function unwrapExpression3(node) {
|
|
16326
|
-
if (node.type ===
|
|
16586
|
+
if (node.type === import_utils89.AST_NODE_TYPES.TSAsExpression || node.type === import_utils89.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils89.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils89.AST_NODE_TYPES.TSTypeAssertion) {
|
|
16327
16587
|
return unwrapExpression3(node.expression);
|
|
16328
16588
|
}
|
|
16329
16589
|
return node;
|
|
16330
16590
|
}
|
|
16331
16591
|
function isStaticValue(node) {
|
|
16332
16592
|
const value = unwrapExpression3(node);
|
|
16333
|
-
if (value.type ===
|
|
16593
|
+
if (value.type === import_utils89.AST_NODE_TYPES.Literal) {
|
|
16334
16594
|
return true;
|
|
16335
16595
|
}
|
|
16336
|
-
if (value.type ===
|
|
16596
|
+
if (value.type === import_utils89.AST_NODE_TYPES.TemplateLiteral) {
|
|
16337
16597
|
return value.expressions.length === 0;
|
|
16338
16598
|
}
|
|
16339
|
-
if (value.type ===
|
|
16599
|
+
if (value.type === import_utils89.AST_NODE_TYPES.ArrayExpression) {
|
|
16340
16600
|
return value.elements.every(
|
|
16341
|
-
(element) => element !== null && element.type !==
|
|
16601
|
+
(element) => element !== null && element.type !== import_utils89.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
16342
16602
|
);
|
|
16343
16603
|
}
|
|
16344
|
-
if (value.type ===
|
|
16604
|
+
if (value.type === import_utils89.AST_NODE_TYPES.ObjectExpression) {
|
|
16345
16605
|
return value.properties.every(
|
|
16346
|
-
(property) => property.type ===
|
|
16606
|
+
(property) => property.type === import_utils89.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils89.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
16347
16607
|
);
|
|
16348
16608
|
}
|
|
16349
16609
|
return false;
|
|
16350
16610
|
}
|
|
16351
16611
|
function propertyName6(property) {
|
|
16352
16612
|
if (property.computed) return null;
|
|
16353
|
-
if (property.key.type ===
|
|
16613
|
+
if (property.key.type === import_utils89.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
16354
16614
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
16355
16615
|
}
|
|
16356
16616
|
var require_static_next_matcher_default = createRule({
|
|
@@ -16373,19 +16633,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
16373
16633
|
}
|
|
16374
16634
|
return {
|
|
16375
16635
|
ExportNamedDeclaration(node) {
|
|
16376
|
-
if (node.declaration?.type !==
|
|
16636
|
+
if (node.declaration?.type !== import_utils89.AST_NODE_TYPES.VariableDeclaration) {
|
|
16377
16637
|
return;
|
|
16378
16638
|
}
|
|
16379
16639
|
for (const declaration of node.declaration.declarations) {
|
|
16380
|
-
if (declaration.id.type !==
|
|
16640
|
+
if (declaration.id.type !== import_utils89.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
16381
16641
|
continue;
|
|
16382
16642
|
}
|
|
16383
16643
|
const config = unwrapExpression3(declaration.init);
|
|
16384
|
-
if (config.type !==
|
|
16644
|
+
if (config.type !== import_utils89.AST_NODE_TYPES.ObjectExpression) {
|
|
16385
16645
|
continue;
|
|
16386
16646
|
}
|
|
16387
16647
|
for (const property of config.properties) {
|
|
16388
|
-
if (property.type !==
|
|
16648
|
+
if (property.type !== import_utils89.AST_NODE_TYPES.Property || propertyName6(property) !== "matcher" || property.value.type === import_utils89.AST_NODE_TYPES.AssignmentPattern) {
|
|
16389
16649
|
continue;
|
|
16390
16650
|
}
|
|
16391
16651
|
if (!isStaticValue(property.value)) {
|
|
@@ -16399,7 +16659,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
16399
16659
|
});
|
|
16400
16660
|
|
|
16401
16661
|
// src/rules/require-use-form-default-values.ts
|
|
16402
|
-
var
|
|
16662
|
+
var import_utils90 = require("@typescript-eslint/utils");
|
|
16403
16663
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
16404
16664
|
summary: "react-hook-form useForm call without defaultValues",
|
|
16405
16665
|
rationale: "Without an explicit initial value, fields can change from uncontrolled to controlled as data arrives, reset behavior becomes ambiguous, and the form's initial shape no longer documents the values users can edit.",
|
|
@@ -16453,13 +16713,13 @@ var require_use_form_default_values_default = createRule({
|
|
|
16453
16713
|
if (node.source.value !== "react-hook-form") return;
|
|
16454
16714
|
for (const specifier of node.specifiers) {
|
|
16455
16715
|
if (specifier.type !== "ImportSpecifier" || (specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value) !== "useForm") continue;
|
|
16456
|
-
const variable =
|
|
16716
|
+
const variable = import_utils90.ASTUtils.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
16457
16717
|
if (variable) importedHooks.add(variable);
|
|
16458
16718
|
}
|
|
16459
16719
|
},
|
|
16460
16720
|
CallExpression(node) {
|
|
16461
16721
|
if (node.callee.type !== "Identifier") return;
|
|
16462
|
-
const variable =
|
|
16722
|
+
const variable = import_utils90.ASTUtils.findVariable(context.sourceCode.getScope(node.callee), node.callee.name);
|
|
16463
16723
|
const options = node.arguments[0];
|
|
16464
16724
|
if (!variable || !importedHooks.has(variable) || options !== void 0 && options.type !== "ObjectExpression" || hasDefaultValues(options)) return;
|
|
16465
16725
|
context.report({ node, messageId: "requireUseFormDefaultValues" });
|
|
@@ -16469,7 +16729,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
16469
16729
|
});
|
|
16470
16730
|
|
|
16471
16731
|
// src/rules/require-use-server-in-actions-file.ts
|
|
16472
|
-
var
|
|
16732
|
+
var import_utils91 = require("@typescript-eslint/utils");
|
|
16473
16733
|
var ACTION_MODULE_RE = /(?:^|\/)app\/.*\/(?:actions|[^/]+-actions)\.[cm]?[jt]s$/u;
|
|
16474
16734
|
var REQUIRE_USE_SERVER_IN_ACTIONS_FILE_DOCUMENTATION = {
|
|
16475
16735
|
summary: "route action module missing the use server directive",
|
|
@@ -16535,7 +16795,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
16535
16795
|
});
|
|
16536
16796
|
|
|
16537
16797
|
// src/rules/require-zod-form-validation.ts
|
|
16538
|
-
var
|
|
16798
|
+
var import_utils92 = require("@typescript-eslint/utils");
|
|
16539
16799
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
16540
16800
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
16541
16801
|
rationale: "FormData values are untrusted strings or files and need runtime validation before use.",
|
|
@@ -16560,14 +16820,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
16560
16820
|
var zodReceiverRoot = (node) => {
|
|
16561
16821
|
let current = node;
|
|
16562
16822
|
while (true) {
|
|
16563
|
-
if (current.type ===
|
|
16823
|
+
if (current.type === import_utils92.AST_NODE_TYPES.Identifier) {
|
|
16564
16824
|
return current;
|
|
16565
16825
|
}
|
|
16566
|
-
if (current.type ===
|
|
16826
|
+
if (current.type === import_utils92.AST_NODE_TYPES.CallExpression) {
|
|
16567
16827
|
current = current.callee;
|
|
16568
16828
|
continue;
|
|
16569
16829
|
}
|
|
16570
|
-
if (current.type ===
|
|
16830
|
+
if (current.type === import_utils92.AST_NODE_TYPES.MemberExpression) {
|
|
16571
16831
|
current = current.object;
|
|
16572
16832
|
continue;
|
|
16573
16833
|
}
|
|
@@ -16576,12 +16836,12 @@ var zodReceiverRoot = (node) => {
|
|
|
16576
16836
|
};
|
|
16577
16837
|
var isFormDataMethodCall = (node) => {
|
|
16578
16838
|
let current = node;
|
|
16579
|
-
if (current.type ===
|
|
16839
|
+
if (current.type === import_utils92.AST_NODE_TYPES.AwaitExpression) {
|
|
16580
16840
|
current = current.argument;
|
|
16581
16841
|
}
|
|
16582
|
-
if (current.type !==
|
|
16842
|
+
if (current.type !== import_utils92.AST_NODE_TYPES.CallExpression) return false;
|
|
16583
16843
|
const callee = current.callee;
|
|
16584
|
-
return callee.type ===
|
|
16844
|
+
return callee.type === import_utils92.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils92.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
16585
16845
|
};
|
|
16586
16846
|
var require_zod_form_validation_default = createRule({
|
|
16587
16847
|
name: "require-zod-form-validation",
|
|
@@ -16602,7 +16862,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16602
16862
|
return {};
|
|
16603
16863
|
}
|
|
16604
16864
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
16605
|
-
const resolvedBinding = (identifier) =>
|
|
16865
|
+
const resolvedBinding = (identifier) => import_utils92.ASTUtils.findVariable(
|
|
16606
16866
|
context.sourceCode.getScope(identifier),
|
|
16607
16867
|
identifier.name
|
|
16608
16868
|
);
|
|
@@ -16612,16 +16872,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
16612
16872
|
return false;
|
|
16613
16873
|
}
|
|
16614
16874
|
const definition = binding.defs[0];
|
|
16615
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
16875
|
+
if (definition?.type !== "Variable" || definition.node.type !== import_utils92.AST_NODE_TYPES.VariableDeclarator) {
|
|
16616
16876
|
return false;
|
|
16617
16877
|
}
|
|
16618
16878
|
const init = definition.node.init;
|
|
16619
|
-
return init?.type ===
|
|
16879
|
+
return init?.type === import_utils92.AST_NODE_TYPES.ObjectExpression || init?.type === import_utils92.AST_NODE_TYPES.ArrayExpression || init?.type === import_utils92.AST_NODE_TYPES.Literal || init?.type === import_utils92.AST_NODE_TYPES.ArrowFunctionExpression || init?.type === import_utils92.AST_NODE_TYPES.FunctionExpression;
|
|
16620
16880
|
};
|
|
16621
16881
|
const isZodParseCall = (node) => {
|
|
16622
|
-
if (node.type !==
|
|
16882
|
+
if (node.type !== import_utils92.AST_NODE_TYPES.CallExpression) return false;
|
|
16623
16883
|
const callee = node.callee;
|
|
16624
|
-
if (callee.type !==
|
|
16884
|
+
if (callee.type !== import_utils92.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils92.AST_NODE_TYPES.Identifier || !ZOD_PARSE_METHODS.has(callee.property.name)) {
|
|
16625
16885
|
return false;
|
|
16626
16886
|
}
|
|
16627
16887
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -16630,14 +16890,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
16630
16890
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
16631
16891
|
};
|
|
16632
16892
|
const isFormSourceIdentifier = (node) => {
|
|
16633
|
-
if (node.type !==
|
|
16893
|
+
if (node.type !== import_utils92.AST_NODE_TYPES.Identifier) return false;
|
|
16634
16894
|
const conventionalName = /formdata/i.test(node.name);
|
|
16635
16895
|
let scope = context.sourceCode.getScope(node);
|
|
16636
16896
|
while (scope !== null) {
|
|
16637
16897
|
const variable = scope.set.get(node.name);
|
|
16638
16898
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
16639
16899
|
const def = variable.defs[0];
|
|
16640
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
16900
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils92.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
16641
16901
|
return isFormDataMethodCall(def.node.init);
|
|
16642
16902
|
}
|
|
16643
16903
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -16648,8 +16908,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
16648
16908
|
};
|
|
16649
16909
|
const isFormDataGetCall = (node) => {
|
|
16650
16910
|
const callee = node.callee;
|
|
16651
|
-
if (callee.type !==
|
|
16652
|
-
if (callee.property.type !==
|
|
16911
|
+
if (callee.type !== import_utils92.AST_NODE_TYPES.MemberExpression) return false;
|
|
16912
|
+
if (callee.property.type !== import_utils92.AST_NODE_TYPES.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
16653
16913
|
return false;
|
|
16654
16914
|
}
|
|
16655
16915
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -16665,16 +16925,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
16665
16925
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
16666
16926
|
const isInstanceofNarrowing = (node) => {
|
|
16667
16927
|
const parent = node.parent;
|
|
16668
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
16928
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils92.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils92.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
16669
16929
|
};
|
|
16670
16930
|
const boundDeclarator = (node) => {
|
|
16671
16931
|
let current = node;
|
|
16672
16932
|
let parent = current.parent;
|
|
16673
|
-
while ((parent.type ===
|
|
16933
|
+
while ((parent.type === import_utils92.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils92.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils92.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils92.AST_NODE_TYPES.ChainExpression) && parent.expression === current) {
|
|
16674
16934
|
current = parent;
|
|
16675
16935
|
parent = current.parent;
|
|
16676
16936
|
}
|
|
16677
|
-
if (parent.type ===
|
|
16937
|
+
if (parent.type === import_utils92.AST_NODE_TYPES.VariableDeclarator && parent.init === current && parent.id.type === import_utils92.AST_NODE_TYPES.Identifier) {
|
|
16678
16938
|
return parent;
|
|
16679
16939
|
}
|
|
16680
16940
|
return null;
|
|
@@ -16683,7 +16943,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16683
16943
|
let current = node;
|
|
16684
16944
|
while (current.parent !== void 0) {
|
|
16685
16945
|
const parent = current.parent;
|
|
16686
|
-
if (parent.type ===
|
|
16946
|
+
if (parent.type === import_utils92.AST_NODE_TYPES.BlockStatement || parent.type === import_utils92.AST_NODE_TYPES.Program) {
|
|
16687
16947
|
return current;
|
|
16688
16948
|
}
|
|
16689
16949
|
current = parent;
|
|
@@ -16692,12 +16952,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
16692
16952
|
};
|
|
16693
16953
|
const zodParseMethod = (call) => {
|
|
16694
16954
|
const callee = call.callee;
|
|
16695
|
-
return callee.type ===
|
|
16955
|
+
return callee.type === import_utils92.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils92.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
16696
16956
|
};
|
|
16697
16957
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
16698
16958
|
let current = node.parent;
|
|
16699
16959
|
while (current !== void 0 && current !== statement) {
|
|
16700
|
-
if (current.type ===
|
|
16960
|
+
if (current.type === import_utils92.AST_NODE_TYPES.LogicalExpression || current.type === import_utils92.AST_NODE_TYPES.ConditionalExpression) {
|
|
16701
16961
|
return true;
|
|
16702
16962
|
}
|
|
16703
16963
|
current = current.parent;
|
|
@@ -16707,7 +16967,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16707
16967
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
16708
16968
|
let current = node.parent;
|
|
16709
16969
|
while (current !== void 0 && current !== statement) {
|
|
16710
|
-
if (current.type ===
|
|
16970
|
+
if (current.type === import_utils92.AST_NODE_TYPES.AwaitExpression) return true;
|
|
16711
16971
|
current = current.parent;
|
|
16712
16972
|
}
|
|
16713
16973
|
return false;
|
|
@@ -16720,7 +16980,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16720
16980
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
16721
16981
|
return null;
|
|
16722
16982
|
}
|
|
16723
|
-
if (validationStatement.type !==
|
|
16983
|
+
if (validationStatement.type !== import_utils92.AST_NODE_TYPES.VariableDeclaration && validationStatement.type !== import_utils92.AST_NODE_TYPES.ExpressionStatement) {
|
|
16724
16984
|
return null;
|
|
16725
16985
|
}
|
|
16726
16986
|
const method = zodParseMethod(parse2);
|
|
@@ -16732,16 +16992,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
16732
16992
|
};
|
|
16733
16993
|
const isSafePrevalidationInspection = (identifier) => {
|
|
16734
16994
|
const parent = identifier.parent;
|
|
16735
|
-
if (parent.type ===
|
|
16995
|
+
if (parent.type === import_utils92.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof") {
|
|
16736
16996
|
return true;
|
|
16737
16997
|
}
|
|
16738
|
-
if (parent.type !==
|
|
16998
|
+
if (parent.type !== import_utils92.AST_NODE_TYPES.BinaryExpression || parent.left !== identifier) {
|
|
16739
16999
|
return false;
|
|
16740
17000
|
}
|
|
16741
17001
|
if (parent.operator === "instanceof") {
|
|
16742
|
-
return parent.right.type ===
|
|
17002
|
+
return parent.right.type === import_utils92.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
16743
17003
|
}
|
|
16744
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
17004
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === import_utils92.AST_NODE_TYPES.Literal && parent.right.value === null || parent.right.type === import_utils92.AST_NODE_TYPES.Identifier && parent.right.name === "undefined");
|
|
16745
17005
|
};
|
|
16746
17006
|
const isDescendantOf = (node, ancestor) => {
|
|
16747
17007
|
let current = node;
|
|
@@ -16752,23 +17012,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
16752
17012
|
return false;
|
|
16753
17013
|
};
|
|
16754
17014
|
const blockTerminates = (node) => {
|
|
16755
|
-
if (node.type ===
|
|
17015
|
+
if (node.type === import_utils92.AST_NODE_TYPES.ReturnStatement || node.type === import_utils92.AST_NODE_TYPES.ThrowStatement) {
|
|
16756
17016
|
return true;
|
|
16757
17017
|
}
|
|
16758
|
-
if (node.type !==
|
|
17018
|
+
if (node.type !== import_utils92.AST_NODE_TYPES.BlockStatement || node.body.length === 0) return false;
|
|
16759
17019
|
const last = node.body.at(-1);
|
|
16760
17020
|
return last !== void 0 && blockTerminates(last);
|
|
16761
17021
|
};
|
|
16762
17022
|
const narrowingIf = (identifier) => {
|
|
16763
17023
|
const comparison = identifier.parent;
|
|
16764
|
-
if (comparison?.type !==
|
|
17024
|
+
if (comparison?.type !== import_utils92.AST_NODE_TYPES.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== import_utils92.AST_NODE_TYPES.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
16765
17025
|
return null;
|
|
16766
17026
|
}
|
|
16767
17027
|
const maybeNegation = comparison.parent;
|
|
16768
|
-
const negated = maybeNegation?.type ===
|
|
17028
|
+
const negated = maybeNegation?.type === import_utils92.AST_NODE_TYPES.UnaryExpression && maybeNegation.operator === "!";
|
|
16769
17029
|
const test = negated ? maybeNegation : comparison;
|
|
16770
17030
|
const branch = test.parent;
|
|
16771
|
-
return branch?.type ===
|
|
17031
|
+
return branch?.type === import_utils92.AST_NODE_TYPES.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
16772
17032
|
};
|
|
16773
17033
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
16774
17034
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -16788,7 +17048,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16788
17048
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
16789
17049
|
if (variable === void 0) return false;
|
|
16790
17050
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
16791
|
-
(identifier) => identifier.type ===
|
|
17051
|
+
(identifier) => identifier.type === import_utils92.AST_NODE_TYPES.Identifier
|
|
16792
17052
|
);
|
|
16793
17053
|
if (references.length === 0) return false;
|
|
16794
17054
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -16814,7 +17074,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16814
17074
|
ImportDeclaration(node) {
|
|
16815
17075
|
if (!isZodModule(node.source.value)) return;
|
|
16816
17076
|
for (const specifier of node.specifiers) {
|
|
16817
|
-
if (specifier.type ===
|
|
17077
|
+
if (specifier.type === import_utils92.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils92.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils92.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils92.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
16818
17078
|
const binding = resolvedBinding(specifier.local);
|
|
16819
17079
|
if (binding !== null) zodBindings.add(binding);
|
|
16820
17080
|
}
|
|
@@ -16835,7 +17095,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16835
17095
|
});
|
|
16836
17096
|
|
|
16837
17097
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
16838
|
-
var
|
|
17098
|
+
var import_utils93 = require("@typescript-eslint/utils");
|
|
16839
17099
|
var STORE_INSERT_REQUIRES_ON_CONFLICT_DOCUMENTATION = {
|
|
16840
17100
|
summary: "Require embedded inserts in explicitly replayable callables to carry conflict handling.",
|
|
16841
17101
|
rationale: "A callable named as an enqueue, seed, migration, schedule, ensure, or upsert promises replay safety.",
|
|
@@ -16899,7 +17159,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
16899
17159
|
});
|
|
16900
17160
|
|
|
16901
17161
|
// src/rules/stepdown.ts
|
|
16902
|
-
var
|
|
17162
|
+
var import_utils94 = require("@typescript-eslint/utils");
|
|
16903
17163
|
var STEPDOWN_DOCUMENTATION = {
|
|
16904
17164
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
16905
17165
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -16919,7 +17179,7 @@ var STEPDOWN_DOCUMENTATION = {
|
|
|
16919
17179
|
]
|
|
16920
17180
|
};
|
|
16921
17181
|
function isFunction(node) {
|
|
16922
|
-
return node.type ===
|
|
17182
|
+
return node.type === import_utils94.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils94.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils94.AST_NODE_TYPES.FunctionExpression;
|
|
16923
17183
|
}
|
|
16924
17184
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true, makeFix) {
|
|
16925
17185
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -17016,8 +17276,8 @@ function moduleScope(context, program) {
|
|
|
17016
17276
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
17017
17277
|
const overloadNames = new Set(
|
|
17018
17278
|
program.body.flatMap((statement) => {
|
|
17019
|
-
const node = statement.type ===
|
|
17020
|
-
return node?.type ===
|
|
17279
|
+
const node = statement.type === import_utils94.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
17280
|
+
return node?.type === import_utils94.AST_NODE_TYPES.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
17021
17281
|
})
|
|
17022
17282
|
);
|
|
17023
17283
|
const exported = exportedNames(program);
|
|
@@ -17041,7 +17301,7 @@ function moduleScope(context, program) {
|
|
|
17041
17301
|
const nearestFunction2 = [...ancestors].reverse().find(isFunction);
|
|
17042
17302
|
const parent = identifier.parent;
|
|
17043
17303
|
const callerDefinition = nearestFunction2 === void 0 ? void 0 : byFunction.get(nearestFunction2);
|
|
17044
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
17304
|
+
if (callerDefinition === void 0 || parent.type !== import_utils94.AST_NODE_TYPES.CallExpression || parent.callee !== identifier) {
|
|
17045
17305
|
pinned.add(definition.name);
|
|
17046
17306
|
continue;
|
|
17047
17307
|
}
|
|
@@ -17056,38 +17316,38 @@ function moduleScope(context, program) {
|
|
|
17056
17316
|
function exportedNames(program) {
|
|
17057
17317
|
const names = /* @__PURE__ */ new Set();
|
|
17058
17318
|
for (const statement of program.body) {
|
|
17059
|
-
if (statement.type !==
|
|
17060
|
-
if (statement.declaration?.type ===
|
|
17319
|
+
if (statement.type !== import_utils94.AST_NODE_TYPES.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
17320
|
+
if (statement.declaration?.type === import_utils94.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) {
|
|
17061
17321
|
names.add(statement.declaration.id.name);
|
|
17062
17322
|
}
|
|
17063
|
-
if (statement.declaration?.type ===
|
|
17323
|
+
if (statement.declaration?.type === import_utils94.AST_NODE_TYPES.VariableDeclaration) {
|
|
17064
17324
|
for (const declarator of statement.declaration.declarations) {
|
|
17065
|
-
if (declarator.id.type ===
|
|
17325
|
+
if (declarator.id.type === import_utils94.AST_NODE_TYPES.Identifier) names.add(declarator.id.name);
|
|
17066
17326
|
}
|
|
17067
17327
|
}
|
|
17068
17328
|
for (const specifier of statement.specifiers) {
|
|
17069
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
17329
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils94.AST_NODE_TYPES.Identifier) {
|
|
17070
17330
|
names.add(specifier.local.name);
|
|
17071
17331
|
}
|
|
17072
17332
|
}
|
|
17073
17333
|
}
|
|
17074
17334
|
for (const statement of program.body) {
|
|
17075
|
-
if (statement.type ===
|
|
17076
|
-
if (statement.type ===
|
|
17335
|
+
if (statement.type === import_utils94.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils94.AST_NODE_TYPES.Identifier) names.add(statement.declaration.name);
|
|
17336
|
+
if (statement.type === import_utils94.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils94.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
17077
17337
|
}
|
|
17078
17338
|
return names;
|
|
17079
17339
|
}
|
|
17080
17340
|
function moduleDefinitions(program) {
|
|
17081
17341
|
const definitions = [];
|
|
17082
17342
|
for (const statement of program.body) {
|
|
17083
|
-
const node = statement.type ===
|
|
17084
|
-
if (node?.type ===
|
|
17343
|
+
const node = statement.type === import_utils94.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils94.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
17344
|
+
if (node?.type === import_utils94.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
17085
17345
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
17086
17346
|
continue;
|
|
17087
17347
|
}
|
|
17088
|
-
if (node?.type !==
|
|
17348
|
+
if (node?.type !== import_utils94.AST_NODE_TYPES.VariableDeclaration || node.kind !== "const") continue;
|
|
17089
17349
|
for (const declarator of node.declarations) {
|
|
17090
|
-
if (declarator.id.type ===
|
|
17350
|
+
if (declarator.id.type === import_utils94.AST_NODE_TYPES.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
17091
17351
|
definitions.push({
|
|
17092
17352
|
name: declarator.id.name,
|
|
17093
17353
|
node: declarator,
|
|
@@ -17100,21 +17360,21 @@ function moduleDefinitions(program) {
|
|
|
17100
17360
|
return definitions;
|
|
17101
17361
|
}
|
|
17102
17362
|
function methodName(node) {
|
|
17103
|
-
if (node.key.type ===
|
|
17104
|
-
return !node.computed && node.key.type ===
|
|
17363
|
+
if (node.key.type === import_utils94.AST_NODE_TYPES.PrivateIdentifier) return `#${node.key.name}`;
|
|
17364
|
+
return !node.computed && node.key.type === import_utils94.AST_NODE_TYPES.Identifier ? node.key.name : null;
|
|
17105
17365
|
}
|
|
17106
17366
|
function referencedMethod(context, node, classVariables) {
|
|
17107
|
-
const objectVariable = node.object.type ===
|
|
17367
|
+
const objectVariable = node.object.type === import_utils94.AST_NODE_TYPES.Identifier ? import_utils94.ASTUtils.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
17108
17368
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
17109
|
-
if (node.object.type !==
|
|
17110
|
-
if (node.property.type ===
|
|
17111
|
-
if (!node.computed && node.property.type ===
|
|
17112
|
-
return node.computed && node.property.type ===
|
|
17369
|
+
if (node.object.type !== import_utils94.AST_NODE_TYPES.ThisExpression && !isClassReference) return null;
|
|
17370
|
+
if (node.property.type === import_utils94.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
17371
|
+
if (!node.computed && node.property.type === import_utils94.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
17372
|
+
return node.computed && node.property.type === import_utils94.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
17113
17373
|
}
|
|
17114
17374
|
function referencedPropertyName(node) {
|
|
17115
|
-
if (node.property.type ===
|
|
17116
|
-
if (!node.computed && node.property.type ===
|
|
17117
|
-
return node.computed && node.property.type ===
|
|
17375
|
+
if (node.property.type === import_utils94.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
17376
|
+
if (!node.computed && node.property.type === import_utils94.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
17377
|
+
return node.computed && node.property.type === import_utils94.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
17118
17378
|
}
|
|
17119
17379
|
function walk2(node, visitorKeys, visit, nestedFunction = false) {
|
|
17120
17380
|
visit(node, nestedFunction);
|
|
@@ -17130,7 +17390,7 @@ function walk2(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
17130
17390
|
}
|
|
17131
17391
|
function classScope(context, node, computedReferenceNames) {
|
|
17132
17392
|
const methods = node.body.body.filter(
|
|
17133
|
-
(member) => member.type ===
|
|
17393
|
+
(member) => member.type === import_utils94.AST_NODE_TYPES.MethodDefinition
|
|
17134
17394
|
);
|
|
17135
17395
|
const counts = /* @__PURE__ */ new Map();
|
|
17136
17396
|
for (const method of methods) {
|
|
@@ -17138,8 +17398,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
17138
17398
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
17139
17399
|
}
|
|
17140
17400
|
for (const member of node.body.body) {
|
|
17141
|
-
if (member.type !==
|
|
17142
|
-
const name = !member.computed && member.key.type ===
|
|
17401
|
+
if (member.type !== import_utils94.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
17402
|
+
const name = !member.computed && member.key.type === import_utils94.AST_NODE_TYPES.Identifier ? member.key.name : null;
|
|
17143
17403
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
17144
17404
|
}
|
|
17145
17405
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -17148,7 +17408,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
17148
17408
|
});
|
|
17149
17409
|
const definitions = methods.flatMap((method) => {
|
|
17150
17410
|
const name = methodName(method);
|
|
17151
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
17411
|
+
const isPrivate = method.accessibility === "private" || method.key.type === import_utils94.AST_NODE_TYPES.PrivateIdentifier;
|
|
17152
17412
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
17153
17413
|
});
|
|
17154
17414
|
if (definitions.length === 0) return;
|
|
@@ -17157,11 +17417,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
17157
17417
|
const pinned = /* @__PURE__ */ new Set();
|
|
17158
17418
|
const classVariables = /* @__PURE__ */ new Set();
|
|
17159
17419
|
if (node.id !== null) {
|
|
17160
|
-
const internal =
|
|
17420
|
+
const internal = import_utils94.ASTUtils.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
17161
17421
|
if (internal !== null) classVariables.add(internal);
|
|
17162
17422
|
}
|
|
17163
|
-
if (node.type ===
|
|
17164
|
-
const outer =
|
|
17423
|
+
if (node.type === import_utils94.AST_NODE_TYPES.ClassExpression && node.parent.type === import_utils94.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils94.AST_NODE_TYPES.Identifier) {
|
|
17424
|
+
const outer = import_utils94.ASTUtils.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
17165
17425
|
if (outer !== null) classVariables.add(outer);
|
|
17166
17426
|
}
|
|
17167
17427
|
for (const method of methods) {
|
|
@@ -17177,27 +17437,27 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
17177
17437
|
}
|
|
17178
17438
|
const thisValue = (value) => {
|
|
17179
17439
|
let current = value;
|
|
17180
|
-
while (current?.type ===
|
|
17181
|
-
return current?.type ===
|
|
17440
|
+
while (current?.type === import_utils94.AST_NODE_TYPES.TSAsExpression || current?.type === import_utils94.AST_NODE_TYPES.TSSatisfiesExpression || current?.type === import_utils94.AST_NODE_TYPES.TSNonNullExpression) current = current.expression;
|
|
17441
|
+
return current?.type === import_utils94.AST_NODE_TYPES.ThisExpression;
|
|
17182
17442
|
};
|
|
17183
17443
|
const collectAlias = (current, nestedFunction) => {
|
|
17184
|
-
if (nestedFunction || current.type !==
|
|
17185
|
-
if (current.type ===
|
|
17186
|
-
const binding = current.type ===
|
|
17187
|
-
const value = current.type ===
|
|
17444
|
+
if (nestedFunction || current.type !== import_utils94.AST_NODE_TYPES.VariableDeclarator && current.type !== import_utils94.AST_NODE_TYPES.AssignmentPattern) return;
|
|
17445
|
+
if (current.type === import_utils94.AST_NODE_TYPES.VariableDeclarator && (current.parent.type !== import_utils94.AST_NODE_TYPES.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
17446
|
+
const binding = current.type === import_utils94.AST_NODE_TYPES.VariableDeclarator ? current.id : current.left;
|
|
17447
|
+
const value = current.type === import_utils94.AST_NODE_TYPES.VariableDeclarator ? current.init : current.right;
|
|
17188
17448
|
if (!thisValue(value)) return;
|
|
17189
|
-
if (binding.type ===
|
|
17449
|
+
if (binding.type === import_utils94.AST_NODE_TYPES.ObjectPattern) {
|
|
17190
17450
|
for (const property of binding.properties) {
|
|
17191
|
-
if (property.type ===
|
|
17451
|
+
if (property.type === import_utils94.AST_NODE_TYPES.RestElement) {
|
|
17192
17452
|
for (const name of privateNames) pinned.add(name);
|
|
17193
|
-
} else if (property.key.type ===
|
|
17453
|
+
} else if (property.key.type === import_utils94.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) {
|
|
17194
17454
|
pinned.add(property.key.name);
|
|
17195
17455
|
}
|
|
17196
17456
|
}
|
|
17197
17457
|
return;
|
|
17198
17458
|
}
|
|
17199
|
-
if (binding.type !==
|
|
17200
|
-
const variable =
|
|
17459
|
+
if (binding.type !== import_utils94.AST_NODE_TYPES.Identifier) return;
|
|
17460
|
+
const variable = import_utils94.ASTUtils.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
17201
17461
|
if (variable !== null) {
|
|
17202
17462
|
methodClassVariables.add(variable);
|
|
17203
17463
|
methodAliases.add(variable);
|
|
@@ -17210,16 +17470,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
17210
17470
|
walk2(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
17211
17471
|
}
|
|
17212
17472
|
const visitCall = (current, nestedFunction) => {
|
|
17213
|
-
if (current.type ===
|
|
17473
|
+
if (current.type === import_utils94.AST_NODE_TYPES.VariableDeclarator && current.id.type === import_utils94.AST_NODE_TYPES.ObjectPattern && thisValue(current.init)) {
|
|
17214
17474
|
for (const property of current.id.properties) {
|
|
17215
|
-
if (property.type ===
|
|
17475
|
+
if (property.type === import_utils94.AST_NODE_TYPES.RestElement) {
|
|
17216
17476
|
for (const name of privateNames) pinned.add(name);
|
|
17217
17477
|
continue;
|
|
17218
17478
|
}
|
|
17219
|
-
if (property.type ===
|
|
17479
|
+
if (property.type === import_utils94.AST_NODE_TYPES.Property && property.key.type === import_utils94.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
17220
17480
|
}
|
|
17221
17481
|
}
|
|
17222
|
-
if (current.type !==
|
|
17482
|
+
if (current.type !== import_utils94.AST_NODE_TYPES.MemberExpression) return;
|
|
17223
17483
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
17224
17484
|
if (target === null) {
|
|
17225
17485
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -17227,12 +17487,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
17227
17487
|
return;
|
|
17228
17488
|
}
|
|
17229
17489
|
if (!privateNames.has(target)) return;
|
|
17230
|
-
const objectVariable = current.object.type ===
|
|
17490
|
+
const objectVariable = current.object.type === import_utils94.AST_NODE_TYPES.Identifier ? import_utils94.ASTUtils.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
17231
17491
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
17232
17492
|
pinned.add(target);
|
|
17233
17493
|
return;
|
|
17234
17494
|
}
|
|
17235
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
17495
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== import_utils94.AST_NODE_TYPES.CallExpression || current.parent.callee !== current) {
|
|
17236
17496
|
pinned.add(target);
|
|
17237
17497
|
return;
|
|
17238
17498
|
}
|
|
@@ -17252,9 +17512,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
17252
17512
|
}
|
|
17253
17513
|
}
|
|
17254
17514
|
for (const member of node.body.body) {
|
|
17255
|
-
if (member.type ===
|
|
17515
|
+
if (member.type === import_utils94.AST_NODE_TYPES.MethodDefinition || member.type === import_utils94.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
17256
17516
|
walk2(member, context.sourceCode.visitorKeys, (current) => {
|
|
17257
|
-
if (current.type !==
|
|
17517
|
+
if (current.type !== import_utils94.AST_NODE_TYPES.MemberExpression) return;
|
|
17258
17518
|
const target = referencedMethod(context, current, classVariables);
|
|
17259
17519
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
17260
17520
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -17306,12 +17566,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
17306
17566
|
}
|
|
17307
17567
|
function isClassRuntimeBarrier(member) {
|
|
17308
17568
|
switch (member.type) {
|
|
17309
|
-
case
|
|
17569
|
+
case import_utils94.AST_NODE_TYPES.StaticBlock:
|
|
17310
17570
|
return true;
|
|
17311
|
-
case
|
|
17312
|
-
case
|
|
17571
|
+
case import_utils94.AST_NODE_TYPES.PropertyDefinition:
|
|
17572
|
+
case import_utils94.AST_NODE_TYPES.AccessorProperty:
|
|
17313
17573
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
17314
|
-
case
|
|
17574
|
+
case import_utils94.AST_NODE_TYPES.MethodDefinition:
|
|
17315
17575
|
return member.computed || member.decorators.length > 0;
|
|
17316
17576
|
default:
|
|
17317
17577
|
return false;
|
|
@@ -17344,7 +17604,7 @@ var stepdown_default = createRule({
|
|
|
17344
17604
|
moduleScope(context, program);
|
|
17345
17605
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
17346
17606
|
walk2(program, context.sourceCode.visitorKeys, (node) => {
|
|
17347
|
-
if (node.type ===
|
|
17607
|
+
if (node.type === import_utils94.AST_NODE_TYPES.MemberExpression && node.computed && node.property.type === import_utils94.AST_NODE_TYPES.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
17348
17608
|
});
|
|
17349
17609
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
17350
17610
|
}
|
|
@@ -17353,7 +17613,7 @@ var stepdown_default = createRule({
|
|
|
17353
17613
|
});
|
|
17354
17614
|
|
|
17355
17615
|
// src/rules/source-coupled-test.ts
|
|
17356
|
-
var
|
|
17616
|
+
var import_utils95 = require("@typescript-eslint/utils");
|
|
17357
17617
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|py|[cm]?[jt]s)$/iu;
|
|
17358
17618
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
17359
17619
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -17422,20 +17682,20 @@ var SOURCE_COUPLED_TEST_DOCUMENTATION = {
|
|
|
17422
17682
|
]
|
|
17423
17683
|
};
|
|
17424
17684
|
function staticMemberName7(node) {
|
|
17425
|
-
if (!node.computed && node.property.type ===
|
|
17426
|
-
if (node.computed && node.property.type ===
|
|
17685
|
+
if (!node.computed && node.property.type === import_utils95.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
17686
|
+
if (node.computed && node.property.type === import_utils95.AST_NODE_TYPES.Literal && typeof node.property.value === "string") return node.property.value;
|
|
17427
17687
|
return null;
|
|
17428
17688
|
}
|
|
17429
17689
|
function unwrap6(node) {
|
|
17430
|
-
if (node.type ===
|
|
17431
|
-
if (node.type ===
|
|
17432
|
-
if (node.type ===
|
|
17690
|
+
if (node.type === import_utils95.AST_NODE_TYPES.AwaitExpression) return unwrap6(node.argument);
|
|
17691
|
+
if (node.type === import_utils95.AST_NODE_TYPES.ChainExpression) return unwrap6(node.expression);
|
|
17692
|
+
if (node.type === import_utils95.AST_NODE_TYPES.TSAsExpression || node.type === import_utils95.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils95.AST_NODE_TYPES.TSTypeAssertion) return unwrap6(node.expression);
|
|
17433
17693
|
return node;
|
|
17434
17694
|
}
|
|
17435
17695
|
function stringValue(node) {
|
|
17436
17696
|
const current = unwrap6(node);
|
|
17437
|
-
if (current.type ===
|
|
17438
|
-
if (current.type ===
|
|
17697
|
+
if (current.type === import_utils95.AST_NODE_TYPES.Literal && typeof current.value === "string") return current.value;
|
|
17698
|
+
if (current.type === import_utils95.AST_NODE_TYPES.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
17439
17699
|
return null;
|
|
17440
17700
|
}
|
|
17441
17701
|
function importSource(node) {
|
|
@@ -17443,7 +17703,7 @@ function importSource(node) {
|
|
|
17443
17703
|
}
|
|
17444
17704
|
function requireSource(node) {
|
|
17445
17705
|
const current = unwrap6(node);
|
|
17446
|
-
if (current.type !==
|
|
17706
|
+
if (current.type !== import_utils95.AST_NODE_TYPES.CallExpression || current.callee.type !== import_utils95.AST_NODE_TYPES.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === import_utils95.AST_NODE_TYPES.SpreadElement) return null;
|
|
17447
17707
|
return stringValue(current.arguments[0]);
|
|
17448
17708
|
}
|
|
17449
17709
|
function newScope() {
|
|
@@ -17483,38 +17743,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17483
17743
|
const current = unwrap6(node);
|
|
17484
17744
|
const value = stringValue(current);
|
|
17485
17745
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
17486
|
-
if (current.type ===
|
|
17487
|
-
if (current.type ===
|
|
17746
|
+
if (current.type === import_utils95.AST_NODE_TYPES.Identifier) return visible("paths", current.name);
|
|
17747
|
+
if (current.type === import_utils95.AST_NODE_TYPES.BinaryExpression && current.operator === "+") {
|
|
17488
17748
|
return sourcePath(current.left) || sourcePath(current.right);
|
|
17489
17749
|
}
|
|
17490
|
-
if (current.type ===
|
|
17491
|
-
if (current.type ===
|
|
17492
|
-
return current.arguments.some((argument) => argument.type !==
|
|
17750
|
+
if (current.type === import_utils95.AST_NODE_TYPES.TemplateLiteral) return current.expressions.some(sourcePath);
|
|
17751
|
+
if (current.type === import_utils95.AST_NODE_TYPES.CallExpression || current.type === import_utils95.AST_NODE_TYPES.NewExpression) {
|
|
17752
|
+
return current.arguments.some((argument) => argument.type !== import_utils95.AST_NODE_TYPES.SpreadElement && sourcePath(argument));
|
|
17493
17753
|
}
|
|
17494
|
-
if (current.type ===
|
|
17754
|
+
if (current.type === import_utils95.AST_NODE_TYPES.MemberExpression) return sourcePath(current.object);
|
|
17495
17755
|
return false;
|
|
17496
17756
|
};
|
|
17497
17757
|
const rawRead = (node) => {
|
|
17498
17758
|
const current = unwrap6(node);
|
|
17499
|
-
if (current.type !==
|
|
17759
|
+
if (current.type !== import_utils95.AST_NODE_TYPES.CallExpression || current.arguments.length === 0) return false;
|
|
17500
17760
|
const callee = unwrap6(current.callee);
|
|
17501
|
-
if (callee.type ===
|
|
17761
|
+
if (callee.type === import_utils95.AST_NODE_TYPES.Identifier) {
|
|
17502
17762
|
return visible("fsReaders", callee.name) && sourcePath(current.arguments[0]);
|
|
17503
17763
|
}
|
|
17504
|
-
if (callee.type !==
|
|
17764
|
+
if (callee.type !== import_utils95.AST_NODE_TYPES.MemberExpression) return false;
|
|
17505
17765
|
const name2 = staticMemberName7(callee);
|
|
17506
17766
|
const object = unwrap6(callee.object);
|
|
17507
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
17767
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === import_utils95.AST_NODE_TYPES.Identifier && visible("fsObjects", object.name) && sourcePath(current.arguments[0]);
|
|
17508
17768
|
};
|
|
17509
17769
|
const rawOrigins = (node) => {
|
|
17510
17770
|
const current = unwrap6(node);
|
|
17511
|
-
if (current.type ===
|
|
17771
|
+
if (current.type === import_utils95.AST_NODE_TYPES.Identifier) return visibleRawOrigins(current.name);
|
|
17512
17772
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
17513
|
-
if (current.type ===
|
|
17514
|
-
if (current.type ===
|
|
17515
|
-
if (current.type !==
|
|
17773
|
+
if (current.type === import_utils95.AST_NODE_TYPES.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
17774
|
+
if (current.type === import_utils95.AST_NODE_TYPES.MemberExpression && staticMemberName7(current) === "length") return rawOrigins(current.object);
|
|
17775
|
+
if (current.type !== import_utils95.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
17516
17776
|
const callee = unwrap6(current.callee);
|
|
17517
|
-
if (callee.type !==
|
|
17777
|
+
if (callee.type !== import_utils95.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
17518
17778
|
const name2 = staticMemberName7(callee);
|
|
17519
17779
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(callee.object) : /* @__PURE__ */ new Set();
|
|
17520
17780
|
};
|
|
@@ -17522,38 +17782,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17522
17782
|
const current = unwrap6(node);
|
|
17523
17783
|
const direct = rawOrigins(current);
|
|
17524
17784
|
if (direct.size > 0) return direct;
|
|
17525
|
-
if (current.type ===
|
|
17526
|
-
if (current.type ===
|
|
17527
|
-
if (current.type !==
|
|
17785
|
+
if (current.type === import_utils95.AST_NODE_TYPES.BinaryExpression || current.type === import_utils95.AST_NODE_TYPES.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
17786
|
+
if (current.type === import_utils95.AST_NODE_TYPES.UnaryExpression) return evidenceOrigins(current.argument);
|
|
17787
|
+
if (current.type !== import_utils95.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
17528
17788
|
const callee = unwrap6(current.callee);
|
|
17529
|
-
if (callee.type !==
|
|
17789
|
+
if (callee.type !== import_utils95.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
17530
17790
|
const name2 = staticMemberName7(callee);
|
|
17531
17791
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(callee.object);
|
|
17532
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
17792
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === import_utils95.AST_NODE_TYPES.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
17533
17793
|
return /* @__PURE__ */ new Set();
|
|
17534
17794
|
};
|
|
17535
17795
|
const rawAssertionOrigins = (node) => {
|
|
17536
17796
|
const callee = unwrap6(node.callee);
|
|
17537
|
-
if (callee.type ===
|
|
17538
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
17797
|
+
if (callee.type === import_utils95.AST_NODE_TYPES.Identifier && callee.name === "assert") {
|
|
17798
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils95.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
17539
17799
|
}
|
|
17540
|
-
if (callee.type !==
|
|
17800
|
+
if (callee.type !== import_utils95.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
17541
17801
|
const matcher = staticMemberName7(callee);
|
|
17542
17802
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
17543
17803
|
let receiver = unwrap6(callee.object);
|
|
17544
|
-
while (receiver.type ===
|
|
17545
|
-
if (receiver.type ===
|
|
17804
|
+
while (receiver.type === import_utils95.AST_NODE_TYPES.MemberExpression && EXPECT_MODIFIERS2.has(staticMemberName7(receiver) ?? "")) receiver = unwrap6(receiver.object);
|
|
17805
|
+
if (receiver.type === import_utils95.AST_NODE_TYPES.CallExpression && receiver.callee.type === import_utils95.AST_NODE_TYPES.Identifier && receiver.callee.name === "expect") {
|
|
17546
17806
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
17547
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
17807
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === import_utils95.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
17548
17808
|
}
|
|
17549
|
-
if (receiver.type !==
|
|
17550
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
17809
|
+
if (receiver.type !== import_utils95.AST_NODE_TYPES.Identifier || receiver.name !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
17810
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils95.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
17551
17811
|
};
|
|
17552
17812
|
const rawRegexExtractionOrigins = (node) => {
|
|
17553
17813
|
const callee = unwrap6(node.callee);
|
|
17554
|
-
if (callee.type !==
|
|
17814
|
+
if (callee.type !== import_utils95.AST_NODE_TYPES.MemberExpression || staticMemberName7(callee) !== "matchAll" || node.arguments.length !== 1) return /* @__PURE__ */ new Set();
|
|
17555
17815
|
const argument = node.arguments[0];
|
|
17556
|
-
if (argument?.type !==
|
|
17816
|
+
if (argument?.type !== import_utils95.AST_NODE_TYPES.Literal || !(argument.value instanceof RegExp)) return /* @__PURE__ */ new Set();
|
|
17557
17817
|
return rawOrigins(callee.object);
|
|
17558
17818
|
};
|
|
17559
17819
|
const declare = (name2, state) => {
|
|
@@ -17574,15 +17834,15 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17574
17834
|
};
|
|
17575
17835
|
const sourceCollection = (node) => {
|
|
17576
17836
|
const current = unwrap6(node);
|
|
17577
|
-
return current.type ===
|
|
17837
|
+
return current.type === import_utils95.AST_NODE_TYPES.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== import_utils95.AST_NODE_TYPES.SpreadElement && sourcePath(element));
|
|
17578
17838
|
};
|
|
17579
17839
|
const declaredNames2 = (node) => {
|
|
17580
17840
|
const current = unwrap6(node);
|
|
17581
|
-
if (current.type ===
|
|
17582
|
-
if (current.type ===
|
|
17583
|
-
if (current.type ===
|
|
17584
|
-
if (current.type ===
|
|
17585
|
-
if (current.type ===
|
|
17841
|
+
if (current.type === import_utils95.AST_NODE_TYPES.Identifier) return [current.name];
|
|
17842
|
+
if (current.type === import_utils95.AST_NODE_TYPES.AssignmentPattern) return declaredNames2(current.left);
|
|
17843
|
+
if (current.type === import_utils95.AST_NODE_TYPES.RestElement) return declaredNames2(current.argument);
|
|
17844
|
+
if (current.type === import_utils95.AST_NODE_TYPES.ArrayPattern) return current.elements.flatMap((element) => element === null ? [] : declaredNames2(element));
|
|
17845
|
+
if (current.type === import_utils95.AST_NODE_TYPES.ObjectPattern) return current.properties.flatMap((property) => property.type === import_utils95.AST_NODE_TYPES.RestElement ? declaredNames2(property.argument) : declaredNames2(property.value));
|
|
17586
17846
|
return [];
|
|
17587
17847
|
};
|
|
17588
17848
|
const enterFunction = (node) => {
|
|
@@ -17597,8 +17857,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17597
17857
|
const source = importSource(node);
|
|
17598
17858
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
17599
17859
|
for (const specifier of node.specifiers) {
|
|
17600
|
-
if (specifier.type ===
|
|
17601
|
-
const imported = specifier.imported.type ===
|
|
17860
|
+
if (specifier.type === import_utils95.AST_NODE_TYPES.ImportSpecifier) {
|
|
17861
|
+
const imported = specifier.imported.type === import_utils95.AST_NODE_TYPES.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
17602
17862
|
if (FS_READERS.has(imported)) declare(specifier.local.name, { fsReader: true });
|
|
17603
17863
|
} else {
|
|
17604
17864
|
declare(specifier.local.name, { fsObject: true });
|
|
@@ -17610,29 +17870,29 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17610
17870
|
VariableDeclarator(node) {
|
|
17611
17871
|
if (node.init === null) return;
|
|
17612
17872
|
const required = requireSource(node.init);
|
|
17613
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
17873
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === import_utils95.AST_NODE_TYPES.Identifier) {
|
|
17614
17874
|
declare(node.id.name, { fsObject: true });
|
|
17615
17875
|
return;
|
|
17616
17876
|
}
|
|
17617
|
-
if (node.id.type ===
|
|
17877
|
+
if (node.id.type === import_utils95.AST_NODE_TYPES.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
17618
17878
|
for (const property of node.id.properties) {
|
|
17619
|
-
if (property.type !==
|
|
17620
|
-
const key = property.key.type ===
|
|
17879
|
+
if (property.type !== import_utils95.AST_NODE_TYPES.Property || property.value.type !== import_utils95.AST_NODE_TYPES.Identifier) continue;
|
|
17880
|
+
const key = property.key.type === import_utils95.AST_NODE_TYPES.Identifier ? property.key.name : property.key.type === import_utils95.AST_NODE_TYPES.Literal ? String(property.key.value) : "";
|
|
17621
17881
|
if (FS_READERS.has(key)) declare(property.value.name, { fsReader: true });
|
|
17622
17882
|
}
|
|
17623
17883
|
return;
|
|
17624
17884
|
}
|
|
17625
|
-
if (node.id.type !==
|
|
17885
|
+
if (node.id.type !== import_utils95.AST_NODE_TYPES.Identifier) return;
|
|
17626
17886
|
declare(node.id.name, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
17627
17887
|
},
|
|
17628
17888
|
AssignmentExpression(node) {
|
|
17629
|
-
if (node.left.type ===
|
|
17889
|
+
if (node.left.type === import_utils95.AST_NODE_TYPES.Identifier) declare(node.left.name, { path: sourcePath(node.right), rawOrigins: rawOrigins(node.right) });
|
|
17630
17890
|
},
|
|
17631
17891
|
ForOfStatement(node) {
|
|
17632
17892
|
const right = unwrap6(node.right);
|
|
17633
|
-
const collection = right.type ===
|
|
17634
|
-
const left = node.left.type ===
|
|
17635
|
-
if (collection && left?.type ===
|
|
17893
|
+
const collection = right.type === import_utils95.AST_NODE_TYPES.Identifier && visible("collections", right.name);
|
|
17894
|
+
const left = node.left.type === import_utils95.AST_NODE_TYPES.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
17895
|
+
if (collection && left?.type === import_utils95.AST_NODE_TYPES.Identifier) declare(left.name, { path: true });
|
|
17636
17896
|
},
|
|
17637
17897
|
CallExpression(node) {
|
|
17638
17898
|
const origins = /* @__PURE__ */ new Set([
|
|
@@ -17654,7 +17914,7 @@ var source_coupled_test_default = createSourceCoupledRule(
|
|
|
17654
17914
|
);
|
|
17655
17915
|
|
|
17656
17916
|
// src/rules/sole-export-matches-filename.ts
|
|
17657
|
-
var
|
|
17917
|
+
var import_utils96 = require("@typescript-eslint/utils");
|
|
17658
17918
|
var SOLE_EXPORT_MATCHES_FILENAME_DOCUMENTATION = {
|
|
17659
17919
|
summary: "Match a module filename to its sole named public runtime export.",
|
|
17660
17920
|
rationale: "When a module owns one runtime responsibility, matching names make that responsibility directly discoverable.",
|
|
@@ -17697,10 +17957,10 @@ function kebabCase(name) {
|
|
|
17697
17957
|
function declarationExport(statement) {
|
|
17698
17958
|
const declaration = statement.declaration;
|
|
17699
17959
|
if (declaration === null || declaration.declare === true) return [];
|
|
17700
|
-
if (declaration.type ===
|
|
17701
|
-
if (declaration.type !==
|
|
17960
|
+
if (declaration.type === import_utils96.AST_NODE_TYPES.ClassDeclaration || declaration.type === import_utils96.AST_NODE_TYPES.FunctionDeclaration || declaration.type === import_utils96.AST_NODE_TYPES.TSEnumDeclaration) return declaration.id === null ? [] : [{ name: declaration.id.name, node: declaration }];
|
|
17961
|
+
if (declaration.type !== import_utils96.AST_NODE_TYPES.VariableDeclaration) return [];
|
|
17702
17962
|
return declaration.declarations.flatMap(
|
|
17703
|
-
(item) => item.id.type ===
|
|
17963
|
+
(item) => item.id.type === import_utils96.AST_NODE_TYPES.Identifier ? [{ name: item.id.name, node: item }] : []
|
|
17704
17964
|
);
|
|
17705
17965
|
}
|
|
17706
17966
|
var sole_export_matches_filename_default = createRule({
|
|
@@ -17724,31 +17984,31 @@ var sole_export_matches_filename_default = createRule({
|
|
|
17724
17984
|
const exports2 = [];
|
|
17725
17985
|
const publicExports = /* @__PURE__ */ new Set();
|
|
17726
17986
|
for (const statement of program.body) {
|
|
17727
|
-
if (statement.type ===
|
|
17728
|
-
if (statement.type ===
|
|
17987
|
+
if (statement.type === import_utils96.AST_NODE_TYPES.ExportAllDeclaration || statement.type === import_utils96.AST_NODE_TYPES.ExportNamedDeclaration && statement.source !== null) return;
|
|
17988
|
+
if (statement.type === import_utils96.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
17729
17989
|
publicExports.add("default");
|
|
17730
17990
|
const declaration2 = statement.declaration;
|
|
17731
|
-
if ((declaration2.type ===
|
|
17991
|
+
if ((declaration2.type === import_utils96.AST_NODE_TYPES.ClassDeclaration || declaration2.type === import_utils96.AST_NODE_TYPES.FunctionDeclaration) && declaration2.id !== null) exports2.push({ name: declaration2.id.name, node: declaration2 });
|
|
17732
17992
|
else return;
|
|
17733
17993
|
}
|
|
17734
|
-
if (statement.type !==
|
|
17994
|
+
if (statement.type !== import_utils96.AST_NODE_TYPES.ExportNamedDeclaration) continue;
|
|
17735
17995
|
const declaration = statement.declaration;
|
|
17736
|
-
if (declaration !== null && "id" in declaration && declaration.id?.type ===
|
|
17996
|
+
if (declaration !== null && "id" in declaration && declaration.id?.type === import_utils96.AST_NODE_TYPES.Identifier) {
|
|
17737
17997
|
publicExports.add(declaration.id.name);
|
|
17738
17998
|
}
|
|
17739
|
-
if (declaration?.type ===
|
|
17999
|
+
if (declaration?.type === import_utils96.AST_NODE_TYPES.VariableDeclaration) {
|
|
17740
18000
|
for (const item of declaration.declarations) {
|
|
17741
|
-
if (item.id.type ===
|
|
18001
|
+
if (item.id.type === import_utils96.AST_NODE_TYPES.Identifier) publicExports.add(item.id.name);
|
|
17742
18002
|
}
|
|
17743
18003
|
}
|
|
17744
18004
|
for (const specifier of statement.specifiers) {
|
|
17745
|
-
const exported = specifier.exported.type ===
|
|
18005
|
+
const exported = specifier.exported.type === import_utils96.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
17746
18006
|
publicExports.add(String(exported));
|
|
17747
18007
|
}
|
|
17748
18008
|
if (statement.exportKind === "type") continue;
|
|
17749
18009
|
exports2.push(...declarationExport(statement));
|
|
17750
18010
|
for (const specifier of statement.specifiers) {
|
|
17751
|
-
const exported = specifier.exported.type ===
|
|
18011
|
+
const exported = specifier.exported.type === import_utils96.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
17752
18012
|
publicExports.add(String(exported));
|
|
17753
18013
|
if (specifier.exportKind === "type") continue;
|
|
17754
18014
|
if (exported === "default") exports2.push({ name: specifier.local.name, node: specifier });
|
|
@@ -17806,7 +18066,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
17806
18066
|
);
|
|
17807
18067
|
|
|
17808
18068
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
17809
|
-
var
|
|
18069
|
+
var import_utils97 = require("@typescript-eslint/utils");
|
|
17810
18070
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
17811
18071
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
17812
18072
|
rationale: "A reusable Zod schema is a runtime type contract. PascalCase mirrors that role; SCREAMING_SNAKE_CASE should remain reserved for scalar values and lookup tables.",
|
|
@@ -17938,18 +18198,18 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
17938
18198
|
"superRefine",
|
|
17939
18199
|
"transform"
|
|
17940
18200
|
]);
|
|
17941
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
18201
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils97.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
17942
18202
|
var calleeChainRoot = (node) => {
|
|
17943
18203
|
let current = node;
|
|
17944
18204
|
for (; ; ) {
|
|
17945
|
-
if (current.type ===
|
|
18205
|
+
if (current.type === import_utils97.AST_NODE_TYPES.Identifier) {
|
|
17946
18206
|
return current;
|
|
17947
18207
|
}
|
|
17948
|
-
if (current.type ===
|
|
18208
|
+
if (current.type === import_utils97.AST_NODE_TYPES.MemberExpression) {
|
|
17949
18209
|
current = current.object;
|
|
17950
18210
|
continue;
|
|
17951
18211
|
}
|
|
17952
|
-
if (current.type ===
|
|
18212
|
+
if (current.type === import_utils97.AST_NODE_TYPES.CallExpression) {
|
|
17953
18213
|
current = current.callee;
|
|
17954
18214
|
continue;
|
|
17955
18215
|
}
|
|
@@ -17960,13 +18220,13 @@ var chainMemberNames = (node) => {
|
|
|
17960
18220
|
const names = [];
|
|
17961
18221
|
let current = node;
|
|
17962
18222
|
for (; ; ) {
|
|
17963
|
-
if (current.type ===
|
|
17964
|
-
if (current.computed || current.property.type !==
|
|
18223
|
+
if (current.type === import_utils97.AST_NODE_TYPES.MemberExpression) {
|
|
18224
|
+
if (current.computed || current.property.type !== import_utils97.AST_NODE_TYPES.Identifier) return [];
|
|
17965
18225
|
names.push(current.property.name);
|
|
17966
18226
|
current = current.object;
|
|
17967
18227
|
continue;
|
|
17968
18228
|
}
|
|
17969
|
-
if (current.type ===
|
|
18229
|
+
if (current.type === import_utils97.AST_NODE_TYPES.CallExpression) {
|
|
17970
18230
|
current = current.callee;
|
|
17971
18231
|
continue;
|
|
17972
18232
|
}
|
|
@@ -17977,16 +18237,16 @@ var chainMemberNames = (node) => {
|
|
|
17977
18237
|
};
|
|
17978
18238
|
var unwrapExpression4 = (node) => {
|
|
17979
18239
|
let current = node;
|
|
17980
|
-
while (current.type ===
|
|
18240
|
+
while (current.type === import_utils97.AST_NODE_TYPES.TSAsExpression || current.type === import_utils97.AST_NODE_TYPES.TSSatisfiesExpression || current.type === import_utils97.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils97.AST_NODE_TYPES.TSTypeAssertion) {
|
|
17981
18241
|
current = current.expression;
|
|
17982
18242
|
}
|
|
17983
18243
|
return current;
|
|
17984
18244
|
};
|
|
17985
18245
|
var isModuleDeclarator = (node) => {
|
|
17986
18246
|
const declaration = node.parent;
|
|
17987
|
-
if (declaration.type !==
|
|
18247
|
+
if (declaration.type !== import_utils97.AST_NODE_TYPES.VariableDeclaration) return false;
|
|
17988
18248
|
const owner = declaration.parent;
|
|
17989
|
-
return owner.type ===
|
|
18249
|
+
return owner.type === import_utils97.AST_NODE_TYPES.Program || owner.type === import_utils97.AST_NODE_TYPES.ExportNamedDeclaration && owner.parent.type === import_utils97.AST_NODE_TYPES.Program;
|
|
17990
18250
|
};
|
|
17991
18251
|
var require_pascal_case_zod_schema_name_default = createRule({
|
|
17992
18252
|
name: "require-pascal-case-zod-schema-name",
|
|
@@ -18006,7 +18266,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
18006
18266
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
18007
18267
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
18008
18268
|
function resolvedBinding(identifier) {
|
|
18009
|
-
return
|
|
18269
|
+
return import_utils97.ASTUtils.findVariable(
|
|
18010
18270
|
context.sourceCode.getScope(identifier),
|
|
18011
18271
|
identifier.name
|
|
18012
18272
|
);
|
|
@@ -18027,8 +18287,8 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
18027
18287
|
}
|
|
18028
18288
|
function isConfirmedSchema(expression) {
|
|
18029
18289
|
const init = unwrapExpression4(expression);
|
|
18030
|
-
if (init.type ===
|
|
18031
|
-
if (init.type !==
|
|
18290
|
+
if (init.type === import_utils97.AST_NODE_TYPES.Identifier) return isSchemaBinding(init);
|
|
18291
|
+
if (init.type !== import_utils97.AST_NODE_TYPES.CallExpression || init.callee.type !== import_utils97.AST_NODE_TYPES.MemberExpression) {
|
|
18032
18292
|
return false;
|
|
18033
18293
|
}
|
|
18034
18294
|
const terminal = terminalMethodName(init.callee);
|
|
@@ -18048,7 +18308,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
18048
18308
|
ImportDeclaration(node) {
|
|
18049
18309
|
if (!isZodModule(node.source.value)) return;
|
|
18050
18310
|
for (const specifier of node.specifiers) {
|
|
18051
|
-
if (specifier.type ===
|
|
18311
|
+
if (specifier.type === import_utils97.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils97.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils97.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils97.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
18052
18312
|
recordZodBinding(specifier.local);
|
|
18053
18313
|
}
|
|
18054
18314
|
}
|
|
@@ -18057,7 +18317,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
18057
18317
|
if (!isModuleDeclarator(node)) return;
|
|
18058
18318
|
const init = node.init;
|
|
18059
18319
|
if (init === null || init === void 0) return;
|
|
18060
|
-
if (node.id.type !==
|
|
18320
|
+
if (node.id.type !== import_utils97.AST_NODE_TYPES.Identifier) return;
|
|
18061
18321
|
if (!isConfirmedSchema(init)) return;
|
|
18062
18322
|
const binding = resolvedBinding(node.id);
|
|
18063
18323
|
if (binding !== null) schemaBindings.add(binding);
|
|
@@ -18215,6 +18475,9 @@ var RULES = {
|
|
|
18215
18475
|
"prefer-shadcn-primitives": prefer_shadcn_primitives_default,
|
|
18216
18476
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
18217
18477
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
18478
|
+
"prefer-module-level-refined-schema": prefer_module_level_refined_schema_default,
|
|
18479
|
+
"prefer-multi-value-zod-literal": prefer_multi_value_zod_literal_default,
|
|
18480
|
+
"prefer-named-callback-domain": prefer_named_callback_domain_default,
|
|
18218
18481
|
"prefer-named-complex-return-type": prefer_named_complex_return_type_default,
|
|
18219
18482
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
18220
18483
|
"prefer-node-crypto-hash": prefer_node_crypto_hash_default,
|
|
@@ -18238,14 +18501,14 @@ var RULES = {
|
|
|
18238
18501
|
"require-static-next-matcher": require_static_next_matcher_default,
|
|
18239
18502
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
18240
18503
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
18241
|
-
|
|
18504
|
+
stepdown: stepdown_default,
|
|
18242
18505
|
"source-coupled-test": source_coupled_test_default,
|
|
18243
18506
|
"sole-export-matches-filename": sole_export_matches_filename_default,
|
|
18244
18507
|
"require-pascal-case-zod-schema-name": require_pascal_case_zod_schema_name_default
|
|
18245
18508
|
};
|
|
18246
18509
|
var meta = {
|
|
18247
18510
|
name: "@sarj/eslint-plugin",
|
|
18248
|
-
version: "15.
|
|
18511
|
+
version: "15.17.0"
|
|
18249
18512
|
};
|
|
18250
18513
|
var APPLICATION_ONLY_RULES = [
|
|
18251
18514
|
"no-restricted-library-load",
|
|
@@ -18253,6 +18516,9 @@ var APPLICATION_ONLY_RULES = [
|
|
|
18253
18516
|
"prefer-shadcn-primitives"
|
|
18254
18517
|
];
|
|
18255
18518
|
var ADVISORY_RULES = [
|
|
18519
|
+
"@sarj/prefer-module-level-refined-schema",
|
|
18520
|
+
"@sarj/prefer-multi-value-zod-literal",
|
|
18521
|
+
"@sarj/prefer-named-callback-domain",
|
|
18256
18522
|
"@sarj/prefer-named-complex-return-type",
|
|
18257
18523
|
"@sarj/prefer-node-crypto-hash",
|
|
18258
18524
|
"@sarj/prefer-node-fs-promises",
|
|
@@ -18316,6 +18582,9 @@ var RECOMMENDED_RULES = {
|
|
|
18316
18582
|
"@sarj/prefer-immutable-module-constant": "error",
|
|
18317
18583
|
"@sarj/prefer-module-level-constant": "error",
|
|
18318
18584
|
"@sarj/prefer-module-level-schema": "error",
|
|
18585
|
+
"@sarj/prefer-module-level-refined-schema": "warn",
|
|
18586
|
+
"@sarj/prefer-multi-value-zod-literal": ["warn", { zodMajorVersion: 4 }],
|
|
18587
|
+
"@sarj/prefer-named-callback-domain": "warn",
|
|
18319
18588
|
"@sarj/prefer-named-complex-return-type": "warn",
|
|
18320
18589
|
"@sarj/prefer-node-crypto-hash": "warn",
|
|
18321
18590
|
"@sarj/prefer-node-fs-promises": "warn",
|
|
@@ -18403,6 +18672,9 @@ var STRICT_RULES = {
|
|
|
18403
18672
|
"@sarj/prefer-immutable-module-constant": "error",
|
|
18404
18673
|
"@sarj/prefer-module-level-constant": "error",
|
|
18405
18674
|
"@sarj/prefer-module-level-schema": "error",
|
|
18675
|
+
"@sarj/prefer-module-level-refined-schema": "warn",
|
|
18676
|
+
"@sarj/prefer-multi-value-zod-literal": ["warn", { zodMajorVersion: 4 }],
|
|
18677
|
+
"@sarj/prefer-named-callback-domain": "warn",
|
|
18406
18678
|
"@sarj/prefer-named-complex-return-type": "warn",
|
|
18407
18679
|
"@sarj/prefer-node-crypto-hash": "warn",
|
|
18408
18680
|
"@sarj/prefer-node-fs-promises": "warn",
|