@sarj/eslint-plugin 15.15.0 → 15.16.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 +797 -363
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +812 -378
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4051,8 +4051,8 @@ function privateMemberFixes(context, services, owner, members, removePrivateKeyw
|
|
|
4051
4051
|
return;
|
|
4052
4052
|
}
|
|
4053
4053
|
if (node.type !== import_utils19.AST_NODE_TYPES.MemberExpression) return;
|
|
4054
|
-
const
|
|
4055
|
-
if (
|
|
4054
|
+
const propertyName7 = node.property.type === import_utils19.AST_NODE_TYPES.Identifier || node.property.type === import_utils19.AST_NODE_TYPES.PrivateIdentifier ? node.property.name : node.property.type === import_utils19.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
4055
|
+
if (propertyName7 !== name) return;
|
|
4056
4056
|
const propertySymbol = symbolAt(services, checker, node.property);
|
|
4057
4057
|
if (node.computed || node.property.type !== import_utils19.AST_NODE_TYPES.Identifier || node.object.type !== import_utils19.AST_NODE_TYPES.ThisExpression || enclosingClass(node) !== owner || !symbols.some((symbol) => sameSymbol(symbol, propertySymbol))) {
|
|
4058
4058
|
unsafe = true;
|
|
@@ -5461,9 +5461,9 @@ var no_positional_tuple_return_default = createRule({
|
|
|
5461
5461
|
TSMethodSignature(node) {
|
|
5462
5462
|
const owner = owningInterface(node);
|
|
5463
5463
|
const alias = owningTypeAlias(node);
|
|
5464
|
-
const
|
|
5465
|
-
if ((owner === null || !isExportedInterface(owner, typeExports)) && (alias === null || !typeExports.has(alias.id.name)) || node.returnType === void 0 ||
|
|
5466
|
-
report2(node.returnType.typeAnnotation, `${owner?.id.name ?? alias?.id.name ?? "type"}.${
|
|
5464
|
+
const memberName6 = staticMemberName3(node.key);
|
|
5465
|
+
if ((owner === null || !isExportedInterface(owner, typeExports)) && (alias === null || !typeExports.has(alias.id.name)) || node.returnType === void 0 || memberName6 === null) return;
|
|
5466
|
+
report2(node.returnType.typeAnnotation, `${owner?.id.name ?? alias?.id.name ?? "type"}.${memberName6}`);
|
|
5467
5467
|
},
|
|
5468
5468
|
TSTypeAliasDeclaration(node) {
|
|
5469
5469
|
if (!typeExports.has(node.id.name)) return;
|
|
@@ -5474,11 +5474,11 @@ var no_positional_tuple_return_default = createRule({
|
|
|
5474
5474
|
const owner = owningInterface(node);
|
|
5475
5475
|
const alias = owningTypeAlias(node);
|
|
5476
5476
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
5477
|
-
const
|
|
5478
|
-
if ((owner === null || !isExportedInterface(owner, typeExports)) && (alias === null || !typeExports.has(alias.id.name)) ||
|
|
5477
|
+
const memberName6 = staticMemberName3(node.key);
|
|
5478
|
+
if ((owner === null || !isExportedInterface(owner, typeExports)) && (alias === null || !typeExports.has(alias.id.name)) || memberName6 === null || annotation === void 0) return;
|
|
5479
5479
|
const returnType = callableReturnType(annotation, aliases);
|
|
5480
5480
|
if (returnType !== null) {
|
|
5481
|
-
report2(returnType, `${owner?.id.name ?? alias?.id.name ?? "type"}.${
|
|
5481
|
+
report2(returnType, `${owner?.id.name ?? alias?.id.name ?? "type"}.${memberName6}`);
|
|
5482
5482
|
}
|
|
5483
5483
|
},
|
|
5484
5484
|
PropertyDefinition(node) {
|
|
@@ -11861,7 +11861,7 @@ var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
|
11861
11861
|
remediation: "Import hash from node:crypto and replace a single-update chain with hash(algorithm, value, encoding). Keep createHash for streams or multiple incremental updates.",
|
|
11862
11862
|
category: "performance",
|
|
11863
11863
|
limitations: [
|
|
11864
|
-
"Only
|
|
11864
|
+
"Only bindings and inline calls with statically proven provenance from crypto or node:crypto are analyzed; arbitrary assignments and dynamic module specifiers are excluded.",
|
|
11865
11865
|
"Only a literal algorithm with exactly one update call is reported; streaming and incremental hashes remain valid."
|
|
11866
11866
|
],
|
|
11867
11867
|
examples: [
|
|
@@ -11869,22 +11869,79 @@ var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
|
11869
11869
|
{ id: "mutable-one-shot-chain", title: "Avoid mutable state for one value", outcome: "match", files: [{ path: "case.ts", source: "import { createHash } from 'node:crypto'; export const digest = createHash('sha256').update('value').digest('hex');" }], focusPath: "case.ts", expectedCount: 1, public: true }
|
|
11870
11870
|
]
|
|
11871
11871
|
};
|
|
11872
|
+
function memberName3(node) {
|
|
11873
|
+
if (!node.computed && node.property.type === import_utils68.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
11874
|
+
if (node.computed && node.property.type === import_utils68.AST_NODE_TYPES.Literal && typeof node.property.value === "string") {
|
|
11875
|
+
return node.property.value;
|
|
11876
|
+
}
|
|
11877
|
+
return null;
|
|
11878
|
+
}
|
|
11879
|
+
function isCryptoLoader(node, resolve) {
|
|
11880
|
+
if (node.type !== import_utils68.AST_NODE_TYPES.CallExpression || node.arguments.length !== 1) return false;
|
|
11881
|
+
const [argument] = node.arguments;
|
|
11882
|
+
if (argument === void 0 || argument.type === import_utils68.AST_NODE_TYPES.SpreadElement || !isCryptoSpecifier(argument)) {
|
|
11883
|
+
return false;
|
|
11884
|
+
}
|
|
11885
|
+
if (node.callee.type === import_utils68.AST_NODE_TYPES.Identifier) {
|
|
11886
|
+
return node.callee.name === "require" && isUnshadowedBuiltinIdentifier(node.callee, resolve);
|
|
11887
|
+
}
|
|
11888
|
+
return node.callee.type === import_utils68.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils68.AST_NODE_TYPES.Identifier && node.callee.object.name === "process" && isUnshadowedBuiltinIdentifier(node.callee.object, resolve) && memberName3(node.callee) === "getBuiltinModule";
|
|
11889
|
+
}
|
|
11890
|
+
function isCryptoSpecifier(node) {
|
|
11891
|
+
return node.type === import_utils68.AST_NODE_TYPES.Literal && (node.value === "crypto" || node.value === "node:crypto");
|
|
11892
|
+
}
|
|
11893
|
+
function isUnshadowedBuiltinIdentifier(identifier, resolve) {
|
|
11894
|
+
const variable = resolve(identifier);
|
|
11895
|
+
return variable === null || variable.defs.length === 0;
|
|
11896
|
+
}
|
|
11897
|
+
function propertyName3(node) {
|
|
11898
|
+
if (!node.computed && node.key.type === import_utils68.AST_NODE_TYPES.Identifier) return node.key.name;
|
|
11899
|
+
if (node.key.type === import_utils68.AST_NODE_TYPES.Literal && typeof node.key.value === "string") {
|
|
11900
|
+
return node.key.value;
|
|
11901
|
+
}
|
|
11902
|
+
return null;
|
|
11903
|
+
}
|
|
11872
11904
|
var prefer_node_crypto_hash_default = createRule({
|
|
11873
11905
|
name: "prefer-node-crypto-hash",
|
|
11874
11906
|
documentation: PREFER_NODE_CRYPTO_HASH_DOCUMENTATION,
|
|
11875
11907
|
meta: { type: "problem", docs: { description: PREFER_NODE_CRYPTO_HASH_DOCUMENTATION.summary }, schema: [], messages: { preferNodeCryptoHash: "Prefer the modern one-shot node:crypto hash API when streaming state is unnecessary." } },
|
|
11876
11908
|
defaultOptions: [],
|
|
11877
11909
|
create(context) {
|
|
11878
|
-
const
|
|
11879
|
-
const
|
|
11910
|
+
const directBindings = /* @__PURE__ */ new Set();
|
|
11911
|
+
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
11912
|
+
function resolve(identifier) {
|
|
11913
|
+
return import_utils68.ASTUtils.findVariable(
|
|
11914
|
+
context.sourceCode.getScope(identifier),
|
|
11915
|
+
identifier.name
|
|
11916
|
+
);
|
|
11917
|
+
}
|
|
11918
|
+
function record(identifier, destination) {
|
|
11919
|
+
const variable = resolve(identifier);
|
|
11920
|
+
if (variable !== null) destination.add(variable);
|
|
11921
|
+
}
|
|
11880
11922
|
return {
|
|
11881
11923
|
ImportDeclaration(node) {
|
|
11882
|
-
if (node.source.value !== "node:crypto") return;
|
|
11924
|
+
if (node.source.value !== "crypto" && node.source.value !== "node:crypto") return;
|
|
11883
11925
|
for (const specifier of node.specifiers) {
|
|
11884
|
-
if (specifier.type === import_utils68.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
11885
|
-
|
|
11926
|
+
if (specifier.type === import_utils68.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils68.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
11927
|
+
record(specifier.local, namespaceBindings);
|
|
11886
11928
|
} else if (specifier.type === import_utils68.AST_NODE_TYPES.ImportSpecifier && importedName5(specifier.imported) === "createHash") {
|
|
11887
|
-
|
|
11929
|
+
record(specifier.local, directBindings);
|
|
11930
|
+
}
|
|
11931
|
+
}
|
|
11932
|
+
},
|
|
11933
|
+
VariableDeclarator(node) {
|
|
11934
|
+
if (node.parent.kind !== "const" || node.init === null || !isCryptoLoader(node.init, resolve)) {
|
|
11935
|
+
return;
|
|
11936
|
+
}
|
|
11937
|
+
if (node.id.type === import_utils68.AST_NODE_TYPES.Identifier) {
|
|
11938
|
+
record(node.id, namespaceBindings);
|
|
11939
|
+
return;
|
|
11940
|
+
}
|
|
11941
|
+
if (node.id.type !== import_utils68.AST_NODE_TYPES.ObjectPattern) return;
|
|
11942
|
+
for (const property of node.id.properties) {
|
|
11943
|
+
if (property.type === import_utils68.AST_NODE_TYPES.Property && propertyName3(property) === "createHash" && property.value.type === import_utils68.AST_NODE_TYPES.Identifier) {
|
|
11944
|
+
record(property.value, directBindings);
|
|
11888
11945
|
}
|
|
11889
11946
|
}
|
|
11890
11947
|
},
|
|
@@ -11894,7 +11951,12 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
11894
11951
|
if (update.type !== import_utils68.AST_NODE_TYPES.CallExpression || update.arguments.length !== 1 || !isMemberCall(update, "update"))
|
|
11895
11952
|
return;
|
|
11896
11953
|
const create = update.callee.object;
|
|
11897
|
-
if (create.type !== import_utils68.AST_NODE_TYPES.CallExpression || create.arguments.length !== 1 || create.arguments[0]?.type !== import_utils68.AST_NODE_TYPES.Literal || typeof create.arguments[0].value !== "string" || !isCreateHashCall(
|
|
11954
|
+
if (create.type !== import_utils68.AST_NODE_TYPES.CallExpression || create.arguments.length !== 1 || create.arguments[0]?.type !== import_utils68.AST_NODE_TYPES.Literal || typeof create.arguments[0].value !== "string" || !isCreateHashCall(
|
|
11955
|
+
create,
|
|
11956
|
+
directBindings,
|
|
11957
|
+
namespaceBindings,
|
|
11958
|
+
resolve
|
|
11959
|
+
))
|
|
11898
11960
|
return;
|
|
11899
11961
|
context.report({ node, messageId: "preferNodeCryptoHash" });
|
|
11900
11962
|
}
|
|
@@ -11905,12 +11967,20 @@ function importedName5(node) {
|
|
|
11905
11967
|
return node.type === import_utils68.AST_NODE_TYPES.Identifier ? node.name : node.value;
|
|
11906
11968
|
}
|
|
11907
11969
|
function isMemberCall(node, name) {
|
|
11908
|
-
return node.callee.type === import_utils68.AST_NODE_TYPES.MemberExpression &&
|
|
11970
|
+
return node.callee.type === import_utils68.AST_NODE_TYPES.MemberExpression && memberName3(node.callee) === name;
|
|
11909
11971
|
}
|
|
11910
|
-
function isCreateHashCall(node,
|
|
11911
|
-
if (node.callee.type === import_utils68.AST_NODE_TYPES.Identifier)
|
|
11912
|
-
|
|
11913
|
-
|
|
11972
|
+
function isCreateHashCall(node, directBindings, namespaceBindings, resolve) {
|
|
11973
|
+
if (node.callee.type === import_utils68.AST_NODE_TYPES.Identifier) {
|
|
11974
|
+
const variable2 = resolve(node.callee);
|
|
11975
|
+
return variable2 !== null && directBindings.has(variable2);
|
|
11976
|
+
}
|
|
11977
|
+
if (node.callee.type !== import_utils68.AST_NODE_TYPES.MemberExpression || memberName3(node.callee) !== "createHash") {
|
|
11978
|
+
return false;
|
|
11979
|
+
}
|
|
11980
|
+
if (isCryptoLoader(node.callee.object, resolve)) return true;
|
|
11981
|
+
if (node.callee.object.type !== import_utils68.AST_NODE_TYPES.Identifier) return false;
|
|
11982
|
+
const variable = resolve(node.callee.object);
|
|
11983
|
+
return variable !== null && namespaceBindings.has(variable);
|
|
11914
11984
|
}
|
|
11915
11985
|
|
|
11916
11986
|
// src/rules/prefer-node-fs-promises.ts
|
|
@@ -11923,20 +11993,40 @@ var PREFER_NODE_FS_PROMISES_DOCUMENTATION = {
|
|
|
11923
11993
|
limitations: [
|
|
11924
11994
|
"Tests and generated files are excluded.",
|
|
11925
11995
|
"ESLint rule implementations under src/rules are excluded because visitor creation and execution are synchronous by contract.",
|
|
11926
|
-
"
|
|
11996
|
+
"Only statically identifiable node:fs loads are inspected; filesystem objects passed through arbitrary functions or assignments require type-aware analysis."
|
|
11927
11997
|
],
|
|
11928
11998
|
examples: [
|
|
11929
11999
|
{ id: "async-read", title: "Use the promise API", outcome: "no-match", files: [{ path: "src/store.ts", source: "import { readFile } from 'node:fs/promises'; export async function load(path: string) { return readFile(path, 'utf8'); }" }], focusPath: "src/store.ts", expectedCount: 0, public: true },
|
|
11930
12000
|
{ id: "sync-read", title: "Do not block on a synchronous read", outcome: "match", files: [{ path: "src/store.ts", source: "import { readFileSync } from 'node:fs'; export function load(path: string) { return readFileSync(path, 'utf8'); }" }], focusPath: "src/store.ts", expectedCount: 1, public: true }
|
|
11931
12001
|
]
|
|
11932
12002
|
};
|
|
11933
|
-
function
|
|
12003
|
+
function memberName4(node) {
|
|
11934
12004
|
if (!node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
11935
12005
|
if (node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Literal && typeof node.property.value === "string") {
|
|
11936
12006
|
return node.property.value;
|
|
11937
12007
|
}
|
|
11938
12008
|
return null;
|
|
11939
12009
|
}
|
|
12010
|
+
function unwrapAwait2(node) {
|
|
12011
|
+
return node.type === import_utils69.AST_NODE_TYPES.AwaitExpression ? node.argument : node;
|
|
12012
|
+
}
|
|
12013
|
+
function isFsLoader(node) {
|
|
12014
|
+
const expression = unwrapAwait2(node);
|
|
12015
|
+
if (expression.type === import_utils69.AST_NODE_TYPES.ImportExpression) return isFsSpecifier(expression.source);
|
|
12016
|
+
if (expression.type !== import_utils69.AST_NODE_TYPES.CallExpression || expression.arguments.length !== 1) return false;
|
|
12017
|
+
const [argument] = expression.arguments;
|
|
12018
|
+
if (argument === void 0 || argument.type === import_utils69.AST_NODE_TYPES.SpreadElement || !isFsSpecifier(argument)) return false;
|
|
12019
|
+
if (expression.callee.type === import_utils69.AST_NODE_TYPES.Identifier) return expression.callee.name === "require";
|
|
12020
|
+
return expression.callee.type === import_utils69.AST_NODE_TYPES.MemberExpression && expression.callee.object.type === import_utils69.AST_NODE_TYPES.Identifier && expression.callee.object.name === "process" && memberName4(expression.callee) === "getBuiltinModule";
|
|
12021
|
+
}
|
|
12022
|
+
function isFsSpecifier(node) {
|
|
12023
|
+
return node.type === import_utils69.AST_NODE_TYPES.Literal && (node.value === "node:fs" || node.value === "fs");
|
|
12024
|
+
}
|
|
12025
|
+
function propertyName4(node) {
|
|
12026
|
+
if (!node.computed && node.key.type === import_utils69.AST_NODE_TYPES.Identifier) return node.key.name;
|
|
12027
|
+
if (node.key.type === import_utils69.AST_NODE_TYPES.Literal && typeof node.key.value === "string") return node.key.value;
|
|
12028
|
+
return null;
|
|
12029
|
+
}
|
|
11940
12030
|
var prefer_node_fs_promises_default = createRule({
|
|
11941
12031
|
name: "prefer-node-fs-promises",
|
|
11942
12032
|
documentation: PREFER_NODE_FS_PROMISES_DOCUMENTATION,
|
|
@@ -11973,10 +12063,32 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
11973
12063
|
});
|
|
11974
12064
|
}
|
|
11975
12065
|
},
|
|
12066
|
+
VariableDeclarator(node) {
|
|
12067
|
+
if (node.init === null || !isFsLoader(node.init) && (node.init.type !== import_utils69.AST_NODE_TYPES.Identifier || !namespaces.has(node.init.name)))
|
|
12068
|
+
return;
|
|
12069
|
+
if (node.id.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
12070
|
+
namespaces.add(node.id.name);
|
|
12071
|
+
return;
|
|
12072
|
+
}
|
|
12073
|
+
if (node.id.type !== import_utils69.AST_NODE_TYPES.ObjectPattern) return;
|
|
12074
|
+
const synchronousImports = node.id.properties.flatMap((property) => {
|
|
12075
|
+
if (property.type !== import_utils69.AST_NODE_TYPES.Property) return [];
|
|
12076
|
+
const name = propertyName4(property);
|
|
12077
|
+
return name?.endsWith("Sync") === true ? [name] : [];
|
|
12078
|
+
});
|
|
12079
|
+
if (synchronousImports.length > 0) {
|
|
12080
|
+
context.report({
|
|
12081
|
+
node,
|
|
12082
|
+
messageId: "preferAsyncFs",
|
|
12083
|
+
data: { name: synchronousImports.join(", ") }
|
|
12084
|
+
});
|
|
12085
|
+
}
|
|
12086
|
+
},
|
|
11976
12087
|
MemberExpression(node) {
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
|
|
12088
|
+
const name = memberName4(node);
|
|
12089
|
+
if (name?.endsWith("Sync") !== true) return;
|
|
12090
|
+
const object = unwrapAwait2(node.object);
|
|
12091
|
+
if (object.type === import_utils69.AST_NODE_TYPES.Identifier && namespaces.has(object.name) || isFsLoader(object)) {
|
|
11980
12092
|
context.report({ node, messageId: "preferAsyncFs", data: { name } });
|
|
11981
12093
|
}
|
|
11982
12094
|
}
|
|
@@ -11998,7 +12110,7 @@ var PREFER_NON_NULLABLE_COLLECTION_DOCUMENTATION = {
|
|
|
11998
12110
|
]
|
|
11999
12111
|
};
|
|
12000
12112
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
12001
|
-
function
|
|
12113
|
+
function propertyName5(node) {
|
|
12002
12114
|
const key = node.key;
|
|
12003
12115
|
if (node.computed) return null;
|
|
12004
12116
|
if (key.type === import_utils70.AST_NODE_TYPES.Identifier) return key.name;
|
|
@@ -12011,7 +12123,7 @@ function isArrayType(node) {
|
|
|
12011
12123
|
}
|
|
12012
12124
|
function nullableProperty(node) {
|
|
12013
12125
|
if (node.optional) return null;
|
|
12014
|
-
const name =
|
|
12126
|
+
const name = propertyName5(node);
|
|
12015
12127
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
12016
12128
|
if (name === null || annotation?.type !== import_utils70.AST_NODE_TYPES.TSUnionType) return null;
|
|
12017
12129
|
const concrete = annotation.types.filter(
|
|
@@ -12221,7 +12333,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
12221
12333
|
context.report({
|
|
12222
12334
|
node,
|
|
12223
12335
|
messageId: "preferNonNullableCollection",
|
|
12224
|
-
data: { name:
|
|
12336
|
+
data: { name: propertyName5(node) ?? "collection" }
|
|
12225
12337
|
});
|
|
12226
12338
|
}
|
|
12227
12339
|
}
|
|
@@ -13052,14 +13164,14 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
13052
13164
|
// src/rules/prefer-shared-zod-enum.ts
|
|
13053
13165
|
var import_utils74 = require("@typescript-eslint/utils");
|
|
13054
13166
|
var PREFER_SHARED_ZOD_ENUM_DOCUMENTATION = {
|
|
13055
|
-
summary: "
|
|
13056
|
-
rationale: "
|
|
13057
|
-
remediation: "Declare
|
|
13167
|
+
summary: "Give literal Zod enum domains one reusable module-level schema.",
|
|
13168
|
+
rationale: "Inline or repeated literal domains hide a reusable contract and allow equivalent fields to drift independently.",
|
|
13169
|
+
remediation: "Declare a module-level named Zod enum schema and reuse it at each field or contract site.",
|
|
13058
13170
|
category: "maintainability",
|
|
13059
|
-
limitations: ["Only direct z.enum calls with
|
|
13171
|
+
limitations: ["Only direct z.enum calls with string-literal arrays are inspected; computed domains require review."],
|
|
13060
13172
|
examples: [
|
|
13061
13173
|
{ id: "shared-provider", title: "Reuse a named enum schema", outcome: "no-match", files: [{ path: "src/provider.ts", source: "import { z } from 'zod'; const ProviderSchema = z.enum(['agy', 'claude', 'sol']); const JobSchema = z.object({ provider: ProviderSchema }); const StatusSchema = z.object({ provider: ProviderSchema.optional() });" }], focusPath: "src/provider.ts", expectedCount: 0, public: true },
|
|
13062
|
-
{ id: "
|
|
13174
|
+
{ id: "inline-provider", title: "Do not inline enum domains in object fields", outcome: "match", files: [{ path: "src/provider.ts", source: "import { z } from 'zod'; const JobSchema = z.object({ provider: z.enum(['agy', 'claude', 'sol']) });" }], focusPath: "src/provider.ts", expectedCount: 1, public: true }
|
|
13063
13175
|
]
|
|
13064
13176
|
};
|
|
13065
13177
|
function literalDomain(node) {
|
|
@@ -13072,15 +13184,26 @@ function literalDomain(node) {
|
|
|
13072
13184
|
}
|
|
13073
13185
|
return values;
|
|
13074
13186
|
}
|
|
13187
|
+
function isModuleLevelNamedSchema(node) {
|
|
13188
|
+
let current = node;
|
|
13189
|
+
while (current.parent?.type === import_utils74.AST_NODE_TYPES.MemberExpression && current.parent.object === current) {
|
|
13190
|
+
current = current.parent;
|
|
13191
|
+
if (current.parent?.type === import_utils74.AST_NODE_TYPES.CallExpression && current.parent.callee === current) current = current.parent;
|
|
13192
|
+
}
|
|
13193
|
+
const declarator = current.parent;
|
|
13194
|
+
if (declarator?.type !== import_utils74.AST_NODE_TYPES.VariableDeclarator || declarator.init !== current || declarator.id.type !== import_utils74.AST_NODE_TYPES.Identifier || declarator.parent.type !== import_utils74.AST_NODE_TYPES.VariableDeclaration) return false;
|
|
13195
|
+
const declarationParent = declarator.parent.parent;
|
|
13196
|
+
return declarationParent.type === import_utils74.AST_NODE_TYPES.Program || declarationParent.type === import_utils74.AST_NODE_TYPES.ExportNamedDeclaration && declarationParent.parent.type === import_utils74.AST_NODE_TYPES.Program;
|
|
13197
|
+
}
|
|
13075
13198
|
var prefer_shared_zod_enum_default = createRule({
|
|
13076
13199
|
name: "prefer-shared-zod-enum",
|
|
13077
13200
|
documentation: PREFER_SHARED_ZOD_ENUM_DOCUMENTATION,
|
|
13078
13201
|
meta: {
|
|
13079
13202
|
type: "suggestion",
|
|
13080
|
-
docs: { description: "
|
|
13203
|
+
docs: { description: "Give literal Zod enum domains one reusable module-level schema." },
|
|
13081
13204
|
schema: [],
|
|
13082
13205
|
messages: {
|
|
13083
|
-
shareEnumDomain: "
|
|
13206
|
+
shareEnumDomain: "Extract this literal Zod enum to one module-level named schema and reuse it."
|
|
13084
13207
|
}
|
|
13085
13208
|
},
|
|
13086
13209
|
defaultOptions: [],
|
|
@@ -13100,7 +13223,9 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
13100
13223
|
const domain = literalDomain(node);
|
|
13101
13224
|
if (domain === null) return;
|
|
13102
13225
|
const key = JSON.stringify(domain);
|
|
13103
|
-
|
|
13226
|
+
const inline = !isModuleLevelNamedSchema(node);
|
|
13227
|
+
if (inline || seen.has(key))
|
|
13228
|
+
context.report({ node, messageId: "shareEnumDomain" });
|
|
13104
13229
|
else seen.add(key);
|
|
13105
13230
|
}
|
|
13106
13231
|
};
|
|
@@ -13116,6 +13241,7 @@ var PREFER_SWITCH_FOR_REPEATED_EQUALITY_DOCUMENTATION = {
|
|
|
13116
13241
|
category: "maintainability",
|
|
13117
13242
|
limitations: [
|
|
13118
13243
|
"Only direct if/else-if chains with at least three strict-equality tests are reported.",
|
|
13244
|
+
"Case values may be literals, enum-like member references, or upper-case named constants; dynamic expressions are excluded.",
|
|
13119
13245
|
"The rule deliberately ignores compound predicates, loose equality, ranges, and chains that compare different discriminants."
|
|
13120
13246
|
],
|
|
13121
13247
|
examples: [
|
|
@@ -13125,11 +13251,17 @@ var PREFER_SWITCH_FOR_REPEATED_EQUALITY_DOCUMENTATION = {
|
|
|
13125
13251
|
};
|
|
13126
13252
|
function discriminantText(sourceCode, test) {
|
|
13127
13253
|
if (test.type !== import_utils75.AST_NODE_TYPES.BinaryExpression || test.operator !== "===") return null;
|
|
13128
|
-
const leftIsCase = test.left
|
|
13129
|
-
const rightIsCase = test.right
|
|
13254
|
+
const leftIsCase = isCaseValue(test.left);
|
|
13255
|
+
const rightIsCase = isCaseValue(test.right);
|
|
13130
13256
|
if (leftIsCase === rightIsCase) return null;
|
|
13131
13257
|
return sourceCode.getText(leftIsCase ? test.right : test.left);
|
|
13132
13258
|
}
|
|
13259
|
+
function isCaseValue(node) {
|
|
13260
|
+
if (node.type === import_utils75.AST_NODE_TYPES.Literal) return true;
|
|
13261
|
+
if (node.type === import_utils75.AST_NODE_TYPES.Identifier) return /^[A-Z][A-Z0-9_]*$/u.test(node.name);
|
|
13262
|
+
if (node.type !== import_utils75.AST_NODE_TYPES.MemberExpression || node.computed) return false;
|
|
13263
|
+
return node.property.type === import_utils75.AST_NODE_TYPES.Identifier && (node.object.type === import_utils75.AST_NODE_TYPES.Identifier || isCaseValue(node.object));
|
|
13264
|
+
}
|
|
13133
13265
|
var prefer_switch_for_repeated_equality_default = createRule({
|
|
13134
13266
|
name: "prefer-switch-for-repeated-equality",
|
|
13135
13267
|
documentation: PREFER_SWITCH_FOR_REPEATED_EQUALITY_DOCUMENTATION,
|
|
@@ -14667,11 +14799,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
14667
14799
|
continue;
|
|
14668
14800
|
}
|
|
14669
14801
|
const key = member.key;
|
|
14670
|
-
const
|
|
14671
|
-
if (
|
|
14802
|
+
const propertyName7 = key.type === import_utils80.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils80.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
14803
|
+
if (propertyName7 === null) {
|
|
14672
14804
|
continue;
|
|
14673
14805
|
}
|
|
14674
|
-
const propertyTokens = nameTokens(
|
|
14806
|
+
const propertyTokens = nameTokens(propertyName7);
|
|
14675
14807
|
if (propertyTokens.length < 2) {
|
|
14676
14808
|
continue;
|
|
14677
14809
|
}
|
|
@@ -14686,7 +14818,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14686
14818
|
node: annotation,
|
|
14687
14819
|
owner,
|
|
14688
14820
|
ownerName,
|
|
14689
|
-
propertyName:
|
|
14821
|
+
propertyName: propertyName7,
|
|
14690
14822
|
propertyTokens
|
|
14691
14823
|
});
|
|
14692
14824
|
}
|
|
@@ -15214,8 +15346,141 @@ var require_fetch_timeout_default = createRule({
|
|
|
15214
15346
|
}
|
|
15215
15347
|
});
|
|
15216
15348
|
|
|
15217
|
-
// src/rules/require-
|
|
15349
|
+
// src/rules/require-interface-for-exported-class.ts
|
|
15218
15350
|
var import_utils83 = require("@typescript-eslint/utils");
|
|
15351
|
+
var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
15352
|
+
summary: "Require exported concrete classes with public behavior to declare a contract.",
|
|
15353
|
+
rationale: "Consumers coupled only to a concrete class cannot substitute implementations or state the supported public capability independently of implementation details.",
|
|
15354
|
+
remediation: "Declare a focused interface and add an implements clause, or inherit from an intentional base contract.",
|
|
15355
|
+
category: "architecture",
|
|
15356
|
+
limitations: [
|
|
15357
|
+
"The warning-stage rule checks module-level class declarations and direct class-expression values exported directly, through local export specifiers, or through a default identifier; re-exports and expressions wrapped in other calls require review.",
|
|
15358
|
+
"An extends clause satisfies the contract only when its target is a locally declared abstract class; imported base-class contracts require an explicit implements clause.",
|
|
15359
|
+
"Static factories and data-only classes without public instance methods are outside the contract requirement."
|
|
15360
|
+
],
|
|
15361
|
+
examples: [
|
|
15362
|
+
{
|
|
15363
|
+
id: "implemented-store-contract",
|
|
15364
|
+
title: "Export behavior through a focused contract",
|
|
15365
|
+
outcome: "no-match",
|
|
15366
|
+
files: [
|
|
15367
|
+
{
|
|
15368
|
+
path: "src/artifact-store.ts",
|
|
15369
|
+
source: "export interface ArtifactStorage { read(id: string): Promise<Uint8Array>; } export class ArtifactStore implements ArtifactStorage { async read(id: string) { return new Uint8Array(); } }"
|
|
15370
|
+
}
|
|
15371
|
+
],
|
|
15372
|
+
focusPath: "src/artifact-store.ts",
|
|
15373
|
+
expectedCount: 0,
|
|
15374
|
+
public: true
|
|
15375
|
+
},
|
|
15376
|
+
{
|
|
15377
|
+
id: "concrete-only-store",
|
|
15378
|
+
title: "Do not export behavior only through a concrete class",
|
|
15379
|
+
outcome: "match",
|
|
15380
|
+
files: [
|
|
15381
|
+
{
|
|
15382
|
+
path: "src/artifact-store.ts",
|
|
15383
|
+
source: "export class ArtifactStore { async read(id: string) { return new Uint8Array(); } }"
|
|
15384
|
+
}
|
|
15385
|
+
],
|
|
15386
|
+
focusPath: "src/artifact-store.ts",
|
|
15387
|
+
expectedCount: 1,
|
|
15388
|
+
public: true
|
|
15389
|
+
}
|
|
15390
|
+
]
|
|
15391
|
+
};
|
|
15392
|
+
function hasPublicInstanceBehavior(node) {
|
|
15393
|
+
return node.body.body.some((member) => {
|
|
15394
|
+
if (member.type === import_utils83.AST_NODE_TYPES.MethodDefinition) {
|
|
15395
|
+
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !== import_utils83.AST_NODE_TYPES.PrivateIdentifier;
|
|
15396
|
+
}
|
|
15397
|
+
if (member.type !== import_utils83.AST_NODE_TYPES.PropertyDefinition || member.static)
|
|
15398
|
+
return false;
|
|
15399
|
+
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type === import_utils83.AST_NODE_TYPES.PrivateIdentifier) return false;
|
|
15400
|
+
return member.value?.type === import_utils83.AST_NODE_TYPES.ArrowFunctionExpression || member.value?.type === import_utils83.AST_NODE_TYPES.FunctionExpression || member.typeAnnotation?.typeAnnotation.type === import_utils83.AST_NODE_TYPES.TSFunctionType;
|
|
15401
|
+
});
|
|
15402
|
+
}
|
|
15403
|
+
function classBindings(statement) {
|
|
15404
|
+
const declaration = statement.type === import_utils83.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15405
|
+
if (declaration?.type === import_utils83.AST_NODE_TYPES.ClassDeclaration) {
|
|
15406
|
+
return declaration.id === null ? [] : [{ declaration, name: declaration.id.name }];
|
|
15407
|
+
}
|
|
15408
|
+
if (declaration?.type !== import_utils83.AST_NODE_TYPES.VariableDeclaration) return [];
|
|
15409
|
+
return declaration.declarations.flatMap(
|
|
15410
|
+
(item) => item.id.type === import_utils83.AST_NODE_TYPES.Identifier && item.init?.type === import_utils83.AST_NODE_TYPES.ClassExpression ? [{ declaration: item.init, name: item.id.name }] : []
|
|
15411
|
+
);
|
|
15412
|
+
}
|
|
15413
|
+
var require_interface_for_exported_class_default = createRule({
|
|
15414
|
+
name: "require-interface-for-exported-class",
|
|
15415
|
+
documentation: REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION,
|
|
15416
|
+
meta: {
|
|
15417
|
+
type: "suggestion",
|
|
15418
|
+
docs: {
|
|
15419
|
+
description: "Require exported concrete classes with public behavior to declare a contract."
|
|
15420
|
+
},
|
|
15421
|
+
schema: [],
|
|
15422
|
+
messages: {
|
|
15423
|
+
requireContract: "Exported class `{{name}}` has public behavior but no declared interface or base contract; add a focused contract and implement it."
|
|
15424
|
+
}
|
|
15425
|
+
},
|
|
15426
|
+
defaultOptions: [],
|
|
15427
|
+
create(context) {
|
|
15428
|
+
if (isTestFile(context.filename) || isStoryFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
15429
|
+
return {
|
|
15430
|
+
"Program:exit"(program) {
|
|
15431
|
+
const classes = /* @__PURE__ */ new Map();
|
|
15432
|
+
const abstractBases = /* @__PURE__ */ new Set();
|
|
15433
|
+
for (const statement of program.body) {
|
|
15434
|
+
for (const binding of classBindings(statement)) {
|
|
15435
|
+
classes.set(binding.name, binding.declaration);
|
|
15436
|
+
if (binding.declaration.abstract) abstractBases.add(binding.name);
|
|
15437
|
+
}
|
|
15438
|
+
}
|
|
15439
|
+
const exported = /* @__PURE__ */ new Map();
|
|
15440
|
+
for (const statement of program.body) {
|
|
15441
|
+
if (statement.type === import_utils83.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
15442
|
+
for (const binding of classBindings(statement)) {
|
|
15443
|
+
exported.set(binding.declaration, binding.name);
|
|
15444
|
+
}
|
|
15445
|
+
if (statement.source !== null || statement.exportKind === "type") continue;
|
|
15446
|
+
for (const specifier of statement.specifiers) {
|
|
15447
|
+
if (specifier.exportKind === "type") continue;
|
|
15448
|
+
const candidate2 = classes.get(specifier.local.name);
|
|
15449
|
+
if (candidate2 === void 0) continue;
|
|
15450
|
+
const exportedName = specifier.exported.type === import_utils83.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
15451
|
+
exported.set(candidate2, exportedName);
|
|
15452
|
+
}
|
|
15453
|
+
continue;
|
|
15454
|
+
}
|
|
15455
|
+
if (statement.type !== import_utils83.AST_NODE_TYPES.ExportDefaultDeclaration) continue;
|
|
15456
|
+
if (statement.declaration.type === import_utils83.AST_NODE_TYPES.ClassDeclaration || statement.declaration.type === import_utils83.AST_NODE_TYPES.ClassExpression) {
|
|
15457
|
+
exported.set(
|
|
15458
|
+
statement.declaration,
|
|
15459
|
+
statement.declaration.id?.name ?? "default"
|
|
15460
|
+
);
|
|
15461
|
+
} else if (statement.declaration.type === import_utils83.AST_NODE_TYPES.Identifier) {
|
|
15462
|
+
const candidate2 = classes.get(statement.declaration.name);
|
|
15463
|
+
if (candidate2 !== void 0) {
|
|
15464
|
+
exported.set(candidate2, statement.declaration.name);
|
|
15465
|
+
}
|
|
15466
|
+
}
|
|
15467
|
+
}
|
|
15468
|
+
for (const [declaration, exportedName] of exported) {
|
|
15469
|
+
const extendsLocalAbstractBase = declaration.superClass?.type === import_utils83.AST_NODE_TYPES.Identifier && abstractBases.has(declaration.superClass.name);
|
|
15470
|
+
if (declaration.abstract || declaration.implements.length > 0 || extendsLocalAbstractBase || !hasPublicInstanceBehavior(declaration)) continue;
|
|
15471
|
+
context.report({
|
|
15472
|
+
node: declaration.id ?? declaration,
|
|
15473
|
+
messageId: "requireContract",
|
|
15474
|
+
data: { name: exportedName }
|
|
15475
|
+
});
|
|
15476
|
+
}
|
|
15477
|
+
}
|
|
15478
|
+
};
|
|
15479
|
+
}
|
|
15480
|
+
});
|
|
15481
|
+
|
|
15482
|
+
// src/rules/require-port-for-service.ts
|
|
15483
|
+
var import_utils84 = require("@typescript-eslint/utils");
|
|
15219
15484
|
var REQUIRE_PORT_FOR_SERVICE_DOCUMENTATION = {
|
|
15220
15485
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
15221
15486
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -15240,45 +15505,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
15240
15505
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
15241
15506
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
15242
15507
|
var staticMemberName6 = (member) => {
|
|
15243
|
-
if (member.property.type ===
|
|
15244
|
-
if (!member.computed && member.property.type ===
|
|
15245
|
-
return member.computed && member.property.type ===
|
|
15508
|
+
if (member.property.type === import_utils84.AST_NODE_TYPES.PrivateIdentifier) return `#${member.property.name}`;
|
|
15509
|
+
if (!member.computed && member.property.type === import_utils84.AST_NODE_TYPES.Identifier) return member.property.name;
|
|
15510
|
+
return member.computed && member.property.type === import_utils84.AST_NODE_TYPES.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
15246
15511
|
};
|
|
15247
15512
|
var detachedValueExports = (program) => {
|
|
15248
15513
|
const names = /* @__PURE__ */ new Set();
|
|
15249
15514
|
for (const statement of program.body) {
|
|
15250
|
-
if (statement.type ===
|
|
15515
|
+
if (statement.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
15251
15516
|
for (const specifier of statement.specifiers) {
|
|
15252
15517
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
15253
15518
|
}
|
|
15254
|
-
} else if (statement.type ===
|
|
15519
|
+
} else if (statement.type === import_utils84.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils84.AST_NODE_TYPES.Identifier) {
|
|
15255
15520
|
names.add(statement.declaration.name);
|
|
15256
|
-
} else if (statement.type ===
|
|
15521
|
+
} else if (statement.type === import_utils84.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils84.AST_NODE_TYPES.Identifier) {
|
|
15257
15522
|
names.add(statement.expression.name);
|
|
15258
15523
|
}
|
|
15259
15524
|
}
|
|
15260
15525
|
return names;
|
|
15261
15526
|
};
|
|
15262
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
15527
|
+
var isExportedClass2 = (node, detached) => node.parent.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils84.AST_NODE_TYPES.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
15263
15528
|
var readTypeReference = (annotation) => {
|
|
15264
|
-
if (annotation?.type ===
|
|
15529
|
+
if (annotation?.type === import_utils84.AST_NODE_TYPES.TSUnionType) {
|
|
15265
15530
|
const members = annotation.types.filter(
|
|
15266
|
-
(member) => member.type !==
|
|
15531
|
+
(member) => member.type !== import_utils84.AST_NODE_TYPES.TSUndefinedKeyword && member.type !== import_utils84.AST_NODE_TYPES.TSNullKeyword
|
|
15267
15532
|
);
|
|
15268
15533
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
15269
15534
|
}
|
|
15270
|
-
if (annotation === void 0 || annotation.type !==
|
|
15535
|
+
if (annotation === void 0 || annotation.type !== import_utils84.AST_NODE_TYPES.TSTypeReference) return null;
|
|
15271
15536
|
const { typeName } = annotation;
|
|
15272
|
-
const rightmost = typeName.type ===
|
|
15537
|
+
const rightmost = typeName.type === import_utils84.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils84.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
15273
15538
|
if (rightmost === null) return null;
|
|
15274
15539
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
15275
15540
|
};
|
|
15276
|
-
var qualifiedName = (name) => name.type ===
|
|
15541
|
+
var qualifiedName = (name) => name.type === import_utils84.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils84.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
15277
15542
|
var propertySignatureTypes = (members) => {
|
|
15278
15543
|
const types = /* @__PURE__ */ new Map();
|
|
15279
15544
|
for (const member of members) {
|
|
15280
|
-
if (member.type !==
|
|
15281
|
-
if (member.computed || member.key.type !==
|
|
15545
|
+
if (member.type !== import_utils84.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15546
|
+
if (member.computed || member.key.type !== import_utils84.AST_NODE_TYPES.Identifier) continue;
|
|
15282
15547
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
15283
15548
|
if (reference === null) continue;
|
|
15284
15549
|
types.set(member.key.name, reference);
|
|
@@ -15289,18 +15554,18 @@ var fileTypeIndex = (program) => {
|
|
|
15289
15554
|
const objects = /* @__PURE__ */ new Map();
|
|
15290
15555
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
15291
15556
|
for (const statement of program.body) {
|
|
15292
|
-
const declaration = statement.type ===
|
|
15293
|
-
if (declaration?.type ===
|
|
15557
|
+
const declaration = statement.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15558
|
+
if (declaration?.type === import_utils84.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
15294
15559
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
15295
15560
|
continue;
|
|
15296
15561
|
}
|
|
15297
|
-
if (declaration?.type !==
|
|
15562
|
+
if (declaration?.type !== import_utils84.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
15298
15563
|
const aliased = declaration.typeAnnotation;
|
|
15299
|
-
if (aliased.type ===
|
|
15564
|
+
if (aliased.type === import_utils84.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils84.AST_NODE_TYPES.TSConstructorType) {
|
|
15300
15565
|
functionAliases.add(declaration.id.name);
|
|
15301
15566
|
continue;
|
|
15302
15567
|
}
|
|
15303
|
-
const literals = aliased.type ===
|
|
15568
|
+
const literals = aliased.type === import_utils84.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils84.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils84.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
15304
15569
|
if (literals.length === 0) continue;
|
|
15305
15570
|
const merged = /* @__PURE__ */ new Map();
|
|
15306
15571
|
for (const literal of literals) {
|
|
@@ -15329,10 +15594,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
15329
15594
|
while (pending.length > 0) {
|
|
15330
15595
|
const current = pending.pop();
|
|
15331
15596
|
if (current === void 0) break;
|
|
15332
|
-
if (current.type ===
|
|
15333
|
-
const expression = current.type ===
|
|
15334
|
-
const storedField = expression?.type ===
|
|
15335
|
-
if (expression?.type !==
|
|
15597
|
+
if (current.type === import_utils84.AST_NODE_TYPES.ArrowFunctionExpression || current.type === import_utils84.AST_NODE_TYPES.FunctionExpression || current.type === import_utils84.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils84.AST_NODE_TYPES.ClassExpression || current.type === import_utils84.AST_NODE_TYPES.ClassDeclaration) continue;
|
|
15598
|
+
const expression = current.type === import_utils84.AST_NODE_TYPES.ExpressionStatement ? current.expression : null;
|
|
15599
|
+
const storedField = expression?.type === import_utils84.AST_NODE_TYPES.AssignmentExpression && expression.left.type === import_utils84.AST_NODE_TYPES.MemberExpression && expression.left.object.type === import_utils84.AST_NODE_TYPES.ThisExpression ? staticMemberName6(expression.left) : null;
|
|
15600
|
+
if (expression?.type !== import_utils84.AST_NODE_TYPES.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== import_utils84.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils84.AST_NODE_TYPES.ThisExpression || storedField === null) {
|
|
15336
15601
|
for (const key of Object.keys(current)) {
|
|
15337
15602
|
if (key === "parent") continue;
|
|
15338
15603
|
const value = current[key];
|
|
@@ -15345,14 +15610,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
15345
15610
|
continue;
|
|
15346
15611
|
}
|
|
15347
15612
|
let source = expression.right;
|
|
15348
|
-
while (source.type ===
|
|
15349
|
-
if (source.type ===
|
|
15613
|
+
while (source.type === import_utils84.AST_NODE_TYPES.TSNonNullExpression || source.type === import_utils84.AST_NODE_TYPES.TSAsExpression || source.type === import_utils84.AST_NODE_TYPES.TSSatisfiesExpression || source.type === import_utils84.AST_NODE_TYPES.TSTypeAssertion) source = source.expression;
|
|
15614
|
+
if (source.type === import_utils84.AST_NODE_TYPES.NewExpression) {
|
|
15350
15615
|
constructedFields += 1;
|
|
15351
|
-
} else if (source.type ===
|
|
15616
|
+
} else if (source.type === import_utils84.AST_NODE_TYPES.Identifier) {
|
|
15352
15617
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
15353
15618
|
fields.add(storedField);
|
|
15354
15619
|
storedFieldsFrom.set(source.name, fields);
|
|
15355
|
-
} else if (source.type ===
|
|
15620
|
+
} else if (source.type === import_utils84.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils84.AST_NODE_TYPES.Identifier) {
|
|
15356
15621
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
15357
15622
|
fields.add(storedField);
|
|
15358
15623
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -15370,7 +15635,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
15370
15635
|
const collaborators = [];
|
|
15371
15636
|
for (const parameter of ctor.value.params) {
|
|
15372
15637
|
for (const reference of parameterCollaborators(parameter, declared, storedMemberFieldsFrom)) {
|
|
15373
|
-
const fields = parameter.type ===
|
|
15638
|
+
const fields = parameter.type === import_utils84.AST_NODE_TYPES.TSParameterProperty ? [reference.name] : reference.fields.length > 0 ? reference.fields : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
15374
15639
|
if (fields.length === 0) continue;
|
|
15375
15640
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
15376
15641
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -15385,8 +15650,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
15385
15650
|
};
|
|
15386
15651
|
var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
15387
15652
|
let target = parameter;
|
|
15388
|
-
if (target.type ===
|
|
15389
|
-
if (target.type ===
|
|
15653
|
+
if (target.type === import_utils84.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15654
|
+
if (target.type === import_utils84.AST_NODE_TYPES.ObjectPattern) {
|
|
15390
15655
|
return objectPatternCollaborators(target, declared);
|
|
15391
15656
|
}
|
|
15392
15657
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -15395,9 +15660,9 @@ var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
|
15395
15660
|
};
|
|
15396
15661
|
var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
15397
15662
|
let target = annotated;
|
|
15398
|
-
if (target.type ===
|
|
15399
|
-
if (target.type ===
|
|
15400
|
-
if (target.type !==
|
|
15663
|
+
if (target.type === import_utils84.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
15664
|
+
if (target.type === import_utils84.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15665
|
+
if (target.type !== import_utils84.AST_NODE_TYPES.Identifier) return [];
|
|
15401
15666
|
const members = bagMemberTypes(target.typeAnnotation?.typeAnnotation, declared);
|
|
15402
15667
|
if (members === null) return [];
|
|
15403
15668
|
const storedMembers = storedMemberFieldsFrom.get(target.name);
|
|
@@ -15413,9 +15678,9 @@ var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
|
15413
15678
|
};
|
|
15414
15679
|
var namedParameterCollaborator = (annotated) => {
|
|
15415
15680
|
let target = annotated;
|
|
15416
|
-
if (target.type ===
|
|
15417
|
-
if (target.type ===
|
|
15418
|
-
if (target.type !==
|
|
15681
|
+
if (target.type === import_utils84.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
15682
|
+
if (target.type === import_utils84.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15683
|
+
if (target.type !== import_utils84.AST_NODE_TYPES.Identifier) return null;
|
|
15419
15684
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
15420
15685
|
if (reference === null) return null;
|
|
15421
15686
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -15427,11 +15692,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
15427
15692
|
if (members === null) return [];
|
|
15428
15693
|
const collaborators = [];
|
|
15429
15694
|
for (const property of pattern.properties) {
|
|
15430
|
-
if (property.type !==
|
|
15431
|
-
if (property.key.type !==
|
|
15695
|
+
if (property.type !== import_utils84.AST_NODE_TYPES.Property || property.computed) continue;
|
|
15696
|
+
if (property.key.type !== import_utils84.AST_NODE_TYPES.Identifier) continue;
|
|
15432
15697
|
const key = property.key.name;
|
|
15433
|
-
const bound = property.value.type ===
|
|
15434
|
-
if (bound.type !==
|
|
15698
|
+
const bound = property.value.type === import_utils84.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
15699
|
+
if (bound.type !== import_utils84.AST_NODE_TYPES.Identifier) continue;
|
|
15435
15700
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
15436
15701
|
const reference = members.get(key);
|
|
15437
15702
|
if (reference === void 0) continue;
|
|
@@ -15441,21 +15706,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
15441
15706
|
};
|
|
15442
15707
|
var bagMemberTypes = (annotation, declared) => {
|
|
15443
15708
|
if (annotation === void 0) return null;
|
|
15444
|
-
if (annotation.type ===
|
|
15709
|
+
if (annotation.type === import_utils84.AST_NODE_TYPES.TSTypeLiteral) {
|
|
15445
15710
|
return propertySignatureTypes(annotation.members);
|
|
15446
15711
|
}
|
|
15447
|
-
if (annotation.type !==
|
|
15712
|
+
if (annotation.type !== import_utils84.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils84.AST_NODE_TYPES.Identifier) {
|
|
15448
15713
|
return null;
|
|
15449
15714
|
}
|
|
15450
15715
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
15451
15716
|
};
|
|
15452
15717
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
15453
|
-
if (node.type ===
|
|
15718
|
+
if (node.type === import_utils84.AST_NODE_TYPES.CallExpression) {
|
|
15454
15719
|
const { callee } = node;
|
|
15455
|
-
if (callee.type ===
|
|
15456
|
-
return callee.type ===
|
|
15720
|
+
if (callee.type === import_utils84.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
15721
|
+
return callee.type === import_utils84.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils84.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
15457
15722
|
}
|
|
15458
|
-
return node.type ===
|
|
15723
|
+
return node.type === import_utils84.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils84.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
15459
15724
|
});
|
|
15460
15725
|
var subtreeHas = (root, found) => {
|
|
15461
15726
|
let hit = false;
|
|
@@ -15482,19 +15747,19 @@ var invokedInstanceField = (call) => {
|
|
|
15482
15747
|
const direct = instanceField(call.callee);
|
|
15483
15748
|
if (direct !== null) return direct;
|
|
15484
15749
|
let callee = call.callee;
|
|
15485
|
-
while (callee.type ===
|
|
15486
|
-
return callee.type ===
|
|
15750
|
+
while (callee.type === import_utils84.AST_NODE_TYPES.ChainExpression || callee.type === import_utils84.AST_NODE_TYPES.TSAsExpression || callee.type === import_utils84.AST_NODE_TYPES.TSNonNullExpression || callee.type === import_utils84.AST_NODE_TYPES.TSSatisfiesExpression || callee.type === import_utils84.AST_NODE_TYPES.TSTypeAssertion) callee = callee.expression;
|
|
15751
|
+
return callee.type === import_utils84.AST_NODE_TYPES.MemberExpression ? instanceField(callee.object) : null;
|
|
15487
15752
|
};
|
|
15488
15753
|
var instanceField = (candidate2) => {
|
|
15489
15754
|
let node = candidate2;
|
|
15490
|
-
while (node.type ===
|
|
15491
|
-
return node.type ===
|
|
15755
|
+
while (node.type === import_utils84.AST_NODE_TYPES.ChainExpression || node.type === import_utils84.AST_NODE_TYPES.TSAsExpression || node.type === import_utils84.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils84.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils84.AST_NODE_TYPES.TSTypeAssertion) node = node.expression;
|
|
15756
|
+
return node.type === import_utils84.AST_NODE_TYPES.MemberExpression && node.object.type === import_utils84.AST_NODE_TYPES.ThisExpression ? staticMemberName6(node) : null;
|
|
15492
15757
|
};
|
|
15493
15758
|
var behaviorallyInvokedFields = (body2) => {
|
|
15494
15759
|
const invoked = /* @__PURE__ */ new Set();
|
|
15495
15760
|
const visit = (current) => {
|
|
15496
|
-
if (current.type ===
|
|
15497
|
-
if (current.type ===
|
|
15761
|
+
if (current.type === import_utils84.AST_NODE_TYPES.ClassDeclaration || current.type === import_utils84.AST_NODE_TYPES.ClassExpression || current.type === import_utils84.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils84.AST_NODE_TYPES.FunctionExpression) return;
|
|
15762
|
+
if (current.type === import_utils84.AST_NODE_TYPES.CallExpression) {
|
|
15498
15763
|
const field = invokedInstanceField(current);
|
|
15499
15764
|
if (field !== null) invoked.add(field);
|
|
15500
15765
|
}
|
|
@@ -15507,14 +15772,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
15507
15772
|
}
|
|
15508
15773
|
};
|
|
15509
15774
|
for (const member of body2.body) {
|
|
15510
|
-
if (member.type ===
|
|
15511
|
-
if (member.type ===
|
|
15775
|
+
if (member.type === import_utils84.AST_NODE_TYPES.StaticBlock || member.static) continue;
|
|
15776
|
+
if (member.type === import_utils84.AST_NODE_TYPES.MethodDefinition) {
|
|
15512
15777
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
15513
15778
|
continue;
|
|
15514
15779
|
}
|
|
15515
|
-
if (member.type !==
|
|
15780
|
+
if (member.type !== import_utils84.AST_NODE_TYPES.PropertyDefinition || member.value === null) continue;
|
|
15516
15781
|
visit(
|
|
15517
|
-
member.value.type ===
|
|
15782
|
+
member.value.type === import_utils84.AST_NODE_TYPES.ArrowFunctionExpression ? member.value.body : member.value
|
|
15518
15783
|
);
|
|
15519
15784
|
}
|
|
15520
15785
|
return invoked;
|
|
@@ -15534,26 +15799,26 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
15534
15799
|
var fileInterfaceNames = (program) => {
|
|
15535
15800
|
const names = [];
|
|
15536
15801
|
for (const statement of program.body) {
|
|
15537
|
-
const declaration = statement.type ===
|
|
15538
|
-
if (declaration?.type ===
|
|
15802
|
+
const declaration = statement.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15803
|
+
if (declaration?.type === import_utils84.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
15539
15804
|
}
|
|
15540
15805
|
return names;
|
|
15541
15806
|
};
|
|
15542
15807
|
var publicMethodNames = (body2, functionAliases) => {
|
|
15543
15808
|
const names = [];
|
|
15544
15809
|
for (const member of body2.body) {
|
|
15545
|
-
if (member.type ===
|
|
15810
|
+
if (member.type === import_utils84.AST_NODE_TYPES.PropertyDefinition) {
|
|
15546
15811
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
15547
|
-
if (member.key.type ===
|
|
15548
|
-
if (member.value?.type !==
|
|
15549
|
-
names.push(member.key.type ===
|
|
15812
|
+
if (member.key.type === import_utils84.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
15813
|
+
if (member.value?.type !== import_utils84.AST_NODE_TYPES.ArrowFunctionExpression && member.value?.type !== import_utils84.AST_NODE_TYPES.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== import_utils84.AST_NODE_TYPES.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === import_utils84.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils84.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
15814
|
+
names.push(member.key.type === import_utils84.AST_NODE_TYPES.Identifier ? member.key.name : "\u2026");
|
|
15550
15815
|
continue;
|
|
15551
15816
|
}
|
|
15552
|
-
if (member.type !==
|
|
15817
|
+
if (member.type !== import_utils84.AST_NODE_TYPES.MethodDefinition) continue;
|
|
15553
15818
|
if (member.kind !== "method" || member.static) continue;
|
|
15554
15819
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
15555
|
-
if (member.key.type ===
|
|
15556
|
-
if (member.key.type ===
|
|
15820
|
+
if (member.key.type === import_utils84.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
15821
|
+
if (member.key.type === import_utils84.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
15557
15822
|
else names.push("\u2026");
|
|
15558
15823
|
}
|
|
15559
15824
|
return names;
|
|
@@ -15561,13 +15826,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
15561
15826
|
var isFluentConstructionObject = (node, getText) => {
|
|
15562
15827
|
if (node.id === null) return false;
|
|
15563
15828
|
const methods = node.body.body.filter(
|
|
15564
|
-
(member) => member.type ===
|
|
15829
|
+
(member) => member.type === import_utils84.AST_NODE_TYPES.MethodDefinition && member.kind === "method" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.value.body !== null
|
|
15565
15830
|
);
|
|
15566
15831
|
if (methods.length === 0) return false;
|
|
15567
15832
|
return methods.every((member) => {
|
|
15568
15833
|
const result = member.value.returnType?.typeAnnotation;
|
|
15569
15834
|
if (result === void 0) return false;
|
|
15570
|
-
const returnsOwnType = result.type ===
|
|
15835
|
+
const returnsOwnType = result.type === import_utils84.AST_NODE_TYPES.TSTypeReference && result.typeName.type === import_utils84.AST_NODE_TYPES.Identifier && result.typeName.name === node.id?.name;
|
|
15571
15836
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
15572
15837
|
});
|
|
15573
15838
|
};
|
|
@@ -15575,10 +15840,10 @@ function localClassAbstractness(program) {
|
|
|
15575
15840
|
const classes = /* @__PURE__ */ new Map();
|
|
15576
15841
|
const parents = /* @__PURE__ */ new Map();
|
|
15577
15842
|
for (const statement of program.body) {
|
|
15578
|
-
const declaration = statement.type ===
|
|
15579
|
-
if (declaration?.type ===
|
|
15843
|
+
const declaration = statement.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils84.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
15844
|
+
if (declaration?.type === import_utils84.AST_NODE_TYPES.ClassDeclaration && declaration.id !== null) {
|
|
15580
15845
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
15581
|
-
if (declaration.superClass?.type ===
|
|
15846
|
+
if (declaration.superClass?.type === import_utils84.AST_NODE_TYPES.Identifier) {
|
|
15582
15847
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
15583
15848
|
}
|
|
15584
15849
|
}
|
|
@@ -15600,43 +15865,43 @@ function localInterfaceSurfaces(program) {
|
|
|
15600
15865
|
const parents = /* @__PURE__ */ new Map();
|
|
15601
15866
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
15602
15867
|
for (const statement of program.body) {
|
|
15603
|
-
const declaration = statement.type ===
|
|
15604
|
-
if (declaration?.type ===
|
|
15868
|
+
const declaration = statement.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15869
|
+
if (declaration?.type === import_utils84.AST_NODE_TYPES.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === import_utils84.AST_NODE_TYPES.TSFunctionType || declaration.typeAnnotation.type === import_utils84.AST_NODE_TYPES.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
15605
15870
|
}
|
|
15606
15871
|
for (const statement of program.body) {
|
|
15607
|
-
const declaration = statement.type ===
|
|
15608
|
-
if (declaration?.type ===
|
|
15872
|
+
const declaration = statement.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15873
|
+
if (declaration?.type === import_utils84.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
15609
15874
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
15610
|
-
const parts = declaration.typeAnnotation.type ===
|
|
15875
|
+
const parts = declaration.typeAnnotation.type === import_utils84.AST_NODE_TYPES.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
15611
15876
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
15612
15877
|
for (const part of parts) {
|
|
15613
|
-
if (part.type ===
|
|
15878
|
+
if (part.type === import_utils84.AST_NODE_TYPES.TSTypeReference && part.typeName.type === import_utils84.AST_NODE_TYPES.Identifier) {
|
|
15614
15879
|
inherited.push(part.typeName.name);
|
|
15615
15880
|
continue;
|
|
15616
15881
|
}
|
|
15617
|
-
if (part.type !==
|
|
15882
|
+
if (part.type !== import_utils84.AST_NODE_TYPES.TSTypeLiteral) continue;
|
|
15618
15883
|
for (const member of part.members) {
|
|
15619
|
-
if (member.type !==
|
|
15620
|
-
if (member.computed || member.key.type !==
|
|
15621
|
-
if (member.type ===
|
|
15884
|
+
if (member.type !== import_utils84.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils84.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15885
|
+
if (member.computed || member.key.type !== import_utils84.AST_NODE_TYPES.Identifier) continue;
|
|
15886
|
+
if (member.type === import_utils84.AST_NODE_TYPES.TSMethodSignature) {
|
|
15622
15887
|
callables2.add(member.key.name);
|
|
15623
15888
|
continue;
|
|
15624
15889
|
}
|
|
15625
|
-
if (member.type !==
|
|
15890
|
+
if (member.type !== import_utils84.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15626
15891
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
15627
|
-
if (annotation?.type ===
|
|
15892
|
+
if (annotation?.type === import_utils84.AST_NODE_TYPES.TSFunctionType || annotation?.type === import_utils84.AST_NODE_TYPES.TSTypeReference && annotation.typeName.type === import_utils84.AST_NODE_TYPES.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(member.key.name);
|
|
15628
15893
|
}
|
|
15629
15894
|
}
|
|
15630
15895
|
interfaces.set(declaration.id.name, callables2);
|
|
15631
15896
|
parents.set(declaration.id.name, inherited);
|
|
15632
15897
|
continue;
|
|
15633
15898
|
}
|
|
15634
|
-
if (declaration?.type !==
|
|
15899
|
+
if (declaration?.type !== import_utils84.AST_NODE_TYPES.TSInterfaceDeclaration) continue;
|
|
15635
15900
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
15636
15901
|
for (const member of declaration.body.body) {
|
|
15637
|
-
if (member.type !==
|
|
15638
|
-
if (member.computed || member.key.type !==
|
|
15639
|
-
if (member.type ===
|
|
15902
|
+
if (member.type !== import_utils84.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils84.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15903
|
+
if (member.computed || member.key.type !== import_utils84.AST_NODE_TYPES.Identifier) continue;
|
|
15904
|
+
if (member.type === import_utils84.AST_NODE_TYPES.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === import_utils84.AST_NODE_TYPES.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === import_utils84.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils84.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(member.key.name);
|
|
15640
15905
|
}
|
|
15641
15906
|
interfaces.set(declaration.id.name, callables);
|
|
15642
15907
|
parents.set(
|
|
@@ -15644,7 +15909,7 @@ function localInterfaceSurfaces(program) {
|
|
|
15644
15909
|
[
|
|
15645
15910
|
...parents.get(declaration.id.name) ?? [],
|
|
15646
15911
|
...declaration.extends.flatMap(
|
|
15647
|
-
(heritage) => heritage.expression.type ===
|
|
15912
|
+
(heritage) => heritage.expression.type === import_utils84.AST_NODE_TYPES.Identifier ? [heritage.expression.name] : ["*"]
|
|
15648
15913
|
)
|
|
15649
15914
|
]
|
|
15650
15915
|
);
|
|
@@ -15671,7 +15936,7 @@ function localInterfaceSurfaces(program) {
|
|
|
15671
15936
|
}
|
|
15672
15937
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
15673
15938
|
if (node.superClass !== null) {
|
|
15674
|
-
if (node.superClass.type !==
|
|
15939
|
+
if (node.superClass.type !== import_utils84.AST_NODE_TYPES.Identifier) return true;
|
|
15675
15940
|
const localAbstract = classes.get(node.superClass.name);
|
|
15676
15941
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
15677
15942
|
}
|
|
@@ -15683,7 +15948,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
15683
15948
|
if (node.implements.length === 0) return false;
|
|
15684
15949
|
const combined = /* @__PURE__ */ new Set();
|
|
15685
15950
|
for (const implementation of node.implements) {
|
|
15686
|
-
if (implementation.expression.type !==
|
|
15951
|
+
if (implementation.expression.type !== import_utils84.AST_NODE_TYPES.Identifier) return true;
|
|
15687
15952
|
const name = implementation.expression.name;
|
|
15688
15953
|
const localAbstract = classes.get(name);
|
|
15689
15954
|
if (localAbstract === true) return true;
|
|
@@ -15726,7 +15991,7 @@ var require_port_for_service_default = createRule({
|
|
|
15726
15991
|
if (node.abstract === true) return;
|
|
15727
15992
|
if (node.decorators.length > 0) return;
|
|
15728
15993
|
const ctor = node.body.body.find(
|
|
15729
|
-
(member) => member.type ===
|
|
15994
|
+
(member) => member.type === import_utils84.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
15730
15995
|
);
|
|
15731
15996
|
if (ctor === void 0) return;
|
|
15732
15997
|
const constructorFacts = readConstructor(
|
|
@@ -15761,32 +16026,67 @@ var require_port_for_service_default = createRule({
|
|
|
15761
16026
|
});
|
|
15762
16027
|
|
|
15763
16028
|
// src/rules/require-sql-access-class.ts
|
|
15764
|
-
var
|
|
15765
|
-
var
|
|
16029
|
+
var import_utils85 = require("@typescript-eslint/utils");
|
|
16030
|
+
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
15766
16031
|
"all",
|
|
15767
16032
|
"batch",
|
|
15768
|
-
"delete",
|
|
15769
16033
|
"dump",
|
|
15770
16034
|
"exec",
|
|
15771
16035
|
"execute",
|
|
15772
16036
|
"get",
|
|
15773
|
-
"insert",
|
|
15774
16037
|
"pragma",
|
|
15775
16038
|
"prepare",
|
|
16039
|
+
"query",
|
|
15776
16040
|
"run",
|
|
16041
|
+
"transaction"
|
|
16042
|
+
]);
|
|
16043
|
+
var BUILDER_TERMINAL_METHODS = /* @__PURE__ */ new Set([
|
|
16044
|
+
"execute",
|
|
16045
|
+
"executeQuery",
|
|
16046
|
+
"executeTakeFirst",
|
|
16047
|
+
"executeTakeFirstOrThrow",
|
|
16048
|
+
"stream"
|
|
16049
|
+
]);
|
|
16050
|
+
var BUILDER_METHODS = /* @__PURE__ */ new Set([
|
|
16051
|
+
"delete",
|
|
16052
|
+
"insert",
|
|
15777
16053
|
"select",
|
|
15778
|
-
"transaction",
|
|
15779
16054
|
"update"
|
|
15780
16055
|
]);
|
|
15781
|
-
var
|
|
16056
|
+
var BUILDER_SHORT_TERMINALS = /* @__PURE__ */ new Set([
|
|
16057
|
+
"all",
|
|
16058
|
+
"get",
|
|
16059
|
+
"run"
|
|
16060
|
+
]);
|
|
16061
|
+
var MODEL_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
16062
|
+
"aggregate",
|
|
16063
|
+
"count",
|
|
16064
|
+
"create",
|
|
16065
|
+
"createMany",
|
|
16066
|
+
"createManyAndReturn",
|
|
16067
|
+
"delete",
|
|
16068
|
+
"deleteMany",
|
|
16069
|
+
"findFirst",
|
|
16070
|
+
"findFirstOrThrow",
|
|
16071
|
+
"findMany",
|
|
16072
|
+
"findUnique",
|
|
16073
|
+
"findUniqueOrThrow",
|
|
16074
|
+
"groupBy",
|
|
16075
|
+
"update",
|
|
16076
|
+
"updateMany",
|
|
16077
|
+
"updateManyAndReturn",
|
|
16078
|
+
"upsert"
|
|
16079
|
+
]);
|
|
16080
|
+
var DATABASE_NAMES = /^(?:db|database|connection|pool|prisma|query|transaction|tx)$/iu;
|
|
15782
16081
|
var REQUIRE_SQL_ACCESS_CLASS_DOCUMENTATION = {
|
|
15783
16082
|
summary: "Keep SQL reads and writes inside a class that receives its database dependency.",
|
|
15784
16083
|
rationale: "Free-function database access hides connection ownership and makes transaction, retry, observability, and test boundaries inconsistent.",
|
|
15785
16084
|
remediation: "Move the query into a repository or store class and inject the pool, connection, transaction, or typed database binding through its constructor.",
|
|
15786
16085
|
category: "architecture",
|
|
15787
16086
|
limitations: [
|
|
15788
|
-
"The rule recognizes conventional database receiver names
|
|
15789
|
-
"Query construction without execution is not reported."
|
|
16087
|
+
"The rule recognizes conventional database receiver names, Cloudflare DB bindings, direct pool.query calls, explicit query-builder terminals, and Prisma-style model delegates; unusually named or heavily aliased clients require architectural review.",
|
|
16088
|
+
"Query construction without a recognized execution terminal is intentionally not reported.",
|
|
16089
|
+
"Constructor injection inherited from a base class or transformed through a wrapper is not inferred by this syntax-only rule."
|
|
15790
16090
|
],
|
|
15791
16091
|
examples: [
|
|
15792
16092
|
{
|
|
@@ -15819,28 +16119,160 @@ var REQUIRE_SQL_ACCESS_CLASS_DOCUMENTATION = {
|
|
|
15819
16119
|
}
|
|
15820
16120
|
]
|
|
15821
16121
|
};
|
|
15822
|
-
function
|
|
15823
|
-
if (!node.computed && node.property.type ===
|
|
16122
|
+
function memberName5(node) {
|
|
16123
|
+
if (!node.computed && node.property.type === import_utils85.AST_NODE_TYPES.Identifier)
|
|
15824
16124
|
return node.property.name;
|
|
15825
|
-
if (node.computed && node.property.type ===
|
|
16125
|
+
if (node.computed && node.property.type === import_utils85.AST_NODE_TYPES.Literal && typeof node.property.value === "string")
|
|
15826
16126
|
return node.property.value;
|
|
15827
16127
|
return null;
|
|
15828
16128
|
}
|
|
16129
|
+
function isDatabaseOperation(method, receiver) {
|
|
16130
|
+
if (DIRECT_EXECUTION_METHODS.has(method) && databaseReceiver(receiver))
|
|
16131
|
+
return true;
|
|
16132
|
+
if (!expressionHasDatabaseMarker(receiver)) return false;
|
|
16133
|
+
if (BUILDER_TERMINAL_METHODS.has(method) || MODEL_EXECUTION_METHODS.has(method)) return true;
|
|
16134
|
+
return BUILDER_SHORT_TERMINALS.has(method) && expressionCallsBuilder(receiver);
|
|
16135
|
+
}
|
|
15829
16136
|
function databaseReceiver(node) {
|
|
15830
|
-
if (node.type ===
|
|
16137
|
+
if (node.type === import_utils85.AST_NODE_TYPES.Identifier)
|
|
15831
16138
|
return DATABASE_NAMES.test(node.name);
|
|
15832
|
-
if (node.type !==
|
|
15833
|
-
const name =
|
|
16139
|
+
if (node.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return false;
|
|
16140
|
+
const name = memberName5(node);
|
|
15834
16141
|
return name === "DB" || name !== null && DATABASE_NAMES.test(name);
|
|
15835
16142
|
}
|
|
15836
|
-
function
|
|
16143
|
+
function databaseRootMember(node) {
|
|
16144
|
+
let current = node;
|
|
16145
|
+
for (; ; ) {
|
|
16146
|
+
if (current.type === import_utils85.AST_NODE_TYPES.ChainExpression) {
|
|
16147
|
+
current = current.expression;
|
|
16148
|
+
continue;
|
|
16149
|
+
}
|
|
16150
|
+
if (current.type === import_utils85.AST_NODE_TYPES.TSAsExpression || current.type === import_utils85.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils85.AST_NODE_TYPES.TSTypeAssertion) {
|
|
16151
|
+
current = current.expression;
|
|
16152
|
+
continue;
|
|
16153
|
+
}
|
|
16154
|
+
if (current.type === import_utils85.AST_NODE_TYPES.CallExpression) {
|
|
16155
|
+
if (current.callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return null;
|
|
16156
|
+
current = current.callee.object;
|
|
16157
|
+
continue;
|
|
16158
|
+
}
|
|
16159
|
+
if (current.type === import_utils85.AST_NODE_TYPES.MemberExpression) {
|
|
16160
|
+
if (current.object.type === import_utils85.AST_NODE_TYPES.ThisExpression)
|
|
16161
|
+
return memberName5(current);
|
|
16162
|
+
current = current.object;
|
|
16163
|
+
continue;
|
|
16164
|
+
}
|
|
16165
|
+
return current.type === import_utils85.AST_NODE_TYPES.Identifier ? current.name : null;
|
|
16166
|
+
}
|
|
16167
|
+
}
|
|
16168
|
+
function expressionHasDatabaseMarker(node) {
|
|
16169
|
+
let current = node;
|
|
16170
|
+
for (; ; ) {
|
|
16171
|
+
if (current.type === import_utils85.AST_NODE_TYPES.ChainExpression) {
|
|
16172
|
+
current = current.expression;
|
|
16173
|
+
continue;
|
|
16174
|
+
}
|
|
16175
|
+
if (current.type === import_utils85.AST_NODE_TYPES.TSAsExpression || current.type === import_utils85.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils85.AST_NODE_TYPES.TSTypeAssertion) {
|
|
16176
|
+
current = current.expression;
|
|
16177
|
+
continue;
|
|
16178
|
+
}
|
|
16179
|
+
if (current.type === import_utils85.AST_NODE_TYPES.CallExpression) {
|
|
16180
|
+
if (current.callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return false;
|
|
16181
|
+
current = current.callee.object;
|
|
16182
|
+
continue;
|
|
16183
|
+
}
|
|
16184
|
+
if (current.type === import_utils85.AST_NODE_TYPES.MemberExpression) {
|
|
16185
|
+
const name = memberName5(current);
|
|
16186
|
+
if (name === "DB" || name !== null && DATABASE_NAMES.test(name))
|
|
16187
|
+
return true;
|
|
16188
|
+
current = current.object;
|
|
16189
|
+
continue;
|
|
16190
|
+
}
|
|
16191
|
+
return current.type === import_utils85.AST_NODE_TYPES.Identifier && DATABASE_NAMES.test(current.name);
|
|
16192
|
+
}
|
|
16193
|
+
}
|
|
16194
|
+
function expressionCallsBuilder(node) {
|
|
16195
|
+
let current = node;
|
|
16196
|
+
for (; ; ) {
|
|
16197
|
+
if (current.type === import_utils85.AST_NODE_TYPES.ChainExpression) {
|
|
16198
|
+
current = current.expression;
|
|
16199
|
+
continue;
|
|
16200
|
+
}
|
|
16201
|
+
if (current.type === import_utils85.AST_NODE_TYPES.TSAsExpression || current.type === import_utils85.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils85.AST_NODE_TYPES.TSTypeAssertion) {
|
|
16202
|
+
current = current.expression;
|
|
16203
|
+
continue;
|
|
16204
|
+
}
|
|
16205
|
+
if (current.type === import_utils85.AST_NODE_TYPES.CallExpression) {
|
|
16206
|
+
if (current.callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return false;
|
|
16207
|
+
const name = memberName5(current.callee);
|
|
16208
|
+
if (name !== null && BUILDER_METHODS.has(name)) return true;
|
|
16209
|
+
current = current.callee.object;
|
|
16210
|
+
continue;
|
|
16211
|
+
}
|
|
16212
|
+
if (current.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return false;
|
|
16213
|
+
current = current.object;
|
|
16214
|
+
}
|
|
16215
|
+
}
|
|
16216
|
+
function owningClass2(node) {
|
|
15837
16217
|
let current = node.parent;
|
|
15838
16218
|
while (current != null) {
|
|
15839
|
-
if (current.type ===
|
|
15840
|
-
return
|
|
16219
|
+
if (current.type === import_utils85.AST_NODE_TYPES.ClassDeclaration || current.type === import_utils85.AST_NODE_TYPES.ClassExpression)
|
|
16220
|
+
return current;
|
|
15841
16221
|
current = current.parent;
|
|
15842
16222
|
}
|
|
15843
|
-
return
|
|
16223
|
+
return null;
|
|
16224
|
+
}
|
|
16225
|
+
function injectedMembers(owner) {
|
|
16226
|
+
const injected = /* @__PURE__ */ new Set();
|
|
16227
|
+
const constructor = owner.body.body.find(
|
|
16228
|
+
(member) => member.type === import_utils85.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
16229
|
+
);
|
|
16230
|
+
if (constructor === void 0) return injected;
|
|
16231
|
+
const parameters = /* @__PURE__ */ new Set();
|
|
16232
|
+
for (const parameter of constructor.value.params) {
|
|
16233
|
+
for (const name of parameterNames(parameter)) parameters.add(name);
|
|
16234
|
+
if (parameter.type !== import_utils85.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
16235
|
+
const value = parameter.parameter.type === import_utils85.AST_NODE_TYPES.AssignmentPattern ? parameter.parameter.left : parameter.parameter;
|
|
16236
|
+
if (value.type === import_utils85.AST_NODE_TYPES.Identifier) injected.add(value.name);
|
|
16237
|
+
}
|
|
16238
|
+
const body2 = constructor.value.body;
|
|
16239
|
+
if (body2 === null) return injected;
|
|
16240
|
+
for (const statement of body2.body) {
|
|
16241
|
+
if (statement.type !== import_utils85.AST_NODE_TYPES.ExpressionStatement || statement.expression.type !== import_utils85.AST_NODE_TYPES.AssignmentExpression || statement.expression.operator !== "=") continue;
|
|
16242
|
+
const { left, right } = statement.expression;
|
|
16243
|
+
if (left.type !== import_utils85.AST_NODE_TYPES.MemberExpression) continue;
|
|
16244
|
+
const target = thisRootMember(left);
|
|
16245
|
+
if (target === null) continue;
|
|
16246
|
+
const source = right.type === import_utils85.AST_NODE_TYPES.Identifier ? right.name : right.type === import_utils85.AST_NODE_TYPES.MemberExpression && right.object.type === import_utils85.AST_NODE_TYPES.Identifier ? right.object.name : null;
|
|
16247
|
+
if (source !== null && parameters.has(source)) injected.add(target);
|
|
16248
|
+
}
|
|
16249
|
+
return injected;
|
|
16250
|
+
}
|
|
16251
|
+
function thisRootMember(node) {
|
|
16252
|
+
let current = node;
|
|
16253
|
+
let root = null;
|
|
16254
|
+
while (current.type === import_utils85.AST_NODE_TYPES.MemberExpression) {
|
|
16255
|
+
const name = memberName5(current);
|
|
16256
|
+
if (name === null) return null;
|
|
16257
|
+
root = name;
|
|
16258
|
+
current = current.object;
|
|
16259
|
+
}
|
|
16260
|
+
return current.type === import_utils85.AST_NODE_TYPES.ThisExpression ? root : null;
|
|
16261
|
+
}
|
|
16262
|
+
function parameterNames(parameter) {
|
|
16263
|
+
let value = parameter;
|
|
16264
|
+
if (value.type === import_utils85.AST_NODE_TYPES.TSParameterProperty) value = value.parameter;
|
|
16265
|
+
if (value.type === import_utils85.AST_NODE_TYPES.AssignmentPattern) value = value.left;
|
|
16266
|
+
if (value.type === import_utils85.AST_NODE_TYPES.Identifier) return /* @__PURE__ */ new Set([value.name]);
|
|
16267
|
+
if (value.type !== import_utils85.AST_NODE_TYPES.ObjectPattern) return /* @__PURE__ */ new Set();
|
|
16268
|
+
return new Set(
|
|
16269
|
+
value.properties.flatMap((property) => {
|
|
16270
|
+
if (property.type === import_utils85.AST_NODE_TYPES.RestElement)
|
|
16271
|
+
return property.argument.type === import_utils85.AST_NODE_TYPES.Identifier ? [property.argument.name] : [];
|
|
16272
|
+
const target = property.value.type === import_utils85.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
16273
|
+
return target.type === import_utils85.AST_NODE_TYPES.Identifier ? [target.name] : [];
|
|
16274
|
+
})
|
|
16275
|
+
);
|
|
15844
16276
|
}
|
|
15845
16277
|
var require_sql_access_class_default = createRule({
|
|
15846
16278
|
name: "require-sql-access-class",
|
|
@@ -15861,11 +16293,16 @@ var require_sql_access_class_default = createRule({
|
|
|
15861
16293
|
return {};
|
|
15862
16294
|
return {
|
|
15863
16295
|
CallExpression(node) {
|
|
15864
|
-
if (
|
|
16296
|
+
if (node.callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression)
|
|
15865
16297
|
return;
|
|
15866
|
-
const method =
|
|
15867
|
-
if (method === null || !
|
|
16298
|
+
const method = memberName5(node.callee);
|
|
16299
|
+
if (method === null || !isDatabaseOperation(method, node.callee.object))
|
|
15868
16300
|
return;
|
|
16301
|
+
const owner = owningClass2(node);
|
|
16302
|
+
if (owner !== null) {
|
|
16303
|
+
const root = databaseRootMember(node.callee.object);
|
|
16304
|
+
if (root !== null && injectedMembers(owner).has(root)) return;
|
|
16305
|
+
}
|
|
15869
16306
|
context.report({ node, messageId: "moveSqlIntoClass" });
|
|
15870
16307
|
}
|
|
15871
16308
|
};
|
|
@@ -15873,7 +16310,7 @@ var require_sql_access_class_default = createRule({
|
|
|
15873
16310
|
});
|
|
15874
16311
|
|
|
15875
16312
|
// src/rules/require-static-next-matcher.ts
|
|
15876
|
-
var
|
|
16313
|
+
var import_utils86 = require("@typescript-eslint/utils");
|
|
15877
16314
|
var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
15878
16315
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
15879
16316
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -15886,34 +16323,34 @@ var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
|
15886
16323
|
};
|
|
15887
16324
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
15888
16325
|
function unwrapExpression3(node) {
|
|
15889
|
-
if (node.type ===
|
|
16326
|
+
if (node.type === import_utils86.AST_NODE_TYPES.TSAsExpression || node.type === import_utils86.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils86.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils86.AST_NODE_TYPES.TSTypeAssertion) {
|
|
15890
16327
|
return unwrapExpression3(node.expression);
|
|
15891
16328
|
}
|
|
15892
16329
|
return node;
|
|
15893
16330
|
}
|
|
15894
16331
|
function isStaticValue(node) {
|
|
15895
16332
|
const value = unwrapExpression3(node);
|
|
15896
|
-
if (value.type ===
|
|
16333
|
+
if (value.type === import_utils86.AST_NODE_TYPES.Literal) {
|
|
15897
16334
|
return true;
|
|
15898
16335
|
}
|
|
15899
|
-
if (value.type ===
|
|
16336
|
+
if (value.type === import_utils86.AST_NODE_TYPES.TemplateLiteral) {
|
|
15900
16337
|
return value.expressions.length === 0;
|
|
15901
16338
|
}
|
|
15902
|
-
if (value.type ===
|
|
16339
|
+
if (value.type === import_utils86.AST_NODE_TYPES.ArrayExpression) {
|
|
15903
16340
|
return value.elements.every(
|
|
15904
|
-
(element) => element !== null && element.type !==
|
|
16341
|
+
(element) => element !== null && element.type !== import_utils86.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
15905
16342
|
);
|
|
15906
16343
|
}
|
|
15907
|
-
if (value.type ===
|
|
16344
|
+
if (value.type === import_utils86.AST_NODE_TYPES.ObjectExpression) {
|
|
15908
16345
|
return value.properties.every(
|
|
15909
|
-
(property) => property.type ===
|
|
16346
|
+
(property) => property.type === import_utils86.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils86.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
15910
16347
|
);
|
|
15911
16348
|
}
|
|
15912
16349
|
return false;
|
|
15913
16350
|
}
|
|
15914
|
-
function
|
|
16351
|
+
function propertyName6(property) {
|
|
15915
16352
|
if (property.computed) return null;
|
|
15916
|
-
if (property.key.type ===
|
|
16353
|
+
if (property.key.type === import_utils86.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
15917
16354
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
15918
16355
|
}
|
|
15919
16356
|
var require_static_next_matcher_default = createRule({
|
|
@@ -15936,19 +16373,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
15936
16373
|
}
|
|
15937
16374
|
return {
|
|
15938
16375
|
ExportNamedDeclaration(node) {
|
|
15939
|
-
if (node.declaration?.type !==
|
|
16376
|
+
if (node.declaration?.type !== import_utils86.AST_NODE_TYPES.VariableDeclaration) {
|
|
15940
16377
|
return;
|
|
15941
16378
|
}
|
|
15942
16379
|
for (const declaration of node.declaration.declarations) {
|
|
15943
|
-
if (declaration.id.type !==
|
|
16380
|
+
if (declaration.id.type !== import_utils86.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
15944
16381
|
continue;
|
|
15945
16382
|
}
|
|
15946
16383
|
const config = unwrapExpression3(declaration.init);
|
|
15947
|
-
if (config.type !==
|
|
16384
|
+
if (config.type !== import_utils86.AST_NODE_TYPES.ObjectExpression) {
|
|
15948
16385
|
continue;
|
|
15949
16386
|
}
|
|
15950
16387
|
for (const property of config.properties) {
|
|
15951
|
-
if (property.type !==
|
|
16388
|
+
if (property.type !== import_utils86.AST_NODE_TYPES.Property || propertyName6(property) !== "matcher" || property.value.type === import_utils86.AST_NODE_TYPES.AssignmentPattern) {
|
|
15952
16389
|
continue;
|
|
15953
16390
|
}
|
|
15954
16391
|
if (!isStaticValue(property.value)) {
|
|
@@ -15962,7 +16399,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
15962
16399
|
});
|
|
15963
16400
|
|
|
15964
16401
|
// src/rules/require-use-form-default-values.ts
|
|
15965
|
-
var
|
|
16402
|
+
var import_utils87 = require("@typescript-eslint/utils");
|
|
15966
16403
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
15967
16404
|
summary: "react-hook-form useForm call without defaultValues",
|
|
15968
16405
|
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.",
|
|
@@ -16016,13 +16453,13 @@ var require_use_form_default_values_default = createRule({
|
|
|
16016
16453
|
if (node.source.value !== "react-hook-form") return;
|
|
16017
16454
|
for (const specifier of node.specifiers) {
|
|
16018
16455
|
if (specifier.type !== "ImportSpecifier" || (specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value) !== "useForm") continue;
|
|
16019
|
-
const variable =
|
|
16456
|
+
const variable = import_utils87.ASTUtils.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
16020
16457
|
if (variable) importedHooks.add(variable);
|
|
16021
16458
|
}
|
|
16022
16459
|
},
|
|
16023
16460
|
CallExpression(node) {
|
|
16024
16461
|
if (node.callee.type !== "Identifier") return;
|
|
16025
|
-
const variable =
|
|
16462
|
+
const variable = import_utils87.ASTUtils.findVariable(context.sourceCode.getScope(node.callee), node.callee.name);
|
|
16026
16463
|
const options = node.arguments[0];
|
|
16027
16464
|
if (!variable || !importedHooks.has(variable) || options !== void 0 && options.type !== "ObjectExpression" || hasDefaultValues(options)) return;
|
|
16028
16465
|
context.report({ node, messageId: "requireUseFormDefaultValues" });
|
|
@@ -16032,7 +16469,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
16032
16469
|
});
|
|
16033
16470
|
|
|
16034
16471
|
// src/rules/require-use-server-in-actions-file.ts
|
|
16035
|
-
var
|
|
16472
|
+
var import_utils88 = require("@typescript-eslint/utils");
|
|
16036
16473
|
var ACTION_MODULE_RE = /(?:^|\/)app\/.*\/(?:actions|[^/]+-actions)\.[cm]?[jt]s$/u;
|
|
16037
16474
|
var REQUIRE_USE_SERVER_IN_ACTIONS_FILE_DOCUMENTATION = {
|
|
16038
16475
|
summary: "route action module missing the use server directive",
|
|
@@ -16098,7 +16535,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
16098
16535
|
});
|
|
16099
16536
|
|
|
16100
16537
|
// src/rules/require-zod-form-validation.ts
|
|
16101
|
-
var
|
|
16538
|
+
var import_utils89 = require("@typescript-eslint/utils");
|
|
16102
16539
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
16103
16540
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
16104
16541
|
rationale: "FormData values are untrusted strings or files and need runtime validation before use.",
|
|
@@ -16123,14 +16560,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
16123
16560
|
var zodReceiverRoot = (node) => {
|
|
16124
16561
|
let current = node;
|
|
16125
16562
|
while (true) {
|
|
16126
|
-
if (current.type ===
|
|
16563
|
+
if (current.type === import_utils89.AST_NODE_TYPES.Identifier) {
|
|
16127
16564
|
return current;
|
|
16128
16565
|
}
|
|
16129
|
-
if (current.type ===
|
|
16566
|
+
if (current.type === import_utils89.AST_NODE_TYPES.CallExpression) {
|
|
16130
16567
|
current = current.callee;
|
|
16131
16568
|
continue;
|
|
16132
16569
|
}
|
|
16133
|
-
if (current.type ===
|
|
16570
|
+
if (current.type === import_utils89.AST_NODE_TYPES.MemberExpression) {
|
|
16134
16571
|
current = current.object;
|
|
16135
16572
|
continue;
|
|
16136
16573
|
}
|
|
@@ -16139,12 +16576,12 @@ var zodReceiverRoot = (node) => {
|
|
|
16139
16576
|
};
|
|
16140
16577
|
var isFormDataMethodCall = (node) => {
|
|
16141
16578
|
let current = node;
|
|
16142
|
-
if (current.type ===
|
|
16579
|
+
if (current.type === import_utils89.AST_NODE_TYPES.AwaitExpression) {
|
|
16143
16580
|
current = current.argument;
|
|
16144
16581
|
}
|
|
16145
|
-
if (current.type !==
|
|
16582
|
+
if (current.type !== import_utils89.AST_NODE_TYPES.CallExpression) return false;
|
|
16146
16583
|
const callee = current.callee;
|
|
16147
|
-
return callee.type ===
|
|
16584
|
+
return callee.type === import_utils89.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils89.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
16148
16585
|
};
|
|
16149
16586
|
var require_zod_form_validation_default = createRule({
|
|
16150
16587
|
name: "require-zod-form-validation",
|
|
@@ -16165,7 +16602,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16165
16602
|
return {};
|
|
16166
16603
|
}
|
|
16167
16604
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
16168
|
-
const resolvedBinding = (identifier) =>
|
|
16605
|
+
const resolvedBinding = (identifier) => import_utils89.ASTUtils.findVariable(
|
|
16169
16606
|
context.sourceCode.getScope(identifier),
|
|
16170
16607
|
identifier.name
|
|
16171
16608
|
);
|
|
@@ -16175,16 +16612,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
16175
16612
|
return false;
|
|
16176
16613
|
}
|
|
16177
16614
|
const definition = binding.defs[0];
|
|
16178
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
16615
|
+
if (definition?.type !== "Variable" || definition.node.type !== import_utils89.AST_NODE_TYPES.VariableDeclarator) {
|
|
16179
16616
|
return false;
|
|
16180
16617
|
}
|
|
16181
16618
|
const init = definition.node.init;
|
|
16182
|
-
return init?.type ===
|
|
16619
|
+
return init?.type === import_utils89.AST_NODE_TYPES.ObjectExpression || init?.type === import_utils89.AST_NODE_TYPES.ArrayExpression || init?.type === import_utils89.AST_NODE_TYPES.Literal || init?.type === import_utils89.AST_NODE_TYPES.ArrowFunctionExpression || init?.type === import_utils89.AST_NODE_TYPES.FunctionExpression;
|
|
16183
16620
|
};
|
|
16184
16621
|
const isZodParseCall = (node) => {
|
|
16185
|
-
if (node.type !==
|
|
16622
|
+
if (node.type !== import_utils89.AST_NODE_TYPES.CallExpression) return false;
|
|
16186
16623
|
const callee = node.callee;
|
|
16187
|
-
if (callee.type !==
|
|
16624
|
+
if (callee.type !== import_utils89.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils89.AST_NODE_TYPES.Identifier || !ZOD_PARSE_METHODS.has(callee.property.name)) {
|
|
16188
16625
|
return false;
|
|
16189
16626
|
}
|
|
16190
16627
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -16193,14 +16630,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
16193
16630
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
16194
16631
|
};
|
|
16195
16632
|
const isFormSourceIdentifier = (node) => {
|
|
16196
|
-
if (node.type !==
|
|
16633
|
+
if (node.type !== import_utils89.AST_NODE_TYPES.Identifier) return false;
|
|
16197
16634
|
const conventionalName = /formdata/i.test(node.name);
|
|
16198
16635
|
let scope = context.sourceCode.getScope(node);
|
|
16199
16636
|
while (scope !== null) {
|
|
16200
16637
|
const variable = scope.set.get(node.name);
|
|
16201
16638
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
16202
16639
|
const def = variable.defs[0];
|
|
16203
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
16640
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils89.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
16204
16641
|
return isFormDataMethodCall(def.node.init);
|
|
16205
16642
|
}
|
|
16206
16643
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -16211,8 +16648,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
16211
16648
|
};
|
|
16212
16649
|
const isFormDataGetCall = (node) => {
|
|
16213
16650
|
const callee = node.callee;
|
|
16214
|
-
if (callee.type !==
|
|
16215
|
-
if (callee.property.type !==
|
|
16651
|
+
if (callee.type !== import_utils89.AST_NODE_TYPES.MemberExpression) return false;
|
|
16652
|
+
if (callee.property.type !== import_utils89.AST_NODE_TYPES.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
16216
16653
|
return false;
|
|
16217
16654
|
}
|
|
16218
16655
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -16228,16 +16665,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
16228
16665
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
16229
16666
|
const isInstanceofNarrowing = (node) => {
|
|
16230
16667
|
const parent = node.parent;
|
|
16231
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
16668
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils89.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils89.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
16232
16669
|
};
|
|
16233
16670
|
const boundDeclarator = (node) => {
|
|
16234
16671
|
let current = node;
|
|
16235
16672
|
let parent = current.parent;
|
|
16236
|
-
while ((parent.type ===
|
|
16673
|
+
while ((parent.type === import_utils89.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils89.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils89.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils89.AST_NODE_TYPES.ChainExpression) && parent.expression === current) {
|
|
16237
16674
|
current = parent;
|
|
16238
16675
|
parent = current.parent;
|
|
16239
16676
|
}
|
|
16240
|
-
if (parent.type ===
|
|
16677
|
+
if (parent.type === import_utils89.AST_NODE_TYPES.VariableDeclarator && parent.init === current && parent.id.type === import_utils89.AST_NODE_TYPES.Identifier) {
|
|
16241
16678
|
return parent;
|
|
16242
16679
|
}
|
|
16243
16680
|
return null;
|
|
@@ -16246,7 +16683,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16246
16683
|
let current = node;
|
|
16247
16684
|
while (current.parent !== void 0) {
|
|
16248
16685
|
const parent = current.parent;
|
|
16249
|
-
if (parent.type ===
|
|
16686
|
+
if (parent.type === import_utils89.AST_NODE_TYPES.BlockStatement || parent.type === import_utils89.AST_NODE_TYPES.Program) {
|
|
16250
16687
|
return current;
|
|
16251
16688
|
}
|
|
16252
16689
|
current = parent;
|
|
@@ -16255,12 +16692,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
16255
16692
|
};
|
|
16256
16693
|
const zodParseMethod = (call) => {
|
|
16257
16694
|
const callee = call.callee;
|
|
16258
|
-
return callee.type ===
|
|
16695
|
+
return callee.type === import_utils89.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils89.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
16259
16696
|
};
|
|
16260
16697
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
16261
16698
|
let current = node.parent;
|
|
16262
16699
|
while (current !== void 0 && current !== statement) {
|
|
16263
|
-
if (current.type ===
|
|
16700
|
+
if (current.type === import_utils89.AST_NODE_TYPES.LogicalExpression || current.type === import_utils89.AST_NODE_TYPES.ConditionalExpression) {
|
|
16264
16701
|
return true;
|
|
16265
16702
|
}
|
|
16266
16703
|
current = current.parent;
|
|
@@ -16270,7 +16707,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16270
16707
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
16271
16708
|
let current = node.parent;
|
|
16272
16709
|
while (current !== void 0 && current !== statement) {
|
|
16273
|
-
if (current.type ===
|
|
16710
|
+
if (current.type === import_utils89.AST_NODE_TYPES.AwaitExpression) return true;
|
|
16274
16711
|
current = current.parent;
|
|
16275
16712
|
}
|
|
16276
16713
|
return false;
|
|
@@ -16283,7 +16720,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16283
16720
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
16284
16721
|
return null;
|
|
16285
16722
|
}
|
|
16286
|
-
if (validationStatement.type !==
|
|
16723
|
+
if (validationStatement.type !== import_utils89.AST_NODE_TYPES.VariableDeclaration && validationStatement.type !== import_utils89.AST_NODE_TYPES.ExpressionStatement) {
|
|
16287
16724
|
return null;
|
|
16288
16725
|
}
|
|
16289
16726
|
const method = zodParseMethod(parse2);
|
|
@@ -16295,16 +16732,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
16295
16732
|
};
|
|
16296
16733
|
const isSafePrevalidationInspection = (identifier) => {
|
|
16297
16734
|
const parent = identifier.parent;
|
|
16298
|
-
if (parent.type ===
|
|
16735
|
+
if (parent.type === import_utils89.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof") {
|
|
16299
16736
|
return true;
|
|
16300
16737
|
}
|
|
16301
|
-
if (parent.type !==
|
|
16738
|
+
if (parent.type !== import_utils89.AST_NODE_TYPES.BinaryExpression || parent.left !== identifier) {
|
|
16302
16739
|
return false;
|
|
16303
16740
|
}
|
|
16304
16741
|
if (parent.operator === "instanceof") {
|
|
16305
|
-
return parent.right.type ===
|
|
16742
|
+
return parent.right.type === import_utils89.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
16306
16743
|
}
|
|
16307
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
16744
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === import_utils89.AST_NODE_TYPES.Literal && parent.right.value === null || parent.right.type === import_utils89.AST_NODE_TYPES.Identifier && parent.right.name === "undefined");
|
|
16308
16745
|
};
|
|
16309
16746
|
const isDescendantOf = (node, ancestor) => {
|
|
16310
16747
|
let current = node;
|
|
@@ -16315,23 +16752,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
16315
16752
|
return false;
|
|
16316
16753
|
};
|
|
16317
16754
|
const blockTerminates = (node) => {
|
|
16318
|
-
if (node.type ===
|
|
16755
|
+
if (node.type === import_utils89.AST_NODE_TYPES.ReturnStatement || node.type === import_utils89.AST_NODE_TYPES.ThrowStatement) {
|
|
16319
16756
|
return true;
|
|
16320
16757
|
}
|
|
16321
|
-
if (node.type !==
|
|
16758
|
+
if (node.type !== import_utils89.AST_NODE_TYPES.BlockStatement || node.body.length === 0) return false;
|
|
16322
16759
|
const last = node.body.at(-1);
|
|
16323
16760
|
return last !== void 0 && blockTerminates(last);
|
|
16324
16761
|
};
|
|
16325
16762
|
const narrowingIf = (identifier) => {
|
|
16326
16763
|
const comparison = identifier.parent;
|
|
16327
|
-
if (comparison?.type !==
|
|
16764
|
+
if (comparison?.type !== import_utils89.AST_NODE_TYPES.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== import_utils89.AST_NODE_TYPES.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
16328
16765
|
return null;
|
|
16329
16766
|
}
|
|
16330
16767
|
const maybeNegation = comparison.parent;
|
|
16331
|
-
const negated = maybeNegation?.type ===
|
|
16768
|
+
const negated = maybeNegation?.type === import_utils89.AST_NODE_TYPES.UnaryExpression && maybeNegation.operator === "!";
|
|
16332
16769
|
const test = negated ? maybeNegation : comparison;
|
|
16333
16770
|
const branch = test.parent;
|
|
16334
|
-
return branch?.type ===
|
|
16771
|
+
return branch?.type === import_utils89.AST_NODE_TYPES.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
16335
16772
|
};
|
|
16336
16773
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
16337
16774
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -16351,7 +16788,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16351
16788
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
16352
16789
|
if (variable === void 0) return false;
|
|
16353
16790
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
16354
|
-
(identifier) => identifier.type ===
|
|
16791
|
+
(identifier) => identifier.type === import_utils89.AST_NODE_TYPES.Identifier
|
|
16355
16792
|
);
|
|
16356
16793
|
if (references.length === 0) return false;
|
|
16357
16794
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -16377,7 +16814,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16377
16814
|
ImportDeclaration(node) {
|
|
16378
16815
|
if (!isZodModule(node.source.value)) return;
|
|
16379
16816
|
for (const specifier of node.specifiers) {
|
|
16380
|
-
if (specifier.type ===
|
|
16817
|
+
if (specifier.type === import_utils89.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils89.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils89.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils89.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
16381
16818
|
const binding = resolvedBinding(specifier.local);
|
|
16382
16819
|
if (binding !== null) zodBindings.add(binding);
|
|
16383
16820
|
}
|
|
@@ -16398,7 +16835,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
16398
16835
|
});
|
|
16399
16836
|
|
|
16400
16837
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
16401
|
-
var
|
|
16838
|
+
var import_utils90 = require("@typescript-eslint/utils");
|
|
16402
16839
|
var STORE_INSERT_REQUIRES_ON_CONFLICT_DOCUMENTATION = {
|
|
16403
16840
|
summary: "Require embedded inserts in explicitly replayable callables to carry conflict handling.",
|
|
16404
16841
|
rationale: "A callable named as an enqueue, seed, migration, schedule, ensure, or upsert promises replay safety.",
|
|
@@ -16462,7 +16899,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
16462
16899
|
});
|
|
16463
16900
|
|
|
16464
16901
|
// src/rules/stepdown.ts
|
|
16465
|
-
var
|
|
16902
|
+
var import_utils91 = require("@typescript-eslint/utils");
|
|
16466
16903
|
var STEPDOWN_DOCUMENTATION = {
|
|
16467
16904
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
16468
16905
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -16482,7 +16919,7 @@ var STEPDOWN_DOCUMENTATION = {
|
|
|
16482
16919
|
]
|
|
16483
16920
|
};
|
|
16484
16921
|
function isFunction(node) {
|
|
16485
|
-
return node.type ===
|
|
16922
|
+
return node.type === import_utils91.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils91.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils91.AST_NODE_TYPES.FunctionExpression;
|
|
16486
16923
|
}
|
|
16487
16924
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true, makeFix) {
|
|
16488
16925
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -16579,8 +17016,8 @@ function moduleScope(context, program) {
|
|
|
16579
17016
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
16580
17017
|
const overloadNames = new Set(
|
|
16581
17018
|
program.body.flatMap((statement) => {
|
|
16582
|
-
const node = statement.type ===
|
|
16583
|
-
return node?.type ===
|
|
17019
|
+
const node = statement.type === import_utils91.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
17020
|
+
return node?.type === import_utils91.AST_NODE_TYPES.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
16584
17021
|
})
|
|
16585
17022
|
);
|
|
16586
17023
|
const exported = exportedNames(program);
|
|
@@ -16604,7 +17041,7 @@ function moduleScope(context, program) {
|
|
|
16604
17041
|
const nearestFunction2 = [...ancestors].reverse().find(isFunction);
|
|
16605
17042
|
const parent = identifier.parent;
|
|
16606
17043
|
const callerDefinition = nearestFunction2 === void 0 ? void 0 : byFunction.get(nearestFunction2);
|
|
16607
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
17044
|
+
if (callerDefinition === void 0 || parent.type !== import_utils91.AST_NODE_TYPES.CallExpression || parent.callee !== identifier) {
|
|
16608
17045
|
pinned.add(definition.name);
|
|
16609
17046
|
continue;
|
|
16610
17047
|
}
|
|
@@ -16619,38 +17056,38 @@ function moduleScope(context, program) {
|
|
|
16619
17056
|
function exportedNames(program) {
|
|
16620
17057
|
const names = /* @__PURE__ */ new Set();
|
|
16621
17058
|
for (const statement of program.body) {
|
|
16622
|
-
if (statement.type !==
|
|
16623
|
-
if (statement.declaration?.type ===
|
|
17059
|
+
if (statement.type !== import_utils91.AST_NODE_TYPES.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
17060
|
+
if (statement.declaration?.type === import_utils91.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) {
|
|
16624
17061
|
names.add(statement.declaration.id.name);
|
|
16625
17062
|
}
|
|
16626
|
-
if (statement.declaration?.type ===
|
|
17063
|
+
if (statement.declaration?.type === import_utils91.AST_NODE_TYPES.VariableDeclaration) {
|
|
16627
17064
|
for (const declarator of statement.declaration.declarations) {
|
|
16628
|
-
if (declarator.id.type ===
|
|
17065
|
+
if (declarator.id.type === import_utils91.AST_NODE_TYPES.Identifier) names.add(declarator.id.name);
|
|
16629
17066
|
}
|
|
16630
17067
|
}
|
|
16631
17068
|
for (const specifier of statement.specifiers) {
|
|
16632
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
17069
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils91.AST_NODE_TYPES.Identifier) {
|
|
16633
17070
|
names.add(specifier.local.name);
|
|
16634
17071
|
}
|
|
16635
17072
|
}
|
|
16636
17073
|
}
|
|
16637
17074
|
for (const statement of program.body) {
|
|
16638
|
-
if (statement.type ===
|
|
16639
|
-
if (statement.type ===
|
|
17075
|
+
if (statement.type === import_utils91.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils91.AST_NODE_TYPES.Identifier) names.add(statement.declaration.name);
|
|
17076
|
+
if (statement.type === import_utils91.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils91.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
16640
17077
|
}
|
|
16641
17078
|
return names;
|
|
16642
17079
|
}
|
|
16643
17080
|
function moduleDefinitions(program) {
|
|
16644
17081
|
const definitions = [];
|
|
16645
17082
|
for (const statement of program.body) {
|
|
16646
|
-
const node = statement.type ===
|
|
16647
|
-
if (node?.type ===
|
|
17083
|
+
const node = statement.type === import_utils91.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils91.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
17084
|
+
if (node?.type === import_utils91.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
16648
17085
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
16649
17086
|
continue;
|
|
16650
17087
|
}
|
|
16651
|
-
if (node?.type !==
|
|
17088
|
+
if (node?.type !== import_utils91.AST_NODE_TYPES.VariableDeclaration || node.kind !== "const") continue;
|
|
16652
17089
|
for (const declarator of node.declarations) {
|
|
16653
|
-
if (declarator.id.type ===
|
|
17090
|
+
if (declarator.id.type === import_utils91.AST_NODE_TYPES.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
16654
17091
|
definitions.push({
|
|
16655
17092
|
name: declarator.id.name,
|
|
16656
17093
|
node: declarator,
|
|
@@ -16663,21 +17100,21 @@ function moduleDefinitions(program) {
|
|
|
16663
17100
|
return definitions;
|
|
16664
17101
|
}
|
|
16665
17102
|
function methodName(node) {
|
|
16666
|
-
if (node.key.type ===
|
|
16667
|
-
return !node.computed && node.key.type ===
|
|
17103
|
+
if (node.key.type === import_utils91.AST_NODE_TYPES.PrivateIdentifier) return `#${node.key.name}`;
|
|
17104
|
+
return !node.computed && node.key.type === import_utils91.AST_NODE_TYPES.Identifier ? node.key.name : null;
|
|
16668
17105
|
}
|
|
16669
17106
|
function referencedMethod(context, node, classVariables) {
|
|
16670
|
-
const objectVariable = node.object.type ===
|
|
17107
|
+
const objectVariable = node.object.type === import_utils91.AST_NODE_TYPES.Identifier ? import_utils91.ASTUtils.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
16671
17108
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
16672
|
-
if (node.object.type !==
|
|
16673
|
-
if (node.property.type ===
|
|
16674
|
-
if (!node.computed && node.property.type ===
|
|
16675
|
-
return node.computed && node.property.type ===
|
|
17109
|
+
if (node.object.type !== import_utils91.AST_NODE_TYPES.ThisExpression && !isClassReference) return null;
|
|
17110
|
+
if (node.property.type === import_utils91.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
17111
|
+
if (!node.computed && node.property.type === import_utils91.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
17112
|
+
return node.computed && node.property.type === import_utils91.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
16676
17113
|
}
|
|
16677
17114
|
function referencedPropertyName(node) {
|
|
16678
|
-
if (node.property.type ===
|
|
16679
|
-
if (!node.computed && node.property.type ===
|
|
16680
|
-
return node.computed && node.property.type ===
|
|
17115
|
+
if (node.property.type === import_utils91.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
17116
|
+
if (!node.computed && node.property.type === import_utils91.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
17117
|
+
return node.computed && node.property.type === import_utils91.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
16681
17118
|
}
|
|
16682
17119
|
function walk2(node, visitorKeys, visit, nestedFunction = false) {
|
|
16683
17120
|
visit(node, nestedFunction);
|
|
@@ -16693,7 +17130,7 @@ function walk2(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
16693
17130
|
}
|
|
16694
17131
|
function classScope(context, node, computedReferenceNames) {
|
|
16695
17132
|
const methods = node.body.body.filter(
|
|
16696
|
-
(member) => member.type ===
|
|
17133
|
+
(member) => member.type === import_utils91.AST_NODE_TYPES.MethodDefinition
|
|
16697
17134
|
);
|
|
16698
17135
|
const counts = /* @__PURE__ */ new Map();
|
|
16699
17136
|
for (const method of methods) {
|
|
@@ -16701,8 +17138,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16701
17138
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
16702
17139
|
}
|
|
16703
17140
|
for (const member of node.body.body) {
|
|
16704
|
-
if (member.type !==
|
|
16705
|
-
const name = !member.computed && member.key.type ===
|
|
17141
|
+
if (member.type !== import_utils91.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
17142
|
+
const name = !member.computed && member.key.type === import_utils91.AST_NODE_TYPES.Identifier ? member.key.name : null;
|
|
16706
17143
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
16707
17144
|
}
|
|
16708
17145
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -16711,7 +17148,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16711
17148
|
});
|
|
16712
17149
|
const definitions = methods.flatMap((method) => {
|
|
16713
17150
|
const name = methodName(method);
|
|
16714
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
17151
|
+
const isPrivate = method.accessibility === "private" || method.key.type === import_utils91.AST_NODE_TYPES.PrivateIdentifier;
|
|
16715
17152
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
16716
17153
|
});
|
|
16717
17154
|
if (definitions.length === 0) return;
|
|
@@ -16720,11 +17157,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16720
17157
|
const pinned = /* @__PURE__ */ new Set();
|
|
16721
17158
|
const classVariables = /* @__PURE__ */ new Set();
|
|
16722
17159
|
if (node.id !== null) {
|
|
16723
|
-
const internal =
|
|
17160
|
+
const internal = import_utils91.ASTUtils.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
16724
17161
|
if (internal !== null) classVariables.add(internal);
|
|
16725
17162
|
}
|
|
16726
|
-
if (node.type ===
|
|
16727
|
-
const outer =
|
|
17163
|
+
if (node.type === import_utils91.AST_NODE_TYPES.ClassExpression && node.parent.type === import_utils91.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils91.AST_NODE_TYPES.Identifier) {
|
|
17164
|
+
const outer = import_utils91.ASTUtils.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
16728
17165
|
if (outer !== null) classVariables.add(outer);
|
|
16729
17166
|
}
|
|
16730
17167
|
for (const method of methods) {
|
|
@@ -16740,27 +17177,27 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16740
17177
|
}
|
|
16741
17178
|
const thisValue = (value) => {
|
|
16742
17179
|
let current = value;
|
|
16743
|
-
while (current?.type ===
|
|
16744
|
-
return current?.type ===
|
|
17180
|
+
while (current?.type === import_utils91.AST_NODE_TYPES.TSAsExpression || current?.type === import_utils91.AST_NODE_TYPES.TSSatisfiesExpression || current?.type === import_utils91.AST_NODE_TYPES.TSNonNullExpression) current = current.expression;
|
|
17181
|
+
return current?.type === import_utils91.AST_NODE_TYPES.ThisExpression;
|
|
16745
17182
|
};
|
|
16746
17183
|
const collectAlias = (current, nestedFunction) => {
|
|
16747
|
-
if (nestedFunction || current.type !==
|
|
16748
|
-
if (current.type ===
|
|
16749
|
-
const binding = current.type ===
|
|
16750
|
-
const value = current.type ===
|
|
17184
|
+
if (nestedFunction || current.type !== import_utils91.AST_NODE_TYPES.VariableDeclarator && current.type !== import_utils91.AST_NODE_TYPES.AssignmentPattern) return;
|
|
17185
|
+
if (current.type === import_utils91.AST_NODE_TYPES.VariableDeclarator && (current.parent.type !== import_utils91.AST_NODE_TYPES.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
17186
|
+
const binding = current.type === import_utils91.AST_NODE_TYPES.VariableDeclarator ? current.id : current.left;
|
|
17187
|
+
const value = current.type === import_utils91.AST_NODE_TYPES.VariableDeclarator ? current.init : current.right;
|
|
16751
17188
|
if (!thisValue(value)) return;
|
|
16752
|
-
if (binding.type ===
|
|
17189
|
+
if (binding.type === import_utils91.AST_NODE_TYPES.ObjectPattern) {
|
|
16753
17190
|
for (const property of binding.properties) {
|
|
16754
|
-
if (property.type ===
|
|
17191
|
+
if (property.type === import_utils91.AST_NODE_TYPES.RestElement) {
|
|
16755
17192
|
for (const name of privateNames) pinned.add(name);
|
|
16756
|
-
} else if (property.key.type ===
|
|
17193
|
+
} else if (property.key.type === import_utils91.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) {
|
|
16757
17194
|
pinned.add(property.key.name);
|
|
16758
17195
|
}
|
|
16759
17196
|
}
|
|
16760
17197
|
return;
|
|
16761
17198
|
}
|
|
16762
|
-
if (binding.type !==
|
|
16763
|
-
const variable =
|
|
17199
|
+
if (binding.type !== import_utils91.AST_NODE_TYPES.Identifier) return;
|
|
17200
|
+
const variable = import_utils91.ASTUtils.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
16764
17201
|
if (variable !== null) {
|
|
16765
17202
|
methodClassVariables.add(variable);
|
|
16766
17203
|
methodAliases.add(variable);
|
|
@@ -16773,16 +17210,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16773
17210
|
walk2(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
16774
17211
|
}
|
|
16775
17212
|
const visitCall = (current, nestedFunction) => {
|
|
16776
|
-
if (current.type ===
|
|
17213
|
+
if (current.type === import_utils91.AST_NODE_TYPES.VariableDeclarator && current.id.type === import_utils91.AST_NODE_TYPES.ObjectPattern && thisValue(current.init)) {
|
|
16777
17214
|
for (const property of current.id.properties) {
|
|
16778
|
-
if (property.type ===
|
|
17215
|
+
if (property.type === import_utils91.AST_NODE_TYPES.RestElement) {
|
|
16779
17216
|
for (const name of privateNames) pinned.add(name);
|
|
16780
17217
|
continue;
|
|
16781
17218
|
}
|
|
16782
|
-
if (property.type ===
|
|
17219
|
+
if (property.type === import_utils91.AST_NODE_TYPES.Property && property.key.type === import_utils91.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
16783
17220
|
}
|
|
16784
17221
|
}
|
|
16785
|
-
if (current.type !==
|
|
17222
|
+
if (current.type !== import_utils91.AST_NODE_TYPES.MemberExpression) return;
|
|
16786
17223
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
16787
17224
|
if (target === null) {
|
|
16788
17225
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -16790,12 +17227,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16790
17227
|
return;
|
|
16791
17228
|
}
|
|
16792
17229
|
if (!privateNames.has(target)) return;
|
|
16793
|
-
const objectVariable = current.object.type ===
|
|
17230
|
+
const objectVariable = current.object.type === import_utils91.AST_NODE_TYPES.Identifier ? import_utils91.ASTUtils.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
16794
17231
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
16795
17232
|
pinned.add(target);
|
|
16796
17233
|
return;
|
|
16797
17234
|
}
|
|
16798
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
17235
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== import_utils91.AST_NODE_TYPES.CallExpression || current.parent.callee !== current) {
|
|
16799
17236
|
pinned.add(target);
|
|
16800
17237
|
return;
|
|
16801
17238
|
}
|
|
@@ -16815,9 +17252,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16815
17252
|
}
|
|
16816
17253
|
}
|
|
16817
17254
|
for (const member of node.body.body) {
|
|
16818
|
-
if (member.type ===
|
|
17255
|
+
if (member.type === import_utils91.AST_NODE_TYPES.MethodDefinition || member.type === import_utils91.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
16819
17256
|
walk2(member, context.sourceCode.visitorKeys, (current) => {
|
|
16820
|
-
if (current.type !==
|
|
17257
|
+
if (current.type !== import_utils91.AST_NODE_TYPES.MemberExpression) return;
|
|
16821
17258
|
const target = referencedMethod(context, current, classVariables);
|
|
16822
17259
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
16823
17260
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -16869,12 +17306,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16869
17306
|
}
|
|
16870
17307
|
function isClassRuntimeBarrier(member) {
|
|
16871
17308
|
switch (member.type) {
|
|
16872
|
-
case
|
|
17309
|
+
case import_utils91.AST_NODE_TYPES.StaticBlock:
|
|
16873
17310
|
return true;
|
|
16874
|
-
case
|
|
16875
|
-
case
|
|
17311
|
+
case import_utils91.AST_NODE_TYPES.PropertyDefinition:
|
|
17312
|
+
case import_utils91.AST_NODE_TYPES.AccessorProperty:
|
|
16876
17313
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
16877
|
-
case
|
|
17314
|
+
case import_utils91.AST_NODE_TYPES.MethodDefinition:
|
|
16878
17315
|
return member.computed || member.decorators.length > 0;
|
|
16879
17316
|
default:
|
|
16880
17317
|
return false;
|
|
@@ -16907,7 +17344,7 @@ var stepdown_default = createRule({
|
|
|
16907
17344
|
moduleScope(context, program);
|
|
16908
17345
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
16909
17346
|
walk2(program, context.sourceCode.visitorKeys, (node) => {
|
|
16910
|
-
if (node.type ===
|
|
17347
|
+
if (node.type === import_utils91.AST_NODE_TYPES.MemberExpression && node.computed && node.property.type === import_utils91.AST_NODE_TYPES.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
16911
17348
|
});
|
|
16912
17349
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
16913
17350
|
}
|
|
@@ -16916,7 +17353,7 @@ var stepdown_default = createRule({
|
|
|
16916
17353
|
});
|
|
16917
17354
|
|
|
16918
17355
|
// src/rules/source-coupled-test.ts
|
|
16919
|
-
var
|
|
17356
|
+
var import_utils92 = require("@typescript-eslint/utils");
|
|
16920
17357
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|py|[cm]?[jt]s)$/iu;
|
|
16921
17358
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
16922
17359
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -16985,20 +17422,20 @@ var SOURCE_COUPLED_TEST_DOCUMENTATION = {
|
|
|
16985
17422
|
]
|
|
16986
17423
|
};
|
|
16987
17424
|
function staticMemberName7(node) {
|
|
16988
|
-
if (!node.computed && node.property.type ===
|
|
16989
|
-
if (node.computed && node.property.type ===
|
|
17425
|
+
if (!node.computed && node.property.type === import_utils92.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
17426
|
+
if (node.computed && node.property.type === import_utils92.AST_NODE_TYPES.Literal && typeof node.property.value === "string") return node.property.value;
|
|
16990
17427
|
return null;
|
|
16991
17428
|
}
|
|
16992
17429
|
function unwrap6(node) {
|
|
16993
|
-
if (node.type ===
|
|
16994
|
-
if (node.type ===
|
|
16995
|
-
if (node.type ===
|
|
17430
|
+
if (node.type === import_utils92.AST_NODE_TYPES.AwaitExpression) return unwrap6(node.argument);
|
|
17431
|
+
if (node.type === import_utils92.AST_NODE_TYPES.ChainExpression) return unwrap6(node.expression);
|
|
17432
|
+
if (node.type === import_utils92.AST_NODE_TYPES.TSAsExpression || node.type === import_utils92.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils92.AST_NODE_TYPES.TSTypeAssertion) return unwrap6(node.expression);
|
|
16996
17433
|
return node;
|
|
16997
17434
|
}
|
|
16998
17435
|
function stringValue(node) {
|
|
16999
17436
|
const current = unwrap6(node);
|
|
17000
|
-
if (current.type ===
|
|
17001
|
-
if (current.type ===
|
|
17437
|
+
if (current.type === import_utils92.AST_NODE_TYPES.Literal && typeof current.value === "string") return current.value;
|
|
17438
|
+
if (current.type === import_utils92.AST_NODE_TYPES.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
17002
17439
|
return null;
|
|
17003
17440
|
}
|
|
17004
17441
|
function importSource(node) {
|
|
@@ -17006,7 +17443,7 @@ function importSource(node) {
|
|
|
17006
17443
|
}
|
|
17007
17444
|
function requireSource(node) {
|
|
17008
17445
|
const current = unwrap6(node);
|
|
17009
|
-
if (current.type !==
|
|
17446
|
+
if (current.type !== import_utils92.AST_NODE_TYPES.CallExpression || current.callee.type !== import_utils92.AST_NODE_TYPES.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === import_utils92.AST_NODE_TYPES.SpreadElement) return null;
|
|
17010
17447
|
return stringValue(current.arguments[0]);
|
|
17011
17448
|
}
|
|
17012
17449
|
function newScope() {
|
|
@@ -17046,38 +17483,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17046
17483
|
const current = unwrap6(node);
|
|
17047
17484
|
const value = stringValue(current);
|
|
17048
17485
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
17049
|
-
if (current.type ===
|
|
17050
|
-
if (current.type ===
|
|
17486
|
+
if (current.type === import_utils92.AST_NODE_TYPES.Identifier) return visible("paths", current.name);
|
|
17487
|
+
if (current.type === import_utils92.AST_NODE_TYPES.BinaryExpression && current.operator === "+") {
|
|
17051
17488
|
return sourcePath(current.left) || sourcePath(current.right);
|
|
17052
17489
|
}
|
|
17053
|
-
if (current.type ===
|
|
17054
|
-
if (current.type ===
|
|
17055
|
-
return current.arguments.some((argument) => argument.type !==
|
|
17490
|
+
if (current.type === import_utils92.AST_NODE_TYPES.TemplateLiteral) return current.expressions.some(sourcePath);
|
|
17491
|
+
if (current.type === import_utils92.AST_NODE_TYPES.CallExpression || current.type === import_utils92.AST_NODE_TYPES.NewExpression) {
|
|
17492
|
+
return current.arguments.some((argument) => argument.type !== import_utils92.AST_NODE_TYPES.SpreadElement && sourcePath(argument));
|
|
17056
17493
|
}
|
|
17057
|
-
if (current.type ===
|
|
17494
|
+
if (current.type === import_utils92.AST_NODE_TYPES.MemberExpression) return sourcePath(current.object);
|
|
17058
17495
|
return false;
|
|
17059
17496
|
};
|
|
17060
17497
|
const rawRead = (node) => {
|
|
17061
17498
|
const current = unwrap6(node);
|
|
17062
|
-
if (current.type !==
|
|
17499
|
+
if (current.type !== import_utils92.AST_NODE_TYPES.CallExpression || current.arguments.length === 0) return false;
|
|
17063
17500
|
const callee = unwrap6(current.callee);
|
|
17064
|
-
if (callee.type ===
|
|
17501
|
+
if (callee.type === import_utils92.AST_NODE_TYPES.Identifier) {
|
|
17065
17502
|
return visible("fsReaders", callee.name) && sourcePath(current.arguments[0]);
|
|
17066
17503
|
}
|
|
17067
|
-
if (callee.type !==
|
|
17504
|
+
if (callee.type !== import_utils92.AST_NODE_TYPES.MemberExpression) return false;
|
|
17068
17505
|
const name2 = staticMemberName7(callee);
|
|
17069
17506
|
const object = unwrap6(callee.object);
|
|
17070
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
17507
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === import_utils92.AST_NODE_TYPES.Identifier && visible("fsObjects", object.name) && sourcePath(current.arguments[0]);
|
|
17071
17508
|
};
|
|
17072
17509
|
const rawOrigins = (node) => {
|
|
17073
17510
|
const current = unwrap6(node);
|
|
17074
|
-
if (current.type ===
|
|
17511
|
+
if (current.type === import_utils92.AST_NODE_TYPES.Identifier) return visibleRawOrigins(current.name);
|
|
17075
17512
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
17076
|
-
if (current.type ===
|
|
17077
|
-
if (current.type ===
|
|
17078
|
-
if (current.type !==
|
|
17513
|
+
if (current.type === import_utils92.AST_NODE_TYPES.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
17514
|
+
if (current.type === import_utils92.AST_NODE_TYPES.MemberExpression && staticMemberName7(current) === "length") return rawOrigins(current.object);
|
|
17515
|
+
if (current.type !== import_utils92.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
17079
17516
|
const callee = unwrap6(current.callee);
|
|
17080
|
-
if (callee.type !==
|
|
17517
|
+
if (callee.type !== import_utils92.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
17081
17518
|
const name2 = staticMemberName7(callee);
|
|
17082
17519
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(callee.object) : /* @__PURE__ */ new Set();
|
|
17083
17520
|
};
|
|
@@ -17085,38 +17522,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17085
17522
|
const current = unwrap6(node);
|
|
17086
17523
|
const direct = rawOrigins(current);
|
|
17087
17524
|
if (direct.size > 0) return direct;
|
|
17088
|
-
if (current.type ===
|
|
17089
|
-
if (current.type ===
|
|
17090
|
-
if (current.type !==
|
|
17525
|
+
if (current.type === import_utils92.AST_NODE_TYPES.BinaryExpression || current.type === import_utils92.AST_NODE_TYPES.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
17526
|
+
if (current.type === import_utils92.AST_NODE_TYPES.UnaryExpression) return evidenceOrigins(current.argument);
|
|
17527
|
+
if (current.type !== import_utils92.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
17091
17528
|
const callee = unwrap6(current.callee);
|
|
17092
|
-
if (callee.type !==
|
|
17529
|
+
if (callee.type !== import_utils92.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
17093
17530
|
const name2 = staticMemberName7(callee);
|
|
17094
17531
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(callee.object);
|
|
17095
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
17532
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === import_utils92.AST_NODE_TYPES.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
17096
17533
|
return /* @__PURE__ */ new Set();
|
|
17097
17534
|
};
|
|
17098
17535
|
const rawAssertionOrigins = (node) => {
|
|
17099
17536
|
const callee = unwrap6(node.callee);
|
|
17100
|
-
if (callee.type ===
|
|
17101
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
17537
|
+
if (callee.type === import_utils92.AST_NODE_TYPES.Identifier && callee.name === "assert") {
|
|
17538
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils92.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
17102
17539
|
}
|
|
17103
|
-
if (callee.type !==
|
|
17540
|
+
if (callee.type !== import_utils92.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
17104
17541
|
const matcher = staticMemberName7(callee);
|
|
17105
17542
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
17106
17543
|
let receiver = unwrap6(callee.object);
|
|
17107
|
-
while (receiver.type ===
|
|
17108
|
-
if (receiver.type ===
|
|
17544
|
+
while (receiver.type === import_utils92.AST_NODE_TYPES.MemberExpression && EXPECT_MODIFIERS2.has(staticMemberName7(receiver) ?? "")) receiver = unwrap6(receiver.object);
|
|
17545
|
+
if (receiver.type === import_utils92.AST_NODE_TYPES.CallExpression && receiver.callee.type === import_utils92.AST_NODE_TYPES.Identifier && receiver.callee.name === "expect") {
|
|
17109
17546
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
17110
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
17547
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === import_utils92.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
17111
17548
|
}
|
|
17112
|
-
if (receiver.type !==
|
|
17113
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
17549
|
+
if (receiver.type !== import_utils92.AST_NODE_TYPES.Identifier || receiver.name !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
17550
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils92.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
17114
17551
|
};
|
|
17115
17552
|
const rawRegexExtractionOrigins = (node) => {
|
|
17116
17553
|
const callee = unwrap6(node.callee);
|
|
17117
|
-
if (callee.type !==
|
|
17554
|
+
if (callee.type !== import_utils92.AST_NODE_TYPES.MemberExpression || staticMemberName7(callee) !== "matchAll" || node.arguments.length !== 1) return /* @__PURE__ */ new Set();
|
|
17118
17555
|
const argument = node.arguments[0];
|
|
17119
|
-
if (argument?.type !==
|
|
17556
|
+
if (argument?.type !== import_utils92.AST_NODE_TYPES.Literal || !(argument.value instanceof RegExp)) return /* @__PURE__ */ new Set();
|
|
17120
17557
|
return rawOrigins(callee.object);
|
|
17121
17558
|
};
|
|
17122
17559
|
const declare = (name2, state) => {
|
|
@@ -17137,15 +17574,15 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17137
17574
|
};
|
|
17138
17575
|
const sourceCollection = (node) => {
|
|
17139
17576
|
const current = unwrap6(node);
|
|
17140
|
-
return current.type ===
|
|
17577
|
+
return current.type === import_utils92.AST_NODE_TYPES.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== import_utils92.AST_NODE_TYPES.SpreadElement && sourcePath(element));
|
|
17141
17578
|
};
|
|
17142
17579
|
const declaredNames2 = (node) => {
|
|
17143
17580
|
const current = unwrap6(node);
|
|
17144
|
-
if (current.type ===
|
|
17145
|
-
if (current.type ===
|
|
17146
|
-
if (current.type ===
|
|
17147
|
-
if (current.type ===
|
|
17148
|
-
if (current.type ===
|
|
17581
|
+
if (current.type === import_utils92.AST_NODE_TYPES.Identifier) return [current.name];
|
|
17582
|
+
if (current.type === import_utils92.AST_NODE_TYPES.AssignmentPattern) return declaredNames2(current.left);
|
|
17583
|
+
if (current.type === import_utils92.AST_NODE_TYPES.RestElement) return declaredNames2(current.argument);
|
|
17584
|
+
if (current.type === import_utils92.AST_NODE_TYPES.ArrayPattern) return current.elements.flatMap((element) => element === null ? [] : declaredNames2(element));
|
|
17585
|
+
if (current.type === import_utils92.AST_NODE_TYPES.ObjectPattern) return current.properties.flatMap((property) => property.type === import_utils92.AST_NODE_TYPES.RestElement ? declaredNames2(property.argument) : declaredNames2(property.value));
|
|
17149
17586
|
return [];
|
|
17150
17587
|
};
|
|
17151
17588
|
const enterFunction = (node) => {
|
|
@@ -17160,8 +17597,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17160
17597
|
const source = importSource(node);
|
|
17161
17598
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
17162
17599
|
for (const specifier of node.specifiers) {
|
|
17163
|
-
if (specifier.type ===
|
|
17164
|
-
const imported = specifier.imported.type ===
|
|
17600
|
+
if (specifier.type === import_utils92.AST_NODE_TYPES.ImportSpecifier) {
|
|
17601
|
+
const imported = specifier.imported.type === import_utils92.AST_NODE_TYPES.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
17165
17602
|
if (FS_READERS.has(imported)) declare(specifier.local.name, { fsReader: true });
|
|
17166
17603
|
} else {
|
|
17167
17604
|
declare(specifier.local.name, { fsObject: true });
|
|
@@ -17173,29 +17610,29 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
17173
17610
|
VariableDeclarator(node) {
|
|
17174
17611
|
if (node.init === null) return;
|
|
17175
17612
|
const required = requireSource(node.init);
|
|
17176
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
17613
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === import_utils92.AST_NODE_TYPES.Identifier) {
|
|
17177
17614
|
declare(node.id.name, { fsObject: true });
|
|
17178
17615
|
return;
|
|
17179
17616
|
}
|
|
17180
|
-
if (node.id.type ===
|
|
17617
|
+
if (node.id.type === import_utils92.AST_NODE_TYPES.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
17181
17618
|
for (const property of node.id.properties) {
|
|
17182
|
-
if (property.type !==
|
|
17183
|
-
const key = property.key.type ===
|
|
17619
|
+
if (property.type !== import_utils92.AST_NODE_TYPES.Property || property.value.type !== import_utils92.AST_NODE_TYPES.Identifier) continue;
|
|
17620
|
+
const key = property.key.type === import_utils92.AST_NODE_TYPES.Identifier ? property.key.name : property.key.type === import_utils92.AST_NODE_TYPES.Literal ? String(property.key.value) : "";
|
|
17184
17621
|
if (FS_READERS.has(key)) declare(property.value.name, { fsReader: true });
|
|
17185
17622
|
}
|
|
17186
17623
|
return;
|
|
17187
17624
|
}
|
|
17188
|
-
if (node.id.type !==
|
|
17625
|
+
if (node.id.type !== import_utils92.AST_NODE_TYPES.Identifier) return;
|
|
17189
17626
|
declare(node.id.name, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
17190
17627
|
},
|
|
17191
17628
|
AssignmentExpression(node) {
|
|
17192
|
-
if (node.left.type ===
|
|
17629
|
+
if (node.left.type === import_utils92.AST_NODE_TYPES.Identifier) declare(node.left.name, { path: sourcePath(node.right), rawOrigins: rawOrigins(node.right) });
|
|
17193
17630
|
},
|
|
17194
17631
|
ForOfStatement(node) {
|
|
17195
17632
|
const right = unwrap6(node.right);
|
|
17196
|
-
const collection = right.type ===
|
|
17197
|
-
const left = node.left.type ===
|
|
17198
|
-
if (collection && left?.type ===
|
|
17633
|
+
const collection = right.type === import_utils92.AST_NODE_TYPES.Identifier && visible("collections", right.name);
|
|
17634
|
+
const left = node.left.type === import_utils92.AST_NODE_TYPES.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
17635
|
+
if (collection && left?.type === import_utils92.AST_NODE_TYPES.Identifier) declare(left.name, { path: true });
|
|
17199
17636
|
},
|
|
17200
17637
|
CallExpression(node) {
|
|
17201
17638
|
const origins = /* @__PURE__ */ new Set([
|
|
@@ -17217,7 +17654,7 @@ var source_coupled_test_default = createSourceCoupledRule(
|
|
|
17217
17654
|
);
|
|
17218
17655
|
|
|
17219
17656
|
// src/rules/sole-export-matches-filename.ts
|
|
17220
|
-
var
|
|
17657
|
+
var import_utils93 = require("@typescript-eslint/utils");
|
|
17221
17658
|
var SOLE_EXPORT_MATCHES_FILENAME_DOCUMENTATION = {
|
|
17222
17659
|
summary: "Match a module filename to its sole named public runtime export.",
|
|
17223
17660
|
rationale: "When a module owns one runtime responsibility, matching names make that responsibility directly discoverable.",
|
|
@@ -17234,29 +17671,21 @@ var SOLE_EXPORT_MATCHES_FILENAME_DOCUMENTATION = {
|
|
|
17234
17671
|
};
|
|
17235
17672
|
var EXCLUDED_STEMS = /* @__PURE__ */ new Set([
|
|
17236
17673
|
"common",
|
|
17237
|
-
"config",
|
|
17238
|
-
"constants",
|
|
17239
|
-
"error",
|
|
17240
|
-
"errors",
|
|
17241
17674
|
"global",
|
|
17242
|
-
"handler",
|
|
17243
17675
|
"helpers",
|
|
17244
17676
|
"index",
|
|
17245
17677
|
"layout",
|
|
17246
17678
|
"loading",
|
|
17247
17679
|
"middleware",
|
|
17248
17680
|
"misc",
|
|
17249
|
-
"models",
|
|
17250
17681
|
"not-found",
|
|
17251
17682
|
"page",
|
|
17252
17683
|
"route",
|
|
17253
|
-
"schema",
|
|
17254
17684
|
"shared",
|
|
17255
17685
|
"template",
|
|
17256
17686
|
"types",
|
|
17257
17687
|
"util",
|
|
17258
|
-
"utils"
|
|
17259
|
-
"worker"
|
|
17688
|
+
"utils"
|
|
17260
17689
|
]);
|
|
17261
17690
|
function stem3(filename) {
|
|
17262
17691
|
const base = filename.replaceAll("\\", "/").split("/").at(-1) ?? "";
|
|
@@ -17268,10 +17697,10 @@ function kebabCase(name) {
|
|
|
17268
17697
|
function declarationExport(statement) {
|
|
17269
17698
|
const declaration = statement.declaration;
|
|
17270
17699
|
if (declaration === null || declaration.declare === true) return [];
|
|
17271
|
-
if (declaration.type ===
|
|
17272
|
-
if (declaration.type !==
|
|
17700
|
+
if (declaration.type === import_utils93.AST_NODE_TYPES.ClassDeclaration || declaration.type === import_utils93.AST_NODE_TYPES.FunctionDeclaration || declaration.type === import_utils93.AST_NODE_TYPES.TSEnumDeclaration) return declaration.id === null ? [] : [{ name: declaration.id.name, node: declaration }];
|
|
17701
|
+
if (declaration.type !== import_utils93.AST_NODE_TYPES.VariableDeclaration) return [];
|
|
17273
17702
|
return declaration.declarations.flatMap(
|
|
17274
|
-
(item) => item.id.type ===
|
|
17703
|
+
(item) => item.id.type === import_utils93.AST_NODE_TYPES.Identifier ? [{ name: item.id.name, node: item }] : []
|
|
17275
17704
|
);
|
|
17276
17705
|
}
|
|
17277
17706
|
var sole_export_matches_filename_default = createRule({
|
|
@@ -17295,31 +17724,31 @@ var sole_export_matches_filename_default = createRule({
|
|
|
17295
17724
|
const exports2 = [];
|
|
17296
17725
|
const publicExports = /* @__PURE__ */ new Set();
|
|
17297
17726
|
for (const statement of program.body) {
|
|
17298
|
-
if (statement.type ===
|
|
17299
|
-
if (statement.type ===
|
|
17727
|
+
if (statement.type === import_utils93.AST_NODE_TYPES.ExportAllDeclaration || statement.type === import_utils93.AST_NODE_TYPES.ExportNamedDeclaration && statement.source !== null) return;
|
|
17728
|
+
if (statement.type === import_utils93.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
17300
17729
|
publicExports.add("default");
|
|
17301
17730
|
const declaration2 = statement.declaration;
|
|
17302
|
-
if ((declaration2.type ===
|
|
17731
|
+
if ((declaration2.type === import_utils93.AST_NODE_TYPES.ClassDeclaration || declaration2.type === import_utils93.AST_NODE_TYPES.FunctionDeclaration) && declaration2.id !== null) exports2.push({ name: declaration2.id.name, node: declaration2 });
|
|
17303
17732
|
else return;
|
|
17304
17733
|
}
|
|
17305
|
-
if (statement.type !==
|
|
17734
|
+
if (statement.type !== import_utils93.AST_NODE_TYPES.ExportNamedDeclaration) continue;
|
|
17306
17735
|
const declaration = statement.declaration;
|
|
17307
|
-
if (declaration !== null && "id" in declaration && declaration.id?.type ===
|
|
17736
|
+
if (declaration !== null && "id" in declaration && declaration.id?.type === import_utils93.AST_NODE_TYPES.Identifier) {
|
|
17308
17737
|
publicExports.add(declaration.id.name);
|
|
17309
17738
|
}
|
|
17310
|
-
if (declaration?.type ===
|
|
17739
|
+
if (declaration?.type === import_utils93.AST_NODE_TYPES.VariableDeclaration) {
|
|
17311
17740
|
for (const item of declaration.declarations) {
|
|
17312
|
-
if (item.id.type ===
|
|
17741
|
+
if (item.id.type === import_utils93.AST_NODE_TYPES.Identifier) publicExports.add(item.id.name);
|
|
17313
17742
|
}
|
|
17314
17743
|
}
|
|
17315
17744
|
for (const specifier of statement.specifiers) {
|
|
17316
|
-
const exported = specifier.exported.type ===
|
|
17745
|
+
const exported = specifier.exported.type === import_utils93.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
17317
17746
|
publicExports.add(String(exported));
|
|
17318
17747
|
}
|
|
17319
17748
|
if (statement.exportKind === "type") continue;
|
|
17320
17749
|
exports2.push(...declarationExport(statement));
|
|
17321
17750
|
for (const specifier of statement.specifiers) {
|
|
17322
|
-
const exported = specifier.exported.type ===
|
|
17751
|
+
const exported = specifier.exported.type === import_utils93.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
17323
17752
|
publicExports.add(String(exported));
|
|
17324
17753
|
if (specifier.exportKind === "type") continue;
|
|
17325
17754
|
if (exported === "default") exports2.push({ name: specifier.local.name, node: specifier });
|
|
@@ -17377,7 +17806,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
17377
17806
|
);
|
|
17378
17807
|
|
|
17379
17808
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
17380
|
-
var
|
|
17809
|
+
var import_utils94 = require("@typescript-eslint/utils");
|
|
17381
17810
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
17382
17811
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
17383
17812
|
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.",
|
|
@@ -17509,18 +17938,18 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
17509
17938
|
"superRefine",
|
|
17510
17939
|
"transform"
|
|
17511
17940
|
]);
|
|
17512
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
17941
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils94.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
17513
17942
|
var calleeChainRoot = (node) => {
|
|
17514
17943
|
let current = node;
|
|
17515
17944
|
for (; ; ) {
|
|
17516
|
-
if (current.type ===
|
|
17945
|
+
if (current.type === import_utils94.AST_NODE_TYPES.Identifier) {
|
|
17517
17946
|
return current;
|
|
17518
17947
|
}
|
|
17519
|
-
if (current.type ===
|
|
17948
|
+
if (current.type === import_utils94.AST_NODE_TYPES.MemberExpression) {
|
|
17520
17949
|
current = current.object;
|
|
17521
17950
|
continue;
|
|
17522
17951
|
}
|
|
17523
|
-
if (current.type ===
|
|
17952
|
+
if (current.type === import_utils94.AST_NODE_TYPES.CallExpression) {
|
|
17524
17953
|
current = current.callee;
|
|
17525
17954
|
continue;
|
|
17526
17955
|
}
|
|
@@ -17531,13 +17960,13 @@ var chainMemberNames = (node) => {
|
|
|
17531
17960
|
const names = [];
|
|
17532
17961
|
let current = node;
|
|
17533
17962
|
for (; ; ) {
|
|
17534
|
-
if (current.type ===
|
|
17535
|
-
if (current.computed || current.property.type !==
|
|
17963
|
+
if (current.type === import_utils94.AST_NODE_TYPES.MemberExpression) {
|
|
17964
|
+
if (current.computed || current.property.type !== import_utils94.AST_NODE_TYPES.Identifier) return [];
|
|
17536
17965
|
names.push(current.property.name);
|
|
17537
17966
|
current = current.object;
|
|
17538
17967
|
continue;
|
|
17539
17968
|
}
|
|
17540
|
-
if (current.type ===
|
|
17969
|
+
if (current.type === import_utils94.AST_NODE_TYPES.CallExpression) {
|
|
17541
17970
|
current = current.callee;
|
|
17542
17971
|
continue;
|
|
17543
17972
|
}
|
|
@@ -17548,16 +17977,16 @@ var chainMemberNames = (node) => {
|
|
|
17548
17977
|
};
|
|
17549
17978
|
var unwrapExpression4 = (node) => {
|
|
17550
17979
|
let current = node;
|
|
17551
|
-
while (current.type ===
|
|
17980
|
+
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.type === import_utils94.AST_NODE_TYPES.TSTypeAssertion) {
|
|
17552
17981
|
current = current.expression;
|
|
17553
17982
|
}
|
|
17554
17983
|
return current;
|
|
17555
17984
|
};
|
|
17556
17985
|
var isModuleDeclarator = (node) => {
|
|
17557
17986
|
const declaration = node.parent;
|
|
17558
|
-
if (declaration.type !==
|
|
17987
|
+
if (declaration.type !== import_utils94.AST_NODE_TYPES.VariableDeclaration) return false;
|
|
17559
17988
|
const owner = declaration.parent;
|
|
17560
|
-
return owner.type ===
|
|
17989
|
+
return owner.type === import_utils94.AST_NODE_TYPES.Program || owner.type === import_utils94.AST_NODE_TYPES.ExportNamedDeclaration && owner.parent.type === import_utils94.AST_NODE_TYPES.Program;
|
|
17561
17990
|
};
|
|
17562
17991
|
var require_pascal_case_zod_schema_name_default = createRule({
|
|
17563
17992
|
name: "require-pascal-case-zod-schema-name",
|
|
@@ -17577,7 +18006,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
17577
18006
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
17578
18007
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
17579
18008
|
function resolvedBinding(identifier) {
|
|
17580
|
-
return
|
|
18009
|
+
return import_utils94.ASTUtils.findVariable(
|
|
17581
18010
|
context.sourceCode.getScope(identifier),
|
|
17582
18011
|
identifier.name
|
|
17583
18012
|
);
|
|
@@ -17598,8 +18027,8 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
17598
18027
|
}
|
|
17599
18028
|
function isConfirmedSchema(expression) {
|
|
17600
18029
|
const init = unwrapExpression4(expression);
|
|
17601
|
-
if (init.type ===
|
|
17602
|
-
if (init.type !==
|
|
18030
|
+
if (init.type === import_utils94.AST_NODE_TYPES.Identifier) return isSchemaBinding(init);
|
|
18031
|
+
if (init.type !== import_utils94.AST_NODE_TYPES.CallExpression || init.callee.type !== import_utils94.AST_NODE_TYPES.MemberExpression) {
|
|
17603
18032
|
return false;
|
|
17604
18033
|
}
|
|
17605
18034
|
const terminal = terminalMethodName(init.callee);
|
|
@@ -17619,7 +18048,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
17619
18048
|
ImportDeclaration(node) {
|
|
17620
18049
|
if (!isZodModule(node.source.value)) return;
|
|
17621
18050
|
for (const specifier of node.specifiers) {
|
|
17622
|
-
if (specifier.type ===
|
|
18051
|
+
if (specifier.type === import_utils94.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils94.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils94.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils94.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
17623
18052
|
recordZodBinding(specifier.local);
|
|
17624
18053
|
}
|
|
17625
18054
|
}
|
|
@@ -17628,7 +18057,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
17628
18057
|
if (!isModuleDeclarator(node)) return;
|
|
17629
18058
|
const init = node.init;
|
|
17630
18059
|
if (init === null || init === void 0) return;
|
|
17631
|
-
if (node.id.type !==
|
|
18060
|
+
if (node.id.type !== import_utils94.AST_NODE_TYPES.Identifier) return;
|
|
17632
18061
|
if (!isConfirmedSchema(init)) return;
|
|
17633
18062
|
const binding = resolvedBinding(node.id);
|
|
17634
18063
|
if (binding !== null) schemaBindings.add(binding);
|
|
@@ -17803,6 +18232,7 @@ var RULES = {
|
|
|
17803
18232
|
"prefer-zod-infer": prefer_zod_infer_default,
|
|
17804
18233
|
"require-assert-never": require_assert_never_default,
|
|
17805
18234
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
18235
|
+
"require-interface-for-exported-class": require_interface_for_exported_class_default,
|
|
17806
18236
|
"require-port-for-service": require_port_for_service_default,
|
|
17807
18237
|
"require-sql-access-class": require_sql_access_class_default,
|
|
17808
18238
|
"require-static-next-matcher": require_static_next_matcher_default,
|
|
@@ -17815,7 +18245,7 @@ var RULES = {
|
|
|
17815
18245
|
};
|
|
17816
18246
|
var meta = {
|
|
17817
18247
|
name: "@sarj/eslint-plugin",
|
|
17818
|
-
version: "15.
|
|
18248
|
+
version: "15.16.0"
|
|
17819
18249
|
};
|
|
17820
18250
|
var APPLICATION_ONLY_RULES = [
|
|
17821
18251
|
"no-restricted-library-load",
|
|
@@ -17825,8 +18255,10 @@ var APPLICATION_ONLY_RULES = [
|
|
|
17825
18255
|
var ADVISORY_RULES = [
|
|
17826
18256
|
"@sarj/prefer-named-complex-return-type",
|
|
17827
18257
|
"@sarj/prefer-node-crypto-hash",
|
|
18258
|
+
"@sarj/prefer-node-fs-promises",
|
|
17828
18259
|
"@sarj/prefer-shared-zod-enum",
|
|
17829
18260
|
"@sarj/prefer-switch-for-repeated-equality",
|
|
18261
|
+
"@sarj/require-interface-for-exported-class",
|
|
17830
18262
|
"@sarj/require-pascal-case-zod-schema-name",
|
|
17831
18263
|
"@sarj/require-sql-access-class",
|
|
17832
18264
|
"@sarj/sole-export-matches-filename"
|
|
@@ -17886,7 +18318,7 @@ var RECOMMENDED_RULES = {
|
|
|
17886
18318
|
"@sarj/prefer-module-level-schema": "error",
|
|
17887
18319
|
"@sarj/prefer-named-complex-return-type": "warn",
|
|
17888
18320
|
"@sarj/prefer-node-crypto-hash": "warn",
|
|
17889
|
-
"@sarj/prefer-node-fs-promises": "
|
|
18321
|
+
"@sarj/prefer-node-fs-promises": "warn",
|
|
17890
18322
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
17891
18323
|
"@sarj/prefer-nullish-filter-predicate": "error",
|
|
17892
18324
|
"@sarj/prefer-await-in-async-return": "error",
|
|
@@ -17900,6 +18332,7 @@ var RECOMMENDED_RULES = {
|
|
|
17900
18332
|
"@sarj/prefer-zod-infer": "error",
|
|
17901
18333
|
"@sarj/require-assert-never": "error",
|
|
17902
18334
|
"@sarj/require-fetch-timeout": "error",
|
|
18335
|
+
"@sarj/require-interface-for-exported-class": "warn",
|
|
17903
18336
|
"@sarj/require-port-for-service": "error",
|
|
17904
18337
|
"@sarj/require-sql-access-class": "warn",
|
|
17905
18338
|
"@sarj/require-static-next-matcher": "error",
|
|
@@ -17972,7 +18405,7 @@ var STRICT_RULES = {
|
|
|
17972
18405
|
"@sarj/prefer-module-level-schema": "error",
|
|
17973
18406
|
"@sarj/prefer-named-complex-return-type": "warn",
|
|
17974
18407
|
"@sarj/prefer-node-crypto-hash": "warn",
|
|
17975
|
-
"@sarj/prefer-node-fs-promises": "
|
|
18408
|
+
"@sarj/prefer-node-fs-promises": "warn",
|
|
17976
18409
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
17977
18410
|
"@sarj/prefer-nullish-filter-predicate": "error",
|
|
17978
18411
|
"@sarj/prefer-await-in-async-return": "error",
|
|
@@ -17986,6 +18419,7 @@ var STRICT_RULES = {
|
|
|
17986
18419
|
"@sarj/prefer-zod-infer": "error",
|
|
17987
18420
|
"@sarj/require-assert-never": "error",
|
|
17988
18421
|
"@sarj/require-fetch-timeout": "error",
|
|
18422
|
+
"@sarj/require-interface-for-exported-class": "warn",
|
|
17989
18423
|
"@sarj/require-port-for-service": "error",
|
|
17990
18424
|
"@sarj/require-sql-access-class": "warn",
|
|
17991
18425
|
"@sarj/require-static-next-matcher": "error",
|