@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.js
CHANGED
|
@@ -3674,8 +3674,6 @@ import {
|
|
|
3674
3674
|
} from "@typescript-eslint/utils";
|
|
3675
3675
|
|
|
3676
3676
|
// src/rules/_zod.ts
|
|
3677
|
-
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
3678
|
-
var ZOD_SUFFIX_RE = /Schema$/;
|
|
3679
3677
|
var ZOD_SCHEMA_NAME_RE = /Schema$|^Z[A-Z]/;
|
|
3680
3678
|
function isZodModule(source) {
|
|
3681
3679
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
@@ -12010,13 +12008,173 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
12010
12008
|
}
|
|
12011
12009
|
});
|
|
12012
12010
|
|
|
12013
|
-
// src/rules/prefer-
|
|
12011
|
+
// src/rules/prefer-nullish-filter-predicate.ts
|
|
12014
12012
|
import {
|
|
12013
|
+
AST_NODE_TYPES as AST_NODE_TYPES52,
|
|
12015
12014
|
ASTUtils as ASTUtils16,
|
|
12016
|
-
ESLintUtils as ESLintUtils5
|
|
12017
|
-
|
|
12015
|
+
ESLintUtils as ESLintUtils5
|
|
12016
|
+
} from "@typescript-eslint/utils";
|
|
12017
|
+
import ts3 from "typescript";
|
|
12018
|
+
var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
12019
|
+
summary: "Prefer an explicit nullish predicate when `filter(Boolean)` removes only nullish values but does not narrow the result type.",
|
|
12020
|
+
rationale: "An explicit nullish predicate preserves the same runtime elements while letting TypeScript remove `null` and `undefined` from the result.",
|
|
12021
|
+
remediation: "Replace `filter(Boolean)` with `filter((value) => value !== null && value !== undefined)`.",
|
|
12022
|
+
category: "correctness",
|
|
12023
|
+
autofix: "suggestion",
|
|
12024
|
+
limitations: [
|
|
12025
|
+
"The receiver must resolve to the built-in Array or ReadonlyArray filter method.",
|
|
12026
|
+
"Broad primitive types, falsy literals, any, unknown, generics, intersections, custom filters, and shadowed Boolean bindings are excluded."
|
|
12027
|
+
],
|
|
12028
|
+
examples: [
|
|
12029
|
+
{
|
|
12030
|
+
id: "explicit-nullish-predicate",
|
|
12031
|
+
title: "Nullish filtering narrows the result",
|
|
12032
|
+
outcome: "no-match",
|
|
12033
|
+
files: [
|
|
12034
|
+
{
|
|
12035
|
+
path: "src/users.ts",
|
|
12036
|
+
source: "declare const users: readonly ({ id: string } | null)[];\nconst present = users.filter((user) => user !== null && user !== undefined);"
|
|
12037
|
+
}
|
|
12038
|
+
],
|
|
12039
|
+
focusPath: "src/users.ts",
|
|
12040
|
+
expectedCount: 0,
|
|
12041
|
+
public: true
|
|
12042
|
+
},
|
|
12043
|
+
{
|
|
12044
|
+
id: "boolean-nullish-filter",
|
|
12045
|
+
title: "Boolean filtering loses nullish narrowing",
|
|
12046
|
+
outcome: "match",
|
|
12047
|
+
files: [
|
|
12048
|
+
{
|
|
12049
|
+
path: "src/users.ts",
|
|
12050
|
+
source: "declare const users: readonly ({ id: string } | null)[];\nconst present = users.filter(Boolean);"
|
|
12051
|
+
}
|
|
12052
|
+
],
|
|
12053
|
+
focusPath: "src/users.ts",
|
|
12054
|
+
expectedCount: 1,
|
|
12055
|
+
public: true
|
|
12056
|
+
}
|
|
12057
|
+
]
|
|
12058
|
+
};
|
|
12059
|
+
function isUnshadowedBoolean(node, context) {
|
|
12060
|
+
const variable = ASTUtils16.findVariable(context.sourceCode.getScope(node), node.name);
|
|
12061
|
+
return variable === null || variable.defs.length === 0;
|
|
12062
|
+
}
|
|
12063
|
+
function isBuiltinArrayFilter(node, services) {
|
|
12064
|
+
const checker = services.program.getTypeChecker();
|
|
12065
|
+
const property = services.esTreeNodeToTSNodeMap.get(node.property);
|
|
12066
|
+
const symbol = checker.getSymbolAtLocation(property);
|
|
12067
|
+
return symbol?.declarations?.some((declaration) => {
|
|
12068
|
+
const owner = declaration.parent;
|
|
12069
|
+
return ts3.isInterfaceDeclaration(owner) && (owner.name.text === "Array" || owner.name.text === "ReadonlyArray") && services.program.isSourceFileDefaultLibrary(owner.getSourceFile());
|
|
12070
|
+
}) ?? false;
|
|
12071
|
+
}
|
|
12072
|
+
function arrayElementType(node, services) {
|
|
12073
|
+
const checker = services.program.getTypeChecker();
|
|
12074
|
+
const receiver = services.esTreeNodeToTSNodeMap.get(node);
|
|
12075
|
+
return checker.getIndexTypeOfType(checker.getTypeAtLocation(receiver), ts3.IndexKind.Number) ?? null;
|
|
12076
|
+
}
|
|
12077
|
+
var NULLISH_FLAGS = ts3.TypeFlags.Null | ts3.TypeFlags.Undefined;
|
|
12078
|
+
var UNKNOWN_FLAGS = ts3.TypeFlags.Any | ts3.TypeFlags.Unknown | ts3.TypeFlags.TypeParameter | ts3.TypeFlags.Intersection | ts3.TypeFlags.Enum | ts3.TypeFlags.EnumLiteral;
|
|
12079
|
+
function isNullishPlusTruthy(type, checker) {
|
|
12080
|
+
const members = type.isUnion() ? type.types : [type];
|
|
12081
|
+
let sawNullish = false;
|
|
12082
|
+
for (const member of members) {
|
|
12083
|
+
if ((member.flags & NULLISH_FLAGS) !== 0) {
|
|
12084
|
+
sawNullish = true;
|
|
12085
|
+
} else if ((member.flags & ts3.TypeFlags.Never) === 0 && !isProvablyTruthy(member, checker)) {
|
|
12086
|
+
return false;
|
|
12087
|
+
}
|
|
12088
|
+
}
|
|
12089
|
+
return sawNullish;
|
|
12090
|
+
}
|
|
12091
|
+
function isProvablyTruthy(type, checker) {
|
|
12092
|
+
if ((type.flags & UNKNOWN_FLAGS) !== 0) return false;
|
|
12093
|
+
if ((type.flags & ts3.TypeFlags.Object) !== 0) {
|
|
12094
|
+
return ![
|
|
12095
|
+
checker.getStringType(),
|
|
12096
|
+
checker.getNumberType(),
|
|
12097
|
+
checker.getBigIntType(),
|
|
12098
|
+
checker.getBooleanType()
|
|
12099
|
+
].some((primitive) => checker.isTypeAssignableTo(primitive, type));
|
|
12100
|
+
}
|
|
12101
|
+
if ((type.flags & (ts3.TypeFlags.ESSymbol | ts3.TypeFlags.UniqueESSymbol)) !== 0) return true;
|
|
12102
|
+
if ((type.flags & ts3.TypeFlags.BooleanLiteral) !== 0) {
|
|
12103
|
+
return type.intrinsicName === "true";
|
|
12104
|
+
}
|
|
12105
|
+
if ((type.flags & ts3.TypeFlags.StringLiteral) !== 0) {
|
|
12106
|
+
return type.value.length > 0;
|
|
12107
|
+
}
|
|
12108
|
+
if ((type.flags & ts3.TypeFlags.NumberLiteral) !== 0) {
|
|
12109
|
+
const value = type.value;
|
|
12110
|
+
return value !== 0 && !Number.isNaN(value);
|
|
12111
|
+
}
|
|
12112
|
+
if ((type.flags & ts3.TypeFlags.BigIntLiteral) !== 0) {
|
|
12113
|
+
return type.value.base10Value !== "0";
|
|
12114
|
+
}
|
|
12115
|
+
return false;
|
|
12116
|
+
}
|
|
12117
|
+
function availableParameterName(node, context) {
|
|
12118
|
+
for (const name of ["value", "item", "element", "candidate"]) {
|
|
12119
|
+
if (ASTUtils16.findVariable(context.sourceCode.getScope(node), name) === null) return name;
|
|
12120
|
+
}
|
|
12121
|
+
return null;
|
|
12122
|
+
}
|
|
12123
|
+
var prefer_nullish_filter_predicate_default = createRule({
|
|
12124
|
+
name: "prefer-nullish-filter-predicate",
|
|
12125
|
+
documentation: PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION,
|
|
12126
|
+
meta: {
|
|
12127
|
+
type: "suggestion",
|
|
12128
|
+
docs: { description: PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION.summary },
|
|
12129
|
+
hasSuggestions: true,
|
|
12130
|
+
schema: [],
|
|
12131
|
+
messages: {
|
|
12132
|
+
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.",
|
|
12133
|
+
replaceBoolean: "Replace `Boolean` with an explicit nullish predicate."
|
|
12134
|
+
}
|
|
12135
|
+
},
|
|
12136
|
+
defaultOptions: [],
|
|
12137
|
+
create(context) {
|
|
12138
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
12139
|
+
let services;
|
|
12140
|
+
try {
|
|
12141
|
+
services = ESLintUtils5.getParserServices(context);
|
|
12142
|
+
} catch {
|
|
12143
|
+
services = null;
|
|
12144
|
+
}
|
|
12145
|
+
if (services === null) return {};
|
|
12146
|
+
return {
|
|
12147
|
+
CallExpression(node) {
|
|
12148
|
+
const callee = node.callee;
|
|
12149
|
+
const callback = node.arguments[0];
|
|
12150
|
+
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES52.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES52.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES52.Identifier || callee.property.name !== "filter" || !isUnshadowedBoolean(callback, context) || !isBuiltinArrayFilter(callee, services)) return;
|
|
12151
|
+
const elementType = arrayElementType(callee.object, services);
|
|
12152
|
+
const checker = services.program.getTypeChecker();
|
|
12153
|
+
if (elementType === null || !isNullishPlusTruthy(elementType, checker)) return;
|
|
12154
|
+
const parameter = availableParameterName(node, context);
|
|
12155
|
+
context.report({
|
|
12156
|
+
node: callback,
|
|
12157
|
+
messageId: "preferNullishPredicate",
|
|
12158
|
+
suggest: parameter === null ? null : [{
|
|
12159
|
+
messageId: "replaceBoolean",
|
|
12160
|
+
fix: (fixer) => fixer.replaceText(
|
|
12161
|
+
callback,
|
|
12162
|
+
`(${parameter}) => ${parameter} !== null && ${parameter} !== undefined`
|
|
12163
|
+
)
|
|
12164
|
+
}]
|
|
12165
|
+
});
|
|
12166
|
+
}
|
|
12167
|
+
};
|
|
12168
|
+
}
|
|
12169
|
+
});
|
|
12170
|
+
|
|
12171
|
+
// src/rules/prefer-await-in-async-return.ts
|
|
12172
|
+
import {
|
|
12173
|
+
ASTUtils as ASTUtils17,
|
|
12174
|
+
ESLintUtils as ESLintUtils6,
|
|
12175
|
+
AST_NODE_TYPES as AST_NODE_TYPES53
|
|
12018
12176
|
} from "@typescript-eslint/utils";
|
|
12019
|
-
import * as
|
|
12177
|
+
import * as ts4 from "typescript";
|
|
12020
12178
|
var PREFER_AWAIT_IN_ASYNC_RETURN_DOCUMENTATION = {
|
|
12021
12179
|
summary: "Prefer explicit `await` when an async function directly returns one typed Promise `.then` transform.",
|
|
12022
12180
|
rationale: "Mixing a directly returned Promise callback into otherwise async control flow makes sequencing and failures harder to read.",
|
|
@@ -12057,10 +12215,10 @@ var PREFER_AWAIT_IN_ASYNC_RETURN_DOCUMENTATION = {
|
|
|
12057
12215
|
};
|
|
12058
12216
|
function directAsyncReturnOwner(node) {
|
|
12059
12217
|
const parent = node.parent;
|
|
12060
|
-
if (parent.type ===
|
|
12218
|
+
if (parent.type === AST_NODE_TYPES53.ArrowFunctionExpression && parent.body === node) {
|
|
12061
12219
|
return parent.async && !parent.generator ? parent : null;
|
|
12062
12220
|
}
|
|
12063
|
-
if (parent.type !==
|
|
12221
|
+
if (parent.type !== AST_NODE_TYPES53.ReturnStatement || parent.argument !== node) {
|
|
12064
12222
|
return null;
|
|
12065
12223
|
}
|
|
12066
12224
|
let owner = parent.parent;
|
|
@@ -12070,15 +12228,15 @@ function directAsyncReturnOwner(node) {
|
|
|
12070
12228
|
return owner !== void 0 && owner.async && !owner.generator ? owner : null;
|
|
12071
12229
|
}
|
|
12072
12230
|
function isRuntimeFunction(node) {
|
|
12073
|
-
return node.type ===
|
|
12231
|
+
return node.type === AST_NODE_TYPES53.ArrowFunctionExpression || node.type === AST_NODE_TYPES53.FunctionDeclaration || node.type === AST_NODE_TYPES53.FunctionExpression;
|
|
12074
12232
|
}
|
|
12075
12233
|
function promiseThenReceiver(node) {
|
|
12076
12234
|
const callee = node.callee;
|
|
12077
|
-
if (callee.type !==
|
|
12235
|
+
if (callee.type !== AST_NODE_TYPES53.MemberExpression || callee.computed || callee.optional || callee.property.type !== AST_NODE_TYPES53.Identifier || callee.property.name !== "then" || node.optional || node.arguments.length !== 1) {
|
|
12078
12236
|
return null;
|
|
12079
12237
|
}
|
|
12080
12238
|
const callback = node.arguments[0];
|
|
12081
|
-
if (callback === void 0 || callback.type !==
|
|
12239
|
+
if (callback === void 0 || callback.type !== AST_NODE_TYPES53.ArrowFunctionExpression && callback.type !== AST_NODE_TYPES53.FunctionExpression) {
|
|
12082
12240
|
return null;
|
|
12083
12241
|
}
|
|
12084
12242
|
return callee.object;
|
|
@@ -12087,14 +12245,14 @@ function isProvenPromiseLike(node, services) {
|
|
|
12087
12245
|
const checker = services.program.getTypeChecker();
|
|
12088
12246
|
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
|
|
12089
12247
|
const receiverType = checker.getTypeAtLocation(tsNode);
|
|
12090
|
-
if ((receiverType.flags & (
|
|
12248
|
+
if ((receiverType.flags & (ts4.TypeFlags.Any | ts4.TypeFlags.Unknown | ts4.TypeFlags.Never)) !== 0) {
|
|
12091
12249
|
return false;
|
|
12092
12250
|
}
|
|
12093
12251
|
const thenSymbol = checker.getPropertyOfType(receiverType, "then");
|
|
12094
12252
|
const hasBuiltInPromiseDeclaration = thenSymbol?.declarations?.some(
|
|
12095
12253
|
(declaration) => {
|
|
12096
12254
|
let owner = declaration.parent;
|
|
12097
|
-
while (owner !== void 0 && !
|
|
12255
|
+
while (owner !== void 0 && !ts4.isInterfaceDeclaration(owner)) {
|
|
12098
12256
|
owner = owner.parent;
|
|
12099
12257
|
}
|
|
12100
12258
|
return owner !== void 0 && (owner.name.text === "Promise" || owner.name.text === "PromiseLike") && services.program.isSourceFileDefaultLibrary(owner.getSourceFile());
|
|
@@ -12119,32 +12277,32 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
12119
12277
|
create(context) {
|
|
12120
12278
|
let services;
|
|
12121
12279
|
try {
|
|
12122
|
-
services =
|
|
12280
|
+
services = ESLintUtils6.getParserServices(context);
|
|
12123
12281
|
} catch {
|
|
12124
12282
|
services = null;
|
|
12125
12283
|
}
|
|
12126
12284
|
if (services === null) return {};
|
|
12127
12285
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
12128
12286
|
const rememberFrameworkLoader = (identifier) => {
|
|
12129
|
-
const variable =
|
|
12287
|
+
const variable = ASTUtils17.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
12130
12288
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
12131
12289
|
};
|
|
12132
12290
|
const isFrameworkLoaderCallback = (owner) => {
|
|
12133
12291
|
const parent = owner.parent;
|
|
12134
|
-
if (parent.type !==
|
|
12135
|
-
const variable =
|
|
12292
|
+
if (parent.type !== AST_NODE_TYPES53.CallExpression || parent.arguments[0] !== owner || parent.callee.type !== AST_NODE_TYPES53.Identifier) return false;
|
|
12293
|
+
const variable = ASTUtils17.findVariable(context.sourceCode.getScope(parent.callee), parent.callee.name);
|
|
12136
12294
|
return variable !== null && frameworkLoaders.has(variable);
|
|
12137
12295
|
};
|
|
12138
12296
|
return {
|
|
12139
12297
|
ImportDeclaration(node) {
|
|
12140
12298
|
if (node.source.value === "react") {
|
|
12141
12299
|
for (const specifier of node.specifiers) {
|
|
12142
|
-
if (specifier.type ===
|
|
12300
|
+
if (specifier.type === AST_NODE_TYPES53.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES53.Identifier ? specifier.imported.name : specifier.imported.value) === "lazy") rememberFrameworkLoader(specifier.local);
|
|
12143
12301
|
}
|
|
12144
12302
|
}
|
|
12145
12303
|
if (node.source.value === "next/dynamic") {
|
|
12146
12304
|
for (const specifier of node.specifiers) {
|
|
12147
|
-
if (specifier.type ===
|
|
12305
|
+
if (specifier.type === AST_NODE_TYPES53.ImportDefaultSpecifier) rememberFrameworkLoader(specifier.local);
|
|
12148
12306
|
}
|
|
12149
12307
|
}
|
|
12150
12308
|
},
|
|
@@ -12162,7 +12320,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
12162
12320
|
});
|
|
12163
12321
|
|
|
12164
12322
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
12165
|
-
import { AST_NODE_TYPES as
|
|
12323
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54 } from "@typescript-eslint/utils";
|
|
12166
12324
|
var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
12167
12325
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
12168
12326
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -12177,9 +12335,9 @@ var PREFER_SCHEMA_FOR_API_PAYLOAD_DOCUMENTATION = {
|
|
|
12177
12335
|
var unwrap4 = (node) => {
|
|
12178
12336
|
let current = node;
|
|
12179
12337
|
while (current !== null && current !== void 0) {
|
|
12180
|
-
if (current.type ===
|
|
12338
|
+
if (current.type === AST_NODE_TYPES54.TSAsExpression || current.type === AST_NODE_TYPES54.TSTypeAssertion || current.type === AST_NODE_TYPES54.TSNonNullExpression || current.type === AST_NODE_TYPES54.TSSatisfiesExpression) {
|
|
12181
12339
|
current = current.expression;
|
|
12182
|
-
} else if (current.type ===
|
|
12340
|
+
} else if (current.type === AST_NODE_TYPES54.ChainExpression) {
|
|
12183
12341
|
current = current.expression;
|
|
12184
12342
|
} else {
|
|
12185
12343
|
break;
|
|
@@ -12194,23 +12352,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
12194
12352
|
]);
|
|
12195
12353
|
var isSchemaParseReference = (node) => {
|
|
12196
12354
|
const inner = unwrap4(node);
|
|
12197
|
-
return inner !== null && inner.type ===
|
|
12355
|
+
return inner !== null && inner.type === AST_NODE_TYPES54.MemberExpression && !inner.computed && inner.property.type === AST_NODE_TYPES54.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
12198
12356
|
};
|
|
12199
12357
|
var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
12200
12358
|
let current = unwrap4(node);
|
|
12201
12359
|
if (current === null) return false;
|
|
12202
|
-
if (current.type ===
|
|
12360
|
+
if (current.type === AST_NODE_TYPES54.AwaitExpression) {
|
|
12203
12361
|
current = unwrap4(current.argument);
|
|
12204
12362
|
}
|
|
12205
|
-
if (current === null || current.type !==
|
|
12363
|
+
if (current === null || current.type !== AST_NODE_TYPES54.CallExpression) {
|
|
12206
12364
|
return false;
|
|
12207
12365
|
}
|
|
12208
12366
|
const callee = unwrap4(current.callee);
|
|
12209
|
-
if (callee === null || callee.type !==
|
|
12367
|
+
if (callee === null || callee.type !== AST_NODE_TYPES54.MemberExpression) {
|
|
12210
12368
|
return false;
|
|
12211
12369
|
}
|
|
12212
12370
|
const property = unwrap4(callee.property);
|
|
12213
|
-
if (property === null || property.type !==
|
|
12371
|
+
if (property === null || property.type !== AST_NODE_TYPES54.Identifier) {
|
|
12214
12372
|
return false;
|
|
12215
12373
|
}
|
|
12216
12374
|
if (property.name === "json") {
|
|
@@ -12220,17 +12378,17 @@ var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
|
12220
12378
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
12221
12379
|
}
|
|
12222
12380
|
const object = unwrap4(callee.object);
|
|
12223
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
12381
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES54.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
12224
12382
|
};
|
|
12225
12383
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
12226
12384
|
var isDirectLocalFileRead = (node) => {
|
|
12227
12385
|
let current = unwrap4(node);
|
|
12228
|
-
if (current?.type ===
|
|
12386
|
+
if (current?.type === AST_NODE_TYPES54.AwaitExpression) {
|
|
12229
12387
|
current = unwrap4(current.argument);
|
|
12230
12388
|
}
|
|
12231
|
-
if (current?.type !==
|
|
12389
|
+
if (current?.type !== AST_NODE_TYPES54.CallExpression) return false;
|
|
12232
12390
|
const callee = unwrap4(current.callee);
|
|
12233
|
-
const name = callee?.type ===
|
|
12391
|
+
const name = callee?.type === AST_NODE_TYPES54.Identifier ? callee.name : callee?.type === AST_NODE_TYPES54.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES54.Identifier ? callee.property.name : null;
|
|
12234
12392
|
return name !== null && FILE_READ_RE.test(name);
|
|
12235
12393
|
};
|
|
12236
12394
|
var isLocalFileRead = (node) => {
|
|
@@ -12257,15 +12415,15 @@ var isLocalFileRead = (node) => {
|
|
|
12257
12415
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
12258
12416
|
var isInsideAssertion = (node) => {
|
|
12259
12417
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12260
|
-
if (current.type !==
|
|
12418
|
+
if (current.type !== AST_NODE_TYPES54.CallExpression) continue;
|
|
12261
12419
|
let callee = current.callee;
|
|
12262
|
-
while (callee.type ===
|
|
12420
|
+
while (callee.type === AST_NODE_TYPES54.MemberExpression) {
|
|
12263
12421
|
callee = callee.object;
|
|
12264
12422
|
}
|
|
12265
|
-
if (callee.type ===
|
|
12423
|
+
if (callee.type === AST_NODE_TYPES54.CallExpression) {
|
|
12266
12424
|
callee = callee.callee;
|
|
12267
12425
|
}
|
|
12268
|
-
if (callee.type ===
|
|
12426
|
+
if (callee.type === AST_NODE_TYPES54.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
12269
12427
|
return true;
|
|
12270
12428
|
}
|
|
12271
12429
|
}
|
|
@@ -12284,22 +12442,22 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
12284
12442
|
var isValidationRead = (node) => {
|
|
12285
12443
|
let current = node;
|
|
12286
12444
|
let parent = current.parent;
|
|
12287
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
12445
|
+
while (parent !== null && parent !== void 0 && (parent.type === AST_NODE_TYPES54.TSAsExpression || parent.type === AST_NODE_TYPES54.TSTypeAssertion || parent.type === AST_NODE_TYPES54.TSNonNullExpression || parent.type === AST_NODE_TYPES54.TSSatisfiesExpression || parent.type === AST_NODE_TYPES54.ChainExpression)) {
|
|
12288
12446
|
current = parent;
|
|
12289
12447
|
parent = parent.parent;
|
|
12290
12448
|
}
|
|
12291
12449
|
if (parent === null || parent === void 0) return false;
|
|
12292
|
-
if (parent.type ===
|
|
12450
|
+
if (parent.type === AST_NODE_TYPES54.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
12293
12451
|
return true;
|
|
12294
12452
|
}
|
|
12295
|
-
if (parent.type !==
|
|
12453
|
+
if (parent.type !== AST_NODE_TYPES54.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
12296
12454
|
return false;
|
|
12297
12455
|
}
|
|
12298
12456
|
const callee = parent.callee;
|
|
12299
|
-
if (callee.type ===
|
|
12457
|
+
if (callee.type === AST_NODE_TYPES54.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES54.Identifier && callee.object.name === "Array" && callee.property.type === AST_NODE_TYPES54.Identifier && callee.property.name === "isArray") {
|
|
12300
12458
|
return parent.arguments.length === 1;
|
|
12301
12459
|
}
|
|
12302
|
-
return callee.type ===
|
|
12460
|
+
return callee.type === AST_NODE_TYPES54.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
12303
12461
|
};
|
|
12304
12462
|
var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
12305
12463
|
"bigint",
|
|
@@ -12310,13 +12468,13 @@ var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
|
12310
12468
|
"undefined"
|
|
12311
12469
|
]);
|
|
12312
12470
|
var bindingValidationPolarity = (test, bindingName) => {
|
|
12313
|
-
if (test.type ===
|
|
12471
|
+
if (test.type === AST_NODE_TYPES54.UnaryExpression && test.operator === "!") {
|
|
12314
12472
|
const inner = bindingValidationPolarity(test.argument, bindingName);
|
|
12315
12473
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
12316
12474
|
}
|
|
12317
|
-
if (test.type ===
|
|
12318
|
-
const typeofName = (node) => node.type ===
|
|
12319
|
-
const literalType = (node) => node.type ===
|
|
12475
|
+
if (test.type === AST_NODE_TYPES54.BinaryExpression) {
|
|
12476
|
+
const typeofName = (node) => node.type === AST_NODE_TYPES54.UnaryExpression && node.operator === "typeof" && node.argument.type === AST_NODE_TYPES54.Identifier ? node.argument.name : null;
|
|
12477
|
+
const literalType = (node) => node.type === AST_NODE_TYPES54.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value) ? node.value : null;
|
|
12320
12478
|
const matches = typeofName(test.left) === bindingName && literalType(test.right) !== null || typeofName(test.right) === bindingName && literalType(test.left) !== null;
|
|
12321
12479
|
if (!matches) return null;
|
|
12322
12480
|
if (test.operator === "===" || test.operator === "==") {
|
|
@@ -12324,9 +12482,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
12324
12482
|
}
|
|
12325
12483
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
12326
12484
|
}
|
|
12327
|
-
return test.type ===
|
|
12485
|
+
return test.type === AST_NODE_TYPES54.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES54.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES54.MemberExpression && !test.callee.computed && test.callee.object.type === AST_NODE_TYPES54.Identifier && test.callee.object.name === "Array" && test.callee.property.type === AST_NODE_TYPES54.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
12328
12486
|
};
|
|
12329
|
-
var plainMemberAccess = (node) => node.type ===
|
|
12487
|
+
var plainMemberAccess = (node) => node.type === AST_NODE_TYPES54.MemberExpression && !node.computed && node.object.type === AST_NODE_TYPES54.Identifier && node.property.type === AST_NODE_TYPES54.Identifier ? { object: node.object.name, property: node.property.name } : null;
|
|
12330
12488
|
var isSamePlainMember = (node, access) => {
|
|
12331
12489
|
const candidate2 = plainMemberAccess(node);
|
|
12332
12490
|
return candidate2 !== null && candidate2.object === access.object && candidate2.property === access.property;
|
|
@@ -12334,19 +12492,19 @@ var isSamePlainMember = (node, access) => {
|
|
|
12334
12492
|
var nodeWithin2 = (node, container) => node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
12335
12493
|
var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
12336
12494
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12337
|
-
if (current.type ===
|
|
12495
|
+
if (current.type === AST_NODE_TYPES54.ConditionalExpression) {
|
|
12338
12496
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
12339
12497
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
12340
12498
|
return true;
|
|
12341
12499
|
}
|
|
12342
12500
|
}
|
|
12343
|
-
if (current.type ===
|
|
12501
|
+
if (current.type === AST_NODE_TYPES54.IfStatement) {
|
|
12344
12502
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
12345
12503
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
12346
12504
|
return true;
|
|
12347
12505
|
}
|
|
12348
12506
|
}
|
|
12349
|
-
if (current.type ===
|
|
12507
|
+
if (current.type === AST_NODE_TYPES54.FunctionDeclaration || current.type === AST_NODE_TYPES54.FunctionExpression || current.type === AST_NODE_TYPES54.ArrowFunctionExpression) {
|
|
12350
12508
|
return false;
|
|
12351
12509
|
}
|
|
12352
12510
|
}
|
|
@@ -12354,32 +12512,32 @@ var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
|
12354
12512
|
};
|
|
12355
12513
|
var isMemberUseWithinValidatedBranch = (node, access) => {
|
|
12356
12514
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12357
|
-
if (current.type ===
|
|
12515
|
+
if (current.type === AST_NODE_TYPES54.ConditionalExpression) {
|
|
12358
12516
|
const polarity = memberValidationPolarity(current.test, access);
|
|
12359
12517
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
12360
12518
|
return true;
|
|
12361
12519
|
}
|
|
12362
12520
|
}
|
|
12363
|
-
if (current.type ===
|
|
12521
|
+
if (current.type === AST_NODE_TYPES54.IfStatement) {
|
|
12364
12522
|
const polarity = memberValidationPolarity(current.test, access);
|
|
12365
12523
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
12366
12524
|
return true;
|
|
12367
12525
|
}
|
|
12368
12526
|
}
|
|
12369
|
-
if (current.type ===
|
|
12527
|
+
if (current.type === AST_NODE_TYPES54.FunctionDeclaration || current.type === AST_NODE_TYPES54.FunctionExpression || current.type === AST_NODE_TYPES54.ArrowFunctionExpression) {
|
|
12370
12528
|
return false;
|
|
12371
12529
|
}
|
|
12372
12530
|
}
|
|
12373
12531
|
return false;
|
|
12374
12532
|
};
|
|
12375
12533
|
var memberValidationPolarity = (test, access) => {
|
|
12376
|
-
if (test.type ===
|
|
12534
|
+
if (test.type === AST_NODE_TYPES54.UnaryExpression && test.operator === "!") {
|
|
12377
12535
|
const inner = memberValidationPolarity(test.argument, access);
|
|
12378
12536
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
12379
12537
|
}
|
|
12380
|
-
if (test.type ===
|
|
12381
|
-
const isMatchingTypeof = (node) => node.type ===
|
|
12382
|
-
const isPrimitiveType = (node) => node.type ===
|
|
12538
|
+
if (test.type === AST_NODE_TYPES54.BinaryExpression) {
|
|
12539
|
+
const isMatchingTypeof = (node) => node.type === AST_NODE_TYPES54.UnaryExpression && node.operator === "typeof" && isSamePlainMember(node.argument, access);
|
|
12540
|
+
const isPrimitiveType = (node) => node.type === AST_NODE_TYPES54.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value);
|
|
12383
12541
|
if (!(isMatchingTypeof(test.left) && isPrimitiveType(test.right) || isMatchingTypeof(test.right) && isPrimitiveType(test.left))) {
|
|
12384
12542
|
return null;
|
|
12385
12543
|
}
|
|
@@ -12388,15 +12546,15 @@ var memberValidationPolarity = (test, access) => {
|
|
|
12388
12546
|
}
|
|
12389
12547
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
12390
12548
|
}
|
|
12391
|
-
return test.type ===
|
|
12549
|
+
return test.type === AST_NODE_TYPES54.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES54.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES54.MemberExpression && !test.callee.computed && test.callee.object.type === AST_NODE_TYPES54.Identifier && test.callee.object.name === "Array" && test.callee.property.type === AST_NODE_TYPES54.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
12392
12550
|
};
|
|
12393
12551
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
12394
12552
|
const isValidationReference = (identifier) => {
|
|
12395
12553
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12396
|
-
if ((current.type ===
|
|
12554
|
+
if ((current.type === AST_NODE_TYPES54.BinaryExpression || current.type === AST_NODE_TYPES54.CallExpression || current.type === AST_NODE_TYPES54.UnaryExpression) && bindingValidationPolarity(current, identifier.name) !== null) {
|
|
12397
12555
|
return true;
|
|
12398
12556
|
}
|
|
12399
|
-
if (current.type !==
|
|
12557
|
+
if (current.type !== AST_NODE_TYPES54.UnaryExpression && current.type !== AST_NODE_TYPES54.MemberExpression && current.type !== AST_NODE_TYPES54.CallExpression) {
|
|
12400
12558
|
return false;
|
|
12401
12559
|
}
|
|
12402
12560
|
}
|
|
@@ -12404,7 +12562,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12404
12562
|
};
|
|
12405
12563
|
const isGuardedUse = (identifier) => {
|
|
12406
12564
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
12407
|
-
if (current.type ===
|
|
12565
|
+
if (current.type === AST_NODE_TYPES54.ConditionalExpression) {
|
|
12408
12566
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
12409
12567
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
12410
12568
|
return true;
|
|
@@ -12413,7 +12571,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12413
12571
|
return true;
|
|
12414
12572
|
}
|
|
12415
12573
|
}
|
|
12416
|
-
if (current.type ===
|
|
12574
|
+
if (current.type === AST_NODE_TYPES54.IfStatement) {
|
|
12417
12575
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
12418
12576
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
12419
12577
|
return true;
|
|
@@ -12422,14 +12580,14 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12422
12580
|
return true;
|
|
12423
12581
|
}
|
|
12424
12582
|
}
|
|
12425
|
-
if (current.type ===
|
|
12583
|
+
if (current.type === AST_NODE_TYPES54.FunctionDeclaration || current.type === AST_NODE_TYPES54.FunctionExpression || current.type === AST_NODE_TYPES54.ArrowFunctionExpression) {
|
|
12426
12584
|
return false;
|
|
12427
12585
|
}
|
|
12428
12586
|
}
|
|
12429
12587
|
return false;
|
|
12430
12588
|
};
|
|
12431
12589
|
const declarator = member.parent;
|
|
12432
|
-
if (declarator.type !==
|
|
12590
|
+
if (declarator.type !== AST_NODE_TYPES54.VariableDeclarator || declarator.init !== member || declarator.id.type !== AST_NODE_TYPES54.Identifier || declarator.parent.type !== AST_NODE_TYPES54.VariableDeclaration || declarator.parent.kind !== "const") {
|
|
12433
12591
|
return false;
|
|
12434
12592
|
}
|
|
12435
12593
|
const extracted = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -12437,7 +12595,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
12437
12595
|
let hasValueUse = false;
|
|
12438
12596
|
for (const reference of extracted.references) {
|
|
12439
12597
|
const identifier = reference.identifier;
|
|
12440
|
-
if (identifier.type !==
|
|
12598
|
+
if (identifier.type !== AST_NODE_TYPES54.Identifier) return false;
|
|
12441
12599
|
if (nodeWithin2(identifier, declarator)) continue;
|
|
12442
12600
|
if (isValidationReference(identifier)) continue;
|
|
12443
12601
|
hasValueUse = true;
|
|
@@ -12450,17 +12608,17 @@ var isGuardTestPosition = (node) => {
|
|
|
12450
12608
|
let parent = current.parent;
|
|
12451
12609
|
while (parent !== void 0 && parent !== null) {
|
|
12452
12610
|
switch (parent.type) {
|
|
12453
|
-
case
|
|
12454
|
-
case
|
|
12455
|
-
case
|
|
12611
|
+
case AST_NODE_TYPES54.UnaryExpression:
|
|
12612
|
+
case AST_NODE_TYPES54.LogicalExpression:
|
|
12613
|
+
case AST_NODE_TYPES54.ChainExpression:
|
|
12456
12614
|
current = parent;
|
|
12457
12615
|
parent = parent.parent;
|
|
12458
12616
|
continue;
|
|
12459
|
-
case
|
|
12460
|
-
case
|
|
12461
|
-
case
|
|
12462
|
-
case
|
|
12463
|
-
case
|
|
12617
|
+
case AST_NODE_TYPES54.IfStatement:
|
|
12618
|
+
case AST_NODE_TYPES54.ConditionalExpression:
|
|
12619
|
+
case AST_NODE_TYPES54.WhileStatement:
|
|
12620
|
+
case AST_NODE_TYPES54.DoWhileStatement:
|
|
12621
|
+
case AST_NODE_TYPES54.ForStatement:
|
|
12464
12622
|
return parent.test === current;
|
|
12465
12623
|
default:
|
|
12466
12624
|
return false;
|
|
@@ -12470,7 +12628,7 @@ var isGuardTestPosition = (node) => {
|
|
|
12470
12628
|
};
|
|
12471
12629
|
var unvalidatedVariableRef = (node, scope, tracked) => {
|
|
12472
12630
|
const unwrapped = unwrap4(node);
|
|
12473
|
-
if (unwrapped === null || unwrapped.type !==
|
|
12631
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES54.Identifier) {
|
|
12474
12632
|
return null;
|
|
12475
12633
|
}
|
|
12476
12634
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -12499,7 +12657,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12499
12657
|
const localFileTextVariables = /* @__PURE__ */ new Set();
|
|
12500
12658
|
const localFileTextRef = (node, scope) => {
|
|
12501
12659
|
const unwrapped = unwrap4(node);
|
|
12502
|
-
if (unwrapped?.type !==
|
|
12660
|
+
if (unwrapped?.type !== AST_NODE_TYPES54.Identifier) return null;
|
|
12503
12661
|
const variable = findVariable2(scope, unwrapped.name);
|
|
12504
12662
|
return variable !== null && localFileTextVariables.has(variable) ? variable : null;
|
|
12505
12663
|
};
|
|
@@ -12568,7 +12726,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12568
12726
|
return {
|
|
12569
12727
|
VariableDeclarator(node) {
|
|
12570
12728
|
const scope = context.sourceCode.getScope(node);
|
|
12571
|
-
if (node.id.type ===
|
|
12729
|
+
if (node.id.type === AST_NODE_TYPES54.Identifier) {
|
|
12572
12730
|
const variable = context.sourceCode.getDeclaredVariables(node)[0];
|
|
12573
12731
|
if (variable !== void 0) {
|
|
12574
12732
|
updateLocalFileText(variable, node.init, scope);
|
|
@@ -12576,7 +12734,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12576
12734
|
trackInitializer(node, scope);
|
|
12577
12735
|
return;
|
|
12578
12736
|
}
|
|
12579
|
-
if (node.id.type ===
|
|
12737
|
+
if (node.id.type === AST_NODE_TYPES54.ObjectPattern || node.id.type === AST_NODE_TYPES54.ArrayPattern) {
|
|
12580
12738
|
if (isRawPayloadSource(
|
|
12581
12739
|
node.init,
|
|
12582
12740
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
@@ -12593,7 +12751,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12593
12751
|
},
|
|
12594
12752
|
AssignmentExpression(node) {
|
|
12595
12753
|
const scope = context.sourceCode.getScope(node);
|
|
12596
|
-
if (node.left.type ===
|
|
12754
|
+
if (node.left.type === AST_NODE_TYPES54.Identifier) {
|
|
12597
12755
|
const variable = findVariable2(scope, node.left.name);
|
|
12598
12756
|
if (variable === null) return;
|
|
12599
12757
|
const isLocalText = (candidate2) => localFileTextRef(candidate2, scope) !== null;
|
|
@@ -12607,7 +12765,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12607
12765
|
}
|
|
12608
12766
|
return;
|
|
12609
12767
|
}
|
|
12610
|
-
if (node.left.type ===
|
|
12768
|
+
if (node.left.type === AST_NODE_TYPES54.ObjectPattern || node.left.type === AST_NODE_TYPES54.ArrayPattern) {
|
|
12611
12769
|
if (isRawPayloadSource(
|
|
12612
12770
|
node.right,
|
|
12613
12771
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
@@ -12627,15 +12785,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12627
12785
|
}
|
|
12628
12786
|
},
|
|
12629
12787
|
CallExpression(node) {
|
|
12630
|
-
if (node.callee.type !==
|
|
12788
|
+
if (node.callee.type !== AST_NODE_TYPES54.Identifier) return;
|
|
12631
12789
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
12632
12790
|
return;
|
|
12633
12791
|
}
|
|
12634
12792
|
const scope = context.sourceCode.getScope(node);
|
|
12635
12793
|
for (const arg of node.arguments) {
|
|
12636
|
-
if (arg.type ===
|
|
12794
|
+
if (arg.type === AST_NODE_TYPES54.SpreadElement) continue;
|
|
12637
12795
|
const unwrapped = unwrap4(arg);
|
|
12638
|
-
if (unwrapped === null || unwrapped.type !==
|
|
12796
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES54.Identifier) {
|
|
12639
12797
|
continue;
|
|
12640
12798
|
}
|
|
12641
12799
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -12652,14 +12810,14 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12652
12810
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
12653
12811
|
)) {
|
|
12654
12812
|
const parent = node.parent;
|
|
12655
|
-
if (parent.type ===
|
|
12813
|
+
if (parent.type === AST_NODE_TYPES54.CallExpression && parent.callee === node && node.property.type === AST_NODE_TYPES54.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
12656
12814
|
return;
|
|
12657
12815
|
}
|
|
12658
12816
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
12659
12817
|
return;
|
|
12660
12818
|
}
|
|
12661
|
-
const variable = obj?.type ===
|
|
12662
|
-
if (variable !== null && obj?.type ===
|
|
12819
|
+
const variable = obj?.type === AST_NODE_TYPES54.Identifier ? unvalidatedVariableRef(obj, scope, unvalidatedVariables) : null;
|
|
12820
|
+
if (variable !== null && obj?.type === AST_NODE_TYPES54.Identifier) {
|
|
12663
12821
|
if (isUseWithinValidatedBranch(node, obj.name)) {
|
|
12664
12822
|
return;
|
|
12665
12823
|
}
|
|
@@ -12679,7 +12837,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
12679
12837
|
});
|
|
12680
12838
|
|
|
12681
12839
|
// src/rules/prefer-semantic-colors.ts
|
|
12682
|
-
import { AST_NODE_TYPES as
|
|
12840
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES55 } from "@typescript-eslint/utils";
|
|
12683
12841
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
12684
12842
|
import { dirname, join, parse } from "path";
|
|
12685
12843
|
|
|
@@ -12791,7 +12949,7 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
12791
12949
|
var isInsideSvg = (node) => {
|
|
12792
12950
|
let current = node.parent;
|
|
12793
12951
|
while (current !== void 0 && current !== null) {
|
|
12794
|
-
if (current.type ===
|
|
12952
|
+
if (current.type === AST_NODE_TYPES55.JSXElement) {
|
|
12795
12953
|
const name = jsxElementName(current);
|
|
12796
12954
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
12797
12955
|
}
|
|
@@ -12801,8 +12959,8 @@ var isInsideSvg = (node) => {
|
|
|
12801
12959
|
};
|
|
12802
12960
|
function jsxElementName(node) {
|
|
12803
12961
|
const name = node.openingElement.name;
|
|
12804
|
-
if (name.type ===
|
|
12805
|
-
if (name.type ===
|
|
12962
|
+
if (name.type === AST_NODE_TYPES55.JSXIdentifier) return name.name;
|
|
12963
|
+
if (name.type === AST_NODE_TYPES55.JSXMemberExpression && name.property.type === AST_NODE_TYPES55.JSXIdentifier) {
|
|
12806
12964
|
return name.property.name;
|
|
12807
12965
|
}
|
|
12808
12966
|
return null;
|
|
@@ -12828,7 +12986,7 @@ function isSvgLikeElementName(name) {
|
|
|
12828
12986
|
var isInsideIconFactoryPath = (node) => {
|
|
12829
12987
|
let current = node.parent;
|
|
12830
12988
|
while (current !== void 0 && current !== null) {
|
|
12831
|
-
if (current.type ===
|
|
12989
|
+
if (current.type === AST_NODE_TYPES55.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES55.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES55.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES55.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
12832
12990
|
return true;
|
|
12833
12991
|
}
|
|
12834
12992
|
current = current.parent;
|
|
@@ -12962,12 +13120,12 @@ var expandWorkspaceGlob = (root, glob) => {
|
|
|
12962
13120
|
return readdirSync(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => join(parent, entry.name));
|
|
12963
13121
|
};
|
|
12964
13122
|
var propName = (key) => {
|
|
12965
|
-
if (key.type ===
|
|
12966
|
-
if (key.type ===
|
|
13123
|
+
if (key.type === AST_NODE_TYPES55.Identifier) return key.name;
|
|
13124
|
+
if (key.type === AST_NODE_TYPES55.Literal && typeof key.value === "string") return key.value;
|
|
12967
13125
|
return null;
|
|
12968
13126
|
};
|
|
12969
13127
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
12970
|
-
if (statement.type !==
|
|
13128
|
+
if (statement.type !== AST_NODE_TYPES55.ImportDeclaration && statement.type !== AST_NODE_TYPES55.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES55.ExportAllDeclaration) {
|
|
12971
13129
|
return false;
|
|
12972
13130
|
}
|
|
12973
13131
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -13020,27 +13178,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13020
13178
|
const checkClassNode = (node) => {
|
|
13021
13179
|
if (node === null) return;
|
|
13022
13180
|
switch (node.type) {
|
|
13023
|
-
case
|
|
13181
|
+
case AST_NODE_TYPES55.Literal:
|
|
13024
13182
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
13025
13183
|
break;
|
|
13026
|
-
case
|
|
13184
|
+
case AST_NODE_TYPES55.TemplateLiteral:
|
|
13027
13185
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
13028
13186
|
break;
|
|
13029
|
-
case
|
|
13187
|
+
case AST_NODE_TYPES55.ArrayExpression:
|
|
13030
13188
|
for (const element of node.elements) {
|
|
13031
|
-
if (element !== null && element.type !==
|
|
13189
|
+
if (element !== null && element.type !== AST_NODE_TYPES55.SpreadElement) checkClassNode(element);
|
|
13032
13190
|
}
|
|
13033
13191
|
break;
|
|
13034
|
-
case
|
|
13192
|
+
case AST_NODE_TYPES55.ObjectExpression:
|
|
13035
13193
|
for (const property of node.properties) {
|
|
13036
|
-
if (property.type ===
|
|
13194
|
+
if (property.type === AST_NODE_TYPES55.Property) checkClassNode(property.value);
|
|
13037
13195
|
}
|
|
13038
13196
|
break;
|
|
13039
|
-
case
|
|
13197
|
+
case AST_NODE_TYPES55.ConditionalExpression:
|
|
13040
13198
|
checkClassNode(node.consequent);
|
|
13041
13199
|
checkClassNode(node.alternate);
|
|
13042
13200
|
break;
|
|
13043
|
-
case
|
|
13201
|
+
case AST_NODE_TYPES55.LogicalExpression:
|
|
13044
13202
|
checkClassNode(node.right);
|
|
13045
13203
|
break;
|
|
13046
13204
|
default:
|
|
@@ -13048,32 +13206,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13048
13206
|
}
|
|
13049
13207
|
};
|
|
13050
13208
|
const checkColorValueNode = (node) => {
|
|
13051
|
-
if (node.type ===
|
|
13209
|
+
if (node.type === AST_NODE_TYPES55.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
13052
13210
|
report(node, "inlineColor", { value: node.value });
|
|
13053
13211
|
}
|
|
13054
13212
|
};
|
|
13055
13213
|
return {
|
|
13056
13214
|
"JSXAttribute[name.name='className']"(node) {
|
|
13057
13215
|
if (node.value === null) return;
|
|
13058
|
-
if (node.value.type ===
|
|
13059
|
-
else if (node.value.type ===
|
|
13060
|
-
if (node.value.expression.type !==
|
|
13216
|
+
if (node.value.type === AST_NODE_TYPES55.Literal) checkClassNode(node.value);
|
|
13217
|
+
else if (node.value.type === AST_NODE_TYPES55.JSXExpressionContainer) {
|
|
13218
|
+
if (node.value.expression.type !== AST_NODE_TYPES55.JSXEmptyExpression) {
|
|
13061
13219
|
checkClassNode(node.value.expression);
|
|
13062
13220
|
}
|
|
13063
13221
|
}
|
|
13064
13222
|
},
|
|
13065
13223
|
CallExpression(node) {
|
|
13066
|
-
if (node.callee.type ===
|
|
13224
|
+
if (node.callee.type === AST_NODE_TYPES55.Identifier && node.callee.name === "require" && node.arguments[0]?.type === AST_NODE_TYPES55.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
13067
13225
|
importsEmailOrPdfRenderer = true;
|
|
13068
13226
|
}
|
|
13069
|
-
if (node.callee.type ===
|
|
13227
|
+
if (node.callee.type === AST_NODE_TYPES55.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
13070
13228
|
for (const arg of node.arguments) {
|
|
13071
|
-
if (arg.type !==
|
|
13229
|
+
if (arg.type !== AST_NODE_TYPES55.SpreadElement) checkClassNode(arg);
|
|
13072
13230
|
}
|
|
13073
13231
|
}
|
|
13074
13232
|
},
|
|
13075
13233
|
VariableDeclarator(node) {
|
|
13076
|
-
if (node.id.type ===
|
|
13234
|
+
if (node.id.type === AST_NODE_TYPES55.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
13077
13235
|
checkClassNode(node.init);
|
|
13078
13236
|
}
|
|
13079
13237
|
},
|
|
@@ -13083,9 +13241,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13083
13241
|
},
|
|
13084
13242
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
13085
13243
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
13086
|
-
if (node.value?.type !==
|
|
13244
|
+
if (node.value?.type !== AST_NODE_TYPES55.Literal) return;
|
|
13087
13245
|
const owner = node.parent.name;
|
|
13088
|
-
if (owner.type ===
|
|
13246
|
+
if (owner.type === AST_NODE_TYPES55.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
13089
13247
|
return;
|
|
13090
13248
|
}
|
|
13091
13249
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -13099,7 +13257,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
13099
13257
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
13100
13258
|
},
|
|
13101
13259
|
ImportExpression(node) {
|
|
13102
|
-
if (node.source.type ===
|
|
13260
|
+
if (node.source.type === AST_NODE_TYPES55.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
13103
13261
|
importsEmailOrPdfRenderer = true;
|
|
13104
13262
|
}
|
|
13105
13263
|
},
|
|
@@ -13301,7 +13459,7 @@ var prefer_server_actions_default = createRule({
|
|
|
13301
13459
|
});
|
|
13302
13460
|
|
|
13303
13461
|
// src/rules/prefer-whole-object-assertion.ts
|
|
13304
|
-
import { AST_NODE_TYPES as
|
|
13462
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES56 } from "@typescript-eslint/utils";
|
|
13305
13463
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
13306
13464
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
13307
13465
|
["toBeNull", "null"],
|
|
@@ -13326,11 +13484,11 @@ var PREFER_WHOLE_OBJECT_ASSERTION_DOCUMENTATION = {
|
|
|
13326
13484
|
};
|
|
13327
13485
|
function literalText(node, getText) {
|
|
13328
13486
|
switch (node.type) {
|
|
13329
|
-
case
|
|
13487
|
+
case AST_NODE_TYPES56.Literal:
|
|
13330
13488
|
return "regex" in node ? null : getText(node);
|
|
13331
|
-
case
|
|
13489
|
+
case AST_NODE_TYPES56.TemplateLiteral:
|
|
13332
13490
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
13333
|
-
case
|
|
13491
|
+
case AST_NODE_TYPES56.UnaryExpression:
|
|
13334
13492
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
13335
13493
|
default:
|
|
13336
13494
|
return null;
|
|
@@ -13338,15 +13496,15 @@ function literalText(node, getText) {
|
|
|
13338
13496
|
}
|
|
13339
13497
|
function isPureReceiver(node) {
|
|
13340
13498
|
switch (node.type) {
|
|
13341
|
-
case
|
|
13342
|
-
case
|
|
13499
|
+
case AST_NODE_TYPES56.Identifier:
|
|
13500
|
+
case AST_NODE_TYPES56.ThisExpression:
|
|
13343
13501
|
return true;
|
|
13344
|
-
case
|
|
13502
|
+
case AST_NODE_TYPES56.MemberExpression:
|
|
13345
13503
|
if (node.optional) {
|
|
13346
13504
|
return false;
|
|
13347
13505
|
}
|
|
13348
13506
|
if (node.computed) {
|
|
13349
|
-
return node.property.type ===
|
|
13507
|
+
return node.property.type === AST_NODE_TYPES56.Literal && isPureReceiver(node.object);
|
|
13350
13508
|
}
|
|
13351
13509
|
return isPureReceiver(node.object);
|
|
13352
13510
|
default:
|
|
@@ -13354,7 +13512,7 @@ function isPureReceiver(node) {
|
|
|
13354
13512
|
}
|
|
13355
13513
|
}
|
|
13356
13514
|
function literalIndex(node) {
|
|
13357
|
-
if (node.type !==
|
|
13515
|
+
if (node.type !== AST_NODE_TYPES56.Literal || typeof node.value !== "number") {
|
|
13358
13516
|
return null;
|
|
13359
13517
|
}
|
|
13360
13518
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -13362,8 +13520,8 @@ function literalIndex(node) {
|
|
|
13362
13520
|
function propertyAccess(node) {
|
|
13363
13521
|
const path = [];
|
|
13364
13522
|
let current = node;
|
|
13365
|
-
while (current.type ===
|
|
13366
|
-
if (current.property.type !==
|
|
13523
|
+
while (current.type === AST_NODE_TYPES56.MemberExpression && !current.computed && !current.optional) {
|
|
13524
|
+
if (current.property.type !== AST_NODE_TYPES56.Identifier || COLLECTION_PROPERTIES.has(current.property.name) || LITERAL_KEY_HAZARDS.has(current.property.name)) return null;
|
|
13367
13525
|
path.unshift(current.property.name);
|
|
13368
13526
|
current = current.object;
|
|
13369
13527
|
}
|
|
@@ -13391,24 +13549,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
13391
13549
|
}
|
|
13392
13550
|
const { sourceCode } = context;
|
|
13393
13551
|
function parseAssertion(statement) {
|
|
13394
|
-
if (statement.type !==
|
|
13552
|
+
if (statement.type !== AST_NODE_TYPES56.ExpressionStatement) {
|
|
13395
13553
|
return null;
|
|
13396
13554
|
}
|
|
13397
13555
|
const call = statement.expression;
|
|
13398
|
-
if (call.type !==
|
|
13556
|
+
if (call.type !== AST_NODE_TYPES56.CallExpression) {
|
|
13399
13557
|
return null;
|
|
13400
13558
|
}
|
|
13401
13559
|
const callee = call.callee;
|
|
13402
|
-
if (callee.type !==
|
|
13560
|
+
if (callee.type !== AST_NODE_TYPES56.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES56.Identifier) {
|
|
13403
13561
|
return null;
|
|
13404
13562
|
}
|
|
13405
13563
|
const matcher = callee.property.name;
|
|
13406
13564
|
const expectCall = callee.object;
|
|
13407
|
-
if (expectCall.type !==
|
|
13565
|
+
if (expectCall.type !== AST_NODE_TYPES56.CallExpression || expectCall.callee.type !== AST_NODE_TYPES56.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
13408
13566
|
return null;
|
|
13409
13567
|
}
|
|
13410
13568
|
const actual = expectCall.arguments[0];
|
|
13411
|
-
if (actual === void 0 || actual.type !==
|
|
13569
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES56.MemberExpression || actual.optional) {
|
|
13412
13570
|
return null;
|
|
13413
13571
|
}
|
|
13414
13572
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -13437,7 +13595,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
13437
13595
|
return null;
|
|
13438
13596
|
}
|
|
13439
13597
|
const expected = call.arguments[0];
|
|
13440
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
13598
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES56.SpreadElement) {
|
|
13441
13599
|
return null;
|
|
13442
13600
|
}
|
|
13443
13601
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -13578,7 +13736,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
13578
13736
|
});
|
|
13579
13737
|
|
|
13580
13738
|
// src/rules/repeated-static-call-cases.ts
|
|
13581
|
-
import { AST_NODE_TYPES as
|
|
13739
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES57, ASTUtils as ASTUtils18 } from "@typescript-eslint/utils";
|
|
13582
13740
|
var REPEATED_STATIC_CALL_CASES_DOCUMENTATION = {
|
|
13583
13741
|
summary: "Report three or more consecutive literal call assertions that should be independently named test cases.",
|
|
13584
13742
|
rationale: "Copy-pasted cases obscure the input table and stop later cases from being reported after the first failure.",
|
|
@@ -13599,67 +13757,67 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
13599
13757
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
13600
13758
|
var MIN_CASES2 = 3;
|
|
13601
13759
|
function staticMemberName5(node) {
|
|
13602
|
-
if (!node.computed && node.property.type ===
|
|
13603
|
-
if (node.computed && node.property.type ===
|
|
13760
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES57.Identifier) return node.property.name;
|
|
13761
|
+
if (node.computed && node.property.type === AST_NODE_TYPES57.Literal && typeof node.property.value === "string") return node.property.value;
|
|
13604
13762
|
return null;
|
|
13605
13763
|
}
|
|
13606
13764
|
function importedName5(identifier, context, modules) {
|
|
13607
|
-
const variable =
|
|
13765
|
+
const variable = ASTUtils18.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
13608
13766
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
13609
13767
|
for (const definition of variable.defs) {
|
|
13610
|
-
if (definition.node.type !==
|
|
13768
|
+
if (definition.node.type !== AST_NODE_TYPES57.ImportSpecifier) continue;
|
|
13611
13769
|
const declaration = definition.node.parent;
|
|
13612
|
-
if (declaration.type !==
|
|
13770
|
+
if (declaration.type !== AST_NODE_TYPES57.ImportDeclaration || typeof declaration.source.value !== "string" || !modules.has(declaration.source.value)) continue;
|
|
13613
13771
|
const imported = definition.node.imported;
|
|
13614
|
-
return imported.type ===
|
|
13772
|
+
return imported.type === AST_NODE_TYPES57.Identifier ? imported.name : String(imported.value);
|
|
13615
13773
|
}
|
|
13616
13774
|
return null;
|
|
13617
13775
|
}
|
|
13618
13776
|
function isDirectTestCallback2(node, context) {
|
|
13619
|
-
if (node.type !==
|
|
13777
|
+
if (node.type !== AST_NODE_TYPES57.ArrowFunctionExpression && node.type !== AST_NODE_TYPES57.FunctionExpression) return false;
|
|
13620
13778
|
const call = node.parent;
|
|
13621
|
-
if (call?.type !==
|
|
13779
|
+
if (call?.type !== AST_NODE_TYPES57.CallExpression || !call.arguments.includes(node)) return false;
|
|
13622
13780
|
const root = testRoot2(call.callee);
|
|
13623
13781
|
return root !== null && TEST_NAMES2.has(importedName5(root, context, TEST_MODULES4) ?? "");
|
|
13624
13782
|
}
|
|
13625
13783
|
function testRoot2(callee) {
|
|
13626
|
-
if (callee.type ===
|
|
13627
|
-
if (callee.type !==
|
|
13784
|
+
if (callee.type === AST_NODE_TYPES57.Identifier) return callee;
|
|
13785
|
+
if (callee.type !== AST_NODE_TYPES57.MemberExpression) return null;
|
|
13628
13786
|
const modifier = staticMemberName5(callee);
|
|
13629
13787
|
return modifier !== null && TEST_MODIFIERS4.has(modifier) ? testRoot2(callee.object) : null;
|
|
13630
13788
|
}
|
|
13631
13789
|
function isStatic(node) {
|
|
13632
|
-
if (node.type ===
|
|
13790
|
+
if (node.type === AST_NODE_TYPES57.TSAsExpression || node.type === AST_NODE_TYPES57.TSTypeAssertion || node.type === AST_NODE_TYPES57.TSSatisfiesExpression || node.type === AST_NODE_TYPES57.TSNonNullExpression) return isStatic(node.expression);
|
|
13633
13791
|
switch (node.type) {
|
|
13634
|
-
case
|
|
13792
|
+
case AST_NODE_TYPES57.Literal:
|
|
13635
13793
|
return true;
|
|
13636
|
-
case
|
|
13794
|
+
case AST_NODE_TYPES57.TemplateLiteral:
|
|
13637
13795
|
return node.expressions.length === 0;
|
|
13638
|
-
case
|
|
13796
|
+
case AST_NODE_TYPES57.UnaryExpression:
|
|
13639
13797
|
return (node.operator === "+" || node.operator === "-") && isStatic(node.argument);
|
|
13640
|
-
case
|
|
13641
|
-
return node.elements.every((item) => item !== null && item.type !==
|
|
13642
|
-
case
|
|
13643
|
-
return node.properties.every((property) => property.type ===
|
|
13798
|
+
case AST_NODE_TYPES57.ArrayExpression:
|
|
13799
|
+
return node.elements.every((item) => item !== null && item.type !== AST_NODE_TYPES57.SpreadElement && isStatic(item));
|
|
13800
|
+
case AST_NODE_TYPES57.ObjectExpression:
|
|
13801
|
+
return node.properties.every((property) => property.type === AST_NODE_TYPES57.Property && !property.computed && property.kind === "init" && property.value.type !== AST_NODE_TYPES57.AssignmentPattern && isStatic(property.value));
|
|
13644
13802
|
default:
|
|
13645
13803
|
return false;
|
|
13646
13804
|
}
|
|
13647
13805
|
}
|
|
13648
13806
|
function staticShape(node) {
|
|
13649
|
-
if (node.type ===
|
|
13807
|
+
if (node.type === AST_NODE_TYPES57.TSAsExpression || node.type === AST_NODE_TYPES57.TSTypeAssertion || node.type === AST_NODE_TYPES57.TSSatisfiesExpression || node.type === AST_NODE_TYPES57.TSNonNullExpression) return staticShape(node.expression);
|
|
13650
13808
|
switch (node.type) {
|
|
13651
|
-
case
|
|
13809
|
+
case AST_NODE_TYPES57.Literal:
|
|
13652
13810
|
return `literal:${typeof node.value}`;
|
|
13653
|
-
case
|
|
13811
|
+
case AST_NODE_TYPES57.TemplateLiteral:
|
|
13654
13812
|
return "template";
|
|
13655
|
-
case
|
|
13813
|
+
case AST_NODE_TYPES57.UnaryExpression:
|
|
13656
13814
|
return `unary:${node.operator}:${staticShape(node.argument)}`;
|
|
13657
|
-
case
|
|
13658
|
-
return `array(${node.elements.map((item) => item === null || item.type ===
|
|
13659
|
-
case
|
|
13815
|
+
case AST_NODE_TYPES57.ArrayExpression:
|
|
13816
|
+
return `array(${node.elements.map((item) => item === null || item.type === AST_NODE_TYPES57.SpreadElement ? "invalid" : staticShape(item)).join(",")})`;
|
|
13817
|
+
case AST_NODE_TYPES57.ObjectExpression:
|
|
13660
13818
|
return `object(${node.properties.map((property) => {
|
|
13661
|
-
if (property.type !==
|
|
13662
|
-
const key = property.key.type ===
|
|
13819
|
+
if (property.type !== AST_NODE_TYPES57.Property || property.computed || property.value.type === AST_NODE_TYPES57.AssignmentPattern) return "invalid";
|
|
13820
|
+
const key = property.key.type === AST_NODE_TYPES57.Identifier ? property.key.name : String(property.key.value);
|
|
13663
13821
|
return `${key}:${staticShape(property.value)}`;
|
|
13664
13822
|
}).join(",")})`;
|
|
13665
13823
|
default:
|
|
@@ -13667,16 +13825,16 @@ function staticShape(node) {
|
|
|
13667
13825
|
}
|
|
13668
13826
|
}
|
|
13669
13827
|
function assertionShape(statement, context) {
|
|
13670
|
-
if (statement.type !==
|
|
13828
|
+
if (statement.type !== AST_NODE_TYPES57.ExpressionStatement || statement.expression.type !== AST_NODE_TYPES57.CallExpression) return null;
|
|
13671
13829
|
const matcherCall = statement.expression;
|
|
13672
|
-
if (matcherCall.callee.type !==
|
|
13830
|
+
if (matcherCall.callee.type !== AST_NODE_TYPES57.MemberExpression || matcherCall.callee.computed || matcherCall.callee.property.type !== AST_NODE_TYPES57.Identifier || matcherCall.arguments.length !== 1) return null;
|
|
13673
13831
|
const matcher = matcherCall.callee.property.name;
|
|
13674
13832
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
13675
13833
|
const chain = expectCallFromMatcher(matcherCall.callee);
|
|
13676
|
-
if (chain === null || chain.call.callee.type !==
|
|
13834
|
+
if (chain === null || chain.call.callee.type !== AST_NODE_TYPES57.Identifier || importedName5(chain.call.callee, context, ASSERTION_MODULES3) !== "expect" || chain.call.arguments.length !== 1) return null;
|
|
13677
13835
|
const observed = chain.call.arguments[0];
|
|
13678
13836
|
const expected = matcherCall.arguments[0];
|
|
13679
|
-
if (observed?.type !==
|
|
13837
|
+
if (observed?.type !== AST_NODE_TYPES57.CallExpression || observed.callee.type !== AST_NODE_TYPES57.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === AST_NODE_TYPES57.SpreadElement || !isStatic(arg)) || expected?.type === AST_NODE_TYPES57.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
13680
13838
|
const skeleton = `${observed.callee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
13681
13839
|
const values = [...observed.arguments, expected].map((item) => context.sourceCode.getText(item)).join("\0");
|
|
13682
13840
|
return { statement, skeleton, values };
|
|
@@ -13684,13 +13842,13 @@ function assertionShape(statement, context) {
|
|
|
13684
13842
|
function expectCallFromMatcher(node) {
|
|
13685
13843
|
const modifiers = [];
|
|
13686
13844
|
let receiver = node.object;
|
|
13687
|
-
while (receiver.type ===
|
|
13845
|
+
while (receiver.type === AST_NODE_TYPES57.MemberExpression) {
|
|
13688
13846
|
const modifier = staticMemberName5(receiver);
|
|
13689
13847
|
if (modifier === null || !EXPECT_MODIFIERS.has(modifier)) return null;
|
|
13690
13848
|
modifiers.unshift(modifier);
|
|
13691
13849
|
receiver = receiver.object;
|
|
13692
13850
|
}
|
|
13693
|
-
return receiver.type ===
|
|
13851
|
+
return receiver.type === AST_NODE_TYPES57.CallExpression ? { call: receiver, modifiers } : null;
|
|
13694
13852
|
}
|
|
13695
13853
|
var repeated_static_call_cases_default = createRule({
|
|
13696
13854
|
name: "repeated-static-call-cases",
|
|
@@ -13710,7 +13868,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
13710
13868
|
return {
|
|
13711
13869
|
"CallExpression > ArrowFunctionExpression, CallExpression > FunctionExpression"(node) {
|
|
13712
13870
|
const call = node.parent;
|
|
13713
|
-
if (call?.type ===
|
|
13871
|
+
if (call?.type === AST_NODE_TYPES57.CallExpression) {
|
|
13714
13872
|
const duplicate = duplicateTestBodyCandidate(call, sourceCode);
|
|
13715
13873
|
if (duplicate !== null && duplicate.body === node) {
|
|
13716
13874
|
const groups = duplicateGroups.get(duplicate.container) ?? /* @__PURE__ */ new Map();
|
|
@@ -13720,7 +13878,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
13720
13878
|
duplicateGroups.set(duplicate.container, groups);
|
|
13721
13879
|
}
|
|
13722
13880
|
}
|
|
13723
|
-
if (!isDirectTestCallback2(node, context) || node.body.type !==
|
|
13881
|
+
if (!isDirectTestCallback2(node, context) || node.body.type !== AST_NODE_TYPES57.BlockStatement) return;
|
|
13724
13882
|
let run = [];
|
|
13725
13883
|
const flush = () => {
|
|
13726
13884
|
if (run.length >= MIN_CASES2 && new Set(run.map((item) => item.values)).size > 1) {
|
|
@@ -13761,7 +13919,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
13761
13919
|
});
|
|
13762
13920
|
|
|
13763
13921
|
// src/rules/prefer-zod-infer.ts
|
|
13764
|
-
import { AST_NODE_TYPES as
|
|
13922
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES58 } from "@typescript-eslint/utils";
|
|
13765
13923
|
var PREFER_ZOD_INFER_DOCUMENTATION = {
|
|
13766
13924
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
13767
13925
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -13814,47 +13972,47 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
13814
13972
|
"Schema"
|
|
13815
13973
|
]);
|
|
13816
13974
|
var LEAF_NODE_TYPES = {
|
|
13817
|
-
string: [
|
|
13818
|
-
email: [
|
|
13819
|
-
url: [
|
|
13820
|
-
uuid: [
|
|
13821
|
-
ulid: [
|
|
13822
|
-
cuid: [
|
|
13823
|
-
cuid2: [
|
|
13824
|
-
nanoid: [
|
|
13825
|
-
iso: [
|
|
13826
|
-
number: [
|
|
13827
|
-
int: [
|
|
13828
|
-
float32: [
|
|
13829
|
-
float64: [
|
|
13830
|
-
boolean: [
|
|
13831
|
-
bigint: [
|
|
13832
|
-
symbol: [
|
|
13833
|
-
any: [
|
|
13834
|
-
unknown: [
|
|
13835
|
-
never: [
|
|
13836
|
-
void: [
|
|
13837
|
-
null: [
|
|
13838
|
-
undefined: [
|
|
13839
|
-
literal: [
|
|
13840
|
-
date: [
|
|
13841
|
-
array: [
|
|
13842
|
-
tuple: [
|
|
13843
|
-
object: [
|
|
13844
|
-
strictObject: [
|
|
13845
|
-
looseObject: [
|
|
13846
|
-
record: [
|
|
13847
|
-
map: [
|
|
13848
|
-
set: [
|
|
13849
|
-
promise: [
|
|
13850
|
-
enum: [
|
|
13851
|
-
nativeEnum: [
|
|
13852
|
-
union: [
|
|
13853
|
-
discriminatedUnion: [
|
|
13854
|
-
intersection: [
|
|
13975
|
+
string: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13976
|
+
email: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13977
|
+
url: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13978
|
+
uuid: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13979
|
+
ulid: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13980
|
+
cuid: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13981
|
+
cuid2: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13982
|
+
nanoid: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13983
|
+
iso: [AST_NODE_TYPES58.TSStringKeyword],
|
|
13984
|
+
number: [AST_NODE_TYPES58.TSNumberKeyword],
|
|
13985
|
+
int: [AST_NODE_TYPES58.TSNumberKeyword],
|
|
13986
|
+
float32: [AST_NODE_TYPES58.TSNumberKeyword],
|
|
13987
|
+
float64: [AST_NODE_TYPES58.TSNumberKeyword],
|
|
13988
|
+
boolean: [AST_NODE_TYPES58.TSBooleanKeyword],
|
|
13989
|
+
bigint: [AST_NODE_TYPES58.TSBigIntKeyword],
|
|
13990
|
+
symbol: [AST_NODE_TYPES58.TSSymbolKeyword],
|
|
13991
|
+
any: [AST_NODE_TYPES58.TSAnyKeyword],
|
|
13992
|
+
unknown: [AST_NODE_TYPES58.TSUnknownKeyword],
|
|
13993
|
+
never: [AST_NODE_TYPES58.TSNeverKeyword],
|
|
13994
|
+
void: [AST_NODE_TYPES58.TSVoidKeyword],
|
|
13995
|
+
null: [AST_NODE_TYPES58.TSNullKeyword],
|
|
13996
|
+
undefined: [AST_NODE_TYPES58.TSUndefinedKeyword],
|
|
13997
|
+
literal: [AST_NODE_TYPES58.TSLiteralType],
|
|
13998
|
+
date: [AST_NODE_TYPES58.TSTypeReference],
|
|
13999
|
+
array: [AST_NODE_TYPES58.TSArrayType, AST_NODE_TYPES58.TSTypeReference],
|
|
14000
|
+
tuple: [AST_NODE_TYPES58.TSTupleType],
|
|
14001
|
+
object: [AST_NODE_TYPES58.TSTypeLiteral, AST_NODE_TYPES58.TSTypeReference],
|
|
14002
|
+
strictObject: [AST_NODE_TYPES58.TSTypeLiteral, AST_NODE_TYPES58.TSTypeReference],
|
|
14003
|
+
looseObject: [AST_NODE_TYPES58.TSTypeLiteral, AST_NODE_TYPES58.TSTypeReference],
|
|
14004
|
+
record: [AST_NODE_TYPES58.TSTypeReference, AST_NODE_TYPES58.TSTypeLiteral],
|
|
14005
|
+
map: [AST_NODE_TYPES58.TSTypeReference],
|
|
14006
|
+
set: [AST_NODE_TYPES58.TSTypeReference],
|
|
14007
|
+
promise: [AST_NODE_TYPES58.TSTypeReference],
|
|
14008
|
+
enum: [AST_NODE_TYPES58.TSUnionType, AST_NODE_TYPES58.TSTypeReference, AST_NODE_TYPES58.TSLiteralType],
|
|
14009
|
+
nativeEnum: [AST_NODE_TYPES58.TSUnionType, AST_NODE_TYPES58.TSTypeReference, AST_NODE_TYPES58.TSLiteralType],
|
|
14010
|
+
union: [AST_NODE_TYPES58.TSUnionType, AST_NODE_TYPES58.TSTypeReference],
|
|
14011
|
+
discriminatedUnion: [AST_NODE_TYPES58.TSUnionType, AST_NODE_TYPES58.TSTypeReference],
|
|
14012
|
+
intersection: [AST_NODE_TYPES58.TSIntersectionType, AST_NODE_TYPES58.TSTypeReference]
|
|
13855
14013
|
};
|
|
13856
14014
|
function primitiveLiteralKey(node) {
|
|
13857
|
-
if (node.type !==
|
|
14015
|
+
if (node.type !== AST_NODE_TYPES58.Literal) {
|
|
13858
14016
|
return null;
|
|
13859
14017
|
}
|
|
13860
14018
|
if (node.value === null) {
|
|
@@ -13886,13 +14044,13 @@ function staticZodDomain(leaf, call) {
|
|
|
13886
14044
|
}
|
|
13887
14045
|
if (leaf === "literal") {
|
|
13888
14046
|
const [argument] = call.arguments;
|
|
13889
|
-
if (argument === void 0 || argument.type ===
|
|
14047
|
+
if (argument === void 0 || argument.type === AST_NODE_TYPES58.SpreadElement) {
|
|
13890
14048
|
return null;
|
|
13891
14049
|
}
|
|
13892
|
-
if (argument.type ===
|
|
14050
|
+
if (argument.type === AST_NODE_TYPES58.ArrayExpression) {
|
|
13893
14051
|
return exactDomain(
|
|
13894
14052
|
argument.elements.map(
|
|
13895
|
-
(element) => element === null || element.type ===
|
|
14053
|
+
(element) => element === null || element.type === AST_NODE_TYPES58.SpreadElement ? null : primitiveLiteralKey(element)
|
|
13896
14054
|
)
|
|
13897
14055
|
);
|
|
13898
14056
|
}
|
|
@@ -13900,13 +14058,13 @@ function staticZodDomain(leaf, call) {
|
|
|
13900
14058
|
}
|
|
13901
14059
|
if (leaf === "enum") {
|
|
13902
14060
|
const [argument] = call.arguments;
|
|
13903
|
-
if (argument === void 0 || argument.type ===
|
|
14061
|
+
if (argument === void 0 || argument.type === AST_NODE_TYPES58.SpreadElement) {
|
|
13904
14062
|
return null;
|
|
13905
14063
|
}
|
|
13906
|
-
if (argument.type ===
|
|
14064
|
+
if (argument.type === AST_NODE_TYPES58.ArrayExpression) {
|
|
13907
14065
|
return exactDomain(
|
|
13908
14066
|
argument.elements.map((element) => {
|
|
13909
|
-
if (element === null || element.type ===
|
|
14067
|
+
if (element === null || element.type === AST_NODE_TYPES58.SpreadElement) {
|
|
13910
14068
|
return null;
|
|
13911
14069
|
}
|
|
13912
14070
|
const key = primitiveLiteralKey(element);
|
|
@@ -13914,10 +14072,10 @@ function staticZodDomain(leaf, call) {
|
|
|
13914
14072
|
})
|
|
13915
14073
|
);
|
|
13916
14074
|
}
|
|
13917
|
-
if (argument.type ===
|
|
14075
|
+
if (argument.type === AST_NODE_TYPES58.ObjectExpression) {
|
|
13918
14076
|
return exactDomain(
|
|
13919
14077
|
argument.properties.map((property) => {
|
|
13920
|
-
if (property.type !==
|
|
14078
|
+
if (property.type !== AST_NODE_TYPES58.Property || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
13921
14079
|
return null;
|
|
13922
14080
|
}
|
|
13923
14081
|
const key = primitiveLiteralKey(property.value);
|
|
@@ -13944,15 +14102,15 @@ function sameDomain(left, right) {
|
|
|
13944
14102
|
return true;
|
|
13945
14103
|
}
|
|
13946
14104
|
function isExportedDeclaration(node) {
|
|
13947
|
-
return node.parent?.type ===
|
|
14105
|
+
return node.parent?.type === AST_NODE_TYPES58.ExportNamedDeclaration;
|
|
13948
14106
|
}
|
|
13949
14107
|
function isModuleLevelConst(node) {
|
|
13950
14108
|
const declaration = node.parent;
|
|
13951
|
-
if (declaration.type !==
|
|
14109
|
+
if (declaration.type !== AST_NODE_TYPES58.VariableDeclaration || declaration.kind !== "const") {
|
|
13952
14110
|
return false;
|
|
13953
14111
|
}
|
|
13954
14112
|
const container = declaration.parent;
|
|
13955
|
-
return container.type ===
|
|
14113
|
+
return container.type === AST_NODE_TYPES58.Program || container.type === AST_NODE_TYPES58.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES58.Program;
|
|
13956
14114
|
}
|
|
13957
14115
|
function normalizeSchemaName(name) {
|
|
13958
14116
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -13961,20 +14119,20 @@ function normalizeTypeName(name) {
|
|
|
13961
14119
|
return name.replace(/Type$/, "").toLowerCase();
|
|
13962
14120
|
}
|
|
13963
14121
|
function unwrapNullish(annotation) {
|
|
13964
|
-
if (annotation.type !==
|
|
14122
|
+
if (annotation.type !== AST_NODE_TYPES58.TSUnionType) {
|
|
13965
14123
|
return {
|
|
13966
14124
|
core: annotation,
|
|
13967
|
-
nullable: annotation.type ===
|
|
14125
|
+
nullable: annotation.type === AST_NODE_TYPES58.TSNullKeyword
|
|
13968
14126
|
};
|
|
13969
14127
|
}
|
|
13970
14128
|
const rest = [];
|
|
13971
14129
|
let nullable = false;
|
|
13972
14130
|
for (const member of annotation.types) {
|
|
13973
|
-
if (member.type ===
|
|
14131
|
+
if (member.type === AST_NODE_TYPES58.TSNullKeyword) {
|
|
13974
14132
|
nullable = true;
|
|
13975
14133
|
continue;
|
|
13976
14134
|
}
|
|
13977
|
-
if (member.type ===
|
|
14135
|
+
if (member.type === AST_NODE_TYPES58.TSUndefinedKeyword) {
|
|
13978
14136
|
continue;
|
|
13979
14137
|
}
|
|
13980
14138
|
rest.push(member);
|
|
@@ -14008,18 +14166,18 @@ function leafAgrees(field, annotation) {
|
|
|
14008
14166
|
return null;
|
|
14009
14167
|
}
|
|
14010
14168
|
if (leaf === "date") {
|
|
14011
|
-
return core.type ===
|
|
14169
|
+
return core.type === AST_NODE_TYPES58.TSTypeReference && core.typeName.type === AST_NODE_TYPES58.Identifier && core.typeName.name === "Date";
|
|
14012
14170
|
}
|
|
14013
14171
|
return expected.includes(core.type);
|
|
14014
14172
|
}
|
|
14015
14173
|
function typeLiteralDomain(annotation) {
|
|
14016
|
-
const members = annotation.type ===
|
|
14174
|
+
const members = annotation.type === AST_NODE_TYPES58.TSUnionType ? annotation.types : [annotation];
|
|
14017
14175
|
const keys = [];
|
|
14018
14176
|
for (const member of members) {
|
|
14019
|
-
if (member.type ===
|
|
14177
|
+
if (member.type === AST_NODE_TYPES58.TSNullKeyword) {
|
|
14020
14178
|
continue;
|
|
14021
14179
|
}
|
|
14022
|
-
if (member.type !==
|
|
14180
|
+
if (member.type !== AST_NODE_TYPES58.TSLiteralType) {
|
|
14023
14181
|
return null;
|
|
14024
14182
|
}
|
|
14025
14183
|
keys.push(primitiveLiteralKey(member.literal));
|
|
@@ -14027,11 +14185,11 @@ function typeLiteralDomain(annotation) {
|
|
|
14027
14185
|
return exactDomain(keys);
|
|
14028
14186
|
}
|
|
14029
14187
|
function staticStringUnionDomain(node) {
|
|
14030
|
-
if (node.type !==
|
|
14188
|
+
if (node.type !== AST_NODE_TYPES58.TSUnionType) {
|
|
14031
14189
|
return null;
|
|
14032
14190
|
}
|
|
14033
14191
|
const keys = node.types.map((member) => {
|
|
14034
|
-
if (member.type !==
|
|
14192
|
+
if (member.type !== AST_NODE_TYPES58.TSLiteralType) {
|
|
14035
14193
|
return null;
|
|
14036
14194
|
}
|
|
14037
14195
|
const key = primitiveLiteralKey(member.literal);
|
|
@@ -14099,14 +14257,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14099
14257
|
function zodCallChain(node) {
|
|
14100
14258
|
const chain = [];
|
|
14101
14259
|
let current = node;
|
|
14102
|
-
while (current.type ===
|
|
14260
|
+
while (current.type === AST_NODE_TYPES58.CallExpression) {
|
|
14103
14261
|
const callee = current.callee;
|
|
14104
|
-
if (callee.type !==
|
|
14262
|
+
if (callee.type !== AST_NODE_TYPES58.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES58.Identifier) {
|
|
14105
14263
|
return null;
|
|
14106
14264
|
}
|
|
14107
14265
|
chain.push(current);
|
|
14108
14266
|
const receiver = callee.object;
|
|
14109
|
-
if (receiver.type ===
|
|
14267
|
+
if (receiver.type === AST_NODE_TYPES58.Identifier) {
|
|
14110
14268
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
14111
14269
|
}
|
|
14112
14270
|
current = receiver;
|
|
@@ -14115,14 +14273,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14115
14273
|
}
|
|
14116
14274
|
function methodName2(call) {
|
|
14117
14275
|
const callee = call.callee;
|
|
14118
|
-
return callee.type ===
|
|
14276
|
+
return callee.type === AST_NODE_TYPES58.MemberExpression && callee.property.type === AST_NODE_TYPES58.Identifier ? callee.property.name : "";
|
|
14119
14277
|
}
|
|
14120
14278
|
function recordZodImport(node) {
|
|
14121
14279
|
if (!isZodModule(node.source.value)) {
|
|
14122
14280
|
return;
|
|
14123
14281
|
}
|
|
14124
14282
|
for (const specifier of node.specifiers) {
|
|
14125
|
-
if (specifier.type ===
|
|
14283
|
+
if (specifier.type === AST_NODE_TYPES58.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES58.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES58.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES58.Identifier && specifier.imported.name === "z") {
|
|
14126
14284
|
zodNamespaces.add(specifier.local.name);
|
|
14127
14285
|
}
|
|
14128
14286
|
}
|
|
@@ -14132,13 +14290,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
14132
14290
|
let current = node;
|
|
14133
14291
|
let leaf = null;
|
|
14134
14292
|
let leafCall = null;
|
|
14135
|
-
while (current.type ===
|
|
14293
|
+
while (current.type === AST_NODE_TYPES58.CallExpression) {
|
|
14136
14294
|
const callee = current.callee;
|
|
14137
|
-
if (callee.type !==
|
|
14295
|
+
if (callee.type !== AST_NODE_TYPES58.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES58.Identifier) {
|
|
14138
14296
|
break;
|
|
14139
14297
|
}
|
|
14140
14298
|
const receiver = callee.object;
|
|
14141
|
-
if (receiver.type ===
|
|
14299
|
+
if (receiver.type === AST_NODE_TYPES58.Identifier && zodNamespaces.has(receiver.name)) {
|
|
14142
14300
|
leaf = callee.property.name;
|
|
14143
14301
|
leafCall = current;
|
|
14144
14302
|
break;
|
|
@@ -14169,20 +14327,20 @@ var prefer_zod_infer_default = createRule({
|
|
|
14169
14327
|
return domain instanceof Set && domain.size >= 2 ? domain : null;
|
|
14170
14328
|
}
|
|
14171
14329
|
function inferredSchemaName(node) {
|
|
14172
|
-
if (node.type !==
|
|
14330
|
+
if (node.type !== AST_NODE_TYPES58.TSTypeReference || node.typeName.type !== AST_NODE_TYPES58.TSQualifiedName || node.typeName.left.type !== AST_NODE_TYPES58.Identifier || !zodNamespaces.has(node.typeName.left.name) || node.typeName.right.name !== "infer") {
|
|
14173
14331
|
return null;
|
|
14174
14332
|
}
|
|
14175
14333
|
const arguments_ = node.typeArguments?.params ?? [];
|
|
14176
14334
|
const [argument] = arguments_;
|
|
14177
|
-
return arguments_.length === 1 && argument?.type ===
|
|
14335
|
+
return arguments_.length === 1 && argument?.type === AST_NODE_TYPES58.TSTypeQuery && argument.exprName.type === AST_NODE_TYPES58.Identifier ? argument.exprName.name : null;
|
|
14178
14336
|
}
|
|
14179
14337
|
function recordLiteralUnions(members, owner, ownerName, exported) {
|
|
14180
14338
|
for (const member of members) {
|
|
14181
|
-
if (member.type !==
|
|
14339
|
+
if (member.type !== AST_NODE_TYPES58.TSPropertySignature || member.computed || member.optional || member.readonly || member.typeAnnotation === void 0) {
|
|
14182
14340
|
continue;
|
|
14183
14341
|
}
|
|
14184
14342
|
const key = member.key;
|
|
14185
|
-
const propertyName5 = key.type ===
|
|
14343
|
+
const propertyName5 = key.type === AST_NODE_TYPES58.Identifier ? key.name : key.type === AST_NODE_TYPES58.Literal && typeof key.value === "string" ? key.value : null;
|
|
14186
14344
|
if (propertyName5 === null) {
|
|
14187
14345
|
continue;
|
|
14188
14346
|
}
|
|
@@ -14192,7 +14350,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14192
14350
|
}
|
|
14193
14351
|
const annotation = member.typeAnnotation.typeAnnotation;
|
|
14194
14352
|
const domain = staticStringUnionDomain(annotation);
|
|
14195
|
-
if (domain === null || annotation.type !==
|
|
14353
|
+
if (domain === null || annotation.type !== AST_NODE_TYPES58.TSUnionType) {
|
|
14196
14354
|
continue;
|
|
14197
14355
|
}
|
|
14198
14356
|
literalUnionOccurrences.push({
|
|
@@ -14223,16 +14381,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
14223
14381
|
return null;
|
|
14224
14382
|
}
|
|
14225
14383
|
const shape = base.arguments[0];
|
|
14226
|
-
if (shape === void 0 || shape.type !==
|
|
14384
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES58.ObjectExpression) {
|
|
14227
14385
|
return null;
|
|
14228
14386
|
}
|
|
14229
14387
|
const fields = /* @__PURE__ */ new Map();
|
|
14230
14388
|
for (const property of shape.properties) {
|
|
14231
|
-
if (property.type !==
|
|
14389
|
+
if (property.type !== AST_NODE_TYPES58.Property || property.computed) {
|
|
14232
14390
|
return null;
|
|
14233
14391
|
}
|
|
14234
14392
|
const { key } = property;
|
|
14235
|
-
const name = key.type ===
|
|
14393
|
+
const name = key.type === AST_NODE_TYPES58.Identifier ? key.name : key.type === AST_NODE_TYPES58.Literal && typeof key.value === "string" ? key.value : null;
|
|
14236
14394
|
if (name === null) {
|
|
14237
14395
|
return null;
|
|
14238
14396
|
}
|
|
@@ -14243,11 +14401,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
14243
14401
|
function typeMembers(members) {
|
|
14244
14402
|
const result = /* @__PURE__ */ new Map();
|
|
14245
14403
|
for (const member of members) {
|
|
14246
|
-
if (member.type !==
|
|
14404
|
+
if (member.type !== AST_NODE_TYPES58.TSPropertySignature || member.computed) {
|
|
14247
14405
|
return null;
|
|
14248
14406
|
}
|
|
14249
14407
|
const { key } = member;
|
|
14250
|
-
const name = key.type ===
|
|
14408
|
+
const name = key.type === AST_NODE_TYPES58.Identifier ? key.name : key.type === AST_NODE_TYPES58.Literal && typeof key.value === "string" ? key.value : null;
|
|
14251
14409
|
if (name === null) {
|
|
14252
14410
|
return null;
|
|
14253
14411
|
}
|
|
@@ -14262,8 +14420,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
14262
14420
|
return result.size === 0 ? null : result;
|
|
14263
14421
|
}
|
|
14264
14422
|
function collectConstrainedNames(node) {
|
|
14265
|
-
if (node.type ===
|
|
14266
|
-
if (node.typeName.type ===
|
|
14423
|
+
if (node.type === AST_NODE_TYPES58.TSTypeReference) {
|
|
14424
|
+
if (node.typeName.type === AST_NODE_TYPES58.Identifier) {
|
|
14267
14425
|
constrainedTypeNames.add(node.typeName.name);
|
|
14268
14426
|
}
|
|
14269
14427
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -14271,11 +14429,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
14271
14429
|
}
|
|
14272
14430
|
return;
|
|
14273
14431
|
}
|
|
14274
|
-
if (node.type ===
|
|
14432
|
+
if (node.type === AST_NODE_TYPES58.TSArrayType) {
|
|
14275
14433
|
collectConstrainedNames(node.elementType);
|
|
14276
14434
|
return;
|
|
14277
14435
|
}
|
|
14278
|
-
if (node.type ===
|
|
14436
|
+
if (node.type === AST_NODE_TYPES58.TSUnionType || node.type === AST_NODE_TYPES58.TSIntersectionType) {
|
|
14279
14437
|
for (const member of node.types) {
|
|
14280
14438
|
collectConstrainedNames(member);
|
|
14281
14439
|
}
|
|
@@ -14319,7 +14477,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14319
14477
|
return {
|
|
14320
14478
|
Program(node) {
|
|
14321
14479
|
for (const statement of node.body) {
|
|
14322
|
-
if (statement.type ===
|
|
14480
|
+
if (statement.type === AST_NODE_TYPES58.ImportDeclaration) {
|
|
14323
14481
|
recordZodImport(statement);
|
|
14324
14482
|
}
|
|
14325
14483
|
}
|
|
@@ -14328,7 +14486,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14328
14486
|
recordZodImport(node);
|
|
14329
14487
|
},
|
|
14330
14488
|
VariableDeclarator(node) {
|
|
14331
|
-
if (node.id.type !==
|
|
14489
|
+
if (node.id.type !== AST_NODE_TYPES58.Identifier || node.init == null) {
|
|
14332
14490
|
return;
|
|
14333
14491
|
}
|
|
14334
14492
|
const fields = schemaFields(node.init);
|
|
@@ -14345,14 +14503,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
14345
14503
|
},
|
|
14346
14504
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
14347
14505
|
"MemberExpression[computed=false]"(node) {
|
|
14348
|
-
if (node.object.type ===
|
|
14506
|
+
if (node.object.type === AST_NODE_TYPES58.Identifier && node.property.type === AST_NODE_TYPES58.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
14349
14507
|
reshapedSchemaNames.add(node.object.name);
|
|
14350
14508
|
}
|
|
14351
14509
|
},
|
|
14352
14510
|
/** Records every type argument carried by a Zod constraint. */
|
|
14353
14511
|
TSTypeReference(node) {
|
|
14354
14512
|
const { typeName } = node;
|
|
14355
|
-
const referenced = typeName.type ===
|
|
14513
|
+
const referenced = typeName.type === AST_NODE_TYPES58.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES58.TSQualifiedName && typeName.right.type === AST_NODE_TYPES58.Identifier ? typeName.right.name : null;
|
|
14356
14514
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
14357
14515
|
return;
|
|
14358
14516
|
}
|
|
@@ -14384,7 +14542,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
14384
14542
|
typeName: node.id.name
|
|
14385
14543
|
});
|
|
14386
14544
|
}
|
|
14387
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
14545
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES58.TSTypeLiteral) {
|
|
14388
14546
|
return;
|
|
14389
14547
|
}
|
|
14390
14548
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -14484,10 +14642,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
14484
14642
|
|
|
14485
14643
|
// src/rules/require-assert-never.ts
|
|
14486
14644
|
import {
|
|
14487
|
-
ESLintUtils as
|
|
14488
|
-
AST_NODE_TYPES as
|
|
14645
|
+
ESLintUtils as ESLintUtils7,
|
|
14646
|
+
AST_NODE_TYPES as AST_NODE_TYPES59
|
|
14489
14647
|
} from "@typescript-eslint/utils";
|
|
14490
|
-
import
|
|
14648
|
+
import ts5 from "typescript";
|
|
14491
14649
|
var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
14492
14650
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
14493
14651
|
rationale: "An empty default silently accepts new union members instead of making the compiler identify the missing case.",
|
|
@@ -14499,14 +14657,14 @@ var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
|
14499
14657
|
]
|
|
14500
14658
|
};
|
|
14501
14659
|
var isRuntimeHandlingStatement = (statement) => {
|
|
14502
|
-
if (statement.type ===
|
|
14503
|
-
if (statement.type ===
|
|
14660
|
+
if (statement.type === AST_NODE_TYPES59.EmptyStatement) return false;
|
|
14661
|
+
if (statement.type === AST_NODE_TYPES59.BreakStatement) {
|
|
14504
14662
|
return statement.label !== null;
|
|
14505
14663
|
}
|
|
14506
|
-
if (statement.type ===
|
|
14664
|
+
if (statement.type === AST_NODE_TYPES59.TSTypeAliasDeclaration || statement.type === AST_NODE_TYPES59.TSInterfaceDeclaration) {
|
|
14507
14665
|
return false;
|
|
14508
14666
|
}
|
|
14509
|
-
if (statement.type ===
|
|
14667
|
+
if (statement.type === AST_NODE_TYPES59.BlockStatement) {
|
|
14510
14668
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
14511
14669
|
}
|
|
14512
14670
|
return true;
|
|
@@ -14522,7 +14680,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
14522
14680
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
14523
14681
|
}
|
|
14524
14682
|
const only = defaultCase.consequent[0];
|
|
14525
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
14683
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES59.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
14526
14684
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
14527
14685
|
}
|
|
14528
14686
|
return false;
|
|
@@ -14534,7 +14692,7 @@ function isExhaustiveFiniteSwitch(node, services) {
|
|
|
14534
14692
|
const constituents = discriminantType.isUnion() ? discriminantType.types : [discriminantType];
|
|
14535
14693
|
if (!discriminantType.isUnion() || constituents.length < 2) return false;
|
|
14536
14694
|
if (constituents.every(
|
|
14537
|
-
(constituent) => (constituent.flags &
|
|
14695
|
+
(constituent) => (constituent.flags & ts5.TypeFlags.BooleanLiteral) !== 0
|
|
14538
14696
|
)) {
|
|
14539
14697
|
return false;
|
|
14540
14698
|
}
|
|
@@ -14558,7 +14716,7 @@ function isExhaustiveFiniteSwitch(node, services) {
|
|
|
14558
14716
|
return [...expected].every((key) => handled.has(key));
|
|
14559
14717
|
}
|
|
14560
14718
|
function finiteTypeKey(type, checker) {
|
|
14561
|
-
const finiteFlags =
|
|
14719
|
+
const finiteFlags = ts5.TypeFlags.StringLiteral | ts5.TypeFlags.NumberLiteral | ts5.TypeFlags.BooleanLiteral | ts5.TypeFlags.EnumLiteral | ts5.TypeFlags.UniqueESSymbol | ts5.TypeFlags.Null | ts5.TypeFlags.Undefined;
|
|
14562
14720
|
return (type.flags & finiteFlags) !== 0 ? checker.typeToString(type) : null;
|
|
14563
14721
|
}
|
|
14564
14722
|
var require_assert_never_default = createRule({
|
|
@@ -14578,7 +14736,7 @@ var require_assert_never_default = createRule({
|
|
|
14578
14736
|
create(context) {
|
|
14579
14737
|
let services;
|
|
14580
14738
|
try {
|
|
14581
|
-
services =
|
|
14739
|
+
services = ESLintUtils7.getParserServices(context);
|
|
14582
14740
|
} catch {
|
|
14583
14741
|
services = null;
|
|
14584
14742
|
}
|
|
@@ -14605,7 +14763,7 @@ var require_assert_never_default = createRule({
|
|
|
14605
14763
|
});
|
|
14606
14764
|
|
|
14607
14765
|
// src/rules/require-fetch-timeout.ts
|
|
14608
|
-
import { AST_NODE_TYPES as
|
|
14766
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES60, ASTUtils as ASTUtils19 } from "@typescript-eslint/utils";
|
|
14609
14767
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
14610
14768
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
14611
14769
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -14631,14 +14789,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
14631
14789
|
return false;
|
|
14632
14790
|
}
|
|
14633
14791
|
function initProvablyLacksSignal(init) {
|
|
14634
|
-
if (init.type !==
|
|
14792
|
+
if (init.type !== AST_NODE_TYPES60.ObjectExpression) {
|
|
14635
14793
|
return false;
|
|
14636
14794
|
}
|
|
14637
14795
|
for (const prop of init.properties) {
|
|
14638
|
-
if (prop.type ===
|
|
14796
|
+
if (prop.type === AST_NODE_TYPES60.SpreadElement) {
|
|
14639
14797
|
return false;
|
|
14640
14798
|
}
|
|
14641
|
-
if (prop.key.type ===
|
|
14799
|
+
if (prop.key.type === AST_NODE_TYPES60.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES60.Literal && prop.key.value === "signal") {
|
|
14642
14800
|
return false;
|
|
14643
14801
|
}
|
|
14644
14802
|
if (prop.computed) {
|
|
@@ -14648,7 +14806,7 @@ function initProvablyLacksSignal(init) {
|
|
|
14648
14806
|
return true;
|
|
14649
14807
|
}
|
|
14650
14808
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
14651
|
-
return node.type ===
|
|
14809
|
+
return node.type === AST_NODE_TYPES60.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES60.TemplateLiteral || node.type === AST_NODE_TYPES60.NewExpression && node.callee.type === AST_NODE_TYPES60.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
14652
14810
|
}
|
|
14653
14811
|
var require_fetch_timeout_default = createRule({
|
|
14654
14812
|
name: "require-fetch-timeout",
|
|
@@ -14686,30 +14844,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
14686
14844
|
}
|
|
14687
14845
|
function resolvesToGlobal(identifier) {
|
|
14688
14846
|
const scope = context.sourceCode.getScope(identifier);
|
|
14689
|
-
const variable =
|
|
14847
|
+
const variable = ASTUtils19.findVariable(scope, identifier.name);
|
|
14690
14848
|
return variable === null || variable.defs.length === 0;
|
|
14691
14849
|
}
|
|
14692
14850
|
function isGlobalFetchCall2(callee) {
|
|
14693
|
-
if (callee.type ===
|
|
14851
|
+
if (callee.type === AST_NODE_TYPES60.Identifier) {
|
|
14694
14852
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
14695
14853
|
}
|
|
14696
|
-
return callee.type ===
|
|
14854
|
+
return callee.type === AST_NODE_TYPES60.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES60.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES60.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
14697
14855
|
}
|
|
14698
14856
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
14699
|
-
const variable =
|
|
14857
|
+
const variable = ASTUtils19.findVariable(
|
|
14700
14858
|
context.sourceCode.getScope(identifier),
|
|
14701
14859
|
identifier.name
|
|
14702
14860
|
);
|
|
14703
14861
|
if (variable?.defs.length !== 1) return false;
|
|
14704
14862
|
const definition = variable.defs[0];
|
|
14705
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
14863
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== AST_NODE_TYPES60.ObjectExpression || !initProvablyLacksSignal(definition.node.init)) {
|
|
14706
14864
|
return false;
|
|
14707
14865
|
}
|
|
14708
14866
|
for (const reference of variable.references) {
|
|
14709
14867
|
const ref = reference.identifier;
|
|
14710
14868
|
if (ref === identifier || ref === definition.name) continue;
|
|
14711
14869
|
const member = ref.parent;
|
|
14712
|
-
if (member.type !==
|
|
14870
|
+
if (member.type !== AST_NODE_TYPES60.MemberExpression || member.object !== ref || member.computed || member.property.type !== AST_NODE_TYPES60.Identifier || member.property.name === "signal" || member.parent.type !== AST_NODE_TYPES60.AssignmentExpression || member.parent.left !== member) {
|
|
14713
14871
|
return false;
|
|
14714
14872
|
}
|
|
14715
14873
|
}
|
|
@@ -14724,7 +14882,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
14724
14882
|
if (node.arguments.length === 1 && first !== void 0 && !isInlineUrl(first, resolvesToGlobal)) {
|
|
14725
14883
|
return;
|
|
14726
14884
|
}
|
|
14727
|
-
if (init === void 0 || initProvablyLacksSignal(init) || init.type ===
|
|
14885
|
+
if (init === void 0 || initProvablyLacksSignal(init) || init.type === AST_NODE_TYPES60.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
14728
14886
|
context.report({ node, messageId: "missingSignal" });
|
|
14729
14887
|
}
|
|
14730
14888
|
}
|
|
@@ -14733,7 +14891,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
14733
14891
|
});
|
|
14734
14892
|
|
|
14735
14893
|
// src/rules/require-port-for-service.ts
|
|
14736
|
-
import { AST_NODE_TYPES as
|
|
14894
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES61 } from "@typescript-eslint/utils";
|
|
14737
14895
|
var REQUIRE_PORT_FOR_SERVICE_DOCUMENTATION = {
|
|
14738
14896
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
14739
14897
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -14758,45 +14916,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
14758
14916
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
14759
14917
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
14760
14918
|
var staticMemberName6 = (member) => {
|
|
14761
|
-
if (member.property.type ===
|
|
14762
|
-
if (!member.computed && member.property.type ===
|
|
14763
|
-
return member.computed && member.property.type ===
|
|
14919
|
+
if (member.property.type === AST_NODE_TYPES61.PrivateIdentifier) return `#${member.property.name}`;
|
|
14920
|
+
if (!member.computed && member.property.type === AST_NODE_TYPES61.Identifier) return member.property.name;
|
|
14921
|
+
return member.computed && member.property.type === AST_NODE_TYPES61.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
14764
14922
|
};
|
|
14765
14923
|
var detachedValueExports = (program) => {
|
|
14766
14924
|
const names = /* @__PURE__ */ new Set();
|
|
14767
14925
|
for (const statement of program.body) {
|
|
14768
|
-
if (statement.type ===
|
|
14926
|
+
if (statement.type === AST_NODE_TYPES61.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
14769
14927
|
for (const specifier of statement.specifiers) {
|
|
14770
14928
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
14771
14929
|
}
|
|
14772
|
-
} else if (statement.type ===
|
|
14930
|
+
} else if (statement.type === AST_NODE_TYPES61.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES61.Identifier) {
|
|
14773
14931
|
names.add(statement.declaration.name);
|
|
14774
|
-
} else if (statement.type ===
|
|
14932
|
+
} else if (statement.type === AST_NODE_TYPES61.TSExportAssignment && statement.expression.type === AST_NODE_TYPES61.Identifier) {
|
|
14775
14933
|
names.add(statement.expression.name);
|
|
14776
14934
|
}
|
|
14777
14935
|
}
|
|
14778
14936
|
return names;
|
|
14779
14937
|
};
|
|
14780
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
14938
|
+
var isExportedClass2 = (node, detached) => node.parent.type === AST_NODE_TYPES61.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES61.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
14781
14939
|
var readTypeReference = (annotation) => {
|
|
14782
|
-
if (annotation?.type ===
|
|
14940
|
+
if (annotation?.type === AST_NODE_TYPES61.TSUnionType) {
|
|
14783
14941
|
const members = annotation.types.filter(
|
|
14784
|
-
(member) => member.type !==
|
|
14942
|
+
(member) => member.type !== AST_NODE_TYPES61.TSUndefinedKeyword && member.type !== AST_NODE_TYPES61.TSNullKeyword
|
|
14785
14943
|
);
|
|
14786
14944
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
14787
14945
|
}
|
|
14788
|
-
if (annotation === void 0 || annotation.type !==
|
|
14946
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES61.TSTypeReference) return null;
|
|
14789
14947
|
const { typeName } = annotation;
|
|
14790
|
-
const rightmost = typeName.type ===
|
|
14948
|
+
const rightmost = typeName.type === AST_NODE_TYPES61.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES61.TSQualifiedName ? typeName.right.name : null;
|
|
14791
14949
|
if (rightmost === null) return null;
|
|
14792
14950
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
14793
14951
|
};
|
|
14794
|
-
var qualifiedName = (name) => name.type ===
|
|
14952
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES61.Identifier ? name.name : name.type === AST_NODE_TYPES61.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
14795
14953
|
var propertySignatureTypes = (members) => {
|
|
14796
14954
|
const types = /* @__PURE__ */ new Map();
|
|
14797
14955
|
for (const member of members) {
|
|
14798
|
-
if (member.type !==
|
|
14799
|
-
if (member.computed || member.key.type !==
|
|
14956
|
+
if (member.type !== AST_NODE_TYPES61.TSPropertySignature) continue;
|
|
14957
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES61.Identifier) continue;
|
|
14800
14958
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
14801
14959
|
if (reference === null) continue;
|
|
14802
14960
|
types.set(member.key.name, reference);
|
|
@@ -14807,18 +14965,18 @@ var fileTypeIndex = (program) => {
|
|
|
14807
14965
|
const objects = /* @__PURE__ */ new Map();
|
|
14808
14966
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
14809
14967
|
for (const statement of program.body) {
|
|
14810
|
-
const declaration = statement.type ===
|
|
14811
|
-
if (declaration?.type ===
|
|
14968
|
+
const declaration = statement.type === AST_NODE_TYPES61.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14969
|
+
if (declaration?.type === AST_NODE_TYPES61.TSInterfaceDeclaration) {
|
|
14812
14970
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
14813
14971
|
continue;
|
|
14814
14972
|
}
|
|
14815
|
-
if (declaration?.type !==
|
|
14973
|
+
if (declaration?.type !== AST_NODE_TYPES61.TSTypeAliasDeclaration) continue;
|
|
14816
14974
|
const aliased = declaration.typeAnnotation;
|
|
14817
|
-
if (aliased.type ===
|
|
14975
|
+
if (aliased.type === AST_NODE_TYPES61.TSFunctionType || aliased.type === AST_NODE_TYPES61.TSConstructorType) {
|
|
14818
14976
|
functionAliases.add(declaration.id.name);
|
|
14819
14977
|
continue;
|
|
14820
14978
|
}
|
|
14821
|
-
const literals = aliased.type ===
|
|
14979
|
+
const literals = aliased.type === AST_NODE_TYPES61.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES61.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES61.TSTypeLiteral) : [];
|
|
14822
14980
|
if (literals.length === 0) continue;
|
|
14823
14981
|
const merged = /* @__PURE__ */ new Map();
|
|
14824
14982
|
for (const literal of literals) {
|
|
@@ -14847,10 +15005,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14847
15005
|
while (pending.length > 0) {
|
|
14848
15006
|
const current = pending.pop();
|
|
14849
15007
|
if (current === void 0) break;
|
|
14850
|
-
if (current.type ===
|
|
14851
|
-
const expression = current.type ===
|
|
14852
|
-
const storedField = expression?.type ===
|
|
14853
|
-
if (expression?.type !==
|
|
15008
|
+
if (current.type === AST_NODE_TYPES61.ArrowFunctionExpression || current.type === AST_NODE_TYPES61.FunctionExpression || current.type === AST_NODE_TYPES61.FunctionDeclaration || current.type === AST_NODE_TYPES61.ClassExpression || current.type === AST_NODE_TYPES61.ClassDeclaration) continue;
|
|
15009
|
+
const expression = current.type === AST_NODE_TYPES61.ExpressionStatement ? current.expression : null;
|
|
15010
|
+
const storedField = expression?.type === AST_NODE_TYPES61.AssignmentExpression && expression.left.type === AST_NODE_TYPES61.MemberExpression && expression.left.object.type === AST_NODE_TYPES61.ThisExpression ? staticMemberName6(expression.left) : null;
|
|
15011
|
+
if (expression?.type !== AST_NODE_TYPES61.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== AST_NODE_TYPES61.MemberExpression || expression.left.object.type !== AST_NODE_TYPES61.ThisExpression || storedField === null) {
|
|
14854
15012
|
for (const key of Object.keys(current)) {
|
|
14855
15013
|
if (key === "parent") continue;
|
|
14856
15014
|
const value = current[key];
|
|
@@ -14863,14 +15021,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14863
15021
|
continue;
|
|
14864
15022
|
}
|
|
14865
15023
|
let source = expression.right;
|
|
14866
|
-
while (source.type ===
|
|
14867
|
-
if (source.type ===
|
|
15024
|
+
while (source.type === AST_NODE_TYPES61.TSNonNullExpression || source.type === AST_NODE_TYPES61.TSAsExpression || source.type === AST_NODE_TYPES61.TSSatisfiesExpression || source.type === AST_NODE_TYPES61.TSTypeAssertion) source = source.expression;
|
|
15025
|
+
if (source.type === AST_NODE_TYPES61.NewExpression) {
|
|
14868
15026
|
constructedFields += 1;
|
|
14869
|
-
} else if (source.type ===
|
|
15027
|
+
} else if (source.type === AST_NODE_TYPES61.Identifier) {
|
|
14870
15028
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
14871
15029
|
fields.add(storedField);
|
|
14872
15030
|
storedFieldsFrom.set(source.name, fields);
|
|
14873
|
-
} else if (source.type ===
|
|
15031
|
+
} else if (source.type === AST_NODE_TYPES61.MemberExpression && source.object.type === AST_NODE_TYPES61.Identifier) {
|
|
14874
15032
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
14875
15033
|
fields.add(storedField);
|
|
14876
15034
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -14888,7 +15046,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14888
15046
|
const collaborators = [];
|
|
14889
15047
|
for (const parameter of ctor.value.params) {
|
|
14890
15048
|
for (const reference of parameterCollaborators(parameter, declared, storedMemberFieldsFrom)) {
|
|
14891
|
-
const fields = parameter.type ===
|
|
15049
|
+
const fields = parameter.type === AST_NODE_TYPES61.TSParameterProperty ? [reference.name] : reference.fields.length > 0 ? reference.fields : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
14892
15050
|
if (fields.length === 0) continue;
|
|
14893
15051
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
14894
15052
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -14903,8 +15061,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
14903
15061
|
};
|
|
14904
15062
|
var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
14905
15063
|
let target = parameter;
|
|
14906
|
-
if (target.type ===
|
|
14907
|
-
if (target.type ===
|
|
15064
|
+
if (target.type === AST_NODE_TYPES61.AssignmentPattern) target = target.left;
|
|
15065
|
+
if (target.type === AST_NODE_TYPES61.ObjectPattern) {
|
|
14908
15066
|
return objectPatternCollaborators(target, declared);
|
|
14909
15067
|
}
|
|
14910
15068
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -14913,9 +15071,9 @@ var parameterCollaborators = (parameter, declared, storedMemberFieldsFrom) => {
|
|
|
14913
15071
|
};
|
|
14914
15072
|
var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
14915
15073
|
let target = annotated;
|
|
14916
|
-
if (target.type ===
|
|
14917
|
-
if (target.type ===
|
|
14918
|
-
if (target.type !==
|
|
15074
|
+
if (target.type === AST_NODE_TYPES61.TSParameterProperty) target = target.parameter;
|
|
15075
|
+
if (target.type === AST_NODE_TYPES61.AssignmentPattern) target = target.left;
|
|
15076
|
+
if (target.type !== AST_NODE_TYPES61.Identifier) return [];
|
|
14919
15077
|
const members = bagMemberTypes(target.typeAnnotation?.typeAnnotation, declared);
|
|
14920
15078
|
if (members === null) return [];
|
|
14921
15079
|
const storedMembers = storedMemberFieldsFrom.get(target.name);
|
|
@@ -14931,9 +15089,9 @@ var namedBagCollaborators = (annotated, declared, storedMemberFieldsFrom) => {
|
|
|
14931
15089
|
};
|
|
14932
15090
|
var namedParameterCollaborator = (annotated) => {
|
|
14933
15091
|
let target = annotated;
|
|
14934
|
-
if (target.type ===
|
|
14935
|
-
if (target.type ===
|
|
14936
|
-
if (target.type !==
|
|
15092
|
+
if (target.type === AST_NODE_TYPES61.TSParameterProperty) target = target.parameter;
|
|
15093
|
+
if (target.type === AST_NODE_TYPES61.AssignmentPattern) target = target.left;
|
|
15094
|
+
if (target.type !== AST_NODE_TYPES61.Identifier) return null;
|
|
14937
15095
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
14938
15096
|
if (reference === null) return null;
|
|
14939
15097
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -14945,11 +15103,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
14945
15103
|
if (members === null) return [];
|
|
14946
15104
|
const collaborators = [];
|
|
14947
15105
|
for (const property of pattern.properties) {
|
|
14948
|
-
if (property.type !==
|
|
14949
|
-
if (property.key.type !==
|
|
15106
|
+
if (property.type !== AST_NODE_TYPES61.Property || property.computed) continue;
|
|
15107
|
+
if (property.key.type !== AST_NODE_TYPES61.Identifier) continue;
|
|
14950
15108
|
const key = property.key.name;
|
|
14951
|
-
const bound = property.value.type ===
|
|
14952
|
-
if (bound.type !==
|
|
15109
|
+
const bound = property.value.type === AST_NODE_TYPES61.AssignmentPattern ? property.value.left : property.value;
|
|
15110
|
+
if (bound.type !== AST_NODE_TYPES61.Identifier) continue;
|
|
14953
15111
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
14954
15112
|
const reference = members.get(key);
|
|
14955
15113
|
if (reference === void 0) continue;
|
|
@@ -14959,21 +15117,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
14959
15117
|
};
|
|
14960
15118
|
var bagMemberTypes = (annotation, declared) => {
|
|
14961
15119
|
if (annotation === void 0) return null;
|
|
14962
|
-
if (annotation.type ===
|
|
15120
|
+
if (annotation.type === AST_NODE_TYPES61.TSTypeLiteral) {
|
|
14963
15121
|
return propertySignatureTypes(annotation.members);
|
|
14964
15122
|
}
|
|
14965
|
-
if (annotation.type !==
|
|
15123
|
+
if (annotation.type !== AST_NODE_TYPES61.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES61.Identifier) {
|
|
14966
15124
|
return null;
|
|
14967
15125
|
}
|
|
14968
15126
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
14969
15127
|
};
|
|
14970
15128
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
14971
|
-
if (node.type ===
|
|
15129
|
+
if (node.type === AST_NODE_TYPES61.CallExpression) {
|
|
14972
15130
|
const { callee } = node;
|
|
14973
|
-
if (callee.type ===
|
|
14974
|
-
return callee.type ===
|
|
15131
|
+
if (callee.type === AST_NODE_TYPES61.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
15132
|
+
return callee.type === AST_NODE_TYPES61.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES61.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
14975
15133
|
}
|
|
14976
|
-
return node.type ===
|
|
15134
|
+
return node.type === AST_NODE_TYPES61.TSTypeReference && node.typeName.type === AST_NODE_TYPES61.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
14977
15135
|
});
|
|
14978
15136
|
var subtreeHas = (root, found) => {
|
|
14979
15137
|
let hit = false;
|
|
@@ -15000,19 +15158,19 @@ var invokedInstanceField = (call) => {
|
|
|
15000
15158
|
const direct = instanceField(call.callee);
|
|
15001
15159
|
if (direct !== null) return direct;
|
|
15002
15160
|
let callee = call.callee;
|
|
15003
|
-
while (callee.type ===
|
|
15004
|
-
return callee.type ===
|
|
15161
|
+
while (callee.type === AST_NODE_TYPES61.ChainExpression || callee.type === AST_NODE_TYPES61.TSAsExpression || callee.type === AST_NODE_TYPES61.TSNonNullExpression || callee.type === AST_NODE_TYPES61.TSSatisfiesExpression || callee.type === AST_NODE_TYPES61.TSTypeAssertion) callee = callee.expression;
|
|
15162
|
+
return callee.type === AST_NODE_TYPES61.MemberExpression ? instanceField(callee.object) : null;
|
|
15005
15163
|
};
|
|
15006
15164
|
var instanceField = (candidate2) => {
|
|
15007
15165
|
let node = candidate2;
|
|
15008
|
-
while (node.type ===
|
|
15009
|
-
return node.type ===
|
|
15166
|
+
while (node.type === AST_NODE_TYPES61.ChainExpression || node.type === AST_NODE_TYPES61.TSAsExpression || node.type === AST_NODE_TYPES61.TSNonNullExpression || node.type === AST_NODE_TYPES61.TSSatisfiesExpression || node.type === AST_NODE_TYPES61.TSTypeAssertion) node = node.expression;
|
|
15167
|
+
return node.type === AST_NODE_TYPES61.MemberExpression && node.object.type === AST_NODE_TYPES61.ThisExpression ? staticMemberName6(node) : null;
|
|
15010
15168
|
};
|
|
15011
15169
|
var behaviorallyInvokedFields = (body2) => {
|
|
15012
15170
|
const invoked = /* @__PURE__ */ new Set();
|
|
15013
15171
|
const visit = (current) => {
|
|
15014
|
-
if (current.type ===
|
|
15015
|
-
if (current.type ===
|
|
15172
|
+
if (current.type === AST_NODE_TYPES61.ClassDeclaration || current.type === AST_NODE_TYPES61.ClassExpression || current.type === AST_NODE_TYPES61.FunctionDeclaration || current.type === AST_NODE_TYPES61.FunctionExpression) return;
|
|
15173
|
+
if (current.type === AST_NODE_TYPES61.CallExpression) {
|
|
15016
15174
|
const field = invokedInstanceField(current);
|
|
15017
15175
|
if (field !== null) invoked.add(field);
|
|
15018
15176
|
}
|
|
@@ -15025,14 +15183,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
15025
15183
|
}
|
|
15026
15184
|
};
|
|
15027
15185
|
for (const member of body2.body) {
|
|
15028
|
-
if (member.type ===
|
|
15029
|
-
if (member.type ===
|
|
15186
|
+
if (member.type === AST_NODE_TYPES61.StaticBlock || member.static) continue;
|
|
15187
|
+
if (member.type === AST_NODE_TYPES61.MethodDefinition) {
|
|
15030
15188
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
15031
15189
|
continue;
|
|
15032
15190
|
}
|
|
15033
|
-
if (member.type !==
|
|
15191
|
+
if (member.type !== AST_NODE_TYPES61.PropertyDefinition || member.value === null) continue;
|
|
15034
15192
|
visit(
|
|
15035
|
-
member.value.type ===
|
|
15193
|
+
member.value.type === AST_NODE_TYPES61.ArrowFunctionExpression ? member.value.body : member.value
|
|
15036
15194
|
);
|
|
15037
15195
|
}
|
|
15038
15196
|
return invoked;
|
|
@@ -15052,25 +15210,25 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
15052
15210
|
var fileInterfaceNames = (program) => {
|
|
15053
15211
|
const names = [];
|
|
15054
15212
|
for (const statement of program.body) {
|
|
15055
|
-
const declaration = statement.type ===
|
|
15056
|
-
if (declaration?.type ===
|
|
15213
|
+
const declaration = statement.type === AST_NODE_TYPES61.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15214
|
+
if (declaration?.type === AST_NODE_TYPES61.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
15057
15215
|
}
|
|
15058
15216
|
return names;
|
|
15059
15217
|
};
|
|
15060
15218
|
var publicMethodNames = (body2, functionAliases) => {
|
|
15061
15219
|
const names = [];
|
|
15062
15220
|
for (const member of body2.body) {
|
|
15063
|
-
if (member.type ===
|
|
15221
|
+
if (member.type === AST_NODE_TYPES61.PropertyDefinition) {
|
|
15064
15222
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
15065
|
-
if (member.value?.type !==
|
|
15066
|
-
names.push(member.key.type ===
|
|
15223
|
+
if (member.value?.type !== AST_NODE_TYPES61.ArrowFunctionExpression && member.value?.type !== AST_NODE_TYPES61.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES61.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES61.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === AST_NODE_TYPES61.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
15224
|
+
names.push(member.key.type === AST_NODE_TYPES61.Identifier ? member.key.name : "\u2026");
|
|
15067
15225
|
continue;
|
|
15068
15226
|
}
|
|
15069
|
-
if (member.type !==
|
|
15227
|
+
if (member.type !== AST_NODE_TYPES61.MethodDefinition) continue;
|
|
15070
15228
|
if (member.kind !== "method" || member.static) continue;
|
|
15071
15229
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
15072
|
-
if (member.key.type ===
|
|
15073
|
-
if (member.key.type ===
|
|
15230
|
+
if (member.key.type === AST_NODE_TYPES61.PrivateIdentifier) continue;
|
|
15231
|
+
if (member.key.type === AST_NODE_TYPES61.Identifier) names.push(member.key.name);
|
|
15074
15232
|
else names.push("\u2026");
|
|
15075
15233
|
}
|
|
15076
15234
|
return names;
|
|
@@ -15078,13 +15236,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
15078
15236
|
var isFluentConstructionObject = (node, getText) => {
|
|
15079
15237
|
if (node.id === null) return false;
|
|
15080
15238
|
const methods = node.body.body.filter(
|
|
15081
|
-
(member) => member.type ===
|
|
15239
|
+
(member) => member.type === AST_NODE_TYPES61.MethodDefinition && member.kind === "method" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.value.body !== null
|
|
15082
15240
|
);
|
|
15083
15241
|
if (methods.length === 0) return false;
|
|
15084
15242
|
return methods.every((member) => {
|
|
15085
15243
|
const result = member.value.returnType?.typeAnnotation;
|
|
15086
15244
|
if (result === void 0) return false;
|
|
15087
|
-
const returnsOwnType = result.type ===
|
|
15245
|
+
const returnsOwnType = result.type === AST_NODE_TYPES61.TSTypeReference && result.typeName.type === AST_NODE_TYPES61.Identifier && result.typeName.name === node.id?.name;
|
|
15088
15246
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
15089
15247
|
});
|
|
15090
15248
|
};
|
|
@@ -15092,10 +15250,10 @@ function localClassAbstractness(program) {
|
|
|
15092
15250
|
const classes = /* @__PURE__ */ new Map();
|
|
15093
15251
|
const parents = /* @__PURE__ */ new Map();
|
|
15094
15252
|
for (const statement of program.body) {
|
|
15095
|
-
const declaration = statement.type ===
|
|
15096
|
-
if (declaration?.type ===
|
|
15253
|
+
const declaration = statement.type === AST_NODE_TYPES61.ExportNamedDeclaration || statement.type === AST_NODE_TYPES61.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
15254
|
+
if (declaration?.type === AST_NODE_TYPES61.ClassDeclaration && declaration.id !== null) {
|
|
15097
15255
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
15098
|
-
if (declaration.superClass?.type ===
|
|
15256
|
+
if (declaration.superClass?.type === AST_NODE_TYPES61.Identifier) {
|
|
15099
15257
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
15100
15258
|
}
|
|
15101
15259
|
}
|
|
@@ -15117,43 +15275,43 @@ function localInterfaceSurfaces(program) {
|
|
|
15117
15275
|
const parents = /* @__PURE__ */ new Map();
|
|
15118
15276
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
15119
15277
|
for (const statement of program.body) {
|
|
15120
|
-
const declaration = statement.type ===
|
|
15121
|
-
if (declaration?.type ===
|
|
15278
|
+
const declaration = statement.type === AST_NODE_TYPES61.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15279
|
+
if (declaration?.type === AST_NODE_TYPES61.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === AST_NODE_TYPES61.TSFunctionType || declaration.typeAnnotation.type === AST_NODE_TYPES61.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
15122
15280
|
}
|
|
15123
15281
|
for (const statement of program.body) {
|
|
15124
|
-
const declaration = statement.type ===
|
|
15125
|
-
if (declaration?.type ===
|
|
15282
|
+
const declaration = statement.type === AST_NODE_TYPES61.ExportNamedDeclaration ? statement.declaration : statement;
|
|
15283
|
+
if (declaration?.type === AST_NODE_TYPES61.TSTypeAliasDeclaration) {
|
|
15126
15284
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
15127
|
-
const parts = declaration.typeAnnotation.type ===
|
|
15285
|
+
const parts = declaration.typeAnnotation.type === AST_NODE_TYPES61.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
15128
15286
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
15129
15287
|
for (const part of parts) {
|
|
15130
|
-
if (part.type ===
|
|
15288
|
+
if (part.type === AST_NODE_TYPES61.TSTypeReference && part.typeName.type === AST_NODE_TYPES61.Identifier) {
|
|
15131
15289
|
inherited.push(part.typeName.name);
|
|
15132
15290
|
continue;
|
|
15133
15291
|
}
|
|
15134
|
-
if (part.type !==
|
|
15292
|
+
if (part.type !== AST_NODE_TYPES61.TSTypeLiteral) continue;
|
|
15135
15293
|
for (const member of part.members) {
|
|
15136
|
-
if (member.type !==
|
|
15137
|
-
if (member.computed || member.key.type !==
|
|
15138
|
-
if (member.type ===
|
|
15294
|
+
if (member.type !== AST_NODE_TYPES61.TSMethodSignature && member.type !== AST_NODE_TYPES61.TSPropertySignature) continue;
|
|
15295
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES61.Identifier) continue;
|
|
15296
|
+
if (member.type === AST_NODE_TYPES61.TSMethodSignature) {
|
|
15139
15297
|
callables2.add(member.key.name);
|
|
15140
15298
|
continue;
|
|
15141
15299
|
}
|
|
15142
|
-
if (member.type !==
|
|
15300
|
+
if (member.type !== AST_NODE_TYPES61.TSPropertySignature) continue;
|
|
15143
15301
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
15144
|
-
if (annotation?.type ===
|
|
15302
|
+
if (annotation?.type === AST_NODE_TYPES61.TSFunctionType || annotation?.type === AST_NODE_TYPES61.TSTypeReference && annotation.typeName.type === AST_NODE_TYPES61.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(member.key.name);
|
|
15145
15303
|
}
|
|
15146
15304
|
}
|
|
15147
15305
|
interfaces.set(declaration.id.name, callables2);
|
|
15148
15306
|
parents.set(declaration.id.name, inherited);
|
|
15149
15307
|
continue;
|
|
15150
15308
|
}
|
|
15151
|
-
if (declaration?.type !==
|
|
15309
|
+
if (declaration?.type !== AST_NODE_TYPES61.TSInterfaceDeclaration) continue;
|
|
15152
15310
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
15153
15311
|
for (const member of declaration.body.body) {
|
|
15154
|
-
if (member.type !==
|
|
15155
|
-
if (member.computed || member.key.type !==
|
|
15156
|
-
if (member.type ===
|
|
15312
|
+
if (member.type !== AST_NODE_TYPES61.TSMethodSignature && member.type !== AST_NODE_TYPES61.TSPropertySignature) continue;
|
|
15313
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES61.Identifier) continue;
|
|
15314
|
+
if (member.type === AST_NODE_TYPES61.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES61.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES61.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === AST_NODE_TYPES61.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(member.key.name);
|
|
15157
15315
|
}
|
|
15158
15316
|
interfaces.set(declaration.id.name, callables);
|
|
15159
15317
|
parents.set(
|
|
@@ -15161,7 +15319,7 @@ function localInterfaceSurfaces(program) {
|
|
|
15161
15319
|
[
|
|
15162
15320
|
...parents.get(declaration.id.name) ?? [],
|
|
15163
15321
|
...declaration.extends.flatMap(
|
|
15164
|
-
(heritage) => heritage.expression.type ===
|
|
15322
|
+
(heritage) => heritage.expression.type === AST_NODE_TYPES61.Identifier ? [heritage.expression.name] : ["*"]
|
|
15165
15323
|
)
|
|
15166
15324
|
]
|
|
15167
15325
|
);
|
|
@@ -15188,7 +15346,7 @@ function localInterfaceSurfaces(program) {
|
|
|
15188
15346
|
}
|
|
15189
15347
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
15190
15348
|
if (node.superClass !== null) {
|
|
15191
|
-
if (node.superClass.type !==
|
|
15349
|
+
if (node.superClass.type !== AST_NODE_TYPES61.Identifier) return true;
|
|
15192
15350
|
const localAbstract = classes.get(node.superClass.name);
|
|
15193
15351
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
15194
15352
|
}
|
|
@@ -15200,7 +15358,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
15200
15358
|
if (node.implements.length === 0) return false;
|
|
15201
15359
|
const combined = /* @__PURE__ */ new Set();
|
|
15202
15360
|
for (const implementation of node.implements) {
|
|
15203
|
-
if (implementation.expression.type !==
|
|
15361
|
+
if (implementation.expression.type !== AST_NODE_TYPES61.Identifier) return true;
|
|
15204
15362
|
const name = implementation.expression.name;
|
|
15205
15363
|
const localAbstract = classes.get(name);
|
|
15206
15364
|
if (localAbstract === true) return true;
|
|
@@ -15243,7 +15401,7 @@ var require_port_for_service_default = createRule({
|
|
|
15243
15401
|
if (node.abstract === true) return;
|
|
15244
15402
|
if (node.decorators.length > 0) return;
|
|
15245
15403
|
const ctor = node.body.body.find(
|
|
15246
|
-
(member) => member.type ===
|
|
15404
|
+
(member) => member.type === AST_NODE_TYPES61.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
15247
15405
|
);
|
|
15248
15406
|
if (ctor === void 0) return;
|
|
15249
15407
|
const constructorFacts = readConstructor(
|
|
@@ -15278,7 +15436,7 @@ var require_port_for_service_default = createRule({
|
|
|
15278
15436
|
});
|
|
15279
15437
|
|
|
15280
15438
|
// src/rules/require-static-next-matcher.ts
|
|
15281
|
-
import { AST_NODE_TYPES as
|
|
15439
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES62 } from "@typescript-eslint/utils";
|
|
15282
15440
|
var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
15283
15441
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
15284
15442
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -15291,34 +15449,34 @@ var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
|
15291
15449
|
};
|
|
15292
15450
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
15293
15451
|
function unwrapExpression3(node) {
|
|
15294
|
-
if (node.type ===
|
|
15452
|
+
if (node.type === AST_NODE_TYPES62.TSAsExpression || node.type === AST_NODE_TYPES62.TSSatisfiesExpression || node.type === AST_NODE_TYPES62.TSNonNullExpression || node.type === AST_NODE_TYPES62.TSTypeAssertion) {
|
|
15295
15453
|
return unwrapExpression3(node.expression);
|
|
15296
15454
|
}
|
|
15297
15455
|
return node;
|
|
15298
15456
|
}
|
|
15299
15457
|
function isStaticValue(node) {
|
|
15300
15458
|
const value = unwrapExpression3(node);
|
|
15301
|
-
if (value.type ===
|
|
15459
|
+
if (value.type === AST_NODE_TYPES62.Literal) {
|
|
15302
15460
|
return true;
|
|
15303
15461
|
}
|
|
15304
|
-
if (value.type ===
|
|
15462
|
+
if (value.type === AST_NODE_TYPES62.TemplateLiteral) {
|
|
15305
15463
|
return value.expressions.length === 0;
|
|
15306
15464
|
}
|
|
15307
|
-
if (value.type ===
|
|
15465
|
+
if (value.type === AST_NODE_TYPES62.ArrayExpression) {
|
|
15308
15466
|
return value.elements.every(
|
|
15309
|
-
(element) => element !== null && element.type !==
|
|
15467
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES62.SpreadElement && isStaticValue(element)
|
|
15310
15468
|
);
|
|
15311
15469
|
}
|
|
15312
|
-
if (value.type ===
|
|
15470
|
+
if (value.type === AST_NODE_TYPES62.ObjectExpression) {
|
|
15313
15471
|
return value.properties.every(
|
|
15314
|
-
(property) => property.type ===
|
|
15472
|
+
(property) => property.type === AST_NODE_TYPES62.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES62.AssignmentPattern && isStaticValue(property.value)
|
|
15315
15473
|
);
|
|
15316
15474
|
}
|
|
15317
15475
|
return false;
|
|
15318
15476
|
}
|
|
15319
15477
|
function propertyName4(property) {
|
|
15320
15478
|
if (property.computed) return null;
|
|
15321
|
-
if (property.key.type ===
|
|
15479
|
+
if (property.key.type === AST_NODE_TYPES62.Identifier) return property.key.name;
|
|
15322
15480
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
15323
15481
|
}
|
|
15324
15482
|
var require_static_next_matcher_default = createRule({
|
|
@@ -15341,19 +15499,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
15341
15499
|
}
|
|
15342
15500
|
return {
|
|
15343
15501
|
ExportNamedDeclaration(node) {
|
|
15344
|
-
if (node.declaration?.type !==
|
|
15502
|
+
if (node.declaration?.type !== AST_NODE_TYPES62.VariableDeclaration) {
|
|
15345
15503
|
return;
|
|
15346
15504
|
}
|
|
15347
15505
|
for (const declaration of node.declaration.declarations) {
|
|
15348
|
-
if (declaration.id.type !==
|
|
15506
|
+
if (declaration.id.type !== AST_NODE_TYPES62.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
15349
15507
|
continue;
|
|
15350
15508
|
}
|
|
15351
15509
|
const config = unwrapExpression3(declaration.init);
|
|
15352
|
-
if (config.type !==
|
|
15510
|
+
if (config.type !== AST_NODE_TYPES62.ObjectExpression) {
|
|
15353
15511
|
continue;
|
|
15354
15512
|
}
|
|
15355
15513
|
for (const property of config.properties) {
|
|
15356
|
-
if (property.type !==
|
|
15514
|
+
if (property.type !== AST_NODE_TYPES62.Property || propertyName4(property) !== "matcher" || property.value.type === AST_NODE_TYPES62.AssignmentPattern) {
|
|
15357
15515
|
continue;
|
|
15358
15516
|
}
|
|
15359
15517
|
if (!isStaticValue(property.value)) {
|
|
@@ -15367,7 +15525,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
15367
15525
|
});
|
|
15368
15526
|
|
|
15369
15527
|
// src/rules/require-use-form-default-values.ts
|
|
15370
|
-
import { ASTUtils as
|
|
15528
|
+
import { ASTUtils as ASTUtils20 } from "@typescript-eslint/utils";
|
|
15371
15529
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
15372
15530
|
summary: "react-hook-form useForm call without defaultValues",
|
|
15373
15531
|
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.",
|
|
@@ -15421,13 +15579,13 @@ var require_use_form_default_values_default = createRule({
|
|
|
15421
15579
|
if (node.source.value !== "react-hook-form") return;
|
|
15422
15580
|
for (const specifier of node.specifiers) {
|
|
15423
15581
|
if (specifier.type !== "ImportSpecifier" || (specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value) !== "useForm") continue;
|
|
15424
|
-
const variable =
|
|
15582
|
+
const variable = ASTUtils20.findVariable(context.sourceCode.getScope(specifier.local), specifier.local.name);
|
|
15425
15583
|
if (variable) importedHooks.add(variable);
|
|
15426
15584
|
}
|
|
15427
15585
|
},
|
|
15428
15586
|
CallExpression(node) {
|
|
15429
15587
|
if (node.callee.type !== "Identifier") return;
|
|
15430
|
-
const variable =
|
|
15588
|
+
const variable = ASTUtils20.findVariable(context.sourceCode.getScope(node.callee), node.callee.name);
|
|
15431
15589
|
const options = node.arguments[0];
|
|
15432
15590
|
if (!variable || !importedHooks.has(variable) || options !== void 0 && options.type !== "ObjectExpression" || hasDefaultValues(options)) return;
|
|
15433
15591
|
context.report({ node, messageId: "requireUseFormDefaultValues" });
|
|
@@ -15504,8 +15662,8 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
15504
15662
|
|
|
15505
15663
|
// src/rules/require-zod-form-validation.ts
|
|
15506
15664
|
import {
|
|
15507
|
-
AST_NODE_TYPES as
|
|
15508
|
-
ASTUtils as
|
|
15665
|
+
AST_NODE_TYPES as AST_NODE_TYPES63,
|
|
15666
|
+
ASTUtils as ASTUtils21
|
|
15509
15667
|
} from "@typescript-eslint/utils";
|
|
15510
15668
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
15511
15669
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
@@ -15531,14 +15689,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
15531
15689
|
var zodReceiverRoot = (node) => {
|
|
15532
15690
|
let current = node;
|
|
15533
15691
|
while (true) {
|
|
15534
|
-
if (current.type ===
|
|
15692
|
+
if (current.type === AST_NODE_TYPES63.Identifier) {
|
|
15535
15693
|
return current;
|
|
15536
15694
|
}
|
|
15537
|
-
if (current.type ===
|
|
15695
|
+
if (current.type === AST_NODE_TYPES63.CallExpression) {
|
|
15538
15696
|
current = current.callee;
|
|
15539
15697
|
continue;
|
|
15540
15698
|
}
|
|
15541
|
-
if (current.type ===
|
|
15699
|
+
if (current.type === AST_NODE_TYPES63.MemberExpression) {
|
|
15542
15700
|
current = current.object;
|
|
15543
15701
|
continue;
|
|
15544
15702
|
}
|
|
@@ -15547,12 +15705,12 @@ var zodReceiverRoot = (node) => {
|
|
|
15547
15705
|
};
|
|
15548
15706
|
var isFormDataMethodCall = (node) => {
|
|
15549
15707
|
let current = node;
|
|
15550
|
-
if (current.type ===
|
|
15708
|
+
if (current.type === AST_NODE_TYPES63.AwaitExpression) {
|
|
15551
15709
|
current = current.argument;
|
|
15552
15710
|
}
|
|
15553
|
-
if (current.type !==
|
|
15711
|
+
if (current.type !== AST_NODE_TYPES63.CallExpression) return false;
|
|
15554
15712
|
const callee = current.callee;
|
|
15555
|
-
return callee.type ===
|
|
15713
|
+
return callee.type === AST_NODE_TYPES63.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES63.Identifier && callee.property.name === "formData";
|
|
15556
15714
|
};
|
|
15557
15715
|
var require_zod_form_validation_default = createRule({
|
|
15558
15716
|
name: "require-zod-form-validation",
|
|
@@ -15573,7 +15731,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15573
15731
|
return {};
|
|
15574
15732
|
}
|
|
15575
15733
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
15576
|
-
const resolvedBinding = (identifier) =>
|
|
15734
|
+
const resolvedBinding = (identifier) => ASTUtils21.findVariable(
|
|
15577
15735
|
context.sourceCode.getScope(identifier),
|
|
15578
15736
|
identifier.name
|
|
15579
15737
|
);
|
|
@@ -15583,16 +15741,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
15583
15741
|
return false;
|
|
15584
15742
|
}
|
|
15585
15743
|
const definition = binding.defs[0];
|
|
15586
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
15744
|
+
if (definition?.type !== "Variable" || definition.node.type !== AST_NODE_TYPES63.VariableDeclarator) {
|
|
15587
15745
|
return false;
|
|
15588
15746
|
}
|
|
15589
15747
|
const init = definition.node.init;
|
|
15590
|
-
return init?.type ===
|
|
15748
|
+
return init?.type === AST_NODE_TYPES63.ObjectExpression || init?.type === AST_NODE_TYPES63.ArrayExpression || init?.type === AST_NODE_TYPES63.Literal || init?.type === AST_NODE_TYPES63.ArrowFunctionExpression || init?.type === AST_NODE_TYPES63.FunctionExpression;
|
|
15591
15749
|
};
|
|
15592
15750
|
const isZodParseCall = (node) => {
|
|
15593
|
-
if (node.type !==
|
|
15751
|
+
if (node.type !== AST_NODE_TYPES63.CallExpression) return false;
|
|
15594
15752
|
const callee = node.callee;
|
|
15595
|
-
if (callee.type !==
|
|
15753
|
+
if (callee.type !== AST_NODE_TYPES63.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES63.Identifier || !ZOD_PARSE_METHODS.has(callee.property.name)) {
|
|
15596
15754
|
return false;
|
|
15597
15755
|
}
|
|
15598
15756
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -15601,14 +15759,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
15601
15759
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
15602
15760
|
};
|
|
15603
15761
|
const isFormSourceIdentifier = (node) => {
|
|
15604
|
-
if (node.type !==
|
|
15762
|
+
if (node.type !== AST_NODE_TYPES63.Identifier) return false;
|
|
15605
15763
|
const conventionalName = /formdata/i.test(node.name);
|
|
15606
15764
|
let scope = context.sourceCode.getScope(node);
|
|
15607
15765
|
while (scope !== null) {
|
|
15608
15766
|
const variable = scope.set.get(node.name);
|
|
15609
15767
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
15610
15768
|
const def = variable.defs[0];
|
|
15611
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
15769
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES63.VariableDeclarator && def.node.init !== null) {
|
|
15612
15770
|
return isFormDataMethodCall(def.node.init);
|
|
15613
15771
|
}
|
|
15614
15772
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -15619,8 +15777,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
15619
15777
|
};
|
|
15620
15778
|
const isFormDataGetCall = (node) => {
|
|
15621
15779
|
const callee = node.callee;
|
|
15622
|
-
if (callee.type !==
|
|
15623
|
-
if (callee.property.type !==
|
|
15780
|
+
if (callee.type !== AST_NODE_TYPES63.MemberExpression) return false;
|
|
15781
|
+
if (callee.property.type !== AST_NODE_TYPES63.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
15624
15782
|
return false;
|
|
15625
15783
|
}
|
|
15626
15784
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -15636,16 +15794,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
15636
15794
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
15637
15795
|
const isInstanceofNarrowing = (node) => {
|
|
15638
15796
|
const parent = node.parent;
|
|
15639
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
15797
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES63.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES63.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
15640
15798
|
};
|
|
15641
15799
|
const boundDeclarator = (node) => {
|
|
15642
15800
|
let current = node;
|
|
15643
15801
|
let parent = current.parent;
|
|
15644
|
-
while ((parent.type ===
|
|
15802
|
+
while ((parent.type === AST_NODE_TYPES63.TSAsExpression || parent.type === AST_NODE_TYPES63.TSSatisfiesExpression || parent.type === AST_NODE_TYPES63.TSNonNullExpression || parent.type === AST_NODE_TYPES63.ChainExpression) && parent.expression === current) {
|
|
15645
15803
|
current = parent;
|
|
15646
15804
|
parent = current.parent;
|
|
15647
15805
|
}
|
|
15648
|
-
if (parent.type ===
|
|
15806
|
+
if (parent.type === AST_NODE_TYPES63.VariableDeclarator && parent.init === current && parent.id.type === AST_NODE_TYPES63.Identifier) {
|
|
15649
15807
|
return parent;
|
|
15650
15808
|
}
|
|
15651
15809
|
return null;
|
|
@@ -15654,7 +15812,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15654
15812
|
let current = node;
|
|
15655
15813
|
while (current.parent !== void 0) {
|
|
15656
15814
|
const parent = current.parent;
|
|
15657
|
-
if (parent.type ===
|
|
15815
|
+
if (parent.type === AST_NODE_TYPES63.BlockStatement || parent.type === AST_NODE_TYPES63.Program) {
|
|
15658
15816
|
return current;
|
|
15659
15817
|
}
|
|
15660
15818
|
current = parent;
|
|
@@ -15663,12 +15821,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
15663
15821
|
};
|
|
15664
15822
|
const zodParseMethod = (call) => {
|
|
15665
15823
|
const callee = call.callee;
|
|
15666
|
-
return callee.type ===
|
|
15824
|
+
return callee.type === AST_NODE_TYPES63.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES63.Identifier ? callee.property.name : null;
|
|
15667
15825
|
};
|
|
15668
15826
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
15669
15827
|
let current = node.parent;
|
|
15670
15828
|
while (current !== void 0 && current !== statement) {
|
|
15671
|
-
if (current.type ===
|
|
15829
|
+
if (current.type === AST_NODE_TYPES63.LogicalExpression || current.type === AST_NODE_TYPES63.ConditionalExpression) {
|
|
15672
15830
|
return true;
|
|
15673
15831
|
}
|
|
15674
15832
|
current = current.parent;
|
|
@@ -15678,7 +15836,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15678
15836
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
15679
15837
|
let current = node.parent;
|
|
15680
15838
|
while (current !== void 0 && current !== statement) {
|
|
15681
|
-
if (current.type ===
|
|
15839
|
+
if (current.type === AST_NODE_TYPES63.AwaitExpression) return true;
|
|
15682
15840
|
current = current.parent;
|
|
15683
15841
|
}
|
|
15684
15842
|
return false;
|
|
@@ -15691,7 +15849,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15691
15849
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
15692
15850
|
return null;
|
|
15693
15851
|
}
|
|
15694
|
-
if (validationStatement.type !==
|
|
15852
|
+
if (validationStatement.type !== AST_NODE_TYPES63.VariableDeclaration && validationStatement.type !== AST_NODE_TYPES63.ExpressionStatement) {
|
|
15695
15853
|
return null;
|
|
15696
15854
|
}
|
|
15697
15855
|
const method = zodParseMethod(parse2);
|
|
@@ -15703,16 +15861,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
15703
15861
|
};
|
|
15704
15862
|
const isSafePrevalidationInspection = (identifier) => {
|
|
15705
15863
|
const parent = identifier.parent;
|
|
15706
|
-
if (parent.type ===
|
|
15864
|
+
if (parent.type === AST_NODE_TYPES63.UnaryExpression && parent.operator === "typeof") {
|
|
15707
15865
|
return true;
|
|
15708
15866
|
}
|
|
15709
|
-
if (parent.type !==
|
|
15867
|
+
if (parent.type !== AST_NODE_TYPES63.BinaryExpression || parent.left !== identifier) {
|
|
15710
15868
|
return false;
|
|
15711
15869
|
}
|
|
15712
15870
|
if (parent.operator === "instanceof") {
|
|
15713
|
-
return parent.right.type ===
|
|
15871
|
+
return parent.right.type === AST_NODE_TYPES63.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
15714
15872
|
}
|
|
15715
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
15873
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === AST_NODE_TYPES63.Literal && parent.right.value === null || parent.right.type === AST_NODE_TYPES63.Identifier && parent.right.name === "undefined");
|
|
15716
15874
|
};
|
|
15717
15875
|
const isDescendantOf = (node, ancestor) => {
|
|
15718
15876
|
let current = node;
|
|
@@ -15723,23 +15881,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
15723
15881
|
return false;
|
|
15724
15882
|
};
|
|
15725
15883
|
const blockTerminates = (node) => {
|
|
15726
|
-
if (node.type ===
|
|
15884
|
+
if (node.type === AST_NODE_TYPES63.ReturnStatement || node.type === AST_NODE_TYPES63.ThrowStatement) {
|
|
15727
15885
|
return true;
|
|
15728
15886
|
}
|
|
15729
|
-
if (node.type !==
|
|
15887
|
+
if (node.type !== AST_NODE_TYPES63.BlockStatement || node.body.length === 0) return false;
|
|
15730
15888
|
const last = node.body.at(-1);
|
|
15731
15889
|
return last !== void 0 && blockTerminates(last);
|
|
15732
15890
|
};
|
|
15733
15891
|
const narrowingIf = (identifier) => {
|
|
15734
15892
|
const comparison = identifier.parent;
|
|
15735
|
-
if (comparison?.type !==
|
|
15893
|
+
if (comparison?.type !== AST_NODE_TYPES63.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== AST_NODE_TYPES63.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
15736
15894
|
return null;
|
|
15737
15895
|
}
|
|
15738
15896
|
const maybeNegation = comparison.parent;
|
|
15739
|
-
const negated = maybeNegation?.type ===
|
|
15897
|
+
const negated = maybeNegation?.type === AST_NODE_TYPES63.UnaryExpression && maybeNegation.operator === "!";
|
|
15740
15898
|
const test = negated ? maybeNegation : comparison;
|
|
15741
15899
|
const branch = test.parent;
|
|
15742
|
-
return branch?.type ===
|
|
15900
|
+
return branch?.type === AST_NODE_TYPES63.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
15743
15901
|
};
|
|
15744
15902
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
15745
15903
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -15759,7 +15917,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15759
15917
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
15760
15918
|
if (variable === void 0) return false;
|
|
15761
15919
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
15762
|
-
(identifier) => identifier.type ===
|
|
15920
|
+
(identifier) => identifier.type === AST_NODE_TYPES63.Identifier
|
|
15763
15921
|
);
|
|
15764
15922
|
if (references.length === 0) return false;
|
|
15765
15923
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -15785,7 +15943,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
15785
15943
|
ImportDeclaration(node) {
|
|
15786
15944
|
if (!isZodModule(node.source.value)) return;
|
|
15787
15945
|
for (const specifier of node.specifiers) {
|
|
15788
|
-
if (specifier.type ===
|
|
15946
|
+
if (specifier.type === AST_NODE_TYPES63.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES63.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES63.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES63.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
15789
15947
|
const binding = resolvedBinding(specifier.local);
|
|
15790
15948
|
if (binding !== null) zodBindings.add(binding);
|
|
15791
15949
|
}
|
|
@@ -15870,7 +16028,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
15870
16028
|
});
|
|
15871
16029
|
|
|
15872
16030
|
// src/rules/stepdown.ts
|
|
15873
|
-
import { AST_NODE_TYPES as
|
|
16031
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES64, ASTUtils as ASTUtils22 } from "@typescript-eslint/utils";
|
|
15874
16032
|
var STEPDOWN_DOCUMENTATION = {
|
|
15875
16033
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
15876
16034
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -15890,7 +16048,7 @@ var STEPDOWN_DOCUMENTATION = {
|
|
|
15890
16048
|
]
|
|
15891
16049
|
};
|
|
15892
16050
|
function isFunction(node) {
|
|
15893
|
-
return node.type ===
|
|
16051
|
+
return node.type === AST_NODE_TYPES64.ArrowFunctionExpression || node.type === AST_NODE_TYPES64.FunctionDeclaration || node.type === AST_NODE_TYPES64.FunctionExpression;
|
|
15894
16052
|
}
|
|
15895
16053
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true, makeFix) {
|
|
15896
16054
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -15987,8 +16145,8 @@ function moduleScope(context, program) {
|
|
|
15987
16145
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
15988
16146
|
const overloadNames = new Set(
|
|
15989
16147
|
program.body.flatMap((statement) => {
|
|
15990
|
-
const node = statement.type ===
|
|
15991
|
-
return node?.type ===
|
|
16148
|
+
const node = statement.type === AST_NODE_TYPES64.ExportNamedDeclaration ? statement.declaration : statement;
|
|
16149
|
+
return node?.type === AST_NODE_TYPES64.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
15992
16150
|
})
|
|
15993
16151
|
);
|
|
15994
16152
|
const exported = exportedNames(program);
|
|
@@ -16012,7 +16170,7 @@ function moduleScope(context, program) {
|
|
|
16012
16170
|
const nearestFunction2 = [...ancestors].reverse().find(isFunction);
|
|
16013
16171
|
const parent = identifier.parent;
|
|
16014
16172
|
const callerDefinition = nearestFunction2 === void 0 ? void 0 : byFunction.get(nearestFunction2);
|
|
16015
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
16173
|
+
if (callerDefinition === void 0 || parent.type !== AST_NODE_TYPES64.CallExpression || parent.callee !== identifier) {
|
|
16016
16174
|
pinned.add(definition.name);
|
|
16017
16175
|
continue;
|
|
16018
16176
|
}
|
|
@@ -16027,38 +16185,38 @@ function moduleScope(context, program) {
|
|
|
16027
16185
|
function exportedNames(program) {
|
|
16028
16186
|
const names = /* @__PURE__ */ new Set();
|
|
16029
16187
|
for (const statement of program.body) {
|
|
16030
|
-
if (statement.type !==
|
|
16031
|
-
if (statement.declaration?.type ===
|
|
16188
|
+
if (statement.type !== AST_NODE_TYPES64.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
16189
|
+
if (statement.declaration?.type === AST_NODE_TYPES64.FunctionDeclaration && statement.declaration.id !== null) {
|
|
16032
16190
|
names.add(statement.declaration.id.name);
|
|
16033
16191
|
}
|
|
16034
|
-
if (statement.declaration?.type ===
|
|
16192
|
+
if (statement.declaration?.type === AST_NODE_TYPES64.VariableDeclaration) {
|
|
16035
16193
|
for (const declarator of statement.declaration.declarations) {
|
|
16036
|
-
if (declarator.id.type ===
|
|
16194
|
+
if (declarator.id.type === AST_NODE_TYPES64.Identifier) names.add(declarator.id.name);
|
|
16037
16195
|
}
|
|
16038
16196
|
}
|
|
16039
16197
|
for (const specifier of statement.specifiers) {
|
|
16040
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
16198
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES64.Identifier) {
|
|
16041
16199
|
names.add(specifier.local.name);
|
|
16042
16200
|
}
|
|
16043
16201
|
}
|
|
16044
16202
|
}
|
|
16045
16203
|
for (const statement of program.body) {
|
|
16046
|
-
if (statement.type ===
|
|
16047
|
-
if (statement.type ===
|
|
16204
|
+
if (statement.type === AST_NODE_TYPES64.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES64.Identifier) names.add(statement.declaration.name);
|
|
16205
|
+
if (statement.type === AST_NODE_TYPES64.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES64.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
16048
16206
|
}
|
|
16049
16207
|
return names;
|
|
16050
16208
|
}
|
|
16051
16209
|
function moduleDefinitions(program) {
|
|
16052
16210
|
const definitions = [];
|
|
16053
16211
|
for (const statement of program.body) {
|
|
16054
|
-
const node = statement.type ===
|
|
16055
|
-
if (node?.type ===
|
|
16212
|
+
const node = statement.type === AST_NODE_TYPES64.ExportNamedDeclaration || statement.type === AST_NODE_TYPES64.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
16213
|
+
if (node?.type === AST_NODE_TYPES64.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
16056
16214
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
16057
16215
|
continue;
|
|
16058
16216
|
}
|
|
16059
|
-
if (node?.type !==
|
|
16217
|
+
if (node?.type !== AST_NODE_TYPES64.VariableDeclaration || node.kind !== "const") continue;
|
|
16060
16218
|
for (const declarator of node.declarations) {
|
|
16061
|
-
if (declarator.id.type ===
|
|
16219
|
+
if (declarator.id.type === AST_NODE_TYPES64.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
16062
16220
|
definitions.push({
|
|
16063
16221
|
name: declarator.id.name,
|
|
16064
16222
|
node: declarator,
|
|
@@ -16071,21 +16229,21 @@ function moduleDefinitions(program) {
|
|
|
16071
16229
|
return definitions;
|
|
16072
16230
|
}
|
|
16073
16231
|
function methodName(node) {
|
|
16074
|
-
if (node.key.type ===
|
|
16075
|
-
return !node.computed && node.key.type ===
|
|
16232
|
+
if (node.key.type === AST_NODE_TYPES64.PrivateIdentifier) return `#${node.key.name}`;
|
|
16233
|
+
return !node.computed && node.key.type === AST_NODE_TYPES64.Identifier ? node.key.name : null;
|
|
16076
16234
|
}
|
|
16077
16235
|
function referencedMethod(context, node, classVariables) {
|
|
16078
|
-
const objectVariable = node.object.type ===
|
|
16236
|
+
const objectVariable = node.object.type === AST_NODE_TYPES64.Identifier ? ASTUtils22.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
16079
16237
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
16080
|
-
if (node.object.type !==
|
|
16081
|
-
if (node.property.type ===
|
|
16082
|
-
if (!node.computed && node.property.type ===
|
|
16083
|
-
return node.computed && node.property.type ===
|
|
16238
|
+
if (node.object.type !== AST_NODE_TYPES64.ThisExpression && !isClassReference) return null;
|
|
16239
|
+
if (node.property.type === AST_NODE_TYPES64.PrivateIdentifier) return `#${node.property.name}`;
|
|
16240
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES64.Identifier) return node.property.name;
|
|
16241
|
+
return node.computed && node.property.type === AST_NODE_TYPES64.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
16084
16242
|
}
|
|
16085
16243
|
function referencedPropertyName(node) {
|
|
16086
|
-
if (node.property.type ===
|
|
16087
|
-
if (!node.computed && node.property.type ===
|
|
16088
|
-
return node.computed && node.property.type ===
|
|
16244
|
+
if (node.property.type === AST_NODE_TYPES64.PrivateIdentifier) return `#${node.property.name}`;
|
|
16245
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES64.Identifier) return node.property.name;
|
|
16246
|
+
return node.computed && node.property.type === AST_NODE_TYPES64.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
16089
16247
|
}
|
|
16090
16248
|
function walk2(node, visitorKeys, visit, nestedFunction = false) {
|
|
16091
16249
|
visit(node, nestedFunction);
|
|
@@ -16101,7 +16259,7 @@ function walk2(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
16101
16259
|
}
|
|
16102
16260
|
function classScope(context, node, computedReferenceNames) {
|
|
16103
16261
|
const methods = node.body.body.filter(
|
|
16104
|
-
(member) => member.type ===
|
|
16262
|
+
(member) => member.type === AST_NODE_TYPES64.MethodDefinition
|
|
16105
16263
|
);
|
|
16106
16264
|
const counts = /* @__PURE__ */ new Map();
|
|
16107
16265
|
for (const method of methods) {
|
|
@@ -16109,8 +16267,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16109
16267
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
16110
16268
|
}
|
|
16111
16269
|
for (const member of node.body.body) {
|
|
16112
|
-
if (member.type !==
|
|
16113
|
-
const name = !member.computed && member.key.type ===
|
|
16270
|
+
if (member.type !== AST_NODE_TYPES64.TSAbstractMethodDefinition) continue;
|
|
16271
|
+
const name = !member.computed && member.key.type === AST_NODE_TYPES64.Identifier ? member.key.name : null;
|
|
16114
16272
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
16115
16273
|
}
|
|
16116
16274
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -16119,7 +16277,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16119
16277
|
});
|
|
16120
16278
|
const definitions = methods.flatMap((method) => {
|
|
16121
16279
|
const name = methodName(method);
|
|
16122
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
16280
|
+
const isPrivate = method.accessibility === "private" || method.key.type === AST_NODE_TYPES64.PrivateIdentifier;
|
|
16123
16281
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
16124
16282
|
});
|
|
16125
16283
|
if (definitions.length === 0) return;
|
|
@@ -16128,11 +16286,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16128
16286
|
const pinned = /* @__PURE__ */ new Set();
|
|
16129
16287
|
const classVariables = /* @__PURE__ */ new Set();
|
|
16130
16288
|
if (node.id !== null) {
|
|
16131
|
-
const internal =
|
|
16289
|
+
const internal = ASTUtils22.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
16132
16290
|
if (internal !== null) classVariables.add(internal);
|
|
16133
16291
|
}
|
|
16134
|
-
if (node.type ===
|
|
16135
|
-
const outer =
|
|
16292
|
+
if (node.type === AST_NODE_TYPES64.ClassExpression && node.parent.type === AST_NODE_TYPES64.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES64.Identifier) {
|
|
16293
|
+
const outer = ASTUtils22.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
16136
16294
|
if (outer !== null) classVariables.add(outer);
|
|
16137
16295
|
}
|
|
16138
16296
|
for (const method of methods) {
|
|
@@ -16148,27 +16306,27 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16148
16306
|
}
|
|
16149
16307
|
const thisValue = (value) => {
|
|
16150
16308
|
let current = value;
|
|
16151
|
-
while (current?.type ===
|
|
16152
|
-
return current?.type ===
|
|
16309
|
+
while (current?.type === AST_NODE_TYPES64.TSAsExpression || current?.type === AST_NODE_TYPES64.TSSatisfiesExpression || current?.type === AST_NODE_TYPES64.TSNonNullExpression) current = current.expression;
|
|
16310
|
+
return current?.type === AST_NODE_TYPES64.ThisExpression;
|
|
16153
16311
|
};
|
|
16154
16312
|
const collectAlias = (current, nestedFunction) => {
|
|
16155
|
-
if (nestedFunction || current.type !==
|
|
16156
|
-
if (current.type ===
|
|
16157
|
-
const binding = current.type ===
|
|
16158
|
-
const value = current.type ===
|
|
16313
|
+
if (nestedFunction || current.type !== AST_NODE_TYPES64.VariableDeclarator && current.type !== AST_NODE_TYPES64.AssignmentPattern) return;
|
|
16314
|
+
if (current.type === AST_NODE_TYPES64.VariableDeclarator && (current.parent.type !== AST_NODE_TYPES64.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
16315
|
+
const binding = current.type === AST_NODE_TYPES64.VariableDeclarator ? current.id : current.left;
|
|
16316
|
+
const value = current.type === AST_NODE_TYPES64.VariableDeclarator ? current.init : current.right;
|
|
16159
16317
|
if (!thisValue(value)) return;
|
|
16160
|
-
if (binding.type ===
|
|
16318
|
+
if (binding.type === AST_NODE_TYPES64.ObjectPattern) {
|
|
16161
16319
|
for (const property of binding.properties) {
|
|
16162
|
-
if (property.type ===
|
|
16320
|
+
if (property.type === AST_NODE_TYPES64.RestElement) {
|
|
16163
16321
|
for (const name of privateNames) pinned.add(name);
|
|
16164
|
-
} else if (property.key.type ===
|
|
16322
|
+
} else if (property.key.type === AST_NODE_TYPES64.Identifier && privateNames.has(property.key.name)) {
|
|
16165
16323
|
pinned.add(property.key.name);
|
|
16166
16324
|
}
|
|
16167
16325
|
}
|
|
16168
16326
|
return;
|
|
16169
16327
|
}
|
|
16170
|
-
if (binding.type !==
|
|
16171
|
-
const variable =
|
|
16328
|
+
if (binding.type !== AST_NODE_TYPES64.Identifier) return;
|
|
16329
|
+
const variable = ASTUtils22.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
16172
16330
|
if (variable !== null) {
|
|
16173
16331
|
methodClassVariables.add(variable);
|
|
16174
16332
|
methodAliases.add(variable);
|
|
@@ -16181,16 +16339,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16181
16339
|
walk2(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
16182
16340
|
}
|
|
16183
16341
|
const visitCall = (current, nestedFunction) => {
|
|
16184
|
-
if (current.type ===
|
|
16342
|
+
if (current.type === AST_NODE_TYPES64.VariableDeclarator && current.id.type === AST_NODE_TYPES64.ObjectPattern && thisValue(current.init)) {
|
|
16185
16343
|
for (const property of current.id.properties) {
|
|
16186
|
-
if (property.type ===
|
|
16344
|
+
if (property.type === AST_NODE_TYPES64.RestElement) {
|
|
16187
16345
|
for (const name of privateNames) pinned.add(name);
|
|
16188
16346
|
continue;
|
|
16189
16347
|
}
|
|
16190
|
-
if (property.type ===
|
|
16348
|
+
if (property.type === AST_NODE_TYPES64.Property && property.key.type === AST_NODE_TYPES64.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
16191
16349
|
}
|
|
16192
16350
|
}
|
|
16193
|
-
if (current.type !==
|
|
16351
|
+
if (current.type !== AST_NODE_TYPES64.MemberExpression) return;
|
|
16194
16352
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
16195
16353
|
if (target === null) {
|
|
16196
16354
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -16198,12 +16356,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16198
16356
|
return;
|
|
16199
16357
|
}
|
|
16200
16358
|
if (!privateNames.has(target)) return;
|
|
16201
|
-
const objectVariable = current.object.type ===
|
|
16359
|
+
const objectVariable = current.object.type === AST_NODE_TYPES64.Identifier ? ASTUtils22.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
16202
16360
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
16203
16361
|
pinned.add(target);
|
|
16204
16362
|
return;
|
|
16205
16363
|
}
|
|
16206
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
16364
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== AST_NODE_TYPES64.CallExpression || current.parent.callee !== current) {
|
|
16207
16365
|
pinned.add(target);
|
|
16208
16366
|
return;
|
|
16209
16367
|
}
|
|
@@ -16223,9 +16381,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16223
16381
|
}
|
|
16224
16382
|
}
|
|
16225
16383
|
for (const member of node.body.body) {
|
|
16226
|
-
if (member.type ===
|
|
16384
|
+
if (member.type === AST_NODE_TYPES64.MethodDefinition || member.type === AST_NODE_TYPES64.TSAbstractMethodDefinition) continue;
|
|
16227
16385
|
walk2(member, context.sourceCode.visitorKeys, (current) => {
|
|
16228
|
-
if (current.type !==
|
|
16386
|
+
if (current.type !== AST_NODE_TYPES64.MemberExpression) return;
|
|
16229
16387
|
const target = referencedMethod(context, current, classVariables);
|
|
16230
16388
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
16231
16389
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -16277,12 +16435,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
16277
16435
|
}
|
|
16278
16436
|
function isClassRuntimeBarrier(member) {
|
|
16279
16437
|
switch (member.type) {
|
|
16280
|
-
case
|
|
16438
|
+
case AST_NODE_TYPES64.StaticBlock:
|
|
16281
16439
|
return true;
|
|
16282
|
-
case
|
|
16283
|
-
case
|
|
16440
|
+
case AST_NODE_TYPES64.PropertyDefinition:
|
|
16441
|
+
case AST_NODE_TYPES64.AccessorProperty:
|
|
16284
16442
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
16285
|
-
case
|
|
16443
|
+
case AST_NODE_TYPES64.MethodDefinition:
|
|
16286
16444
|
return member.computed || member.decorators.length > 0;
|
|
16287
16445
|
default:
|
|
16288
16446
|
return false;
|
|
@@ -16315,7 +16473,7 @@ var stepdown_default = createRule({
|
|
|
16315
16473
|
moduleScope(context, program);
|
|
16316
16474
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
16317
16475
|
walk2(program, context.sourceCode.visitorKeys, (node) => {
|
|
16318
|
-
if (node.type ===
|
|
16476
|
+
if (node.type === AST_NODE_TYPES64.MemberExpression && node.computed && node.property.type === AST_NODE_TYPES64.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
16319
16477
|
});
|
|
16320
16478
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
16321
16479
|
}
|
|
@@ -16324,7 +16482,7 @@ var stepdown_default = createRule({
|
|
|
16324
16482
|
});
|
|
16325
16483
|
|
|
16326
16484
|
// src/rules/source-coupled-test.ts
|
|
16327
|
-
import { AST_NODE_TYPES as
|
|
16485
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES65 } from "@typescript-eslint/utils";
|
|
16328
16486
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|py|[cm]?[jt]s)$/iu;
|
|
16329
16487
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
16330
16488
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -16393,20 +16551,20 @@ var SOURCE_COUPLED_TEST_DOCUMENTATION = {
|
|
|
16393
16551
|
]
|
|
16394
16552
|
};
|
|
16395
16553
|
function staticMemberName7(node) {
|
|
16396
|
-
if (!node.computed && node.property.type ===
|
|
16397
|
-
if (node.computed && node.property.type ===
|
|
16554
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES65.Identifier) return node.property.name;
|
|
16555
|
+
if (node.computed && node.property.type === AST_NODE_TYPES65.Literal && typeof node.property.value === "string") return node.property.value;
|
|
16398
16556
|
return null;
|
|
16399
16557
|
}
|
|
16400
16558
|
function unwrap5(node) {
|
|
16401
|
-
if (node.type ===
|
|
16402
|
-
if (node.type ===
|
|
16403
|
-
if (node.type ===
|
|
16559
|
+
if (node.type === AST_NODE_TYPES65.AwaitExpression) return unwrap5(node.argument);
|
|
16560
|
+
if (node.type === AST_NODE_TYPES65.ChainExpression) return unwrap5(node.expression);
|
|
16561
|
+
if (node.type === AST_NODE_TYPES65.TSAsExpression || node.type === AST_NODE_TYPES65.TSNonNullExpression || node.type === AST_NODE_TYPES65.TSTypeAssertion) return unwrap5(node.expression);
|
|
16404
16562
|
return node;
|
|
16405
16563
|
}
|
|
16406
16564
|
function stringValue(node) {
|
|
16407
16565
|
const current = unwrap5(node);
|
|
16408
|
-
if (current.type ===
|
|
16409
|
-
if (current.type ===
|
|
16566
|
+
if (current.type === AST_NODE_TYPES65.Literal && typeof current.value === "string") return current.value;
|
|
16567
|
+
if (current.type === AST_NODE_TYPES65.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
16410
16568
|
return null;
|
|
16411
16569
|
}
|
|
16412
16570
|
function importSource(node) {
|
|
@@ -16414,7 +16572,7 @@ function importSource(node) {
|
|
|
16414
16572
|
}
|
|
16415
16573
|
function requireSource(node) {
|
|
16416
16574
|
const current = unwrap5(node);
|
|
16417
|
-
if (current.type !==
|
|
16575
|
+
if (current.type !== AST_NODE_TYPES65.CallExpression || current.callee.type !== AST_NODE_TYPES65.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === AST_NODE_TYPES65.SpreadElement) return null;
|
|
16418
16576
|
return stringValue(current.arguments[0]);
|
|
16419
16577
|
}
|
|
16420
16578
|
function newScope() {
|
|
@@ -16454,38 +16612,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16454
16612
|
const current = unwrap5(node);
|
|
16455
16613
|
const value = stringValue(current);
|
|
16456
16614
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
16457
|
-
if (current.type ===
|
|
16458
|
-
if (current.type ===
|
|
16615
|
+
if (current.type === AST_NODE_TYPES65.Identifier) return visible("paths", current.name);
|
|
16616
|
+
if (current.type === AST_NODE_TYPES65.BinaryExpression && current.operator === "+") {
|
|
16459
16617
|
return sourcePath(current.left) || sourcePath(current.right);
|
|
16460
16618
|
}
|
|
16461
|
-
if (current.type ===
|
|
16462
|
-
if (current.type ===
|
|
16463
|
-
return current.arguments.some((argument) => argument.type !==
|
|
16619
|
+
if (current.type === AST_NODE_TYPES65.TemplateLiteral) return current.expressions.some(sourcePath);
|
|
16620
|
+
if (current.type === AST_NODE_TYPES65.CallExpression || current.type === AST_NODE_TYPES65.NewExpression) {
|
|
16621
|
+
return current.arguments.some((argument) => argument.type !== AST_NODE_TYPES65.SpreadElement && sourcePath(argument));
|
|
16464
16622
|
}
|
|
16465
|
-
if (current.type ===
|
|
16623
|
+
if (current.type === AST_NODE_TYPES65.MemberExpression) return sourcePath(current.object);
|
|
16466
16624
|
return false;
|
|
16467
16625
|
};
|
|
16468
16626
|
const rawRead = (node) => {
|
|
16469
16627
|
const current = unwrap5(node);
|
|
16470
|
-
if (current.type !==
|
|
16628
|
+
if (current.type !== AST_NODE_TYPES65.CallExpression || current.arguments.length === 0) return false;
|
|
16471
16629
|
const callee = unwrap5(current.callee);
|
|
16472
|
-
if (callee.type ===
|
|
16630
|
+
if (callee.type === AST_NODE_TYPES65.Identifier) {
|
|
16473
16631
|
return visible("fsReaders", callee.name) && sourcePath(current.arguments[0]);
|
|
16474
16632
|
}
|
|
16475
|
-
if (callee.type !==
|
|
16633
|
+
if (callee.type !== AST_NODE_TYPES65.MemberExpression) return false;
|
|
16476
16634
|
const name2 = staticMemberName7(callee);
|
|
16477
16635
|
const object = unwrap5(callee.object);
|
|
16478
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
16636
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === AST_NODE_TYPES65.Identifier && visible("fsObjects", object.name) && sourcePath(current.arguments[0]);
|
|
16479
16637
|
};
|
|
16480
16638
|
const rawOrigins = (node) => {
|
|
16481
16639
|
const current = unwrap5(node);
|
|
16482
|
-
if (current.type ===
|
|
16640
|
+
if (current.type === AST_NODE_TYPES65.Identifier) return visibleRawOrigins(current.name);
|
|
16483
16641
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
16484
|
-
if (current.type ===
|
|
16485
|
-
if (current.type ===
|
|
16486
|
-
if (current.type !==
|
|
16642
|
+
if (current.type === AST_NODE_TYPES65.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
16643
|
+
if (current.type === AST_NODE_TYPES65.MemberExpression && staticMemberName7(current) === "length") return rawOrigins(current.object);
|
|
16644
|
+
if (current.type !== AST_NODE_TYPES65.CallExpression) return /* @__PURE__ */ new Set();
|
|
16487
16645
|
const callee = unwrap5(current.callee);
|
|
16488
|
-
if (callee.type !==
|
|
16646
|
+
if (callee.type !== AST_NODE_TYPES65.MemberExpression) return /* @__PURE__ */ new Set();
|
|
16489
16647
|
const name2 = staticMemberName7(callee);
|
|
16490
16648
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(callee.object) : /* @__PURE__ */ new Set();
|
|
16491
16649
|
};
|
|
@@ -16493,38 +16651,38 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16493
16651
|
const current = unwrap5(node);
|
|
16494
16652
|
const direct = rawOrigins(current);
|
|
16495
16653
|
if (direct.size > 0) return direct;
|
|
16496
|
-
if (current.type ===
|
|
16497
|
-
if (current.type ===
|
|
16498
|
-
if (current.type !==
|
|
16654
|
+
if (current.type === AST_NODE_TYPES65.BinaryExpression || current.type === AST_NODE_TYPES65.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
16655
|
+
if (current.type === AST_NODE_TYPES65.UnaryExpression) return evidenceOrigins(current.argument);
|
|
16656
|
+
if (current.type !== AST_NODE_TYPES65.CallExpression) return /* @__PURE__ */ new Set();
|
|
16499
16657
|
const callee = unwrap5(current.callee);
|
|
16500
|
-
if (callee.type !==
|
|
16658
|
+
if (callee.type !== AST_NODE_TYPES65.MemberExpression) return /* @__PURE__ */ new Set();
|
|
16501
16659
|
const name2 = staticMemberName7(callee);
|
|
16502
16660
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(callee.object);
|
|
16503
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
16661
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES65.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
16504
16662
|
return /* @__PURE__ */ new Set();
|
|
16505
16663
|
};
|
|
16506
16664
|
const rawAssertionOrigins = (node) => {
|
|
16507
16665
|
const callee = unwrap5(node.callee);
|
|
16508
|
-
if (callee.type ===
|
|
16509
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
16666
|
+
if (callee.type === AST_NODE_TYPES65.Identifier && callee.name === "assert") {
|
|
16667
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES65.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
16510
16668
|
}
|
|
16511
|
-
if (callee.type !==
|
|
16669
|
+
if (callee.type !== AST_NODE_TYPES65.MemberExpression) return /* @__PURE__ */ new Set();
|
|
16512
16670
|
const matcher = staticMemberName7(callee);
|
|
16513
16671
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
16514
16672
|
let receiver = unwrap5(callee.object);
|
|
16515
|
-
while (receiver.type ===
|
|
16516
|
-
if (receiver.type ===
|
|
16673
|
+
while (receiver.type === AST_NODE_TYPES65.MemberExpression && EXPECT_MODIFIERS2.has(staticMemberName7(receiver) ?? "")) receiver = unwrap5(receiver.object);
|
|
16674
|
+
if (receiver.type === AST_NODE_TYPES65.CallExpression && receiver.callee.type === AST_NODE_TYPES65.Identifier && receiver.callee.name === "expect") {
|
|
16517
16675
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
16518
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
16676
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === AST_NODE_TYPES65.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
16519
16677
|
}
|
|
16520
|
-
if (receiver.type !==
|
|
16521
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
16678
|
+
if (receiver.type !== AST_NODE_TYPES65.Identifier || receiver.name !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
16679
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES65.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
16522
16680
|
};
|
|
16523
16681
|
const rawRegexExtractionOrigins = (node) => {
|
|
16524
16682
|
const callee = unwrap5(node.callee);
|
|
16525
|
-
if (callee.type !==
|
|
16683
|
+
if (callee.type !== AST_NODE_TYPES65.MemberExpression || staticMemberName7(callee) !== "matchAll" || node.arguments.length !== 1) return /* @__PURE__ */ new Set();
|
|
16526
16684
|
const argument = node.arguments[0];
|
|
16527
|
-
if (argument?.type !==
|
|
16685
|
+
if (argument?.type !== AST_NODE_TYPES65.Literal || !(argument.value instanceof RegExp)) return /* @__PURE__ */ new Set();
|
|
16528
16686
|
return rawOrigins(callee.object);
|
|
16529
16687
|
};
|
|
16530
16688
|
const declare = (name2, state) => {
|
|
@@ -16545,15 +16703,15 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16545
16703
|
};
|
|
16546
16704
|
const sourceCollection = (node) => {
|
|
16547
16705
|
const current = unwrap5(node);
|
|
16548
|
-
return current.type ===
|
|
16706
|
+
return current.type === AST_NODE_TYPES65.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== AST_NODE_TYPES65.SpreadElement && sourcePath(element));
|
|
16549
16707
|
};
|
|
16550
16708
|
const declaredNames2 = (node) => {
|
|
16551
16709
|
const current = unwrap5(node);
|
|
16552
|
-
if (current.type ===
|
|
16553
|
-
if (current.type ===
|
|
16554
|
-
if (current.type ===
|
|
16555
|
-
if (current.type ===
|
|
16556
|
-
if (current.type ===
|
|
16710
|
+
if (current.type === AST_NODE_TYPES65.Identifier) return [current.name];
|
|
16711
|
+
if (current.type === AST_NODE_TYPES65.AssignmentPattern) return declaredNames2(current.left);
|
|
16712
|
+
if (current.type === AST_NODE_TYPES65.RestElement) return declaredNames2(current.argument);
|
|
16713
|
+
if (current.type === AST_NODE_TYPES65.ArrayPattern) return current.elements.flatMap((element) => element === null ? [] : declaredNames2(element));
|
|
16714
|
+
if (current.type === AST_NODE_TYPES65.ObjectPattern) return current.properties.flatMap((property) => property.type === AST_NODE_TYPES65.RestElement ? declaredNames2(property.argument) : declaredNames2(property.value));
|
|
16557
16715
|
return [];
|
|
16558
16716
|
};
|
|
16559
16717
|
const enterFunction = (node) => {
|
|
@@ -16568,8 +16726,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16568
16726
|
const source = importSource(node);
|
|
16569
16727
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
16570
16728
|
for (const specifier of node.specifiers) {
|
|
16571
|
-
if (specifier.type ===
|
|
16572
|
-
const imported = specifier.imported.type ===
|
|
16729
|
+
if (specifier.type === AST_NODE_TYPES65.ImportSpecifier) {
|
|
16730
|
+
const imported = specifier.imported.type === AST_NODE_TYPES65.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
16573
16731
|
if (FS_READERS.has(imported)) declare(specifier.local.name, { fsReader: true });
|
|
16574
16732
|
} else {
|
|
16575
16733
|
declare(specifier.local.name, { fsObject: true });
|
|
@@ -16581,29 +16739,29 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
16581
16739
|
VariableDeclarator(node) {
|
|
16582
16740
|
if (node.init === null) return;
|
|
16583
16741
|
const required = requireSource(node.init);
|
|
16584
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
16742
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === AST_NODE_TYPES65.Identifier) {
|
|
16585
16743
|
declare(node.id.name, { fsObject: true });
|
|
16586
16744
|
return;
|
|
16587
16745
|
}
|
|
16588
|
-
if (node.id.type ===
|
|
16746
|
+
if (node.id.type === AST_NODE_TYPES65.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
16589
16747
|
for (const property of node.id.properties) {
|
|
16590
|
-
if (property.type !==
|
|
16591
|
-
const key = property.key.type ===
|
|
16748
|
+
if (property.type !== AST_NODE_TYPES65.Property || property.value.type !== AST_NODE_TYPES65.Identifier) continue;
|
|
16749
|
+
const key = property.key.type === AST_NODE_TYPES65.Identifier ? property.key.name : property.key.type === AST_NODE_TYPES65.Literal ? String(property.key.value) : "";
|
|
16592
16750
|
if (FS_READERS.has(key)) declare(property.value.name, { fsReader: true });
|
|
16593
16751
|
}
|
|
16594
16752
|
return;
|
|
16595
16753
|
}
|
|
16596
|
-
if (node.id.type !==
|
|
16754
|
+
if (node.id.type !== AST_NODE_TYPES65.Identifier) return;
|
|
16597
16755
|
declare(node.id.name, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
16598
16756
|
},
|
|
16599
16757
|
AssignmentExpression(node) {
|
|
16600
|
-
if (node.left.type ===
|
|
16758
|
+
if (node.left.type === AST_NODE_TYPES65.Identifier) declare(node.left.name, { path: sourcePath(node.right), rawOrigins: rawOrigins(node.right) });
|
|
16601
16759
|
},
|
|
16602
16760
|
ForOfStatement(node) {
|
|
16603
16761
|
const right = unwrap5(node.right);
|
|
16604
|
-
const collection = right.type ===
|
|
16605
|
-
const left = node.left.type ===
|
|
16606
|
-
if (collection && left?.type ===
|
|
16762
|
+
const collection = right.type === AST_NODE_TYPES65.Identifier && visible("collections", right.name);
|
|
16763
|
+
const left = node.left.type === AST_NODE_TYPES65.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
16764
|
+
if (collection && left?.type === AST_NODE_TYPES65.Identifier) declare(left.name, { path: true });
|
|
16607
16765
|
},
|
|
16608
16766
|
CallExpression(node) {
|
|
16609
16767
|
const origins = /* @__PURE__ */ new Set([
|
|
@@ -16662,27 +16820,29 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
16662
16820
|
IAC_SOURCE_SUFFIX_RE
|
|
16663
16821
|
);
|
|
16664
16822
|
|
|
16665
|
-
// src/rules/zod-
|
|
16823
|
+
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
16666
16824
|
import {
|
|
16667
|
-
AST_NODE_TYPES as
|
|
16668
|
-
ASTUtils as
|
|
16825
|
+
AST_NODE_TYPES as AST_NODE_TYPES66,
|
|
16826
|
+
ASTUtils as ASTUtils23
|
|
16669
16827
|
} from "@typescript-eslint/utils";
|
|
16670
|
-
var
|
|
16671
|
-
summary: "
|
|
16672
|
-
rationale: "A
|
|
16673
|
-
remediation: "Rename the
|
|
16828
|
+
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
16829
|
+
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
16830
|
+
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.",
|
|
16831
|
+
remediation: "Rename the binding to PascalCase ending in `Schema` (for example, `MutationRouteBaseSchema`).",
|
|
16674
16832
|
category: "style",
|
|
16833
|
+
aliases: ["zod-naming-convention"],
|
|
16834
|
+
autofix: "none",
|
|
16835
|
+
limitations: [
|
|
16836
|
+
"Only module-level bindings proven from a Zod import or a same-file proven schema are checked.",
|
|
16837
|
+
"Tests, benchmarks, generated files, imported schemas, re-export aliases, and arbitrary wrapper-factory results are excluded.",
|
|
16838
|
+
"Cross-file and exported renames are not safely file-local, so the rule has no autofix."
|
|
16839
|
+
],
|
|
16675
16840
|
examples: [
|
|
16676
|
-
{ id: "
|
|
16677
|
-
{ id: "
|
|
16841
|
+
{ 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 },
|
|
16842
|
+
{ 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 }
|
|
16678
16843
|
]
|
|
16679
16844
|
};
|
|
16680
|
-
var
|
|
16681
|
-
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
16682
|
-
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
16683
|
-
either: { test: ZOD_SCHEMA_NAME_RE, messageId: "zodSchemaName" }
|
|
16684
|
-
};
|
|
16685
|
-
var CONTAINS_SCHEMA_RE = /schema/i;
|
|
16845
|
+
var PASCAL_SCHEMA_NAME_RE = /^[A-Z][A-Za-z0-9]*Schema$/;
|
|
16686
16846
|
var BENCHMARK_PATH_RE = /(^|[\\/])(?:benchmarks?|bench)[\\/]/;
|
|
16687
16847
|
var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
16688
16848
|
"parse",
|
|
@@ -16707,58 +16867,164 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
16707
16867
|
"prettifyError",
|
|
16708
16868
|
"treeifyError"
|
|
16709
16869
|
]);
|
|
16710
|
-
var
|
|
16870
|
+
var ZOD_SCHEMA_FACTORIES = /* @__PURE__ */ new Set([
|
|
16871
|
+
"any",
|
|
16872
|
+
"array",
|
|
16873
|
+
"base64",
|
|
16874
|
+
"base64url",
|
|
16875
|
+
"bigint",
|
|
16876
|
+
"boolean",
|
|
16877
|
+
"cidrv4",
|
|
16878
|
+
"cidrv6",
|
|
16879
|
+
"codec",
|
|
16880
|
+
"custom",
|
|
16881
|
+
"date",
|
|
16882
|
+
"discriminatedUnion",
|
|
16883
|
+
"email",
|
|
16884
|
+
"emoji",
|
|
16885
|
+
"enum",
|
|
16886
|
+
"file",
|
|
16887
|
+
"function",
|
|
16888
|
+
"hash",
|
|
16889
|
+
"hex",
|
|
16890
|
+
"hostname",
|
|
16891
|
+
"instanceof",
|
|
16892
|
+
"intersection",
|
|
16893
|
+
"ipv4",
|
|
16894
|
+
"ipv6",
|
|
16895
|
+
"json",
|
|
16896
|
+
"jwt",
|
|
16897
|
+
"lazy",
|
|
16898
|
+
"literal",
|
|
16899
|
+
"looseObject",
|
|
16900
|
+
"map",
|
|
16901
|
+
"nan",
|
|
16902
|
+
"nativeEnum",
|
|
16903
|
+
"never",
|
|
16904
|
+
"null",
|
|
16905
|
+
"nullable",
|
|
16906
|
+
"nullish",
|
|
16907
|
+
"number",
|
|
16908
|
+
"object",
|
|
16909
|
+
"optional",
|
|
16910
|
+
"partialRecord",
|
|
16911
|
+
"preprocess",
|
|
16912
|
+
"promise",
|
|
16913
|
+
"record",
|
|
16914
|
+
"set",
|
|
16915
|
+
"strictObject",
|
|
16916
|
+
"string",
|
|
16917
|
+
"stringbool",
|
|
16918
|
+
"symbol",
|
|
16919
|
+
"templateLiteral",
|
|
16920
|
+
"tuple",
|
|
16921
|
+
"undefined",
|
|
16922
|
+
"union",
|
|
16923
|
+
"unknown",
|
|
16924
|
+
"url",
|
|
16925
|
+
"uuid",
|
|
16926
|
+
"void"
|
|
16927
|
+
]);
|
|
16928
|
+
var ZOD_FACTORY_NAMESPACES = /* @__PURE__ */ new Set(["coerce", "iso"]);
|
|
16929
|
+
var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
16930
|
+
"and",
|
|
16931
|
+
"array",
|
|
16932
|
+
"brand",
|
|
16933
|
+
"catch",
|
|
16934
|
+
"check",
|
|
16935
|
+
"clone",
|
|
16936
|
+
"default",
|
|
16937
|
+
"describe",
|
|
16938
|
+
"extend",
|
|
16939
|
+
"keyof",
|
|
16940
|
+
"meta",
|
|
16941
|
+
"nullable",
|
|
16942
|
+
"nullish",
|
|
16943
|
+
"omit",
|
|
16944
|
+
"optional",
|
|
16945
|
+
"or",
|
|
16946
|
+
"overwrite",
|
|
16947
|
+
"partial",
|
|
16948
|
+
"pick",
|
|
16949
|
+
"pipe",
|
|
16950
|
+
"prefault",
|
|
16951
|
+
"readonly",
|
|
16952
|
+
"refine",
|
|
16953
|
+
"register",
|
|
16954
|
+
"required",
|
|
16955
|
+
"safeExtend",
|
|
16956
|
+
"superRefine",
|
|
16957
|
+
"transform"
|
|
16958
|
+
]);
|
|
16959
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES66.Identifier ? callee.property.name : null;
|
|
16711
16960
|
var calleeChainRoot = (node) => {
|
|
16712
16961
|
let current = node;
|
|
16713
16962
|
for (; ; ) {
|
|
16714
|
-
if (current.type ===
|
|
16963
|
+
if (current.type === AST_NODE_TYPES66.Identifier) {
|
|
16715
16964
|
return current;
|
|
16716
16965
|
}
|
|
16717
|
-
if (current.type ===
|
|
16966
|
+
if (current.type === AST_NODE_TYPES66.MemberExpression) {
|
|
16718
16967
|
current = current.object;
|
|
16719
16968
|
continue;
|
|
16720
16969
|
}
|
|
16721
|
-
if (current.type ===
|
|
16970
|
+
if (current.type === AST_NODE_TYPES66.CallExpression) {
|
|
16722
16971
|
current = current.callee;
|
|
16723
16972
|
continue;
|
|
16724
16973
|
}
|
|
16725
16974
|
return null;
|
|
16726
16975
|
}
|
|
16727
16976
|
};
|
|
16728
|
-
var
|
|
16729
|
-
|
|
16730
|
-
|
|
16977
|
+
var chainMemberNames = (node) => {
|
|
16978
|
+
const names = [];
|
|
16979
|
+
let current = node;
|
|
16980
|
+
for (; ; ) {
|
|
16981
|
+
if (current.type === AST_NODE_TYPES66.MemberExpression) {
|
|
16982
|
+
if (current.computed || current.property.type !== AST_NODE_TYPES66.Identifier) return [];
|
|
16983
|
+
names.push(current.property.name);
|
|
16984
|
+
current = current.object;
|
|
16985
|
+
continue;
|
|
16986
|
+
}
|
|
16987
|
+
if (current.type === AST_NODE_TYPES66.CallExpression) {
|
|
16988
|
+
current = current.callee;
|
|
16989
|
+
continue;
|
|
16990
|
+
}
|
|
16991
|
+
break;
|
|
16992
|
+
}
|
|
16993
|
+
names.reverse();
|
|
16994
|
+
return names;
|
|
16995
|
+
};
|
|
16996
|
+
var unwrapExpression4 = (node) => {
|
|
16997
|
+
let current = node;
|
|
16998
|
+
while (current.type === AST_NODE_TYPES66.TSAsExpression || current.type === AST_NODE_TYPES66.TSSatisfiesExpression || current.type === AST_NODE_TYPES66.TSNonNullExpression || current.type === AST_NODE_TYPES66.TSTypeAssertion) {
|
|
16999
|
+
current = current.expression;
|
|
17000
|
+
}
|
|
17001
|
+
return current;
|
|
17002
|
+
};
|
|
17003
|
+
var isModuleDeclarator = (node) => {
|
|
17004
|
+
const declaration = node.parent;
|
|
17005
|
+
if (declaration.type !== AST_NODE_TYPES66.VariableDeclaration) return false;
|
|
17006
|
+
const owner = declaration.parent;
|
|
17007
|
+
return owner.type === AST_NODE_TYPES66.Program || owner.type === AST_NODE_TYPES66.ExportNamedDeclaration && owner.parent.type === AST_NODE_TYPES66.Program;
|
|
17008
|
+
};
|
|
17009
|
+
var require_pascal_case_zod_schema_name_default = createRule({
|
|
17010
|
+
name: "require-pascal-case-zod-schema-name",
|
|
17011
|
+
documentation: REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION,
|
|
16731
17012
|
meta: {
|
|
16732
17013
|
type: "suggestion",
|
|
16733
17014
|
docs: {
|
|
16734
|
-
description: "
|
|
17015
|
+
description: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix."
|
|
16735
17016
|
},
|
|
16736
|
-
schema: [
|
|
16737
|
-
{
|
|
16738
|
-
type: "object",
|
|
16739
|
-
additionalProperties: false,
|
|
16740
|
-
properties: {
|
|
16741
|
-
convention: {
|
|
16742
|
-
type: "string",
|
|
16743
|
-
enum: ["prefix", "suffix", "either"]
|
|
16744
|
-
}
|
|
16745
|
-
}
|
|
16746
|
-
}
|
|
16747
|
-
],
|
|
17017
|
+
schema: [],
|
|
16748
17018
|
messages: {
|
|
16749
|
-
|
|
16750
|
-
schemaSuffix: "Zod schema names should end with Schema (e.g. `userSchema`)",
|
|
16751
|
-
zodSchemaName: "Zod schema names should start with Z (`ZUser`) or end with Schema (`userSchema`)"
|
|
17019
|
+
requirePascalSchema: "Zod schema contracts must use PascalCase ending in Schema (for example, `MutationRouteBaseSchema`); reserve SCREAMING_SNAKE_CASE for scalar/table constants."
|
|
16752
17020
|
}
|
|
16753
17021
|
},
|
|
16754
|
-
defaultOptions: [
|
|
16755
|
-
create(context
|
|
16756
|
-
const convention = optionsArg?.convention ?? "either";
|
|
16757
|
-
const { test, messageId } = CONVENTIONS[convention];
|
|
16758
|
-
const acceptsSchemaWord = convention !== "prefix";
|
|
17022
|
+
defaultOptions: [],
|
|
17023
|
+
create(context) {
|
|
16759
17024
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
17025
|
+
const schemaBindings = /* @__PURE__ */ new Set();
|
|
16760
17026
|
function resolvedBinding(identifier) {
|
|
16761
|
-
return
|
|
17027
|
+
return ASTUtils23.findVariable(
|
|
16762
17028
|
context.sourceCode.getScope(identifier),
|
|
16763
17029
|
identifier.name
|
|
16764
17030
|
);
|
|
@@ -16773,6 +17039,26 @@ var zod_naming_convention_default = createRule({
|
|
|
16773
17039
|
const binding = resolvedBinding(root);
|
|
16774
17040
|
return binding !== null && zodBindings.has(binding);
|
|
16775
17041
|
}
|
|
17042
|
+
function isSchemaBinding(identifier) {
|
|
17043
|
+
const binding = resolvedBinding(identifier);
|
|
17044
|
+
return binding !== null && schemaBindings.has(binding);
|
|
17045
|
+
}
|
|
17046
|
+
function isConfirmedSchema(expression) {
|
|
17047
|
+
const init = unwrapExpression4(expression);
|
|
17048
|
+
if (init.type === AST_NODE_TYPES66.Identifier) return isSchemaBinding(init);
|
|
17049
|
+
if (init.type !== AST_NODE_TYPES66.CallExpression || init.callee.type !== AST_NODE_TYPES66.MemberExpression) {
|
|
17050
|
+
return false;
|
|
17051
|
+
}
|
|
17052
|
+
const terminal = terminalMethodName(init.callee);
|
|
17053
|
+
if (terminal === null || NON_SCHEMA_TERMINALS.has(terminal)) return false;
|
|
17054
|
+
const names = chainMemberNames(init.callee);
|
|
17055
|
+
if (names.length === 0) return false;
|
|
17056
|
+
if (isZodChain(init.callee)) {
|
|
17057
|
+
return ZOD_SCHEMA_FACTORIES.has(names[0] ?? "") || ZOD_FACTORY_NAMESPACES.has(names[0] ?? "") && ZOD_SCHEMA_FACTORIES.has(names[1] ?? "");
|
|
17058
|
+
}
|
|
17059
|
+
const root = calleeChainRoot(init.callee);
|
|
17060
|
+
return root !== null && isSchemaBinding(root) && SCHEMA_RETURNING_METHODS.has(terminal);
|
|
17061
|
+
}
|
|
16776
17062
|
if (isTestFile(context.filename) || BENCHMARK_PATH_RE.test(context.filename.replaceAll("\\", "/")) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
16777
17063
|
return {};
|
|
16778
17064
|
}
|
|
@@ -16780,26 +17066,23 @@ var zod_naming_convention_default = createRule({
|
|
|
16780
17066
|
ImportDeclaration(node) {
|
|
16781
17067
|
if (!isZodModule(node.source.value)) return;
|
|
16782
17068
|
for (const specifier of node.specifiers) {
|
|
16783
|
-
if (specifier.type ===
|
|
17069
|
+
if (specifier.type === AST_NODE_TYPES66.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES66.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES66.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES66.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
16784
17070
|
recordZodBinding(specifier.local);
|
|
16785
17071
|
}
|
|
16786
17072
|
}
|
|
16787
17073
|
},
|
|
16788
17074
|
VariableDeclarator(node) {
|
|
17075
|
+
if (!isModuleDeclarator(node)) return;
|
|
16789
17076
|
const init = node.init;
|
|
16790
17077
|
if (init === null || init === void 0) return;
|
|
16791
|
-
if (
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
if (
|
|
16795
|
-
|
|
16796
|
-
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
16797
|
-
if (node.id.type !== AST_NODE_TYPES65.Identifier) return;
|
|
16798
|
-
if (test.test(node.id.name)) return;
|
|
16799
|
-
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
17078
|
+
if (node.id.type !== AST_NODE_TYPES66.Identifier) return;
|
|
17079
|
+
if (!isConfirmedSchema(init)) return;
|
|
17080
|
+
const binding = resolvedBinding(node.id);
|
|
17081
|
+
if (binding !== null) schemaBindings.add(binding);
|
|
17082
|
+
if (PASCAL_SCHEMA_NAME_RE.test(node.id.name)) return;
|
|
16800
17083
|
context.report({
|
|
16801
17084
|
node: node.id,
|
|
16802
|
-
messageId
|
|
17085
|
+
messageId: "requirePascalSchema"
|
|
16803
17086
|
});
|
|
16804
17087
|
}
|
|
16805
17088
|
};
|
|
@@ -16809,6 +17092,7 @@ var zod_naming_convention_default = createRule({
|
|
|
16809
17092
|
// src/rules/_renames.ts
|
|
16810
17093
|
var RENAMED_RULES = {
|
|
16811
17094
|
"jsdoc-restates-signature": "no-restated-jsdoc",
|
|
17095
|
+
"zod-naming-convention": "require-pascal-case-zod-schema-name",
|
|
16812
17096
|
"require-interface-for-injected-service": "require-port-for-service",
|
|
16813
17097
|
"strict-test-assertions": "prefer-whole-object-assertion",
|
|
16814
17098
|
"trailing-value-narration": "no-trailing-value-narration"
|
|
@@ -16951,6 +17235,7 @@ var RULES = {
|
|
|
16951
17235
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
16952
17236
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
16953
17237
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
17238
|
+
"prefer-nullish-filter-predicate": prefer_nullish_filter_predicate_default,
|
|
16954
17239
|
"prefer-await-in-async-return": prefer_await_in_async_return_default,
|
|
16955
17240
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
16956
17241
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
@@ -16966,18 +17251,18 @@ var RULES = {
|
|
|
16966
17251
|
"store-insert-requires-on-conflict": store_insert_requires_on_conflict_default,
|
|
16967
17252
|
"stepdown": stepdown_default,
|
|
16968
17253
|
"source-coupled-test": source_coupled_test_default,
|
|
16969
|
-
"zod-
|
|
17254
|
+
"require-pascal-case-zod-schema-name": require_pascal_case_zod_schema_name_default
|
|
16970
17255
|
};
|
|
16971
17256
|
var meta = {
|
|
16972
17257
|
name: "@sarj/eslint-plugin",
|
|
16973
|
-
version: "15.
|
|
17258
|
+
version: "15.14.0"
|
|
16974
17259
|
};
|
|
16975
17260
|
var APPLICATION_ONLY_RULES = [
|
|
16976
17261
|
"no-restricted-library-load",
|
|
16977
17262
|
"prefer-native-random-uuid",
|
|
16978
17263
|
"prefer-shadcn-primitives"
|
|
16979
17264
|
];
|
|
16980
|
-
var ADVISORY_RULES = [];
|
|
17265
|
+
var ADVISORY_RULES = ["@sarj/require-pascal-case-zod-schema-name"];
|
|
16981
17266
|
var RECOMMENDED_RULES = {
|
|
16982
17267
|
"@sarj/interface-contract-members-private": "error",
|
|
16983
17268
|
"@sarj/iac-source-coupled-test": "error",
|
|
@@ -17032,6 +17317,7 @@ var RECOMMENDED_RULES = {
|
|
|
17032
17317
|
"@sarj/prefer-module-level-constant": "error",
|
|
17033
17318
|
"@sarj/prefer-module-level-schema": "error",
|
|
17034
17319
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
17320
|
+
"@sarj/prefer-nullish-filter-predicate": "error",
|
|
17035
17321
|
"@sarj/prefer-await-in-async-return": "error",
|
|
17036
17322
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
17037
17323
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
@@ -17050,7 +17336,7 @@ var RECOMMENDED_RULES = {
|
|
|
17050
17336
|
"@sarj/stepdown": "error",
|
|
17051
17337
|
"@sarj/source-coupled-test": "error",
|
|
17052
17338
|
"@sarj/test-phase-label-comment": "error",
|
|
17053
|
-
"@sarj/zod-
|
|
17339
|
+
"@sarj/require-pascal-case-zod-schema-name": "warn"
|
|
17054
17340
|
};
|
|
17055
17341
|
var STRICT_RULES = {
|
|
17056
17342
|
"@sarj/interface-contract-members-private": "error",
|
|
@@ -17110,6 +17396,7 @@ var STRICT_RULES = {
|
|
|
17110
17396
|
"@sarj/prefer-module-level-constant": "error",
|
|
17111
17397
|
"@sarj/prefer-module-level-schema": "error",
|
|
17112
17398
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
17399
|
+
"@sarj/prefer-nullish-filter-predicate": "error",
|
|
17113
17400
|
"@sarj/prefer-await-in-async-return": "error",
|
|
17114
17401
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
17115
17402
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
@@ -17128,7 +17415,7 @@ var STRICT_RULES = {
|
|
|
17128
17415
|
"@sarj/stepdown": "error",
|
|
17129
17416
|
"@sarj/source-coupled-test": "error",
|
|
17130
17417
|
"@sarj/test-phase-label-comment": "error",
|
|
17131
|
-
"@sarj/zod-
|
|
17418
|
+
"@sarj/require-pascal-case-zod-schema-name": "warn"
|
|
17132
17419
|
};
|
|
17133
17420
|
var PLUGIN = {
|
|
17134
17421
|
meta,
|