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