@sarj/eslint-plugin 15.13.3 → 15.14.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 +703 -544
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +709 -546
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12039,9 +12039,165 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
12039
12039
|
}
|
|
12040
12040
|
});
|
|
12041
12041
|
|
|
12042
|
-
// src/rules/prefer-
|
|
12042
|
+
// src/rules/prefer-nullish-filter-predicate.ts
|
|
12043
12043
|
var import_utils68 = require("@typescript-eslint/utils");
|
|
12044
|
-
var
|
|
12044
|
+
var import_typescript = __toESM(require("typescript"), 1);
|
|
12045
|
+
var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
12046
|
+
summary: "Prefer an explicit nullish predicate when `filter(Boolean)` removes only nullish values but does not narrow the result type.",
|
|
12047
|
+
rationale: "An explicit nullish predicate preserves the same runtime elements while letting TypeScript remove `null` and `undefined` from the result.",
|
|
12048
|
+
remediation: "Replace `filter(Boolean)` with `filter((value) => value !== null && value !== undefined)`.",
|
|
12049
|
+
category: "correctness",
|
|
12050
|
+
autofix: "suggestion",
|
|
12051
|
+
limitations: [
|
|
12052
|
+
"The receiver must resolve to the built-in Array or ReadonlyArray filter method.",
|
|
12053
|
+
"Broad primitive types, falsy literals, any, unknown, generics, intersections, custom filters, and shadowed Boolean bindings are excluded."
|
|
12054
|
+
],
|
|
12055
|
+
examples: [
|
|
12056
|
+
{
|
|
12057
|
+
id: "explicit-nullish-predicate",
|
|
12058
|
+
title: "Nullish filtering narrows the result",
|
|
12059
|
+
outcome: "no-match",
|
|
12060
|
+
files: [
|
|
12061
|
+
{
|
|
12062
|
+
path: "src/users.ts",
|
|
12063
|
+
source: "declare const users: readonly ({ id: string } | null)[];\nconst present = users.filter((user) => user !== null && user !== undefined);"
|
|
12064
|
+
}
|
|
12065
|
+
],
|
|
12066
|
+
focusPath: "src/users.ts",
|
|
12067
|
+
expectedCount: 0,
|
|
12068
|
+
public: true
|
|
12069
|
+
},
|
|
12070
|
+
{
|
|
12071
|
+
id: "boolean-nullish-filter",
|
|
12072
|
+
title: "Boolean filtering loses nullish narrowing",
|
|
12073
|
+
outcome: "match",
|
|
12074
|
+
files: [
|
|
12075
|
+
{
|
|
12076
|
+
path: "src/users.ts",
|
|
12077
|
+
source: "declare const users: readonly ({ id: string } | null)[];\nconst present = users.filter(Boolean);"
|
|
12078
|
+
}
|
|
12079
|
+
],
|
|
12080
|
+
focusPath: "src/users.ts",
|
|
12081
|
+
expectedCount: 1,
|
|
12082
|
+
public: true
|
|
12083
|
+
}
|
|
12084
|
+
]
|
|
12085
|
+
};
|
|
12086
|
+
function isUnshadowedBoolean(node, context) {
|
|
12087
|
+
const variable = import_utils68.ASTUtils.findVariable(context.sourceCode.getScope(node), node.name);
|
|
12088
|
+
return variable === null || variable.defs.length === 0;
|
|
12089
|
+
}
|
|
12090
|
+
function isBuiltinArrayFilter(node, services) {
|
|
12091
|
+
const checker = services.program.getTypeChecker();
|
|
12092
|
+
const property = services.esTreeNodeToTSNodeMap.get(node.property);
|
|
12093
|
+
const symbol = checker.getSymbolAtLocation(property);
|
|
12094
|
+
return symbol?.declarations?.some((declaration) => {
|
|
12095
|
+
const owner = declaration.parent;
|
|
12096
|
+
return import_typescript.default.isInterfaceDeclaration(owner) && (owner.name.text === "Array" || owner.name.text === "ReadonlyArray") && services.program.isSourceFileDefaultLibrary(owner.getSourceFile());
|
|
12097
|
+
}) ?? false;
|
|
12098
|
+
}
|
|
12099
|
+
function arrayElementType(node, services) {
|
|
12100
|
+
const checker = services.program.getTypeChecker();
|
|
12101
|
+
const receiver = services.esTreeNodeToTSNodeMap.get(node);
|
|
12102
|
+
return checker.getIndexTypeOfType(checker.getTypeAtLocation(receiver), import_typescript.default.IndexKind.Number) ?? null;
|
|
12103
|
+
}
|
|
12104
|
+
var NULLISH_FLAGS = import_typescript.default.TypeFlags.Null | import_typescript.default.TypeFlags.Undefined;
|
|
12105
|
+
var UNKNOWN_FLAGS = import_typescript.default.TypeFlags.Any | import_typescript.default.TypeFlags.Unknown | import_typescript.default.TypeFlags.TypeParameter | import_typescript.default.TypeFlags.Intersection | import_typescript.default.TypeFlags.Enum | import_typescript.default.TypeFlags.EnumLiteral;
|
|
12106
|
+
function isNullishPlusTruthy(type, checker) {
|
|
12107
|
+
const members = type.isUnion() ? type.types : [type];
|
|
12108
|
+
let sawNullish = false;
|
|
12109
|
+
for (const member of members) {
|
|
12110
|
+
if ((member.flags & NULLISH_FLAGS) !== 0) {
|
|
12111
|
+
sawNullish = true;
|
|
12112
|
+
} else if ((member.flags & import_typescript.default.TypeFlags.Never) === 0 && !isProvablyTruthy(member, checker)) {
|
|
12113
|
+
return false;
|
|
12114
|
+
}
|
|
12115
|
+
}
|
|
12116
|
+
return sawNullish;
|
|
12117
|
+
}
|
|
12118
|
+
function isProvablyTruthy(type, checker) {
|
|
12119
|
+
if ((type.flags & UNKNOWN_FLAGS) !== 0) return false;
|
|
12120
|
+
if ((type.flags & import_typescript.default.TypeFlags.Object) !== 0) {
|
|
12121
|
+
return ![
|
|
12122
|
+
checker.getStringType(),
|
|
12123
|
+
checker.getNumberType(),
|
|
12124
|
+
checker.getBigIntType(),
|
|
12125
|
+
checker.getBooleanType()
|
|
12126
|
+
].some((primitive) => checker.isTypeAssignableTo(primitive, type));
|
|
12127
|
+
}
|
|
12128
|
+
if ((type.flags & (import_typescript.default.TypeFlags.ESSymbol | import_typescript.default.TypeFlags.UniqueESSymbol)) !== 0) return true;
|
|
12129
|
+
if ((type.flags & import_typescript.default.TypeFlags.BooleanLiteral) !== 0) {
|
|
12130
|
+
return type.intrinsicName === "true";
|
|
12131
|
+
}
|
|
12132
|
+
if ((type.flags & import_typescript.default.TypeFlags.StringLiteral) !== 0) {
|
|
12133
|
+
return type.value.length > 0;
|
|
12134
|
+
}
|
|
12135
|
+
if ((type.flags & import_typescript.default.TypeFlags.NumberLiteral) !== 0) {
|
|
12136
|
+
const value = type.value;
|
|
12137
|
+
return value !== 0 && !Number.isNaN(value);
|
|
12138
|
+
}
|
|
12139
|
+
if ((type.flags & import_typescript.default.TypeFlags.BigIntLiteral) !== 0) {
|
|
12140
|
+
return type.value.base10Value !== "0";
|
|
12141
|
+
}
|
|
12142
|
+
return false;
|
|
12143
|
+
}
|
|
12144
|
+
function availableParameterName(node, context) {
|
|
12145
|
+
for (const name of ["value", "item", "element", "candidate"]) {
|
|
12146
|
+
if (import_utils68.ASTUtils.findVariable(context.sourceCode.getScope(node), name) === null) return name;
|
|
12147
|
+
}
|
|
12148
|
+
return null;
|
|
12149
|
+
}
|
|
12150
|
+
var prefer_nullish_filter_predicate_default = createRule({
|
|
12151
|
+
name: "prefer-nullish-filter-predicate",
|
|
12152
|
+
documentation: PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION,
|
|
12153
|
+
meta: {
|
|
12154
|
+
type: "suggestion",
|
|
12155
|
+
docs: { description: PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION.summary },
|
|
12156
|
+
hasSuggestions: true,
|
|
12157
|
+
schema: [],
|
|
12158
|
+
messages: {
|
|
12159
|
+
preferNullishPredicate: "This built-in array contains only nullish or provably truthy values, so `filter(Boolean)` preserves runtime values but loses nullish narrowing. Use an explicit nullish predicate.",
|
|
12160
|
+
replaceBoolean: "Replace `Boolean` with an explicit nullish predicate."
|
|
12161
|
+
}
|
|
12162
|
+
},
|
|
12163
|
+
defaultOptions: [],
|
|
12164
|
+
create(context) {
|
|
12165
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
12166
|
+
let services;
|
|
12167
|
+
try {
|
|
12168
|
+
services = import_utils68.ESLintUtils.getParserServices(context);
|
|
12169
|
+
} catch {
|
|
12170
|
+
services = null;
|
|
12171
|
+
}
|
|
12172
|
+
if (services === null) return {};
|
|
12173
|
+
return {
|
|
12174
|
+
CallExpression(node) {
|
|
12175
|
+
const callee = node.callee;
|
|
12176
|
+
const callback = node.arguments[0];
|
|
12177
|
+
if (node.arguments.length !== 1 || callback?.type !== import_utils68.AST_NODE_TYPES.Identifier || callback.name !== "Boolean" || callee.type !== import_utils68.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils68.AST_NODE_TYPES.Identifier || callee.property.name !== "filter" || !isUnshadowedBoolean(callback, context) || !isBuiltinArrayFilter(callee, services)) return;
|
|
12178
|
+
const elementType = arrayElementType(callee.object, services);
|
|
12179
|
+
const checker = services.program.getTypeChecker();
|
|
12180
|
+
if (elementType === null || !isNullishPlusTruthy(elementType, checker)) return;
|
|
12181
|
+
const parameter = availableParameterName(node, context);
|
|
12182
|
+
context.report({
|
|
12183
|
+
node: callback,
|
|
12184
|
+
messageId: "preferNullishPredicate",
|
|
12185
|
+
suggest: parameter === null ? null : [{
|
|
12186
|
+
messageId: "replaceBoolean",
|
|
12187
|
+
fix: (fixer) => fixer.replaceText(
|
|
12188
|
+
callback,
|
|
12189
|
+
`(${parameter}) => ${parameter} !== null && ${parameter} !== undefined`
|
|
12190
|
+
)
|
|
12191
|
+
}]
|
|
12192
|
+
});
|
|
12193
|
+
}
|
|
12194
|
+
};
|
|
12195
|
+
}
|
|
12196
|
+
});
|
|
12197
|
+
|
|
12198
|
+
// src/rules/prefer-await-in-async-return.ts
|
|
12199
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
12200
|
+
var ts4 = __toESM(require("typescript"), 1);
|
|
12045
12201
|
var PREFER_AWAIT_IN_ASYNC_RETURN_DOCUMENTATION = {
|
|
12046
12202
|
summary: "Prefer explicit `await` when an async function directly returns one typed Promise `.then` transform.",
|
|
12047
12203
|
rationale: "Mixing a directly returned Promise callback into otherwise async control flow makes sequencing and failures harder to read.",
|
|
@@ -12082,10 +12238,10 @@ var PREFER_AWAIT_IN_ASYNC_RETURN_DOCUMENTATION = {
|
|
|
12082
12238
|
};
|
|
12083
12239
|
function directAsyncReturnOwner(node) {
|
|
12084
12240
|
const parent = node.parent;
|
|
12085
|
-
if (parent.type ===
|
|
12241
|
+
if (parent.type === import_utils69.AST_NODE_TYPES.ArrowFunctionExpression && parent.body === node) {
|
|
12086
12242
|
return parent.async && !parent.generator ? parent : null;
|
|
12087
12243
|
}
|
|
12088
|
-
if (parent.type !==
|
|
12244
|
+
if (parent.type !== import_utils69.AST_NODE_TYPES.ReturnStatement || parent.argument !== node) {
|
|
12089
12245
|
return null;
|
|
12090
12246
|
}
|
|
12091
12247
|
let owner = parent.parent;
|
|
@@ -12095,15 +12251,15 @@ function directAsyncReturnOwner(node) {
|
|
|
12095
12251
|
return owner !== void 0 && owner.async && !owner.generator ? owner : null;
|
|
12096
12252
|
}
|
|
12097
12253
|
function isRuntimeFunction(node) {
|
|
12098
|
-
return node.type ===
|
|
12254
|
+
return node.type === import_utils69.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils69.AST_NODE_TYPES.FunctionExpression;
|
|
12099
12255
|
}
|
|
12100
12256
|
function promiseThenReceiver(node) {
|
|
12101
12257
|
const callee = node.callee;
|
|
12102
|
-
if (callee.type !==
|
|
12258
|
+
if (callee.type !== import_utils69.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.property.type !== import_utils69.AST_NODE_TYPES.Identifier || callee.property.name !== "then" || node.optional || node.arguments.length !== 1) {
|
|
12103
12259
|
return null;
|
|
12104
12260
|
}
|
|
12105
12261
|
const callback = node.arguments[0];
|
|
12106
|
-
if (callback === void 0 || callback.type !==
|
|
12262
|
+
if (callback === void 0 || callback.type !== import_utils69.AST_NODE_TYPES.ArrowFunctionExpression && callback.type !== import_utils69.AST_NODE_TYPES.FunctionExpression) {
|
|
12107
12263
|
return null;
|
|
12108
12264
|
}
|
|
12109
12265
|
return callee.object;
|
|
@@ -12112,14 +12268,14 @@ function isProvenPromiseLike(node, services) {
|
|
|
12112
12268
|
const checker = services.program.getTypeChecker();
|
|
12113
12269
|
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
|
|
12114
12270
|
const receiverType = checker.getTypeAtLocation(tsNode);
|
|
12115
|
-
if ((receiverType.flags & (
|
|
12271
|
+
if ((receiverType.flags & (ts4.TypeFlags.Any | ts4.TypeFlags.Unknown | ts4.TypeFlags.Never)) !== 0) {
|
|
12116
12272
|
return false;
|
|
12117
12273
|
}
|
|
12118
12274
|
const thenSymbol = checker.getPropertyOfType(receiverType, "then");
|
|
12119
12275
|
const hasBuiltInPromiseDeclaration = thenSymbol?.declarations?.some(
|
|
12120
12276
|
(declaration) => {
|
|
12121
12277
|
let owner = declaration.parent;
|
|
12122
|
-
while (owner !== void 0 && !
|
|
12278
|
+
while (owner !== void 0 && !ts4.isInterfaceDeclaration(owner)) {
|
|
12123
12279
|
owner = owner.parent;
|
|
12124
12280
|
}
|
|
12125
12281
|
return owner !== void 0 && (owner.name.text === "Promise" || owner.name.text === "PromiseLike") && services.program.isSourceFileDefaultLibrary(owner.getSourceFile());
|
|
@@ -12144,32 +12300,32 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
12144
12300
|
create(context) {
|
|
12145
12301
|
let services;
|
|
12146
12302
|
try {
|
|
12147
|
-
services =
|
|
12303
|
+
services = import_utils69.ESLintUtils.getParserServices(context);
|
|
12148
12304
|
} catch {
|
|
12149
12305
|
services = null;
|
|
12150
12306
|
}
|
|
12151
12307
|
if (services === null) return {};
|
|
12152
12308
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
12153
12309
|
const rememberFrameworkLoader = (identifier) => {
|
|
12154
|
-
const variable =
|
|
12310
|
+
const variable = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
12155
12311
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
12156
12312
|
};
|
|
12157
12313
|
const isFrameworkLoaderCallback = (owner) => {
|
|
12158
12314
|
const parent = owner.parent;
|
|
12159
|
-
if (parent.type !==
|
|
12160
|
-
const variable =
|
|
12315
|
+
if (parent.type !== import_utils69.AST_NODE_TYPES.CallExpression || parent.arguments[0] !== owner || parent.callee.type !== import_utils69.AST_NODE_TYPES.Identifier) return false;
|
|
12316
|
+
const variable = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(parent.callee), parent.callee.name);
|
|
12161
12317
|
return variable !== null && frameworkLoaders.has(variable);
|
|
12162
12318
|
};
|
|
12163
12319
|
return {
|
|
12164
12320
|
ImportDeclaration(node) {
|
|
12165
12321
|
if (node.source.value === "react") {
|
|
12166
12322
|
for (const specifier of node.specifiers) {
|
|
12167
|
-
if (specifier.type ===
|
|
12323
|
+
if (specifier.type === import_utils69.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils69.AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value) === "lazy") rememberFrameworkLoader(specifier.local);
|
|
12168
12324
|
}
|
|
12169
12325
|
}
|
|
12170
12326
|
if (node.source.value === "next/dynamic") {
|
|
12171
12327
|
for (const specifier of node.specifiers) {
|
|
12172
|
-
if (specifier.type ===
|
|
12328
|
+
if (specifier.type === import_utils69.AST_NODE_TYPES.ImportDefaultSpecifier) rememberFrameworkLoader(specifier.local);
|
|
12173
12329
|
}
|
|
12174
12330
|
}
|
|
12175
12331
|
},
|
|
@@ -12187,7 +12343,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
12187
12343
|
});
|
|
12188
12344
|
|
|
12189
12345
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
12190
|
-
var
|
|
12346
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
12191
12347
|
var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
12192
12348
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
12193
12349
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -12202,9 +12358,9 @@ var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
|
12202
12358
|
var unwrap4 = (node) => {
|
|
12203
12359
|
let current = node;
|
|
12204
12360
|
while (current !== null && current !== void 0) {
|
|
12205
|
-
if (current.type ===
|
|
12361
|
+
if (current.type === import_utils70.AST_NODE_TYPES.TSAsExpression || current.type === import_utils70.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils70.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils70.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
12206
12362
|
current = current.expression;
|
|
12207
|
-
} else if (current.type ===
|
|
12363
|
+
} else if (current.type === import_utils70.AST_NODE_TYPES.ChainExpression) {
|
|
12208
12364
|
current = current.expression;
|
|
12209
12365
|
} else {
|
|
12210
12366
|
break;
|
|
@@ -12219,23 +12375,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
12219
12375
|
]);
|
|
12220
12376
|
var isSchemaParseReference = (node) => {
|
|
12221
12377
|
const inner = unwrap4(node);
|
|
12222
|
-
return inner !== null && inner.type ===
|
|
12378
|
+
return inner !== null && inner.type === import_utils70.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils70.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
12223
12379
|
};
|
|
12224
12380
|
var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
12225
12381
|
let current = unwrap4(node);
|
|
12226
12382
|
if (current === null) return false;
|
|
12227
|
-
if (current.type ===
|
|
12383
|
+
if (current.type === import_utils70.AST_NODE_TYPES.AwaitExpression) {
|
|
12228
12384
|
current = unwrap4(current.argument);
|
|
12229
12385
|
}
|
|
12230
|
-
if (current === null || current.type !==
|
|
12386
|
+
if (current === null || current.type !== import_utils70.AST_NODE_TYPES.CallExpression) {
|
|
12231
12387
|
return false;
|
|
12232
12388
|
}
|
|
12233
12389
|
const callee = unwrap4(current.callee);
|
|
12234
|
-
if (callee === null || callee.type !==
|
|
12390
|
+
if (callee === null || callee.type !== import_utils70.AST_NODE_TYPES.MemberExpression) {
|
|
12235
12391
|
return false;
|
|
12236
12392
|
}
|
|
12237
12393
|
const property = unwrap4(callee.property);
|
|
12238
|
-
if (property === null || property.type !==
|
|
12394
|
+
if (property === null || property.type !== import_utils70.AST_NODE_TYPES.Identifier) {
|
|
12239
12395
|
return false;
|
|
12240
12396
|
}
|
|
12241
12397
|
if (property.name === "json") {
|
|
@@ -12245,17 +12401,17 @@ var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
|
12245
12401
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
12246
12402
|
}
|
|
12247
12403
|
const object = unwrap4(callee.object);
|
|
12248
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
12404
|
+
return property.name === "parse" && object !== null && object.type === import_utils70.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
12249
12405
|
};
|
|
12250
12406
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
12251
12407
|
var isDirectLocalFileRead = (node) => {
|
|
12252
12408
|
let current = unwrap4(node);
|
|
12253
|
-
if (current?.type ===
|
|
12409
|
+
if (current?.type === import_utils70.AST_NODE_TYPES.AwaitExpression) {
|
|
12254
12410
|
current = unwrap4(current.argument);
|
|
12255
12411
|
}
|
|
12256
|
-
if (current?.type !==
|
|
12412
|
+
if (current?.type !== import_utils70.AST_NODE_TYPES.CallExpression) return false;
|
|
12257
12413
|
const callee = unwrap4(current.callee);
|
|
12258
|
-
const name = callee?.type ===
|
|
12414
|
+
const name = callee?.type === import_utils70.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils70.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils70.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
12259
12415
|
return name !== null && FILE_READ_RE.test(name);
|
|
12260
12416
|
};
|
|
12261
12417
|
var isLocalFileRead = (node) => {
|
|
@@ -12282,15 +12438,15 @@ var isLocalFileRead = (node) => {
|
|
|
12282
12438
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
12283
12439
|
var isInsideAssertion = (node) => {
|
|
12284
12440
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12285
|
-
if (current.type !==
|
|
12441
|
+
if (current.type !== import_utils70.AST_NODE_TYPES.CallExpression) continue;
|
|
12286
12442
|
let callee = current.callee;
|
|
12287
|
-
while (callee.type ===
|
|
12443
|
+
while (callee.type === import_utils70.AST_NODE_TYPES.MemberExpression) {
|
|
12288
12444
|
callee = callee.object;
|
|
12289
12445
|
}
|
|
12290
|
-
if (callee.type ===
|
|
12446
|
+
if (callee.type === import_utils70.AST_NODE_TYPES.CallExpression) {
|
|
12291
12447
|
callee = callee.callee;
|
|
12292
12448
|
}
|
|
12293
|
-
if (callee.type ===
|
|
12449
|
+
if (callee.type === import_utils70.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
12294
12450
|
return true;
|
|
12295
12451
|
}
|
|
12296
12452
|
}
|
|
@@ -12309,22 +12465,22 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
12309
12465
|
var isValidationRead = (node) => {
|
|
12310
12466
|
let current = node;
|
|
12311
12467
|
let parent = current.parent;
|
|
12312
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
12468
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils70.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils70.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils70.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils70.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils70.AST_NODE_TYPES.ChainExpression)) {
|
|
12313
12469
|
current = parent;
|
|
12314
12470
|
parent = parent.parent;
|
|
12315
12471
|
}
|
|
12316
12472
|
if (parent === null || parent === void 0) return false;
|
|
12317
|
-
if (parent.type ===
|
|
12473
|
+
if (parent.type === import_utils70.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
12318
12474
|
return true;
|
|
12319
12475
|
}
|
|
12320
|
-
if (parent.type !==
|
|
12476
|
+
if (parent.type !== import_utils70.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
12321
12477
|
return false;
|
|
12322
12478
|
}
|
|
12323
12479
|
const callee = parent.callee;
|
|
12324
|
-
if (callee.type ===
|
|
12480
|
+
if (callee.type === import_utils70.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils70.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils70.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
12325
12481
|
return parent.arguments.length === 1;
|
|
12326
12482
|
}
|
|
12327
|
-
return callee.type ===
|
|
12483
|
+
return callee.type === import_utils70.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
12328
12484
|
};
|
|
12329
12485
|
var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
12330
12486
|
"bigint",
|
|
@@ -12335,13 +12491,13 @@ var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
|
12335
12491
|
"undefined"
|
|
12336
12492
|
]);
|
|
12337
12493
|
var bindingValidationPolarity = (test, bindingName) => {
|
|
12338
|
-
if (test.type ===
|
|
12494
|
+
if (test.type === import_utils70.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
12339
12495
|
const inner = bindingValidationPolarity(test.argument, bindingName);
|
|
12340
12496
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
12341
12497
|
}
|
|
12342
|
-
if (test.type ===
|
|
12343
|
-
const typeofName = (node) => node.type ===
|
|
12344
|
-
const literalType = (node) => node.type ===
|
|
12498
|
+
if (test.type === import_utils70.AST_NODE_TYPES.BinaryExpression) {
|
|
12499
|
+
const typeofName = (node) => node.type === import_utils70.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && node.argument.type === import_utils70.AST_NODE_TYPES.Identifier ? node.argument.name : null;
|
|
12500
|
+
const literalType = (node) => node.type === import_utils70.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value) ? node.value : null;
|
|
12345
12501
|
const matches = typeofName(test.left) === bindingName && literalType(test.right) !== null || typeofName(test.right) === bindingName && literalType(test.left) !== null;
|
|
12346
12502
|
if (!matches) return null;
|
|
12347
12503
|
if (test.operator === "===" || test.operator === "==") {
|
|
@@ -12349,9 +12505,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
12349
12505
|
}
|
|
12350
12506
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
12351
12507
|
}
|
|
12352
|
-
return test.type ===
|
|
12508
|
+
return test.type === import_utils70.AST_NODE_TYPES.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === import_utils70.AST_NODE_TYPES.Identifier && test.arguments[0].name === bindingName && test.callee.type === import_utils70.AST_NODE_TYPES.MemberExpression && !test.callee.computed && test.callee.object.type === import_utils70.AST_NODE_TYPES.Identifier && test.callee.object.name === "Array" && test.callee.property.type === import_utils70.AST_NODE_TYPES.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
12353
12509
|
};
|
|
12354
|
-
var plainMemberAccess = (node) => node.type ===
|
|
12510
|
+
var plainMemberAccess = (node) => node.type === import_utils70.AST_NODE_TYPES.MemberExpression && !node.computed && node.object.type === import_utils70.AST_NODE_TYPES.Identifier && node.property.type === import_utils70.AST_NODE_TYPES.Identifier ? { object: node.object.name, property: node.property.name } : null;
|
|
12355
12511
|
var isSamePlainMember = (node, access) => {
|
|
12356
12512
|
const candidate2 = plainMemberAccess(node);
|
|
12357
12513
|
return candidate2 !== null && candidate2.object === access.object && candidate2.property === access.property;
|
|
@@ -12359,19 +12515,19 @@ var isSamePlainMember = (node, access) => {
|
|
|
12359
12515
|
var nodeWithin2 = (node, container) => node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
12360
12516
|
var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
12361
12517
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12362
|
-
if (current.type ===
|
|
12518
|
+
if (current.type === import_utils70.AST_NODE_TYPES.ConditionalExpression) {
|
|
12363
12519
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
12364
12520
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
12365
12521
|
return true;
|
|
12366
12522
|
}
|
|
12367
12523
|
}
|
|
12368
|
-
if (current.type ===
|
|
12524
|
+
if (current.type === import_utils70.AST_NODE_TYPES.IfStatement) {
|
|
12369
12525
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
12370
12526
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
12371
12527
|
return true;
|
|
12372
12528
|
}
|
|
12373
12529
|
}
|
|
12374
|
-
if (current.type ===
|
|
12530
|
+
if (current.type === import_utils70.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils70.AST_NODE_TYPES.FunctionExpression || current.type === import_utils70.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
12375
12531
|
return false;
|
|
12376
12532
|
}
|
|
12377
12533
|
}
|
|
@@ -12379,32 +12535,32 @@ var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
|
12379
12535
|
};
|
|
12380
12536
|
var isMemberUseWithinValidatedBranch = (node, access) => {
|
|
12381
12537
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12382
|
-
if (current.type ===
|
|
12538
|
+
if (current.type === import_utils70.AST_NODE_TYPES.ConditionalExpression) {
|
|
12383
12539
|
const polarity = memberValidationPolarity(current.test, access);
|
|
12384
12540
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
12385
12541
|
return true;
|
|
12386
12542
|
}
|
|
12387
12543
|
}
|
|
12388
|
-
if (current.type ===
|
|
12544
|
+
if (current.type === import_utils70.AST_NODE_TYPES.IfStatement) {
|
|
12389
12545
|
const polarity = memberValidationPolarity(current.test, access);
|
|
12390
12546
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
12391
12547
|
return true;
|
|
12392
12548
|
}
|
|
12393
12549
|
}
|
|
12394
|
-
if (current.type ===
|
|
12550
|
+
if (current.type === import_utils70.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils70.AST_NODE_TYPES.FunctionExpression || current.type === import_utils70.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
12395
12551
|
return false;
|
|
12396
12552
|
}
|
|
12397
12553
|
}
|
|
12398
12554
|
return false;
|
|
12399
12555
|
};
|
|
12400
12556
|
var memberValidationPolarity = (test, access) => {
|
|
12401
|
-
if (test.type ===
|
|
12557
|
+
if (test.type === import_utils70.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
12402
12558
|
const inner = memberValidationPolarity(test.argument, access);
|
|
12403
12559
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
12404
12560
|
}
|
|
12405
|
-
if (test.type ===
|
|
12406
|
-
const isMatchingTypeof = (node) => node.type ===
|
|
12407
|
-
const isPrimitiveType = (node) => node.type ===
|
|
12561
|
+
if (test.type === import_utils70.AST_NODE_TYPES.BinaryExpression) {
|
|
12562
|
+
const isMatchingTypeof = (node) => node.type === import_utils70.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && isSamePlainMember(node.argument, access);
|
|
12563
|
+
const isPrimitiveType = (node) => node.type === import_utils70.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value);
|
|
12408
12564
|
if (!(isMatchingTypeof(test.left) && isPrimitiveType(test.right) || isMatchingTypeof(test.right) && isPrimitiveType(test.left))) {
|
|
12409
12565
|
return null;
|
|
12410
12566
|
}
|
|
@@ -12413,15 +12569,15 @@ var memberValidationPolarity = (test, access) => {
|
|
|
12413
12569
|
}
|
|
12414
12570
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
12415
12571
|
}
|
|
12416
|
-
return test.type ===
|
|
12572
|
+
return test.type === import_utils70.AST_NODE_TYPES.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== import_utils70.AST_NODE_TYPES.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === import_utils70.AST_NODE_TYPES.MemberExpression && !test.callee.computed && test.callee.object.type === import_utils70.AST_NODE_TYPES.Identifier && test.callee.object.name === "Array" && test.callee.property.type === import_utils70.AST_NODE_TYPES.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
12417
12573
|
};
|
|
12418
12574
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
12419
12575
|
const isValidationReference = (identifier) => {
|
|
12420
12576
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12421
|
-
if ((current.type ===
|
|
12577
|
+
if ((current.type === import_utils70.AST_NODE_TYPES.BinaryExpression || current.type === import_utils70.AST_NODE_TYPES.CallExpression || current.type === import_utils70.AST_NODE_TYPES.UnaryExpression) && bindingValidationPolarity(current, identifier.name) !== null) {
|
|
12422
12578
|
return true;
|
|
12423
12579
|
}
|
|
12424
|
-
if (current.type !==
|
|
12580
|
+
if (current.type !== import_utils70.AST_NODE_TYPES.UnaryExpression && current.type !== import_utils70.AST_NODE_TYPES.MemberExpression && current.type !== import_utils70.AST_NODE_TYPES.CallExpression) {
|
|
12425
12581
|
return false;
|
|
12426
12582
|
}
|
|
12427
12583
|
}
|
|
@@ -12429,7 +12585,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12429
12585
|
};
|
|
12430
12586
|
const isGuardedUse = (identifier) => {
|
|
12431
12587
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12432
|
-
if (current.type ===
|
|
12588
|
+
if (current.type === import_utils70.AST_NODE_TYPES.ConditionalExpression) {
|
|
12433
12589
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
12434
12590
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
12435
12591
|
return true;
|
|
@@ -12438,7 +12594,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12438
12594
|
return true;
|
|
12439
12595
|
}
|
|
12440
12596
|
}
|
|
12441
|
-
if (current.type ===
|
|
12597
|
+
if (current.type === import_utils70.AST_NODE_TYPES.IfStatement) {
|
|
12442
12598
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
12443
12599
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
12444
12600
|
return true;
|
|
@@ -12447,14 +12603,14 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12447
12603
|
return true;
|
|
12448
12604
|
}
|
|
12449
12605
|
}
|
|
12450
|
-
if (current.type ===
|
|
12606
|
+
if (current.type === import_utils70.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils70.AST_NODE_TYPES.FunctionExpression || current.type === import_utils70.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
12451
12607
|
return false;
|
|
12452
12608
|
}
|
|
12453
12609
|
}
|
|
12454
12610
|
return false;
|
|
12455
12611
|
};
|
|
12456
12612
|
const declarator = member.parent;
|
|
12457
|
-
if (declarator.type !==
|
|
12613
|
+
if (declarator.type !== import_utils70.AST_NODE_TYPES.VariableDeclarator || declarator.init !== member || declarator.id.type !== import_utils70.AST_NODE_TYPES.Identifier || declarator.parent.type !== import_utils70.AST_NODE_TYPES.VariableDeclaration || declarator.parent.kind !== "const") {
|
|
12458
12614
|
return false;
|
|
12459
12615
|
}
|
|
12460
12616
|
const extracted = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -12462,7 +12618,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12462
12618
|
let hasValueUse = false;
|
|
12463
12619
|
for (const reference of extracted.references) {
|
|
12464
12620
|
const identifier = reference.identifier;
|
|
12465
|
-
if (identifier.type !==
|
|
12621
|
+
if (identifier.type !== import_utils70.AST_NODE_TYPES.Identifier) return false;
|
|
12466
12622
|
if (nodeWithin2(identifier, declarator)) continue;
|
|
12467
12623
|
if (isValidationReference(identifier)) continue;
|
|
12468
12624
|
hasValueUse = true;
|
|
@@ -12475,17 +12631,17 @@ var isGuardTestPosition = (node) => {
|
|
|
12475
12631
|
let parent = current.parent;
|
|
12476
12632
|
while (parent !== void 0 && parent !== null) {
|
|
12477
12633
|
switch (parent.type) {
|
|
12478
|
-
case
|
|
12479
|
-
case
|
|
12480
|
-
case
|
|
12634
|
+
case import_utils70.AST_NODE_TYPES.UnaryExpression:
|
|
12635
|
+
case import_utils70.AST_NODE_TYPES.LogicalExpression:
|
|
12636
|
+
case import_utils70.AST_NODE_TYPES.ChainExpression:
|
|
12481
12637
|
current = parent;
|
|
12482
12638
|
parent = parent.parent;
|
|
12483
12639
|
continue;
|
|
12484
|
-
case
|
|
12485
|
-
case
|
|
12486
|
-
case
|
|
12487
|
-
case
|
|
12488
|
-
case
|
|
12640
|
+
case import_utils70.AST_NODE_TYPES.IfStatement:
|
|
12641
|
+
case import_utils70.AST_NODE_TYPES.ConditionalExpression:
|
|
12642
|
+
case import_utils70.AST_NODE_TYPES.WhileStatement:
|
|
12643
|
+
case import_utils70.AST_NODE_TYPES.DoWhileStatement:
|
|
12644
|
+
case import_utils70.AST_NODE_TYPES.ForStatement:
|
|
12489
12645
|
return parent.test === current;
|
|
12490
12646
|
default:
|
|
12491
12647
|
return false;
|
|
@@ -12495,7 +12651,7 @@ var isGuardTestPosition = (node) => {
|
|
|
12495
12651
|
};
|
|
12496
12652
|
var unvalidatedVariableRef = (node, scope, tracked) => {
|
|
12497
12653
|
const unwrapped = unwrap4(node);
|
|
12498
|
-
if (unwrapped === null || unwrapped.type !==
|
|
12654
|
+
if (unwrapped === null || unwrapped.type !== import_utils70.AST_NODE_TYPES.Identifier) {
|
|
12499
12655
|
return null;
|
|
12500
12656
|
}
|
|
12501
12657
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -12524,7 +12680,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12524
12680
|
const localFileTextVariables = /* @__PURE__ */ new Set();
|
|
12525
12681
|
const localFileTextRef = (node, scope) => {
|
|
12526
12682
|
const unwrapped = unwrap4(node);
|
|
12527
|
-
if (unwrapped?.type !==
|
|
12683
|
+
if (unwrapped?.type !== import_utils70.AST_NODE_TYPES.Identifier) return null;
|
|
12528
12684
|
const variable = findVariable2(scope, unwrapped.name);
|
|
12529
12685
|
return variable !== null && localFileTextVariables.has(variable) ? variable : null;
|
|
12530
12686
|
};
|
|
@@ -12593,7 +12749,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12593
12749
|
return {
|
|
12594
12750
|
VariableDeclarator(node) {
|
|
12595
12751
|
const scope = context.sourceCode.getScope(node);
|
|
12596
|
-
if (node.id.type ===
|
|
12752
|
+
if (node.id.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
12597
12753
|
const variable = context.sourceCode.getDeclaredVariables(node)[0];
|
|
12598
12754
|
if (variable !== void 0) {
|
|
12599
12755
|
updateLocalFileText(variable, node.init, scope);
|
|
@@ -12601,7 +12757,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12601
12757
|
trackInitializer(node, scope);
|
|
12602
12758
|
return;
|
|
12603
12759
|
}
|
|
12604
|
-
if (node.id.type ===
|
|
12760
|
+
if (node.id.type === import_utils70.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils70.AST_NODE_TYPES.ArrayPattern) {
|
|
12605
12761
|
if (isRawPayloadSource(
|
|
12606
12762
|
node.init,
|
|
12607
12763
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
@@ -12618,7 +12774,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12618
12774
|
},
|
|
12619
12775
|
AssignmentExpression(node) {
|
|
12620
12776
|
const scope = context.sourceCode.getScope(node);
|
|
12621
|
-
if (node.left.type ===
|
|
12777
|
+
if (node.left.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
12622
12778
|
const variable = findVariable2(scope, node.left.name);
|
|
12623
12779
|
if (variable === null) return;
|
|
12624
12780
|
const isLocalText = (candidate2) => localFileTextRef(candidate2, scope) !== null;
|
|
@@ -12632,7 +12788,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12632
12788
|
}
|
|
12633
12789
|
return;
|
|
12634
12790
|
}
|
|
12635
|
-
if (node.left.type ===
|
|
12791
|
+
if (node.left.type === import_utils70.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils70.AST_NODE_TYPES.ArrayPattern) {
|
|
12636
12792
|
if (isRawPayloadSource(
|
|
12637
12793
|
node.right,
|
|
12638
12794
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
@@ -12652,15 +12808,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12652
12808
|
}
|
|
12653
12809
|
},
|
|
12654
12810
|
CallExpression(node) {
|
|
12655
|
-
if (node.callee.type !==
|
|
12811
|
+
if (node.callee.type !== import_utils70.AST_NODE_TYPES.Identifier) return;
|
|
12656
12812
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
12657
12813
|
return;
|
|
12658
12814
|
}
|
|
12659
12815
|
const scope = context.sourceCode.getScope(node);
|
|
12660
12816
|
for (const arg of node.arguments) {
|
|
12661
|
-
if (arg.type ===
|
|
12817
|
+
if (arg.type === import_utils70.AST_NODE_TYPES.SpreadElement) continue;
|
|
12662
12818
|
const unwrapped = unwrap4(arg);
|
|
12663
|
-
if (unwrapped === null || unwrapped.type !==
|
|
12819
|
+
if (unwrapped === null || unwrapped.type !== import_utils70.AST_NODE_TYPES.Identifier) {
|
|
12664
12820
|
continue;
|
|
12665
12821
|
}
|
|
12666
12822
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -12677,14 +12833,14 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12677
12833
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
12678
12834
|
)) {
|
|
12679
12835
|
const parent = node.parent;
|
|
12680
|
-
if (parent.type ===
|
|
12836
|
+
if (parent.type === import_utils70.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils70.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
12681
12837
|
return;
|
|
12682
12838
|
}
|
|
12683
12839
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
12684
12840
|
return;
|
|
12685
12841
|
}
|
|
12686
|
-
const variable = obj?.type ===
|
|
12687
|
-
if (variable !== null && obj?.type ===
|
|
12842
|
+
const variable = obj?.type === import_utils70.AST_NODE_TYPES.Identifier ? unvalidatedVariableRef(obj, scope, unvalidatedVariables) : null;
|
|
12843
|
+
if (variable !== null && obj?.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
12688
12844
|
if (isUseWithinValidatedBranch(node, obj.name)) {
|
|
12689
12845
|
return;
|
|
12690
12846
|
}
|
|
@@ -12704,7 +12860,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12704
12860
|
});
|
|
12705
12861
|
|
|
12706
12862
|
// src/rules/prefer-semantic-colors.ts
|
|
12707
|
-
var
|
|
12863
|
+
var import_utils71 = require("@typescript-eslint/utils");
|
|
12708
12864
|
var import_fs = require("fs");
|
|
12709
12865
|
var import_path = require("path");
|
|
12710
12866
|
|
|
@@ -12816,7 +12972,7 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
12816
12972
|
var isInsideSvg = (node) => {
|
|
12817
12973
|
let current = node.parent;
|
|
12818
12974
|
while (current !== void 0 && current !== null) {
|
|
12819
|
-
if (current.type ===
|
|
12975
|
+
if (current.type === import_utils71.AST_NODE_TYPES.JSXElement) {
|
|
12820
12976
|
const name = jsxElementName(current);
|
|
12821
12977
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
12822
12978
|
}
|
|
@@ -12826,8 +12982,8 @@ var isInsideSvg = (node) => {
|
|
|
12826
12982
|
};
|
|
12827
12983
|
function jsxElementName(node) {
|
|
12828
12984
|
const name = node.openingElement.name;
|
|
12829
|
-
if (name.type ===
|
|
12830
|
-
if (name.type ===
|
|
12985
|
+
if (name.type === import_utils71.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
12986
|
+
if (name.type === import_utils71.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils71.AST_NODE_TYPES.JSXIdentifier) {
|
|
12831
12987
|
return name.property.name;
|
|
12832
12988
|
}
|
|
12833
12989
|
return null;
|
|
@@ -12853,7 +13009,7 @@ function isSvgLikeElementName(name) {
|
|
|
12853
13009
|
var isInsideIconFactoryPath = (node) => {
|
|
12854
13010
|
let current = node.parent;
|
|
12855
13011
|
while (current !== void 0 && current !== null) {
|
|
12856
|
-
if (current.type ===
|
|
13012
|
+
if (current.type === import_utils71.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils71.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils71.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils71.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
12857
13013
|
return true;
|
|
12858
13014
|
}
|
|
12859
13015
|
current = current.parent;
|
|
@@ -12987,12 +13143,12 @@ var expandWorkspaceGlob = (root, glob) => {
|
|
|
12987
13143
|
return (0, import_fs.readdirSync)(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => (0, import_path.join)(parent, entry.name));
|
|
12988
13144
|
};
|
|
12989
13145
|
var propName = (key) => {
|
|
12990
|
-
if (key.type ===
|
|
12991
|
-
if (key.type ===
|
|
13146
|
+
if (key.type === import_utils71.AST_NODE_TYPES.Identifier) return key.name;
|
|
13147
|
+
if (key.type === import_utils71.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
12992
13148
|
return null;
|
|
12993
13149
|
};
|
|
12994
13150
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
12995
|
-
if (statement.type !==
|
|
13151
|
+
if (statement.type !== import_utils71.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils71.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils71.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
12996
13152
|
return false;
|
|
12997
13153
|
}
|
|
12998
13154
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -13045,27 +13201,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13045
13201
|
const checkClassNode = (node) => {
|
|
13046
13202
|
if (node === null) return;
|
|
13047
13203
|
switch (node.type) {
|
|
13048
|
-
case
|
|
13204
|
+
case import_utils71.AST_NODE_TYPES.Literal:
|
|
13049
13205
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
13050
13206
|
break;
|
|
13051
|
-
case
|
|
13207
|
+
case import_utils71.AST_NODE_TYPES.TemplateLiteral:
|
|
13052
13208
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
13053
13209
|
break;
|
|
13054
|
-
case
|
|
13210
|
+
case import_utils71.AST_NODE_TYPES.ArrayExpression:
|
|
13055
13211
|
for (const element of node.elements) {
|
|
13056
|
-
if (element !== null && element.type !==
|
|
13212
|
+
if (element !== null && element.type !== import_utils71.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
13057
13213
|
}
|
|
13058
13214
|
break;
|
|
13059
|
-
case
|
|
13215
|
+
case import_utils71.AST_NODE_TYPES.ObjectExpression:
|
|
13060
13216
|
for (const property of node.properties) {
|
|
13061
|
-
if (property.type ===
|
|
13217
|
+
if (property.type === import_utils71.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
13062
13218
|
}
|
|
13063
13219
|
break;
|
|
13064
|
-
case
|
|
13220
|
+
case import_utils71.AST_NODE_TYPES.ConditionalExpression:
|
|
13065
13221
|
checkClassNode(node.consequent);
|
|
13066
13222
|
checkClassNode(node.alternate);
|
|
13067
13223
|
break;
|
|
13068
|
-
case
|
|
13224
|
+
case import_utils71.AST_NODE_TYPES.LogicalExpression:
|
|
13069
13225
|
checkClassNode(node.right);
|
|
13070
13226
|
break;
|
|
13071
13227
|
default:
|
|
@@ -13073,32 +13229,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13073
13229
|
}
|
|
13074
13230
|
};
|
|
13075
13231
|
const checkColorValueNode = (node) => {
|
|
13076
|
-
if (node.type ===
|
|
13232
|
+
if (node.type === import_utils71.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
13077
13233
|
report(node, "inlineColor", { value: node.value });
|
|
13078
13234
|
}
|
|
13079
13235
|
};
|
|
13080
13236
|
return {
|
|
13081
13237
|
"JSXAttribute[name.name='className']"(node) {
|
|
13082
13238
|
if (node.value === null) return;
|
|
13083
|
-
if (node.value.type ===
|
|
13084
|
-
else if (node.value.type ===
|
|
13085
|
-
if (node.value.expression.type !==
|
|
13239
|
+
if (node.value.type === import_utils71.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
13240
|
+
else if (node.value.type === import_utils71.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
13241
|
+
if (node.value.expression.type !== import_utils71.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
13086
13242
|
checkClassNode(node.value.expression);
|
|
13087
13243
|
}
|
|
13088
13244
|
}
|
|
13089
13245
|
},
|
|
13090
13246
|
CallExpression(node) {
|
|
13091
|
-
if (node.callee.type ===
|
|
13247
|
+
if (node.callee.type === import_utils71.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils71.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
13092
13248
|
importsEmailOrPdfRenderer = true;
|
|
13093
13249
|
}
|
|
13094
|
-
if (node.callee.type ===
|
|
13250
|
+
if (node.callee.type === import_utils71.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
13095
13251
|
for (const arg of node.arguments) {
|
|
13096
|
-
if (arg.type !==
|
|
13252
|
+
if (arg.type !== import_utils71.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
13097
13253
|
}
|
|
13098
13254
|
}
|
|
13099
13255
|
},
|
|
13100
13256
|
VariableDeclarator(node) {
|
|
13101
|
-
if (node.id.type ===
|
|
13257
|
+
if (node.id.type === import_utils71.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
13102
13258
|
checkClassNode(node.init);
|
|
13103
13259
|
}
|
|
13104
13260
|
},
|
|
@@ -13108,9 +13264,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13108
13264
|
},
|
|
13109
13265
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
13110
13266
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
13111
|
-
if (node.value?.type !==
|
|
13267
|
+
if (node.value?.type !== import_utils71.AST_NODE_TYPES.Literal) return;
|
|
13112
13268
|
const owner = node.parent.name;
|
|
13113
|
-
if (owner.type ===
|
|
13269
|
+
if (owner.type === import_utils71.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
13114
13270
|
return;
|
|
13115
13271
|
}
|
|
13116
13272
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -13124,7 +13280,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13124
13280
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
13125
13281
|
},
|
|
13126
13282
|
ImportExpression(node) {
|
|
13127
|
-
if (node.source.type ===
|
|
13283
|
+
if (node.source.type === import_utils71.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
13128
13284
|
importsEmailOrPdfRenderer = true;
|
|
13129
13285
|
}
|
|
13130
13286
|
},
|
|
@@ -13137,7 +13293,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13137
13293
|
});
|
|
13138
13294
|
|
|
13139
13295
|
// src/rules/prefer-server-actions.ts
|
|
13140
|
-
var
|
|
13296
|
+
var import_utils72 = require("@typescript-eslint/utils");
|
|
13141
13297
|
var PREFER_SERVER_ACTIONS_DOCUMENTATION = {
|
|
13142
13298
|
summary: "Prefer Next.js Server Actions over /api/* mutations.",
|
|
13143
13299
|
rationale: "Server Actions preserve typed application calls and avoid an internal JSON request-response boundary.",
|
|
@@ -13326,7 +13482,7 @@ var prefer_server_actions_default = createRule({
|
|
|
13326
13482
|
});
|
|
13327
13483
|
|
|
13328
13484
|
// src/rules/prefer-whole-object-assertion.ts
|
|
13329
|
-
var
|
|
13485
|
+
var import_utils73 = require("@typescript-eslint/utils");
|
|
13330
13486
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
13331
13487
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
13332
13488
|
["toBeNull", "null"],
|
|
@@ -13351,11 +13507,11 @@ var PREFER_WHOLE_OBJECT_ASSERTION_DOCUMENTATION = {
|
|
|
13351
13507
|
};
|
|
13352
13508
|
function literalText(node, getText) {
|
|
13353
13509
|
switch (node.type) {
|
|
13354
|
-
case
|
|
13510
|
+
case import_utils73.AST_NODE_TYPES.Literal:
|
|
13355
13511
|
return "regex" in node ? null : getText(node);
|
|
13356
|
-
case
|
|
13512
|
+
case import_utils73.AST_NODE_TYPES.TemplateLiteral:
|
|
13357
13513
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
13358
|
-
case
|
|
13514
|
+
case import_utils73.AST_NODE_TYPES.UnaryExpression:
|
|
13359
13515
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
13360
13516
|
default:
|
|
13361
13517
|
return null;
|
|
@@ -13363,15 +13519,15 @@ function literalText(node, getText) {
|
|
|
13363
13519
|
}
|
|
13364
13520
|
function isPureReceiver(node) {
|
|
13365
13521
|
switch (node.type) {
|
|
13366
|
-
case
|
|
13367
|
-
case
|
|
13522
|
+
case import_utils73.AST_NODE_TYPES.Identifier:
|
|
13523
|
+
case import_utils73.AST_NODE_TYPES.ThisExpression:
|
|
13368
13524
|
return true;
|
|
13369
|
-
case
|
|
13525
|
+
case import_utils73.AST_NODE_TYPES.MemberExpression:
|
|
13370
13526
|
if (node.optional) {
|
|
13371
13527
|
return false;
|
|
13372
13528
|
}
|
|
13373
13529
|
if (node.computed) {
|
|
13374
|
-
return node.property.type ===
|
|
13530
|
+
return node.property.type === import_utils73.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
13375
13531
|
}
|
|
13376
13532
|
return isPureReceiver(node.object);
|
|
13377
13533
|
default:
|
|
@@ -13379,7 +13535,7 @@ function isPureReceiver(node) {
|
|
|
13379
13535
|
}
|
|
13380
13536
|
}
|
|
13381
13537
|
function literalIndex(node) {
|
|
13382
|
-
if (node.type !==
|
|
13538
|
+
if (node.type !== import_utils73.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
13383
13539
|
return null;
|
|
13384
13540
|
}
|
|
13385
13541
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -13387,8 +13543,8 @@ function literalIndex(node) {
|
|
|
13387
13543
|
function propertyAccess(node) {
|
|
13388
13544
|
const path = [];
|
|
13389
13545
|
let current = node;
|
|
13390
|
-
while (current.type ===
|
|
13391
|
-
if (current.property.type !==
|
|
13546
|
+
while (current.type === import_utils73.AST_NODE_TYPES.MemberExpression && !current.computed && !current.optional) {
|
|
13547
|
+
if (current.property.type !== import_utils73.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(current.property.name) || LITERAL_KEY_HAZARDS.has(current.property.name)) return null;
|
|
13392
13548
|
path.unshift(current.property.name);
|
|
13393
13549
|
current = current.object;
|
|
13394
13550
|
}
|
|
@@ -13416,24 +13572,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
13416
13572
|
}
|
|
13417
13573
|
const { sourceCode } = context;
|
|
13418
13574
|
function parseAssertion(statement) {
|
|
13419
|
-
if (statement.type !==
|
|
13575
|
+
if (statement.type !== import_utils73.AST_NODE_TYPES.ExpressionStatement) {
|
|
13420
13576
|
return null;
|
|
13421
13577
|
}
|
|
13422
13578
|
const call = statement.expression;
|
|
13423
|
-
if (call.type !==
|
|
13579
|
+
if (call.type !== import_utils73.AST_NODE_TYPES.CallExpression) {
|
|
13424
13580
|
return null;
|
|
13425
13581
|
}
|
|
13426
13582
|
const callee = call.callee;
|
|
13427
|
-
if (callee.type !==
|
|
13583
|
+
if (callee.type !== import_utils73.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils73.AST_NODE_TYPES.Identifier) {
|
|
13428
13584
|
return null;
|
|
13429
13585
|
}
|
|
13430
13586
|
const matcher = callee.property.name;
|
|
13431
13587
|
const expectCall = callee.object;
|
|
13432
|
-
if (expectCall.type !==
|
|
13588
|
+
if (expectCall.type !== import_utils73.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils73.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
13433
13589
|
return null;
|
|
13434
13590
|
}
|
|
13435
13591
|
const actual = expectCall.arguments[0];
|
|
13436
|
-
if (actual === void 0 || actual.type !==
|
|
13592
|
+
if (actual === void 0 || actual.type !== import_utils73.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
13437
13593
|
return null;
|
|
13438
13594
|
}
|
|
13439
13595
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -13462,7 +13618,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
13462
13618
|
return null;
|
|
13463
13619
|
}
|
|
13464
13620
|
const expected = call.arguments[0];
|
|
13465
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
13621
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils73.AST_NODE_TYPES.SpreadElement) {
|
|
13466
13622
|
return null;
|
|
13467
13623
|
}
|
|
13468
13624
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -13603,7 +13759,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
13603
13759
|
});
|
|
13604
13760
|
|
|
13605
13761
|
// src/rules/repeated-static-call-cases.ts
|
|
13606
|
-
var
|
|
13762
|
+
var import_utils74 = require("@typescript-eslint/utils");
|
|
13607
13763
|
var REPEATED_STATIC_CALL_CASES_DOCUMENTATION = {
|
|
13608
13764
|
summary: "Report three or more consecutive literal call assertions that should be independently named test cases.",
|
|
13609
13765
|
rationale: "Copy-pasted cases obscure the input table and stop later cases from being reported after the first failure.",
|
|
@@ -13624,67 +13780,67 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
13624
13780
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
13625
13781
|
var MIN_CASES2 = 3;
|
|
13626
13782
|
function staticMemberName5(node) {
|
|
13627
|
-
if (!node.computed && node.property.type ===
|
|
13628
|
-
if (node.computed && node.property.type ===
|
|
13783
|
+
if (!node.computed && node.property.type === import_utils74.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
13784
|
+
if (node.computed && node.property.type === import_utils74.AST_NODE_TYPES.Literal && typeof node.property.value === "string") return node.property.value;
|
|
13629
13785
|
return null;
|
|
13630
13786
|
}
|
|
13631
13787
|
function importedName5(identifier, context, modules) {
|
|
13632
|
-
const variable =
|
|
13788
|
+
const variable = import_utils74.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
13633
13789
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
13634
13790
|
for (const definition of variable.defs) {
|
|
13635
|
-
if (definition.node.type !==
|
|
13791
|
+
if (definition.node.type !== import_utils74.AST_NODE_TYPES.ImportSpecifier) continue;
|
|
13636
13792
|
const declaration = definition.node.parent;
|
|
13637
|
-
if (declaration.type !==
|
|
13793
|
+
if (declaration.type !== import_utils74.AST_NODE_TYPES.ImportDeclaration || typeof declaration.source.value !== "string" || !modules.has(declaration.source.value)) continue;
|
|
13638
13794
|
const imported = definition.node.imported;
|
|
13639
|
-
return imported.type ===
|
|
13795
|
+
return imported.type === import_utils74.AST_NODE_TYPES.Identifier ? imported.name : String(imported.value);
|
|
13640
13796
|
}
|
|
13641
13797
|
return null;
|
|
13642
13798
|
}
|
|
13643
13799
|
function isDirectTestCallback2(node, context) {
|
|
13644
|
-
if (node.type !==
|
|
13800
|
+
if (node.type !== import_utils74.AST_NODE_TYPES.ArrowFunctionExpression && node.type !== import_utils74.AST_NODE_TYPES.FunctionExpression) return false;
|
|
13645
13801
|
const call = node.parent;
|
|
13646
|
-
if (call?.type !==
|
|
13802
|
+
if (call?.type !== import_utils74.AST_NODE_TYPES.CallExpression || !call.arguments.includes(node)) return false;
|
|
13647
13803
|
const root = testRoot2(call.callee);
|
|
13648
13804
|
return root !== null && TEST_NAMES2.has(importedName5(root, context, TEST_MODULES4) ?? "");
|
|
13649
13805
|
}
|
|
13650
13806
|
function testRoot2(callee) {
|
|
13651
|
-
if (callee.type ===
|
|
13652
|
-
if (callee.type !==
|
|
13807
|
+
if (callee.type === import_utils74.AST_NODE_TYPES.Identifier) return callee;
|
|
13808
|
+
if (callee.type !== import_utils74.AST_NODE_TYPES.MemberExpression) return null;
|
|
13653
13809
|
const modifier = staticMemberName5(callee);
|
|
13654
13810
|
return modifier !== null && TEST_MODIFIERS4.has(modifier) ? testRoot2(callee.object) : null;
|
|
13655
13811
|
}
|
|
13656
13812
|
function isStatic(node) {
|
|
13657
|
-
if (node.type ===
|
|
13813
|
+
if (node.type === import_utils74.AST_NODE_TYPES.TSAsExpression || node.type === import_utils74.AST_NODE_TYPES.TSTypeAssertion || node.type === import_utils74.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils74.AST_NODE_TYPES.TSNonNullExpression) return isStatic(node.expression);
|
|
13658
13814
|
switch (node.type) {
|
|
13659
|
-
case
|
|
13815
|
+
case import_utils74.AST_NODE_TYPES.Literal:
|
|
13660
13816
|
return true;
|
|
13661
|
-
case
|
|
13817
|
+
case import_utils74.AST_NODE_TYPES.TemplateLiteral:
|
|
13662
13818
|
return node.expressions.length === 0;
|
|
13663
|
-
case
|
|
13819
|
+
case import_utils74.AST_NODE_TYPES.UnaryExpression:
|
|
13664
13820
|
return (node.operator === "+" || node.operator === "-") && isStatic(node.argument);
|
|
13665
|
-
case
|
|
13666
|
-
return node.elements.every((item) => item !== null && item.type !==
|
|
13667
|
-
case
|
|
13668
|
-
return node.properties.every((property) => property.type ===
|
|
13821
|
+
case import_utils74.AST_NODE_TYPES.ArrayExpression:
|
|
13822
|
+
return node.elements.every((item) => item !== null && item.type !== import_utils74.AST_NODE_TYPES.SpreadElement && isStatic(item));
|
|
13823
|
+
case import_utils74.AST_NODE_TYPES.ObjectExpression:
|
|
13824
|
+
return node.properties.every((property) => property.type === import_utils74.AST_NODE_TYPES.Property && !property.computed && property.kind === "init" && property.value.type !== import_utils74.AST_NODE_TYPES.AssignmentPattern && isStatic(property.value));
|
|
13669
13825
|
default:
|
|
13670
13826
|
return false;
|
|
13671
13827
|
}
|
|
13672
13828
|
}
|
|
13673
13829
|
function staticShape(node) {
|
|
13674
|
-
if (node.type ===
|
|
13830
|
+
if (node.type === import_utils74.AST_NODE_TYPES.TSAsExpression || node.type === import_utils74.AST_NODE_TYPES.TSTypeAssertion || node.type === import_utils74.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils74.AST_NODE_TYPES.TSNonNullExpression) return staticShape(node.expression);
|
|
13675
13831
|
switch (node.type) {
|
|
13676
|
-
case
|
|
13832
|
+
case import_utils74.AST_NODE_TYPES.Literal:
|
|
13677
13833
|
return `literal:${typeof node.value}`;
|
|
13678
|
-
case
|
|
13834
|
+
case import_utils74.AST_NODE_TYPES.TemplateLiteral:
|
|
13679
13835
|
return "template";
|
|
13680
|
-
case
|
|
13836
|
+
case import_utils74.AST_NODE_TYPES.UnaryExpression:
|
|
13681
13837
|
return `unary:${node.operator}:${staticShape(node.argument)}`;
|
|
13682
|
-
case
|
|
13683
|
-
return `array(${node.elements.map((item) => item === null || item.type ===
|
|
13684
|
-
case
|
|
13838
|
+
case import_utils74.AST_NODE_TYPES.ArrayExpression:
|
|
13839
|
+
return `array(${node.elements.map((item) => item === null || item.type === import_utils74.AST_NODE_TYPES.SpreadElement ? "invalid" : staticShape(item)).join(",")})`;
|
|
13840
|
+
case import_utils74.AST_NODE_TYPES.ObjectExpression:
|
|
13685
13841
|
return `object(${node.properties.map((property) => {
|
|
13686
|
-
if (property.type !==
|
|
13687
|
-
const key = property.key.type ===
|
|
13842
|
+
if (property.type !== import_utils74.AST_NODE_TYPES.Property || property.computed || property.value.type === import_utils74.AST_NODE_TYPES.AssignmentPattern) return "invalid";
|
|
13843
|
+
const key = property.key.type === import_utils74.AST_NODE_TYPES.Identifier ? property.key.name : String(property.key.value);
|
|
13688
13844
|
return `${key}:${staticShape(property.value)}`;
|
|
13689
13845
|
}).join(",")})`;
|
|
13690
13846
|
default:
|
|
@@ -13692,16 +13848,16 @@ function staticShape(node) {
|
|
|
13692
13848
|
}
|
|
13693
13849
|
}
|
|
13694
13850
|
function assertionShape(statement, context) {
|
|
13695
|
-
if (statement.type !==
|
|
13851
|
+
if (statement.type !== import_utils74.AST_NODE_TYPES.ExpressionStatement || statement.expression.type !== import_utils74.AST_NODE_TYPES.CallExpression) return null;
|
|
13696
13852
|
const matcherCall = statement.expression;
|
|
13697
|
-
if (matcherCall.callee.type !==
|
|
13853
|
+
if (matcherCall.callee.type !== import_utils74.AST_NODE_TYPES.MemberExpression || matcherCall.callee.computed || matcherCall.callee.property.type !== import_utils74.AST_NODE_TYPES.Identifier || matcherCall.arguments.length !== 1) return null;
|
|
13698
13854
|
const matcher = matcherCall.callee.property.name;
|
|
13699
13855
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
13700
13856
|
const chain = expectCallFromMatcher(matcherCall.callee);
|
|
13701
|
-
if (chain === null || chain.call.callee.type !==
|
|
13857
|
+
if (chain === null || chain.call.callee.type !== import_utils74.AST_NODE_TYPES.Identifier || importedName5(chain.call.callee, context, ASSERTION_MODULES3) !== "expect" || chain.call.arguments.length !== 1) return null;
|
|
13702
13858
|
const observed = chain.call.arguments[0];
|
|
13703
13859
|
const expected = matcherCall.arguments[0];
|
|
13704
|
-
if (observed?.type !==
|
|
13860
|
+
if (observed?.type !== import_utils74.AST_NODE_TYPES.CallExpression || observed.callee.type !== import_utils74.AST_NODE_TYPES.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === import_utils74.AST_NODE_TYPES.SpreadElement || !isStatic(arg)) || expected?.type === import_utils74.AST_NODE_TYPES.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
13705
13861
|
const skeleton = `${observed.callee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
13706
13862
|
const values = [...observed.arguments, expected].map((item) => context.sourceCode.getText(item)).join("\0");
|
|
13707
13863
|
return { statement, skeleton, values };
|
|
@@ -13709,13 +13865,13 @@ function assertionShape(statement, context) {
|
|
|
13709
13865
|
function expectCallFromMatcher(node) {
|
|
13710
13866
|
const modifiers = [];
|
|
13711
13867
|
let receiver = node.object;
|
|
13712
|
-
while (receiver.type ===
|
|
13868
|
+
while (receiver.type === import_utils74.AST_NODE_TYPES.MemberExpression) {
|
|
13713
13869
|
const modifier = staticMemberName5(receiver);
|
|
13714
13870
|
if (modifier === null || !EXPECT_MODIFIERS.has(modifier)) return null;
|
|
13715
13871
|
modifiers.unshift(modifier);
|
|
13716
13872
|
receiver = receiver.object;
|
|
13717
13873
|
}
|
|
13718
|
-
return receiver.type ===
|
|
13874
|
+
return receiver.type === import_utils74.AST_NODE_TYPES.CallExpression ? { call: receiver, modifiers } : null;
|
|
13719
13875
|
}
|
|
13720
13876
|
var repeated_static_call_cases_default = createRule({
|
|
13721
13877
|
name: "repeated-static-call-cases",
|
|
@@ -13735,7 +13891,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
13735
13891
|
return {
|
|
13736
13892
|
"CallExpression > ArrowFunctionExpression, CallExpression > FunctionExpression"(node) {
|
|
13737
13893
|
const call = node.parent;
|
|
13738
|
-
if (call?.type ===
|
|
13894
|
+
if (call?.type === import_utils74.AST_NODE_TYPES.CallExpression) {
|
|
13739
13895
|
const duplicate = duplicateTestBodyCandidate(call, sourceCode);
|
|
13740
13896
|
if (duplicate !== null && duplicate.body === node) {
|
|
13741
13897
|
const groups = duplicateGroups.get(duplicate.container) ?? /* @__PURE__ */ new Map();
|
|
@@ -13745,7 +13901,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
13745
13901
|
duplicateGroups.set(duplicate.container, groups);
|
|
13746
13902
|
}
|
|
13747
13903
|
}
|
|
13748
|
-
if (!isDirectTestCallback2(node, context) || node.body.type !==
|
|
13904
|
+
if (!isDirectTestCallback2(node, context) || node.body.type !== import_utils74.AST_NODE_TYPES.BlockStatement) return;
|
|
13749
13905
|
let run = [];
|
|
13750
13906
|
const flush = () => {
|
|
13751
13907
|
if (run.length >= MIN_CASES2 && new Set(run.map((item) => item.values)).size > 1) {
|
|
@@ -13786,7 +13942,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
13786
13942
|
});
|
|
13787
13943
|
|
|
13788
13944
|
// src/rules/prefer-zod-infer.ts
|
|
13789
|
-
var
|
|
13945
|
+
var import_utils75 = require("@typescript-eslint/utils");
|
|
13790
13946
|
var PREFER_ZOD_INFER_DOCUMENTATION = {
|
|
13791
13947
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
13792
13948
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -13839,47 +13995,47 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
13839
13995
|
"Schema"
|
|
13840
13996
|
]);
|
|
13841
13997
|
var LEAF_NODE_TYPES = {
|
|
13842
|
-
string: [
|
|
13843
|
-
email: [
|
|
13844
|
-
url: [
|
|
13845
|
-
uuid: [
|
|
13846
|
-
ulid: [
|
|
13847
|
-
cuid: [
|
|
13848
|
-
cuid2: [
|
|
13849
|
-
nanoid: [
|
|
13850
|
-
iso: [
|
|
13851
|
-
number: [
|
|
13852
|
-
int: [
|
|
13853
|
-
float32: [
|
|
13854
|
-
float64: [
|
|
13855
|
-
boolean: [
|
|
13856
|
-
bigint: [
|
|
13857
|
-
symbol: [
|
|
13858
|
-
any: [
|
|
13859
|
-
unknown: [
|
|
13860
|
-
never: [
|
|
13861
|
-
void: [
|
|
13862
|
-
null: [
|
|
13863
|
-
undefined: [
|
|
13864
|
-
literal: [
|
|
13865
|
-
date: [
|
|
13866
|
-
array: [
|
|
13867
|
-
tuple: [
|
|
13868
|
-
object: [
|
|
13869
|
-
strictObject: [
|
|
13870
|
-
looseObject: [
|
|
13871
|
-
record: [
|
|
13872
|
-
map: [
|
|
13873
|
-
set: [
|
|
13874
|
-
promise: [
|
|
13875
|
-
enum: [
|
|
13876
|
-
nativeEnum: [
|
|
13877
|
-
union: [
|
|
13878
|
-
discriminatedUnion: [
|
|
13879
|
-
intersection: [
|
|
13998
|
+
string: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
13999
|
+
email: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
14000
|
+
url: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
14001
|
+
uuid: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
14002
|
+
ulid: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
14003
|
+
cuid: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
14004
|
+
cuid2: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
14005
|
+
nanoid: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
14006
|
+
iso: [import_utils75.AST_NODE_TYPES.TSStringKeyword],
|
|
14007
|
+
number: [import_utils75.AST_NODE_TYPES.TSNumberKeyword],
|
|
14008
|
+
int: [import_utils75.AST_NODE_TYPES.TSNumberKeyword],
|
|
14009
|
+
float32: [import_utils75.AST_NODE_TYPES.TSNumberKeyword],
|
|
14010
|
+
float64: [import_utils75.AST_NODE_TYPES.TSNumberKeyword],
|
|
14011
|
+
boolean: [import_utils75.AST_NODE_TYPES.TSBooleanKeyword],
|
|
14012
|
+
bigint: [import_utils75.AST_NODE_TYPES.TSBigIntKeyword],
|
|
14013
|
+
symbol: [import_utils75.AST_NODE_TYPES.TSSymbolKeyword],
|
|
14014
|
+
any: [import_utils75.AST_NODE_TYPES.TSAnyKeyword],
|
|
14015
|
+
unknown: [import_utils75.AST_NODE_TYPES.TSUnknownKeyword],
|
|
14016
|
+
never: [import_utils75.AST_NODE_TYPES.TSNeverKeyword],
|
|
14017
|
+
void: [import_utils75.AST_NODE_TYPES.TSVoidKeyword],
|
|
14018
|
+
null: [import_utils75.AST_NODE_TYPES.TSNullKeyword],
|
|
14019
|
+
undefined: [import_utils75.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
14020
|
+
literal: [import_utils75.AST_NODE_TYPES.TSLiteralType],
|
|
14021
|
+
date: [import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14022
|
+
array: [import_utils75.AST_NODE_TYPES.TSArrayType, import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14023
|
+
tuple: [import_utils75.AST_NODE_TYPES.TSTupleType],
|
|
14024
|
+
object: [import_utils75.AST_NODE_TYPES.TSTypeLiteral, import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14025
|
+
strictObject: [import_utils75.AST_NODE_TYPES.TSTypeLiteral, import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14026
|
+
looseObject: [import_utils75.AST_NODE_TYPES.TSTypeLiteral, import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14027
|
+
record: [import_utils75.AST_NODE_TYPES.TSTypeReference, import_utils75.AST_NODE_TYPES.TSTypeLiteral],
|
|
14028
|
+
map: [import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14029
|
+
set: [import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14030
|
+
promise: [import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14031
|
+
enum: [import_utils75.AST_NODE_TYPES.TSUnionType, import_utils75.AST_NODE_TYPES.TSTypeReference, import_utils75.AST_NODE_TYPES.TSLiteralType],
|
|
14032
|
+
nativeEnum: [import_utils75.AST_NODE_TYPES.TSUnionType, import_utils75.AST_NODE_TYPES.TSTypeReference, import_utils75.AST_NODE_TYPES.TSLiteralType],
|
|
14033
|
+
union: [import_utils75.AST_NODE_TYPES.TSUnionType, import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14034
|
+
discriminatedUnion: [import_utils75.AST_NODE_TYPES.TSUnionType, import_utils75.AST_NODE_TYPES.TSTypeReference],
|
|
14035
|
+
intersection: [import_utils75.AST_NODE_TYPES.TSIntersectionType, import_utils75.AST_NODE_TYPES.TSTypeReference]
|
|
13880
14036
|
};
|
|
13881
14037
|
function primitiveLiteralKey(node) {
|
|
13882
|
-
if (node.type !==
|
|
14038
|
+
if (node.type !== import_utils75.AST_NODE_TYPES.Literal) {
|
|
13883
14039
|
return null;
|
|
13884
14040
|
}
|
|
13885
14041
|
if (node.value === null) {
|
|
@@ -13911,13 +14067,13 @@ function staticZodDomain(leaf, call) {
|
|
|
13911
14067
|
}
|
|
13912
14068
|
if (leaf === "literal") {
|
|
13913
14069
|
const [argument] = call.arguments;
|
|
13914
|
-
if (argument === void 0 || argument.type ===
|
|
14070
|
+
if (argument === void 0 || argument.type === import_utils75.AST_NODE_TYPES.SpreadElement) {
|
|
13915
14071
|
return null;
|
|
13916
14072
|
}
|
|
13917
|
-
if (argument.type ===
|
|
14073
|
+
if (argument.type === import_utils75.AST_NODE_TYPES.ArrayExpression) {
|
|
13918
14074
|
return exactDomain(
|
|
13919
14075
|
argument.elements.map(
|
|
13920
|
-
(element) => element === null || element.type ===
|
|
14076
|
+
(element) => element === null || element.type === import_utils75.AST_NODE_TYPES.SpreadElement ? null : primitiveLiteralKey(element)
|
|
13921
14077
|
)
|
|
13922
14078
|
);
|
|
13923
14079
|
}
|
|
@@ -13925,13 +14081,13 @@ function staticZodDomain(leaf, call) {
|
|
|
13925
14081
|
}
|
|
13926
14082
|
if (leaf === "enum") {
|
|
13927
14083
|
const [argument] = call.arguments;
|
|
13928
|
-
if (argument === void 0 || argument.type ===
|
|
14084
|
+
if (argument === void 0 || argument.type === import_utils75.AST_NODE_TYPES.SpreadElement) {
|
|
13929
14085
|
return null;
|
|
13930
14086
|
}
|
|
13931
|
-
if (argument.type ===
|
|
14087
|
+
if (argument.type === import_utils75.AST_NODE_TYPES.ArrayExpression) {
|
|
13932
14088
|
return exactDomain(
|
|
13933
14089
|
argument.elements.map((element) => {
|
|
13934
|
-
if (element === null || element.type ===
|
|
14090
|
+
if (element === null || element.type === import_utils75.AST_NODE_TYPES.SpreadElement) {
|
|
13935
14091
|
return null;
|
|
13936
14092
|
}
|
|
13937
14093
|
const key = primitiveLiteralKey(element);
|
|
@@ -13939,10 +14095,10 @@ function staticZodDomain(leaf, call) {
|
|
|
13939
14095
|
})
|
|
13940
14096
|
);
|
|
13941
14097
|
}
|
|
13942
|
-
if (argument.type ===
|
|
14098
|
+
if (argument.type === import_utils75.AST_NODE_TYPES.ObjectExpression) {
|
|
13943
14099
|
return exactDomain(
|
|
13944
14100
|
argument.properties.map((property) => {
|
|
13945
|
-
if (property.type !==
|
|
14101
|
+
if (property.type !== import_utils75.AST_NODE_TYPES.Property || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
13946
14102
|
return null;
|
|
13947
14103
|
}
|
|
13948
14104
|
const key = primitiveLiteralKey(property.value);
|
|
@@ -13969,15 +14125,15 @@ function sameDomain(left, right) {
|
|
|
13969
14125
|
return true;
|
|
13970
14126
|
}
|
|
13971
14127
|
function isExportedDeclaration(node) {
|
|
13972
|
-
return node.parent?.type ===
|
|
14128
|
+
return node.parent?.type === import_utils75.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
13973
14129
|
}
|
|
13974
14130
|
function isModuleLevelConst(node) {
|
|
13975
14131
|
const declaration = node.parent;
|
|
13976
|
-
if (declaration.type !==
|
|
14132
|
+
if (declaration.type !== import_utils75.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const") {
|
|
13977
14133
|
return false;
|
|
13978
14134
|
}
|
|
13979
14135
|
const container = declaration.parent;
|
|
13980
|
-
return container.type ===
|
|
14136
|
+
return container.type === import_utils75.AST_NODE_TYPES.Program || container.type === import_utils75.AST_NODE_TYPES.ExportNamedDeclaration && container.parent.type === import_utils75.AST_NODE_TYPES.Program;
|
|
13981
14137
|
}
|
|
13982
14138
|
function normalizeSchemaName(name) {
|
|
13983
14139
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -13986,20 +14142,20 @@ function normalizeTypeName(name) {
|
|
|
13986
14142
|
return name.replace(/Type$/, "").toLowerCase();
|
|
13987
14143
|
}
|
|
13988
14144
|
function unwrapNullish(annotation) {
|
|
13989
|
-
if (annotation.type !==
|
|
14145
|
+
if (annotation.type !== import_utils75.AST_NODE_TYPES.TSUnionType) {
|
|
13990
14146
|
return {
|
|
13991
14147
|
core: annotation,
|
|
13992
|
-
nullable: annotation.type ===
|
|
14148
|
+
nullable: annotation.type === import_utils75.AST_NODE_TYPES.TSNullKeyword
|
|
13993
14149
|
};
|
|
13994
14150
|
}
|
|
13995
14151
|
const rest = [];
|
|
13996
14152
|
let nullable = false;
|
|
13997
14153
|
for (const member of annotation.types) {
|
|
13998
|
-
if (member.type ===
|
|
14154
|
+
if (member.type === import_utils75.AST_NODE_TYPES.TSNullKeyword) {
|
|
13999
14155
|
nullable = true;
|
|
14000
14156
|
continue;
|
|
14001
14157
|
}
|
|
14002
|
-
if (member.type ===
|
|
14158
|
+
if (member.type === import_utils75.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
14003
14159
|
continue;
|
|
14004
14160
|
}
|
|
14005
14161
|
rest.push(member);
|
|
@@ -14033,18 +14189,18 @@ function leafAgrees(field, annotation) {
|
|
|
14033
14189
|
return null;
|
|
14034
14190
|
}
|
|
14035
14191
|
if (leaf === "date") {
|
|
14036
|
-
return core.type ===
|
|
14192
|
+
return core.type === import_utils75.AST_NODE_TYPES.TSTypeReference && core.typeName.type === import_utils75.AST_NODE_TYPES.Identifier && core.typeName.name === "Date";
|
|
14037
14193
|
}
|
|
14038
14194
|
return expected.includes(core.type);
|
|
14039
14195
|
}
|
|
14040
14196
|
function typeLiteralDomain(annotation) {
|
|
14041
|
-
const members = annotation.type ===
|
|
14197
|
+
const members = annotation.type === import_utils75.AST_NODE_TYPES.TSUnionType ? annotation.types : [annotation];
|
|
14042
14198
|
const keys = [];
|
|
14043
14199
|
for (const member of members) {
|
|
14044
|
-
if (member.type ===
|
|
14200
|
+
if (member.type === import_utils75.AST_NODE_TYPES.TSNullKeyword) {
|
|
14045
14201
|
continue;
|
|
14046
14202
|
}
|
|
14047
|
-
if (member.type !==
|
|
14203
|
+
if (member.type !== import_utils75.AST_NODE_TYPES.TSLiteralType) {
|
|
14048
14204
|
return null;
|
|
14049
14205
|
}
|
|
14050
14206
|
keys.push(primitiveLiteralKey(member.literal));
|
|
@@ -14052,11 +14208,11 @@ function typeLiteralDomain(annotation) {
|
|
|
14052
14208
|
return exactDomain(keys);
|
|
14053
14209
|
}
|
|
14054
14210
|
function staticStringUnionDomain(node) {
|
|
14055
|
-
if (node.type !==
|
|
14211
|
+
if (node.type !== import_utils75.AST_NODE_TYPES.TSUnionType) {
|
|
14056
14212
|
return null;
|
|
14057
14213
|
}
|
|
14058
14214
|
const keys = node.types.map((member) => {
|
|
14059
|
-
if (member.type !==
|
|
14215
|
+
if (member.type !== import_utils75.AST_NODE_TYPES.TSLiteralType) {
|
|
14060
14216
|
return null;
|
|
14061
14217
|
}
|
|
14062
14218
|
const key = primitiveLiteralKey(member.literal);
|
|
@@ -14124,14 +14280,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14124
14280
|
function zodCallChain(node) {
|
|
14125
14281
|
const chain = [];
|
|
14126
14282
|
let current = node;
|
|
14127
|
-
while (current.type ===
|
|
14283
|
+
while (current.type === import_utils75.AST_NODE_TYPES.CallExpression) {
|
|
14128
14284
|
const callee = current.callee;
|
|
14129
|
-
if (callee.type !==
|
|
14285
|
+
if (callee.type !== import_utils75.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils75.AST_NODE_TYPES.Identifier) {
|
|
14130
14286
|
return null;
|
|
14131
14287
|
}
|
|
14132
14288
|
chain.push(current);
|
|
14133
14289
|
const receiver = callee.object;
|
|
14134
|
-
if (receiver.type ===
|
|
14290
|
+
if (receiver.type === import_utils75.AST_NODE_TYPES.Identifier) {
|
|
14135
14291
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
14136
14292
|
}
|
|
14137
14293
|
current = receiver;
|
|
@@ -14140,14 +14296,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14140
14296
|
}
|
|
14141
14297
|
function methodName2(call) {
|
|
14142
14298
|
const callee = call.callee;
|
|
14143
|
-
return callee.type ===
|
|
14299
|
+
return callee.type === import_utils75.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils75.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
14144
14300
|
}
|
|
14145
14301
|
function recordZodImport(node) {
|
|
14146
14302
|
if (!isZodModule(node.source.value)) {
|
|
14147
14303
|
return;
|
|
14148
14304
|
}
|
|
14149
14305
|
for (const specifier of node.specifiers) {
|
|
14150
|
-
if (specifier.type ===
|
|
14306
|
+
if (specifier.type === import_utils75.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils75.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils75.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils75.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
14151
14307
|
zodNamespaces.add(specifier.local.name);
|
|
14152
14308
|
}
|
|
14153
14309
|
}
|
|
@@ -14157,13 +14313,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
14157
14313
|
let current = node;
|
|
14158
14314
|
let leaf = null;
|
|
14159
14315
|
let leafCall = null;
|
|
14160
|
-
while (current.type ===
|
|
14316
|
+
while (current.type === import_utils75.AST_NODE_TYPES.CallExpression) {
|
|
14161
14317
|
const callee = current.callee;
|
|
14162
|
-
if (callee.type !==
|
|
14318
|
+
if (callee.type !== import_utils75.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils75.AST_NODE_TYPES.Identifier) {
|
|
14163
14319
|
break;
|
|
14164
14320
|
}
|
|
14165
14321
|
const receiver = callee.object;
|
|
14166
|
-
if (receiver.type ===
|
|
14322
|
+
if (receiver.type === import_utils75.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
14167
14323
|
leaf = callee.property.name;
|
|
14168
14324
|
leafCall = current;
|
|
14169
14325
|
break;
|
|
@@ -14194,20 +14350,20 @@ var prefer_zod_infer_default = createRule({
|
|
|
14194
14350
|
return domain instanceof Set && domain.size >= 2 ? domain : null;
|
|
14195
14351
|
}
|
|
14196
14352
|
function inferredSchemaName(node) {
|
|
14197
|
-
if (node.type !==
|
|
14353
|
+
if (node.type !== import_utils75.AST_NODE_TYPES.TSTypeReference || node.typeName.type !== import_utils75.AST_NODE_TYPES.TSQualifiedName || node.typeName.left.type !== import_utils75.AST_NODE_TYPES.Identifier || !zodNamespaces.has(node.typeName.left.name) || node.typeName.right.name !== "infer") {
|
|
14198
14354
|
return null;
|
|
14199
14355
|
}
|
|
14200
14356
|
const arguments_ = node.typeArguments?.params ?? [];
|
|
14201
14357
|
const [argument] = arguments_;
|
|
14202
|
-
return arguments_.length === 1 && argument?.type ===
|
|
14358
|
+
return arguments_.length === 1 && argument?.type === import_utils75.AST_NODE_TYPES.TSTypeQuery && argument.exprName.type === import_utils75.AST_NODE_TYPES.Identifier ? argument.exprName.name : null;
|
|
14203
14359
|
}
|
|
14204
14360
|
function recordLiteralUnions(members, owner, ownerName, exported) {
|
|
14205
14361
|
for (const member of members) {
|
|
14206
|
-
if (member.type !==
|
|
14362
|
+
if (member.type !== import_utils75.AST_NODE_TYPES.TSPropertySignature || member.computed || member.optional || member.readonly || member.typeAnnotation === void 0) {
|
|
14207
14363
|
continue;
|
|
14208
14364
|
}
|
|
14209
14365
|
const key = member.key;
|
|
14210
|
-
const propertyName5 = key.type ===
|
|
14366
|
+
const propertyName5 = key.type === import_utils75.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils75.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
14211
14367
|
if (propertyName5 === null) {
|
|
14212
14368
|
continue;
|
|
14213
14369
|
}
|
|
@@ -14217,7 +14373,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14217
14373
|
}
|
|
14218
14374
|
const annotation = member.typeAnnotation.typeAnnotation;
|
|
14219
14375
|
const domain = staticStringUnionDomain(annotation);
|
|
14220
|
-
if (domain === null || annotation.type !==
|
|
14376
|
+
if (domain === null || annotation.type !== import_utils75.AST_NODE_TYPES.TSUnionType) {
|
|
14221
14377
|
continue;
|
|
14222
14378
|
}
|
|
14223
14379
|
literalUnionOccurrences.push({
|
|
@@ -14248,16 +14404,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
14248
14404
|
return null;
|
|
14249
14405
|
}
|
|
14250
14406
|
const shape = base.arguments[0];
|
|
14251
|
-
if (shape === void 0 || shape.type !==
|
|
14407
|
+
if (shape === void 0 || shape.type !== import_utils75.AST_NODE_TYPES.ObjectExpression) {
|
|
14252
14408
|
return null;
|
|
14253
14409
|
}
|
|
14254
14410
|
const fields = /* @__PURE__ */ new Map();
|
|
14255
14411
|
for (const property of shape.properties) {
|
|
14256
|
-
if (property.type !==
|
|
14412
|
+
if (property.type !== import_utils75.AST_NODE_TYPES.Property || property.computed) {
|
|
14257
14413
|
return null;
|
|
14258
14414
|
}
|
|
14259
14415
|
const { key } = property;
|
|
14260
|
-
const name = key.type ===
|
|
14416
|
+
const name = key.type === import_utils75.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils75.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
14261
14417
|
if (name === null) {
|
|
14262
14418
|
return null;
|
|
14263
14419
|
}
|
|
@@ -14268,11 +14424,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
14268
14424
|
function typeMembers(members) {
|
|
14269
14425
|
const result = /* @__PURE__ */ new Map();
|
|
14270
14426
|
for (const member of members) {
|
|
14271
|
-
if (member.type !==
|
|
14427
|
+
if (member.type !== import_utils75.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
14272
14428
|
return null;
|
|
14273
14429
|
}
|
|
14274
14430
|
const { key } = member;
|
|
14275
|
-
const name = key.type ===
|
|
14431
|
+
const name = key.type === import_utils75.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils75.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
14276
14432
|
if (name === null) {
|
|
14277
14433
|
return null;
|
|
14278
14434
|
}
|
|
@@ -14287,8 +14443,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
14287
14443
|
return result.size === 0 ? null : result;
|
|
14288
14444
|
}
|
|
14289
14445
|
function collectConstrainedNames(node) {
|
|
14290
|
-
if (node.type ===
|
|
14291
|
-
if (node.typeName.type ===
|
|
14446
|
+
if (node.type === import_utils75.AST_NODE_TYPES.TSTypeReference) {
|
|
14447
|
+
if (node.typeName.type === import_utils75.AST_NODE_TYPES.Identifier) {
|
|
14292
14448
|
constrainedTypeNames.add(node.typeName.name);
|
|
14293
14449
|
}
|
|
14294
14450
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -14296,11 +14452,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
14296
14452
|
}
|
|
14297
14453
|
return;
|
|
14298
14454
|
}
|
|
14299
|
-
if (node.type ===
|
|
14455
|
+
if (node.type === import_utils75.AST_NODE_TYPES.TSArrayType) {
|
|
14300
14456
|
collectConstrainedNames(node.elementType);
|
|
14301
14457
|
return;
|
|
14302
14458
|
}
|
|
14303
|
-
if (node.type ===
|
|
14459
|
+
if (node.type === import_utils75.AST_NODE_TYPES.TSUnionType || node.type === import_utils75.AST_NODE_TYPES.TSIntersectionType) {
|
|
14304
14460
|
for (const member of node.types) {
|
|
14305
14461
|
collectConstrainedNames(member);
|
|
14306
14462
|
}
|
|
@@ -14344,7 +14500,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14344
14500
|
return {
|
|
14345
14501
|
Program(node) {
|
|
14346
14502
|
for (const statement of node.body) {
|
|
14347
|
-
if (statement.type ===
|
|
14503
|
+
if (statement.type === import_utils75.AST_NODE_TYPES.ImportDeclaration) {
|
|
14348
14504
|
recordZodImport(statement);
|
|
14349
14505
|
}
|
|
14350
14506
|
}
|
|
@@ -14353,7 +14509,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14353
14509
|
recordZodImport(node);
|
|
14354
14510
|
},
|
|
14355
14511
|
VariableDeclarator(node) {
|
|
14356
|
-
if (node.id.type !==
|
|
14512
|
+
if (node.id.type !== import_utils75.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
14357
14513
|
return;
|
|
14358
14514
|
}
|
|
14359
14515
|
const fields = schemaFields(node.init);
|
|
@@ -14370,14 +14526,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14370
14526
|
},
|
|
14371
14527
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
14372
14528
|
"MemberExpression[computed=false]"(node) {
|
|
14373
|
-
if (node.object.type ===
|
|
14529
|
+
if (node.object.type === import_utils75.AST_NODE_TYPES.Identifier && node.property.type === import_utils75.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
14374
14530
|
reshapedSchemaNames.add(node.object.name);
|
|
14375
14531
|
}
|
|
14376
14532
|
},
|
|
14377
14533
|
/** Records every type argument carried by a Zod constraint. */
|
|
14378
14534
|
TSTypeReference(node) {
|
|
14379
14535
|
const { typeName } = node;
|
|
14380
|
-
const referenced = typeName.type ===
|
|
14536
|
+
const referenced = typeName.type === import_utils75.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils75.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils75.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
14381
14537
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
14382
14538
|
return;
|
|
14383
14539
|
}
|
|
@@ -14409,7 +14565,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14409
14565
|
typeName: node.id.name
|
|
14410
14566
|
});
|
|
14411
14567
|
}
|
|
14412
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
14568
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils75.AST_NODE_TYPES.TSTypeLiteral) {
|
|
14413
14569
|
return;
|
|
14414
14570
|
}
|
|
14415
14571
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -14508,8 +14664,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
14508
14664
|
});
|
|
14509
14665
|
|
|
14510
14666
|
// src/rules/require-assert-never.ts
|
|
14511
|
-
var
|
|
14512
|
-
var
|
|
14667
|
+
var import_utils76 = require("@typescript-eslint/utils");
|
|
14668
|
+
var import_typescript2 = __toESM(require("typescript"), 1);
|
|
14513
14669
|
var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
14514
14670
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
14515
14671
|
rationale: "An empty default silently accepts new union members instead of making the compiler identify the missing case.",
|
|
@@ -14521,14 +14677,14 @@ var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
|
14521
14677
|
]
|
|
14522
14678
|
};
|
|
14523
14679
|
var isRuntimeHandlingStatement = (statement) => {
|
|
14524
|
-
if (statement.type ===
|
|
14525
|
-
if (statement.type ===
|
|
14680
|
+
if (statement.type === import_utils76.AST_NODE_TYPES.EmptyStatement) return false;
|
|
14681
|
+
if (statement.type === import_utils76.AST_NODE_TYPES.BreakStatement) {
|
|
14526
14682
|
return statement.label !== null;
|
|
14527
14683
|
}
|
|
14528
|
-
if (statement.type ===
|
|
14684
|
+
if (statement.type === import_utils76.AST_NODE_TYPES.TSTypeAliasDeclaration || statement.type === import_utils76.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
14529
14685
|
return false;
|
|
14530
14686
|
}
|
|
14531
|
-
if (statement.type ===
|
|
14687
|
+
if (statement.type === import_utils76.AST_NODE_TYPES.BlockStatement) {
|
|
14532
14688
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
14533
14689
|
}
|
|
14534
14690
|
return true;
|
|
@@ -14544,7 +14700,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
14544
14700
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
14545
14701
|
}
|
|
14546
14702
|
const only = defaultCase.consequent[0];
|
|
14547
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
14703
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils76.AST_NODE_TYPES.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
14548
14704
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
14549
14705
|
}
|
|
14550
14706
|
return false;
|
|
@@ -14556,7 +14712,7 @@ function isExhaustiveFiniteSwitch(node, services) {
|
|
|
14556
14712
|
const constituents = discriminantType.isUnion() ? discriminantType.types : [discriminantType];
|
|
14557
14713
|
if (!discriminantType.isUnion() || constituents.length < 2) return false;
|
|
14558
14714
|
if (constituents.every(
|
|
14559
|
-
(constituent) => (constituent.flags &
|
|
14715
|
+
(constituent) => (constituent.flags & import_typescript2.default.TypeFlags.BooleanLiteral) !== 0
|
|
14560
14716
|
)) {
|
|
14561
14717
|
return false;
|
|
14562
14718
|
}
|
|
@@ -14580,7 +14736,7 @@ function isExhaustiveFiniteSwitch(node, services) {
|
|
|
14580
14736
|
return [...expected].every((key) => handled.has(key));
|
|
14581
14737
|
}
|
|
14582
14738
|
function finiteTypeKey(type, checker) {
|
|
14583
|
-
const finiteFlags =
|
|
14739
|
+
const finiteFlags = import_typescript2.default.TypeFlags.StringLiteral | import_typescript2.default.TypeFlags.NumberLiteral | import_typescript2.default.TypeFlags.BooleanLiteral | import_typescript2.default.TypeFlags.EnumLiteral | import_typescript2.default.TypeFlags.UniqueESSymbol | import_typescript2.default.TypeFlags.Null | import_typescript2.default.TypeFlags.Undefined;
|
|
14584
14740
|
return (type.flags & finiteFlags) !== 0 ? checker.typeToString(type) : null;
|
|
14585
14741
|
}
|
|
14586
14742
|
var require_assert_never_default = createRule({
|
|
@@ -14600,7 +14756,7 @@ var require_assert_never_default = createRule({
|
|
|
14600
14756
|
create(context) {
|
|
14601
14757
|
let services;
|
|
14602
14758
|
try {
|
|
14603
|
-
services =
|
|
14759
|
+
services = import_utils76.ESLintUtils.getParserServices(context);
|
|
14604
14760
|
} catch {
|
|
14605
14761
|
services = null;
|
|
14606
14762
|
}
|
|
@@ -14627,7 +14783,7 @@ var require_assert_never_default = createRule({
|
|
|
14627
14783
|
});
|
|
14628
14784
|
|
|
14629
14785
|
// src/rules/require-fetch-timeout.ts
|
|
14630
|
-
var
|
|
14786
|
+
var import_utils77 = require("@typescript-eslint/utils");
|
|
14631
14787
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
14632
14788
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
14633
14789
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -14653,14 +14809,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
14653
14809
|
return false;
|
|
14654
14810
|
}
|
|
14655
14811
|
function initProvablyLacksSignal(init) {
|
|
14656
|
-
if (init.type !==
|
|
14812
|
+
if (init.type !== import_utils77.AST_NODE_TYPES.ObjectExpression) {
|
|
14657
14813
|
return false;
|
|
14658
14814
|
}
|
|
14659
14815
|
for (const prop of init.properties) {
|
|
14660
|
-
if (prop.type ===
|
|
14816
|
+
if (prop.type === import_utils77.AST_NODE_TYPES.SpreadElement) {
|
|
14661
14817
|
return false;
|
|
14662
14818
|
}
|
|
14663
|
-
if (prop.key.type ===
|
|
14819
|
+
if (prop.key.type === import_utils77.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils77.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
14664
14820
|
return false;
|
|
14665
14821
|
}
|
|
14666
14822
|
if (prop.computed) {
|
|
@@ -14670,7 +14826,7 @@ function initProvablyLacksSignal(init) {
|
|
|
14670
14826
|
return true;
|
|
14671
14827
|
}
|
|
14672
14828
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
14673
|
-
return node.type ===
|
|
14829
|
+
return node.type === import_utils77.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils77.AST_NODE_TYPES.TemplateLiteral || node.type === import_utils77.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils77.AST_NODE_TYPES.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
14674
14830
|
}
|
|
14675
14831
|
var require_fetch_timeout_default = createRule({
|
|
14676
14832
|
name: "require-fetch-timeout",
|
|
@@ -14708,30 +14864,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
14708
14864
|
}
|
|
14709
14865
|
function resolvesToGlobal(identifier) {
|
|
14710
14866
|
const scope = context.sourceCode.getScope(identifier);
|
|
14711
|
-
const variable =
|
|
14867
|
+
const variable = import_utils77.ASTUtils.findVariable(scope, identifier.name);
|
|
14712
14868
|
return variable === null || variable.defs.length === 0;
|
|
14713
14869
|
}
|
|
14714
14870
|
function isGlobalFetchCall2(callee) {
|
|
14715
|
-
if (callee.type ===
|
|
14871
|
+
if (callee.type === import_utils77.AST_NODE_TYPES.Identifier) {
|
|
14716
14872
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
14717
14873
|
}
|
|
14718
|
-
return callee.type ===
|
|
14874
|
+
return callee.type === import_utils77.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils77.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils77.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
14719
14875
|
}
|
|
14720
14876
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
14721
|
-
const variable =
|
|
14877
|
+
const variable = import_utils77.ASTUtils.findVariable(
|
|
14722
14878
|
context.sourceCode.getScope(identifier),
|
|
14723
14879
|
identifier.name
|
|
14724
14880
|
);
|
|
14725
14881
|
if (variable?.defs.length !== 1) return false;
|
|
14726
14882
|
const definition = variable.defs[0];
|
|
14727
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
14883
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== import_utils77.AST_NODE_TYPES.ObjectExpression || !initProvablyLacksSignal(definition.node.init)) {
|
|
14728
14884
|
return false;
|
|
14729
14885
|
}
|
|
14730
14886
|
for (const reference of variable.references) {
|
|
14731
14887
|
const ref = reference.identifier;
|
|
14732
14888
|
if (ref === identifier || ref === definition.name) continue;
|
|
14733
14889
|
const member = ref.parent;
|
|
14734
|
-
if (member.type !==
|
|
14890
|
+
if (member.type !== import_utils77.AST_NODE_TYPES.MemberExpression || member.object !== ref || member.computed || member.property.type !== import_utils77.AST_NODE_TYPES.Identifier || member.property.name === "signal" || member.parent.type !== import_utils77.AST_NODE_TYPES.AssignmentExpression || member.parent.left !== member) {
|
|
14735
14891
|
return false;
|
|
14736
14892
|
}
|
|
14737
14893
|
}
|
|
@@ -14746,7 +14902,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
14746
14902
|
if (node.arguments.length === 1 && first !== void 0 && !isInlineUrl(first, resolvesToGlobal)) {
|
|
14747
14903
|
return;
|
|
14748
14904
|
}
|
|
14749
|
-
if (init === void 0 || initProvablyLacksSignal(init) || init.type ===
|
|
14905
|
+
if (init === void 0 || initProvablyLacksSignal(init) || init.type === import_utils77.AST_NODE_TYPES.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
14750
14906
|
context.report({ node, messageId: "missingSignal" });
|
|
14751
14907
|
}
|
|
14752
14908
|
}
|
|
@@ -14755,7 +14911,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
14755
14911
|
});
|
|
14756
14912
|
|
|
14757
14913
|
// src/rules/require-port-for-service.ts
|
|
14758
|
-
var
|
|
14914
|
+
var import_utils78 = require("@typescript-eslint/utils");
|
|
14759
14915
|
var REQUIRE_PORT_FOR_SERVICE_DOCUMENTATION = {
|
|
14760
14916
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
14761
14917
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -14780,45 +14936,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
14780
14936
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
14781
14937
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
14782
14938
|
var staticMemberName6 = (member) => {
|
|
14783
|
-
if (member.property.type ===
|
|
14784
|
-
if (!member.computed && member.property.type ===
|
|
14785
|
-
return member.computed && member.property.type ===
|
|
14939
|
+
if (member.property.type === import_utils78.AST_NODE_TYPES.PrivateIdentifier) return `#${member.property.name}`;
|
|
14940
|
+
if (!member.computed && member.property.type === import_utils78.AST_NODE_TYPES.Identifier) return member.property.name;
|
|
14941
|
+
return member.computed && member.property.type === import_utils78.AST_NODE_TYPES.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
14786
14942
|
};
|
|
14787
14943
|
var detachedValueExports = (program) => {
|
|
14788
14944
|
const names = /* @__PURE__ */ new Set();
|
|
14789
14945
|
for (const statement of program.body) {
|
|
14790
|
-
if (statement.type ===
|
|
14946
|
+
if (statement.type === import_utils78.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
14791
14947
|
for (const specifier of statement.specifiers) {
|
|
14792
14948
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
14793
14949
|
}
|
|
14794
|
-
} else if (statement.type ===
|
|
14950
|
+
} else if (statement.type === import_utils78.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils78.AST_NODE_TYPES.Identifier) {
|
|
14795
14951
|
names.add(statement.declaration.name);
|
|
14796
|
-
} else if (statement.type ===
|
|
14952
|
+
} else if (statement.type === import_utils78.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils78.AST_NODE_TYPES.Identifier) {
|
|
14797
14953
|
names.add(statement.expression.name);
|
|
14798
14954
|
}
|
|
14799
14955
|
}
|
|
14800
14956
|
return names;
|
|
14801
14957
|
};
|
|
14802
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
14958
|
+
var isExportedClass2 = (node, detached) => node.parent.type === import_utils78.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils78.AST_NODE_TYPES.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
14803
14959
|
var readTypeReference = (annotation) => {
|
|
14804
|
-
if (annotation?.type ===
|
|
14960
|
+
if (annotation?.type === import_utils78.AST_NODE_TYPES.TSUnionType) {
|
|
14805
14961
|
const members = annotation.types.filter(
|
|
14806
|
-
(member) => member.type !==
|
|
14962
|
+
(member) => member.type !== import_utils78.AST_NODE_TYPES.TSUndefinedKeyword && member.type !== import_utils78.AST_NODE_TYPES.TSNullKeyword
|
|
14807
14963
|
);
|
|
14808
14964
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
14809
14965
|
}
|
|
14810
|
-
if (annotation === void 0 || annotation.type !==
|
|
14966
|
+
if (annotation === void 0 || annotation.type !== import_utils78.AST_NODE_TYPES.TSTypeReference) return null;
|
|
14811
14967
|
const { typeName } = annotation;
|
|
14812
|
-
const rightmost = typeName.type ===
|
|
14968
|
+
const rightmost = typeName.type === import_utils78.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils78.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
14813
14969
|
if (rightmost === null) return null;
|
|
14814
14970
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
14815
14971
|
};
|
|
14816
|
-
var qualifiedName = (name) => name.type ===
|
|
14972
|
+
var qualifiedName = (name) => name.type === import_utils78.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils78.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
14817
14973
|
var propertySignatureTypes = (members) => {
|
|
14818
14974
|
const types = /* @__PURE__ */ new Map();
|
|
14819
14975
|
for (const member of members) {
|
|
14820
|
-
if (member.type !==
|
|
14821
|
-
if (member.computed || member.key.type !==
|
|
14976
|
+
if (member.type !== import_utils78.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
14977
|
+
if (member.computed || member.key.type !== import_utils78.AST_NODE_TYPES.Identifier) continue;
|
|
14822
14978
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
14823
14979
|
if (reference === null) continue;
|
|
14824
14980
|
types.set(member.key.name, reference);
|
|
@@ -14829,18 +14985,18 @@ var fileTypeIndex = (program) => {
|
|
|
14829
14985
|
const objects = /* @__PURE__ */ new Map();
|
|
14830
14986
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
14831
14987
|
for (const statement of program.body) {
|
|
14832
|
-
const declaration = statement.type ===
|
|
14833
|
-
if (declaration?.type ===
|
|
14988
|
+
const declaration = statement.type === import_utils78.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14989
|
+
if (declaration?.type === import_utils78.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
14834
14990
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
14835
14991
|
continue;
|
|
14836
14992
|
}
|
|
14837
|
-
if (declaration?.type !==
|
|
14993
|
+
if (declaration?.type !== import_utils78.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
14838
14994
|
const aliased = declaration.typeAnnotation;
|
|
14839
|
-
if (aliased.type ===
|
|
14995
|
+
if (aliased.type === import_utils78.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils78.AST_NODE_TYPES.TSConstructorType) {
|
|
14840
14996
|
functionAliases.add(declaration.id.name);
|
|
14841
14997
|
continue;
|
|
14842
14998
|
}
|
|
14843
|
-
const literals = aliased.type ===
|
|
14999
|
+
const literals = aliased.type === import_utils78.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils78.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils78.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
14844
15000
|
if (literals.length === 0) continue;
|
|
14845
15001
|
const merged = /* @__PURE__ */ new Map();
|
|
14846
15002
|
for (const literal of literals) {
|
|
@@ -14869,10 +15025,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14869
15025
|
while (pending.length > 0) {
|
|
14870
15026
|
const current = pending.pop();
|
|
14871
15027
|
if (current === void 0) break;
|
|
14872
|
-
if (current.type ===
|
|
14873
|
-
const expression = current.type ===
|
|
14874
|
-
const storedField = expression?.type ===
|
|
14875
|
-
if (expression?.type !==
|
|
15028
|
+
if (current.type === import_utils78.AST_NODE_TYPES.ArrowFunctionExpression || current.type === import_utils78.AST_NODE_TYPES.FunctionExpression || current.type === import_utils78.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils78.AST_NODE_TYPES.ClassExpression || current.type === import_utils78.AST_NODE_TYPES.ClassDeclaration) continue;
|
|
15029
|
+
const expression = current.type === import_utils78.AST_NODE_TYPES.ExpressionStatement ? current.expression : null;
|
|
15030
|
+
const storedField = expression?.type === import_utils78.AST_NODE_TYPES.AssignmentExpression && expression.left.type === import_utils78.AST_NODE_TYPES.MemberExpression && expression.left.object.type === import_utils78.AST_NODE_TYPES.ThisExpression ? staticMemberName6(expression.left) : null;
|
|
15031
|
+
if (expression?.type !== import_utils78.AST_NODE_TYPES.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== import_utils78.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils78.AST_NODE_TYPES.ThisExpression || storedField === null) {
|
|
14876
15032
|
for (const key of Object.keys(current)) {
|
|
14877
15033
|
if (key === "parent") continue;
|
|
14878
15034
|
const value = current[key];
|
|
@@ -14885,14 +15041,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14885
15041
|
continue;
|
|
14886
15042
|
}
|
|
14887
15043
|
let source = expression.right;
|
|
14888
|
-
while (source.type ===
|
|
14889
|
-
if (source.type ===
|
|
15044
|
+
while (source.type === import_utils78.AST_NODE_TYPES.TSNonNullExpression || source.type === import_utils78.AST_NODE_TYPES.TSAsExpression || source.type === import_utils78.AST_NODE_TYPES.TSSatisfiesExpression || source.type === import_utils78.AST_NODE_TYPES.TSTypeAssertion) source = source.expression;
|
|
15045
|
+
if (source.type === import_utils78.AST_NODE_TYPES.NewExpression) {
|
|
14890
15046
|
constructedFields += 1;
|
|
14891
|
-
} else if (source.type ===
|
|
15047
|
+
} else if (source.type === import_utils78.AST_NODE_TYPES.Identifier) {
|
|
14892
15048
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
14893
15049
|
fields.add(storedField);
|
|
14894
15050
|
storedFieldsFrom.set(source.name, fields);
|
|
14895
|
-
} else if (source.type ===
|
|
15051
|
+
} else if (source.type === import_utils78.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils78.AST_NODE_TYPES.Identifier) {
|
|
14896
15052
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
14897
15053
|
fields.add(storedField);
|
|
14898
15054
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -14910,7 +15066,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14910
15066
|
const collaborators = [];
|
|
14911
15067
|
for (const parameter of ctor.value.params) {
|
|
14912
15068
|
for (const reference of parameterCollaborators(parameter, declared, storedMemberFieldsFrom)) {
|
|
14913
|
-
const fields = parameter.type ===
|
|
15069
|
+
const fields = parameter.type === import_utils78.AST_NODE_TYPES.TSParameterProperty ? [reference.name] : reference.fields.length > 0 ? reference.fields : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
14914
15070
|
if (fields.length === 0) continue;
|
|
14915
15071
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
14916
15072
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -14925,8 +15081,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14925
15081
|
};
|
|
14926
15082
|
var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
14927
15083
|
let target = parameter;
|
|
14928
|
-
if (target.type ===
|
|
14929
|
-
if (target.type ===
|
|
15084
|
+
if (target.type === import_utils78.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15085
|
+
if (target.type === import_utils78.AST_NODE_TYPES.ObjectPattern) {
|
|
14930
15086
|
return objectPatternCollaborators(target, declared);
|
|
14931
15087
|
}
|
|
14932
15088
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -14935,9 +15091,9 @@ var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
|
14935
15091
|
};
|
|
14936
15092
|
var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
14937
15093
|
let target = annotated;
|
|
14938
|
-
if (target.type ===
|
|
14939
|
-
if (target.type ===
|
|
14940
|
-
if (target.type !==
|
|
15094
|
+
if (target.type === import_utils78.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
15095
|
+
if (target.type === import_utils78.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15096
|
+
if (target.type !== import_utils78.AST_NODE_TYPES.Identifier) return [];
|
|
14941
15097
|
const members = bagMemberTypes(target.typeAnnotation?.typeAnnotation, declared);
|
|
14942
15098
|
if (members === null) return [];
|
|
14943
15099
|
const storedMembers = storedMemberFieldsFrom.get(target.name);
|
|
@@ -14953,9 +15109,9 @@ var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
|
14953
15109
|
};
|
|
14954
15110
|
var namedParameterCollaborator = (annotated) => {
|
|
14955
15111
|
let target = annotated;
|
|
14956
|
-
if (target.type ===
|
|
14957
|
-
if (target.type ===
|
|
14958
|
-
if (target.type !==
|
|
15112
|
+
if (target.type === import_utils78.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
15113
|
+
if (target.type === import_utils78.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
15114
|
+
if (target.type !== import_utils78.AST_NODE_TYPES.Identifier) return null;
|
|
14959
15115
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
14960
15116
|
if (reference === null) return null;
|
|
14961
15117
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -14967,11 +15123,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
14967
15123
|
if (members === null) return [];
|
|
14968
15124
|
const collaborators = [];
|
|
14969
15125
|
for (const property of pattern.properties) {
|
|
14970
|
-
if (property.type !==
|
|
14971
|
-
if (property.key.type !==
|
|
15126
|
+
if (property.type !== import_utils78.AST_NODE_TYPES.Property || property.computed) continue;
|
|
15127
|
+
if (property.key.type !== import_utils78.AST_NODE_TYPES.Identifier) continue;
|
|
14972
15128
|
const key = property.key.name;
|
|
14973
|
-
const bound = property.value.type ===
|
|
14974
|
-
if (bound.type !==
|
|
15129
|
+
const bound = property.value.type === import_utils78.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
15130
|
+
if (bound.type !== import_utils78.AST_NODE_TYPES.Identifier) continue;
|
|
14975
15131
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
14976
15132
|
const reference = members.get(key);
|
|
14977
15133
|
if (reference === void 0) continue;
|
|
@@ -14981,21 +15137,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
14981
15137
|
};
|
|
14982
15138
|
var bagMemberTypes = (annotation, declared) => {
|
|
14983
15139
|
if (annotation === void 0) return null;
|
|
14984
|
-
if (annotation.type ===
|
|
15140
|
+
if (annotation.type === import_utils78.AST_NODE_TYPES.TSTypeLiteral) {
|
|
14985
15141
|
return propertySignatureTypes(annotation.members);
|
|
14986
15142
|
}
|
|
14987
|
-
if (annotation.type !==
|
|
15143
|
+
if (annotation.type !== import_utils78.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils78.AST_NODE_TYPES.Identifier) {
|
|
14988
15144
|
return null;
|
|
14989
15145
|
}
|
|
14990
15146
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
14991
15147
|
};
|
|
14992
15148
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
14993
|
-
if (node.type ===
|
|
15149
|
+
if (node.type === import_utils78.AST_NODE_TYPES.CallExpression) {
|
|
14994
15150
|
const { callee } = node;
|
|
14995
|
-
if (callee.type ===
|
|
14996
|
-
return callee.type ===
|
|
15151
|
+
if (callee.type === import_utils78.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
15152
|
+
return callee.type === import_utils78.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils78.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
14997
15153
|
}
|
|
14998
|
-
return node.type ===
|
|
15154
|
+
return node.type === import_utils78.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils78.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
14999
15155
|
});
|
|
15000
15156
|
var subtreeHas = (root, found) => {
|
|
15001
15157
|
let hit = false;
|
|
@@ -15022,19 +15178,19 @@ var invokedInstanceField = (call) => {
|
|
|
15022
15178
|
const direct = instanceField(call.callee);
|
|
15023
15179
|
if (direct !== null) return direct;
|
|
15024
15180
|
let callee = call.callee;
|
|
15025
|
-
while (callee.type ===
|
|
15026
|
-
return callee.type ===
|
|
15181
|
+
while (callee.type === import_utils78.AST_NODE_TYPES.ChainExpression || callee.type === import_utils78.AST_NODE_TYPES.TSAsExpression || callee.type === import_utils78.AST_NODE_TYPES.TSNonNullExpression || callee.type === import_utils78.AST_NODE_TYPES.TSSatisfiesExpression || callee.type === import_utils78.AST_NODE_TYPES.TSTypeAssertion) callee = callee.expression;
|
|
15182
|
+
return callee.type === import_utils78.AST_NODE_TYPES.MemberExpression ? instanceField(callee.object) : null;
|
|
15027
15183
|
};
|
|
15028
15184
|
var instanceField = (candidate2) => {
|
|
15029
15185
|
let node = candidate2;
|
|
15030
|
-
while (node.type ===
|
|
15031
|
-
return node.type ===
|
|
15186
|
+
while (node.type === import_utils78.AST_NODE_TYPES.ChainExpression || node.type === import_utils78.AST_NODE_TYPES.TSAsExpression || node.type === import_utils78.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils78.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils78.AST_NODE_TYPES.TSTypeAssertion) node = node.expression;
|
|
15187
|
+
return node.type === import_utils78.AST_NODE_TYPES.MemberExpression && node.object.type === import_utils78.AST_NODE_TYPES.ThisExpression ? staticMemberName6(node) : null;
|
|
15032
15188
|
};
|
|
15033
15189
|
var behaviorallyInvokedFields = (body2) => {
|
|
15034
15190
|
const invoked = /* @__PURE__ */ new Set();
|
|
15035
15191
|
const visit = (current) => {
|
|
15036
|
-
if (current.type ===
|
|
15037
|
-
if (current.type ===
|
|
15192
|
+
if (current.type === import_utils78.AST_NODE_TYPES.ClassDeclaration || current.type === import_utils78.AST_NODE_TYPES.ClassExpression || current.type === import_utils78.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils78.AST_NODE_TYPES.FunctionExpression) return;
|
|
15193
|
+
if (current.type === import_utils78.AST_NODE_TYPES.CallExpression) {
|
|
15038
15194
|
const field = invokedInstanceField(current);
|
|
15039
15195
|
if (field !== null) invoked.add(field);
|
|
15040
15196
|
}
|
|
@@ -15047,14 +15203,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
15047
15203
|
}
|
|
15048
15204
|
};
|
|
15049
15205
|
for (const member of body2.body) {
|
|
15050
|
-
if (member.type ===
|
|
15051
|
-
if (member.type ===
|
|
15206
|
+
if (member.type === import_utils78.AST_NODE_TYPES.StaticBlock || member.static) continue;
|
|
15207
|
+
if (member.type === import_utils78.AST_NODE_TYPES.MethodDefinition) {
|
|
15052
15208
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
15053
15209
|
continue;
|
|
15054
15210
|
}
|
|
15055
|
-
if (member.type !==
|
|
15211
|
+
if (member.type !== import_utils78.AST_NODE_TYPES.PropertyDefinition || member.value === null) continue;
|
|
15056
15212
|
visit(
|
|
15057
|
-
member.value.type ===
|
|
15213
|
+
member.value.type === import_utils78.AST_NODE_TYPES.ArrowFunctionExpression ? member.value.body : member.value
|
|
15058
15214
|
);
|
|
15059
15215
|
}
|
|
15060
15216
|
return invoked;
|
|
@@ -15074,25 +15230,25 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
15074
15230
|
var fileInterfaceNames = (program) => {
|
|
15075
15231
|
const names = [];
|
|
15076
15232
|
for (const statement of program.body) {
|
|
15077
|
-
const declaration = statement.type ===
|
|
15078
|
-
if (declaration?.type ===
|
|
15233
|
+
const declaration = statement.type === import_utils78.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15234
|
+
if (declaration?.type === import_utils78.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
15079
15235
|
}
|
|
15080
15236
|
return names;
|
|
15081
15237
|
};
|
|
15082
15238
|
var publicMethodNames = (body2, functionAliases) => {
|
|
15083
15239
|
const names = [];
|
|
15084
15240
|
for (const member of body2.body) {
|
|
15085
|
-
if (member.type ===
|
|
15241
|
+
if (member.type === import_utils78.AST_NODE_TYPES.PropertyDefinition) {
|
|
15086
15242
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
15087
|
-
if (member.value?.type !==
|
|
15088
|
-
names.push(member.key.type ===
|
|
15243
|
+
if (member.value?.type !== import_utils78.AST_NODE_TYPES.ArrowFunctionExpression && member.value?.type !== import_utils78.AST_NODE_TYPES.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== import_utils78.AST_NODE_TYPES.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === import_utils78.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils78.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
15244
|
+
names.push(member.key.type === import_utils78.AST_NODE_TYPES.Identifier ? member.key.name : "\u2026");
|
|
15089
15245
|
continue;
|
|
15090
15246
|
}
|
|
15091
|
-
if (member.type !==
|
|
15247
|
+
if (member.type !== import_utils78.AST_NODE_TYPES.MethodDefinition) continue;
|
|
15092
15248
|
if (member.kind !== "method" || member.static) continue;
|
|
15093
15249
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
15094
|
-
if (member.key.type ===
|
|
15095
|
-
if (member.key.type ===
|
|
15250
|
+
if (member.key.type === import_utils78.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
15251
|
+
if (member.key.type === import_utils78.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
15096
15252
|
else names.push("\u2026");
|
|
15097
15253
|
}
|
|
15098
15254
|
return names;
|
|
@@ -15100,13 +15256,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
15100
15256
|
var isFluentConstructionObject = (node, getText) => {
|
|
15101
15257
|
if (node.id === null) return false;
|
|
15102
15258
|
const methods = node.body.body.filter(
|
|
15103
|
-
(member) => member.type ===
|
|
15259
|
+
(member) => member.type === import_utils78.AST_NODE_TYPES.MethodDefinition && member.kind === "method" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.value.body !== null
|
|
15104
15260
|
);
|
|
15105
15261
|
if (methods.length === 0) return false;
|
|
15106
15262
|
return methods.every((member) => {
|
|
15107
15263
|
const result = member.value.returnType?.typeAnnotation;
|
|
15108
15264
|
if (result === void 0) return false;
|
|
15109
|
-
const returnsOwnType = result.type ===
|
|
15265
|
+
const returnsOwnType = result.type === import_utils78.AST_NODE_TYPES.TSTypeReference && result.typeName.type === import_utils78.AST_NODE_TYPES.Identifier && result.typeName.name === node.id?.name;
|
|
15110
15266
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
15111
15267
|
});
|
|
15112
15268
|
};
|
|
@@ -15114,10 +15270,10 @@ function localClassAbstractness(program) {
|
|
|
15114
15270
|
const classes = /* @__PURE__ */ new Map();
|
|
15115
15271
|
const parents = /* @__PURE__ */ new Map();
|
|
15116
15272
|
for (const statement of program.body) {
|
|
15117
|
-
const declaration = statement.type ===
|
|
15118
|
-
if (declaration?.type ===
|
|
15273
|
+
const declaration = statement.type === import_utils78.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils78.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
15274
|
+
if (declaration?.type === import_utils78.AST_NODE_TYPES.ClassDeclaration && declaration.id !== null) {
|
|
15119
15275
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
15120
|
-
if (declaration.superClass?.type ===
|
|
15276
|
+
if (declaration.superClass?.type === import_utils78.AST_NODE_TYPES.Identifier) {
|
|
15121
15277
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
15122
15278
|
}
|
|
15123
15279
|
}
|
|
@@ -15139,43 +15295,43 @@ function localInterfaceSurfaces(program) {
|
|
|
15139
15295
|
const parents = /* @__PURE__ */ new Map();
|
|
15140
15296
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
15141
15297
|
for (const statement of program.body) {
|
|
15142
|
-
const declaration = statement.type ===
|
|
15143
|
-
if (declaration?.type ===
|
|
15298
|
+
const declaration = statement.type === import_utils78.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15299
|
+
if (declaration?.type === import_utils78.AST_NODE_TYPES.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === import_utils78.AST_NODE_TYPES.TSFunctionType || declaration.typeAnnotation.type === import_utils78.AST_NODE_TYPES.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
15144
15300
|
}
|
|
15145
15301
|
for (const statement of program.body) {
|
|
15146
|
-
const declaration = statement.type ===
|
|
15147
|
-
if (declaration?.type ===
|
|
15302
|
+
const declaration = statement.type === import_utils78.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15303
|
+
if (declaration?.type === import_utils78.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
15148
15304
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
15149
|
-
const parts = declaration.typeAnnotation.type ===
|
|
15305
|
+
const parts = declaration.typeAnnotation.type === import_utils78.AST_NODE_TYPES.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
15150
15306
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
15151
15307
|
for (const part of parts) {
|
|
15152
|
-
if (part.type ===
|
|
15308
|
+
if (part.type === import_utils78.AST_NODE_TYPES.TSTypeReference && part.typeName.type === import_utils78.AST_NODE_TYPES.Identifier) {
|
|
15153
15309
|
inherited.push(part.typeName.name);
|
|
15154
15310
|
continue;
|
|
15155
15311
|
}
|
|
15156
|
-
if (part.type !==
|
|
15312
|
+
if (part.type !== import_utils78.AST_NODE_TYPES.TSTypeLiteral) continue;
|
|
15157
15313
|
for (const member of part.members) {
|
|
15158
|
-
if (member.type !==
|
|
15159
|
-
if (member.computed || member.key.type !==
|
|
15160
|
-
if (member.type ===
|
|
15314
|
+
if (member.type !== import_utils78.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils78.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15315
|
+
if (member.computed || member.key.type !== import_utils78.AST_NODE_TYPES.Identifier) continue;
|
|
15316
|
+
if (member.type === import_utils78.AST_NODE_TYPES.TSMethodSignature) {
|
|
15161
15317
|
callables2.add(member.key.name);
|
|
15162
15318
|
continue;
|
|
15163
15319
|
}
|
|
15164
|
-
if (member.type !==
|
|
15320
|
+
if (member.type !== import_utils78.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15165
15321
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
15166
|
-
if (annotation?.type ===
|
|
15322
|
+
if (annotation?.type === import_utils78.AST_NODE_TYPES.TSFunctionType || annotation?.type === import_utils78.AST_NODE_TYPES.TSTypeReference && annotation.typeName.type === import_utils78.AST_NODE_TYPES.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(member.key.name);
|
|
15167
15323
|
}
|
|
15168
15324
|
}
|
|
15169
15325
|
interfaces.set(declaration.id.name, callables2);
|
|
15170
15326
|
parents.set(declaration.id.name, inherited);
|
|
15171
15327
|
continue;
|
|
15172
15328
|
}
|
|
15173
|
-
if (declaration?.type !==
|
|
15329
|
+
if (declaration?.type !== import_utils78.AST_NODE_TYPES.TSInterfaceDeclaration) continue;
|
|
15174
15330
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
15175
15331
|
for (const member of declaration.body.body) {
|
|
15176
|
-
if (member.type !==
|
|
15177
|
-
if (member.computed || member.key.type !==
|
|
15178
|
-
if (member.type ===
|
|
15332
|
+
if (member.type !== import_utils78.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils78.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
15333
|
+
if (member.computed || member.key.type !== import_utils78.AST_NODE_TYPES.Identifier) continue;
|
|
15334
|
+
if (member.type === import_utils78.AST_NODE_TYPES.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === import_utils78.AST_NODE_TYPES.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === import_utils78.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils78.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(member.key.name);
|
|
15179
15335
|
}
|
|
15180
15336
|
interfaces.set(declaration.id.name, callables);
|
|
15181
15337
|
parents.set(
|
|
@@ -15183,7 +15339,7 @@ function localInterfaceSurfaces(program) {
|
|
|
15183
15339
|
[
|
|
15184
15340
|
...parents.get(declaration.id.name) ?? [],
|
|
15185
15341
|
...declaration.extends.flatMap(
|
|
15186
|
-
(heritage) => heritage.expression.type ===
|
|
15342
|
+
(heritage) => heritage.expression.type === import_utils78.AST_NODE_TYPES.Identifier ? [heritage.expression.name] : ["*"]
|
|
15187
15343
|
)
|
|
15188
15344
|
]
|
|
15189
15345
|
);
|
|
@@ -15210,7 +15366,7 @@ function localInterfaceSurfaces(program) {
|
|
|
15210
15366
|
}
|
|
15211
15367
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
15212
15368
|
if (node.superClass !== null) {
|
|
15213
|
-
if (node.superClass.type !==
|
|
15369
|
+
if (node.superClass.type !== import_utils78.AST_NODE_TYPES.Identifier) return true;
|
|
15214
15370
|
const localAbstract = classes.get(node.superClass.name);
|
|
15215
15371
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
15216
15372
|
}
|
|
@@ -15222,7 +15378,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
15222
15378
|
if (node.implements.length === 0) return false;
|
|
15223
15379
|
const combined = /* @__PURE__ */ new Set();
|
|
15224
15380
|
for (const implementation of node.implements) {
|
|
15225
|
-
if (implementation.expression.type !==
|
|
15381
|
+
if (implementation.expression.type !== import_utils78.AST_NODE_TYPES.Identifier) return true;
|
|
15226
15382
|
const name = implementation.expression.name;
|
|
15227
15383
|
const localAbstract = classes.get(name);
|
|
15228
15384
|
if (localAbstract === true) return true;
|
|
@@ -15265,7 +15421,7 @@ var require_port_for_service_default = createRule({
|
|
|
15265
15421
|
if (node.abstract === true) return;
|
|
15266
15422
|
if (node.decorators.length > 0) return;
|
|
15267
15423
|
const ctor = node.body.body.find(
|
|
15268
|
-
(member) => member.type ===
|
|
15424
|
+
(member) => member.type === import_utils78.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
15269
15425
|
);
|
|
15270
15426
|
if (ctor === void 0) return;
|
|
15271
15427
|
const constructorFacts = readConstructor(
|
|
@@ -15300,7 +15456,7 @@ var require_port_for_service_default = createRule({
|
|
|
15300
15456
|
});
|
|
15301
15457
|
|
|
15302
15458
|
// src/rules/require-static-next-matcher.ts
|
|
15303
|
-
var
|
|
15459
|
+
var import_utils79 = require("@typescript-eslint/utils");
|
|
15304
15460
|
var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
15305
15461
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
15306
15462
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -15313,34 +15469,34 @@ var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
|
15313
15469
|
};
|
|
15314
15470
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
15315
15471
|
function unwrapExpression3(node) {
|
|
15316
|
-
if (node.type ===
|
|
15472
|
+
if (node.type === import_utils79.AST_NODE_TYPES.TSAsExpression || node.type === import_utils79.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils79.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils79.AST_NODE_TYPES.TSTypeAssertion) {
|
|
15317
15473
|
return unwrapExpression3(node.expression);
|
|
15318
15474
|
}
|
|
15319
15475
|
return node;
|
|
15320
15476
|
}
|
|
15321
15477
|
function isStaticValue(node) {
|
|
15322
15478
|
const value = unwrapExpression3(node);
|
|
15323
|
-
if (value.type ===
|
|
15479
|
+
if (value.type === import_utils79.AST_NODE_TYPES.Literal) {
|
|
15324
15480
|
return true;
|
|
15325
15481
|
}
|
|
15326
|
-
if (value.type ===
|
|
15482
|
+
if (value.type === import_utils79.AST_NODE_TYPES.TemplateLiteral) {
|
|
15327
15483
|
return value.expressions.length === 0;
|
|
15328
15484
|
}
|
|
15329
|
-
if (value.type ===
|
|
15485
|
+
if (value.type === import_utils79.AST_NODE_TYPES.ArrayExpression) {
|
|
15330
15486
|
return value.elements.every(
|
|
15331
|
-
(element) => element !== null && element.type !==
|
|
15487
|
+
(element) => element !== null && element.type !== import_utils79.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
15332
15488
|
);
|
|
15333
15489
|
}
|
|
15334
|
-
if (value.type ===
|
|
15490
|
+
if (value.type === import_utils79.AST_NODE_TYPES.ObjectExpression) {
|
|
15335
15491
|
return value.properties.every(
|
|
15336
|
-
(property) => property.type ===
|
|
15492
|
+
(property) => property.type === import_utils79.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils79.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
15337
15493
|
);
|
|
15338
15494
|
}
|
|
15339
15495
|
return false;
|
|
15340
15496
|
}
|
|
15341
15497
|
function propertyName4(property) {
|
|
15342
15498
|
if (property.computed) return null;
|
|
15343
|
-
if (property.key.type ===
|
|
15499
|
+
if (property.key.type === import_utils79.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
15344
15500
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
15345
15501
|
}
|
|
15346
15502
|
var require_static_next_matcher_default = createRule({
|
|
@@ -15363,19 +15519,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
15363
15519
|
}
|
|
15364
15520
|
return {
|
|
15365
15521
|
ExportNamedDeclaration(node) {
|
|
15366
|
-
if (node.declaration?.type !==
|
|
15522
|
+
if (node.declaration?.type !== import_utils79.AST_NODE_TYPES.VariableDeclaration) {
|
|
15367
15523
|
return;
|
|
15368
15524
|
}
|
|
15369
15525
|
for (const declaration of node.declaration.declarations) {
|
|
15370
|
-
if (declaration.id.type !==
|
|
15526
|
+
if (declaration.id.type !== import_utils79.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
15371
15527
|
continue;
|
|
15372
15528
|
}
|
|
15373
15529
|
const config = unwrapExpression3(declaration.init);
|
|
15374
|
-
if (config.type !==
|
|
15530
|
+
if (config.type !== import_utils79.AST_NODE_TYPES.ObjectExpression) {
|
|
15375
15531
|
continue;
|
|
15376
15532
|
}
|
|
15377
15533
|
for (const property of config.properties) {
|
|
15378
|
-
if (property.type !==
|
|
15534
|
+
if (property.type !== import_utils79.AST_NODE_TYPES.Property || propertyName4(property) !== "matcher" || property.value.type === import_utils79.AST_NODE_TYPES.AssignmentPattern) {
|
|
15379
15535
|
continue;
|
|
15380
15536
|
}
|
|
15381
15537
|
if (!isStaticValue(property.value)) {
|
|
@@ -15389,7 +15545,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
15389
15545
|
});
|
|
15390
15546
|
|
|
15391
15547
|
// src/rules/require-use-form-default-values.ts
|
|
15392
|
-
var
|
|
15548
|
+
var import_utils80 = require("@typescript-eslint/utils");
|
|
15393
15549
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
15394
15550
|
summary: "react-hook-form useForm call without defaultValues",
|
|
15395
15551
|
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.",
|
|
@@ -15443,13 +15599,13 @@ var require_use_form_default_values_default = createRule({
|
|
|
15443
15599
|
if (node.source.value !== "react-hook-form") return;
|
|
15444
15600
|
for (const specifier of node.specifiers) {
|
|
15445
15601
|
if (specifier.type !== "ImportSpecifier" || (specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value) !== "useForm") continue;
|
|
15446
|
-
const variable =
|
|
15602
|
+
const variable = import_utils80.ASTUtils.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
15447
15603
|
if (variable) importedHooks.add(variable);
|
|
15448
15604
|
}
|
|
15449
15605
|
},
|
|
15450
15606
|
CallExpression(node) {
|
|
15451
15607
|
if (node.callee.type !== "Identifier") return;
|
|
15452
|
-
const variable =
|
|
15608
|
+
const variable = import_utils80.ASTUtils.findVariable(context.sourceCode.getScope(node.callee), node.callee.name);
|
|
15453
15609
|
const options = node.arguments[0];
|
|
15454
15610
|
if (!variable || !importedHooks.has(variable) || options !== void 0 && options.type !== "ObjectExpression" || hasDefaultValues(options)) return;
|
|
15455
15611
|
context.report({ node, messageId: "requireUseFormDefaultValues" });
|
|
@@ -15459,7 +15615,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
15459
15615
|
});
|
|
15460
15616
|
|
|
15461
15617
|
// src/rules/require-use-server-in-actions-file.ts
|
|
15462
|
-
var
|
|
15618
|
+
var import_utils81 = require("@typescript-eslint/utils");
|
|
15463
15619
|
var ACTION_MODULE_RE = /(?:^|\/)app\/.*\/(?:actions|[^/]+-actions)\.[cm]?[jt]s$/u;
|
|
15464
15620
|
var REQUIRE_USE_SERVER_IN_ACTIONS_FILE_DOCUMENTATION = {
|
|
15465
15621
|
summary: "route action module missing the use server directive",
|
|
@@ -15525,7 +15681,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
15525
15681
|
});
|
|
15526
15682
|
|
|
15527
15683
|
// src/rules/require-zod-form-validation.ts
|
|
15528
|
-
var
|
|
15684
|
+
var import_utils82 = require("@typescript-eslint/utils");
|
|
15529
15685
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
15530
15686
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
15531
15687
|
rationale: "FormData values are untrusted strings or files and need runtime validation before use.",
|
|
@@ -15550,14 +15706,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
15550
15706
|
var zodReceiverRoot = (node) => {
|
|
15551
15707
|
let current = node;
|
|
15552
15708
|
while (true) {
|
|
15553
|
-
if (current.type ===
|
|
15709
|
+
if (current.type === import_utils82.AST_NODE_TYPES.Identifier) {
|
|
15554
15710
|
return current;
|
|
15555
15711
|
}
|
|
15556
|
-
if (current.type ===
|
|
15712
|
+
if (current.type === import_utils82.AST_NODE_TYPES.CallExpression) {
|
|
15557
15713
|
current = current.callee;
|
|
15558
15714
|
continue;
|
|
15559
15715
|
}
|
|
15560
|
-
if (current.type ===
|
|
15716
|
+
if (current.type === import_utils82.AST_NODE_TYPES.MemberExpression) {
|
|
15561
15717
|
current = current.object;
|
|
15562
15718
|
continue;
|
|
15563
15719
|
}
|
|
@@ -15566,12 +15722,12 @@ var zodReceiverRoot = (node) => {
|
|
|
15566
15722
|
};
|
|
15567
15723
|
var isFormDataMethodCall = (node) => {
|
|
15568
15724
|
let current = node;
|
|
15569
|
-
if (current.type ===
|
|
15725
|
+
if (current.type === import_utils82.AST_NODE_TYPES.AwaitExpression) {
|
|
15570
15726
|
current = current.argument;
|
|
15571
15727
|
}
|
|
15572
|
-
if (current.type !==
|
|
15728
|
+
if (current.type !== import_utils82.AST_NODE_TYPES.CallExpression) return false;
|
|
15573
15729
|
const callee = current.callee;
|
|
15574
|
-
return callee.type ===
|
|
15730
|
+
return callee.type === import_utils82.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils82.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
15575
15731
|
};
|
|
15576
15732
|
var require_zod_form_validation_default = createRule({
|
|
15577
15733
|
name: "require-zod-form-validation",
|
|
@@ -15592,7 +15748,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15592
15748
|
return {};
|
|
15593
15749
|
}
|
|
15594
15750
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
15595
|
-
const resolvedBinding = (identifier) =>
|
|
15751
|
+
const resolvedBinding = (identifier) => import_utils82.ASTUtils.findVariable(
|
|
15596
15752
|
context.sourceCode.getScope(identifier),
|
|
15597
15753
|
identifier.name
|
|
15598
15754
|
);
|
|
@@ -15602,16 +15758,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
15602
15758
|
return false;
|
|
15603
15759
|
}
|
|
15604
15760
|
const definition = binding.defs[0];
|
|
15605
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
15761
|
+
if (definition?.type !== "Variable" || definition.node.type !== import_utils82.AST_NODE_TYPES.VariableDeclarator) {
|
|
15606
15762
|
return false;
|
|
15607
15763
|
}
|
|
15608
15764
|
const init = definition.node.init;
|
|
15609
|
-
return init?.type ===
|
|
15765
|
+
return init?.type === import_utils82.AST_NODE_TYPES.ObjectExpression || init?.type === import_utils82.AST_NODE_TYPES.ArrayExpression || init?.type === import_utils82.AST_NODE_TYPES.Literal || init?.type === import_utils82.AST_NODE_TYPES.ArrowFunctionExpression || init?.type === import_utils82.AST_NODE_TYPES.FunctionExpression;
|
|
15610
15766
|
};
|
|
15611
15767
|
const isZodParseCall = (node) => {
|
|
15612
|
-
if (node.type !==
|
|
15768
|
+
if (node.type !== import_utils82.AST_NODE_TYPES.CallExpression) return false;
|
|
15613
15769
|
const callee = node.callee;
|
|
15614
|
-
if (callee.type !==
|
|
15770
|
+
if (callee.type !== import_utils82.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils82.AST_NODE_TYPES.Identifier || !ZOD_PARSE_METHODS.has(callee.property.name)) {
|
|
15615
15771
|
return false;
|
|
15616
15772
|
}
|
|
15617
15773
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -15620,14 +15776,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
15620
15776
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
15621
15777
|
};
|
|
15622
15778
|
const isFormSourceIdentifier = (node) => {
|
|
15623
|
-
if (node.type !==
|
|
15779
|
+
if (node.type !== import_utils82.AST_NODE_TYPES.Identifier) return false;
|
|
15624
15780
|
const conventionalName = /formdata/i.test(node.name);
|
|
15625
15781
|
let scope = context.sourceCode.getScope(node);
|
|
15626
15782
|
while (scope !== null) {
|
|
15627
15783
|
const variable = scope.set.get(node.name);
|
|
15628
15784
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
15629
15785
|
const def = variable.defs[0];
|
|
15630
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
15786
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils82.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
15631
15787
|
return isFormDataMethodCall(def.node.init);
|
|
15632
15788
|
}
|
|
15633
15789
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -15638,8 +15794,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
15638
15794
|
};
|
|
15639
15795
|
const isFormDataGetCall = (node) => {
|
|
15640
15796
|
const callee = node.callee;
|
|
15641
|
-
if (callee.type !==
|
|
15642
|
-
if (callee.property.type !==
|
|
15797
|
+
if (callee.type !== import_utils82.AST_NODE_TYPES.MemberExpression) return false;
|
|
15798
|
+
if (callee.property.type !== import_utils82.AST_NODE_TYPES.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
15643
15799
|
return false;
|
|
15644
15800
|
}
|
|
15645
15801
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -15655,16 +15811,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
15655
15811
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
15656
15812
|
const isInstanceofNarrowing = (node) => {
|
|
15657
15813
|
const parent = node.parent;
|
|
15658
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
15814
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils82.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils82.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
15659
15815
|
};
|
|
15660
15816
|
const boundDeclarator = (node) => {
|
|
15661
15817
|
let current = node;
|
|
15662
15818
|
let parent = current.parent;
|
|
15663
|
-
while ((parent.type ===
|
|
15819
|
+
while ((parent.type === import_utils82.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils82.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils82.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils82.AST_NODE_TYPES.ChainExpression) && parent.expression === current) {
|
|
15664
15820
|
current = parent;
|
|
15665
15821
|
parent = current.parent;
|
|
15666
15822
|
}
|
|
15667
|
-
if (parent.type ===
|
|
15823
|
+
if (parent.type === import_utils82.AST_NODE_TYPES.VariableDeclarator && parent.init === current && parent.id.type === import_utils82.AST_NODE_TYPES.Identifier) {
|
|
15668
15824
|
return parent;
|
|
15669
15825
|
}
|
|
15670
15826
|
return null;
|
|
@@ -15673,7 +15829,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15673
15829
|
let current = node;
|
|
15674
15830
|
while (current.parent !== void 0) {
|
|
15675
15831
|
const parent = current.parent;
|
|
15676
|
-
if (parent.type ===
|
|
15832
|
+
if (parent.type === import_utils82.AST_NODE_TYPES.BlockStatement || parent.type === import_utils82.AST_NODE_TYPES.Program) {
|
|
15677
15833
|
return current;
|
|
15678
15834
|
}
|
|
15679
15835
|
current = parent;
|
|
@@ -15682,12 +15838,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
15682
15838
|
};
|
|
15683
15839
|
const zodParseMethod = (call) => {
|
|
15684
15840
|
const callee = call.callee;
|
|
15685
|
-
return callee.type ===
|
|
15841
|
+
return callee.type === import_utils82.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils82.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
15686
15842
|
};
|
|
15687
15843
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
15688
15844
|
let current = node.parent;
|
|
15689
15845
|
while (current !== void 0 && current !== statement) {
|
|
15690
|
-
if (current.type ===
|
|
15846
|
+
if (current.type === import_utils82.AST_NODE_TYPES.LogicalExpression || current.type === import_utils82.AST_NODE_TYPES.ConditionalExpression) {
|
|
15691
15847
|
return true;
|
|
15692
15848
|
}
|
|
15693
15849
|
current = current.parent;
|
|
@@ -15697,7 +15853,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15697
15853
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
15698
15854
|
let current = node.parent;
|
|
15699
15855
|
while (current !== void 0 && current !== statement) {
|
|
15700
|
-
if (current.type ===
|
|
15856
|
+
if (current.type === import_utils82.AST_NODE_TYPES.AwaitExpression) return true;
|
|
15701
15857
|
current = current.parent;
|
|
15702
15858
|
}
|
|
15703
15859
|
return false;
|
|
@@ -15710,7 +15866,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15710
15866
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
15711
15867
|
return null;
|
|
15712
15868
|
}
|
|
15713
|
-
if (validationStatement.type !==
|
|
15869
|
+
if (validationStatement.type !== import_utils82.AST_NODE_TYPES.VariableDeclaration && validationStatement.type !== import_utils82.AST_NODE_TYPES.ExpressionStatement) {
|
|
15714
15870
|
return null;
|
|
15715
15871
|
}
|
|
15716
15872
|
const method = zodParseMethod(parse2);
|
|
@@ -15722,16 +15878,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
15722
15878
|
};
|
|
15723
15879
|
const isSafePrevalidationInspection = (identifier) => {
|
|
15724
15880
|
const parent = identifier.parent;
|
|
15725
|
-
if (parent.type ===
|
|
15881
|
+
if (parent.type === import_utils82.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof") {
|
|
15726
15882
|
return true;
|
|
15727
15883
|
}
|
|
15728
|
-
if (parent.type !==
|
|
15884
|
+
if (parent.type !== import_utils82.AST_NODE_TYPES.BinaryExpression || parent.left !== identifier) {
|
|
15729
15885
|
return false;
|
|
15730
15886
|
}
|
|
15731
15887
|
if (parent.operator === "instanceof") {
|
|
15732
|
-
return parent.right.type ===
|
|
15888
|
+
return parent.right.type === import_utils82.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
15733
15889
|
}
|
|
15734
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
15890
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === import_utils82.AST_NODE_TYPES.Literal && parent.right.value === null || parent.right.type === import_utils82.AST_NODE_TYPES.Identifier && parent.right.name === "undefined");
|
|
15735
15891
|
};
|
|
15736
15892
|
const isDescendantOf = (node, ancestor) => {
|
|
15737
15893
|
let current = node;
|
|
@@ -15742,23 +15898,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
15742
15898
|
return false;
|
|
15743
15899
|
};
|
|
15744
15900
|
const blockTerminates = (node) => {
|
|
15745
|
-
if (node.type ===
|
|
15901
|
+
if (node.type === import_utils82.AST_NODE_TYPES.ReturnStatement || node.type === import_utils82.AST_NODE_TYPES.ThrowStatement) {
|
|
15746
15902
|
return true;
|
|
15747
15903
|
}
|
|
15748
|
-
if (node.type !==
|
|
15904
|
+
if (node.type !== import_utils82.AST_NODE_TYPES.BlockStatement || node.body.length === 0) return false;
|
|
15749
15905
|
const last = node.body.at(-1);
|
|
15750
15906
|
return last !== void 0 && blockTerminates(last);
|
|
15751
15907
|
};
|
|
15752
15908
|
const narrowingIf = (identifier) => {
|
|
15753
15909
|
const comparison = identifier.parent;
|
|
15754
|
-
if (comparison?.type !==
|
|
15910
|
+
if (comparison?.type !== import_utils82.AST_NODE_TYPES.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== import_utils82.AST_NODE_TYPES.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
15755
15911
|
return null;
|
|
15756
15912
|
}
|
|
15757
15913
|
const maybeNegation = comparison.parent;
|
|
15758
|
-
const negated = maybeNegation?.type ===
|
|
15914
|
+
const negated = maybeNegation?.type === import_utils82.AST_NODE_TYPES.UnaryExpression && maybeNegation.operator === "!";
|
|
15759
15915
|
const test = negated ? maybeNegation : comparison;
|
|
15760
15916
|
const branch = test.parent;
|
|
15761
|
-
return branch?.type ===
|
|
15917
|
+
return branch?.type === import_utils82.AST_NODE_TYPES.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
15762
15918
|
};
|
|
15763
15919
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
15764
15920
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -15778,7 +15934,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15778
15934
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
15779
15935
|
if (variable === void 0) return false;
|
|
15780
15936
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
15781
|
-
(identifier) => identifier.type ===
|
|
15937
|
+
(identifier) => identifier.type === import_utils82.AST_NODE_TYPES.Identifier
|
|
15782
15938
|
);
|
|
15783
15939
|
if (references.length === 0) return false;
|
|
15784
15940
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -15804,7 +15960,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15804
15960
|
ImportDeclaration(node) {
|
|
15805
15961
|
if (!isZodModule(node.source.value)) return;
|
|
15806
15962
|
for (const specifier of node.specifiers) {
|
|
15807
|
-
if (specifier.type ===
|
|
15963
|
+
if (specifier.type === import_utils82.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils82.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils82.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils82.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
15808
15964
|
const binding = resolvedBinding(specifier.local);
|
|
15809
15965
|
if (binding !== null) zodBindings.add(binding);
|
|
15810
15966
|
}
|
|
@@ -15825,7 +15981,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15825
15981
|
});
|
|
15826
15982
|
|
|
15827
15983
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
15828
|
-
var
|
|
15984
|
+
var import_utils83 = require("@typescript-eslint/utils");
|
|
15829
15985
|
var STORE_INSERT_REQUIRES_ON_CONFLICT_DOCUMENTATION = {
|
|
15830
15986
|
summary: "Require embedded inserts in explicitly replayable callables to carry conflict handling.",
|
|
15831
15987
|
rationale: "A callable named as an enqueue, seed, migration, schedule, ensure, or upsert promises replay safety.",
|
|
@@ -15889,7 +16045,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
15889
16045
|
});
|
|
15890
16046
|
|
|
15891
16047
|
// src/rules/stepdown.ts
|
|
15892
|
-
var
|
|
16048
|
+
var import_utils84 = require("@typescript-eslint/utils");
|
|
15893
16049
|
var STEPDOWN_DOCUMENTATION = {
|
|
15894
16050
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
15895
16051
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -15909,7 +16065,7 @@ var STEPDOWN_DOCUMENTATION = {
|
|
|
15909
16065
|
]
|
|
15910
16066
|
};
|
|
15911
16067
|
function isFunction(node) {
|
|
15912
|
-
return node.type ===
|
|
16068
|
+
return node.type === import_utils84.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils84.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils84.AST_NODE_TYPES.FunctionExpression;
|
|
15913
16069
|
}
|
|
15914
16070
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true, makeFix) {
|
|
15915
16071
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -16006,8 +16162,8 @@ function moduleScope(context, program) {
|
|
|
16006
16162
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
16007
16163
|
const overloadNames = new Set(
|
|
16008
16164
|
program.body.flatMap((statement) => {
|
|
16009
|
-
const node = statement.type ===
|
|
16010
|
-
return node?.type ===
|
|
16165
|
+
const node = statement.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
16166
|
+
return node?.type === import_utils84.AST_NODE_TYPES.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
16011
16167
|
})
|
|
16012
16168
|
);
|
|
16013
16169
|
const exported = exportedNames(program);
|
|
@@ -16031,7 +16187,7 @@ function moduleScope(context, program) {
|
|
|
16031
16187
|
const nearestFunction2 = [...ancestors].reverse().find(isFunction);
|
|
16032
16188
|
const parent = identifier.parent;
|
|
16033
16189
|
const callerDefinition = nearestFunction2 === void 0 ? void 0 : byFunction.get(nearestFunction2);
|
|
16034
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
16190
|
+
if (callerDefinition === void 0 || parent.type !== import_utils84.AST_NODE_TYPES.CallExpression || parent.callee !== identifier) {
|
|
16035
16191
|
pinned.add(definition.name);
|
|
16036
16192
|
continue;
|
|
16037
16193
|
}
|
|
@@ -16046,38 +16202,38 @@ function moduleScope(context, program) {
|
|
|
16046
16202
|
function exportedNames(program) {
|
|
16047
16203
|
const names = /* @__PURE__ */ new Set();
|
|
16048
16204
|
for (const statement of program.body) {
|
|
16049
|
-
if (statement.type !==
|
|
16050
|
-
if (statement.declaration?.type ===
|
|
16205
|
+
if (statement.type !== import_utils84.AST_NODE_TYPES.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
16206
|
+
if (statement.declaration?.type === import_utils84.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) {
|
|
16051
16207
|
names.add(statement.declaration.id.name);
|
|
16052
16208
|
}
|
|
16053
|
-
if (statement.declaration?.type ===
|
|
16209
|
+
if (statement.declaration?.type === import_utils84.AST_NODE_TYPES.VariableDeclaration) {
|
|
16054
16210
|
for (const declarator of statement.declaration.declarations) {
|
|
16055
|
-
if (declarator.id.type ===
|
|
16211
|
+
if (declarator.id.type === import_utils84.AST_NODE_TYPES.Identifier) names.add(declarator.id.name);
|
|
16056
16212
|
}
|
|
16057
16213
|
}
|
|
16058
16214
|
for (const specifier of statement.specifiers) {
|
|
16059
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
16215
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils84.AST_NODE_TYPES.Identifier) {
|
|
16060
16216
|
names.add(specifier.local.name);
|
|
16061
16217
|
}
|
|
16062
16218
|
}
|
|
16063
16219
|
}
|
|
16064
16220
|
for (const statement of program.body) {
|
|
16065
|
-
if (statement.type ===
|
|
16066
|
-
if (statement.type ===
|
|
16221
|
+
if (statement.type === import_utils84.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils84.AST_NODE_TYPES.Identifier) names.add(statement.declaration.name);
|
|
16222
|
+
if (statement.type === import_utils84.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils84.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
16067
16223
|
}
|
|
16068
16224
|
return names;
|
|
16069
16225
|
}
|
|
16070
16226
|
function moduleDefinitions(program) {
|
|
16071
16227
|
const definitions = [];
|
|
16072
16228
|
for (const statement of program.body) {
|
|
16073
|
-
const node = statement.type ===
|
|
16074
|
-
if (node?.type ===
|
|
16229
|
+
const node = statement.type === import_utils84.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils84.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
16230
|
+
if (node?.type === import_utils84.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
16075
16231
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
16076
16232
|
continue;
|
|
16077
16233
|
}
|
|
16078
|
-
if (node?.type !==
|
|
16234
|
+
if (node?.type !== import_utils84.AST_NODE_TYPES.VariableDeclaration || node.kind !== "const") continue;
|
|
16079
16235
|
for (const declarator of node.declarations) {
|
|
16080
|
-
if (declarator.id.type ===
|
|
16236
|
+
if (declarator.id.type === import_utils84.AST_NODE_TYPES.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
16081
16237
|
definitions.push({
|
|
16082
16238
|
name: declarator.id.name,
|
|
16083
16239
|
node: declarator,
|
|
@@ -16090,21 +16246,21 @@ function moduleDefinitions(program) {
|
|
|
16090
16246
|
return definitions;
|
|
16091
16247
|
}
|
|
16092
16248
|
function methodName(node) {
|
|
16093
|
-
if (node.key.type ===
|
|
16094
|
-
return !node.computed && node.key.type ===
|
|
16249
|
+
if (node.key.type === import_utils84.AST_NODE_TYPES.PrivateIdentifier) return `#${node.key.name}`;
|
|
16250
|
+
return !node.computed && node.key.type === import_utils84.AST_NODE_TYPES.Identifier ? node.key.name : null;
|
|
16095
16251
|
}
|
|
16096
16252
|
function referencedMethod(context, node, classVariables) {
|
|
16097
|
-
const objectVariable = node.object.type ===
|
|
16253
|
+
const objectVariable = node.object.type === import_utils84.AST_NODE_TYPES.Identifier ? import_utils84.ASTUtils.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
16098
16254
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
16099
|
-
if (node.object.type !==
|
|
16100
|
-
if (node.property.type ===
|
|
16101
|
-
if (!node.computed && node.property.type ===
|
|
16102
|
-
return node.computed && node.property.type ===
|
|
16255
|
+
if (node.object.type !== import_utils84.AST_NODE_TYPES.ThisExpression && !isClassReference) return null;
|
|
16256
|
+
if (node.property.type === import_utils84.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
16257
|
+
if (!node.computed && node.property.type === import_utils84.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
16258
|
+
return node.computed && node.property.type === import_utils84.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
16103
16259
|
}
|
|
16104
16260
|
function referencedPropertyName(node) {
|
|
16105
|
-
if (node.property.type ===
|
|
16106
|
-
if (!node.computed && node.property.type ===
|
|
16107
|
-
return node.computed && node.property.type ===
|
|
16261
|
+
if (node.property.type === import_utils84.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
16262
|
+
if (!node.computed && node.property.type === import_utils84.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
16263
|
+
return node.computed && node.property.type === import_utils84.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
16108
16264
|
}
|
|
16109
16265
|
function walk2(node, visitorKeys, visit, nestedFunction = false) {
|
|
16110
16266
|
visit(node, nestedFunction);
|
|
@@ -16120,7 +16276,7 @@ function walk2(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
16120
16276
|
}
|
|
16121
16277
|
function classScope(context, node, computedReferenceNames) {
|
|
16122
16278
|
const methods = node.body.body.filter(
|
|
16123
|
-
(member) => member.type ===
|
|
16279
|
+
(member) => member.type === import_utils84.AST_NODE_TYPES.MethodDefinition
|
|
16124
16280
|
);
|
|
16125
16281
|
const counts = /* @__PURE__ */ new Map();
|
|
16126
16282
|
for (const method of methods) {
|
|
@@ -16128,8 +16284,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16128
16284
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
16129
16285
|
}
|
|
16130
16286
|
for (const member of node.body.body) {
|
|
16131
|
-
if (member.type !==
|
|
16132
|
-
const name = !member.computed && member.key.type ===
|
|
16287
|
+
if (member.type !== import_utils84.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
16288
|
+
const name = !member.computed && member.key.type === import_utils84.AST_NODE_TYPES.Identifier ? member.key.name : null;
|
|
16133
16289
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
16134
16290
|
}
|
|
16135
16291
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -16138,7 +16294,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16138
16294
|
});
|
|
16139
16295
|
const definitions = methods.flatMap((method) => {
|
|
16140
16296
|
const name = methodName(method);
|
|
16141
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
16297
|
+
const isPrivate = method.accessibility === "private" || method.key.type === import_utils84.AST_NODE_TYPES.PrivateIdentifier;
|
|
16142
16298
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
16143
16299
|
});
|
|
16144
16300
|
if (definitions.length === 0) return;
|
|
@@ -16147,11 +16303,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16147
16303
|
const pinned = /* @__PURE__ */ new Set();
|
|
16148
16304
|
const classVariables = /* @__PURE__ */ new Set();
|
|
16149
16305
|
if (node.id !== null) {
|
|
16150
|
-
const internal =
|
|
16306
|
+
const internal = import_utils84.ASTUtils.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
16151
16307
|
if (internal !== null) classVariables.add(internal);
|
|
16152
16308
|
}
|
|
16153
|
-
if (node.type ===
|
|
16154
|
-
const outer =
|
|
16309
|
+
if (node.type === import_utils84.AST_NODE_TYPES.ClassExpression && node.parent.type === import_utils84.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils84.AST_NODE_TYPES.Identifier) {
|
|
16310
|
+
const outer = import_utils84.ASTUtils.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
16155
16311
|
if (outer !== null) classVariables.add(outer);
|
|
16156
16312
|
}
|
|
16157
16313
|
for (const method of methods) {
|
|
@@ -16167,27 +16323,27 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16167
16323
|
}
|
|
16168
16324
|
const thisValue = (value) => {
|
|
16169
16325
|
let current = value;
|
|
16170
|
-
while (current?.type ===
|
|
16171
|
-
return current?.type ===
|
|
16326
|
+
while (current?.type === import_utils84.AST_NODE_TYPES.TSAsExpression || current?.type === import_utils84.AST_NODE_TYPES.TSSatisfiesExpression || current?.type === import_utils84.AST_NODE_TYPES.TSNonNullExpression) current = current.expression;
|
|
16327
|
+
return current?.type === import_utils84.AST_NODE_TYPES.ThisExpression;
|
|
16172
16328
|
};
|
|
16173
16329
|
const collectAlias = (current, nestedFunction) => {
|
|
16174
|
-
if (nestedFunction || current.type !==
|
|
16175
|
-
if (current.type ===
|
|
16176
|
-
const binding = current.type ===
|
|
16177
|
-
const value = current.type ===
|
|
16330
|
+
if (nestedFunction || current.type !== import_utils84.AST_NODE_TYPES.VariableDeclarator && current.type !== import_utils84.AST_NODE_TYPES.AssignmentPattern) return;
|
|
16331
|
+
if (current.type === import_utils84.AST_NODE_TYPES.VariableDeclarator && (current.parent.type !== import_utils84.AST_NODE_TYPES.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
16332
|
+
const binding = current.type === import_utils84.AST_NODE_TYPES.VariableDeclarator ? current.id : current.left;
|
|
16333
|
+
const value = current.type === import_utils84.AST_NODE_TYPES.VariableDeclarator ? current.init : current.right;
|
|
16178
16334
|
if (!thisValue(value)) return;
|
|
16179
|
-
if (binding.type ===
|
|
16335
|
+
if (binding.type === import_utils84.AST_NODE_TYPES.ObjectPattern) {
|
|
16180
16336
|
for (const property of binding.properties) {
|
|
16181
|
-
if (property.type ===
|
|
16337
|
+
if (property.type === import_utils84.AST_NODE_TYPES.RestElement) {
|
|
16182
16338
|
for (const name of privateNames) pinned.add(name);
|
|
16183
|
-
} else if (property.key.type ===
|
|
16339
|
+
} else if (property.key.type === import_utils84.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) {
|
|
16184
16340
|
pinned.add(property.key.name);
|
|
16185
16341
|
}
|
|
16186
16342
|
}
|
|
16187
16343
|
return;
|
|
16188
16344
|
}
|
|
16189
|
-
if (binding.type !==
|
|
16190
|
-
const variable =
|
|
16345
|
+
if (binding.type !== import_utils84.AST_NODE_TYPES.Identifier) return;
|
|
16346
|
+
const variable = import_utils84.ASTUtils.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
16191
16347
|
if (variable !== null) {
|
|
16192
16348
|
methodClassVariables.add(variable);
|
|
16193
16349
|
methodAliases.add(variable);
|
|
@@ -16200,16 +16356,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16200
16356
|
walk2(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
16201
16357
|
}
|
|
16202
16358
|
const visitCall = (current, nestedFunction) => {
|
|
16203
|
-
if (current.type ===
|
|
16359
|
+
if (current.type === import_utils84.AST_NODE_TYPES.VariableDeclarator && current.id.type === import_utils84.AST_NODE_TYPES.ObjectPattern && thisValue(current.init)) {
|
|
16204
16360
|
for (const property of current.id.properties) {
|
|
16205
|
-
if (property.type ===
|
|
16361
|
+
if (property.type === import_utils84.AST_NODE_TYPES.RestElement) {
|
|
16206
16362
|
for (const name of privateNames) pinned.add(name);
|
|
16207
16363
|
continue;
|
|
16208
16364
|
}
|
|
16209
|
-
if (property.type ===
|
|
16365
|
+
if (property.type === import_utils84.AST_NODE_TYPES.Property && property.key.type === import_utils84.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
16210
16366
|
}
|
|
16211
16367
|
}
|
|
16212
|
-
if (current.type !==
|
|
16368
|
+
if (current.type !== import_utils84.AST_NODE_TYPES.MemberExpression) return;
|
|
16213
16369
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
16214
16370
|
if (target === null) {
|
|
16215
16371
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -16217,12 +16373,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16217
16373
|
return;
|
|
16218
16374
|
}
|
|
16219
16375
|
if (!privateNames.has(target)) return;
|
|
16220
|
-
const objectVariable = current.object.type ===
|
|
16376
|
+
const objectVariable = current.object.type === import_utils84.AST_NODE_TYPES.Identifier ? import_utils84.ASTUtils.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
16221
16377
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
16222
16378
|
pinned.add(target);
|
|
16223
16379
|
return;
|
|
16224
16380
|
}
|
|
16225
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
16381
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== import_utils84.AST_NODE_TYPES.CallExpression || current.parent.callee !== current) {
|
|
16226
16382
|
pinned.add(target);
|
|
16227
16383
|
return;
|
|
16228
16384
|
}
|
|
@@ -16242,9 +16398,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16242
16398
|
}
|
|
16243
16399
|
}
|
|
16244
16400
|
for (const member of node.body.body) {
|
|
16245
|
-
if (member.type ===
|
|
16401
|
+
if (member.type === import_utils84.AST_NODE_TYPES.MethodDefinition || member.type === import_utils84.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
16246
16402
|
walk2(member, context.sourceCode.visitorKeys, (current) => {
|
|
16247
|
-
if (current.type !==
|
|
16403
|
+
if (current.type !== import_utils84.AST_NODE_TYPES.MemberExpression) return;
|
|
16248
16404
|
const target = referencedMethod(context, current, classVariables);
|
|
16249
16405
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
16250
16406
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -16296,12 +16452,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16296
16452
|
}
|
|
16297
16453
|
function isClassRuntimeBarrier(member) {
|
|
16298
16454
|
switch (member.type) {
|
|
16299
|
-
case
|
|
16455
|
+
case import_utils84.AST_NODE_TYPES.StaticBlock:
|
|
16300
16456
|
return true;
|
|
16301
|
-
case
|
|
16302
|
-
case
|
|
16457
|
+
case import_utils84.AST_NODE_TYPES.PropertyDefinition:
|
|
16458
|
+
case import_utils84.AST_NODE_TYPES.AccessorProperty:
|
|
16303
16459
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
16304
|
-
case
|
|
16460
|
+
case import_utils84.AST_NODE_TYPES.MethodDefinition:
|
|
16305
16461
|
return member.computed || member.decorators.length > 0;
|
|
16306
16462
|
default:
|
|
16307
16463
|
return false;
|
|
@@ -16334,7 +16490,7 @@ var stepdown_default = createRule({
|
|
|
16334
16490
|
moduleScope(context, program);
|
|
16335
16491
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
16336
16492
|
walk2(program, context.sourceCode.visitorKeys, (node) => {
|
|
16337
|
-
if (node.type ===
|
|
16493
|
+
if (node.type === import_utils84.AST_NODE_TYPES.MemberExpression && node.computed && node.property.type === import_utils84.AST_NODE_TYPES.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
16338
16494
|
});
|
|
16339
16495
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
16340
16496
|
}
|
|
@@ -16343,7 +16499,7 @@ var stepdown_default = createRule({
|
|
|
16343
16499
|
});
|
|
16344
16500
|
|
|
16345
16501
|
// src/rules/source-coupled-test.ts
|
|
16346
|
-
var
|
|
16502
|
+
var import_utils85 = require("@typescript-eslint/utils");
|
|
16347
16503
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|py|[cm]?[jt]s)$/iu;
|
|
16348
16504
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
16349
16505
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -16412,20 +16568,20 @@ var SOURCE_COUPLED_TEST_DOCUMENTATION = {
|
|
|
16412
16568
|
]
|
|
16413
16569
|
};
|
|
16414
16570
|
function staticMemberName7(node) {
|
|
16415
|
-
if (!node.computed && node.property.type ===
|
|
16416
|
-
if (node.computed && node.property.type ===
|
|
16571
|
+
if (!node.computed && node.property.type === import_utils85.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
16572
|
+
if (node.computed && node.property.type === import_utils85.AST_NODE_TYPES.Literal && typeof node.property.value === "string") return node.property.value;
|
|
16417
16573
|
return null;
|
|
16418
16574
|
}
|
|
16419
16575
|
function unwrap5(node) {
|
|
16420
|
-
if (node.type ===
|
|
16421
|
-
if (node.type ===
|
|
16422
|
-
if (node.type ===
|
|
16576
|
+
if (node.type === import_utils85.AST_NODE_TYPES.AwaitExpression) return unwrap5(node.argument);
|
|
16577
|
+
if (node.type === import_utils85.AST_NODE_TYPES.ChainExpression) return unwrap5(node.expression);
|
|
16578
|
+
if (node.type === import_utils85.AST_NODE_TYPES.TSAsExpression || node.type === import_utils85.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils85.AST_NODE_TYPES.TSTypeAssertion) return unwrap5(node.expression);
|
|
16423
16579
|
return node;
|
|
16424
16580
|
}
|
|
16425
16581
|
function stringValue(node) {
|
|
16426
16582
|
const current = unwrap5(node);
|
|
16427
|
-
if (current.type ===
|
|
16428
|
-
if (current.type ===
|
|
16583
|
+
if (current.type === import_utils85.AST_NODE_TYPES.Literal && typeof current.value === "string") return current.value;
|
|
16584
|
+
if (current.type === import_utils85.AST_NODE_TYPES.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
16429
16585
|
return null;
|
|
16430
16586
|
}
|
|
16431
16587
|
function importSource(node) {
|
|
@@ -16433,7 +16589,7 @@ function importSource(node) {
|
|
|
16433
16589
|
}
|
|
16434
16590
|
function requireSource(node) {
|
|
16435
16591
|
const current = unwrap5(node);
|
|
16436
|
-
if (current.type !==
|
|
16592
|
+
if (current.type !== import_utils85.AST_NODE_TYPES.CallExpression || current.callee.type !== import_utils85.AST_NODE_TYPES.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === import_utils85.AST_NODE_TYPES.SpreadElement) return null;
|
|
16437
16593
|
return stringValue(current.arguments[0]);
|
|
16438
16594
|
}
|
|
16439
16595
|
function newScope() {
|
|
@@ -16473,38 +16629,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16473
16629
|
const current = unwrap5(node);
|
|
16474
16630
|
const value = stringValue(current);
|
|
16475
16631
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
16476
|
-
if (current.type ===
|
|
16477
|
-
if (current.type ===
|
|
16632
|
+
if (current.type === import_utils85.AST_NODE_TYPES.Identifier) return visible("paths", current.name);
|
|
16633
|
+
if (current.type === import_utils85.AST_NODE_TYPES.BinaryExpression && current.operator === "+") {
|
|
16478
16634
|
return sourcePath(current.left) || sourcePath(current.right);
|
|
16479
16635
|
}
|
|
16480
|
-
if (current.type ===
|
|
16481
|
-
if (current.type ===
|
|
16482
|
-
return current.arguments.some((argument) => argument.type !==
|
|
16636
|
+
if (current.type === import_utils85.AST_NODE_TYPES.TemplateLiteral) return current.expressions.some(sourcePath);
|
|
16637
|
+
if (current.type === import_utils85.AST_NODE_TYPES.CallExpression || current.type === import_utils85.AST_NODE_TYPES.NewExpression) {
|
|
16638
|
+
return current.arguments.some((argument) => argument.type !== import_utils85.AST_NODE_TYPES.SpreadElement && sourcePath(argument));
|
|
16483
16639
|
}
|
|
16484
|
-
if (current.type ===
|
|
16640
|
+
if (current.type === import_utils85.AST_NODE_TYPES.MemberExpression) return sourcePath(current.object);
|
|
16485
16641
|
return false;
|
|
16486
16642
|
};
|
|
16487
16643
|
const rawRead = (node) => {
|
|
16488
16644
|
const current = unwrap5(node);
|
|
16489
|
-
if (current.type !==
|
|
16645
|
+
if (current.type !== import_utils85.AST_NODE_TYPES.CallExpression || current.arguments.length === 0) return false;
|
|
16490
16646
|
const callee = unwrap5(current.callee);
|
|
16491
|
-
if (callee.type ===
|
|
16647
|
+
if (callee.type === import_utils85.AST_NODE_TYPES.Identifier) {
|
|
16492
16648
|
return visible("fsReaders", callee.name) && sourcePath(current.arguments[0]);
|
|
16493
16649
|
}
|
|
16494
|
-
if (callee.type !==
|
|
16650
|
+
if (callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return false;
|
|
16495
16651
|
const name2 = staticMemberName7(callee);
|
|
16496
16652
|
const object = unwrap5(callee.object);
|
|
16497
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
16653
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === import_utils85.AST_NODE_TYPES.Identifier && visible("fsObjects", object.name) && sourcePath(current.arguments[0]);
|
|
16498
16654
|
};
|
|
16499
16655
|
const rawOrigins = (node) => {
|
|
16500
16656
|
const current = unwrap5(node);
|
|
16501
|
-
if (current.type ===
|
|
16657
|
+
if (current.type === import_utils85.AST_NODE_TYPES.Identifier) return visibleRawOrigins(current.name);
|
|
16502
16658
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
16503
|
-
if (current.type ===
|
|
16504
|
-
if (current.type ===
|
|
16505
|
-
if (current.type !==
|
|
16659
|
+
if (current.type === import_utils85.AST_NODE_TYPES.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
16660
|
+
if (current.type === import_utils85.AST_NODE_TYPES.MemberExpression && staticMemberName7(current) === "length") return rawOrigins(current.object);
|
|
16661
|
+
if (current.type !== import_utils85.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
16506
16662
|
const callee = unwrap5(current.callee);
|
|
16507
|
-
if (callee.type !==
|
|
16663
|
+
if (callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
16508
16664
|
const name2 = staticMemberName7(callee);
|
|
16509
16665
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(callee.object) : /* @__PURE__ */ new Set();
|
|
16510
16666
|
};
|
|
@@ -16512,38 +16668,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16512
16668
|
const current = unwrap5(node);
|
|
16513
16669
|
const direct = rawOrigins(current);
|
|
16514
16670
|
if (direct.size > 0) return direct;
|
|
16515
|
-
if (current.type ===
|
|
16516
|
-
if (current.type ===
|
|
16517
|
-
if (current.type !==
|
|
16671
|
+
if (current.type === import_utils85.AST_NODE_TYPES.BinaryExpression || current.type === import_utils85.AST_NODE_TYPES.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
16672
|
+
if (current.type === import_utils85.AST_NODE_TYPES.UnaryExpression) return evidenceOrigins(current.argument);
|
|
16673
|
+
if (current.type !== import_utils85.AST_NODE_TYPES.CallExpression) return /* @__PURE__ */ new Set();
|
|
16518
16674
|
const callee = unwrap5(current.callee);
|
|
16519
|
-
if (callee.type !==
|
|
16675
|
+
if (callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
16520
16676
|
const name2 = staticMemberName7(callee);
|
|
16521
16677
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(callee.object);
|
|
16522
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
16678
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === import_utils85.AST_NODE_TYPES.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
16523
16679
|
return /* @__PURE__ */ new Set();
|
|
16524
16680
|
};
|
|
16525
16681
|
const rawAssertionOrigins = (node) => {
|
|
16526
16682
|
const callee = unwrap5(node.callee);
|
|
16527
|
-
if (callee.type ===
|
|
16528
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
16683
|
+
if (callee.type === import_utils85.AST_NODE_TYPES.Identifier && callee.name === "assert") {
|
|
16684
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils85.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
16529
16685
|
}
|
|
16530
|
-
if (callee.type !==
|
|
16686
|
+
if (callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression) return /* @__PURE__ */ new Set();
|
|
16531
16687
|
const matcher = staticMemberName7(callee);
|
|
16532
16688
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
16533
16689
|
let receiver = unwrap5(callee.object);
|
|
16534
|
-
while (receiver.type ===
|
|
16535
|
-
if (receiver.type ===
|
|
16690
|
+
while (receiver.type === import_utils85.AST_NODE_TYPES.MemberExpression && EXPECT_MODIFIERS2.has(staticMemberName7(receiver) ?? "")) receiver = unwrap5(receiver.object);
|
|
16691
|
+
if (receiver.type === import_utils85.AST_NODE_TYPES.CallExpression && receiver.callee.type === import_utils85.AST_NODE_TYPES.Identifier && receiver.callee.name === "expect") {
|
|
16536
16692
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
16537
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
16693
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === import_utils85.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
16538
16694
|
}
|
|
16539
|
-
if (receiver.type !==
|
|
16540
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
16695
|
+
if (receiver.type !== import_utils85.AST_NODE_TYPES.Identifier || receiver.name !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
16696
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === import_utils85.AST_NODE_TYPES.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
16541
16697
|
};
|
|
16542
16698
|
const rawRegexExtractionOrigins = (node) => {
|
|
16543
16699
|
const callee = unwrap5(node.callee);
|
|
16544
|
-
if (callee.type !==
|
|
16700
|
+
if (callee.type !== import_utils85.AST_NODE_TYPES.MemberExpression || staticMemberName7(callee) !== "matchAll" || node.arguments.length !== 1) return /* @__PURE__ */ new Set();
|
|
16545
16701
|
const argument = node.arguments[0];
|
|
16546
|
-
if (argument?.type !==
|
|
16702
|
+
if (argument?.type !== import_utils85.AST_NODE_TYPES.Literal || !(argument.value instanceof RegExp)) return /* @__PURE__ */ new Set();
|
|
16547
16703
|
return rawOrigins(callee.object);
|
|
16548
16704
|
};
|
|
16549
16705
|
const declare = (name2, state) => {
|
|
@@ -16564,15 +16720,15 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16564
16720
|
};
|
|
16565
16721
|
const sourceCollection = (node) => {
|
|
16566
16722
|
const current = unwrap5(node);
|
|
16567
|
-
return current.type ===
|
|
16723
|
+
return current.type === import_utils85.AST_NODE_TYPES.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== import_utils85.AST_NODE_TYPES.SpreadElement && sourcePath(element));
|
|
16568
16724
|
};
|
|
16569
16725
|
const declaredNames2 = (node) => {
|
|
16570
16726
|
const current = unwrap5(node);
|
|
16571
|
-
if (current.type ===
|
|
16572
|
-
if (current.type ===
|
|
16573
|
-
if (current.type ===
|
|
16574
|
-
if (current.type ===
|
|
16575
|
-
if (current.type ===
|
|
16727
|
+
if (current.type === import_utils85.AST_NODE_TYPES.Identifier) return [current.name];
|
|
16728
|
+
if (current.type === import_utils85.AST_NODE_TYPES.AssignmentPattern) return declaredNames2(current.left);
|
|
16729
|
+
if (current.type === import_utils85.AST_NODE_TYPES.RestElement) return declaredNames2(current.argument);
|
|
16730
|
+
if (current.type === import_utils85.AST_NODE_TYPES.ArrayPattern) return current.elements.flatMap((element) => element === null ? [] : declaredNames2(element));
|
|
16731
|
+
if (current.type === import_utils85.AST_NODE_TYPES.ObjectPattern) return current.properties.flatMap((property) => property.type === import_utils85.AST_NODE_TYPES.RestElement ? declaredNames2(property.argument) : declaredNames2(property.value));
|
|
16576
16732
|
return [];
|
|
16577
16733
|
};
|
|
16578
16734
|
const enterFunction = (node) => {
|
|
@@ -16587,8 +16743,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16587
16743
|
const source = importSource(node);
|
|
16588
16744
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
16589
16745
|
for (const specifier of node.specifiers) {
|
|
16590
|
-
if (specifier.type ===
|
|
16591
|
-
const imported = specifier.imported.type ===
|
|
16746
|
+
if (specifier.type === import_utils85.AST_NODE_TYPES.ImportSpecifier) {
|
|
16747
|
+
const imported = specifier.imported.type === import_utils85.AST_NODE_TYPES.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
16592
16748
|
if (FS_READERS.has(imported)) declare(specifier.local.name, { fsReader: true });
|
|
16593
16749
|
} else {
|
|
16594
16750
|
declare(specifier.local.name, { fsObject: true });
|
|
@@ -16600,29 +16756,29 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16600
16756
|
VariableDeclarator(node) {
|
|
16601
16757
|
if (node.init === null) return;
|
|
16602
16758
|
const required = requireSource(node.init);
|
|
16603
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
16759
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === import_utils85.AST_NODE_TYPES.Identifier) {
|
|
16604
16760
|
declare(node.id.name, { fsObject: true });
|
|
16605
16761
|
return;
|
|
16606
16762
|
}
|
|
16607
|
-
if (node.id.type ===
|
|
16763
|
+
if (node.id.type === import_utils85.AST_NODE_TYPES.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
16608
16764
|
for (const property of node.id.properties) {
|
|
16609
|
-
if (property.type !==
|
|
16610
|
-
const key = property.key.type ===
|
|
16765
|
+
if (property.type !== import_utils85.AST_NODE_TYPES.Property || property.value.type !== import_utils85.AST_NODE_TYPES.Identifier) continue;
|
|
16766
|
+
const key = property.key.type === import_utils85.AST_NODE_TYPES.Identifier ? property.key.name : property.key.type === import_utils85.AST_NODE_TYPES.Literal ? String(property.key.value) : "";
|
|
16611
16767
|
if (FS_READERS.has(key)) declare(property.value.name, { fsReader: true });
|
|
16612
16768
|
}
|
|
16613
16769
|
return;
|
|
16614
16770
|
}
|
|
16615
|
-
if (node.id.type !==
|
|
16771
|
+
if (node.id.type !== import_utils85.AST_NODE_TYPES.Identifier) return;
|
|
16616
16772
|
declare(node.id.name, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
16617
16773
|
},
|
|
16618
16774
|
AssignmentExpression(node) {
|
|
16619
|
-
if (node.left.type ===
|
|
16775
|
+
if (node.left.type === import_utils85.AST_NODE_TYPES.Identifier) declare(node.left.name, { path: sourcePath(node.right), rawOrigins: rawOrigins(node.right) });
|
|
16620
16776
|
},
|
|
16621
16777
|
ForOfStatement(node) {
|
|
16622
16778
|
const right = unwrap5(node.right);
|
|
16623
|
-
const collection = right.type ===
|
|
16624
|
-
const left = node.left.type ===
|
|
16625
|
-
if (collection && left?.type ===
|
|
16779
|
+
const collection = right.type === import_utils85.AST_NODE_TYPES.Identifier && visible("collections", right.name);
|
|
16780
|
+
const left = node.left.type === import_utils85.AST_NODE_TYPES.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
16781
|
+
if (collection && left?.type === import_utils85.AST_NODE_TYPES.Identifier) declare(left.name, { path: true });
|
|
16626
16782
|
},
|
|
16627
16783
|
CallExpression(node) {
|
|
16628
16784
|
const origins = /* @__PURE__ */ new Set([
|
|
@@ -16682,7 +16838,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
16682
16838
|
);
|
|
16683
16839
|
|
|
16684
16840
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
16685
|
-
var
|
|
16841
|
+
var import_utils86 = require("@typescript-eslint/utils");
|
|
16686
16842
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
16687
16843
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
16688
16844
|
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.",
|
|
@@ -16814,18 +16970,18 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
16814
16970
|
"superRefine",
|
|
16815
16971
|
"transform"
|
|
16816
16972
|
]);
|
|
16817
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
16973
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils86.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
16818
16974
|
var calleeChainRoot = (node) => {
|
|
16819
16975
|
let current = node;
|
|
16820
16976
|
for (; ; ) {
|
|
16821
|
-
if (current.type ===
|
|
16977
|
+
if (current.type === import_utils86.AST_NODE_TYPES.Identifier) {
|
|
16822
16978
|
return current;
|
|
16823
16979
|
}
|
|
16824
|
-
if (current.type ===
|
|
16980
|
+
if (current.type === import_utils86.AST_NODE_TYPES.MemberExpression) {
|
|
16825
16981
|
current = current.object;
|
|
16826
16982
|
continue;
|
|
16827
16983
|
}
|
|
16828
|
-
if (current.type ===
|
|
16984
|
+
if (current.type === import_utils86.AST_NODE_TYPES.CallExpression) {
|
|
16829
16985
|
current = current.callee;
|
|
16830
16986
|
continue;
|
|
16831
16987
|
}
|
|
@@ -16836,13 +16992,13 @@ var chainMemberNames = (node) => {
|
|
|
16836
16992
|
const names = [];
|
|
16837
16993
|
let current = node;
|
|
16838
16994
|
for (; ; ) {
|
|
16839
|
-
if (current.type ===
|
|
16840
|
-
if (current.computed || current.property.type !==
|
|
16995
|
+
if (current.type === import_utils86.AST_NODE_TYPES.MemberExpression) {
|
|
16996
|
+
if (current.computed || current.property.type !== import_utils86.AST_NODE_TYPES.Identifier) return [];
|
|
16841
16997
|
names.push(current.property.name);
|
|
16842
16998
|
current = current.object;
|
|
16843
16999
|
continue;
|
|
16844
17000
|
}
|
|
16845
|
-
if (current.type ===
|
|
17001
|
+
if (current.type === import_utils86.AST_NODE_TYPES.CallExpression) {
|
|
16846
17002
|
current = current.callee;
|
|
16847
17003
|
continue;
|
|
16848
17004
|
}
|
|
@@ -16853,16 +17009,16 @@ var chainMemberNames = (node) => {
|
|
|
16853
17009
|
};
|
|
16854
17010
|
var unwrapExpression4 = (node) => {
|
|
16855
17011
|
let current = node;
|
|
16856
|
-
while (current.type ===
|
|
17012
|
+
while (current.type === import_utils86.AST_NODE_TYPES.TSAsExpression || current.type === import_utils86.AST_NODE_TYPES.TSSatisfiesExpression || current.type === import_utils86.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils86.AST_NODE_TYPES.TSTypeAssertion) {
|
|
16857
17013
|
current = current.expression;
|
|
16858
17014
|
}
|
|
16859
17015
|
return current;
|
|
16860
17016
|
};
|
|
16861
17017
|
var isModuleDeclarator = (node) => {
|
|
16862
17018
|
const declaration = node.parent;
|
|
16863
|
-
if (declaration.type !==
|
|
17019
|
+
if (declaration.type !== import_utils86.AST_NODE_TYPES.VariableDeclaration) return false;
|
|
16864
17020
|
const owner = declaration.parent;
|
|
16865
|
-
return owner.type ===
|
|
17021
|
+
return owner.type === import_utils86.AST_NODE_TYPES.Program || owner.type === import_utils86.AST_NODE_TYPES.ExportNamedDeclaration && owner.parent.type === import_utils86.AST_NODE_TYPES.Program;
|
|
16866
17022
|
};
|
|
16867
17023
|
var require_pascal_case_zod_schema_name_default = createRule({
|
|
16868
17024
|
name: "require-pascal-case-zod-schema-name",
|
|
@@ -16882,7 +17038,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
16882
17038
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
16883
17039
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
16884
17040
|
function resolvedBinding(identifier) {
|
|
16885
|
-
return
|
|
17041
|
+
return import_utils86.ASTUtils.findVariable(
|
|
16886
17042
|
context.sourceCode.getScope(identifier),
|
|
16887
17043
|
identifier.name
|
|
16888
17044
|
);
|
|
@@ -16903,8 +17059,8 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
16903
17059
|
}
|
|
16904
17060
|
function isConfirmedSchema(expression) {
|
|
16905
17061
|
const init = unwrapExpression4(expression);
|
|
16906
|
-
if (init.type ===
|
|
16907
|
-
if (init.type !==
|
|
17062
|
+
if (init.type === import_utils86.AST_NODE_TYPES.Identifier) return isSchemaBinding(init);
|
|
17063
|
+
if (init.type !== import_utils86.AST_NODE_TYPES.CallExpression || init.callee.type !== import_utils86.AST_NODE_TYPES.MemberExpression) {
|
|
16908
17064
|
return false;
|
|
16909
17065
|
}
|
|
16910
17066
|
const terminal = terminalMethodName(init.callee);
|
|
@@ -16924,7 +17080,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
16924
17080
|
ImportDeclaration(node) {
|
|
16925
17081
|
if (!isZodModule(node.source.value)) return;
|
|
16926
17082
|
for (const specifier of node.specifiers) {
|
|
16927
|
-
if (specifier.type ===
|
|
17083
|
+
if (specifier.type === import_utils86.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils86.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils86.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils86.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
16928
17084
|
recordZodBinding(specifier.local);
|
|
16929
17085
|
}
|
|
16930
17086
|
}
|
|
@@ -16933,7 +17089,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
16933
17089
|
if (!isModuleDeclarator(node)) return;
|
|
16934
17090
|
const init = node.init;
|
|
16935
17091
|
if (init === null || init === void 0) return;
|
|
16936
|
-
if (node.id.type !==
|
|
17092
|
+
if (node.id.type !== import_utils86.AST_NODE_TYPES.Identifier) return;
|
|
16937
17093
|
if (!isConfirmedSchema(init)) return;
|
|
16938
17094
|
const binding = resolvedBinding(node.id);
|
|
16939
17095
|
if (binding !== null) schemaBindings.add(binding);
|
|
@@ -17093,6 +17249,7 @@ var RULES = {
|
|
|
17093
17249
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
17094
17250
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
17095
17251
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
17252
|
+
"prefer-nullish-filter-predicate": prefer_nullish_filter_predicate_default,
|
|
17096
17253
|
"prefer-await-in-async-return": prefer_await_in_async_return_default,
|
|
17097
17254
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
17098
17255
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
@@ -17112,7 +17269,7 @@ var RULES = {
|
|
|
17112
17269
|
};
|
|
17113
17270
|
var meta = {
|
|
17114
17271
|
name: "@sarj/eslint-plugin",
|
|
17115
|
-
version: "15.
|
|
17272
|
+
version: "15.14.0"
|
|
17116
17273
|
};
|
|
17117
17274
|
var APPLICATION_ONLY_RULES = [
|
|
17118
17275
|
"no-restricted-library-load",
|
|
@@ -17174,6 +17331,7 @@ var RECOMMENDED_RULES = {
|
|
|
17174
17331
|
"@sarj/prefer-module-level-constant": "error",
|
|
17175
17332
|
"@sarj/prefer-module-level-schema": "error",
|
|
17176
17333
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
17334
|
+
"@sarj/prefer-nullish-filter-predicate": "error",
|
|
17177
17335
|
"@sarj/prefer-await-in-async-return": "error",
|
|
17178
17336
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
17179
17337
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
@@ -17252,6 +17410,7 @@ var STRICT_RULES = {
|
|
|
17252
17410
|
"@sarj/prefer-module-level-constant": "error",
|
|
17253
17411
|
"@sarj/prefer-module-level-schema": "error",
|
|
17254
17412
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
17413
|
+
"@sarj/prefer-nullish-filter-predicate": "error",
|
|
17255
17414
|
"@sarj/prefer-await-in-async-return": "error",
|
|
17256
17415
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
17257
17416
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|