@sarj/eslint-plugin 16.20.0 → 16.20.1
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 +1440 -1237
- package/dist/index.js +422 -220
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@sarj/eslint-plugin",
|
|
4
|
-
version: "16.20.
|
|
4
|
+
version: "16.20.1",
|
|
5
5
|
packageManager: "npm@12.2.0",
|
|
6
6
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
7
7
|
type: "module",
|
|
@@ -10427,8 +10427,8 @@ var no_bespoke_api_case_conversion_default = createRule({
|
|
|
10427
10427
|
let typeName = annotation.typeName;
|
|
10428
10428
|
while (typeName.type === AST_NODE_TYPES50.TSQualifiedName) typeName = typeName.left;
|
|
10429
10429
|
if (typeName.type !== AST_NODE_TYPES50.Identifier) return false;
|
|
10430
|
-
const
|
|
10431
|
-
return
|
|
10430
|
+
const typeBinding2 = ASTUtils28.findVariable(context.sourceCode.getScope(typeName), typeName.name);
|
|
10431
|
+
return typeBinding2?.defs.length === 1 && typeBinding2.defs[0]?.type === "ImportBinding" && typeBinding2.defs[0].parent.type === AST_NODE_TYPES50.ImportDeclaration && API_BOUNDARY_IMPORT_RE.test(typeBinding2.defs[0].parent.source.value);
|
|
10432
10432
|
};
|
|
10433
10433
|
return {
|
|
10434
10434
|
Property(node) {
|
|
@@ -16044,9 +16044,24 @@ var no_unnecessary_use_client_default = createRule({
|
|
|
16044
16044
|
|
|
16045
16045
|
// src/rules/no-unsafe-mock-casting.ts
|
|
16046
16046
|
import {
|
|
16047
|
-
AST_NODE_TYPES as AST_NODE_TYPES72
|
|
16048
|
-
ASTUtils as ASTUtils42
|
|
16047
|
+
AST_NODE_TYPES as AST_NODE_TYPES72
|
|
16049
16048
|
} from "@typescript-eslint/utils";
|
|
16049
|
+
|
|
16050
|
+
// src/rules/_type-binding.ts
|
|
16051
|
+
import "@typescript-eslint/utils";
|
|
16052
|
+
function typeBinding(source, identifier) {
|
|
16053
|
+
let scope = source.getScope(identifier);
|
|
16054
|
+
while (scope !== null) {
|
|
16055
|
+
const variable = scope.set.get(identifier.name);
|
|
16056
|
+
if (variable !== void 0 && (variable.isTypeVariable || variable.defs.some((definition) => definition.isTypeDefinition))) {
|
|
16057
|
+
return variable;
|
|
16058
|
+
}
|
|
16059
|
+
scope = scope.upper;
|
|
16060
|
+
}
|
|
16061
|
+
return null;
|
|
16062
|
+
}
|
|
16063
|
+
|
|
16064
|
+
// src/rules/no-unsafe-mock-casting.ts
|
|
16050
16065
|
var MOCK_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
16051
16066
|
"Mock",
|
|
16052
16067
|
"Mocked",
|
|
@@ -16112,10 +16127,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
16112
16127
|
const directBindings = /* @__PURE__ */ new Set();
|
|
16113
16128
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
16114
16129
|
function resolve2(identifier) {
|
|
16115
|
-
return
|
|
16116
|
-
context.sourceCode.getScope(identifier),
|
|
16117
|
-
identifier.name
|
|
16118
|
-
);
|
|
16130
|
+
return typeBinding(context.sourceCode, identifier);
|
|
16119
16131
|
}
|
|
16120
16132
|
function record(identifier, destination) {
|
|
16121
16133
|
const binding = resolve2(identifier);
|
|
@@ -16159,7 +16171,7 @@ var no_unsafe_mock_casting_default = createRule({
|
|
|
16159
16171
|
});
|
|
16160
16172
|
|
|
16161
16173
|
// src/rules/no-unsafe-test-double-cast.ts
|
|
16162
|
-
import { ASTUtils as
|
|
16174
|
+
import { ASTUtils as ASTUtils42, AST_NODE_TYPES as AST_NODE_TYPES73 } from "@typescript-eslint/utils";
|
|
16163
16175
|
var NO_UNSAFE_TEST_DOUBLE_CAST_DOCUMENTATION = {
|
|
16164
16176
|
summary: "Disallow mock-backed test doubles that bypass collaborator contracts through double assertions.",
|
|
16165
16177
|
rationale: "Casting a partial object through unknown hides missing or stale collaborator members, so production interface changes can compile while the test double silently drifts.",
|
|
@@ -16189,7 +16201,7 @@ function isMockFactory(node, source) {
|
|
|
16189
16201
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
16190
16202
|
if (node.type !== AST_NODE_TYPES73.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES73.MemberExpression) return false;
|
|
16191
16203
|
const receiver = unwrapExpression(unwrappedNodeCallee.object);
|
|
16192
|
-
return node.type === AST_NODE_TYPES73.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES73.MemberExpression && receiver.type === AST_NODE_TYPES73.Identifier && (importedTestMockNamespace(source, receiver) !== null || isUnshadowedTestMockGlobal(source, receiver)) &&
|
|
16204
|
+
return node.type === AST_NODE_TYPES73.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES73.MemberExpression && receiver.type === AST_NODE_TYPES73.Identifier && (importedTestMockNamespace(source, receiver) !== null || isUnshadowedTestMockGlobal(source, receiver)) && ASTUtils42.getPropertyName(unwrappedNodeCallee) !== null && ["fn", "spyOn"].includes(ASTUtils42.getPropertyName(unwrappedNodeCallee) ?? "");
|
|
16193
16205
|
}
|
|
16194
16206
|
var no_unsafe_test_double_cast_default = createRule({
|
|
16195
16207
|
name: "no-unsafe-test-double-cast",
|
|
@@ -16215,7 +16227,7 @@ var no_unsafe_test_double_cast_default = createRule({
|
|
|
16215
16227
|
});
|
|
16216
16228
|
|
|
16217
16229
|
// src/rules/no-first-party-module-mock.ts
|
|
16218
|
-
import { ASTUtils as
|
|
16230
|
+
import { ASTUtils as ASTUtils43, AST_NODE_TYPES as AST_NODE_TYPES74 } from "@typescript-eslint/utils";
|
|
16219
16231
|
var NO_FIRST_PARTY_MODULE_MOCK_DOCUMENTATION = {
|
|
16220
16232
|
summary: "Prefer injected collaborators over mocking maintained first-party modules in tests.",
|
|
16221
16233
|
rationale: "Replacing an owned module couples tests to its lookup path and can verify mock wiring while bypassing the real implementation contract.",
|
|
@@ -16246,7 +16258,7 @@ var no_first_party_module_mock_default = createRule({
|
|
|
16246
16258
|
CallExpression(node) {
|
|
16247
16259
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
16248
16260
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES74.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
16249
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES74.MemberExpression || receiver.type !== AST_NODE_TYPES74.Identifier ||
|
|
16261
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES74.MemberExpression || receiver.type !== AST_NODE_TYPES74.Identifier || ASTUtils43.getPropertyName(unwrappedNodeCallee) === null || !["mock", "doMock"].includes(ASTUtils43.getPropertyName(unwrappedNodeCallee) ?? "")) return;
|
|
16250
16262
|
const framework = importedTestMockNamespace(context.sourceCode, receiver);
|
|
16251
16263
|
if (framework === null || framework === "jest" && mayBeVirtual(node.arguments[2])) return;
|
|
16252
16264
|
const argument = node.arguments[0] === void 0 ? void 0 : unwrapExpression(node.arguments[0]);
|
|
@@ -16272,7 +16284,7 @@ function mayBeVirtual(options) {
|
|
|
16272
16284
|
import {
|
|
16273
16285
|
ESLintUtils as ESLintUtils15,
|
|
16274
16286
|
AST_NODE_TYPES as AST_NODE_TYPES75,
|
|
16275
|
-
ASTUtils as
|
|
16287
|
+
ASTUtils as ASTUtils44
|
|
16276
16288
|
} from "@typescript-eslint/utils";
|
|
16277
16289
|
import * as ts16 from "typescript";
|
|
16278
16290
|
var NO_ZOD_NATIVE_ENUM_DOCUMENTATION = {
|
|
@@ -16328,18 +16340,6 @@ var NO_ZOD_NATIVE_ENUM_DOCUMENTATION = {
|
|
|
16328
16340
|
}
|
|
16329
16341
|
]
|
|
16330
16342
|
};
|
|
16331
|
-
var IGNORE_PATTERNS = [
|
|
16332
|
-
/[\\/]generated[\\/]/,
|
|
16333
|
-
/\.gen\.tsx?$/,
|
|
16334
|
-
/\.generated\.tsx?$/,
|
|
16335
|
-
/\.d\.ts$/
|
|
16336
|
-
];
|
|
16337
|
-
function isIgnoredFile(filename, sourceText) {
|
|
16338
|
-
if (IGNORE_PATTERNS.some((re) => re.test(filename))) {
|
|
16339
|
-
return true;
|
|
16340
|
-
}
|
|
16341
|
-
return /@generated\b/.test(sourceText.slice(0, 1024));
|
|
16342
|
-
}
|
|
16343
16343
|
function unwrap2(node) {
|
|
16344
16344
|
if (node.type === AST_NODE_TYPES75.TSAsExpression || node.type === AST_NODE_TYPES75.TSSatisfiesExpression) {
|
|
16345
16345
|
return unwrap2(node.expression);
|
|
@@ -16389,7 +16389,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
16389
16389
|
defaultOptions: [],
|
|
16390
16390
|
create(context) {
|
|
16391
16391
|
const sourceCode = context.sourceCode;
|
|
16392
|
-
if (
|
|
16392
|
+
if (isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
16393
16393
|
return {};
|
|
16394
16394
|
}
|
|
16395
16395
|
if (isTestFile(context.filename)) {
|
|
@@ -16404,7 +16404,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
16404
16404
|
const zodImportedBindings = /* @__PURE__ */ new Map();
|
|
16405
16405
|
const zodNamespaceBindings = /* @__PURE__ */ new Set();
|
|
16406
16406
|
function resolvedBinding(identifier) {
|
|
16407
|
-
return
|
|
16407
|
+
return ASTUtils44.findVariable(
|
|
16408
16408
|
sourceCode.getScope(identifier),
|
|
16409
16409
|
identifier.name
|
|
16410
16410
|
);
|
|
@@ -16412,7 +16412,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
16412
16412
|
function isZodMemberCall(node, api) {
|
|
16413
16413
|
const callee = unwrapExpression(node.callee);
|
|
16414
16414
|
const calleeReceiver = callee.type === AST_NODE_TYPES75.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
16415
|
-
if (callee.type === AST_NODE_TYPES75.MemberExpression && calleeReceiver.type === AST_NODE_TYPES75.Identifier &&
|
|
16415
|
+
if (callee.type === AST_NODE_TYPES75.MemberExpression && calleeReceiver.type === AST_NODE_TYPES75.Identifier && ASTUtils44.getPropertyName(callee) === api) {
|
|
16416
16416
|
const binding = resolvedBinding(calleeReceiver);
|
|
16417
16417
|
return binding !== null && zodNamespaceBindings.has(binding);
|
|
16418
16418
|
}
|
|
@@ -16471,7 +16471,7 @@ var no_zod_native_enum_default = createRule({
|
|
|
16471
16471
|
});
|
|
16472
16472
|
|
|
16473
16473
|
// src/rules/test-loops-over-literal-cases.ts
|
|
16474
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES76, ASTUtils as
|
|
16474
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES76, ASTUtils as ASTUtils45 } from "@typescript-eslint/utils";
|
|
16475
16475
|
var TEST_LOOPS_OVER_LITERAL_CASES_DOCUMENTATION = {
|
|
16476
16476
|
summary: "Disallow assertions over an inline literal case loop in a test; parameterization reports and names every case independently.",
|
|
16477
16477
|
rationale: "A loop is reported as one test, so failures hide the individual case name and may stop later cases from running.",
|
|
@@ -16624,7 +16624,7 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
16624
16624
|
}
|
|
16625
16625
|
const capturesSetup = walkOwnScope2(node.body, (current) => {
|
|
16626
16626
|
if (current.type !== AST_NODE_TYPES76.Identifier) return false;
|
|
16627
|
-
const variable =
|
|
16627
|
+
const variable = ASTUtils45.findVariable(context.sourceCode.getScope(current), current.name);
|
|
16628
16628
|
if (variable === null || !variable.references.some((reference) => reference.identifier === current)) return false;
|
|
16629
16629
|
return variable.defs.some((definition) => {
|
|
16630
16630
|
const declaration = definition.name;
|
|
@@ -16733,7 +16733,7 @@ var test_phase_label_comment_default = createRule({
|
|
|
16733
16733
|
});
|
|
16734
16734
|
|
|
16735
16735
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
16736
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES78, ASTUtils as
|
|
16736
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES78, ASTUtils as ASTUtils46 } from "@typescript-eslint/utils";
|
|
16737
16737
|
var PREFER_CONSTANT_TIME_SECRET_COMPARE_DOCUMENTATION = {
|
|
16738
16738
|
summary: "Prefer a supported constant-time comparison primitive for secret-like values.",
|
|
16739
16739
|
rationale: "Ordinary equality offers no constant-time guarantee for comparing secrets.",
|
|
@@ -16819,7 +16819,7 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
16819
16819
|
return {};
|
|
16820
16820
|
}
|
|
16821
16821
|
const sourceCode = context.sourceCode;
|
|
16822
|
-
const variableOf = (node) =>
|
|
16822
|
+
const variableOf = (node) => ASTUtils46.findVariable(sourceCode.getScope(node), node.name);
|
|
16823
16823
|
function credentialSource(node, seen = /* @__PURE__ */ new Set()) {
|
|
16824
16824
|
if (seen.has(node) || seen.size >= 8) return false;
|
|
16825
16825
|
seen.add(node);
|
|
@@ -16833,10 +16833,10 @@ var prefer_constant_time_secret_compare_default = createRule({
|
|
|
16833
16833
|
const definition = binding.defs[0];
|
|
16834
16834
|
return definition?.type === "Variable" && definition.parent.kind === "const" && definition.node.init !== null && credentialSource(definition.node.init, seen);
|
|
16835
16835
|
}
|
|
16836
|
-
if (node.type !== AST_NODE_TYPES78.CallExpression || node.optional || node.arguments.length !== 1 || node.callee.type !== AST_NODE_TYPES78.MemberExpression || node.callee.optional ||
|
|
16836
|
+
if (node.type !== AST_NODE_TYPES78.CallExpression || node.optional || node.arguments.length !== 1 || node.callee.type !== AST_NODE_TYPES78.MemberExpression || node.callee.optional || ASTUtils46.getPropertyName(node.callee) !== "get") return false;
|
|
16837
16837
|
const receiver = node.callee.object;
|
|
16838
16838
|
const key = staticString(node.arguments[0]);
|
|
16839
|
-
if (receiver.type !== AST_NODE_TYPES78.MemberExpression || receiver.optional ||
|
|
16839
|
+
if (receiver.type !== AST_NODE_TYPES78.MemberExpression || receiver.optional || ASTUtils46.getPropertyName(receiver) !== "headers" || key === null || !isAuthSecretName(key) || !isNativeRequest(receiver.object)) return false;
|
|
16840
16840
|
const words2 = tokenize(key);
|
|
16841
16841
|
return !words2.includes("token") || words2.some((word) => AUTH_TOKEN_QUALIFIERS.has(word) || word !== "token" && SECRET_WORDS.has(word));
|
|
16842
16842
|
}
|
|
@@ -16974,7 +16974,7 @@ var prefer_ecmascript_private_members_default = createRule({
|
|
|
16974
16974
|
import "@typescript-eslint/utils";
|
|
16975
16975
|
|
|
16976
16976
|
// src/rules/_discriminated-union-returns.ts
|
|
16977
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES80, ASTUtils as
|
|
16977
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES80, ASTUtils as ASTUtils47 } from "@typescript-eslint/utils";
|
|
16978
16978
|
var MAX_PATH_VISITS = 2048;
|
|
16979
16979
|
var MAX_RETURN_OBJECTS = 256;
|
|
16980
16980
|
var MAX_PATH_DEPTH = 64;
|
|
@@ -17162,11 +17162,11 @@ function broadSwitchInput(statement, sourceCode) {
|
|
|
17162
17162
|
if (body2.type !== AST_NODE_TYPES80.BlockStatement || body2.body.length !== 1) return void 0;
|
|
17163
17163
|
const owner = body2.parent;
|
|
17164
17164
|
if (owner.type !== AST_NODE_TYPES80.FunctionDeclaration || owner.id === null) return void 0;
|
|
17165
|
-
const callable =
|
|
17165
|
+
const callable = ASTUtils47.findVariable(sourceCode.getScope(owner), owner.id.name);
|
|
17166
17166
|
if (callable?.defs.length !== 1 || callable.defs[0]?.type !== "FunctionName" || callable.defs[0].node !== owner) return void 0;
|
|
17167
17167
|
const input = statement.discriminant;
|
|
17168
17168
|
if (input.type !== AST_NODE_TYPES80.Identifier) return void 0;
|
|
17169
|
-
const binding =
|
|
17169
|
+
const binding = ASTUtils47.findVariable(sourceCode.getScope(input), input.name);
|
|
17170
17170
|
const definition = binding?.defs[0];
|
|
17171
17171
|
if (binding?.defs.length !== 1 || definition?.type !== "Parameter" || definition.node !== owner || definition.name.type !== AST_NODE_TYPES80.Identifier || binding.references.some((reference) => reference.isWrite())) return void 0;
|
|
17172
17172
|
const type = definition.name.typeAnnotation?.typeAnnotation.type;
|
|
@@ -17413,7 +17413,7 @@ var prefer_discriminated_union_default = createRule({
|
|
|
17413
17413
|
});
|
|
17414
17414
|
|
|
17415
17415
|
// src/rules/prefer-input-group-search.ts
|
|
17416
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES82, ASTUtils as
|
|
17416
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES82, ASTUtils as ASTUtils48 } from "@typescript-eslint/utils";
|
|
17417
17417
|
var PREFER_INPUT_GROUP_SEARCH_DOCUMENTATION = {
|
|
17418
17418
|
summary: "Require search icons and shared Input controls in the same visual wrapper to use InputGroup.",
|
|
17419
17419
|
rationale: "The shared compound control provides consistent spacing, focus behavior, and accessible composition.",
|
|
@@ -17537,7 +17537,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
17537
17537
|
JSXOpeningElement(node) {
|
|
17538
17538
|
const name = elementName(node);
|
|
17539
17539
|
if (name === null) return;
|
|
17540
|
-
const binding =
|
|
17540
|
+
const binding = ASTUtils48.findVariable(context.sourceCode.getScope(node), name);
|
|
17541
17541
|
if (binding?.defs.length !== 1 || binding.defs[0]?.node.type !== AST_NODE_TYPES82.ImportSpecifier || binding.defs[0].node.importKind === "type") return;
|
|
17542
17542
|
const occurrence = {
|
|
17543
17543
|
ancestors: context.sourceCode.getAncestors(node),
|
|
@@ -17577,7 +17577,7 @@ var prefer_input_group_search_default = createRule({
|
|
|
17577
17577
|
|
|
17578
17578
|
// src/rules/prefer-millisecond-control-duration-schema.ts
|
|
17579
17579
|
import {
|
|
17580
|
-
ASTUtils as
|
|
17580
|
+
ASTUtils as ASTUtils49,
|
|
17581
17581
|
AST_NODE_TYPES as AST_NODE_TYPES83
|
|
17582
17582
|
} from "@typescript-eslint/utils";
|
|
17583
17583
|
var PREFER_MILLISECOND_CONTROL_DURATION_SCHEMA_DOCUMENTATION = {
|
|
@@ -17648,7 +17648,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
17648
17648
|
const objectFactories = /* @__PURE__ */ new Set();
|
|
17649
17649
|
const numberFactories = /* @__PURE__ */ new Set();
|
|
17650
17650
|
function binding(identifier) {
|
|
17651
|
-
return
|
|
17651
|
+
return ASTUtils49.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
17652
17652
|
}
|
|
17653
17653
|
function record(target, identifier) {
|
|
17654
17654
|
const variable = binding(identifier);
|
|
@@ -17661,7 +17661,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
17661
17661
|
const variable2 = binding(callee);
|
|
17662
17662
|
return variable2 !== null && objectFactories.has(variable2);
|
|
17663
17663
|
}
|
|
17664
|
-
if (callee.type !== AST_NODE_TYPES83.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES83.Identifier ||
|
|
17664
|
+
if (callee.type !== AST_NODE_TYPES83.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES83.Identifier || ASTUtils49.getPropertyName(callee) === null || (ASTUtils49.getPropertyName(callee) ?? "") !== "object" && (ASTUtils49.getPropertyName(callee) ?? "") !== "strictObject") {
|
|
17665
17665
|
return false;
|
|
17666
17666
|
}
|
|
17667
17667
|
const variable = binding(calleeReceiver);
|
|
@@ -17676,12 +17676,12 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
17676
17676
|
const variable = binding(callee);
|
|
17677
17677
|
return variable !== null && numberFactories.has(variable);
|
|
17678
17678
|
}
|
|
17679
|
-
if (callee.type !== AST_NODE_TYPES83.MemberExpression ||
|
|
17679
|
+
if (callee.type !== AST_NODE_TYPES83.MemberExpression || ASTUtils49.getPropertyName(callee) === null) return false;
|
|
17680
17680
|
if (calleeReceiver.type === AST_NODE_TYPES83.Identifier) {
|
|
17681
17681
|
const variable = binding(calleeReceiver);
|
|
17682
|
-
return (
|
|
17682
|
+
return (ASTUtils49.getPropertyName(callee) ?? "") === "number" && variable !== null && zodNamespaces.has(variable);
|
|
17683
17683
|
}
|
|
17684
|
-
return ["int", "min", "max", "positive", "nonnegative", "finite", "multipleOf", "optional", "nullable", "nullish", "default", "describe", "brand", "readonly"].includes(
|
|
17684
|
+
return ["int", "min", "max", "positive", "nonnegative", "finite", "multipleOf", "optional", "nullable", "nullish", "default", "describe", "brand", "readonly"].includes(ASTUtils49.getPropertyName(callee) ?? "") && isNumericSchema(calleeReceiver);
|
|
17685
17685
|
}
|
|
17686
17686
|
return {
|
|
17687
17687
|
ImportDeclaration(node) {
|
|
@@ -17714,7 +17714,7 @@ var prefer_millisecond_control_duration_schema_default = createRule({
|
|
|
17714
17714
|
});
|
|
17715
17715
|
|
|
17716
17716
|
// src/rules/prefer-immutable-module-constant.ts
|
|
17717
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES84, ASTUtils as
|
|
17717
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES84, ASTUtils as ASTUtils50 } from "@typescript-eslint/utils";
|
|
17718
17718
|
var PREFER_IMMUTABLE_MODULE_CONSTANT_DOCUMENTATION = {
|
|
17719
17719
|
summary: "Require module-level constant collections to expose readonly state.",
|
|
17720
17720
|
rationale: "A const binding prevents reassignment but does not stop callers from mutating its array, object, Set, or Map contents.",
|
|
@@ -17933,15 +17933,15 @@ var prefer_immutable_module_constant_default = createRule({
|
|
|
17933
17933
|
create(context) {
|
|
17934
17934
|
const sourceCode = context.sourceCode;
|
|
17935
17935
|
const isUnshadowedGlobal3 = (identifier) => {
|
|
17936
|
-
const variable =
|
|
17936
|
+
const variable = ASTUtils50.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
17937
17937
|
return variable === null || variable.defs.length === 0;
|
|
17938
17938
|
};
|
|
17939
17939
|
const isUnshadowedType = (identifier) => {
|
|
17940
|
-
const variable =
|
|
17940
|
+
const variable = ASTUtils50.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
17941
17941
|
return variable === null || !variable.defs.some((definition) => definition.isTypeDefinition);
|
|
17942
17942
|
};
|
|
17943
17943
|
const resolveLocalType = (identifier) => {
|
|
17944
|
-
const variable =
|
|
17944
|
+
const variable = ASTUtils50.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
17945
17945
|
const definitions2 = variable?.defs.filter((definition) => definition.isTypeDefinition) ?? [];
|
|
17946
17946
|
const declaration = definitions2.length === 1 ? definitions2[0]?.node : void 0;
|
|
17947
17947
|
return declaration?.type === AST_NODE_TYPES84.TSTypeAliasDeclaration || declaration?.type === AST_NODE_TYPES84.TSTypeParameter ? declaration : void 0;
|
|
@@ -18435,7 +18435,7 @@ function matchingAliasTargets(paths, alias) {
|
|
|
18435
18435
|
}
|
|
18436
18436
|
|
|
18437
18437
|
// src/rules/prefer-module-level-constant.ts
|
|
18438
|
-
import { ASTUtils as
|
|
18438
|
+
import { ASTUtils as ASTUtils51, AST_NODE_TYPES as AST_NODE_TYPES86 } from "@typescript-eslint/utils";
|
|
18439
18439
|
var PREFER_MODULE_LEVEL_CONSTANT_DOCUMENTATION = {
|
|
18440
18440
|
summary: "Hoist literal-only constant collections and regexes out of function bodies to module scope so they are allocated once.",
|
|
18441
18441
|
rationale: "Recreating immutable lookup data on every call wastes allocations and obscures its constant nature.",
|
|
@@ -18449,7 +18449,7 @@ var PREFER_MODULE_LEVEL_CONSTANT_DOCUMENTATION = {
|
|
|
18449
18449
|
};
|
|
18450
18450
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
18451
18451
|
var MAX_LITERAL_DEPTH = 4;
|
|
18452
|
-
var
|
|
18452
|
+
var IGNORE_PATTERNS = [
|
|
18453
18453
|
/[\\/]generated[\\/]/,
|
|
18454
18454
|
/\.gen\.tsx?$/,
|
|
18455
18455
|
/\.generated\.tsx?$/,
|
|
@@ -18480,8 +18480,8 @@ var FUNCTION_TYPES7 = /* @__PURE__ */ new Set([
|
|
|
18480
18480
|
AST_NODE_TYPES86.ArrowFunctionExpression
|
|
18481
18481
|
]);
|
|
18482
18482
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
18483
|
-
function
|
|
18484
|
-
if (
|
|
18483
|
+
function isIgnoredFile(filename, sourceText) {
|
|
18484
|
+
if (IGNORE_PATTERNS.some((re) => re.test(filename))) {
|
|
18485
18485
|
return true;
|
|
18486
18486
|
}
|
|
18487
18487
|
return /@generated\b/.test(sourceText.slice(0, 1024));
|
|
@@ -18635,7 +18635,7 @@ function isNonRetainingBuiltinCall(node, argument, sourceCode) {
|
|
|
18635
18635
|
return true;
|
|
18636
18636
|
}
|
|
18637
18637
|
function isUnshadowedBuiltin(identifier, sourceCode) {
|
|
18638
|
-
return (
|
|
18638
|
+
return (ASTUtils51.findVariable(sourceCode.getScope(identifier), identifier.name)?.defs.length ?? 0) === 0;
|
|
18639
18639
|
}
|
|
18640
18640
|
var prefer_module_level_constant_default = createRule({
|
|
18641
18641
|
name: "prefer-module-level-constant",
|
|
@@ -18669,7 +18669,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
18669
18669
|
const ignoreTestFiles = options.ignoreTestFiles ?? true;
|
|
18670
18670
|
const sourceCode = context.sourceCode;
|
|
18671
18671
|
const filename = context.filename;
|
|
18672
|
-
if (
|
|
18672
|
+
if (isIgnoredFile(filename, sourceCode.getText())) {
|
|
18673
18673
|
return {};
|
|
18674
18674
|
}
|
|
18675
18675
|
if (ignoreTestFiles && isLocalFixtureFile(filename)) {
|
|
@@ -18765,14 +18765,14 @@ function isSafeMemberRead(identifier, parent) {
|
|
|
18765
18765
|
if (grandparent.type === AST_NODE_TYPES86.UnaryExpression && grandparent.operator === "delete") {
|
|
18766
18766
|
return false;
|
|
18767
18767
|
}
|
|
18768
|
-
if (grandparent.type === AST_NODE_TYPES86.CallExpression && grandparent.callee === usage && (
|
|
18768
|
+
if (grandparent.type === AST_NODE_TYPES86.CallExpression && grandparent.callee === usage && (ASTUtils51.getPropertyName(parent) === null || MUTATING_METHODS2.has(ASTUtils51.getPropertyName(parent) ?? ""))) {
|
|
18769
18769
|
return false;
|
|
18770
18770
|
}
|
|
18771
18771
|
return true;
|
|
18772
18772
|
}
|
|
18773
18773
|
|
|
18774
18774
|
// src/rules/prefer-module-level-schema.ts
|
|
18775
|
-
import { ASTUtils as
|
|
18775
|
+
import { ASTUtils as ASTUtils52, AST_NODE_TYPES as AST_NODE_TYPES87 } from "@typescript-eslint/utils";
|
|
18776
18776
|
var PREFER_MODULE_LEVEL_SCHEMA_DOCUMENTATION = {
|
|
18777
18777
|
summary: "Declare a Zod schema at module scope when it closes over nothing in the enclosing function",
|
|
18778
18778
|
rationale: "A schema created inside a function is rebuilt on each call. Module scope can enable reuse across callers; local schemas already support local type inference.",
|
|
@@ -18880,7 +18880,7 @@ function schemaExpression(node) {
|
|
|
18880
18880
|
if (parent === void 0) {
|
|
18881
18881
|
return current;
|
|
18882
18882
|
}
|
|
18883
|
-
if (parent.type === AST_NODE_TYPES87.MemberExpression && parent.object === current &&
|
|
18883
|
+
if (parent.type === AST_NODE_TYPES87.MemberExpression && parent.object === current && ASTUtils52.getPropertyName(parent) !== null && TERMINAL_METHODS.has(ASTUtils52.getPropertyName(parent) ?? "")) {
|
|
18884
18884
|
return current;
|
|
18885
18885
|
}
|
|
18886
18886
|
if (parent.type === AST_NODE_TYPES87.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES87.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES87.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES87.TSNonNullExpression && parent.expression === current) {
|
|
@@ -19018,14 +19018,14 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19018
19018
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
19019
19019
|
if (node.type !== AST_NODE_TYPES87.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES87.MemberExpression) return false;
|
|
19020
19020
|
const receiver = unwrapExpression(unwrappedNodeCallee.object);
|
|
19021
|
-
return node.type === AST_NODE_TYPES87.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES87.MemberExpression &&
|
|
19021
|
+
return node.type === AST_NODE_TYPES87.CallExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES87.MemberExpression && ASTUtils52.getPropertyName(unwrappedNodeCallee) !== null && receiver.type === AST_NODE_TYPES87.Identifier && zodNamespaces.has(receiver.name);
|
|
19022
19022
|
}
|
|
19023
19023
|
function isSchemaConstruction(node) {
|
|
19024
19024
|
const callee = unwrapExpression(node.callee);
|
|
19025
19025
|
const calleeReceiver = callee.type === AST_NODE_TYPES87.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
19026
|
-
if (callee.type !== AST_NODE_TYPES87.MemberExpression ||
|
|
19026
|
+
if (callee.type !== AST_NODE_TYPES87.MemberExpression || ASTUtils52.getPropertyName(callee) === null || TERMINAL_METHODS.has(ASTUtils52.getPropertyName(callee) ?? "")) return false;
|
|
19027
19027
|
if (calleeReceiver.type === AST_NODE_TYPES87.CallExpression) return isSchemaConstruction(calleeReceiver);
|
|
19028
|
-
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(
|
|
19028
|
+
return isZodCall(node) && CONSTRUCTION_FACTORIES.has(ASTUtils52.getPropertyName(callee) ?? "");
|
|
19029
19029
|
}
|
|
19030
19030
|
function hasEagerComputation(node) {
|
|
19031
19031
|
return subtreeSome(node, (inner) => inner.type === AST_NODE_TYPES87.NewExpression || inner.type === AST_NODE_TYPES87.TaggedTemplateExpression || inner.type === AST_NODE_TYPES87.CallExpression && !isSchemaConstruction(inner), true);
|
|
@@ -19033,10 +19033,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19033
19033
|
function isCovered(node) {
|
|
19034
19034
|
let current = node.parent ?? void 0;
|
|
19035
19035
|
while (current !== void 0) {
|
|
19036
|
-
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES87.MemberExpression &&
|
|
19036
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES87.MemberExpression && ASTUtils52.getPropertyName(current.callee) !== null && factories.has(ASTUtils52.getPropertyName(current.callee) ?? "")) {
|
|
19037
19037
|
return true;
|
|
19038
19038
|
}
|
|
19039
|
-
if (current.type === AST_NODE_TYPES87.CallExpression && (current.callee.type === AST_NODE_TYPES87.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES87.MemberExpression &&
|
|
19039
|
+
if (current.type === AST_NODE_TYPES87.CallExpression && (current.callee.type === AST_NODE_TYPES87.Identifier && memoCallees.has(current.callee.name) || current.callee.type === AST_NODE_TYPES87.MemberExpression && ASTUtils52.getPropertyName(current.callee) !== null && memoCallees.has(ASTUtils52.getPropertyName(current.callee) ?? ""))) {
|
|
19040
19040
|
return true;
|
|
19041
19041
|
}
|
|
19042
19042
|
current = current.parent ?? void 0;
|
|
@@ -19065,7 +19065,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19065
19065
|
}
|
|
19066
19066
|
function isSchemaComposition(node) {
|
|
19067
19067
|
const callee = unwrapExpression(node.callee);
|
|
19068
|
-
const isCombinator = callee.type === AST_NODE_TYPES87.MemberExpression &&
|
|
19068
|
+
const isCombinator = callee.type === AST_NODE_TYPES87.MemberExpression && ASTUtils52.getPropertyName(callee) !== null && ZOD_COMBINATOR_METHODS.has(ASTUtils52.getPropertyName(callee) ?? "");
|
|
19069
19069
|
return isCombinator || isZodCall(node);
|
|
19070
19070
|
}
|
|
19071
19071
|
function closesOverNothing(node, enclosing) {
|
|
@@ -19138,10 +19138,10 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19138
19138
|
return;
|
|
19139
19139
|
}
|
|
19140
19140
|
const callee = unwrappedNodeCallee;
|
|
19141
|
-
if (
|
|
19141
|
+
if (ASTUtils52.getPropertyName(callee) === null) {
|
|
19142
19142
|
return;
|
|
19143
19143
|
}
|
|
19144
|
-
const factory =
|
|
19144
|
+
const factory = ASTUtils52.getPropertyName(callee) ?? "";
|
|
19145
19145
|
if (!factories.has(factory)) {
|
|
19146
19146
|
return;
|
|
19147
19147
|
}
|
|
@@ -19184,7 +19184,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
19184
19184
|
// src/rules/prefer-module-level-refined-schema.ts
|
|
19185
19185
|
import {
|
|
19186
19186
|
AST_NODE_TYPES as AST_NODE_TYPES88,
|
|
19187
|
-
ASTUtils as
|
|
19187
|
+
ASTUtils as ASTUtils53
|
|
19188
19188
|
} from "@typescript-eslint/utils";
|
|
19189
19189
|
var BENCHMARK_PATH_RE = /(^|[/\\])(?:benchmarks?|bench)[/\\]/;
|
|
19190
19190
|
var FACTORIES = /* @__PURE__ */ new Set([
|
|
@@ -19411,9 +19411,9 @@ function chainMemberNames(node) {
|
|
|
19411
19411
|
for (; ; ) {
|
|
19412
19412
|
current = unwrapExpression(current);
|
|
19413
19413
|
if (current.type === AST_NODE_TYPES88.MemberExpression) {
|
|
19414
|
-
if (
|
|
19414
|
+
if (ASTUtils53.getPropertyName(current) === null)
|
|
19415
19415
|
return [];
|
|
19416
|
-
names.push(
|
|
19416
|
+
names.push(ASTUtils53.getPropertyName(current) ?? "");
|
|
19417
19417
|
current = current.object;
|
|
19418
19418
|
continue;
|
|
19419
19419
|
}
|
|
@@ -19430,8 +19430,8 @@ function schemaExpression2(node) {
|
|
|
19430
19430
|
let current = node;
|
|
19431
19431
|
for (; ; ) {
|
|
19432
19432
|
const parent = current.parent ?? void 0;
|
|
19433
|
-
if (parent?.type === AST_NODE_TYPES88.MemberExpression && parent.object === current &&
|
|
19434
|
-
if (NON_SCHEMA_TERMINALS.has(
|
|
19433
|
+
if (parent?.type === AST_NODE_TYPES88.MemberExpression && parent.object === current && ASTUtils53.getPropertyName(parent) !== null && parent.parent?.type === AST_NODE_TYPES88.CallExpression && parent.parent.callee === parent) {
|
|
19434
|
+
if (NON_SCHEMA_TERMINALS.has(ASTUtils53.getPropertyName(parent) ?? "")) return current;
|
|
19435
19435
|
current = parent.parent;
|
|
19436
19436
|
continue;
|
|
19437
19437
|
}
|
|
@@ -19461,7 +19461,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
19461
19461
|
return {};
|
|
19462
19462
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
19463
19463
|
function resolvedBinding(identifier) {
|
|
19464
|
-
return
|
|
19464
|
+
return ASTUtils53.findVariable(
|
|
19465
19465
|
context.sourceCode.getScope(identifier),
|
|
19466
19466
|
identifier.name
|
|
19467
19467
|
);
|
|
@@ -19487,7 +19487,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
19487
19487
|
function isSchemaConstruction(node) {
|
|
19488
19488
|
const callee = unwrapExpression(node.callee);
|
|
19489
19489
|
const calleeReceiver = callee.type === AST_NODE_TYPES88.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
19490
|
-
if (callee.type !== AST_NODE_TYPES88.MemberExpression ||
|
|
19490
|
+
if (callee.type !== AST_NODE_TYPES88.MemberExpression || ASTUtils53.getPropertyName(callee) === null || NON_SCHEMA_TERMINALS.has(ASTUtils53.getPropertyName(callee) ?? "")) return false;
|
|
19491
19491
|
if (calleeReceiver.type === AST_NODE_TYPES88.CallExpression) return isSchemaConstruction(calleeReceiver);
|
|
19492
19492
|
return factoryName(node, FACTORIES) !== null || factoryName(node, COMPOSITE_FACTORIES) !== null;
|
|
19493
19493
|
}
|
|
@@ -19514,7 +19514,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
19514
19514
|
function isMemoized(node) {
|
|
19515
19515
|
let current = node.parent ?? void 0;
|
|
19516
19516
|
while (current !== void 0) {
|
|
19517
|
-
if (current.type === AST_NODE_TYPES88.CallExpression && (current.callee.type === AST_NODE_TYPES88.Identifier && MEMO_CALLEES2.has(current.callee.name) || current.callee.type === AST_NODE_TYPES88.MemberExpression &&
|
|
19517
|
+
if (current.type === AST_NODE_TYPES88.CallExpression && (current.callee.type === AST_NODE_TYPES88.Identifier && MEMO_CALLEES2.has(current.callee.name) || current.callee.type === AST_NODE_TYPES88.MemberExpression && ASTUtils53.getPropertyName(current.callee) !== null && MEMO_CALLEES2.has(ASTUtils53.getPropertyName(current.callee) ?? "")))
|
|
19518
19518
|
return true;
|
|
19519
19519
|
current = current.parent ?? void 0;
|
|
19520
19520
|
}
|
|
@@ -19577,7 +19577,7 @@ var prefer_module_level_refined_schema_default = createRule({
|
|
|
19577
19577
|
// src/rules/prefer-multi-value-zod-literal.ts
|
|
19578
19578
|
import {
|
|
19579
19579
|
AST_NODE_TYPES as AST_NODE_TYPES89,
|
|
19580
|
-
ASTUtils as
|
|
19580
|
+
ASTUtils as ASTUtils54
|
|
19581
19581
|
} from "@typescript-eslint/utils";
|
|
19582
19582
|
var PREFER_MULTI_VALUE_ZOD_LITERAL_DOCUMENTATION = {
|
|
19583
19583
|
defaultLevel: "error",
|
|
@@ -19626,7 +19626,7 @@ function isStaticPrimitive(node, context) {
|
|
|
19626
19626
|
if (node.type === AST_NODE_TYPES89.TemplateLiteral && node.expressions.length === 0)
|
|
19627
19627
|
return true;
|
|
19628
19628
|
if (node.type === AST_NODE_TYPES89.Identifier && node.name === "undefined") {
|
|
19629
|
-
const binding =
|
|
19629
|
+
const binding = ASTUtils54.findVariable(
|
|
19630
19630
|
context.sourceCode.getScope(node),
|
|
19631
19631
|
node.name
|
|
19632
19632
|
);
|
|
@@ -19664,7 +19664,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
19664
19664
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
19665
19665
|
const zod4Bindings = /* @__PURE__ */ new Set();
|
|
19666
19666
|
function resolvedBinding(identifier) {
|
|
19667
|
-
return
|
|
19667
|
+
return ASTUtils54.findVariable(
|
|
19668
19668
|
context.sourceCode.getScope(identifier),
|
|
19669
19669
|
identifier.name
|
|
19670
19670
|
);
|
|
@@ -19672,7 +19672,7 @@ var prefer_multi_value_zod_literal_default = createRule({
|
|
|
19672
19672
|
function directMemberCall(node, binding, method) {
|
|
19673
19673
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
19674
19674
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES89.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
19675
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES89.MemberExpression || receiver.type !== AST_NODE_TYPES89.Identifier ||
|
|
19675
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES89.MemberExpression || receiver.type !== AST_NODE_TYPES89.Identifier || ASTUtils54.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils54.getPropertyName(unwrappedNodeCallee) ?? "") !== method)
|
|
19676
19676
|
return false;
|
|
19677
19677
|
return resolvedBinding(receiver) === binding;
|
|
19678
19678
|
}
|
|
@@ -19974,7 +19974,7 @@ var prefer_named_complex_return_type_default = createRule({
|
|
|
19974
19974
|
});
|
|
19975
19975
|
|
|
19976
19976
|
// src/rules/prefer-native-random-uuid.ts
|
|
19977
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES93, ASTUtils as
|
|
19977
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES93, ASTUtils as ASTUtils55 } from "@typescript-eslint/utils";
|
|
19978
19978
|
var PREFER_NATIVE_RANDOM_UUID_DOCUMENTATION = {
|
|
19979
19979
|
summary: "Prefer `globalThis.crypto.randomUUID()` over resolved zero-argument UUID v4 bindings from the `uuid` package.",
|
|
19980
19980
|
rationale: "The platform implementation avoids an unnecessary dependency for standard random UUID generation.",
|
|
@@ -20010,14 +20010,14 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
20010
20010
|
const directBindings = /* @__PURE__ */ new Set();
|
|
20011
20011
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
20012
20012
|
function resolve2(identifier) {
|
|
20013
|
-
return
|
|
20013
|
+
return ASTUtils55.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
20014
20014
|
}
|
|
20015
20015
|
function record(identifier, destination) {
|
|
20016
20016
|
const variable = resolve2(identifier);
|
|
20017
20017
|
if (variable !== null) destination.add(variable);
|
|
20018
20018
|
}
|
|
20019
20019
|
function report2(node) {
|
|
20020
|
-
const globalBinding =
|
|
20020
|
+
const globalBinding = ASTUtils55.findVariable(context.sourceCode.getScope(node), "globalThis");
|
|
20021
20021
|
const canSuggest = (globalBinding?.defs.length ?? 0) === 0 && context.sourceCode.getCommentsInside(node).length === 0;
|
|
20022
20022
|
context.report({
|
|
20023
20023
|
node,
|
|
@@ -20076,7 +20076,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
20076
20076
|
});
|
|
20077
20077
|
|
|
20078
20078
|
// src/rules/prefer-node-crypto-hash.ts
|
|
20079
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES94, ASTUtils as
|
|
20079
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES94, ASTUtils as ASTUtils56 } from "@typescript-eslint/utils";
|
|
20080
20080
|
var PREFER_NODE_CRYPTO_HASH_DOCUMENTATION = {
|
|
20081
20081
|
defaultLevel: "warning",
|
|
20082
20082
|
summary: "Prefer the modern one-shot node:crypto hash API when streaming state is unnecessary.",
|
|
@@ -20104,7 +20104,7 @@ function isCryptoLoader(node, resolve2) {
|
|
|
20104
20104
|
if (unwrappedNodeCallee?.type === AST_NODE_TYPES94.Identifier) {
|
|
20105
20105
|
return unwrappedNodeCallee.name === "require" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee, resolve2);
|
|
20106
20106
|
}
|
|
20107
|
-
return unwrappedNodeCallee?.type === AST_NODE_TYPES94.MemberExpression && unwrappedNodeCallee.object.type === AST_NODE_TYPES94.Identifier && unwrappedNodeCallee.object.name === "process" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee.object, resolve2) &&
|
|
20107
|
+
return unwrappedNodeCallee?.type === AST_NODE_TYPES94.MemberExpression && unwrappedNodeCallee.object.type === AST_NODE_TYPES94.Identifier && unwrappedNodeCallee.object.name === "process" && isUnshadowedBuiltinIdentifier(unwrappedNodeCallee.object, resolve2) && ASTUtils56.getPropertyName(unwrappedNodeCallee) === "getBuiltinModule";
|
|
20108
20108
|
}
|
|
20109
20109
|
function isCryptoSpecifier(node) {
|
|
20110
20110
|
return node.type === AST_NODE_TYPES94.Literal && (node.value === "crypto" || node.value === "node:crypto");
|
|
@@ -20129,7 +20129,7 @@ var prefer_node_crypto_hash_default = createRule({
|
|
|
20129
20129
|
const directBindings = /* @__PURE__ */ new Set();
|
|
20130
20130
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
20131
20131
|
function resolve2(identifier) {
|
|
20132
|
-
return
|
|
20132
|
+
return ASTUtils56.findVariable(
|
|
20133
20133
|
context.sourceCode.getScope(identifier),
|
|
20134
20134
|
identifier.name
|
|
20135
20135
|
);
|
|
@@ -20191,7 +20191,7 @@ function importedName5(node) {
|
|
|
20191
20191
|
}
|
|
20192
20192
|
function isMemberCall(node, name) {
|
|
20193
20193
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
20194
|
-
return unwrappedNodeCallee.type === AST_NODE_TYPES94.MemberExpression &&
|
|
20194
|
+
return unwrappedNodeCallee.type === AST_NODE_TYPES94.MemberExpression && ASTUtils56.getPropertyName(unwrappedNodeCallee) === name;
|
|
20195
20195
|
}
|
|
20196
20196
|
function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
20197
20197
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
@@ -20199,7 +20199,7 @@ function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
|
20199
20199
|
const variable2 = resolve2(unwrappedNodeCallee);
|
|
20200
20200
|
return variable2 !== null && directBindings.has(variable2);
|
|
20201
20201
|
}
|
|
20202
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES94.MemberExpression ||
|
|
20202
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES94.MemberExpression || ASTUtils56.getPropertyName(unwrappedNodeCallee) !== "createHash") {
|
|
20203
20203
|
return false;
|
|
20204
20204
|
}
|
|
20205
20205
|
if (isCryptoLoader(unwrappedNodeCallee.object, resolve2)) return true;
|
|
@@ -20209,7 +20209,7 @@ function isCreateHashCall(node, directBindings, namespaceBindings, resolve2) {
|
|
|
20209
20209
|
}
|
|
20210
20210
|
|
|
20211
20211
|
// src/rules/prefer-node-fs-promises.ts
|
|
20212
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES95, ASTUtils as
|
|
20212
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES95, ASTUtils as ASTUtils57 } from "@typescript-eslint/utils";
|
|
20213
20213
|
var PREFER_NODE_FS_PROMISES_DOCUMENTATION = {
|
|
20214
20214
|
defaultLevel: "warning",
|
|
20215
20215
|
summary: "Prefer promise-based Node.js filesystem APIs over synchronous calls in production modules.",
|
|
@@ -20271,7 +20271,7 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
20271
20271
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text) || normalizedFilename.includes("src/rules/"))
|
|
20272
20272
|
return {};
|
|
20273
20273
|
const namespaces = /* @__PURE__ */ new Set();
|
|
20274
|
-
const bindingOf = (node) =>
|
|
20274
|
+
const bindingOf = (node) => ASTUtils57.findVariable(context.sourceCode.getScope(node), node.name);
|
|
20275
20275
|
const isGlobal = (node) => {
|
|
20276
20276
|
const binding = bindingOf(node);
|
|
20277
20277
|
return binding === null || binding.defs.length === 0;
|
|
@@ -20337,16 +20337,22 @@ var prefer_node_fs_promises_default = createRule({
|
|
|
20337
20337
|
});
|
|
20338
20338
|
|
|
20339
20339
|
// src/rules/prefer-non-nullable-collection.ts
|
|
20340
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES96, ASTUtils as
|
|
20340
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES96, ASTUtils as ASTUtils58 } from "@typescript-eslint/utils";
|
|
20341
20341
|
var PREFER_NON_NULLABLE_COLLECTION_DOCUMENTATION = {
|
|
20342
20342
|
summary: "Suggest reviewing nullish arrays that use local empty-array defaults or a shared null-or-empty guard.",
|
|
20343
20343
|
rationale: "A redundant nullish collection state spreads defaults and guards through consumers without carrying information.",
|
|
20344
20344
|
remediation: "Use a non-null collection type and normalize omitted input to an empty collection at the boundary.",
|
|
20345
20345
|
category: "maintainability",
|
|
20346
|
-
limitations: [
|
|
20346
|
+
limitations: [
|
|
20347
|
+
"Recognized defaults and guards are manual modeling prompts, not proof of equivalence for every caller or later use. Recognized exported wire shapes and unknown object escapes are excluded; preserve meaningful null states and boundary compatibility.",
|
|
20348
|
+
"Only inline object types or single unmerged top-level local declarations are resolved, using the type namespace. Array and ReadonlyArray names must be unshadowed built-ins; custom and imported constructors are not inferred. Local named, default and export-assignment type exports preserve ownership of their local interface and alias dependencies; arbitrary value exports remain opaque.",
|
|
20349
|
+
"Explicit exported variable annotations and signatures of local functions or constant callable aliases preserve input ownership, including callable signatures reached by an exported typeof query. Executable bodies, arbitrary value expressions, inferred exported types, class surfaces and ambiguous callable definitions are not resolved."
|
|
20350
|
+
],
|
|
20347
20351
|
examples: [
|
|
20348
20352
|
{ id: "non-null-array", title: "Model an always-present collection", outcome: "no-match", files: [{ path: "src/search.ts", source: "interface Input { items: string[] } function search({ items }: Input) { return items.length; }" }], focusPath: "src/search.ts", expectedCount: 0, public: true },
|
|
20349
|
-
{ id: "defaulted-nullish-array", title: "Do not retain a redundant nullish state", outcome: "match", files: [{ path: "src/search.ts", source: "interface Input { items: string[] | undefined } function search({ items = [] }: Input) { return items.length; }" }], focusPath: "src/search.ts", expectedCount: 1, public: true }
|
|
20353
|
+
{ id: "defaulted-nullish-array", title: "Do not retain a redundant nullish state", outcome: "match", files: [{ path: "src/search.ts", source: "interface Input { items: string[] | undefined } function search({ items = [] }: Input) { return items.length; }" }], focusPath: "src/search.ts", expectedCount: 1, public: true },
|
|
20354
|
+
{ id: "exported-nullish-input", scenarioId: "exported-input", title: "Preserve an exported input contract", outcome: "no-match", files: [{ path: "src/search.ts", source: "interface Input { items: string[] | undefined } export type WireInput = Input; function search({ items = [] }: Input) { return items.length; }" }], focusPath: "src/search.ts", expectedCount: 0, public: true },
|
|
20355
|
+
{ id: "private-nullish-input", scenarioId: "exported-input", title: "Review a private input with an empty default", outcome: "match", files: [{ path: "src/search.ts", source: "interface Input { items: string[] | undefined } type WireInput = Input; function search({ items = [] }: Input) { return items.length; }" }], focusPath: "src/search.ts", expectedCount: 1, public: true }
|
|
20350
20356
|
]
|
|
20351
20357
|
};
|
|
20352
20358
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
@@ -20357,11 +20363,11 @@ function propertyName5(node) {
|
|
|
20357
20363
|
if (key.type === AST_NODE_TYPES96.Literal && typeof key.value === "string") return key.value;
|
|
20358
20364
|
return null;
|
|
20359
20365
|
}
|
|
20360
|
-
function isArrayType(node) {
|
|
20366
|
+
function isArrayType(node, source) {
|
|
20361
20367
|
if (node.type === AST_NODE_TYPES96.TSArrayType) return true;
|
|
20362
|
-
return node.type === AST_NODE_TYPES96.TSTypeReference && node.typeName.type === AST_NODE_TYPES96.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
20368
|
+
return node.type === AST_NODE_TYPES96.TSTypeReference && node.typeName.type === AST_NODE_TYPES96.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name) && node.typeArguments?.params.length === 1 && (typeBinding(source, node.typeName)?.defs.length ?? 0) === 0;
|
|
20363
20369
|
}
|
|
20364
|
-
function nullableProperty(node) {
|
|
20370
|
+
function nullableProperty(node, source) {
|
|
20365
20371
|
if (node.optional) return null;
|
|
20366
20372
|
const name = propertyName5(node);
|
|
20367
20373
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
@@ -20369,7 +20375,7 @@ function nullableProperty(node) {
|
|
|
20369
20375
|
const concrete = annotation.types.filter(
|
|
20370
20376
|
(member) => member.type !== AST_NODE_TYPES96.TSNullKeyword && member.type !== AST_NODE_TYPES96.TSUndefinedKeyword
|
|
20371
20377
|
);
|
|
20372
|
-
if (concrete.length === 0 || !concrete.every(isArrayType)) return null;
|
|
20378
|
+
if (concrete.length === 0 || !concrete.every((member) => isArrayType(member, source))) return null;
|
|
20373
20379
|
const acceptsNull = annotation.types.some((member) => member.type === AST_NODE_TYPES96.TSNullKeyword);
|
|
20374
20380
|
const acceptsUndefined = annotation.types.some(
|
|
20375
20381
|
(member) => member.type === AST_NODE_TYPES96.TSUndefinedKeyword
|
|
@@ -20377,32 +20383,221 @@ function nullableProperty(node) {
|
|
|
20377
20383
|
if (!acceptsNull && !acceptsUndefined) return null;
|
|
20378
20384
|
return { name, node, acceptsNull, acceptsUndefined };
|
|
20379
20385
|
}
|
|
20380
|
-
function shapeProperties(members) {
|
|
20386
|
+
function shapeProperties(members, source) {
|
|
20381
20387
|
return members.flatMap((member) => {
|
|
20382
20388
|
if (member.type !== AST_NODE_TYPES96.TSPropertySignature) return [];
|
|
20383
|
-
const property = nullableProperty(member);
|
|
20389
|
+
const property = nullableProperty(member, source);
|
|
20384
20390
|
return property === null ? [] : [property];
|
|
20385
20391
|
});
|
|
20386
20392
|
}
|
|
20387
|
-
function typeIndex(program) {
|
|
20393
|
+
function typeIndex(program, source, exportedDeclarations) {
|
|
20388
20394
|
const index = /* @__PURE__ */ new Map();
|
|
20389
20395
|
for (const statement of program.body) {
|
|
20390
20396
|
const exported = statement.type === AST_NODE_TYPES96.ExportNamedDeclaration;
|
|
20391
20397
|
const declaration = exported ? statement.declaration : statement;
|
|
20392
20398
|
if (declaration?.type === AST_NODE_TYPES96.TSInterfaceDeclaration) {
|
|
20393
|
-
index.set(declaration
|
|
20394
|
-
exported,
|
|
20395
|
-
properties: shapeProperties(declaration.body.body)
|
|
20399
|
+
index.set(declaration, {
|
|
20400
|
+
exported: exported || exportedDeclarations.has(declaration),
|
|
20401
|
+
properties: shapeProperties(declaration.body.body, source)
|
|
20396
20402
|
});
|
|
20397
20403
|
} else if (declaration?.type === AST_NODE_TYPES96.TSTypeAliasDeclaration && declaration.typeAnnotation.type === AST_NODE_TYPES96.TSTypeLiteral) {
|
|
20398
|
-
index.set(declaration
|
|
20399
|
-
exported,
|
|
20400
|
-
properties: shapeProperties(declaration.typeAnnotation.members)
|
|
20404
|
+
index.set(declaration, {
|
|
20405
|
+
exported: exported || exportedDeclarations.has(declaration),
|
|
20406
|
+
properties: shapeProperties(declaration.typeAnnotation.members, source)
|
|
20401
20407
|
});
|
|
20402
20408
|
}
|
|
20403
20409
|
}
|
|
20404
20410
|
return index;
|
|
20405
20411
|
}
|
|
20412
|
+
function exportedOwnership(program, source) {
|
|
20413
|
+
const seeds = { identifiers: [], values: [], roots: [], callables: /* @__PURE__ */ new Set(), signatures: /* @__PURE__ */ new Set() };
|
|
20414
|
+
for (const statement of program.body) collectExportSeeds(statement, seeds);
|
|
20415
|
+
const graph = {
|
|
20416
|
+
pending: [],
|
|
20417
|
+
declarations: /* @__PURE__ */ new Set(),
|
|
20418
|
+
callables: seeds.callables,
|
|
20419
|
+
signatures: /* @__PURE__ */ new Set(),
|
|
20420
|
+
types: /* @__PURE__ */ new Set(),
|
|
20421
|
+
values: /* @__PURE__ */ new Set(),
|
|
20422
|
+
syntax: /* @__PURE__ */ new Set(),
|
|
20423
|
+
cache: /* @__PURE__ */ new Map()
|
|
20424
|
+
};
|
|
20425
|
+
for (const identifier of seeds.identifiers) graph.pending.push({ kind: "type", identifier });
|
|
20426
|
+
for (const identifier of seeds.values) graph.pending.push({ kind: "value", identifier });
|
|
20427
|
+
for (const declaration of seeds.roots) addTypeDeclaration(declaration, graph);
|
|
20428
|
+
for (const callable of seeds.callables) addSignature(callable, graph);
|
|
20429
|
+
for (const signature of seeds.signatures) addSignature(signature, graph);
|
|
20430
|
+
for (let work = graph.pending.pop(); work !== void 0; work = graph.pending.pop()) {
|
|
20431
|
+
processOwnershipWork(work, source, graph);
|
|
20432
|
+
}
|
|
20433
|
+
return { declarations: graph.declarations, callables: graph.callables };
|
|
20434
|
+
}
|
|
20435
|
+
function processOwnershipWork(work, source, graph) {
|
|
20436
|
+
if (work.kind === "syntax") processOwnershipSyntax(work.node, source, graph);
|
|
20437
|
+
else if (work.kind === "type") processOwnershipType(work.identifier, source, graph);
|
|
20438
|
+
else processOwnershipValue(work.identifier, source, graph);
|
|
20439
|
+
}
|
|
20440
|
+
function processOwnershipSyntax(node, source, graph) {
|
|
20441
|
+
if (graph.syntax.has(node)) return;
|
|
20442
|
+
graph.syntax.add(node);
|
|
20443
|
+
if (node.type === AST_NODE_TYPES96.TSTypeReference && node.typeName.type === AST_NODE_TYPES96.Identifier) {
|
|
20444
|
+
graph.pending.push({ kind: "type", identifier: node.typeName });
|
|
20445
|
+
} else if (node.type === AST_NODE_TYPES96.TSInterfaceHeritage && node.expression.type === AST_NODE_TYPES96.Identifier) {
|
|
20446
|
+
graph.pending.push({ kind: "type", identifier: node.expression });
|
|
20447
|
+
} else if (node.type === AST_NODE_TYPES96.TSTypeQuery && node.exprName.type === AST_NODE_TYPES96.Identifier) {
|
|
20448
|
+
graph.pending.push({ kind: "value", identifier: node.exprName });
|
|
20449
|
+
}
|
|
20450
|
+
forEachAstChild(node, source.visitorKeys, (child) => {
|
|
20451
|
+
graph.pending.push({ kind: "syntax", node: child });
|
|
20452
|
+
});
|
|
20453
|
+
}
|
|
20454
|
+
function processOwnershipType(identifier, source, graph) {
|
|
20455
|
+
const binding = typeBinding(source, identifier);
|
|
20456
|
+
if (binding === null || graph.types.has(binding)) return;
|
|
20457
|
+
graph.types.add(binding);
|
|
20458
|
+
for (const definition of binding.defs) {
|
|
20459
|
+
const declaration = definition.node;
|
|
20460
|
+
if (definition.isTypeDefinition && (declaration.type === AST_NODE_TYPES96.TSTypeAliasDeclaration || declaration.type === AST_NODE_TYPES96.TSInterfaceDeclaration)) addTypeDeclaration(declaration, graph);
|
|
20461
|
+
}
|
|
20462
|
+
}
|
|
20463
|
+
function processOwnershipValue(identifier, source, graph) {
|
|
20464
|
+
const binding = valueBinding(source, identifier);
|
|
20465
|
+
if (binding === null || graph.values.has(binding)) return;
|
|
20466
|
+
graph.values.add(binding);
|
|
20467
|
+
const annotation = exportedValueAnnotation(source, identifier);
|
|
20468
|
+
if (annotation !== void 0) graph.pending.push({ kind: "syntax", node: annotation });
|
|
20469
|
+
const resolved = exportedCallable(source, identifier, graph.cache);
|
|
20470
|
+
if (resolved === null) return;
|
|
20471
|
+
if (resolved.callable !== null) graph.callables.add(resolved.callable);
|
|
20472
|
+
for (const signature of resolved.signatures) addSignature(signature, graph);
|
|
20473
|
+
for (const node of resolved.annotations) graph.pending.push({ kind: "syntax", node });
|
|
20474
|
+
}
|
|
20475
|
+
function addTypeDeclaration(declaration, graph) {
|
|
20476
|
+
if (graph.declarations.has(declaration)) return;
|
|
20477
|
+
graph.declarations.add(declaration);
|
|
20478
|
+
graph.pending.push({ kind: "syntax", node: declaration });
|
|
20479
|
+
}
|
|
20480
|
+
function addSignature(signature, graph) {
|
|
20481
|
+
if (graph.signatures.has(signature)) return;
|
|
20482
|
+
graph.signatures.add(signature);
|
|
20483
|
+
for (const node of callableAnnotations(signature)) graph.pending.push({ kind: "syntax", node });
|
|
20484
|
+
}
|
|
20485
|
+
function collectExportSeeds(statement, seeds) {
|
|
20486
|
+
if (statement.type === AST_NODE_TYPES96.ExportNamedDeclaration && statement.source === null) {
|
|
20487
|
+
collectNamedExport(statement, seeds);
|
|
20488
|
+
} else if (statement.type === AST_NODE_TYPES96.TSExportAssignment) {
|
|
20489
|
+
collectExportValue(statement.expression, seeds);
|
|
20490
|
+
} else if (statement.type === AST_NODE_TYPES96.ExportDefaultDeclaration) {
|
|
20491
|
+
if (statement.declaration.type === AST_NODE_TYPES96.TSInterfaceDeclaration) seeds.roots.push(statement.declaration);
|
|
20492
|
+
else collectExportValue(statement.declaration, seeds);
|
|
20493
|
+
}
|
|
20494
|
+
}
|
|
20495
|
+
function collectNamedExport(statement, seeds) {
|
|
20496
|
+
const declaration = statement.declaration;
|
|
20497
|
+
if (declaration?.type === AST_NODE_TYPES96.TSTypeAliasDeclaration || declaration?.type === AST_NODE_TYPES96.TSInterfaceDeclaration) {
|
|
20498
|
+
seeds.roots.push(declaration);
|
|
20499
|
+
}
|
|
20500
|
+
if (isFunctionNode2(declaration)) seeds.callables.add(declaration);
|
|
20501
|
+
if (isSignatureNode(declaration)) seeds.signatures.add(declaration);
|
|
20502
|
+
if (declaration?.type === AST_NODE_TYPES96.VariableDeclaration) {
|
|
20503
|
+
for (const binding of declaration.declarations) {
|
|
20504
|
+
if (binding.id.type === AST_NODE_TYPES96.Identifier) seeds.values.push(binding.id);
|
|
20505
|
+
}
|
|
20506
|
+
}
|
|
20507
|
+
for (const specifier of statement.specifiers) {
|
|
20508
|
+
if (specifier.local.type !== AST_NODE_TYPES96.Identifier) continue;
|
|
20509
|
+
seeds.identifiers.push(specifier.local);
|
|
20510
|
+
seeds.values.push(specifier.local);
|
|
20511
|
+
}
|
|
20512
|
+
}
|
|
20513
|
+
function collectExportValue(node, seeds) {
|
|
20514
|
+
if (node.type === AST_NODE_TYPES96.Identifier) {
|
|
20515
|
+
seeds.identifiers.push(node);
|
|
20516
|
+
seeds.values.push(node);
|
|
20517
|
+
} else if (isSignatureNode(node)) {
|
|
20518
|
+
seeds.signatures.add(node);
|
|
20519
|
+
if (isFunctionNode2(node)) seeds.callables.add(node);
|
|
20520
|
+
}
|
|
20521
|
+
}
|
|
20522
|
+
function exportedValueAnnotation(source, identifier) {
|
|
20523
|
+
const definitions2 = valueBinding(source, identifier)?.defs.filter((definition) => definition.isVariableDefinition) ?? [];
|
|
20524
|
+
if (definitions2.length !== 1) return void 0;
|
|
20525
|
+
const declaration = definitions2[0]?.node;
|
|
20526
|
+
return declaration?.type === AST_NODE_TYPES96.VariableDeclarator && declaration.id.type === AST_NODE_TYPES96.Identifier ? declaration.id.typeAnnotation : void 0;
|
|
20527
|
+
}
|
|
20528
|
+
function isFunctionNode2(node) {
|
|
20529
|
+
return node?.type === AST_NODE_TYPES96.FunctionDeclaration || node?.type === AST_NODE_TYPES96.FunctionExpression || node?.type === AST_NODE_TYPES96.ArrowFunctionExpression;
|
|
20530
|
+
}
|
|
20531
|
+
function isSignatureNode(node) {
|
|
20532
|
+
return isFunctionNode2(node) || node?.type === AST_NODE_TYPES96.TSDeclareFunction;
|
|
20533
|
+
}
|
|
20534
|
+
function exportedCallable(source, identifier, cache) {
|
|
20535
|
+
const visited = /* @__PURE__ */ new Set();
|
|
20536
|
+
const annotations = [];
|
|
20537
|
+
let target = null;
|
|
20538
|
+
let current = identifier;
|
|
20539
|
+
while (current !== void 0) {
|
|
20540
|
+
const binding = valueBinding(source, current);
|
|
20541
|
+
if (binding === null || visited.has(binding)) break;
|
|
20542
|
+
if (cache.has(binding)) {
|
|
20543
|
+
target = cache.get(binding) ?? null;
|
|
20544
|
+
break;
|
|
20545
|
+
}
|
|
20546
|
+
visited.add(binding);
|
|
20547
|
+
const declared = declaredCallableTarget(binding);
|
|
20548
|
+
if (declared !== null) {
|
|
20549
|
+
target = declared;
|
|
20550
|
+
break;
|
|
20551
|
+
}
|
|
20552
|
+
const step = constantCallableStep(binding);
|
|
20553
|
+
if (step === null) break;
|
|
20554
|
+
if (step.annotation !== void 0) annotations.push(step.annotation);
|
|
20555
|
+
if (isFunctionNode2(step.target)) {
|
|
20556
|
+
target = { callable: step.target, signatures: [step.target] };
|
|
20557
|
+
break;
|
|
20558
|
+
}
|
|
20559
|
+
current = step.target?.type === AST_NODE_TYPES96.Identifier ? step.target : void 0;
|
|
20560
|
+
}
|
|
20561
|
+
for (const binding of visited) cache.set(binding, target);
|
|
20562
|
+
return target === null ? null : { ...target, annotations };
|
|
20563
|
+
}
|
|
20564
|
+
function declaredCallableTarget(binding) {
|
|
20565
|
+
const definitions2 = binding.defs.filter((definition) => definition.isVariableDefinition);
|
|
20566
|
+
const signatures = definitions2.flatMap((definition) => isSignatureNode(definition.node) ? [definition.node] : []);
|
|
20567
|
+
if (signatures.length === 0 || signatures.length !== definitions2.length) return null;
|
|
20568
|
+
const implementations = signatures.filter(isFunctionNode2);
|
|
20569
|
+
return implementations.length > 1 ? null : { callable: implementations[0] ?? null, signatures };
|
|
20570
|
+
}
|
|
20571
|
+
function constantCallableStep(binding) {
|
|
20572
|
+
const definitions2 = binding.defs.filter((definition) => definition.isVariableDefinition);
|
|
20573
|
+
if (definitions2.length !== 1) return null;
|
|
20574
|
+
const declaration = definitions2[0]?.node;
|
|
20575
|
+
if (declaration?.type !== AST_NODE_TYPES96.VariableDeclarator || declaration.parent.type !== AST_NODE_TYPES96.VariableDeclaration || declaration.parent.kind !== "const" || declaration.id.type !== AST_NODE_TYPES96.Identifier) return null;
|
|
20576
|
+
const initializer = declaration.init;
|
|
20577
|
+
return {
|
|
20578
|
+
target: isFunctionNode2(initializer) || initializer?.type === AST_NODE_TYPES96.Identifier ? initializer : null,
|
|
20579
|
+
annotation: declaration.id.typeAnnotation
|
|
20580
|
+
};
|
|
20581
|
+
}
|
|
20582
|
+
function valueBinding(source, identifier) {
|
|
20583
|
+
let scope = source.getScope(identifier);
|
|
20584
|
+
while (scope !== null) {
|
|
20585
|
+
const variable = scope.set.get(identifier.name);
|
|
20586
|
+
if (variable !== void 0 && (variable.isValueVariable || variable.defs.some((definition) => definition.isVariableDefinition))) return variable;
|
|
20587
|
+
scope = scope.upper;
|
|
20588
|
+
}
|
|
20589
|
+
return null;
|
|
20590
|
+
}
|
|
20591
|
+
function callableAnnotations(callable) {
|
|
20592
|
+
const annotations = [];
|
|
20593
|
+
if (callable.returnType !== void 0) annotations.push(callable.returnType);
|
|
20594
|
+
if (callable.typeParameters !== void 0) annotations.push(callable.typeParameters);
|
|
20595
|
+
for (const raw of callable.params) {
|
|
20596
|
+
const parameter = raw.type === AST_NODE_TYPES96.AssignmentPattern ? raw.left : raw;
|
|
20597
|
+
if ((parameter.type === AST_NODE_TYPES96.Identifier || parameter.type === AST_NODE_TYPES96.ObjectPattern || parameter.type === AST_NODE_TYPES96.ArrayPattern || parameter.type === AST_NODE_TYPES96.RestElement) && parameter.typeAnnotation !== void 0) annotations.push(parameter.typeAnnotation);
|
|
20598
|
+
}
|
|
20599
|
+
return annotations;
|
|
20600
|
+
}
|
|
20406
20601
|
function emptyArray(node) {
|
|
20407
20602
|
return node.type === AST_NODE_TYPES96.ArrayExpression && node.elements.length === 0;
|
|
20408
20603
|
}
|
|
@@ -20462,14 +20657,14 @@ function directlyCoalesced(node) {
|
|
|
20462
20657
|
return parent?.type === AST_NODE_TYPES96.LogicalExpression && parent.left === node && (parent.operator === "??" || parent.operator === "||") && emptyArray(parent.right);
|
|
20463
20658
|
}
|
|
20464
20659
|
function identifierIsOnlyCoalesced(context, binding, fn) {
|
|
20465
|
-
const variable =
|
|
20660
|
+
const variable = ASTUtils58.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
20466
20661
|
if (variable === null || variable.references.length === 0) return false;
|
|
20467
20662
|
return variable.references.every(
|
|
20468
20663
|
(reference) => belongsToFunction(reference.identifier, fn) && directlyCoalesced(reference.identifier)
|
|
20469
20664
|
);
|
|
20470
20665
|
}
|
|
20471
20666
|
function memberIsOnlyCoalesced(context, object, property, fn) {
|
|
20472
|
-
const variable =
|
|
20667
|
+
const variable = ASTUtils58.findVariable(context.sourceCode.getScope(object), object.name);
|
|
20473
20668
|
if (variable === null) return false;
|
|
20474
20669
|
const accesses = variable.references.flatMap((reference) => {
|
|
20475
20670
|
if (!belongsToFunction(reference.identifier, fn)) return [null];
|
|
@@ -20498,11 +20693,15 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
20498
20693
|
return {};
|
|
20499
20694
|
}
|
|
20500
20695
|
let shapes = /* @__PURE__ */ new Map();
|
|
20696
|
+
let publicCallables = /* @__PURE__ */ new Set();
|
|
20501
20697
|
const evidence = /* @__PURE__ */ new Map();
|
|
20502
20698
|
function propertiesFor(annotation) {
|
|
20503
|
-
if (annotation?.type === AST_NODE_TYPES96.TSTypeLiteral) return shapeProperties(annotation.members);
|
|
20699
|
+
if (annotation?.type === AST_NODE_TYPES96.TSTypeLiteral) return shapeProperties(annotation.members, context.sourceCode);
|
|
20504
20700
|
if (annotation?.type === AST_NODE_TYPES96.TSTypeReference && annotation.typeName.type === AST_NODE_TYPES96.Identifier) {
|
|
20505
|
-
const
|
|
20701
|
+
const definitions2 = typeBinding(context.sourceCode, annotation.typeName)?.defs.filter((definition) => definition.isTypeDefinition) ?? [];
|
|
20702
|
+
if (definitions2.length !== 1) return [];
|
|
20703
|
+
const declaration = definitions2[0]?.node;
|
|
20704
|
+
const shape = declaration === void 0 ? void 0 : shapes.get(declaration);
|
|
20506
20705
|
return shape?.exported === false ? shape.properties : [];
|
|
20507
20706
|
}
|
|
20508
20707
|
return [];
|
|
@@ -20513,6 +20712,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
20513
20712
|
evidence.set(property.node, values);
|
|
20514
20713
|
}
|
|
20515
20714
|
function checkFunction(fn) {
|
|
20715
|
+
if (publicCallables.has(fn)) return;
|
|
20516
20716
|
function checkParameter(rawParameter) {
|
|
20517
20717
|
const parameter = rawParameter.type === AST_NODE_TYPES96.AssignmentPattern ? rawParameter.left : rawParameter;
|
|
20518
20718
|
if (parameter.type === AST_NODE_TYPES96.ObjectPattern) {
|
|
@@ -20537,7 +20737,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
20537
20737
|
function checkDestructuredProperties(parameter, properties) {
|
|
20538
20738
|
for (const property of properties) {
|
|
20539
20739
|
const bindingProperty = parameter.properties.find(
|
|
20540
|
-
(entry) => entry.type === AST_NODE_TYPES96.Property && !entry.computed &&
|
|
20740
|
+
(entry) => entry.type === AST_NODE_TYPES96.Property && !entry.computed && ASTUtils58.getPropertyName(entry) === property.name
|
|
20541
20741
|
);
|
|
20542
20742
|
if (bindingProperty === void 0) continue;
|
|
20543
20743
|
const value = bindingProperty.value;
|
|
@@ -20563,7 +20763,9 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
20563
20763
|
}
|
|
20564
20764
|
return {
|
|
20565
20765
|
Program(node) {
|
|
20566
|
-
|
|
20766
|
+
const ownership = exportedOwnership(node, context.sourceCode);
|
|
20767
|
+
publicCallables = ownership.callables;
|
|
20768
|
+
shapes = typeIndex(node, context.sourceCode, ownership.declarations);
|
|
20567
20769
|
},
|
|
20568
20770
|
ArrowFunctionExpression: checkFunction,
|
|
20569
20771
|
FunctionDeclaration: checkFunction,
|
|
@@ -20585,7 +20787,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
20585
20787
|
// src/rules/prefer-nullish-filter-predicate.ts
|
|
20586
20788
|
import {
|
|
20587
20789
|
AST_NODE_TYPES as AST_NODE_TYPES97,
|
|
20588
|
-
ASTUtils as
|
|
20790
|
+
ASTUtils as ASTUtils59,
|
|
20589
20791
|
ESLintUtils as ESLintUtils17
|
|
20590
20792
|
} from "@typescript-eslint/utils";
|
|
20591
20793
|
import ts17 from "typescript";
|
|
@@ -20631,7 +20833,7 @@ var PREFER_NULLISH_FILTER_PREDICATE_DOCUMENTATION = {
|
|
|
20631
20833
|
]
|
|
20632
20834
|
};
|
|
20633
20835
|
function isUnshadowedBoolean(node, context) {
|
|
20634
|
-
const variable =
|
|
20836
|
+
const variable = ASTUtils59.findVariable(context.sourceCode.getScope(node), node.name);
|
|
20635
20837
|
return variable === null || variable.defs.length === 0;
|
|
20636
20838
|
}
|
|
20637
20839
|
function isBuiltinArrayFilter(node, services) {
|
|
@@ -20690,7 +20892,7 @@ function isProvablyTruthy(type, checker) {
|
|
|
20690
20892
|
}
|
|
20691
20893
|
function availableParameterName(node, context) {
|
|
20692
20894
|
for (const name of ["value", "item", "element", "candidate"]) {
|
|
20693
|
-
if (
|
|
20895
|
+
if (ASTUtils59.findVariable(context.sourceCode.getScope(node), name) === null) return name;
|
|
20694
20896
|
}
|
|
20695
20897
|
return null;
|
|
20696
20898
|
}
|
|
@@ -20721,7 +20923,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
20721
20923
|
CallExpression(node) {
|
|
20722
20924
|
const callee = unwrapExpression(node.callee);
|
|
20723
20925
|
const callback = node.arguments[0] === void 0 ? void 0 : unwrapExpression(node.arguments[0]);
|
|
20724
|
-
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES97.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES97.MemberExpression ||
|
|
20926
|
+
if (node.arguments.length !== 1 || callback?.type !== AST_NODE_TYPES97.Identifier || callback.name !== "Boolean" || callee.type !== AST_NODE_TYPES97.MemberExpression || ASTUtils59.getPropertyName(callee) === null || (ASTUtils59.getPropertyName(callee) ?? "") !== "filter" || !isUnshadowedBoolean(callback, context) || !isBuiltinArrayFilter(callee, services)) return;
|
|
20725
20927
|
const elementType = arrayElementType(callee.object, services);
|
|
20726
20928
|
const checker = services.program.getTypeChecker();
|
|
20727
20929
|
if (elementType === null || !isNullishPlusTruthy(elementType, checker)) return;
|
|
@@ -20744,7 +20946,7 @@ var prefer_nullish_filter_predicate_default = createRule({
|
|
|
20744
20946
|
|
|
20745
20947
|
// src/rules/prefer-await-in-async-return.ts
|
|
20746
20948
|
import {
|
|
20747
|
-
ASTUtils as
|
|
20949
|
+
ASTUtils as ASTUtils60,
|
|
20748
20950
|
ESLintUtils as ESLintUtils18,
|
|
20749
20951
|
AST_NODE_TYPES as AST_NODE_TYPES98
|
|
20750
20952
|
} from "@typescript-eslint/utils";
|
|
@@ -20807,7 +21009,7 @@ function isRuntimeFunction(node) {
|
|
|
20807
21009
|
}
|
|
20808
21010
|
function promiseThenReceiver(node) {
|
|
20809
21011
|
const callee = unwrapExpression(node.callee);
|
|
20810
|
-
if (callee.type !== AST_NODE_TYPES98.MemberExpression || callee.optional ||
|
|
21012
|
+
if (callee.type !== AST_NODE_TYPES98.MemberExpression || callee.optional || ASTUtils60.getPropertyName(callee) === null || (ASTUtils60.getPropertyName(callee) ?? "") !== "then" || node.optional || node.arguments.length !== 1) {
|
|
20811
21013
|
return null;
|
|
20812
21014
|
}
|
|
20813
21015
|
const argument = node.arguments[0];
|
|
@@ -20877,7 +21079,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
20877
21079
|
if (services === null) return {};
|
|
20878
21080
|
const frameworkLoaders = /* @__PURE__ */ new Set();
|
|
20879
21081
|
const rememberFrameworkLoader = (identifier) => {
|
|
20880
|
-
const variable =
|
|
21082
|
+
const variable = ASTUtils60.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
20881
21083
|
if (variable !== null) frameworkLoaders.add(variable);
|
|
20882
21084
|
};
|
|
20883
21085
|
const isFrameworkLoaderCallback = (owner) => {
|
|
@@ -20885,7 +21087,7 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
20885
21087
|
if (parent === null || parent.arguments[0] !== outerExpression(owner)) return false;
|
|
20886
21088
|
const callee = unwrapExpression(parent.callee);
|
|
20887
21089
|
if (callee.type !== AST_NODE_TYPES98.Identifier) return false;
|
|
20888
|
-
const variable =
|
|
21090
|
+
const variable = ASTUtils60.findVariable(context.sourceCode.getScope(callee), callee.name);
|
|
20889
21091
|
return variable !== null && frameworkLoaders.has(variable);
|
|
20890
21092
|
};
|
|
20891
21093
|
return {
|
|
@@ -20922,18 +21124,18 @@ var prefer_await_in_async_return_default = createRule({
|
|
|
20922
21124
|
});
|
|
20923
21125
|
|
|
20924
21126
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
20925
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES100, ASTUtils as
|
|
21127
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES100, ASTUtils as ASTUtils62 } from "@typescript-eslint/utils";
|
|
20926
21128
|
|
|
20927
21129
|
// src/rules/_native-fetch-reference.ts
|
|
20928
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES99, ASTUtils as
|
|
21130
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES99, ASTUtils as ASTUtils61 } from "@typescript-eslint/utils";
|
|
20929
21131
|
var GLOBAL_RECEIVERS3 = /* @__PURE__ */ new Set(["globalThis", "self", "window"]);
|
|
20930
21132
|
function nativeFetchReference(node, sourceCode, seen = /* @__PURE__ */ new Set()) {
|
|
20931
21133
|
const expression = unwrapExpression(node);
|
|
20932
21134
|
if (expression.type === AST_NODE_TYPES99.MemberExpression) {
|
|
20933
|
-
return
|
|
21135
|
+
return ASTUtils61.getPropertyName(expression) === "fetch" && globalReceiver(expression.object, sourceCode);
|
|
20934
21136
|
}
|
|
20935
21137
|
if (expression.type !== AST_NODE_TYPES99.Identifier) return false;
|
|
20936
|
-
const binding =
|
|
21138
|
+
const binding = ASTUtils61.findVariable(sourceCode.getScope(expression), expression.name);
|
|
20937
21139
|
if (binding === null || binding.defs.length === 0) return expression.name === "fetch";
|
|
20938
21140
|
if (seen.has(binding) || seen.size >= 8 || binding.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
20939
21141
|
seen.add(binding);
|
|
@@ -20942,11 +21144,11 @@ function nativeFetchReference(node, sourceCode, seen = /* @__PURE__ */ new Set()
|
|
|
20942
21144
|
if (definition.node.id.type === AST_NODE_TYPES99.Identifier) {
|
|
20943
21145
|
return nativeFetchReference(definition.node.init, sourceCode, seen);
|
|
20944
21146
|
}
|
|
20945
|
-
return definition.node.id.type === AST_NODE_TYPES99.ObjectPattern && globalReceiver(definition.node.init, sourceCode) && definition.node.id.properties.some((property) => property.type === AST_NODE_TYPES99.Property &&
|
|
21147
|
+
return definition.node.id.type === AST_NODE_TYPES99.ObjectPattern && globalReceiver(definition.node.init, sourceCode) && definition.node.id.properties.some((property) => property.type === AST_NODE_TYPES99.Property && ASTUtils61.getPropertyName(property) === "fetch" && property.value.type === AST_NODE_TYPES99.Identifier && ASTUtils61.findVariable(sourceCode.getScope(property.value), property.value.name) === binding);
|
|
20946
21148
|
}
|
|
20947
21149
|
function globalReceiver(node, sourceCode) {
|
|
20948
21150
|
const receiver = unwrapExpression(node);
|
|
20949
|
-
return receiver.type === AST_NODE_TYPES99.Identifier && GLOBAL_RECEIVERS3.has(receiver.name) && !
|
|
21151
|
+
return receiver.type === AST_NODE_TYPES99.Identifier && GLOBAL_RECEIVERS3.has(receiver.name) && !ASTUtils61.findVariable(sourceCode.getScope(receiver), receiver.name)?.defs.length;
|
|
20950
21152
|
}
|
|
20951
21153
|
|
|
20952
21154
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
@@ -20986,7 +21188,7 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
20986
21188
|
]);
|
|
20987
21189
|
var isSchemaParseReference = (node) => {
|
|
20988
21190
|
const inner = unwrap5(node);
|
|
20989
|
-
return inner !== null && inner.type === AST_NODE_TYPES100.MemberExpression &&
|
|
21191
|
+
return inner !== null && inner.type === AST_NODE_TYPES100.MemberExpression && ASTUtils62.getPropertyName(inner) !== null && ((ASTUtils62.getPropertyName(inner) ?? "") === "parse" || (ASTUtils62.getPropertyName(inner) ?? "") === "safeParse");
|
|
20990
21192
|
};
|
|
20991
21193
|
var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
20992
21194
|
let current = unwrap5(node);
|
|
@@ -21001,7 +21203,7 @@ var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
|
21001
21203
|
if (callee === null || callee.type !== AST_NODE_TYPES100.MemberExpression) {
|
|
21002
21204
|
return false;
|
|
21003
21205
|
}
|
|
21004
|
-
const property =
|
|
21206
|
+
const property = ASTUtils62.getPropertyName(callee);
|
|
21005
21207
|
if (property === null) {
|
|
21006
21208
|
return false;
|
|
21007
21209
|
}
|
|
@@ -21013,19 +21215,19 @@ var isRawPayloadSource = (node, context, isKnownLocalText) => {
|
|
|
21013
21215
|
}
|
|
21014
21216
|
const object = unwrap5(callee.object);
|
|
21015
21217
|
const input = unwrap5(current.arguments[0]);
|
|
21016
|
-
if (input?.type === AST_NODE_TYPES100.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES100.MemberExpression && input.callee.object.type === AST_NODE_TYPES100.Identifier && input.callee.object.name === "JSON" &&
|
|
21017
|
-
return property === "parse" && object !== null && object.type === AST_NODE_TYPES100.Identifier && object.name === "JSON" && (
|
|
21218
|
+
if (input?.type === AST_NODE_TYPES100.CallExpression && input.arguments.length === 1 && input.callee.type === AST_NODE_TYPES100.MemberExpression && input.callee.object.type === AST_NODE_TYPES100.Identifier && input.callee.object.name === "JSON" && ASTUtils62.getPropertyName(input.callee) === "stringify" && (ASTUtils62.findVariable(context.sourceCode.getScope(input.callee.object), "JSON")?.defs.length ?? 0) === 0) return false;
|
|
21219
|
+
return property === "parse" && object !== null && object.type === AST_NODE_TYPES100.Identifier && object.name === "JSON" && (ASTUtils62.findVariable(context.sourceCode.getScope(object), "JSON")?.defs.length ?? 0) === 0 && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
21018
21220
|
};
|
|
21019
21221
|
var isResponseSource = (node, context, seen = /* @__PURE__ */ new Set()) => {
|
|
21020
21222
|
let current = unwrap5(node);
|
|
21021
21223
|
if (current?.type === AST_NODE_TYPES100.AwaitExpression) current = unwrap5(current.argument);
|
|
21022
21224
|
if (current === null || seen.has(current)) return false;
|
|
21023
21225
|
seen.add(current);
|
|
21024
|
-
const isGlobal = (identifier) => (
|
|
21226
|
+
const isGlobal = (identifier) => (ASTUtils62.findVariable(context.sourceCode.getScope(identifier), identifier.name)?.defs.length ?? 0) === 0;
|
|
21025
21227
|
if (current.type === AST_NODE_TYPES100.CallExpression) return nativeFetchReference(current.callee, context.sourceCode);
|
|
21026
21228
|
if (current.type === AST_NODE_TYPES100.NewExpression) return current.callee.type === AST_NODE_TYPES100.Identifier && ["Request", "Response"].includes(current.callee.name) && isGlobal(current.callee);
|
|
21027
21229
|
if (current.type !== AST_NODE_TYPES100.Identifier) return false;
|
|
21028
|
-
const binding =
|
|
21230
|
+
const binding = ASTUtils62.findVariable(context.sourceCode.getScope(current), current.name);
|
|
21029
21231
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
21030
21232
|
const definition = binding.defs[0];
|
|
21031
21233
|
const annotation = definition?.name.type === AST_NODE_TYPES100.Identifier ? definition.name.typeAnnotation?.typeAnnotation : void 0;
|
|
@@ -21040,7 +21242,7 @@ var isDirectLocalFileRead = (node) => {
|
|
|
21040
21242
|
}
|
|
21041
21243
|
if (current?.type !== AST_NODE_TYPES100.CallExpression) return false;
|
|
21042
21244
|
const callee = unwrap5(current.callee);
|
|
21043
|
-
const name = callee?.type === AST_NODE_TYPES100.Identifier ? callee.name : callee?.type === AST_NODE_TYPES100.MemberExpression &&
|
|
21245
|
+
const name = callee?.type === AST_NODE_TYPES100.Identifier ? callee.name : callee?.type === AST_NODE_TYPES100.MemberExpression && ASTUtils62.getPropertyName(callee) !== null ? ASTUtils62.getPropertyName(callee) ?? "" : null;
|
|
21044
21246
|
return name !== null && FILE_READ_RE.test(name);
|
|
21045
21247
|
};
|
|
21046
21248
|
var isLocalFileRead = (node) => {
|
|
@@ -21101,7 +21303,7 @@ var isValidationRead = (node) => {
|
|
|
21101
21303
|
return false;
|
|
21102
21304
|
}
|
|
21103
21305
|
const callee = parent.callee;
|
|
21104
|
-
if (callee.type === AST_NODE_TYPES100.MemberExpression && callee.object.type === AST_NODE_TYPES100.Identifier && callee.object.name === "Array" &&
|
|
21306
|
+
if (callee.type === AST_NODE_TYPES100.MemberExpression && callee.object.type === AST_NODE_TYPES100.Identifier && callee.object.name === "Array" && ASTUtils62.getPropertyName(callee) === "isArray") {
|
|
21105
21307
|
return parent.arguments.length === 1;
|
|
21106
21308
|
}
|
|
21107
21309
|
return callee.type === AST_NODE_TYPES100.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
@@ -21129,11 +21331,11 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
21129
21331
|
}
|
|
21130
21332
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
21131
21333
|
}
|
|
21132
|
-
return test.type === AST_NODE_TYPES100.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES100.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES100.MemberExpression && test.callee.object.type === AST_NODE_TYPES100.Identifier && test.callee.object.name === "Array" &&
|
|
21334
|
+
return test.type === AST_NODE_TYPES100.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === AST_NODE_TYPES100.Identifier && test.arguments[0].name === bindingName && test.callee.type === AST_NODE_TYPES100.MemberExpression && test.callee.object.type === AST_NODE_TYPES100.Identifier && test.callee.object.name === "Array" && ASTUtils62.getPropertyName(test.callee) === "isArray" ? "valid-when-true" : null;
|
|
21133
21335
|
};
|
|
21134
21336
|
var plainMemberAccess = (node) => {
|
|
21135
21337
|
if (node.type !== AST_NODE_TYPES100.MemberExpression || node.object.type !== AST_NODE_TYPES100.Identifier) return null;
|
|
21136
|
-
const property =
|
|
21338
|
+
const property = ASTUtils62.getPropertyName(node);
|
|
21137
21339
|
return property === null ? null : { object: node.object.name, property };
|
|
21138
21340
|
};
|
|
21139
21341
|
var isSamePlainMember = (node, access) => {
|
|
@@ -21197,7 +21399,7 @@ var memberValidationPolarity = (test, access) => {
|
|
|
21197
21399
|
}
|
|
21198
21400
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
21199
21401
|
}
|
|
21200
|
-
return test.type === AST_NODE_TYPES100.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES100.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES100.MemberExpression && test.callee.object.type === AST_NODE_TYPES100.Identifier && test.callee.object.name === "Array" &&
|
|
21402
|
+
return test.type === AST_NODE_TYPES100.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== AST_NODE_TYPES100.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === AST_NODE_TYPES100.MemberExpression && test.callee.object.type === AST_NODE_TYPES100.Identifier && test.callee.object.name === "Array" && ASTUtils62.getPropertyName(test.callee) === "isArray" ? "valid-when-true" : null;
|
|
21201
21403
|
};
|
|
21202
21404
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
21203
21405
|
const isValidationReference = (identifier) => {
|
|
@@ -21480,7 +21682,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
21480
21682
|
(candidate2) => localFileTextRef(candidate2, scope) !== null
|
|
21481
21683
|
)) {
|
|
21482
21684
|
const parent = node.parent;
|
|
21483
|
-
const method =
|
|
21685
|
+
const method = ASTUtils62.getPropertyName(node);
|
|
21484
21686
|
if (parent.type === AST_NODE_TYPES100.CallExpression && parent.callee === node && method !== null && (method === "parse" || method === "safeParse" || PROMISE_CHAIN_METHODS.has(method))) {
|
|
21485
21687
|
return;
|
|
21486
21688
|
}
|
|
@@ -21533,7 +21735,7 @@ function ifGuardDominates(use, branch, positive) {
|
|
|
21533
21735
|
}
|
|
21534
21736
|
|
|
21535
21737
|
// src/rules/prefer-shared-zod-enum.ts
|
|
21536
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES101, ASTUtils as
|
|
21738
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES101, ASTUtils as ASTUtils63 } from "@typescript-eslint/utils";
|
|
21537
21739
|
var PREFER_SHARED_ZOD_ENUM_DOCUMENTATION = {
|
|
21538
21740
|
defaultLevel: "warning",
|
|
21539
21741
|
summary: "Give repeated literal Zod enum domains one reusable module-level schema.",
|
|
@@ -21584,7 +21786,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
21584
21786
|
create(context) {
|
|
21585
21787
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
21586
21788
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
21587
|
-
const bindingOf = (node) =>
|
|
21789
|
+
const bindingOf = (node) => ASTUtils63.findVariable(context.sourceCode.getScope(node), node.name);
|
|
21588
21790
|
const candidates = /* @__PURE__ */ new Map();
|
|
21589
21791
|
return {
|
|
21590
21792
|
ImportDeclaration(node) {
|
|
@@ -21599,7 +21801,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
21599
21801
|
CallExpression(node) {
|
|
21600
21802
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
21601
21803
|
const receiver = unwrappedNodeCallee.type === AST_NODE_TYPES101.MemberExpression ? unwrapExpression(unwrappedNodeCallee.object) : unwrappedNodeCallee;
|
|
21602
|
-
if (unwrappedNodeCallee.type !== AST_NODE_TYPES101.MemberExpression || receiver.type !== AST_NODE_TYPES101.Identifier ||
|
|
21804
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES101.MemberExpression || receiver.type !== AST_NODE_TYPES101.Identifier || ASTUtils63.getPropertyName(unwrappedNodeCallee) === null || (ASTUtils63.getPropertyName(unwrappedNodeCallee) ?? "") !== "enum") return;
|
|
21603
21805
|
const binding = bindingOf(receiver);
|
|
21604
21806
|
if (binding === null || !zodBindings.has(binding)) return;
|
|
21605
21807
|
const domain = literalDomain(node);
|
|
@@ -21624,7 +21826,7 @@ var prefer_shared_zod_enum_default = createRule({
|
|
|
21624
21826
|
});
|
|
21625
21827
|
|
|
21626
21828
|
// src/rules/prefer-switch-for-repeated-equality.ts
|
|
21627
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES102, ASTUtils as
|
|
21829
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES102, ASTUtils as ASTUtils64 } from "@typescript-eslint/utils";
|
|
21628
21830
|
var PREFER_SWITCH_FOR_REPEATED_EQUALITY_DOCUMENTATION = {
|
|
21629
21831
|
defaultLevel: "error",
|
|
21630
21832
|
summary: "Prefer switch over long if/else-if chains that compare one value for strict equality.",
|
|
@@ -21676,7 +21878,7 @@ var prefer_switch_for_repeated_equality_default = createRule({
|
|
|
21676
21878
|
if (node.parent.type === AST_NODE_TYPES102.IfStatement && node.parent.alternate === node) return;
|
|
21677
21879
|
const first = discriminantName(node.test);
|
|
21678
21880
|
if (first === null) return;
|
|
21679
|
-
const binding =
|
|
21881
|
+
const binding = ASTUtils64.findVariable(context.sourceCode.getScope(node), first);
|
|
21680
21882
|
if (binding === null || binding.defs.length !== 1 || binding.scope.type === "global") return;
|
|
21681
21883
|
const [definition] = binding.defs;
|
|
21682
21884
|
if (definition?.type !== "Parameter" && definition?.type !== "Variable") return;
|
|
@@ -22223,7 +22425,7 @@ function packageWorkspaceGlobs(parsed) {
|
|
|
22223
22425
|
}
|
|
22224
22426
|
|
|
22225
22427
|
// src/rules/prefer-server-actions.ts
|
|
22226
|
-
import { ASTUtils as
|
|
22428
|
+
import { ASTUtils as ASTUtils65 } from "@typescript-eslint/utils";
|
|
22227
22429
|
var PREFER_SERVER_ACTIONS_DOCUMENTATION = {
|
|
22228
22430
|
summary: "Prefer Next.js Server Actions over same-origin API mutations.",
|
|
22229
22431
|
rationale: "Server Actions can remove a hand-written internal API wrapper while retaining typed application calls. Client invocations still cross a network and serialization boundary.",
|
|
@@ -22256,7 +22458,7 @@ function resolveNode(node, context) {
|
|
|
22256
22458
|
node = node == null ? node : unwrapExpression(node);
|
|
22257
22459
|
if (!node) return null;
|
|
22258
22460
|
if (node.type !== "Identifier") return node;
|
|
22259
|
-
const variable =
|
|
22461
|
+
const variable = ASTUtils65.findVariable(getScope(context, node), node.name);
|
|
22260
22462
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
22261
22463
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return node;
|
|
22262
22464
|
if (definition.node.init.type === "ObjectExpression" && variable?.references.some((reference) => reference.identifier !== node && reference.init !== true)) return node;
|
|
@@ -22265,7 +22467,7 @@ function resolveNode(node, context) {
|
|
|
22265
22467
|
function isAxiosClient(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
22266
22468
|
if (node.type !== "Identifier" || seen.has(node)) return false;
|
|
22267
22469
|
seen.add(node);
|
|
22268
|
-
const variable =
|
|
22470
|
+
const variable = ASTUtils65.findVariable(getScope(context, node), node.name);
|
|
22269
22471
|
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
22270
22472
|
if (definition === void 0 || variable?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
22271
22473
|
if (variable?.references.some((reference) => {
|
|
@@ -22349,10 +22551,10 @@ function isFunctionArgument(node, context) {
|
|
|
22349
22551
|
}
|
|
22350
22552
|
function getPropertyNode(objNode, propName2) {
|
|
22351
22553
|
if (!objNode || objNode.type !== "ObjectExpression") return null;
|
|
22352
|
-
if (objNode.properties.some((property) => property.type === "SpreadElement" ||
|
|
22554
|
+
if (objNode.properties.some((property) => property.type === "SpreadElement" || ASTUtils65.getPropertyName(property) === null)) return null;
|
|
22353
22555
|
for (const prop of [...objNode.properties].reverse()) {
|
|
22354
22556
|
if (prop.type !== "Property") continue;
|
|
22355
|
-
const keyName =
|
|
22557
|
+
const keyName = ASTUtils65.getPropertyName(prop);
|
|
22356
22558
|
if (keyName === propName2) {
|
|
22357
22559
|
if (prop.value.type === "AssignmentPattern" || prop.value.type === "ArrayPattern" || prop.value.type === "ObjectPattern") {
|
|
22358
22560
|
return null;
|
|
@@ -22476,7 +22678,7 @@ var prefer_server_actions_default = createRule({
|
|
|
22476
22678
|
});
|
|
22477
22679
|
|
|
22478
22680
|
// src/rules/prefer-whole-object-assertion.ts
|
|
22479
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES104, ASTUtils as
|
|
22681
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES104, ASTUtils as ASTUtils66 } from "@typescript-eslint/utils";
|
|
22480
22682
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
22481
22683
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
22482
22684
|
["toBeNull", "null"]
|
|
@@ -22543,7 +22745,7 @@ function propertyAccess(node) {
|
|
|
22543
22745
|
const path = [];
|
|
22544
22746
|
let current = node;
|
|
22545
22747
|
while (current.type === AST_NODE_TYPES104.MemberExpression && !current.optional) {
|
|
22546
|
-
const name =
|
|
22748
|
+
const name = ASTUtils66.getPropertyName(current);
|
|
22547
22749
|
if (name === null || COLLECTION_PROPERTIES.has(name) || LITERAL_KEY_HAZARDS.has(name)) return null;
|
|
22548
22750
|
path.unshift(name);
|
|
22549
22751
|
current = unwrapExpression(current.object);
|
|
@@ -22693,7 +22895,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
22693
22895
|
const callee = unwrapExpression(call.callee);
|
|
22694
22896
|
const calleeReceiver = callee.type === AST_NODE_TYPES104.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
22695
22897
|
if (callee.type !== AST_NODE_TYPES104.MemberExpression) return null;
|
|
22696
|
-
const matcher =
|
|
22898
|
+
const matcher = ASTUtils66.getPropertyName(callee);
|
|
22697
22899
|
if (matcher === null) return null;
|
|
22698
22900
|
const expectCall = calleeReceiver;
|
|
22699
22901
|
const expectCallee = expectCall.type === AST_NODE_TYPES104.CallExpression ? unwrapExpression(expectCall.callee) : null;
|
|
@@ -22730,7 +22932,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
22730
22932
|
const call = statement.expression;
|
|
22731
22933
|
const callee = unwrapExpression(call.callee);
|
|
22732
22934
|
if (callee.type !== AST_NODE_TYPES104.MemberExpression || call.arguments.length !== 1) return false;
|
|
22733
|
-
const matcher =
|
|
22935
|
+
const matcher = ASTUtils66.getPropertyName(callee);
|
|
22734
22936
|
const assertion = unwrapExpression(callee.object);
|
|
22735
22937
|
if (assertion.type !== AST_NODE_TYPES104.CallExpression || assertion.arguments.length !== 1) return false;
|
|
22736
22938
|
const expect = unwrapExpression(assertion.callee);
|
|
@@ -22739,7 +22941,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
22739
22941
|
if (expected?.type !== AST_NODE_TYPES104.Literal || typeof expected.value !== "number" || !Number.isInteger(expected.value) || expected.value < 0) return false;
|
|
22740
22942
|
let actual = assertion.arguments[0] === void 0 ? void 0 : unwrapExpression(assertion.arguments[0]);
|
|
22741
22943
|
if (matcher !== "toHaveLength") {
|
|
22742
|
-
if (matcher === null || !MERGEABLE_MATCHERS.has(matcher) || actual?.type !== AST_NODE_TYPES104.MemberExpression || actual.optional ||
|
|
22944
|
+
if (matcher === null || !MERGEABLE_MATCHERS.has(matcher) || actual?.type !== AST_NODE_TYPES104.MemberExpression || actual.optional || ASTUtils66.getPropertyName(actual) !== "length") return false;
|
|
22743
22945
|
actual = unwrapExpression(actual.object);
|
|
22744
22946
|
}
|
|
22745
22947
|
return actual !== void 0 && sourceCode.getText(actual) === sourceCode.getText(receiver);
|
|
@@ -22778,7 +22980,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
22778
22980
|
});
|
|
22779
22981
|
|
|
22780
22982
|
// src/rules/repeated-static-call-cases.ts
|
|
22781
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES105, ASTUtils as
|
|
22983
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES105, ASTUtils as ASTUtils67 } from "@typescript-eslint/utils";
|
|
22782
22984
|
var REPEATED_STATIC_CALL_CASES_DOCUMENTATION = {
|
|
22783
22985
|
summary: "Review three or more consecutive static-input call assertions as potential named cases.",
|
|
22784
22986
|
rationale: "Copy-pasted cases obscure the input table, and a thrown assertion can stop later cases from being reported.",
|
|
@@ -22799,7 +23001,7 @@ var EXPECT_MODIFIERS = /* @__PURE__ */ new Set(["not", "rejects", "resolves"]);
|
|
|
22799
23001
|
var SNAPSHOT_MATCHERS = /snapshot/iu;
|
|
22800
23002
|
var MIN_CASES2 = 3;
|
|
22801
23003
|
function importedName6(identifier, context, modules) {
|
|
22802
|
-
const variable =
|
|
23004
|
+
const variable = ASTUtils67.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
22803
23005
|
if (variable === null || variable.defs.length === 0) return identifier.name;
|
|
22804
23006
|
for (const definition of variable.defs) {
|
|
22805
23007
|
if (definition.node.type !== AST_NODE_TYPES105.ImportSpecifier) continue;
|
|
@@ -22821,7 +23023,7 @@ function testRoot2(callee) {
|
|
|
22821
23023
|
callee = unwrapExpression(callee);
|
|
22822
23024
|
if (callee.type === AST_NODE_TYPES105.Identifier) return callee;
|
|
22823
23025
|
if (callee.type !== AST_NODE_TYPES105.MemberExpression) return null;
|
|
22824
|
-
const modifier =
|
|
23026
|
+
const modifier = ASTUtils67.getPropertyName(callee);
|
|
22825
23027
|
return modifier !== null && TEST_MODIFIERS5.has(modifier) ? testRoot2(callee.object) : null;
|
|
22826
23028
|
}
|
|
22827
23029
|
function isStatic(input) {
|
|
@@ -22867,8 +23069,8 @@ function assertionShape(statement, context, callback) {
|
|
|
22867
23069
|
const matcherCall = unwrapExpression(statement.expression);
|
|
22868
23070
|
if (matcherCall.type !== AST_NODE_TYPES105.CallExpression) return null;
|
|
22869
23071
|
const matcherCallee = unwrapExpression(matcherCall.callee);
|
|
22870
|
-
if (matcherCallee.type !== AST_NODE_TYPES105.MemberExpression ||
|
|
22871
|
-
const matcher =
|
|
23072
|
+
if (matcherCallee.type !== AST_NODE_TYPES105.MemberExpression || ASTUtils67.getPropertyName(matcherCallee) === null || matcherCall.arguments.length !== 1) return null;
|
|
23073
|
+
const matcher = ASTUtils67.getPropertyName(matcherCallee) ?? "";
|
|
22872
23074
|
if (SNAPSHOT_MATCHERS.test(matcher)) return null;
|
|
22873
23075
|
const chain = expectCallFromMatcher(matcherCallee);
|
|
22874
23076
|
const expectCallee = chain === null ? null : unwrapExpression(chain.call.callee);
|
|
@@ -22878,7 +23080,7 @@ function assertionShape(statement, context, callback) {
|
|
|
22878
23080
|
const observedCallee = observed?.type === AST_NODE_TYPES105.CallExpression ? unwrapExpression(observed.callee) : null;
|
|
22879
23081
|
if (observed?.type !== AST_NODE_TYPES105.CallExpression || observedCallee?.type !== AST_NODE_TYPES105.Identifier || observed.arguments.length === 0 || observed.arguments.some((arg) => arg.type === AST_NODE_TYPES105.SpreadElement || !isStatic(arg)) || expected?.type === AST_NODE_TYPES105.SpreadElement || expected === void 0 || !isStatic(expected)) return null;
|
|
22880
23082
|
const skeleton = `${observedCallee.name}/${observed.arguments.map((item) => staticShape(item)).join(",")}/${chain.modifiers.join(".")}/${matcher}/${staticShape(expected)}`;
|
|
22881
|
-
const binding =
|
|
23083
|
+
const binding = ASTUtils67.findVariable(context.sourceCode.getScope(observedCallee), observedCallee.name);
|
|
22882
23084
|
if (binding?.defs.some(
|
|
22883
23085
|
(definition) => definition.node.range[0] >= callback.range[0] && definition.node.range[1] <= callback.range[1]
|
|
22884
23086
|
)) return null;
|
|
@@ -22889,7 +23091,7 @@ function expectCallFromMatcher(node) {
|
|
|
22889
23091
|
const modifiers = [];
|
|
22890
23092
|
let receiver = node.object;
|
|
22891
23093
|
while (receiver.type === AST_NODE_TYPES105.MemberExpression) {
|
|
22892
|
-
const modifier =
|
|
23094
|
+
const modifier = ASTUtils67.getPropertyName(receiver);
|
|
22893
23095
|
if (modifier === null || !EXPECT_MODIFIERS.has(modifier)) return null;
|
|
22894
23096
|
modifiers.unshift(modifier);
|
|
22895
23097
|
receiver = receiver.object;
|
|
@@ -22965,7 +23167,7 @@ var repeated_static_call_cases_default = createRule({
|
|
|
22965
23167
|
});
|
|
22966
23168
|
|
|
22967
23169
|
// src/rules/prefer-zod-infer.ts
|
|
22968
|
-
import { ASTUtils as
|
|
23170
|
+
import { ASTUtils as ASTUtils68, AST_NODE_TYPES as AST_NODE_TYPES106 } from "@typescript-eslint/utils";
|
|
22969
23171
|
var PREFER_ZOD_INFER_DOCUMENTATION = {
|
|
22970
23172
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
22971
23173
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -23283,7 +23485,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
23283
23485
|
while (current.type === AST_NODE_TYPES106.CallExpression) {
|
|
23284
23486
|
const callee = unwrapExpression(current.callee);
|
|
23285
23487
|
const calleeReceiver = callee.type === AST_NODE_TYPES106.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
23286
|
-
if (callee.type !== AST_NODE_TYPES106.MemberExpression ||
|
|
23488
|
+
if (callee.type !== AST_NODE_TYPES106.MemberExpression || ASTUtils68.getPropertyName(callee) === null) {
|
|
23287
23489
|
return null;
|
|
23288
23490
|
}
|
|
23289
23491
|
chain.push(current);
|
|
@@ -23296,7 +23498,7 @@ function twinCallChain(node, zodNamespaces) {
|
|
|
23296
23498
|
}
|
|
23297
23499
|
function twinMethodName(call) {
|
|
23298
23500
|
const callee = unwrapExpression(call.callee);
|
|
23299
|
-
return callee.type === AST_NODE_TYPES106.MemberExpression &&
|
|
23501
|
+
return callee.type === AST_NODE_TYPES106.MemberExpression && ASTUtils68.getPropertyName(callee) !== null ? ASTUtils68.getPropertyName(callee) ?? "" : "";
|
|
23300
23502
|
}
|
|
23301
23503
|
function twinSchemaFields(initializer, zodNamespaces) {
|
|
23302
23504
|
const chain = twinCallChain(initializer, zodNamespaces);
|
|
@@ -23311,7 +23513,7 @@ function twinSchemaFields(initializer, zodNamespaces) {
|
|
|
23311
23513
|
const fields = /* @__PURE__ */ new Map();
|
|
23312
23514
|
for (const property of shape.properties) {
|
|
23313
23515
|
if (property.type !== AST_NODE_TYPES106.Property) return null;
|
|
23314
|
-
const name =
|
|
23516
|
+
const name = ASTUtils68.getPropertyName(property);
|
|
23315
23517
|
if (name === null) return null;
|
|
23316
23518
|
fields.set(name, twinSchemaField(property.value, zodNamespaces));
|
|
23317
23519
|
}
|
|
@@ -23325,16 +23527,16 @@ function twinSchemaField(node, zodNamespaces) {
|
|
|
23325
23527
|
while (current.type === AST_NODE_TYPES106.CallExpression) {
|
|
23326
23528
|
const callee = unwrapExpression(current.callee);
|
|
23327
23529
|
const calleeReceiver = callee.type === AST_NODE_TYPES106.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
23328
|
-
if (callee.type !== AST_NODE_TYPES106.MemberExpression ||
|
|
23530
|
+
if (callee.type !== AST_NODE_TYPES106.MemberExpression || ASTUtils68.getPropertyName(callee) === null) {
|
|
23329
23531
|
break;
|
|
23330
23532
|
}
|
|
23331
23533
|
const receiver = calleeReceiver;
|
|
23332
23534
|
if (receiver.type === AST_NODE_TYPES106.Identifier && zodNamespaces.has(receiver.name)) {
|
|
23333
|
-
leaf =
|
|
23535
|
+
leaf = ASTUtils68.getPropertyName(callee) ?? "";
|
|
23334
23536
|
leafCall = current;
|
|
23335
23537
|
break;
|
|
23336
23538
|
}
|
|
23337
|
-
modifiers.push(
|
|
23539
|
+
modifiers.push(ASTUtils68.getPropertyName(callee) ?? "");
|
|
23338
23540
|
current = receiver;
|
|
23339
23541
|
}
|
|
23340
23542
|
return {
|
|
@@ -23537,7 +23739,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
23537
23739
|
},
|
|
23538
23740
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
23539
23741
|
"MemberExpression"(node) {
|
|
23540
|
-
if (node.object.type === AST_NODE_TYPES106.Identifier &&
|
|
23742
|
+
if (node.object.type === AST_NODE_TYPES106.Identifier && ASTUtils68.getPropertyName(node) !== null && isPreferZodInferModuleReshaper(ASTUtils68.getPropertyName(node) ?? "")) {
|
|
23541
23743
|
reshapedSchemaNames.add(node.object.name);
|
|
23542
23744
|
}
|
|
23543
23745
|
},
|
|
@@ -23694,7 +23896,7 @@ function staticFieldName(key) {
|
|
|
23694
23896
|
}
|
|
23695
23897
|
|
|
23696
23898
|
// src/rules/named-child-schema-type.ts
|
|
23697
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES107, ASTUtils as
|
|
23899
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES107, ASTUtils as ASTUtils69 } from "@typescript-eslint/utils";
|
|
23698
23900
|
var UNRESOLVED_TYPE_NODES = /* @__PURE__ */ new Set([
|
|
23699
23901
|
AST_NODE_TYPES107.TSTypeQuery,
|
|
23700
23902
|
AST_NODE_TYPES107.TSImportType,
|
|
@@ -23739,7 +23941,7 @@ var named_child_schema_type_default = createRule({
|
|
|
23739
23941
|
const source = context.sourceCode;
|
|
23740
23942
|
if (isGeneratedFile(context.filename, source.text)) return {};
|
|
23741
23943
|
const namespaces = /* @__PURE__ */ new Set();
|
|
23742
|
-
const bindingOf = (node) =>
|
|
23944
|
+
const bindingOf = (node) => ASTUtils69.findVariable(source.getScope(node), node.name);
|
|
23743
23945
|
function namespaceOf(type) {
|
|
23744
23946
|
if (type.typeName.type !== AST_NODE_TYPES107.TSQualifiedName || type.typeName.left.type !== AST_NODE_TYPES107.Identifier) return null;
|
|
23745
23947
|
const binding = bindingOf(type.typeName.left);
|
|
@@ -23783,7 +23985,7 @@ var named_child_schema_type_default = createRule({
|
|
|
23783
23985
|
VariableDeclarator(node) {
|
|
23784
23986
|
if (!isModuleConst(node) || node.id.type !== AST_NODE_TYPES107.Identifier || node.init?.type !== AST_NODE_TYPES107.CallExpression) return;
|
|
23785
23987
|
const call = node.init;
|
|
23786
|
-
if (call.arguments.length !== 2 || call.callee.type !== AST_NODE_TYPES107.MemberExpression || call.callee.object.type !== AST_NODE_TYPES107.Identifier ||
|
|
23988
|
+
if (call.arguments.length !== 2 || call.callee.type !== AST_NODE_TYPES107.MemberExpression || call.callee.object.type !== AST_NODE_TYPES107.Identifier || ASTUtils69.getPropertyName(call.callee) !== "record") return;
|
|
23787
23989
|
const annotation = node.id.typeAnnotation?.typeAnnotation;
|
|
23788
23990
|
if (annotation?.type !== AST_NODE_TYPES107.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES107.TSQualifiedName || annotation.typeName.right.name !== "ZodRecord") return;
|
|
23789
23991
|
const namespace = namespaceOf(annotation);
|
|
@@ -23799,7 +24001,7 @@ var named_child_schema_type_default = createRule({
|
|
|
23799
24001
|
|
|
23800
24002
|
// src/rules/prefer-zod-parse-output-type.ts
|
|
23801
24003
|
import {
|
|
23802
|
-
ASTUtils as
|
|
24004
|
+
ASTUtils as ASTUtils70,
|
|
23803
24005
|
AST_NODE_TYPES as AST_NODE_TYPES108,
|
|
23804
24006
|
ESLintUtils as ESLintUtils19
|
|
23805
24007
|
} from "@typescript-eslint/utils";
|
|
@@ -24046,11 +24248,11 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
24046
24248
|
while (current.type === AST_NODE_TYPES108.CallExpression) {
|
|
24047
24249
|
const callee = unwrapExpression(current.callee);
|
|
24048
24250
|
const calleeReceiver = callee.type === AST_NODE_TYPES108.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24049
|
-
if (callee.type !== AST_NODE_TYPES108.MemberExpression ||
|
|
24251
|
+
if (callee.type !== AST_NODE_TYPES108.MemberExpression || ASTUtils70.getPropertyName(callee) === null) {
|
|
24050
24252
|
return false;
|
|
24051
24253
|
}
|
|
24052
24254
|
if (calleeReceiver.type === AST_NODE_TYPES108.Identifier) {
|
|
24053
|
-
return namespaces.has(calleeReceiver.name) && ((
|
|
24255
|
+
return namespaces.has(calleeReceiver.name) && ((ASTUtils70.getPropertyName(callee) ?? "") === "object" || (ASTUtils70.getPropertyName(callee) ?? "") === "strictObject");
|
|
24054
24256
|
}
|
|
24055
24257
|
current = calleeReceiver;
|
|
24056
24258
|
}
|
|
@@ -24059,10 +24261,10 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
24059
24261
|
function zodParseCall(node) {
|
|
24060
24262
|
const callee = unwrapExpression(node.callee);
|
|
24061
24263
|
const calleeReceiver = callee.type === AST_NODE_TYPES108.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24062
|
-
if (callee.type !== AST_NODE_TYPES108.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES108.Identifier ||
|
|
24264
|
+
if (callee.type !== AST_NODE_TYPES108.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES108.Identifier || ASTUtils70.getPropertyName(callee) === null) {
|
|
24063
24265
|
return null;
|
|
24064
24266
|
}
|
|
24065
|
-
const method =
|
|
24267
|
+
const method = ASTUtils70.getPropertyName(callee);
|
|
24066
24268
|
if (method !== "parse" && method !== "safeParse") return null;
|
|
24067
24269
|
return {
|
|
24068
24270
|
call: node,
|
|
@@ -24104,7 +24306,7 @@ function localParseReturnCandidates(node, sourceCode) {
|
|
|
24104
24306
|
for (const reference of variable.references) {
|
|
24105
24307
|
const identifier = reference.identifier;
|
|
24106
24308
|
const parent = identifier.parent;
|
|
24107
|
-
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES108.MemberExpression && parent.object === identifier &&
|
|
24309
|
+
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES108.MemberExpression && parent.object === identifier && ASTUtils70.getPropertyName(parent) !== null && (ASTUtils70.getPropertyName(parent) ?? "") === "data" ? parent : null;
|
|
24108
24310
|
if (output === null) continue;
|
|
24109
24311
|
const candidate2 = returnedOutputCandidate(parsed, output);
|
|
24110
24312
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
@@ -24479,7 +24681,7 @@ var require_assert_never_default = createRule({
|
|
|
24479
24681
|
// src/rules/require-fetch-timeout.ts
|
|
24480
24682
|
import {
|
|
24481
24683
|
AST_NODE_TYPES as AST_NODE_TYPES110,
|
|
24482
|
-
ASTUtils as
|
|
24684
|
+
ASTUtils as ASTUtils71
|
|
24483
24685
|
} from "@typescript-eslint/utils";
|
|
24484
24686
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
24485
24687
|
summary: "Require an explicit abort signal on locally analyzable global fetch calls.",
|
|
@@ -24548,7 +24750,7 @@ function initSignalState(init, resolvesToGlobal) {
|
|
|
24548
24750
|
const isSignal = !prop.computed && prop.key.type === AST_NODE_TYPES110.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES110.Literal && prop.key.value === "signal";
|
|
24549
24751
|
if (isSignal) {
|
|
24550
24752
|
state = !prop.method ? emptySignal(prop.value, resolvesToGlobal) ?? "unknown" : "unknown";
|
|
24551
|
-
} else if (!prop.computed &&
|
|
24753
|
+
} else if (!prop.computed && ASTUtils71.getPropertyName(prop) === "__proto__" && state === "absent") {
|
|
24552
24754
|
state = "unknown";
|
|
24553
24755
|
} else if (prop.computed && prop.key.type !== AST_NODE_TYPES110.Literal) {
|
|
24554
24756
|
state = "unknown";
|
|
@@ -24557,14 +24759,14 @@ function initSignalState(init, resolvesToGlobal) {
|
|
|
24557
24759
|
return state;
|
|
24558
24760
|
}
|
|
24559
24761
|
function hasUnprovedPrototype(property) {
|
|
24560
|
-
if (property.computed || property.method || property.shorthand ||
|
|
24762
|
+
if (property.computed || property.method || property.shorthand || ASTUtils71.getPropertyName(property) !== "__proto__")
|
|
24561
24763
|
return false;
|
|
24562
24764
|
const prototype = unwrapExpression(property.value);
|
|
24563
24765
|
if (prototype.type === AST_NODE_TYPES110.Literal && prototype.value === null)
|
|
24564
24766
|
return false;
|
|
24565
24767
|
if (prototype.type !== AST_NODE_TYPES110.ObjectExpression) return true;
|
|
24566
24768
|
return prototype.properties.some(
|
|
24567
|
-
(member) => member.type === AST_NODE_TYPES110.SpreadElement || member.kind !== "init" || !member.computed &&
|
|
24769
|
+
(member) => member.type === AST_NODE_TYPES110.SpreadElement || member.kind !== "init" || !member.computed && ASTUtils71.getPropertyName(member) === "__proto__" || member.computed && member.key.type !== AST_NODE_TYPES110.Literal
|
|
24568
24770
|
);
|
|
24569
24771
|
}
|
|
24570
24772
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
@@ -24607,11 +24809,11 @@ var require_fetch_timeout_default = createRule({
|
|
|
24607
24809
|
}
|
|
24608
24810
|
function resolvesToGlobal(identifier) {
|
|
24609
24811
|
const scope = context.sourceCode.getScope(identifier);
|
|
24610
|
-
const variable =
|
|
24812
|
+
const variable = ASTUtils71.findVariable(scope, identifier.name);
|
|
24611
24813
|
return variable === null || variable.defs.length === 0;
|
|
24612
24814
|
}
|
|
24613
24815
|
function localConstInitSignalState(identifier) {
|
|
24614
|
-
const variable =
|
|
24816
|
+
const variable = ASTUtils71.findVariable(
|
|
24615
24817
|
context.sourceCode.getScope(identifier),
|
|
24616
24818
|
identifier.name
|
|
24617
24819
|
);
|
|
@@ -24633,7 +24835,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
24633
24835
|
function isForwardedRequest(argument) {
|
|
24634
24836
|
let value = unwrapExpression(argument);
|
|
24635
24837
|
if (value.type === AST_NODE_TYPES110.Identifier) {
|
|
24636
|
-
const binding =
|
|
24838
|
+
const binding = ASTUtils71.findVariable(
|
|
24637
24839
|
context.sourceCode.getScope(value),
|
|
24638
24840
|
value.name
|
|
24639
24841
|
);
|
|
@@ -24818,7 +25020,7 @@ function exportedClasses(program, classes) {
|
|
|
24818
25020
|
}
|
|
24819
25021
|
|
|
24820
25022
|
// src/rules/require-sql-access-class.ts
|
|
24821
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES112, ASTUtils as
|
|
25023
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES112, ASTUtils as ASTUtils72 } from "@typescript-eslint/utils";
|
|
24822
25024
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
24823
25025
|
"all",
|
|
24824
25026
|
"batch",
|
|
@@ -24925,7 +25127,7 @@ function databaseReceiver(node) {
|
|
|
24925
25127
|
if (node.type === AST_NODE_TYPES112.Identifier)
|
|
24926
25128
|
return DATABASE_NAMES.test(node.name);
|
|
24927
25129
|
if (node.type !== AST_NODE_TYPES112.MemberExpression) return false;
|
|
24928
|
-
const name =
|
|
25130
|
+
const name = ASTUtils72.getPropertyName(node);
|
|
24929
25131
|
return name === "DB" || name !== null && DATABASE_NAMES.test(name);
|
|
24930
25132
|
}
|
|
24931
25133
|
function databaseRootMember(node) {
|
|
@@ -24943,7 +25145,7 @@ function databaseRootMember(node) {
|
|
|
24943
25145
|
}
|
|
24944
25146
|
if (current.type === AST_NODE_TYPES112.MemberExpression) {
|
|
24945
25147
|
if (current.object.type === AST_NODE_TYPES112.ThisExpression)
|
|
24946
|
-
return
|
|
25148
|
+
return ASTUtils72.getPropertyName(current);
|
|
24947
25149
|
current = current.object;
|
|
24948
25150
|
continue;
|
|
24949
25151
|
}
|
|
@@ -24964,7 +25166,7 @@ function expressionHasDatabaseMarker(node) {
|
|
|
24964
25166
|
continue;
|
|
24965
25167
|
}
|
|
24966
25168
|
if (current.type === AST_NODE_TYPES112.MemberExpression) {
|
|
24967
|
-
const name =
|
|
25169
|
+
const name = ASTUtils72.getPropertyName(current);
|
|
24968
25170
|
if (name === "DB" || name !== null && DATABASE_NAMES.test(name))
|
|
24969
25171
|
return true;
|
|
24970
25172
|
current = current.object;
|
|
@@ -24983,7 +25185,7 @@ function expressionCallsBuilder(node) {
|
|
|
24983
25185
|
}
|
|
24984
25186
|
if (current.type === AST_NODE_TYPES112.CallExpression) {
|
|
24985
25187
|
if (current.callee.type !== AST_NODE_TYPES112.MemberExpression) return false;
|
|
24986
|
-
const name =
|
|
25188
|
+
const name = ASTUtils72.getPropertyName(current.callee);
|
|
24987
25189
|
if (name !== null && BUILDER_METHODS.has(name)) return true;
|
|
24988
25190
|
current = current.callee.object;
|
|
24989
25191
|
continue;
|
|
@@ -25034,7 +25236,7 @@ function thisRootMember(node) {
|
|
|
25034
25236
|
let current = node;
|
|
25035
25237
|
let root = null;
|
|
25036
25238
|
while (current.type === AST_NODE_TYPES112.MemberExpression) {
|
|
25037
|
-
const name =
|
|
25239
|
+
const name = ASTUtils72.getPropertyName(current);
|
|
25038
25240
|
if (name === null) return null;
|
|
25039
25241
|
root = name;
|
|
25040
25242
|
current = current.object;
|
|
@@ -25078,19 +25280,19 @@ var require_sql_access_class_default = createRule({
|
|
|
25078
25280
|
if (seen.has(node)) return false;
|
|
25079
25281
|
seen.add(node);
|
|
25080
25282
|
if (node.type === AST_NODE_TYPES112.Identifier) {
|
|
25081
|
-
const binding =
|
|
25283
|
+
const binding = ASTUtils72.findVariable(context.sourceCode.getScope(node), node.name);
|
|
25082
25284
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
25083
25285
|
const definition = binding.defs[0];
|
|
25084
25286
|
return definition?.type === "Variable" && definition.node.init !== null && knownNonDatabase(definition.node.init, seen);
|
|
25085
25287
|
}
|
|
25086
|
-
return node.type === AST_NODE_TYPES112.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES112.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(unwrappedNodeCallee.name) && (
|
|
25288
|
+
return node.type === AST_NODE_TYPES112.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES112.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(unwrappedNodeCallee.name) && (ASTUtils72.findVariable(context.sourceCode.getScope(unwrappedNodeCallee), unwrappedNodeCallee.name)?.defs.length ?? 0) === 0;
|
|
25087
25289
|
}
|
|
25088
25290
|
return {
|
|
25089
25291
|
CallExpression(node) {
|
|
25090
25292
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
25091
25293
|
if (unwrappedNodeCallee.type !== AST_NODE_TYPES112.MemberExpression)
|
|
25092
25294
|
return;
|
|
25093
|
-
const method =
|
|
25295
|
+
const method = ASTUtils72.getPropertyName(unwrappedNodeCallee);
|
|
25094
25296
|
if (knownNonDatabase(unwrappedNodeCallee.object)) return;
|
|
25095
25297
|
if (method === null || !isDatabaseOperation(method, unwrappedNodeCallee.object))
|
|
25096
25298
|
return;
|
|
@@ -25190,7 +25392,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
25190
25392
|
});
|
|
25191
25393
|
|
|
25192
25394
|
// src/rules/require-use-form-default-values.ts
|
|
25193
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES114, ASTUtils as
|
|
25395
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES114, ASTUtils as ASTUtils73 } from "@typescript-eslint/utils";
|
|
25194
25396
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
25195
25397
|
summary: "Require explicit form-level initialization or a field default for directly bound Controller fields.",
|
|
25196
25398
|
rationale: "React Hook Form exposes form-level defaultValues/values and field-level defaultValue as its explicit initialization mechanisms. A directly bound controlled field should not omit both mechanisms.",
|
|
@@ -25241,7 +25443,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
25241
25443
|
const imported = /* @__PURE__ */ new Map();
|
|
25242
25444
|
const uninitializedForms = /* @__PURE__ */ new Set();
|
|
25243
25445
|
const uninitializedControls = /* @__PURE__ */ new Set();
|
|
25244
|
-
const bindingNamed = (node, name) =>
|
|
25446
|
+
const bindingNamed = (node, name) => ASTUtils73.findVariable(context.sourceCode.getScope(node), name);
|
|
25245
25447
|
const bindingOf = (node) => bindingNamed(node, node.name);
|
|
25246
25448
|
const stable = (variable) => !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
25247
25449
|
const importedKind = (node) => {
|
|
@@ -25287,7 +25489,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
25287
25489
|
const variable = bindingOf(node);
|
|
25288
25490
|
return variable !== null && stable(variable) && uninitializedControls.has(variable);
|
|
25289
25491
|
}
|
|
25290
|
-
return node.type === AST_NODE_TYPES114.MemberExpression &&
|
|
25492
|
+
return node.type === AST_NODE_TYPES114.MemberExpression && ASTUtils73.getPropertyName(node) !== null && (ASTUtils73.getPropertyName(node) ?? "") === "control" && isUninitializedForm(node.object);
|
|
25291
25493
|
};
|
|
25292
25494
|
const fieldOptionsNeedDefault = (node) => {
|
|
25293
25495
|
if (node?.type !== AST_NODE_TYPES114.ObjectExpression) return false;
|
|
@@ -25343,7 +25545,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
25343
25545
|
trackDestructuredControl(node.id);
|
|
25344
25546
|
return;
|
|
25345
25547
|
}
|
|
25346
|
-
if (node.id.type === AST_NODE_TYPES114.Identifier && node.init.type === AST_NODE_TYPES114.MemberExpression &&
|
|
25548
|
+
if (node.id.type === AST_NODE_TYPES114.Identifier && node.init.type === AST_NODE_TYPES114.MemberExpression && ASTUtils73.getPropertyName(node.init) !== null && (ASTUtils73.getPropertyName(node.init) ?? "") === "control" && isUninitializedForm(node.init.object)) {
|
|
25347
25549
|
const variable = bindingOf(node.id);
|
|
25348
25550
|
if (variable !== null) uninitializedControls.add(variable);
|
|
25349
25551
|
}
|
|
@@ -25436,7 +25638,7 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
25436
25638
|
// src/rules/require-zod-form-validation.ts
|
|
25437
25639
|
import {
|
|
25438
25640
|
AST_NODE_TYPES as AST_NODE_TYPES115,
|
|
25439
|
-
ASTUtils as
|
|
25641
|
+
ASTUtils as ASTUtils74
|
|
25440
25642
|
} from "@typescript-eslint/utils";
|
|
25441
25643
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
25442
25644
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
@@ -25484,7 +25686,7 @@ var isFormDataMethodCall = (node) => {
|
|
|
25484
25686
|
}
|
|
25485
25687
|
if (current.type !== AST_NODE_TYPES115.CallExpression) return false;
|
|
25486
25688
|
const callee = unwrapExpression(current.callee);
|
|
25487
|
-
return callee.type === AST_NODE_TYPES115.MemberExpression &&
|
|
25689
|
+
return callee.type === AST_NODE_TYPES115.MemberExpression && ASTUtils74.getPropertyName(callee) === "formData";
|
|
25488
25690
|
};
|
|
25489
25691
|
var require_zod_form_validation_default = createRule({
|
|
25490
25692
|
name: "require-zod-form-validation",
|
|
@@ -25505,7 +25707,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
25505
25707
|
return {};
|
|
25506
25708
|
}
|
|
25507
25709
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
25508
|
-
const resolvedBinding = (identifier) =>
|
|
25710
|
+
const resolvedBinding = (identifier) => ASTUtils74.findVariable(
|
|
25509
25711
|
context.sourceCode.getScope(identifier),
|
|
25510
25712
|
identifier.name
|
|
25511
25713
|
);
|
|
@@ -25513,7 +25715,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
25513
25715
|
const callee = unwrapExpression(node.callee);
|
|
25514
25716
|
const calleeReceiver = callee.type === AST_NODE_TYPES115.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
25515
25717
|
if (callee.type !== AST_NODE_TYPES115.MemberExpression) return false;
|
|
25516
|
-
if (
|
|
25718
|
+
if (ASTUtils74.getPropertyName(callee) === null || !FORM_VALUE_METHODS.has(ASTUtils74.getPropertyName(callee) ?? "")) {
|
|
25517
25719
|
return false;
|
|
25518
25720
|
}
|
|
25519
25721
|
return isFormSourceIdentifier(calleeReceiver);
|
|
@@ -25544,7 +25746,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
25544
25746
|
parent = parent.parent;
|
|
25545
25747
|
continue;
|
|
25546
25748
|
}
|
|
25547
|
-
if (parent.type === AST_NODE_TYPES115.CallExpression && parent.callee.type === AST_NODE_TYPES115.MemberExpression && parent.callee.object.type === AST_NODE_TYPES115.Identifier && parent.callee.object.name === "Object" &&
|
|
25749
|
+
if (parent.type === AST_NODE_TYPES115.CallExpression && parent.callee.type === AST_NODE_TYPES115.MemberExpression && parent.callee.object.type === AST_NODE_TYPES115.Identifier && parent.callee.object.name === "Object" && ASTUtils74.getPropertyName(parent.callee) === "fromEntries" && (resolvedBinding(parent.callee.object)?.defs.length ?? 0) === 0) {
|
|
25548
25750
|
parent = parent.parent;
|
|
25549
25751
|
continue;
|
|
25550
25752
|
}
|
|
@@ -25557,7 +25759,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
25557
25759
|
if (node.type !== AST_NODE_TYPES115.CallExpression) return false;
|
|
25558
25760
|
const callee = unwrapExpression(node.callee);
|
|
25559
25761
|
const calleeReceiver = callee.type === AST_NODE_TYPES115.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
25560
|
-
if (callee.type !== AST_NODE_TYPES115.MemberExpression ||
|
|
25762
|
+
if (callee.type !== AST_NODE_TYPES115.MemberExpression || ASTUtils74.getPropertyName(callee) === null || !ZOD_PARSE_METHODS.has(ASTUtils74.getPropertyName(callee) ?? "")) {
|
|
25561
25763
|
return false;
|
|
25562
25764
|
}
|
|
25563
25765
|
const root = zodReceiverRoot(calleeReceiver);
|
|
@@ -25643,7 +25845,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
25643
25845
|
};
|
|
25644
25846
|
const zodParseMethod = (call) => {
|
|
25645
25847
|
const callee = unwrapExpression(call.callee);
|
|
25646
|
-
return callee.type === AST_NODE_TYPES115.MemberExpression &&
|
|
25848
|
+
return callee.type === AST_NODE_TYPES115.MemberExpression && ASTUtils74.getPropertyName(callee) !== null ? ASTUtils74.getPropertyName(callee) ?? "" : null;
|
|
25647
25849
|
};
|
|
25648
25850
|
const isSafePrevalidationInspection = (identifier) => {
|
|
25649
25851
|
const parent = identifier.parent;
|
|
@@ -25819,7 +26021,7 @@ function expressionCallableName(current) {
|
|
|
25819
26021
|
}
|
|
25820
26022
|
|
|
25821
26023
|
// src/rules/stepdown.ts
|
|
25822
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES116, ASTUtils as
|
|
26024
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES116, ASTUtils as ASTUtils75 } from "@typescript-eslint/utils";
|
|
25823
26025
|
var STEPDOWN_DOCUMENTATION = {
|
|
25824
26026
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
25825
26027
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -26119,7 +26321,7 @@ function receiverOrigin(context, object, receivers) {
|
|
|
26119
26321
|
while (true) {
|
|
26120
26322
|
const unwrapped = unwrapExpression4(current);
|
|
26121
26323
|
if (unwrapped.type !== AST_NODE_TYPES116.Identifier) return unwrapped;
|
|
26122
|
-
const variable =
|
|
26324
|
+
const variable = ASTUtils75.findVariable(context.sourceCode.getScope(unwrapped), unwrapped.name);
|
|
26123
26325
|
if (variable === null) return null;
|
|
26124
26326
|
const known = receivers.get(variable);
|
|
26125
26327
|
if (known !== void 0) return known;
|
|
@@ -26300,11 +26502,11 @@ function classScope(context, node, computedReferences) {
|
|
|
26300
26502
|
function classReceiverBindings(context, node) {
|
|
26301
26503
|
const classReceivers = /* @__PURE__ */ new Map();
|
|
26302
26504
|
if (node.id !== null) {
|
|
26303
|
-
const internal =
|
|
26505
|
+
const internal = ASTUtils75.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
26304
26506
|
if (internal !== null && stableVariable(internal)) classReceivers.set(internal, true);
|
|
26305
26507
|
}
|
|
26306
26508
|
if (node.type === AST_NODE_TYPES116.ClassExpression && node.parent.type === AST_NODE_TYPES116.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES116.Identifier && node.parent.parent.type === AST_NODE_TYPES116.VariableDeclaration && node.parent.parent.kind === "const") {
|
|
26307
|
-
const outer =
|
|
26509
|
+
const outer = ASTUtils75.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
26308
26510
|
if (outer !== null && stableVariable(outer)) classReceivers.set(outer, true);
|
|
26309
26511
|
}
|
|
26310
26512
|
return classReceivers;
|
|
@@ -26390,7 +26592,7 @@ function classMethodCounts(body2, methods) {
|
|
|
26390
26592
|
}
|
|
26391
26593
|
|
|
26392
26594
|
// src/rules/source-coupled-test.ts
|
|
26393
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES117, ASTUtils as
|
|
26595
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES117, ASTUtils as ASTUtils76 } from "@typescript-eslint/utils";
|
|
26394
26596
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc|toml|py|[cm]?[jt]s)$|(?<!\.(?:tf|tftest))\.json$/iu;
|
|
26395
26597
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
26396
26598
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -26507,7 +26709,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
26507
26709
|
const scopes = [newScope()];
|
|
26508
26710
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
26509
26711
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
26510
|
-
const bindingOf = (node) =>
|
|
26712
|
+
const bindingOf = (node) => ASTUtils76.findVariable(context.sourceCode.getScope(node), node.name);
|
|
26511
26713
|
const assertionKind = (node) => {
|
|
26512
26714
|
const binding = bindingOf(node);
|
|
26513
26715
|
if (binding === null || binding.defs.length === 0) {
|
|
@@ -26560,7 +26762,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
26560
26762
|
return visible("fsReaders", callee) && sourcePath(current.arguments[0]);
|
|
26561
26763
|
}
|
|
26562
26764
|
if (callee.type !== AST_NODE_TYPES117.MemberExpression) return false;
|
|
26563
|
-
const name2 =
|
|
26765
|
+
const name2 = ASTUtils76.getPropertyName(callee);
|
|
26564
26766
|
const object = unwrap6(calleeReceiver);
|
|
26565
26767
|
return name2 !== null && FS_READERS.has(name2) && object.type === AST_NODE_TYPES117.Identifier && visible("fsObjects", object) && sourcePath(current.arguments[0]);
|
|
26566
26768
|
};
|
|
@@ -26569,12 +26771,12 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
26569
26771
|
if (current.type === AST_NODE_TYPES117.Identifier) return visibleRawOrigins(current);
|
|
26570
26772
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
26571
26773
|
if (current.type === AST_NODE_TYPES117.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
26572
|
-
if (current.type === AST_NODE_TYPES117.MemberExpression &&
|
|
26774
|
+
if (current.type === AST_NODE_TYPES117.MemberExpression && ASTUtils76.getPropertyName(current) === "length") return rawOrigins(current.object);
|
|
26573
26775
|
if (current.type !== AST_NODE_TYPES117.CallExpression) return /* @__PURE__ */ new Set();
|
|
26574
26776
|
const callee = unwrap6(current.callee);
|
|
26575
26777
|
const calleeReceiver = callee.type === AST_NODE_TYPES117.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
26576
26778
|
if (callee.type !== AST_NODE_TYPES117.MemberExpression) return /* @__PURE__ */ new Set();
|
|
26577
|
-
const name2 =
|
|
26779
|
+
const name2 = ASTUtils76.getPropertyName(callee);
|
|
26578
26780
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(calleeReceiver) : /* @__PURE__ */ new Set();
|
|
26579
26781
|
};
|
|
26580
26782
|
const evidenceOrigins = (node) => {
|
|
@@ -26587,7 +26789,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
26587
26789
|
const callee = unwrap6(current.callee);
|
|
26588
26790
|
const calleeReceiver = callee.type === AST_NODE_TYPES117.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
26589
26791
|
if (callee.type !== AST_NODE_TYPES117.MemberExpression) return /* @__PURE__ */ new Set();
|
|
26590
|
-
const name2 =
|
|
26792
|
+
const name2 = ASTUtils76.getPropertyName(callee);
|
|
26591
26793
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(calleeReceiver);
|
|
26592
26794
|
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES117.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
26593
26795
|
return /* @__PURE__ */ new Set();
|
|
@@ -26599,10 +26801,10 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
26599
26801
|
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES117.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
26600
26802
|
}
|
|
26601
26803
|
if (callee.type !== AST_NODE_TYPES117.MemberExpression) return /* @__PURE__ */ new Set();
|
|
26602
|
-
const matcher =
|
|
26804
|
+
const matcher = ASTUtils76.getPropertyName(callee);
|
|
26603
26805
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
26604
26806
|
let receiver = unwrap6(calleeReceiver);
|
|
26605
|
-
while (receiver.type === AST_NODE_TYPES117.MemberExpression && EXPECT_MODIFIERS2.has(
|
|
26807
|
+
while (receiver.type === AST_NODE_TYPES117.MemberExpression && EXPECT_MODIFIERS2.has(ASTUtils76.getPropertyName(receiver) ?? "")) receiver = unwrap6(receiver.object);
|
|
26606
26808
|
const expectCallee = receiver.type === AST_NODE_TYPES117.CallExpression ? unwrapExpression(receiver.callee) : null;
|
|
26607
26809
|
if (receiver.type === AST_NODE_TYPES117.CallExpression && expectCallee?.type === AST_NODE_TYPES117.Identifier && assertionKind(expectCallee) === "expect") {
|
|
26608
26810
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
@@ -26885,7 +27087,7 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
26885
27087
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
26886
27088
|
import {
|
|
26887
27089
|
AST_NODE_TYPES as AST_NODE_TYPES119,
|
|
26888
|
-
ASTUtils as
|
|
27090
|
+
ASTUtils as ASTUtils77
|
|
26889
27091
|
} from "@typescript-eslint/utils";
|
|
26890
27092
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
26891
27093
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
@@ -27018,7 +27220,7 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
27018
27220
|
"superRefine",
|
|
27019
27221
|
"transform"
|
|
27020
27222
|
]);
|
|
27021
|
-
var terminalMethodName = (callee) =>
|
|
27223
|
+
var terminalMethodName = (callee) => ASTUtils77.getPropertyName(callee) !== null ? ASTUtils77.getPropertyName(callee) ?? "" : null;
|
|
27022
27224
|
var calleeChainRoot2 = (node) => {
|
|
27023
27225
|
let current = node;
|
|
27024
27226
|
for (; ; ) {
|
|
@@ -27043,8 +27245,8 @@ var chainMemberNames2 = (node) => {
|
|
|
27043
27245
|
for (; ; ) {
|
|
27044
27246
|
current = unwrapExpression(current);
|
|
27045
27247
|
if (current.type === AST_NODE_TYPES119.MemberExpression) {
|
|
27046
|
-
if (
|
|
27047
|
-
names.push(
|
|
27248
|
+
if (ASTUtils77.getPropertyName(current) === null) return [];
|
|
27249
|
+
names.push(ASTUtils77.getPropertyName(current) ?? "");
|
|
27048
27250
|
current = current.object;
|
|
27049
27251
|
continue;
|
|
27050
27252
|
}
|
|
@@ -27081,7 +27283,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
27081
27283
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
27082
27284
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
27083
27285
|
function resolvedBinding(identifier) {
|
|
27084
|
-
return
|
|
27286
|
+
return ASTUtils77.findVariable(
|
|
27085
27287
|
context.sourceCode.getScope(identifier),
|
|
27086
27288
|
identifier.name
|
|
27087
27289
|
);
|