@sarj/eslint-plugin 16.4.8 → 16.5.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 +483 -362
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +482 -361
- 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.
|
|
4
|
+
version: "16.5.1",
|
|
5
5
|
packageManager: "npm@12.1.0",
|
|
6
6
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
7
7
|
type: "module",
|
|
@@ -1976,13 +1976,21 @@ function attributeText(node, name) {
|
|
|
1976
1976
|
}
|
|
1977
1977
|
return attribute.value === null ? "" : staticText(attribute.value);
|
|
1978
1978
|
}
|
|
1979
|
-
function isHidden(node) {
|
|
1979
|
+
function isHidden(node, source) {
|
|
1980
1980
|
if (attributeText(node, "aria-hidden") === "true") return true;
|
|
1981
1981
|
const hidden = node.attributes.findLast(
|
|
1982
1982
|
(attribute) => attribute.type === AST_NODE_TYPES9.JSXSpreadAttribute || attribute.name.type === AST_NODE_TYPES9.JSXIdentifier && attribute.name.name === "hidden"
|
|
1983
1983
|
);
|
|
1984
1984
|
if (hidden?.type !== AST_NODE_TYPES9.JSXAttribute) return false;
|
|
1985
1985
|
if (hidden.value === null) return true;
|
|
1986
|
+
if (hidden.value.type === AST_NODE_TYPES9.JSXExpressionContainer) {
|
|
1987
|
+
const value = hidden.value.expression;
|
|
1988
|
+
if (value.type === AST_NODE_TYPES9.Identifier && value.name === "undefined") {
|
|
1989
|
+
const binding = ASTUtils4.findVariable(source.getScope(value), value.name);
|
|
1990
|
+
if (binding === null || binding.defs.length === 0) return false;
|
|
1991
|
+
}
|
|
1992
|
+
if (value.type === AST_NODE_TYPES9.UnaryExpression && value.operator === "void" && value.argument.type === AST_NODE_TYPES9.Literal && value.argument.value === 0) return false;
|
|
1993
|
+
}
|
|
1986
1994
|
if (hidden.value.type === AST_NODE_TYPES9.JSXExpressionContainer && hidden.value.expression.type === AST_NODE_TYPES9.Literal)
|
|
1987
1995
|
return hidden.value.expression.value !== false && hidden.value.expression.value !== null;
|
|
1988
1996
|
return true;
|
|
@@ -2013,7 +2021,7 @@ function childrenNameStatus(children, source, iconModules) {
|
|
|
2013
2021
|
return childrenNameStatus(child.children, source, iconModules);
|
|
2014
2022
|
if (child.type !== AST_NODE_TYPES9.JSXElement) return "unknown";
|
|
2015
2023
|
const opening = child.openingElement;
|
|
2016
|
-
if (isHidden(opening)) return "empty";
|
|
2024
|
+
if (isHidden(opening, source)) return "empty";
|
|
2017
2025
|
const imported = importedComponent(opening.name, source);
|
|
2018
2026
|
const intrinsic = opening.name.type === AST_NODE_TYPES9.JSXIdentifier && /^[a-z]/u.test(opening.name.name);
|
|
2019
2027
|
if (!intrinsic && (imported === null || !iconModules.includes(imported.module)))
|
|
@@ -2039,7 +2047,7 @@ function isPassedAsProp(node, source) {
|
|
|
2039
2047
|
}
|
|
2040
2048
|
function hasHiddenAncestor(node, source) {
|
|
2041
2049
|
return source.getAncestors(node).some(
|
|
2042
|
-
(ancestor) => ancestor.type === AST_NODE_TYPES9.JSXElement && isHidden(ancestor.openingElement)
|
|
2050
|
+
(ancestor) => ancestor.type === AST_NODE_TYPES9.JSXElement && isHidden(ancestor.openingElement, source)
|
|
2043
2051
|
);
|
|
2044
2052
|
}
|
|
2045
2053
|
function textNameStatus(text) {
|
|
@@ -2055,7 +2063,8 @@ var REQUIRE_BUTTON_ACCESSIBLE_NAME_DOCUMENTATION = {
|
|
|
2055
2063
|
category: "correctness",
|
|
2056
2064
|
limitations: [
|
|
2057
2065
|
"Native button and conventional Button elements are checked by default. Other custom buttons require exact module/export configuration; aliases and namespace imports are resolved by scope. Lucide icons are recognized by default; other icon modules are configurable.",
|
|
2058
|
-
"Composed JSX passed as props, render/asChild adapters, dynamic labels, children, unknown components, and prop spreads are left to runtime accessibility testing. Referenced IDs, CSS visibility, and meaningful wording are not verified. Generated files, tests, fixtures, and stories are excluded. No automatic labels are invented."
|
|
2066
|
+
"Composed JSX passed as props, render/asChild adapters, dynamic labels, children, unknown components, and prop spreads are left to runtime accessibility testing. Referenced IDs, CSS visibility, and meaningful wording are not verified. Generated files, tests, fixtures, and stories are excluded. No automatic labels are invented.",
|
|
2067
|
+
"A hidden prop with unshadowed undefined or exact void 0 does not hide the element or its children. Shadowed undefined and dynamic hidden values remain unproven."
|
|
2059
2068
|
],
|
|
2060
2069
|
examples: [
|
|
2061
2070
|
{
|
|
@@ -2133,7 +2142,7 @@ var require_button_accessible_name_default = createRule({
|
|
|
2133
2142
|
return;
|
|
2134
2143
|
if (isPassedAsProp(node, context.sourceCode) || hasHiddenAncestor(node, context.sourceCode))
|
|
2135
2144
|
return;
|
|
2136
|
-
if (isHidden(opening) || attributeNameStatus(opening) !== "empty")
|
|
2145
|
+
if (isHidden(opening, context.sourceCode) || attributeNameStatus(opening) !== "empty")
|
|
2137
2146
|
return;
|
|
2138
2147
|
if (childrenNameStatus(node.children, context.sourceCode, iconModules) !== "empty")
|
|
2139
2148
|
return;
|
|
@@ -2229,7 +2238,8 @@ var REQUIRE_SVG_ACCESSIBLE_NAME_DOCUMENTATION = {
|
|
|
2229
2238
|
remediation: "Add aria-label, aria-labelledby, or a direct title child; mark decorative graphics aria-hidden or presentational.",
|
|
2230
2239
|
category: "correctness",
|
|
2231
2240
|
limitations: [
|
|
2232
|
-
"Only intrinsic svg elements are checked. Dynamic labels, forwarded props, and dynamic title content remain runtime concerns. IDs, CSS visibility and graphic meaning are not inferred. Tests, stories, fixtures and generated files are excluded. No automatic title or decorative marker is invented."
|
|
2241
|
+
"Only intrinsic svg elements are checked. Dynamic labels, forwarded props, and dynamic title content remain runtime concerns. IDs, CSS visibility and graphic meaning are not inferred. Tests, stories, fixtures and generated files are excluded. No automatic title or decorative marker is invented.",
|
|
2242
|
+
"A hidden prop with unshadowed undefined or exact void 0 does not hide the element. Shadowed undefined and dynamic hidden values remain unproven."
|
|
2233
2243
|
],
|
|
2234
2244
|
examples: [
|
|
2235
2245
|
{
|
|
@@ -2279,7 +2289,7 @@ var require_svg_accessible_name_default = createRule({
|
|
|
2279
2289
|
return;
|
|
2280
2290
|
if (isPassedAsProp(node, context.sourceCode) || hasHiddenAncestor(node, context.sourceCode))
|
|
2281
2291
|
return;
|
|
2282
|
-
if (isHidden(opening) || ["none", "presentation"].includes(
|
|
2292
|
+
if (isHidden(opening, context.sourceCode) || ["none", "presentation"].includes(
|
|
2283
2293
|
attributeText(opening, "role") ?? ""
|
|
2284
2294
|
))
|
|
2285
2295
|
return;
|
|
@@ -6954,7 +6964,7 @@ var NO_JSON_STRINGIFY_ERROR_DOCUMENTATION = {
|
|
|
6954
6964
|
rationale: "Native Error details are non-enumerable, so generic JSON serialization discards diagnostic information.",
|
|
6955
6965
|
remediation: "Serialize explicit error fields or use an error-aware serializer.",
|
|
6956
6966
|
category: "correctness",
|
|
6957
|
-
limitations: ["The rule uses stable local catch bindings and unshadowed built-in constructors, not runtime type information. Custom replacers and explicit toJSON hooks are left to their serializer contract; a catch value is not guaranteed to be an Error. Member values, including cause, do not inherit the base Error's provenance; even an Error-valued member requires explicit value/dataflow proof outside this rule. Known literal __proto__ initializer chains preserve native hook inheritance and own toJSON precedence; computed __proto__ keys remain data. Unknown prototype expressions, hook values/spreads and deferred hook writes conservatively lose default serializer proof. Explicit writes invalidate constructor provenance except a later, separate top-level statement; deferred functions, loops, and unknown property keys conservatively lose constructor proof. Statically owned global/property writes and native Reflect.set/Reflect.defineProperty/Object.defineProperty/Object.defineProperties calls are tracked. Mutator aliases, replaced Reflect/Object methods, external calls, and runtime-only property names are not resolved; uncertain ordering conservatively loses proof."],
|
|
6967
|
+
limitations: ["The rule uses stable local catch bindings and unshadowed built-in constructors, not runtime type information. Native DOMException constructor coverage is validated in Node; browser serialization is not evaluated. Custom replacers and explicit toJSON hooks are left to their serializer contract; a catch value is not guaranteed to be an Error. Member values, including cause, do not inherit the base Error's provenance; even an Error-valued member requires explicit value/dataflow proof outside this rule. Known literal __proto__ initializer chains preserve native hook inheritance and own toJSON precedence; computed __proto__ keys remain data. Unknown prototype expressions, hook values/spreads and deferred hook writes conservatively lose default serializer proof. Explicit writes invalidate constructor provenance except a later, separate top-level statement; deferred functions, loops, and unknown property keys conservatively lose constructor proof. Statically owned global/property writes and native Reflect.set/Reflect.defineProperty/Object.defineProperty/Object.defineProperties calls are tracked. Mutator aliases, replaced Reflect/Object methods, external calls, and runtime-only property names are not resolved; uncertain ordering conservatively loses proof."],
|
|
6958
6968
|
examples: [
|
|
6959
6969
|
{ id: "explicit-error-message", title: "Narrow an unknown catch value before selecting fields", outcome: "no-match", files: [{ path: "src/report.ts", source: "try { f(); } catch (err) { JSON.stringify({ error: err instanceof Error ? err.message : String(err) }); }" }], focusPath: "src/report.ts", expectedCount: 0, public: true },
|
|
6960
6970
|
{ id: "stringified-error", title: "Do not stringify an Error object", outcome: "match", files: [{ path: "src/report.ts", source: "try { f(); } catch (err) { JSON.stringify({ error: err }); }" }], focusPath: "src/report.ts", expectedCount: 1, public: true },
|
|
@@ -6976,6 +6986,7 @@ var NO_JSON_STRINGIFY_ERROR_DOCUMENTATION = {
|
|
|
6976
6986
|
};
|
|
6977
6987
|
var BUILTIN_ERROR_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
6978
6988
|
"AggregateError",
|
|
6989
|
+
"DOMException",
|
|
6979
6990
|
"Error",
|
|
6980
6991
|
"EvalError",
|
|
6981
6992
|
"RangeError",
|
|
@@ -11836,7 +11847,7 @@ var NO_SILENT_PROMISE_CATCH_DOCUMENTATION = {
|
|
|
11836
11847
|
rationale: "A swallowed rejection hides failures and gives callers an indistinguishable fallback value.",
|
|
11837
11848
|
remediation: "Log, rethrow, or explicitly recover from the rejection; explain intentional teardown suppression.",
|
|
11838
11849
|
category: "correctness",
|
|
11839
|
-
limitations: ["Test files, teardown calls, explanatory comments, non-function handlers, and handlers that consume or report the error are excluded.", "Recognized imported Zod construction chains and their stable local aliases are excluded. Other untyped catch-like APIs are not proven to be Promises.", "Computed methods resolve literal syntax and stable local string aliases in lexical scope. Function-derived, object-derived and mutated computed keys remain unproven."],
|
|
11850
|
+
limitations: ["Test files, teardown calls, explanatory comments, non-function handlers, and handlers that consume or report the error are excluded.", "Recognized imported Zod construction chains and their stable local aliases are excluded, including URL schemas and primitive bigint, boolean, number and string coercion. Other untyped catch-like APIs are not proven to be Promises.", "Computed methods resolve literal syntax and stable local string aliases in lexical scope. Function-derived, object-derived and mutated computed keys remain unproven."],
|
|
11840
11851
|
examples: [
|
|
11841
11852
|
{ id: "reported-rejection", title: "Report the rejection", outcome: "no-match", files: [{ path: "src/load.ts", source: "load().catch((error) => logger.error({ error }, 'load failed'));" }], focusPath: "src/load.ts", expectedCount: 0, public: true },
|
|
11842
11853
|
{ id: "silent-rejection", title: "Do not swallow the rejection", outcome: "match", files: [{ path: "src/load.ts", source: "load().catch(() => null);" }], focusPath: "src/load.ts", expectedCount: 1, public: true },
|
|
@@ -11872,7 +11883,8 @@ var ZOD_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
11872
11883
|
"tuple",
|
|
11873
11884
|
"undefined",
|
|
11874
11885
|
"union",
|
|
11875
|
-
"unknown"
|
|
11886
|
+
"unknown",
|
|
11887
|
+
"url"
|
|
11876
11888
|
]);
|
|
11877
11889
|
var ZOD_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
11878
11890
|
"array",
|
|
@@ -11980,8 +11992,9 @@ var no_silent_promise_catch_default = createRule({
|
|
|
11980
11992
|
return binding.defs.length === 1 && definition?.node.type === AST_NODE_TYPES56.VariableDeclarator && definition.node.init !== null && isZodSchema(definition.node.init, seen);
|
|
11981
11993
|
}
|
|
11982
11994
|
if (node.type !== AST_NODE_TYPES56.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES56.MemberExpression) return false;
|
|
11983
|
-
|
|
11995
|
+
let { object } = unwrappedNodeCallee;
|
|
11984
11996
|
const method = staticPropertyName(unwrappedNodeCallee, context.sourceCode);
|
|
11997
|
+
if (object.type === AST_NODE_TYPES56.MemberExpression && staticPropertyName(object, context.sourceCode) === "coerce" && method !== null && ["bigint", "boolean", "number", "string"].includes(method)) object = object.object;
|
|
11985
11998
|
if (object.type === AST_NODE_TYPES56.Identifier && method !== null && ZOD_CONSTRUCTORS.has(method)) {
|
|
11986
11999
|
const binding = ASTUtils31.findVariable(context.sourceCode.getScope(object), object.name);
|
|
11987
12000
|
if (binding?.defs.some((definition) => {
|
|
@@ -21371,10 +21384,114 @@ function staticFieldName(key) {
|
|
|
21371
21384
|
return key.type === AST_NODE_TYPES99.Identifier ? key.name : key.type === AST_NODE_TYPES99.Literal && typeof key.value === "string" ? key.value : null;
|
|
21372
21385
|
}
|
|
21373
21386
|
|
|
21387
|
+
// src/rules/named-child-schema-type.ts
|
|
21388
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES100, ASTUtils as ASTUtils61 } from "@typescript-eslint/utils";
|
|
21389
|
+
var UNRESOLVED_TYPE_NODES = /* @__PURE__ */ new Set([
|
|
21390
|
+
AST_NODE_TYPES100.TSTypeQuery,
|
|
21391
|
+
AST_NODE_TYPES100.TSImportType,
|
|
21392
|
+
AST_NODE_TYPES100.TSTypeParameter,
|
|
21393
|
+
AST_NODE_TYPES100.TSAnyKeyword,
|
|
21394
|
+
AST_NODE_TYPES100.TSUnknownKeyword
|
|
21395
|
+
]);
|
|
21396
|
+
var NAMED_CHILD_SCHEMA_TYPE_DOCUMENTATION = {
|
|
21397
|
+
defaultLevel: "warning",
|
|
21398
|
+
summary: "Reference a named Zod record child's complete schema type instead of repeating its explicit annotation.",
|
|
21399
|
+
rationale: "Repeating a child schema's generic contract creates a second maintained declaration even though the record already uses that child at runtime.",
|
|
21400
|
+
remediation: "Replace only the matching record type argument with `typeof ChildSchema`; retain the outer annotation required by isolatedDeclarations and every runtime schema operation.",
|
|
21401
|
+
category: "maintainability",
|
|
21402
|
+
autofix: "none",
|
|
21403
|
+
limitations: [
|
|
21404
|
+
"Only direct module-level const z.record calls with two arguments, a ZodRecord annotation, and an earlier local const child with a complete explicit Zod type are inspected.",
|
|
21405
|
+
"The entire generic child annotation must match token for token; input/output, defaults, transforms, readonly modifiers and brands are never compared by output shape alone.",
|
|
21406
|
+
"Bare leaf types, broad ZodType constraints, type queries, imported or unqualified type references, annotation cycles, comments on the repeated argument, mutable bindings and generated files are excluded.",
|
|
21407
|
+
"Import aliases and namespace imports resolve through scope bindings. Independent public contract pins require review; this warning does not remove annotations or change runtime validation."
|
|
21408
|
+
],
|
|
21409
|
+
examples: [
|
|
21410
|
+
{ id: "named-child", title: "Reference the named child contract", outcome: "no-match", files: [{ path: "src/record.ts", source: 'import { z } from "zod"; const KeySchema: z.ZodEnum<{ a: "a"; b: "b" }> = z.enum(["a", "b"]); export const RecordSchema: z.ZodRecord<typeof KeySchema, z.ZodString> = z.record(KeySchema, z.string());' }], focusPath: "src/record.ts", expectedCount: 0, public: true },
|
|
21411
|
+
{ id: "copied-child", title: "Do not repeat the complete child annotation", outcome: "match", files: [{ path: "src/record.ts", source: 'import { z } from "zod"; const KeySchema: z.ZodEnum<{ a: "a"; b: "b" }> = z.enum(["a", "b"]); export const RecordSchema: z.ZodRecord<z.ZodEnum<{ a: "a"; b: "b" }>, z.ZodString> = z.record(KeySchema, z.string());' }], focusPath: "src/record.ts", expectedCount: 1, public: true }
|
|
21412
|
+
]
|
|
21413
|
+
};
|
|
21414
|
+
function isModuleConst(node) {
|
|
21415
|
+
if (node.parent.kind !== "const" || node.id.type !== AST_NODE_TYPES100.Identifier) return false;
|
|
21416
|
+
const parent = node.parent.parent;
|
|
21417
|
+
return parent.type === AST_NODE_TYPES100.Program || parent.type === AST_NODE_TYPES100.ExportNamedDeclaration && parent.parent.type === AST_NODE_TYPES100.Program;
|
|
21418
|
+
}
|
|
21419
|
+
var named_child_schema_type_default = createRule({
|
|
21420
|
+
name: "named-child-schema-type",
|
|
21421
|
+
documentation: NAMED_CHILD_SCHEMA_TYPE_DOCUMENTATION,
|
|
21422
|
+
meta: {
|
|
21423
|
+
type: "suggestion",
|
|
21424
|
+
docs: { description: NAMED_CHILD_SCHEMA_TYPE_DOCUMENTATION.summary },
|
|
21425
|
+
schema: [],
|
|
21426
|
+
messages: { namedChildType: "Use `typeof {{name}}` for this exact child contract; keep the outer schema annotation and runtime operations." }
|
|
21427
|
+
},
|
|
21428
|
+
defaultOptions: [],
|
|
21429
|
+
create(context) {
|
|
21430
|
+
const source = context.sourceCode;
|
|
21431
|
+
if (isGeneratedFile(context.filename, source.text)) return {};
|
|
21432
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
21433
|
+
const bindingOf = (node) => ASTUtils61.findVariable(source.getScope(node), node.name);
|
|
21434
|
+
function namespaceOf(type) {
|
|
21435
|
+
if (type.typeName.type !== AST_NODE_TYPES100.TSQualifiedName || type.typeName.left.type !== AST_NODE_TYPES100.Identifier) return null;
|
|
21436
|
+
const binding = bindingOf(type.typeName.left);
|
|
21437
|
+
return binding !== null && namespaces.has(binding) ? binding : null;
|
|
21438
|
+
}
|
|
21439
|
+
function closedType(node, namespace) {
|
|
21440
|
+
if (UNRESOLVED_TYPE_NODES.has(node.type)) return false;
|
|
21441
|
+
if (node.type === AST_NODE_TYPES100.TSTypeReference && namespaceOf(node) !== namespace) return false;
|
|
21442
|
+
return !forEachOwnAstChild(node, (child) => !closedType(child, namespace));
|
|
21443
|
+
}
|
|
21444
|
+
function inspectChild(argument, repeated, namespace, parent) {
|
|
21445
|
+
if (argument.type !== AST_NODE_TYPES100.Identifier || repeated.type !== AST_NODE_TYPES100.TSTypeReference || repeated.typeArguments === void 0) return;
|
|
21446
|
+
if (repeated.typeName.type !== AST_NODE_TYPES100.TSQualifiedName || /^(?:ZodType|ZodSchema|ZodTypeAny)$/u.test(repeated.typeName.right.name)) return;
|
|
21447
|
+
const variable = bindingOf(argument);
|
|
21448
|
+
const definition = variable?.defs.length === 1 ? variable.defs[0] : void 0;
|
|
21449
|
+
if (definition?.type !== "Variable" || !isModuleConst(definition.node)) return;
|
|
21450
|
+
const child = definition.node;
|
|
21451
|
+
if (child.id.type !== AST_NODE_TYPES100.Identifier || child.init === null || child.range[0] >= parent.range[0]) return;
|
|
21452
|
+
const annotation = child.id.typeAnnotation?.typeAnnotation;
|
|
21453
|
+
if (annotation === void 0 || factoryNamespace(child.init) !== namespace || !closedType(annotation, namespace)) return;
|
|
21454
|
+
if (source.getCommentsInside(repeated).length > 0 || source.getCommentsBefore(repeated).length > 0) return;
|
|
21455
|
+
const expected = source.getTokens(annotation);
|
|
21456
|
+
const actual = source.getTokens(repeated);
|
|
21457
|
+
if (expected.length !== actual.length || expected.some((token, index) => token.type !== actual[index]?.type || token.value !== actual[index]?.value)) return;
|
|
21458
|
+
context.report({ node: repeated, messageId: "namedChildType", data: { name: argument.name } });
|
|
21459
|
+
}
|
|
21460
|
+
function factoryNamespace(expression) {
|
|
21461
|
+
if (expression.type !== AST_NODE_TYPES100.CallExpression || expression.callee.type !== AST_NODE_TYPES100.MemberExpression) return null;
|
|
21462
|
+
const object = expression.callee.object;
|
|
21463
|
+
return object.type === AST_NODE_TYPES100.Identifier ? bindingOf(object) : factoryNamespace(object);
|
|
21464
|
+
}
|
|
21465
|
+
return {
|
|
21466
|
+
ImportDeclaration(node) {
|
|
21467
|
+
if (node.importKind === "type" || !isZodModule(node.source.value)) return;
|
|
21468
|
+
for (const specifier of node.specifiers) {
|
|
21469
|
+
if (specifier.type !== AST_NODE_TYPES100.ImportNamespaceSpecifier && (specifier.type !== AST_NODE_TYPES100.ImportSpecifier || specifier.importKind === "type" || importSpecifierName(specifier) !== "z")) continue;
|
|
21470
|
+
const binding = bindingOf(specifier.local);
|
|
21471
|
+
if (binding !== null) namespaces.add(binding);
|
|
21472
|
+
}
|
|
21473
|
+
},
|
|
21474
|
+
VariableDeclarator(node) {
|
|
21475
|
+
if (!isModuleConst(node) || node.id.type !== AST_NODE_TYPES100.Identifier || node.init?.type !== AST_NODE_TYPES100.CallExpression) return;
|
|
21476
|
+
const call = node.init;
|
|
21477
|
+
if (call.arguments.length !== 2 || call.callee.type !== AST_NODE_TYPES100.MemberExpression || call.callee.object.type !== AST_NODE_TYPES100.Identifier || ASTUtils61.getPropertyName(call.callee) !== "record") return;
|
|
21478
|
+
const annotation = node.id.typeAnnotation?.typeAnnotation;
|
|
21479
|
+
if (annotation?.type !== AST_NODE_TYPES100.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES100.TSQualifiedName || annotation.typeName.right.name !== "ZodRecord") return;
|
|
21480
|
+
const namespace = namespaceOf(annotation);
|
|
21481
|
+
if (namespace === null || bindingOf(call.callee.object) !== namespace || annotation.typeArguments?.params.length !== 2) return;
|
|
21482
|
+
for (const [index, argument] of call.arguments.entries()) {
|
|
21483
|
+
const repeated = annotation.typeArguments.params[index];
|
|
21484
|
+
if (repeated !== void 0) inspectChild(argument, repeated, namespace, node);
|
|
21485
|
+
}
|
|
21486
|
+
}
|
|
21487
|
+
};
|
|
21488
|
+
}
|
|
21489
|
+
});
|
|
21490
|
+
|
|
21374
21491
|
// src/rules/prefer-zod-parse-output-type.ts
|
|
21375
21492
|
import {
|
|
21376
|
-
ASTUtils as
|
|
21377
|
-
AST_NODE_TYPES as
|
|
21493
|
+
ASTUtils as ASTUtils62,
|
|
21494
|
+
AST_NODE_TYPES as AST_NODE_TYPES101,
|
|
21378
21495
|
ESLintUtils as ESLintUtils14
|
|
21379
21496
|
} from "@typescript-eslint/utils";
|
|
21380
21497
|
import ts12 from "typescript";
|
|
@@ -21432,22 +21549,22 @@ var PREFER_ZOD_PARSE_OUTPUT_TYPE_DOCUMENTATION = {
|
|
|
21432
21549
|
};
|
|
21433
21550
|
function isModuleLevelConst2(node) {
|
|
21434
21551
|
const declaration = node.parent;
|
|
21435
|
-
if (declaration.type !==
|
|
21552
|
+
if (declaration.type !== AST_NODE_TYPES101.VariableDeclaration || declaration.kind !== "const") {
|
|
21436
21553
|
return false;
|
|
21437
21554
|
}
|
|
21438
21555
|
const container = declaration.parent;
|
|
21439
|
-
return container.type ===
|
|
21556
|
+
return container.type === AST_NODE_TYPES101.Program || container.type === AST_NODE_TYPES101.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES101.Program;
|
|
21440
21557
|
}
|
|
21441
21558
|
function isLocalZodObjectSchema(node, namespaces) {
|
|
21442
21559
|
let current = node;
|
|
21443
|
-
while (current.type ===
|
|
21560
|
+
while (current.type === AST_NODE_TYPES101.CallExpression) {
|
|
21444
21561
|
const callee = unwrapExpression(current.callee);
|
|
21445
|
-
const calleeReceiver = callee.type ===
|
|
21446
|
-
if (callee.type !==
|
|
21562
|
+
const calleeReceiver = callee.type === AST_NODE_TYPES101.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
21563
|
+
if (callee.type !== AST_NODE_TYPES101.MemberExpression || ASTUtils62.getPropertyName(callee) === null) {
|
|
21447
21564
|
return false;
|
|
21448
21565
|
}
|
|
21449
|
-
if (calleeReceiver.type ===
|
|
21450
|
-
return namespaces.has(calleeReceiver.name) && ((
|
|
21566
|
+
if (calleeReceiver.type === AST_NODE_TYPES101.Identifier) {
|
|
21567
|
+
return namespaces.has(calleeReceiver.name) && ((ASTUtils62.getPropertyName(callee) ?? "") === "object" || (ASTUtils62.getPropertyName(callee) ?? "") === "strictObject");
|
|
21451
21568
|
}
|
|
21452
21569
|
current = calleeReceiver;
|
|
21453
21570
|
}
|
|
@@ -21455,11 +21572,11 @@ function isLocalZodObjectSchema(node, namespaces) {
|
|
|
21455
21572
|
}
|
|
21456
21573
|
function zodParseCall(node) {
|
|
21457
21574
|
const callee = unwrapExpression(node.callee);
|
|
21458
|
-
const calleeReceiver = callee.type ===
|
|
21459
|
-
if (callee.type !==
|
|
21575
|
+
const calleeReceiver = callee.type === AST_NODE_TYPES101.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
21576
|
+
if (callee.type !== AST_NODE_TYPES101.MemberExpression || calleeReceiver.type !== AST_NODE_TYPES101.Identifier || ASTUtils62.getPropertyName(callee) === null) {
|
|
21460
21577
|
return null;
|
|
21461
21578
|
}
|
|
21462
|
-
const method =
|
|
21579
|
+
const method = ASTUtils62.getPropertyName(callee);
|
|
21463
21580
|
if (method !== "parse" && method !== "safeParse") return null;
|
|
21464
21581
|
return {
|
|
21465
21582
|
call: node,
|
|
@@ -21473,7 +21590,7 @@ function returnedOutputCandidate(parsed, output) {
|
|
|
21473
21590
|
const annotation = owner?.returnType?.typeAnnotation;
|
|
21474
21591
|
if (annotation === void 0) return null;
|
|
21475
21592
|
const typeReference = returnContractReference(annotation);
|
|
21476
|
-
if (typeReference === null || typeReference.typeName.type !==
|
|
21593
|
+
if (typeReference === null || typeReference.typeName.type !== AST_NODE_TYPES101.Identifier) {
|
|
21477
21594
|
return null;
|
|
21478
21595
|
}
|
|
21479
21596
|
return {
|
|
@@ -21490,7 +21607,7 @@ function directParseReturnCandidate(node) {
|
|
|
21490
21607
|
return parsed?.method === "parse" ? returnedOutputCandidate(parsed, node) : null;
|
|
21491
21608
|
}
|
|
21492
21609
|
function localParseReturnCandidates(node, sourceCode) {
|
|
21493
|
-
if (node.id.type !==
|
|
21610
|
+
if (node.id.type !== AST_NODE_TYPES101.Identifier || node.init?.type !== AST_NODE_TYPES101.CallExpression || node.parent.type !== AST_NODE_TYPES101.VariableDeclaration || node.parent.kind !== "const" || enclosingFunction4(node.init) === null) {
|
|
21494
21611
|
return [];
|
|
21495
21612
|
}
|
|
21496
21613
|
const parsed = zodParseCall(node.init);
|
|
@@ -21501,7 +21618,7 @@ function localParseReturnCandidates(node, sourceCode) {
|
|
|
21501
21618
|
for (const reference of variable.references) {
|
|
21502
21619
|
const identifier = reference.identifier;
|
|
21503
21620
|
const parent = identifier.parent;
|
|
21504
|
-
const output = parsed.method === "parse" ? identifier : parent.type ===
|
|
21621
|
+
const output = parsed.method === "parse" ? identifier : parent.type === AST_NODE_TYPES101.MemberExpression && parent.object === identifier && ASTUtils62.getPropertyName(parent) !== null && (ASTUtils62.getPropertyName(parent) ?? "") === "data" ? parent : null;
|
|
21505
21622
|
if (output === null) continue;
|
|
21506
21623
|
const candidate2 = returnedOutputCandidate(parsed, output);
|
|
21507
21624
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
@@ -21512,17 +21629,17 @@ function directReturnOwner(node) {
|
|
|
21512
21629
|
let current = node;
|
|
21513
21630
|
while (current.parent !== void 0) {
|
|
21514
21631
|
const parent = current.parent;
|
|
21515
|
-
if (parent.type ===
|
|
21632
|
+
if (parent.type === AST_NODE_TYPES101.ReturnStatement) {
|
|
21516
21633
|
return parent.argument === current ? enclosingFunction4(parent) : null;
|
|
21517
21634
|
}
|
|
21518
|
-
if (parent.type ===
|
|
21635
|
+
if (parent.type === AST_NODE_TYPES101.ArrowFunctionExpression && parent.expression && parent.body === current) {
|
|
21519
21636
|
return parent;
|
|
21520
21637
|
}
|
|
21521
|
-
if (parent.type ===
|
|
21638
|
+
if (parent.type === AST_NODE_TYPES101.AwaitExpression && parent.argument === current) {
|
|
21522
21639
|
current = parent;
|
|
21523
21640
|
continue;
|
|
21524
21641
|
}
|
|
21525
|
-
if (parent.type ===
|
|
21642
|
+
if (parent.type === AST_NODE_TYPES101.ConditionalExpression) {
|
|
21526
21643
|
const parsedWhenTrue = parent.consequent === current && isNullishExpression(parent.alternate);
|
|
21527
21644
|
const parsedWhenFalse = parent.alternate === current && isNullishExpression(parent.consequent);
|
|
21528
21645
|
if (parsedWhenTrue || parsedWhenFalse) {
|
|
@@ -21535,12 +21652,12 @@ function directReturnOwner(node) {
|
|
|
21535
21652
|
return null;
|
|
21536
21653
|
}
|
|
21537
21654
|
function isNullishExpression(node) {
|
|
21538
|
-
return node.type ===
|
|
21655
|
+
return node.type === AST_NODE_TYPES101.Literal && node.value === null || node.type === AST_NODE_TYPES101.Identifier && node.name === "undefined";
|
|
21539
21656
|
}
|
|
21540
21657
|
function enclosingFunction4(node) {
|
|
21541
21658
|
let current = node.parent;
|
|
21542
21659
|
while (current != null) {
|
|
21543
|
-
if (current.type ===
|
|
21660
|
+
if (current.type === AST_NODE_TYPES101.ArrowFunctionExpression || current.type === AST_NODE_TYPES101.FunctionDeclaration || current.type === AST_NODE_TYPES101.FunctionExpression) {
|
|
21544
21661
|
return current;
|
|
21545
21662
|
}
|
|
21546
21663
|
current = current.parent;
|
|
@@ -21548,45 +21665,45 @@ function enclosingFunction4(node) {
|
|
|
21548
21665
|
return null;
|
|
21549
21666
|
}
|
|
21550
21667
|
function returnContractReference(node) {
|
|
21551
|
-
if (node.type ===
|
|
21668
|
+
if (node.type === AST_NODE_TYPES101.TSUnionType) {
|
|
21552
21669
|
const substantive = node.types.filter(
|
|
21553
|
-
(member) => member.type !==
|
|
21670
|
+
(member) => member.type !== AST_NODE_TYPES101.TSNullKeyword && member.type !== AST_NODE_TYPES101.TSUndefinedKeyword
|
|
21554
21671
|
);
|
|
21555
21672
|
const [only] = substantive;
|
|
21556
21673
|
return substantive.length === 1 && only !== void 0 ? returnContractReference(only) : null;
|
|
21557
21674
|
}
|
|
21558
|
-
if (node.type ===
|
|
21675
|
+
if (node.type === AST_NODE_TYPES101.TSTypeReference && node.typeName.type === AST_NODE_TYPES101.Identifier && node.typeName.name === "Promise") {
|
|
21559
21676
|
const parameters = node.typeArguments?.params ?? [];
|
|
21560
21677
|
const [only] = parameters;
|
|
21561
21678
|
return parameters.length === 1 && only !== void 0 ? returnContractReference(only) : null;
|
|
21562
21679
|
}
|
|
21563
|
-
return node.type ===
|
|
21680
|
+
return node.type === AST_NODE_TYPES101.TSTypeReference && node.typeName.type === AST_NODE_TYPES101.Identifier && (node.typeArguments?.params.length ?? 0) === 0 ? node : null;
|
|
21564
21681
|
}
|
|
21565
21682
|
function recordZodNamespaces(node, namespaces) {
|
|
21566
21683
|
for (const statement of node.body) {
|
|
21567
|
-
if (statement.type !==
|
|
21684
|
+
if (statement.type !== AST_NODE_TYPES101.ImportDeclaration || !isZodModule(statement.source.value)) {
|
|
21568
21685
|
continue;
|
|
21569
21686
|
}
|
|
21570
21687
|
for (const specifier of statement.specifiers) {
|
|
21571
|
-
if (specifier.type ===
|
|
21688
|
+
if (specifier.type === AST_NODE_TYPES101.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES101.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES101.ImportSpecifier && importSpecifierName(specifier) === "z") {
|
|
21572
21689
|
namespaces.add(specifier.local.name);
|
|
21573
21690
|
}
|
|
21574
21691
|
}
|
|
21575
21692
|
}
|
|
21576
21693
|
}
|
|
21577
21694
|
function collectConstrainedNames(node, names) {
|
|
21578
|
-
if (node.type ===
|
|
21579
|
-
if (node.typeName.type ===
|
|
21695
|
+
if (node.type === AST_NODE_TYPES101.TSTypeReference) {
|
|
21696
|
+
if (node.typeName.type === AST_NODE_TYPES101.Identifier) names.add(node.typeName.name);
|
|
21580
21697
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
21581
21698
|
collectConstrainedNames(argument, names);
|
|
21582
21699
|
}
|
|
21583
21700
|
return;
|
|
21584
21701
|
}
|
|
21585
|
-
if (node.type ===
|
|
21702
|
+
if (node.type === AST_NODE_TYPES101.TSArrayType) {
|
|
21586
21703
|
collectConstrainedNames(node.elementType, names);
|
|
21587
21704
|
return;
|
|
21588
21705
|
}
|
|
21589
|
-
if (node.type ===
|
|
21706
|
+
if (node.type === AST_NODE_TYPES101.TSUnionType || node.type === AST_NODE_TYPES101.TSIntersectionType) {
|
|
21590
21707
|
for (const member of node.types) collectConstrainedNames(member, names);
|
|
21591
21708
|
}
|
|
21592
21709
|
}
|
|
@@ -21620,7 +21737,7 @@ function reportCandidates(context, services, schemas, candidates, zodNamespaces,
|
|
|
21620
21737
|
if (constrained) return;
|
|
21621
21738
|
if (declaration.getSourceFile() === tsSchema.getSourceFile()) {
|
|
21622
21739
|
const estreeDeclaration = services.tsNodeToESTreeNodeMap.get(declaration);
|
|
21623
|
-
if ((estreeDeclaration.type ===
|
|
21740
|
+
if ((estreeDeclaration.type === AST_NODE_TYPES101.TSInterfaceDeclaration || estreeDeclaration.type === AST_NODE_TYPES101.TSTypeAliasDeclaration) && preferZodInferOwnsDefaultTwin({
|
|
21624
21741
|
constrained,
|
|
21625
21742
|
declaration: estreeDeclaration,
|
|
21626
21743
|
initializer: schema.initializer,
|
|
@@ -21725,7 +21842,7 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
21725
21842
|
recordZodNamespaces(node, namespaces);
|
|
21726
21843
|
},
|
|
21727
21844
|
VariableDeclarator(node) {
|
|
21728
|
-
if (node.id.type ===
|
|
21845
|
+
if (node.id.type === AST_NODE_TYPES101.Identifier && node.init !== null && isModuleLevelConst2(node) && isLocalZodObjectSchema(node.init, namespaces)) {
|
|
21729
21846
|
schemas.push({ identifier: node.id, initializer: node.init, name: node.id.name });
|
|
21730
21847
|
}
|
|
21731
21848
|
candidates.push(...localParseReturnCandidates(node, context.sourceCode));
|
|
@@ -21735,13 +21852,13 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
21735
21852
|
if (candidate2 !== null) candidates.push(candidate2);
|
|
21736
21853
|
},
|
|
21737
21854
|
"MemberExpression"(node) {
|
|
21738
|
-
if (node.object.type ===
|
|
21855
|
+
if (node.object.type === AST_NODE_TYPES101.Identifier && node.property.type === AST_NODE_TYPES101.Identifier && isPreferZodInferModuleReshaper(node.property.name)) {
|
|
21739
21856
|
reshapedSchemas.add(node.object.name);
|
|
21740
21857
|
}
|
|
21741
21858
|
},
|
|
21742
21859
|
TSTypeReference(node) {
|
|
21743
21860
|
const { typeName } = node;
|
|
21744
|
-
const name = typeName.type ===
|
|
21861
|
+
const name = typeName.type === AST_NODE_TYPES101.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES101.TSQualifiedName && typeName.right.type === AST_NODE_TYPES101.Identifier ? typeName.right.name : null;
|
|
21745
21862
|
if (name === null || !isPreferZodInferTypeConstraintName(name)) return;
|
|
21746
21863
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
21747
21864
|
collectConstrainedNames(argument, constrainedTypeNames);
|
|
@@ -21765,7 +21882,7 @@ var prefer_zod_parse_output_type_default = createRule({
|
|
|
21765
21882
|
// src/rules/require-assert-never.ts
|
|
21766
21883
|
import {
|
|
21767
21884
|
ESLintUtils as ESLintUtils15,
|
|
21768
|
-
AST_NODE_TYPES as
|
|
21885
|
+
AST_NODE_TYPES as AST_NODE_TYPES102
|
|
21769
21886
|
} from "@typescript-eslint/utils";
|
|
21770
21887
|
import ts13 from "typescript";
|
|
21771
21888
|
var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
@@ -21780,14 +21897,14 @@ var REQUIRE_ASSERT_NEVER_DOCUMENTATION = {
|
|
|
21780
21897
|
]
|
|
21781
21898
|
};
|
|
21782
21899
|
var isRuntimeHandlingStatement = (statement) => {
|
|
21783
|
-
if (statement.type ===
|
|
21784
|
-
if (statement.type ===
|
|
21900
|
+
if (statement.type === AST_NODE_TYPES102.EmptyStatement) return false;
|
|
21901
|
+
if (statement.type === AST_NODE_TYPES102.BreakStatement) {
|
|
21785
21902
|
return statement.label !== null;
|
|
21786
21903
|
}
|
|
21787
|
-
if (statement.type ===
|
|
21904
|
+
if (statement.type === AST_NODE_TYPES102.TSTypeAliasDeclaration || statement.type === AST_NODE_TYPES102.TSInterfaceDeclaration) {
|
|
21788
21905
|
return false;
|
|
21789
21906
|
}
|
|
21790
|
-
if (statement.type ===
|
|
21907
|
+
if (statement.type === AST_NODE_TYPES102.BlockStatement) {
|
|
21791
21908
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
21792
21909
|
}
|
|
21793
21910
|
return true;
|
|
@@ -21803,7 +21920,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
21803
21920
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
21804
21921
|
}
|
|
21805
21922
|
const only = defaultCase.consequent[0];
|
|
21806
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
21923
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES102.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
21807
21924
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
21808
21925
|
}
|
|
21809
21926
|
return false;
|
|
@@ -21884,7 +22001,7 @@ var require_assert_never_default = createRule({
|
|
|
21884
22001
|
});
|
|
21885
22002
|
|
|
21886
22003
|
// src/rules/require-fetch-timeout.ts
|
|
21887
|
-
import { AST_NODE_TYPES as
|
|
22004
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES103, ASTUtils as ASTUtils63 } from "@typescript-eslint/utils";
|
|
21888
22005
|
var REQUIRE_FETCH_TIMEOUT_DOCUMENTATION = {
|
|
21889
22006
|
summary: "Require an explicit abort signal on locally analyzable global fetch calls.",
|
|
21890
22007
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -21911,18 +22028,18 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
21911
22028
|
return false;
|
|
21912
22029
|
}
|
|
21913
22030
|
function initProvablyLacksSignal(init, resolvesToGlobal) {
|
|
21914
|
-
if (init.type !==
|
|
22031
|
+
if (init.type !== AST_NODE_TYPES103.ObjectExpression) return false;
|
|
21915
22032
|
let lacksSignal = true;
|
|
21916
22033
|
for (const prop of init.properties) {
|
|
21917
|
-
if (prop.type ===
|
|
22034
|
+
if (prop.type === AST_NODE_TYPES103.SpreadElement) {
|
|
21918
22035
|
lacksSignal = false;
|
|
21919
22036
|
continue;
|
|
21920
22037
|
}
|
|
21921
|
-
const isSignal = !prop.computed && prop.key.type ===
|
|
22038
|
+
const isSignal = !prop.computed && prop.key.type === AST_NODE_TYPES103.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES103.Literal && prop.key.value === "signal";
|
|
21922
22039
|
if (isSignal) {
|
|
21923
22040
|
const value = prop.value;
|
|
21924
|
-
lacksSignal = prop.kind === "init" && !prop.method && (value.type ===
|
|
21925
|
-
} else if (prop.computed && prop.key.type !==
|
|
22041
|
+
lacksSignal = prop.kind === "init" && !prop.method && (value.type === AST_NODE_TYPES103.Literal && value.value === null || value.type === AST_NODE_TYPES103.Identifier && value.name === "undefined" && resolvesToGlobal(value) || value.type === AST_NODE_TYPES103.UnaryExpression && value.operator === "void" && value.argument.type === AST_NODE_TYPES103.Literal && value.argument.value === 0);
|
|
22042
|
+
} else if (prop.computed && prop.key.type !== AST_NODE_TYPES103.Literal) {
|
|
21926
22043
|
lacksSignal = false;
|
|
21927
22044
|
}
|
|
21928
22045
|
}
|
|
@@ -21930,7 +22047,7 @@ function initProvablyLacksSignal(init, resolvesToGlobal) {
|
|
|
21930
22047
|
}
|
|
21931
22048
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
21932
22049
|
node = unwrapExpression(node);
|
|
21933
|
-
return node.type ===
|
|
22050
|
+
return node.type === AST_NODE_TYPES103.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES103.TemplateLiteral || node.type === AST_NODE_TYPES103.NewExpression && node.callee.type === AST_NODE_TYPES103.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
21934
22051
|
}
|
|
21935
22052
|
var require_fetch_timeout_default = createRule({
|
|
21936
22053
|
name: "require-fetch-timeout",
|
|
@@ -21968,30 +22085,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
21968
22085
|
}
|
|
21969
22086
|
function resolvesToGlobal(identifier) {
|
|
21970
22087
|
const scope = context.sourceCode.getScope(identifier);
|
|
21971
|
-
const variable =
|
|
22088
|
+
const variable = ASTUtils63.findVariable(scope, identifier.name);
|
|
21972
22089
|
return variable === null || variable.defs.length === 0;
|
|
21973
22090
|
}
|
|
21974
22091
|
function isGlobalFetchCall2(callee) {
|
|
21975
|
-
if (callee.type ===
|
|
22092
|
+
if (callee.type === AST_NODE_TYPES103.Identifier) {
|
|
21976
22093
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
21977
22094
|
}
|
|
21978
|
-
return callee.type ===
|
|
22095
|
+
return callee.type === AST_NODE_TYPES103.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES103.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES103.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
21979
22096
|
}
|
|
21980
22097
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
21981
|
-
const variable =
|
|
22098
|
+
const variable = ASTUtils63.findVariable(
|
|
21982
22099
|
context.sourceCode.getScope(identifier),
|
|
21983
22100
|
identifier.name
|
|
21984
22101
|
);
|
|
21985
22102
|
if (variable?.defs.length !== 1) return false;
|
|
21986
22103
|
const definition = variable.defs[0];
|
|
21987
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
22104
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== AST_NODE_TYPES103.ObjectExpression || !initProvablyLacksSignal(definition.node.init, resolvesToGlobal)) {
|
|
21988
22105
|
return false;
|
|
21989
22106
|
}
|
|
21990
22107
|
for (const reference of variable.references) {
|
|
21991
22108
|
const ref = reference.identifier;
|
|
21992
22109
|
if (ref === identifier || ref === definition.name) continue;
|
|
21993
22110
|
const member = ref.parent;
|
|
21994
|
-
if (member.type !==
|
|
22111
|
+
if (member.type !== AST_NODE_TYPES103.MemberExpression || member.object !== ref || member.computed || member.property.type !== AST_NODE_TYPES103.Identifier || member.property.name === "signal" || member.parent.type !== AST_NODE_TYPES103.AssignmentExpression || member.parent.left !== member) {
|
|
21995
22112
|
return false;
|
|
21996
22113
|
}
|
|
21997
22114
|
}
|
|
@@ -21999,13 +22116,13 @@ var require_fetch_timeout_default = createRule({
|
|
|
21999
22116
|
}
|
|
22000
22117
|
function isForwardedRequest(argument) {
|
|
22001
22118
|
let value = argument;
|
|
22002
|
-
if (value.type ===
|
|
22003
|
-
const binding =
|
|
22119
|
+
if (value.type === AST_NODE_TYPES103.Identifier) {
|
|
22120
|
+
const binding = ASTUtils63.findVariable(context.sourceCode.getScope(value), value.name);
|
|
22004
22121
|
const definition = binding?.defs.length === 1 ? binding.defs[0] : void 0;
|
|
22005
22122
|
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init === null || binding?.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
22006
22123
|
value = definition.node.init;
|
|
22007
22124
|
}
|
|
22008
|
-
return value.type ===
|
|
22125
|
+
return value.type === AST_NODE_TYPES103.NewExpression && value.callee.type === AST_NODE_TYPES103.Identifier && value.callee.name === "Request" && resolvesToGlobal(value.callee);
|
|
22009
22126
|
}
|
|
22010
22127
|
return {
|
|
22011
22128
|
CallExpression(node) {
|
|
@@ -22017,7 +22134,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
22017
22134
|
if (first !== void 0 && (node.arguments.length === 1 && !isInlineUrl(first, resolvesToGlobal) || isForwardedRequest(first))) {
|
|
22018
22135
|
return;
|
|
22019
22136
|
}
|
|
22020
|
-
if (init === void 0 || initProvablyLacksSignal(init, resolvesToGlobal) || init.type ===
|
|
22137
|
+
if (init === void 0 || initProvablyLacksSignal(init, resolvesToGlobal) || init.type === AST_NODE_TYPES103.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
22021
22138
|
context.report({ node, messageId: "missingSignal" });
|
|
22022
22139
|
}
|
|
22023
22140
|
}
|
|
@@ -22026,7 +22143,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
22026
22143
|
});
|
|
22027
22144
|
|
|
22028
22145
|
// src/rules/require-interface-for-exported-class.ts
|
|
22029
|
-
import { AST_NODE_TYPES as
|
|
22146
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES104 } from "@typescript-eslint/utils";
|
|
22030
22147
|
var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
22031
22148
|
defaultLevel: "warning",
|
|
22032
22149
|
summary: "Require exported concrete classes with public behavior to declare a contract.",
|
|
@@ -22073,23 +22190,23 @@ var REQUIRE_INTERFACE_FOR_EXPORTED_CLASS_DOCUMENTATION = {
|
|
|
22073
22190
|
};
|
|
22074
22191
|
function hasPublicInstanceBehavior(node) {
|
|
22075
22192
|
return node.body.body.some((member) => {
|
|
22076
|
-
if (member.type ===
|
|
22077
|
-
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !==
|
|
22193
|
+
if (member.type === AST_NODE_TYPES104.MethodDefinition) {
|
|
22194
|
+
return member.kind !== "constructor" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.key.type !== AST_NODE_TYPES104.PrivateIdentifier;
|
|
22078
22195
|
}
|
|
22079
|
-
if (member.type !==
|
|
22196
|
+
if (member.type !== AST_NODE_TYPES104.PropertyDefinition || member.static)
|
|
22080
22197
|
return false;
|
|
22081
|
-
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type ===
|
|
22082
|
-
return member.value?.type ===
|
|
22198
|
+
if (member.accessibility === "private" || member.accessibility === "protected" || member.key.type === AST_NODE_TYPES104.PrivateIdentifier) return false;
|
|
22199
|
+
return member.value?.type === AST_NODE_TYPES104.ArrowFunctionExpression || member.value?.type === AST_NODE_TYPES104.FunctionExpression || member.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES104.TSFunctionType;
|
|
22083
22200
|
});
|
|
22084
22201
|
}
|
|
22085
22202
|
function classBindings(statement) {
|
|
22086
|
-
const declaration = statement.type ===
|
|
22087
|
-
if (declaration?.type ===
|
|
22203
|
+
const declaration = statement.type === AST_NODE_TYPES104.ExportNamedDeclaration ? statement.declaration : statement;
|
|
22204
|
+
if (declaration?.type === AST_NODE_TYPES104.ClassDeclaration) {
|
|
22088
22205
|
return declaration.id === null ? [] : [{ declaration, name: declaration.id.name }];
|
|
22089
22206
|
}
|
|
22090
|
-
if (declaration?.type !==
|
|
22207
|
+
if (declaration?.type !== AST_NODE_TYPES104.VariableDeclaration) return [];
|
|
22091
22208
|
return declaration.declarations.flatMap(
|
|
22092
|
-
(item) => item.id.type ===
|
|
22209
|
+
(item) => item.id.type === AST_NODE_TYPES104.Identifier && item.init?.type === AST_NODE_TYPES104.ClassExpression ? [{ declaration: item.init, name: item.id.name }] : []
|
|
22093
22210
|
);
|
|
22094
22211
|
}
|
|
22095
22212
|
var require_interface_for_exported_class_default = createRule({
|
|
@@ -22123,7 +22240,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
22123
22240
|
}
|
|
22124
22241
|
const exported = exportedClasses(program, classes);
|
|
22125
22242
|
for (const [declaration, exportedName] of exported) {
|
|
22126
|
-
const extendsLocalAbstractBase = declaration.superClass?.type ===
|
|
22243
|
+
const extendsLocalAbstractBase = declaration.superClass?.type === AST_NODE_TYPES104.Identifier && abstractBases.has(declaration.superClass.name);
|
|
22127
22244
|
if (declaration.abstract || declaration.implements.length > 0 || extendsLocalAbstractBase || !hasPublicInstanceBehavior(declaration)) continue;
|
|
22128
22245
|
context.report({
|
|
22129
22246
|
node: declaration.id ?? declaration,
|
|
@@ -22138,7 +22255,7 @@ var require_interface_for_exported_class_default = createRule({
|
|
|
22138
22255
|
function exportedClasses(program, classes) {
|
|
22139
22256
|
const exported = /* @__PURE__ */ new Map();
|
|
22140
22257
|
function collectExportedClass(statement) {
|
|
22141
|
-
if (statement.type ===
|
|
22258
|
+
if (statement.type === AST_NODE_TYPES104.ExportNamedDeclaration) {
|
|
22142
22259
|
for (const binding of classBindings(statement)) {
|
|
22143
22260
|
exported.set(binding.declaration, binding.name);
|
|
22144
22261
|
}
|
|
@@ -22146,13 +22263,13 @@ function exportedClasses(program, classes) {
|
|
|
22146
22263
|
collectClassSpecifiers(statement);
|
|
22147
22264
|
return;
|
|
22148
22265
|
}
|
|
22149
|
-
if (statement.type !==
|
|
22150
|
-
if (statement.declaration.type ===
|
|
22266
|
+
if (statement.type !== AST_NODE_TYPES104.ExportDefaultDeclaration) return;
|
|
22267
|
+
if (statement.declaration.type === AST_NODE_TYPES104.ClassDeclaration || statement.declaration.type === AST_NODE_TYPES104.ClassExpression) {
|
|
22151
22268
|
exported.set(
|
|
22152
22269
|
statement.declaration,
|
|
22153
22270
|
statement.declaration.id?.name ?? "default"
|
|
22154
22271
|
);
|
|
22155
|
-
} else if (statement.declaration.type ===
|
|
22272
|
+
} else if (statement.declaration.type === AST_NODE_TYPES104.Identifier) {
|
|
22156
22273
|
const candidate2 = classes.get(statement.declaration.name);
|
|
22157
22274
|
if (candidate2 !== void 0) {
|
|
22158
22275
|
exported.set(candidate2, statement.declaration.name);
|
|
@@ -22164,7 +22281,7 @@ function exportedClasses(program, classes) {
|
|
|
22164
22281
|
if (specifier.exportKind === "type") continue;
|
|
22165
22282
|
const candidate2 = classes.get(specifier.local.name);
|
|
22166
22283
|
if (candidate2 === void 0) continue;
|
|
22167
|
-
const exportedName = specifier.exported.type ===
|
|
22284
|
+
const exportedName = specifier.exported.type === AST_NODE_TYPES104.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
22168
22285
|
exported.set(candidate2, exportedName);
|
|
22169
22286
|
}
|
|
22170
22287
|
}
|
|
@@ -22175,7 +22292,7 @@ function exportedClasses(program, classes) {
|
|
|
22175
22292
|
}
|
|
22176
22293
|
|
|
22177
22294
|
// src/rules/require-sql-access-class.ts
|
|
22178
|
-
import { AST_NODE_TYPES as
|
|
22295
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES105, ASTUtils as ASTUtils64 } from "@typescript-eslint/utils";
|
|
22179
22296
|
var DIRECT_EXECUTION_METHODS = /* @__PURE__ */ new Set([
|
|
22180
22297
|
"all",
|
|
22181
22298
|
"batch",
|
|
@@ -22279,80 +22396,80 @@ function isDatabaseOperation(method, receiver) {
|
|
|
22279
22396
|
}
|
|
22280
22397
|
function databaseReceiver(node) {
|
|
22281
22398
|
node = unwrapExpression(node);
|
|
22282
|
-
if (node.type ===
|
|
22399
|
+
if (node.type === AST_NODE_TYPES105.Identifier)
|
|
22283
22400
|
return DATABASE_NAMES.test(node.name);
|
|
22284
|
-
if (node.type !==
|
|
22285
|
-
const name =
|
|
22401
|
+
if (node.type !== AST_NODE_TYPES105.MemberExpression) return false;
|
|
22402
|
+
const name = ASTUtils64.getPropertyName(node);
|
|
22286
22403
|
return name === "DB" || name !== null && DATABASE_NAMES.test(name);
|
|
22287
22404
|
}
|
|
22288
22405
|
function databaseRootMember(node) {
|
|
22289
22406
|
let current = node;
|
|
22290
22407
|
for (; ; ) {
|
|
22291
22408
|
current = unwrapExpression(current);
|
|
22292
|
-
if (current.type ===
|
|
22409
|
+
if (current.type === AST_NODE_TYPES105.ChainExpression) {
|
|
22293
22410
|
current = current.expression;
|
|
22294
22411
|
continue;
|
|
22295
22412
|
}
|
|
22296
|
-
if (current.type ===
|
|
22297
|
-
if (current.callee.type !==
|
|
22413
|
+
if (current.type === AST_NODE_TYPES105.CallExpression) {
|
|
22414
|
+
if (current.callee.type !== AST_NODE_TYPES105.MemberExpression) return null;
|
|
22298
22415
|
current = current.callee.object;
|
|
22299
22416
|
continue;
|
|
22300
22417
|
}
|
|
22301
|
-
if (current.type ===
|
|
22302
|
-
if (current.object.type ===
|
|
22303
|
-
return
|
|
22418
|
+
if (current.type === AST_NODE_TYPES105.MemberExpression) {
|
|
22419
|
+
if (current.object.type === AST_NODE_TYPES105.ThisExpression)
|
|
22420
|
+
return ASTUtils64.getPropertyName(current);
|
|
22304
22421
|
current = current.object;
|
|
22305
22422
|
continue;
|
|
22306
22423
|
}
|
|
22307
|
-
return current.type ===
|
|
22424
|
+
return current.type === AST_NODE_TYPES105.Identifier ? current.name : null;
|
|
22308
22425
|
}
|
|
22309
22426
|
}
|
|
22310
22427
|
function expressionHasDatabaseMarker(node) {
|
|
22311
22428
|
let current = node;
|
|
22312
22429
|
for (; ; ) {
|
|
22313
22430
|
current = unwrapExpression(current);
|
|
22314
|
-
if (current.type ===
|
|
22431
|
+
if (current.type === AST_NODE_TYPES105.ChainExpression) {
|
|
22315
22432
|
current = current.expression;
|
|
22316
22433
|
continue;
|
|
22317
22434
|
}
|
|
22318
|
-
if (current.type ===
|
|
22319
|
-
if (current.callee.type !==
|
|
22435
|
+
if (current.type === AST_NODE_TYPES105.CallExpression) {
|
|
22436
|
+
if (current.callee.type !== AST_NODE_TYPES105.MemberExpression) return false;
|
|
22320
22437
|
current = current.callee.object;
|
|
22321
22438
|
continue;
|
|
22322
22439
|
}
|
|
22323
|
-
if (current.type ===
|
|
22324
|
-
const name =
|
|
22440
|
+
if (current.type === AST_NODE_TYPES105.MemberExpression) {
|
|
22441
|
+
const name = ASTUtils64.getPropertyName(current);
|
|
22325
22442
|
if (name === "DB" || name !== null && DATABASE_NAMES.test(name))
|
|
22326
22443
|
return true;
|
|
22327
22444
|
current = current.object;
|
|
22328
22445
|
continue;
|
|
22329
22446
|
}
|
|
22330
|
-
return current.type ===
|
|
22447
|
+
return current.type === AST_NODE_TYPES105.Identifier && DATABASE_NAMES.test(current.name);
|
|
22331
22448
|
}
|
|
22332
22449
|
}
|
|
22333
22450
|
function expressionCallsBuilder(node) {
|
|
22334
22451
|
let current = node;
|
|
22335
22452
|
for (; ; ) {
|
|
22336
22453
|
current = unwrapExpression(current);
|
|
22337
|
-
if (current.type ===
|
|
22454
|
+
if (current.type === AST_NODE_TYPES105.ChainExpression) {
|
|
22338
22455
|
current = current.expression;
|
|
22339
22456
|
continue;
|
|
22340
22457
|
}
|
|
22341
|
-
if (current.type ===
|
|
22342
|
-
if (current.callee.type !==
|
|
22343
|
-
const name =
|
|
22458
|
+
if (current.type === AST_NODE_TYPES105.CallExpression) {
|
|
22459
|
+
if (current.callee.type !== AST_NODE_TYPES105.MemberExpression) return false;
|
|
22460
|
+
const name = ASTUtils64.getPropertyName(current.callee);
|
|
22344
22461
|
if (name !== null && BUILDER_METHODS.has(name)) return true;
|
|
22345
22462
|
current = current.callee.object;
|
|
22346
22463
|
continue;
|
|
22347
22464
|
}
|
|
22348
|
-
if (current.type !==
|
|
22465
|
+
if (current.type !== AST_NODE_TYPES105.MemberExpression) return false;
|
|
22349
22466
|
current = current.object;
|
|
22350
22467
|
}
|
|
22351
22468
|
}
|
|
22352
22469
|
function owningClass2(node) {
|
|
22353
22470
|
let current = node.parent;
|
|
22354
22471
|
while (current != null) {
|
|
22355
|
-
if (current.type ===
|
|
22472
|
+
if (current.type === AST_NODE_TYPES105.ClassDeclaration || current.type === AST_NODE_TYPES105.ClassExpression)
|
|
22356
22473
|
return current;
|
|
22357
22474
|
current = current.parent;
|
|
22358
22475
|
}
|
|
@@ -22361,25 +22478,25 @@ function owningClass2(node) {
|
|
|
22361
22478
|
function injectedMembers(owner) {
|
|
22362
22479
|
const injected = /* @__PURE__ */ new Set();
|
|
22363
22480
|
const constructor = owner.body.body.find(
|
|
22364
|
-
(member) => member.type ===
|
|
22481
|
+
(member) => member.type === AST_NODE_TYPES105.MethodDefinition && member.kind === "constructor"
|
|
22365
22482
|
);
|
|
22366
22483
|
if (constructor === void 0) return injected;
|
|
22367
22484
|
const parameters = /* @__PURE__ */ new Set();
|
|
22368
22485
|
for (const parameter of constructor.value.params) {
|
|
22369
22486
|
for (const name of parameterNames(parameter)) parameters.add(name);
|
|
22370
|
-
if (parameter.type !==
|
|
22371
|
-
const value = parameter.parameter.type ===
|
|
22372
|
-
if (value.type ===
|
|
22487
|
+
if (parameter.type !== AST_NODE_TYPES105.TSParameterProperty) continue;
|
|
22488
|
+
const value = parameter.parameter.type === AST_NODE_TYPES105.AssignmentPattern ? parameter.parameter.left : parameter.parameter;
|
|
22489
|
+
if (value.type === AST_NODE_TYPES105.Identifier) injected.add(value.name);
|
|
22373
22490
|
}
|
|
22374
22491
|
const body2 = constructor.value.body;
|
|
22375
22492
|
if (body2 === null) return injected;
|
|
22376
22493
|
function collectInjectedMember(statement) {
|
|
22377
|
-
if (statement.type !==
|
|
22494
|
+
if (statement.type !== AST_NODE_TYPES105.ExpressionStatement || statement.expression.type !== AST_NODE_TYPES105.AssignmentExpression || statement.expression.operator !== "=") return;
|
|
22378
22495
|
const { left, right } = statement.expression;
|
|
22379
|
-
if (left.type !==
|
|
22496
|
+
if (left.type !== AST_NODE_TYPES105.MemberExpression) return;
|
|
22380
22497
|
const target = thisRootMember(left);
|
|
22381
22498
|
if (target === null) return;
|
|
22382
|
-
const source = right.type ===
|
|
22499
|
+
const source = right.type === AST_NODE_TYPES105.Identifier ? right.name : right.type === AST_NODE_TYPES105.MemberExpression && right.object.type === AST_NODE_TYPES105.Identifier ? right.object.name : null;
|
|
22383
22500
|
if (source !== null && parameters.has(source)) injected.add(target);
|
|
22384
22501
|
}
|
|
22385
22502
|
for (const statement of body2.body) {
|
|
@@ -22390,26 +22507,26 @@ function injectedMembers(owner) {
|
|
|
22390
22507
|
function thisRootMember(node) {
|
|
22391
22508
|
let current = node;
|
|
22392
22509
|
let root = null;
|
|
22393
|
-
while (current.type ===
|
|
22394
|
-
const name =
|
|
22510
|
+
while (current.type === AST_NODE_TYPES105.MemberExpression) {
|
|
22511
|
+
const name = ASTUtils64.getPropertyName(current);
|
|
22395
22512
|
if (name === null) return null;
|
|
22396
22513
|
root = name;
|
|
22397
22514
|
current = current.object;
|
|
22398
22515
|
}
|
|
22399
|
-
return current.type ===
|
|
22516
|
+
return current.type === AST_NODE_TYPES105.ThisExpression ? root : null;
|
|
22400
22517
|
}
|
|
22401
22518
|
function parameterNames(parameter) {
|
|
22402
22519
|
let value = parameter;
|
|
22403
|
-
if (value.type ===
|
|
22404
|
-
if (value.type ===
|
|
22405
|
-
if (value.type ===
|
|
22406
|
-
if (value.type !==
|
|
22520
|
+
if (value.type === AST_NODE_TYPES105.TSParameterProperty) value = value.parameter;
|
|
22521
|
+
if (value.type === AST_NODE_TYPES105.AssignmentPattern) value = value.left;
|
|
22522
|
+
if (value.type === AST_NODE_TYPES105.Identifier) return /* @__PURE__ */ new Set([value.name]);
|
|
22523
|
+
if (value.type !== AST_NODE_TYPES105.ObjectPattern) return /* @__PURE__ */ new Set();
|
|
22407
22524
|
return new Set(
|
|
22408
22525
|
value.properties.flatMap((property) => {
|
|
22409
|
-
if (property.type ===
|
|
22410
|
-
return property.argument.type ===
|
|
22411
|
-
const target = property.value.type ===
|
|
22412
|
-
return target.type ===
|
|
22526
|
+
if (property.type === AST_NODE_TYPES105.RestElement)
|
|
22527
|
+
return property.argument.type === AST_NODE_TYPES105.Identifier ? [property.argument.name] : [];
|
|
22528
|
+
const target = property.value.type === AST_NODE_TYPES105.AssignmentPattern ? property.value.left : property.value;
|
|
22529
|
+
return target.type === AST_NODE_TYPES105.Identifier ? [target.name] : [];
|
|
22413
22530
|
})
|
|
22414
22531
|
);
|
|
22415
22532
|
}
|
|
@@ -22434,20 +22551,20 @@ var require_sql_access_class_default = createRule({
|
|
|
22434
22551
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
22435
22552
|
if (seen.has(node)) return false;
|
|
22436
22553
|
seen.add(node);
|
|
22437
|
-
if (node.type ===
|
|
22438
|
-
const binding =
|
|
22554
|
+
if (node.type === AST_NODE_TYPES105.Identifier) {
|
|
22555
|
+
const binding = ASTUtils64.findVariable(context.sourceCode.getScope(node), node.name);
|
|
22439
22556
|
if (binding?.defs.length !== 1 || binding.references.some((reference) => reference.isWrite() && reference.init !== true)) return false;
|
|
22440
22557
|
const definition = binding.defs[0];
|
|
22441
22558
|
return definition?.type === "Variable" && definition.node.init !== null && knownNonDatabase(definition.node.init, seen);
|
|
22442
22559
|
}
|
|
22443
|
-
return node.type ===
|
|
22560
|
+
return node.type === AST_NODE_TYPES105.NewExpression && unwrappedNodeCallee?.type === AST_NODE_TYPES105.Identifier && ["Map", "WeakMap", "URLSearchParams"].includes(unwrappedNodeCallee.name) && (ASTUtils64.findVariable(context.sourceCode.getScope(unwrappedNodeCallee), unwrappedNodeCallee.name)?.defs.length ?? 0) === 0;
|
|
22444
22561
|
}
|
|
22445
22562
|
return {
|
|
22446
22563
|
CallExpression(node) {
|
|
22447
22564
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
22448
|
-
if (unwrappedNodeCallee.type !==
|
|
22565
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES105.MemberExpression)
|
|
22449
22566
|
return;
|
|
22450
|
-
const method =
|
|
22567
|
+
const method = ASTUtils64.getPropertyName(unwrappedNodeCallee);
|
|
22451
22568
|
if (knownNonDatabase(unwrappedNodeCallee.object)) return;
|
|
22452
22569
|
if (method === null || !isDatabaseOperation(method, unwrappedNodeCallee.object))
|
|
22453
22570
|
return;
|
|
@@ -22463,7 +22580,7 @@ var require_sql_access_class_default = createRule({
|
|
|
22463
22580
|
});
|
|
22464
22581
|
|
|
22465
22582
|
// src/rules/require-static-next-matcher.ts
|
|
22466
|
-
import { AST_NODE_TYPES as
|
|
22583
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES106 } from "@typescript-eslint/utils";
|
|
22467
22584
|
var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
22468
22585
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
22469
22586
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -22479,27 +22596,27 @@ var REQUIRE_STATIC_NEXT_MATCHER_DOCUMENTATION = {
|
|
|
22479
22596
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
22480
22597
|
function isStaticValue(node) {
|
|
22481
22598
|
const value = unwrapExpression(node);
|
|
22482
|
-
if (value.type ===
|
|
22599
|
+
if (value.type === AST_NODE_TYPES106.Literal) {
|
|
22483
22600
|
return true;
|
|
22484
22601
|
}
|
|
22485
|
-
if (value.type ===
|
|
22602
|
+
if (value.type === AST_NODE_TYPES106.TemplateLiteral) {
|
|
22486
22603
|
return value.expressions.length === 0;
|
|
22487
22604
|
}
|
|
22488
|
-
if (value.type ===
|
|
22605
|
+
if (value.type === AST_NODE_TYPES106.ArrayExpression) {
|
|
22489
22606
|
return value.elements.every(
|
|
22490
|
-
(element) => element !== null && element.type !==
|
|
22607
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES106.SpreadElement && isStaticValue(element)
|
|
22491
22608
|
);
|
|
22492
22609
|
}
|
|
22493
|
-
if (value.type ===
|
|
22610
|
+
if (value.type === AST_NODE_TYPES106.ObjectExpression) {
|
|
22494
22611
|
return value.properties.every(
|
|
22495
|
-
(property) => property.type ===
|
|
22612
|
+
(property) => property.type === AST_NODE_TYPES106.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES106.AssignmentPattern && isStaticValue(property.value)
|
|
22496
22613
|
);
|
|
22497
22614
|
}
|
|
22498
22615
|
return false;
|
|
22499
22616
|
}
|
|
22500
22617
|
function propertyName5(property) {
|
|
22501
|
-
if (!property.computed && property.key.type ===
|
|
22502
|
-
return property.key.type ===
|
|
22618
|
+
if (!property.computed && property.key.type === AST_NODE_TYPES106.Identifier) return property.key.name;
|
|
22619
|
+
return property.key.type === AST_NODE_TYPES106.Literal && typeof property.key.value === "string" ? property.key.value : null;
|
|
22503
22620
|
}
|
|
22504
22621
|
var require_static_next_matcher_default = createRule({
|
|
22505
22622
|
name: "require-static-next-matcher",
|
|
@@ -22521,19 +22638,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
22521
22638
|
}
|
|
22522
22639
|
return {
|
|
22523
22640
|
ExportNamedDeclaration(node) {
|
|
22524
|
-
if (node.declaration?.type !==
|
|
22641
|
+
if (node.declaration?.type !== AST_NODE_TYPES106.VariableDeclaration) {
|
|
22525
22642
|
return;
|
|
22526
22643
|
}
|
|
22527
22644
|
for (const declaration of node.declaration.declarations) {
|
|
22528
|
-
if (declaration.id.type !==
|
|
22645
|
+
if (declaration.id.type !== AST_NODE_TYPES106.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
22529
22646
|
continue;
|
|
22530
22647
|
}
|
|
22531
22648
|
const config = unwrapExpression(declaration.init);
|
|
22532
|
-
if (config.type !==
|
|
22649
|
+
if (config.type !== AST_NODE_TYPES106.ObjectExpression) {
|
|
22533
22650
|
continue;
|
|
22534
22651
|
}
|
|
22535
22652
|
for (const property of config.properties) {
|
|
22536
|
-
if (property.type !==
|
|
22653
|
+
if (property.type !== AST_NODE_TYPES106.Property || propertyName5(property) !== "matcher" || property.value.type === AST_NODE_TYPES106.AssignmentPattern) {
|
|
22537
22654
|
continue;
|
|
22538
22655
|
}
|
|
22539
22656
|
if (!isStaticValue(property.value)) {
|
|
@@ -22547,7 +22664,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
22547
22664
|
});
|
|
22548
22665
|
|
|
22549
22666
|
// src/rules/require-use-form-default-values.ts
|
|
22550
|
-
import { AST_NODE_TYPES as
|
|
22667
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES107, ASTUtils as ASTUtils65 } from "@typescript-eslint/utils";
|
|
22551
22668
|
var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
22552
22669
|
summary: "Require explicit form-level initialization or a field default for directly bound Controller fields.",
|
|
22553
22670
|
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.",
|
|
@@ -22580,8 +22697,8 @@ var REQUIRE_USE_FORM_DEFAULT_VALUES_DOCUMENTATION = {
|
|
|
22580
22697
|
};
|
|
22581
22698
|
function staticPropertyName2(property) {
|
|
22582
22699
|
if (property.computed) return null;
|
|
22583
|
-
if (property.key.type ===
|
|
22584
|
-
if (property.key.type ===
|
|
22700
|
+
if (property.key.type === AST_NODE_TYPES107.Identifier) return property.key.name;
|
|
22701
|
+
if (property.key.type === AST_NODE_TYPES107.Literal && typeof property.key.value === "string") return property.key.value;
|
|
22585
22702
|
return null;
|
|
22586
22703
|
}
|
|
22587
22704
|
var require_use_form_default_values_default = createRule({
|
|
@@ -22598,7 +22715,7 @@ var require_use_form_default_values_default = createRule({
|
|
|
22598
22715
|
const imported = /* @__PURE__ */ new Map();
|
|
22599
22716
|
const uninitializedForms = /* @__PURE__ */ new Set();
|
|
22600
22717
|
const uninitializedControls = /* @__PURE__ */ new Set();
|
|
22601
|
-
const bindingNamed = (node, name) =>
|
|
22718
|
+
const bindingNamed = (node, name) => ASTUtils65.findVariable(context.sourceCode.getScope(node), name);
|
|
22602
22719
|
const bindingOf = (node) => bindingNamed(node, node.name);
|
|
22603
22720
|
const stable = (variable) => !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
22604
22721
|
const importedKind = (node) => {
|
|
@@ -22611,22 +22728,22 @@ var require_use_form_default_values_default = createRule({
|
|
|
22611
22728
|
};
|
|
22612
22729
|
const isDefinitelyUndefined = (node) => {
|
|
22613
22730
|
const value = unwrapExpression(node);
|
|
22614
|
-
return value.type ===
|
|
22731
|
+
return value.type === AST_NODE_TYPES107.UnaryExpression && value.operator === "void" || value.type === AST_NODE_TYPES107.Identifier && value.name === "undefined" && (bindingOf(value)?.defs.length ?? 0) === 0;
|
|
22615
22732
|
};
|
|
22616
22733
|
const uninitializedUseFormCall = (node) => {
|
|
22617
22734
|
node = unwrapExpression(node);
|
|
22618
22735
|
const unwrappedNodeCallee = node.type === "CallExpression" || node.type === "NewExpression" ? unwrapExpression(node.callee) : null;
|
|
22619
|
-
if (node.type !==
|
|
22736
|
+
if (node.type !== AST_NODE_TYPES107.CallExpression || unwrappedNodeCallee?.type !== AST_NODE_TYPES107.Identifier || importedKind(unwrappedNodeCallee) !== "useForm") return false;
|
|
22620
22737
|
const options = node.arguments[0];
|
|
22621
|
-
return options?.type !==
|
|
22738
|
+
return options?.type !== AST_NODE_TYPES107.SpreadElement && initializationState(options) === "uninitialized";
|
|
22622
22739
|
};
|
|
22623
22740
|
const initializationState = (node) => {
|
|
22624
22741
|
if (node === void 0) return "uninitialized";
|
|
22625
|
-
if (node.type !==
|
|
22742
|
+
if (node.type !== AST_NODE_TYPES107.ObjectExpression) return "unknown";
|
|
22626
22743
|
const initialization = /* @__PURE__ */ new Map();
|
|
22627
22744
|
for (const property of node.properties) {
|
|
22628
|
-
if (property.type ===
|
|
22629
|
-
if (property.type !==
|
|
22745
|
+
if (property.type === AST_NODE_TYPES107.SpreadElement || property.computed) return "unknown";
|
|
22746
|
+
if (property.type !== AST_NODE_TYPES107.Property) continue;
|
|
22630
22747
|
const name = staticPropertyName2(property);
|
|
22631
22748
|
if (name === "defaultValues" || name === "values") initialization.set(name, !isDefinitelyUndefined(property.value));
|
|
22632
22749
|
}
|
|
@@ -22634,25 +22751,25 @@ var require_use_form_default_values_default = createRule({
|
|
|
22634
22751
|
};
|
|
22635
22752
|
const isUninitializedForm = (node) => {
|
|
22636
22753
|
node = unwrapExpression(node);
|
|
22637
|
-
if (node.type !==
|
|
22754
|
+
if (node.type !== AST_NODE_TYPES107.Identifier) return false;
|
|
22638
22755
|
const variable = bindingOf(node);
|
|
22639
22756
|
return variable !== null && stable(variable) && uninitializedForms.has(variable);
|
|
22640
22757
|
};
|
|
22641
22758
|
const isUninitializedControl = (node) => {
|
|
22642
22759
|
node = unwrapExpression(node);
|
|
22643
|
-
if (node.type ===
|
|
22760
|
+
if (node.type === AST_NODE_TYPES107.Identifier) {
|
|
22644
22761
|
const variable = bindingOf(node);
|
|
22645
22762
|
return variable !== null && stable(variable) && uninitializedControls.has(variable);
|
|
22646
22763
|
}
|
|
22647
|
-
return node.type ===
|
|
22764
|
+
return node.type === AST_NODE_TYPES107.MemberExpression && ASTUtils65.getPropertyName(node) !== null && (ASTUtils65.getPropertyName(node) ?? "") === "control" && isUninitializedForm(node.object);
|
|
22648
22765
|
};
|
|
22649
22766
|
const fieldOptionsNeedDefault = (node) => {
|
|
22650
|
-
if (node?.type !==
|
|
22767
|
+
if (node?.type !== AST_NODE_TYPES107.ObjectExpression) return false;
|
|
22651
22768
|
let control = null;
|
|
22652
22769
|
let hasDefault = false;
|
|
22653
22770
|
for (const property of node.properties) {
|
|
22654
|
-
if (property.type ===
|
|
22655
|
-
if (property.type !==
|
|
22771
|
+
if (property.type === AST_NODE_TYPES107.SpreadElement || property.computed) return false;
|
|
22772
|
+
if (property.type !== AST_NODE_TYPES107.Property) continue;
|
|
22656
22773
|
const name = staticPropertyName2(property);
|
|
22657
22774
|
if (name === "control") control = property.value;
|
|
22658
22775
|
if (name === "defaultValue") hasDefault = !isDefinitelyUndefined(property.value);
|
|
@@ -22662,14 +22779,14 @@ var require_use_form_default_values_default = createRule({
|
|
|
22662
22779
|
const jsxAttribute = (node, name) => {
|
|
22663
22780
|
let result = null;
|
|
22664
22781
|
for (const attribute of node.attributes) {
|
|
22665
|
-
if (attribute.type ===
|
|
22666
|
-
if (attribute.name.type ===
|
|
22782
|
+
if (attribute.type === AST_NODE_TYPES107.JSXSpreadAttribute) return null;
|
|
22783
|
+
if (attribute.name.type === AST_NODE_TYPES107.JSXIdentifier && attribute.name.name === name) result = attribute;
|
|
22667
22784
|
}
|
|
22668
22785
|
return result;
|
|
22669
22786
|
};
|
|
22670
22787
|
const trackDestructuredControl = (pattern) => {
|
|
22671
22788
|
for (const property of pattern.properties) {
|
|
22672
|
-
if (property.type !==
|
|
22789
|
+
if (property.type !== AST_NODE_TYPES107.Property || staticPropertyName2(property) !== "control" || property.value.type !== AST_NODE_TYPES107.Identifier) continue;
|
|
22673
22790
|
const variable = bindingOf(property.value);
|
|
22674
22791
|
if (variable !== null) uninitializedControls.add(variable);
|
|
22675
22792
|
}
|
|
@@ -22678,8 +22795,8 @@ var require_use_form_default_values_default = createRule({
|
|
|
22678
22795
|
ImportDeclaration(node) {
|
|
22679
22796
|
if (node.source.value !== "react-hook-form") return;
|
|
22680
22797
|
for (const specifier of node.specifiers) {
|
|
22681
|
-
if (specifier.type !==
|
|
22682
|
-
const name = specifier.imported.type ===
|
|
22798
|
+
if (specifier.type !== AST_NODE_TYPES107.ImportSpecifier) continue;
|
|
22799
|
+
const name = specifier.imported.type === AST_NODE_TYPES107.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
22683
22800
|
if (name !== "Controller" && name !== "useController" && name !== "useForm") continue;
|
|
22684
22801
|
const variable = bindingOf(specifier.local);
|
|
22685
22802
|
if (variable !== null) imported.set(variable, name);
|
|
@@ -22688,35 +22805,35 @@ var require_use_form_default_values_default = createRule({
|
|
|
22688
22805
|
VariableDeclarator(node) {
|
|
22689
22806
|
if (node.init === null) return;
|
|
22690
22807
|
if (uninitializedUseFormCall(node.init)) {
|
|
22691
|
-
if (node.id.type ===
|
|
22808
|
+
if (node.id.type === AST_NODE_TYPES107.Identifier) {
|
|
22692
22809
|
const variable = bindingOf(node.id);
|
|
22693
22810
|
if (variable !== null) uninitializedForms.add(variable);
|
|
22694
|
-
} else if (node.id.type ===
|
|
22811
|
+
} else if (node.id.type === AST_NODE_TYPES107.ObjectPattern) {
|
|
22695
22812
|
trackDestructuredControl(node.id);
|
|
22696
22813
|
}
|
|
22697
22814
|
return;
|
|
22698
22815
|
}
|
|
22699
|
-
if (node.id.type ===
|
|
22816
|
+
if (node.id.type === AST_NODE_TYPES107.ObjectPattern && isUninitializedForm(node.init)) {
|
|
22700
22817
|
trackDestructuredControl(node.id);
|
|
22701
22818
|
return;
|
|
22702
22819
|
}
|
|
22703
|
-
if (node.id.type ===
|
|
22820
|
+
if (node.id.type === AST_NODE_TYPES107.Identifier && node.init.type === AST_NODE_TYPES107.MemberExpression && ASTUtils65.getPropertyName(node.init) !== null && (ASTUtils65.getPropertyName(node.init) ?? "") === "control" && isUninitializedForm(node.init.object)) {
|
|
22704
22821
|
const variable = bindingOf(node.id);
|
|
22705
22822
|
if (variable !== null) uninitializedControls.add(variable);
|
|
22706
22823
|
}
|
|
22707
22824
|
},
|
|
22708
22825
|
CallExpression(node) {
|
|
22709
22826
|
const unwrappedNodeCallee = unwrapExpression(node.callee);
|
|
22710
|
-
if (unwrappedNodeCallee.type !==
|
|
22827
|
+
if (unwrappedNodeCallee.type !== AST_NODE_TYPES107.Identifier || importedKind(unwrappedNodeCallee) !== "useController" || !fieldOptionsNeedDefault(node.arguments[0]?.type === AST_NODE_TYPES107.SpreadElement ? void 0 : node.arguments[0])) return;
|
|
22711
22828
|
context.report({ node, messageId: "requireUseFormDefaultValues" });
|
|
22712
22829
|
},
|
|
22713
22830
|
JSXOpeningElement(node) {
|
|
22714
|
-
if (node.name.type !==
|
|
22715
|
-
if (node.attributes.some((attribute) => attribute.type ===
|
|
22831
|
+
if (node.name.type !== AST_NODE_TYPES107.JSXIdentifier || importedJsxKind(node.name) !== "Controller") return;
|
|
22832
|
+
if (node.attributes.some((attribute) => attribute.type === AST_NODE_TYPES107.JSXSpreadAttribute)) return;
|
|
22716
22833
|
const control = jsxAttribute(node, "control");
|
|
22717
|
-
if (control?.value?.type !==
|
|
22834
|
+
if (control?.value?.type !== AST_NODE_TYPES107.JSXExpressionContainer || control.value.expression.type === AST_NODE_TYPES107.JSXEmptyExpression || !isUninitializedControl(control.value.expression)) return;
|
|
22718
22835
|
const defaultValue = jsxAttribute(node, "defaultValue");
|
|
22719
|
-
if (defaultValue !== null && (defaultValue.value === null || defaultValue.value.type !==
|
|
22836
|
+
if (defaultValue !== null && (defaultValue.value === null || defaultValue.value.type !== AST_NODE_TYPES107.JSXExpressionContainer || defaultValue.value.expression.type !== AST_NODE_TYPES107.JSXEmptyExpression && !isDefinitelyUndefined(defaultValue.value.expression))) return;
|
|
22720
22837
|
context.report({ node, messageId: "requireUseFormDefaultValues" });
|
|
22721
22838
|
}
|
|
22722
22839
|
};
|
|
@@ -22792,8 +22909,8 @@ var require_use_server_in_actions_file_default = createRule({
|
|
|
22792
22909
|
|
|
22793
22910
|
// src/rules/require-zod-form-validation.ts
|
|
22794
22911
|
import {
|
|
22795
|
-
AST_NODE_TYPES as
|
|
22796
|
-
ASTUtils as
|
|
22912
|
+
AST_NODE_TYPES as AST_NODE_TYPES108,
|
|
22913
|
+
ASTUtils as ASTUtils66
|
|
22797
22914
|
} from "@typescript-eslint/utils";
|
|
22798
22915
|
var REQUIRE_ZOD_FORM_VALIDATION_DOCUMENTATION = {
|
|
22799
22916
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
@@ -22820,14 +22937,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
22820
22937
|
var zodReceiverRoot = (node) => {
|
|
22821
22938
|
let current = node;
|
|
22822
22939
|
while (true) {
|
|
22823
|
-
if (current.type ===
|
|
22940
|
+
if (current.type === AST_NODE_TYPES108.Identifier) {
|
|
22824
22941
|
return current;
|
|
22825
22942
|
}
|
|
22826
|
-
if (current.type ===
|
|
22943
|
+
if (current.type === AST_NODE_TYPES108.CallExpression) {
|
|
22827
22944
|
current = current.callee;
|
|
22828
22945
|
continue;
|
|
22829
22946
|
}
|
|
22830
|
-
if (current.type ===
|
|
22947
|
+
if (current.type === AST_NODE_TYPES108.MemberExpression) {
|
|
22831
22948
|
current = current.object;
|
|
22832
22949
|
continue;
|
|
22833
22950
|
}
|
|
@@ -22836,12 +22953,12 @@ var zodReceiverRoot = (node) => {
|
|
|
22836
22953
|
};
|
|
22837
22954
|
var isFormDataMethodCall = (node) => {
|
|
22838
22955
|
let current = node;
|
|
22839
|
-
if (current.type ===
|
|
22956
|
+
if (current.type === AST_NODE_TYPES108.AwaitExpression) {
|
|
22840
22957
|
current = current.argument;
|
|
22841
22958
|
}
|
|
22842
|
-
if (current.type !==
|
|
22959
|
+
if (current.type !== AST_NODE_TYPES108.CallExpression) return false;
|
|
22843
22960
|
const callee = unwrapExpression(current.callee);
|
|
22844
|
-
return callee.type ===
|
|
22961
|
+
return callee.type === AST_NODE_TYPES108.MemberExpression && ASTUtils66.getPropertyName(callee) === "formData";
|
|
22845
22962
|
};
|
|
22846
22963
|
var require_zod_form_validation_default = createRule({
|
|
22847
22964
|
name: "require-zod-form-validation",
|
|
@@ -22862,29 +22979,29 @@ var require_zod_form_validation_default = createRule({
|
|
|
22862
22979
|
return {};
|
|
22863
22980
|
}
|
|
22864
22981
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
22865
|
-
const resolvedBinding = (identifier) =>
|
|
22982
|
+
const resolvedBinding = (identifier) => ASTUtils66.findVariable(
|
|
22866
22983
|
context.sourceCode.getScope(identifier),
|
|
22867
22984
|
identifier.name
|
|
22868
22985
|
);
|
|
22869
22986
|
const isFormDataGetCall = (node) => {
|
|
22870
22987
|
const callee = unwrapExpression(node.callee);
|
|
22871
|
-
const calleeReceiver = callee.type ===
|
|
22872
|
-
if (callee.type !==
|
|
22873
|
-
if (
|
|
22988
|
+
const calleeReceiver = callee.type === AST_NODE_TYPES108.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
22989
|
+
if (callee.type !== AST_NODE_TYPES108.MemberExpression) return false;
|
|
22990
|
+
if (ASTUtils66.getPropertyName(callee) === null || !FORM_VALUE_METHODS.has(ASTUtils66.getPropertyName(callee) ?? "")) {
|
|
22874
22991
|
return false;
|
|
22875
22992
|
}
|
|
22876
22993
|
return isFormSourceIdentifier(calleeReceiver);
|
|
22877
22994
|
};
|
|
22878
22995
|
const isFormSourceIdentifier = (node) => {
|
|
22879
22996
|
node = unwrapExpression(node);
|
|
22880
|
-
if (node.type !==
|
|
22997
|
+
if (node.type !== AST_NODE_TYPES108.Identifier) return false;
|
|
22881
22998
|
const conventionalName = /formdata/i.test(node.name);
|
|
22882
22999
|
let scope = context.sourceCode.getScope(node);
|
|
22883
23000
|
while (scope !== null) {
|
|
22884
23001
|
const variable = scope.set.get(node.name);
|
|
22885
23002
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
22886
23003
|
const def = variable.defs[0];
|
|
22887
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
23004
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES108.VariableDeclarator && def.node.init !== null) {
|
|
22888
23005
|
return isFormDataMethodCall(def.node.init);
|
|
22889
23006
|
}
|
|
22890
23007
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -22897,24 +23014,24 @@ var require_zod_form_validation_default = createRule({
|
|
|
22897
23014
|
let parent = node.parent;
|
|
22898
23015
|
while (parent !== null && parent !== void 0) {
|
|
22899
23016
|
if (isZodParseCall(parent)) return parent;
|
|
22900
|
-
if (parent.type ===
|
|
23017
|
+
if (parent.type === AST_NODE_TYPES108.CallExpression && parent.callee.type === AST_NODE_TYPES108.Identifier && ["Number", "String", "Boolean"].includes(parent.callee.name) && parent.arguments.length === 1 && (resolvedBinding(parent.callee)?.defs.length ?? 0) === 0) {
|
|
22901
23018
|
parent = parent.parent;
|
|
22902
23019
|
continue;
|
|
22903
23020
|
}
|
|
22904
|
-
if (parent.type ===
|
|
23021
|
+
if (parent.type === AST_NODE_TYPES108.CallExpression && parent.callee.type === AST_NODE_TYPES108.MemberExpression && parent.callee.object.type === AST_NODE_TYPES108.Identifier && parent.callee.object.name === "Object" && ASTUtils66.getPropertyName(parent.callee) === "fromEntries" && (resolvedBinding(parent.callee.object)?.defs.length ?? 0) === 0) {
|
|
22905
23022
|
parent = parent.parent;
|
|
22906
23023
|
continue;
|
|
22907
23024
|
}
|
|
22908
|
-
if (parent.type ===
|
|
23025
|
+
if (parent.type === AST_NODE_TYPES108.CallExpression || parent.type === AST_NODE_TYPES108.NewExpression || parent.type === AST_NODE_TYPES108.TaggedTemplateExpression || parent.type === AST_NODE_TYPES108.ArrowFunctionExpression || parent.type === AST_NODE_TYPES108.FunctionExpression || parent.type === AST_NODE_TYPES108.FunctionDeclaration) return null;
|
|
22909
23026
|
parent = parent.parent;
|
|
22910
23027
|
}
|
|
22911
23028
|
return null;
|
|
22912
23029
|
};
|
|
22913
23030
|
const isZodParseCall = (node) => {
|
|
22914
|
-
if (node.type !==
|
|
23031
|
+
if (node.type !== AST_NODE_TYPES108.CallExpression) return false;
|
|
22915
23032
|
const callee = unwrapExpression(node.callee);
|
|
22916
|
-
const calleeReceiver = callee.type ===
|
|
22917
|
-
if (callee.type !==
|
|
23033
|
+
const calleeReceiver = callee.type === AST_NODE_TYPES108.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
23034
|
+
if (callee.type !== AST_NODE_TYPES108.MemberExpression || ASTUtils66.getPropertyName(callee) === null || !ZOD_PARSE_METHODS.has(ASTUtils66.getPropertyName(callee) ?? "")) {
|
|
22918
23035
|
return false;
|
|
22919
23036
|
}
|
|
22920
23037
|
const root = zodReceiverRoot(calleeReceiver);
|
|
@@ -22928,25 +23045,25 @@ var require_zod_form_validation_default = createRule({
|
|
|
22928
23045
|
return false;
|
|
22929
23046
|
}
|
|
22930
23047
|
const definition = binding.defs[0];
|
|
22931
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
23048
|
+
if (definition?.type !== "Variable" || definition.node.type !== AST_NODE_TYPES108.VariableDeclarator) {
|
|
22932
23049
|
return false;
|
|
22933
23050
|
}
|
|
22934
23051
|
const init = definition.node.init;
|
|
22935
|
-
return init?.type ===
|
|
23052
|
+
return init?.type === AST_NODE_TYPES108.ObjectExpression || init?.type === AST_NODE_TYPES108.ArrayExpression || init?.type === AST_NODE_TYPES108.Literal || init?.type === AST_NODE_TYPES108.ArrowFunctionExpression || init?.type === AST_NODE_TYPES108.FunctionExpression;
|
|
22936
23053
|
};
|
|
22937
23054
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
22938
23055
|
const isInstanceofNarrowing = (node) => {
|
|
22939
23056
|
const parent = node.parent;
|
|
22940
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
23057
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES108.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES108.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
22941
23058
|
};
|
|
22942
23059
|
const boundDeclarator = (node) => {
|
|
22943
23060
|
let current = node;
|
|
22944
23061
|
let parent = current.parent;
|
|
22945
|
-
while ((parent.type ===
|
|
23062
|
+
while ((parent.type === AST_NODE_TYPES108.TSAsExpression || parent.type === AST_NODE_TYPES108.TSSatisfiesExpression || parent.type === AST_NODE_TYPES108.TSNonNullExpression || parent.type === AST_NODE_TYPES108.ChainExpression) && parent.expression === current) {
|
|
22946
23063
|
current = parent;
|
|
22947
23064
|
parent = current.parent;
|
|
22948
23065
|
}
|
|
22949
|
-
if (parent.type ===
|
|
23066
|
+
if (parent.type === AST_NODE_TYPES108.VariableDeclarator && parent.init === current && parent.id.type === AST_NODE_TYPES108.Identifier) {
|
|
22950
23067
|
return parent;
|
|
22951
23068
|
}
|
|
22952
23069
|
return null;
|
|
@@ -22955,7 +23072,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22955
23072
|
let current = node;
|
|
22956
23073
|
while (current.parent !== void 0) {
|
|
22957
23074
|
const parent = current.parent;
|
|
22958
|
-
if (parent.type ===
|
|
23075
|
+
if (parent.type === AST_NODE_TYPES108.BlockStatement || parent.type === AST_NODE_TYPES108.Program) {
|
|
22959
23076
|
return current;
|
|
22960
23077
|
}
|
|
22961
23078
|
current = parent;
|
|
@@ -22970,7 +23087,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22970
23087
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
22971
23088
|
return null;
|
|
22972
23089
|
}
|
|
22973
|
-
if (validationStatement.type !==
|
|
23090
|
+
if (validationStatement.type !== AST_NODE_TYPES108.VariableDeclaration && validationStatement.type !== AST_NODE_TYPES108.ExpressionStatement) {
|
|
22974
23091
|
return null;
|
|
22975
23092
|
}
|
|
22976
23093
|
const method = zodParseMethod(parse2);
|
|
@@ -22983,7 +23100,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22983
23100
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
22984
23101
|
let current = node.parent;
|
|
22985
23102
|
while (current !== void 0 && current !== statement) {
|
|
22986
|
-
if (current.type ===
|
|
23103
|
+
if (current.type === AST_NODE_TYPES108.AwaitExpression) return true;
|
|
22987
23104
|
current = current.parent;
|
|
22988
23105
|
}
|
|
22989
23106
|
return false;
|
|
@@ -22991,7 +23108,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
22991
23108
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
22992
23109
|
let current = node.parent;
|
|
22993
23110
|
while (current !== void 0 && current !== statement) {
|
|
22994
|
-
if (current.type ===
|
|
23111
|
+
if (current.type === AST_NODE_TYPES108.LogicalExpression || current.type === AST_NODE_TYPES108.ConditionalExpression) {
|
|
22995
23112
|
return true;
|
|
22996
23113
|
}
|
|
22997
23114
|
current = current.parent;
|
|
@@ -23000,20 +23117,20 @@ var require_zod_form_validation_default = createRule({
|
|
|
23000
23117
|
};
|
|
23001
23118
|
const zodParseMethod = (call) => {
|
|
23002
23119
|
const callee = unwrapExpression(call.callee);
|
|
23003
|
-
return callee.type ===
|
|
23120
|
+
return callee.type === AST_NODE_TYPES108.MemberExpression && ASTUtils66.getPropertyName(callee) !== null ? ASTUtils66.getPropertyName(callee) ?? "" : null;
|
|
23004
23121
|
};
|
|
23005
23122
|
const isSafePrevalidationInspection = (identifier) => {
|
|
23006
23123
|
const parent = identifier.parent;
|
|
23007
|
-
if (parent.type ===
|
|
23124
|
+
if (parent.type === AST_NODE_TYPES108.UnaryExpression && parent.operator === "typeof") {
|
|
23008
23125
|
return true;
|
|
23009
23126
|
}
|
|
23010
|
-
if (parent.type !==
|
|
23127
|
+
if (parent.type !== AST_NODE_TYPES108.BinaryExpression || parent.left !== identifier) {
|
|
23011
23128
|
return false;
|
|
23012
23129
|
}
|
|
23013
23130
|
if (parent.operator === "instanceof") {
|
|
23014
|
-
return parent.right.type ===
|
|
23131
|
+
return parent.right.type === AST_NODE_TYPES108.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
23015
23132
|
}
|
|
23016
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
23133
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === AST_NODE_TYPES108.Literal && parent.right.value === null || parent.right.type === AST_NODE_TYPES108.Identifier && parent.right.name === "undefined");
|
|
23017
23134
|
};
|
|
23018
23135
|
const isDescendantOf = (node, ancestor) => {
|
|
23019
23136
|
let current = node;
|
|
@@ -23024,23 +23141,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
23024
23141
|
return false;
|
|
23025
23142
|
};
|
|
23026
23143
|
const blockTerminates = (node) => {
|
|
23027
|
-
if (node.type ===
|
|
23144
|
+
if (node.type === AST_NODE_TYPES108.ReturnStatement || node.type === AST_NODE_TYPES108.ThrowStatement) {
|
|
23028
23145
|
return true;
|
|
23029
23146
|
}
|
|
23030
|
-
if (node.type !==
|
|
23147
|
+
if (node.type !== AST_NODE_TYPES108.BlockStatement || node.body.length === 0) return false;
|
|
23031
23148
|
const last = node.body.at(-1);
|
|
23032
23149
|
return last !== void 0 && blockTerminates(last);
|
|
23033
23150
|
};
|
|
23034
23151
|
const narrowingIf = (identifier) => {
|
|
23035
23152
|
const comparison = identifier.parent;
|
|
23036
|
-
if (comparison?.type !==
|
|
23153
|
+
if (comparison?.type !== AST_NODE_TYPES108.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== AST_NODE_TYPES108.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
23037
23154
|
return null;
|
|
23038
23155
|
}
|
|
23039
23156
|
const maybeNegation = comparison.parent;
|
|
23040
|
-
const negated = maybeNegation?.type ===
|
|
23157
|
+
const negated = maybeNegation?.type === AST_NODE_TYPES108.UnaryExpression && maybeNegation.operator === "!";
|
|
23041
23158
|
const test = negated ? maybeNegation : comparison;
|
|
23042
23159
|
const branch = test.parent;
|
|
23043
|
-
return branch?.type ===
|
|
23160
|
+
return branch?.type === AST_NODE_TYPES108.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
23044
23161
|
};
|
|
23045
23162
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
23046
23163
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -23060,7 +23177,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
23060
23177
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
23061
23178
|
if (variable === void 0) return false;
|
|
23062
23179
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
23063
|
-
(identifier) => identifier.type ===
|
|
23180
|
+
(identifier) => identifier.type === AST_NODE_TYPES108.Identifier
|
|
23064
23181
|
);
|
|
23065
23182
|
if (references.length === 0) return false;
|
|
23066
23183
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -23086,7 +23203,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
23086
23203
|
ImportDeclaration(node) {
|
|
23087
23204
|
if (!isZodModule(node.source.value)) return;
|
|
23088
23205
|
for (const specifier of node.specifiers) {
|
|
23089
|
-
if (specifier.type ===
|
|
23206
|
+
if (specifier.type === AST_NODE_TYPES108.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES108.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES108.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES108.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
23090
23207
|
const binding = resolvedBinding(specifier.local);
|
|
23091
23208
|
if (binding !== null) zodBindings.add(binding);
|
|
23092
23209
|
}
|
|
@@ -23176,7 +23293,7 @@ function expressionCallableName(current) {
|
|
|
23176
23293
|
}
|
|
23177
23294
|
|
|
23178
23295
|
// src/rules/stepdown.ts
|
|
23179
|
-
import { AST_NODE_TYPES as
|
|
23296
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES109, ASTUtils as ASTUtils67 } from "@typescript-eslint/utils";
|
|
23180
23297
|
var STEPDOWN_DOCUMENTATION = {
|
|
23181
23298
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
23182
23299
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -23194,7 +23311,7 @@ var STEPDOWN_DOCUMENTATION = {
|
|
|
23194
23311
|
]
|
|
23195
23312
|
};
|
|
23196
23313
|
function isFunction(node) {
|
|
23197
|
-
return node.type ===
|
|
23314
|
+
return node.type === AST_NODE_TYPES109.ArrowFunctionExpression || node.type === AST_NODE_TYPES109.FunctionDeclaration || node.type === AST_NODE_TYPES109.FunctionExpression;
|
|
23198
23315
|
}
|
|
23199
23316
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true) {
|
|
23200
23317
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.key, definition]));
|
|
@@ -23290,7 +23407,7 @@ function cycleComponents(graph) {
|
|
|
23290
23407
|
return components;
|
|
23291
23408
|
}
|
|
23292
23409
|
function isErasedExpression2(node) {
|
|
23293
|
-
return node.type ===
|
|
23410
|
+
return node.type === AST_NODE_TYPES109.TSAsExpression || node.type === AST_NODE_TYPES109.TSTypeAssertion || node.type === AST_NODE_TYPES109.TSSatisfiesExpression || node.type === AST_NODE_TYPES109.TSNonNullExpression || node.type === AST_NODE_TYPES109.TSInstantiationExpression;
|
|
23294
23411
|
}
|
|
23295
23412
|
function unwrapExpression4(node) {
|
|
23296
23413
|
let current = node;
|
|
@@ -23314,11 +23431,11 @@ function localCallCount(context, node, owner) {
|
|
|
23314
23431
|
if (current === void 0 || enclosingFunction5(context, current) !== owner) return null;
|
|
23315
23432
|
const expression = wrappedExpression(current);
|
|
23316
23433
|
const parent = expression.parent;
|
|
23317
|
-
if (parent?.type ===
|
|
23434
|
+
if (parent?.type === AST_NODE_TYPES109.CallExpression && parent.callee === expression) {
|
|
23318
23435
|
count += 1;
|
|
23319
23436
|
continue;
|
|
23320
23437
|
}
|
|
23321
|
-
if (parent?.type !==
|
|
23438
|
+
if (parent?.type !== AST_NODE_TYPES109.VariableDeclarator || parent.init !== expression || parent.id.type !== AST_NODE_TYPES109.Identifier || parent.parent.type !== AST_NODE_TYPES109.VariableDeclaration || parent.parent.kind !== "const") return null;
|
|
23322
23439
|
const variable = context.sourceCode.getDeclaredVariables(parent)[0];
|
|
23323
23440
|
if (variable === void 0 || seen.has(variable) || !stableVariable(variable)) return null;
|
|
23324
23441
|
seen.add(variable);
|
|
@@ -23333,11 +23450,11 @@ function declarationScope(context, program) {
|
|
|
23333
23450
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
23334
23451
|
const overloadNames = new Set(
|
|
23335
23452
|
program.body.flatMap((statement) => {
|
|
23336
|
-
const node = statement.type ===
|
|
23337
|
-
return node?.type ===
|
|
23453
|
+
const node = statement.type === AST_NODE_TYPES109.ExportNamedDeclaration ? statement.declaration : statement;
|
|
23454
|
+
return node?.type === AST_NODE_TYPES109.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
23338
23455
|
})
|
|
23339
23456
|
);
|
|
23340
|
-
const exported = program.type ===
|
|
23457
|
+
const exported = program.type === AST_NODE_TYPES109.Program ? exportedNames(program) : /* @__PURE__ */ new Set();
|
|
23341
23458
|
const scopeDefinitions = declarations.filter((node) => counts.get(node.name) === 1);
|
|
23342
23459
|
const definitions = scopeDefinitions.filter(
|
|
23343
23460
|
(definition) => !exported.has(definition.name) && !overloadNames.has(definition.name)
|
|
@@ -23349,7 +23466,7 @@ function declarationScope(context, program) {
|
|
|
23349
23466
|
runtimeBarrierPrefix.push((runtimeBarrierPrefix.at(-1) ?? 0) + (isDeferredModuleStatement(statement) ? 0 : 1));
|
|
23350
23467
|
}
|
|
23351
23468
|
const canMove = (helper, caller) => {
|
|
23352
|
-
if (helper.node.type ===
|
|
23469
|
+
if (helper.node.type === AST_NODE_TYPES109.FunctionDeclaration) return true;
|
|
23353
23470
|
const helperIndex = statementIndex(helper);
|
|
23354
23471
|
const callerIndex = statementIndex(caller);
|
|
23355
23472
|
return helperIndex !== void 0 && callerIndex !== void 0 && runtimeBarrierPrefix[callerIndex + 1] === runtimeBarrierPrefix[helperIndex + 1];
|
|
@@ -23391,26 +23508,26 @@ function moduleCallGraph(context, scopeDefinitions) {
|
|
|
23391
23508
|
return { calls, pinned };
|
|
23392
23509
|
}
|
|
23393
23510
|
function isDeferredModuleStatement(statement) {
|
|
23394
|
-
const node = statement.type ===
|
|
23395
|
-
if (node === null || node.type ===
|
|
23396
|
-
return node.type ===
|
|
23397
|
-
(declaration) => declaration.id.type ===
|
|
23511
|
+
const node = statement.type === AST_NODE_TYPES109.ExportNamedDeclaration || statement.type === AST_NODE_TYPES109.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
23512
|
+
if (node === null || node.type === AST_NODE_TYPES109.FunctionDeclaration || node.type === AST_NODE_TYPES109.TSDeclareFunction || node.type === AST_NODE_TYPES109.TSInterfaceDeclaration || node.type === AST_NODE_TYPES109.TSTypeAliasDeclaration || node.type === AST_NODE_TYPES109.ImportDeclaration || node.type === AST_NODE_TYPES109.ExportAllDeclaration || node.type === AST_NODE_TYPES109.EmptyStatement) return true;
|
|
23513
|
+
return node.type === AST_NODE_TYPES109.VariableDeclaration && node.declarations.every(
|
|
23514
|
+
(declaration) => declaration.id.type === AST_NODE_TYPES109.Identifier && declaration.init !== null && isFunction(unwrapExpression4(declaration.init))
|
|
23398
23515
|
);
|
|
23399
23516
|
}
|
|
23400
23517
|
function exportedNames(program) {
|
|
23401
23518
|
const names = /* @__PURE__ */ new Set();
|
|
23402
23519
|
function collectNamedExports(statement) {
|
|
23403
|
-
if (statement.type !==
|
|
23404
|
-
if (statement.declaration?.type ===
|
|
23520
|
+
if (statement.type !== AST_NODE_TYPES109.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) return;
|
|
23521
|
+
if (statement.declaration?.type === AST_NODE_TYPES109.FunctionDeclaration && statement.declaration.id !== null) {
|
|
23405
23522
|
names.add(statement.declaration.id.name);
|
|
23406
23523
|
}
|
|
23407
|
-
if (statement.declaration?.type ===
|
|
23524
|
+
if (statement.declaration?.type === AST_NODE_TYPES109.VariableDeclaration) {
|
|
23408
23525
|
for (const declarator of statement.declaration.declarations) {
|
|
23409
|
-
if (declarator.id.type ===
|
|
23526
|
+
if (declarator.id.type === AST_NODE_TYPES109.Identifier) names.add(declarator.id.name);
|
|
23410
23527
|
}
|
|
23411
23528
|
}
|
|
23412
23529
|
for (const specifier of statement.specifiers) {
|
|
23413
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
23530
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES109.Identifier) {
|
|
23414
23531
|
names.add(specifier.local.name);
|
|
23415
23532
|
}
|
|
23416
23533
|
}
|
|
@@ -23419,23 +23536,23 @@ function exportedNames(program) {
|
|
|
23419
23536
|
collectNamedExports(statement);
|
|
23420
23537
|
}
|
|
23421
23538
|
for (const statement of program.body) {
|
|
23422
|
-
if (statement.type ===
|
|
23423
|
-
if (statement.type ===
|
|
23539
|
+
if (statement.type === AST_NODE_TYPES109.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES109.Identifier) names.add(statement.declaration.name);
|
|
23540
|
+
if (statement.type === AST_NODE_TYPES109.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES109.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
23424
23541
|
}
|
|
23425
23542
|
return names;
|
|
23426
23543
|
}
|
|
23427
23544
|
function moduleDefinitions(program) {
|
|
23428
23545
|
const definitions = [];
|
|
23429
23546
|
for (const statement of program.body) {
|
|
23430
|
-
const node = statement.type ===
|
|
23431
|
-
if (node?.type ===
|
|
23547
|
+
const node = statement.type === AST_NODE_TYPES109.ExportNamedDeclaration || statement.type === AST_NODE_TYPES109.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
23548
|
+
if (node?.type === AST_NODE_TYPES109.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
23432
23549
|
definitions.push({ key: node.id.name, name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
23433
23550
|
continue;
|
|
23434
23551
|
}
|
|
23435
|
-
if (node?.type !==
|
|
23552
|
+
if (node?.type !== AST_NODE_TYPES109.VariableDeclaration || node.kind !== "const" || node.declarations.length !== 1) continue;
|
|
23436
23553
|
for (const declarator of node.declarations) {
|
|
23437
23554
|
const initializer = declarator.init === null ? null : unwrapExpression4(declarator.init);
|
|
23438
|
-
if (declarator.id.type ===
|
|
23555
|
+
if (declarator.id.type === AST_NODE_TYPES109.Identifier && initializer !== null && isFunction(initializer)) {
|
|
23439
23556
|
definitions.push({
|
|
23440
23557
|
key: declarator.id.name,
|
|
23441
23558
|
name: declarator.id.name,
|
|
@@ -23449,25 +23566,25 @@ function moduleDefinitions(program) {
|
|
|
23449
23566
|
return definitions;
|
|
23450
23567
|
}
|
|
23451
23568
|
function methodName(node) {
|
|
23452
|
-
if (node.key.type ===
|
|
23453
|
-
if (!node.computed && node.key.type ===
|
|
23454
|
-
return node.key.type ===
|
|
23569
|
+
if (node.key.type === AST_NODE_TYPES109.PrivateIdentifier) return `#${node.key.name}`;
|
|
23570
|
+
if (!node.computed && node.key.type === AST_NODE_TYPES109.Identifier) return node.key.name;
|
|
23571
|
+
return node.key.type === AST_NODE_TYPES109.Literal && typeof node.key.value === "string" ? node.key.value : null;
|
|
23455
23572
|
}
|
|
23456
23573
|
function methodKey(name, isStatic2) {
|
|
23457
23574
|
return `${isStatic2 ? "static" : "instance"}:${name}`;
|
|
23458
23575
|
}
|
|
23459
23576
|
function receiverDomain(context, object, receivers, thisIsStatic) {
|
|
23460
23577
|
const unwrapped = unwrapExpression4(object);
|
|
23461
|
-
if (unwrapped.type ===
|
|
23578
|
+
if (unwrapped.type === AST_NODE_TYPES109.ThisExpression) return thisIsStatic;
|
|
23462
23579
|
return externalReceiverDomain(context, unwrapped, receivers);
|
|
23463
23580
|
}
|
|
23464
23581
|
function externalReceiverDomain(context, object, receivers) {
|
|
23465
23582
|
const origin = receiverOrigin(context, object, receivers);
|
|
23466
23583
|
if (origin === null || typeof origin === "boolean") return origin;
|
|
23467
|
-
if (origin.type ===
|
|
23584
|
+
if (origin.type === AST_NODE_TYPES109.NewExpression) {
|
|
23468
23585
|
return receiverOrigin(context, origin.callee, receivers) === true ? false : null;
|
|
23469
23586
|
}
|
|
23470
|
-
if (origin.type ===
|
|
23587
|
+
if (origin.type === AST_NODE_TYPES109.ObjectExpression || origin.type === AST_NODE_TYPES109.ArrayExpression || origin.type === AST_NODE_TYPES109.Literal || origin.type === AST_NODE_TYPES109.ArrowFunctionExpression || origin.type === AST_NODE_TYPES109.FunctionExpression) return "unrelated";
|
|
23471
23588
|
return null;
|
|
23472
23589
|
}
|
|
23473
23590
|
function receiverOrigin(context, object, receivers) {
|
|
@@ -23475,8 +23592,8 @@ function receiverOrigin(context, object, receivers) {
|
|
|
23475
23592
|
const seen = /* @__PURE__ */ new Set();
|
|
23476
23593
|
while (true) {
|
|
23477
23594
|
const unwrapped = unwrapExpression4(current);
|
|
23478
|
-
if (unwrapped.type !==
|
|
23479
|
-
const variable =
|
|
23595
|
+
if (unwrapped.type !== AST_NODE_TYPES109.Identifier) return unwrapped;
|
|
23596
|
+
const variable = ASTUtils67.findVariable(context.sourceCode.getScope(unwrapped), unwrapped.name);
|
|
23480
23597
|
if (variable === null) return null;
|
|
23481
23598
|
const known = receivers.get(variable);
|
|
23482
23599
|
if (known !== void 0) return known;
|
|
@@ -23489,25 +23606,25 @@ function immutableInitializer(variable, seen) {
|
|
|
23489
23606
|
if (seen.has(variable) || !stableVariable(variable) || variable.defs.length !== 1) return null;
|
|
23490
23607
|
seen.add(variable);
|
|
23491
23608
|
const definition = variable.defs[0];
|
|
23492
|
-
if (definition?.node.type !==
|
|
23609
|
+
if (definition?.node.type !== AST_NODE_TYPES109.VariableDeclarator || definition.node.parent.type !== AST_NODE_TYPES109.VariableDeclaration || definition.node.parent.kind !== "const") return null;
|
|
23493
23610
|
return definition.node.init;
|
|
23494
23611
|
}
|
|
23495
23612
|
function stableVariable(variable) {
|
|
23496
23613
|
return !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
23497
23614
|
}
|
|
23498
23615
|
function referencedPropertyName(node) {
|
|
23499
|
-
if (node.property.type ===
|
|
23500
|
-
if (!node.computed && node.property.type ===
|
|
23501
|
-
return node.computed && node.property.type ===
|
|
23616
|
+
if (node.property.type === AST_NODE_TYPES109.PrivateIdentifier) return `#${node.property.name}`;
|
|
23617
|
+
if (!node.computed && node.property.type === AST_NODE_TYPES109.Identifier) return node.property.name;
|
|
23618
|
+
return node.computed && node.property.type === AST_NODE_TYPES109.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
23502
23619
|
}
|
|
23503
23620
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
23504
23621
|
visit(node, nestedFunction);
|
|
23505
|
-
const nested = nestedFunction || isFunction(node) || node.type ===
|
|
23622
|
+
const nested = nestedFunction || isFunction(node) || node.type === AST_NODE_TYPES109.ClassDeclaration || node.type === AST_NODE_TYPES109.ClassExpression;
|
|
23506
23623
|
forEachAstChild(node, visitorKeys, (child) => walk(child, visitorKeys, visit, nested));
|
|
23507
23624
|
}
|
|
23508
23625
|
function classScope(context, node, computedReferences) {
|
|
23509
23626
|
const methods = node.body.body.filter(
|
|
23510
|
-
(member) => member.type ===
|
|
23627
|
+
(member) => member.type === AST_NODE_TYPES109.MethodDefinition
|
|
23511
23628
|
);
|
|
23512
23629
|
const counts = classMethodCounts(node.body, methods);
|
|
23513
23630
|
const implementations = methods.filter((method) => isFunction(method.value));
|
|
@@ -23518,7 +23635,7 @@ function classScope(context, node, computedReferences) {
|
|
|
23518
23635
|
return name !== null && key !== null && implementationCounts.get(key) === 1 ? [{ key, name, node: method }] : [];
|
|
23519
23636
|
});
|
|
23520
23637
|
const definitions = scopeDefinitions.filter(
|
|
23521
|
-
({ key, node: method }) => (method.accessibility === "private" || method.key.type ===
|
|
23638
|
+
({ key, node: method }) => (method.accessibility === "private" || method.key.type === AST_NODE_TYPES109.PrivateIdentifier) && counts.get(key) === 1 && method.decorators.length === 0 && !method.computed && method.kind === "method"
|
|
23522
23639
|
);
|
|
23523
23640
|
if (definitions.length === 0) return;
|
|
23524
23641
|
const methodKeys = new Set(scopeDefinitions.map((definition) => definition.key));
|
|
@@ -23534,11 +23651,11 @@ function classScope(context, node, computedReferences) {
|
|
|
23534
23651
|
};
|
|
23535
23652
|
function pinDestructuredMembers(binding, domain) {
|
|
23536
23653
|
for (const property of binding.properties) {
|
|
23537
|
-
if (property.type ===
|
|
23654
|
+
if (property.type === AST_NODE_TYPES109.RestElement || property.computed) {
|
|
23538
23655
|
pinNames(null, domain);
|
|
23539
|
-
} else if (property.key.type ===
|
|
23656
|
+
} else if (property.key.type === AST_NODE_TYPES109.Identifier) {
|
|
23540
23657
|
pinNames(property.key.name, domain);
|
|
23541
|
-
} else if (property.key.type ===
|
|
23658
|
+
} else if (property.key.type === AST_NODE_TYPES109.Literal && typeof property.key.value === "string") {
|
|
23542
23659
|
pinNames(property.key.value, domain);
|
|
23543
23660
|
}
|
|
23544
23661
|
}
|
|
@@ -23560,15 +23677,15 @@ function classScope(context, node, computedReferences) {
|
|
|
23560
23677
|
}
|
|
23561
23678
|
}
|
|
23562
23679
|
const collectAlias = (current, nestedFunction) => {
|
|
23563
|
-
if (nestedFunction || current.type !==
|
|
23680
|
+
if (nestedFunction || current.type !== AST_NODE_TYPES109.VariableDeclarator || current.init === null) return;
|
|
23564
23681
|
const domain = receiverDomain(context, current.init, receivers, method.static);
|
|
23565
23682
|
if (domain === null || domain === "unrelated") return;
|
|
23566
|
-
if (current.id.type ===
|
|
23683
|
+
if (current.id.type === AST_NODE_TYPES109.ObjectPattern) {
|
|
23567
23684
|
pinDestructuredMembers(current.id, domain);
|
|
23568
23685
|
return;
|
|
23569
23686
|
}
|
|
23570
|
-
if (current.id.type !==
|
|
23571
|
-
if (current.parent.type !==
|
|
23687
|
+
if (current.id.type !== AST_NODE_TYPES109.Identifier) return;
|
|
23688
|
+
if (current.parent.type !== AST_NODE_TYPES109.VariableDeclaration || current.parent.kind !== "const") {
|
|
23572
23689
|
pinNames(null, domain);
|
|
23573
23690
|
return;
|
|
23574
23691
|
}
|
|
@@ -23577,7 +23694,7 @@ function classScope(context, node, computedReferences) {
|
|
|
23577
23694
|
const local = variable.references.every((reference) => {
|
|
23578
23695
|
if (!reference.isRead()) return true;
|
|
23579
23696
|
const expression = wrappedExpression(reference.identifier);
|
|
23580
|
-
return enclosingFunction5(context, reference.identifier) === methodFunction && expression.parent?.type ===
|
|
23697
|
+
return enclosingFunction5(context, reference.identifier) === methodFunction && expression.parent?.type === AST_NODE_TYPES109.MemberExpression && expression.parent.object === expression;
|
|
23581
23698
|
});
|
|
23582
23699
|
if (local) receivers.set(variable, domain);
|
|
23583
23700
|
else pinNames(null, domain);
|
|
@@ -23589,7 +23706,7 @@ function classScope(context, node, computedReferences) {
|
|
|
23589
23706
|
const domain2 = receiverDomain(context, destructuring.value, receivers, method.static);
|
|
23590
23707
|
if (domain2 !== "unrelated") pinDestructuredMembers(destructuring.binding, domain2);
|
|
23591
23708
|
}
|
|
23592
|
-
if (current.type !==
|
|
23709
|
+
if (current.type !== AST_NODE_TYPES109.MemberExpression) return;
|
|
23593
23710
|
const domain = receiverDomain(context, current.object, receivers, method.static);
|
|
23594
23711
|
const targetName = referencedPropertyName(current);
|
|
23595
23712
|
if (domain === "unrelated") return;
|
|
@@ -23623,9 +23740,9 @@ function classScope(context, node, computedReferences) {
|
|
|
23623
23740
|
}
|
|
23624
23741
|
for (const method of methods) collectMethodCalls(method);
|
|
23625
23742
|
for (const member of node.body.body) {
|
|
23626
|
-
if (member.type ===
|
|
23743
|
+
if (member.type === AST_NODE_TYPES109.MethodDefinition || member.type === AST_NODE_TYPES109.TSAbstractMethodDefinition) continue;
|
|
23627
23744
|
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
23628
|
-
if (current.type !==
|
|
23745
|
+
if (current.type !== AST_NODE_TYPES109.MemberExpression) return;
|
|
23629
23746
|
if (externalReceiverDomain(context, current.object, classReceivers) === "unrelated") return;
|
|
23630
23747
|
pinNames(referencedPropertyName(current));
|
|
23631
23748
|
});
|
|
@@ -23657,32 +23774,32 @@ function classScope(context, node, computedReferences) {
|
|
|
23657
23774
|
function classReceiverBindings(context, node) {
|
|
23658
23775
|
const classReceivers = /* @__PURE__ */ new Map();
|
|
23659
23776
|
if (node.id !== null) {
|
|
23660
|
-
const internal =
|
|
23777
|
+
const internal = ASTUtils67.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
23661
23778
|
if (internal !== null && stableVariable(internal)) classReceivers.set(internal, true);
|
|
23662
23779
|
}
|
|
23663
|
-
if (node.type ===
|
|
23664
|
-
const outer =
|
|
23780
|
+
if (node.type === AST_NODE_TYPES109.ClassExpression && node.parent.type === AST_NODE_TYPES109.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES109.Identifier && node.parent.parent.type === AST_NODE_TYPES109.VariableDeclaration && node.parent.parent.kind === "const") {
|
|
23781
|
+
const outer = ASTUtils67.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
23665
23782
|
if (outer !== null && stableVariable(outer)) classReceivers.set(outer, true);
|
|
23666
23783
|
}
|
|
23667
23784
|
return classReceivers;
|
|
23668
23785
|
}
|
|
23669
23786
|
function receiverDestructuring(node) {
|
|
23670
|
-
if (node.type ===
|
|
23787
|
+
if (node.type === AST_NODE_TYPES109.VariableDeclarator && node.id.type === AST_NODE_TYPES109.ObjectPattern && node.init !== null) {
|
|
23671
23788
|
return { binding: node.id, value: node.init };
|
|
23672
23789
|
}
|
|
23673
|
-
if ((node.type ===
|
|
23790
|
+
if ((node.type === AST_NODE_TYPES109.AssignmentPattern || node.type === AST_NODE_TYPES109.AssignmentExpression) && node.left.type === AST_NODE_TYPES109.ObjectPattern) {
|
|
23674
23791
|
return { binding: node.left, value: node.right };
|
|
23675
23792
|
}
|
|
23676
23793
|
return null;
|
|
23677
23794
|
}
|
|
23678
23795
|
function isClassRuntimeBarrier(member) {
|
|
23679
23796
|
switch (member.type) {
|
|
23680
|
-
case
|
|
23797
|
+
case AST_NODE_TYPES109.StaticBlock:
|
|
23681
23798
|
return true;
|
|
23682
|
-
case
|
|
23683
|
-
case
|
|
23799
|
+
case AST_NODE_TYPES109.PropertyDefinition:
|
|
23800
|
+
case AST_NODE_TYPES109.AccessorProperty:
|
|
23684
23801
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
23685
|
-
case
|
|
23802
|
+
case AST_NODE_TYPES109.MethodDefinition:
|
|
23686
23803
|
return member.computed || member.decorators.length > 0;
|
|
23687
23804
|
default:
|
|
23688
23805
|
return false;
|
|
@@ -23712,14 +23829,14 @@ var stepdown_default = createRule({
|
|
|
23712
23829
|
classes.push(node);
|
|
23713
23830
|
},
|
|
23714
23831
|
"FunctionDeclaration, FunctionExpression, ArrowFunctionExpression": (node) => {
|
|
23715
|
-
if (isFunction(node) && node.body?.type ===
|
|
23832
|
+
if (isFunction(node) && node.body?.type === AST_NODE_TYPES109.BlockStatement) functionBodies.push(node.body);
|
|
23716
23833
|
},
|
|
23717
23834
|
"Program:exit": (program) => {
|
|
23718
23835
|
declarationScope(context, program);
|
|
23719
23836
|
for (const body2 of functionBodies) declarationScope(context, body2);
|
|
23720
23837
|
const computedReferences = [];
|
|
23721
23838
|
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
23722
|
-
if (node.type ===
|
|
23839
|
+
if (node.type === AST_NODE_TYPES109.MemberExpression && node.computed) computedReferences.push(node);
|
|
23723
23840
|
});
|
|
23724
23841
|
for (const node of classes) classScope(context, node, computedReferences);
|
|
23725
23842
|
}
|
|
@@ -23736,8 +23853,8 @@ function classMethodCounts(body2, methods) {
|
|
|
23736
23853
|
}
|
|
23737
23854
|
}
|
|
23738
23855
|
for (const member of body2.body) {
|
|
23739
|
-
if (member.type !==
|
|
23740
|
-
const name = !member.computed && member.key.type ===
|
|
23856
|
+
if (member.type !== AST_NODE_TYPES109.TSAbstractMethodDefinition) continue;
|
|
23857
|
+
const name = !member.computed && member.key.type === AST_NODE_TYPES109.Identifier ? member.key.name : null;
|
|
23741
23858
|
if (name !== null) {
|
|
23742
23859
|
const key = methodKey(name, member.static);
|
|
23743
23860
|
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
@@ -23747,7 +23864,7 @@ function classMethodCounts(body2, methods) {
|
|
|
23747
23864
|
}
|
|
23748
23865
|
|
|
23749
23866
|
// src/rules/source-coupled-test.ts
|
|
23750
|
-
import { AST_NODE_TYPES as
|
|
23867
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES110, ASTUtils as ASTUtils68 } from "@typescript-eslint/utils";
|
|
23751
23868
|
var GENERAL_SOURCE_SUFFIX_RE = /\.(?:bash|sh|ya?ml|jsonc?|toml|py|[cm]?[jt]s)$/iu;
|
|
23752
23869
|
var FS_MODULES = /* @__PURE__ */ new Set(["fs", "node:fs", "fs/promises", "node:fs/promises"]);
|
|
23753
23870
|
var FS_READERS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
@@ -23821,16 +23938,16 @@ var SOURCE_COUPLED_TEST_DOCUMENTATION = {
|
|
|
23821
23938
|
function unwrap6(node) {
|
|
23822
23939
|
for (; ; ) {
|
|
23823
23940
|
node = unwrapExpression(node);
|
|
23824
|
-
if (node.type ===
|
|
23825
|
-
else if (node.type ===
|
|
23941
|
+
if (node.type === AST_NODE_TYPES110.AwaitExpression) node = node.argument;
|
|
23942
|
+
else if (node.type === AST_NODE_TYPES110.ChainExpression) node = node.expression;
|
|
23826
23943
|
else return node;
|
|
23827
23944
|
}
|
|
23828
23945
|
}
|
|
23829
23946
|
function stringValue(node) {
|
|
23830
23947
|
const current = unwrap6(node);
|
|
23831
|
-
if (current.type ===
|
|
23832
|
-
if (current.type ===
|
|
23833
|
-
if (current.type ===
|
|
23948
|
+
if (current.type === AST_NODE_TYPES110.Literal && typeof current.value === "string") return current.value;
|
|
23949
|
+
if (current.type === AST_NODE_TYPES110.TemplateLiteral && current.expressions.length === 0) return current.quasis[0]?.value.cooked ?? null;
|
|
23950
|
+
if (current.type === AST_NODE_TYPES110.BinaryExpression && current.operator === "+") {
|
|
23834
23951
|
const left = stringValue(current.left);
|
|
23835
23952
|
const right = stringValue(current.right);
|
|
23836
23953
|
return left === null || right === null ? null : left + right;
|
|
@@ -23842,7 +23959,7 @@ function importSource(node) {
|
|
|
23842
23959
|
}
|
|
23843
23960
|
function requireSource(node) {
|
|
23844
23961
|
const current = unwrap6(node);
|
|
23845
|
-
if (current.type !==
|
|
23962
|
+
if (current.type !== AST_NODE_TYPES110.CallExpression || current.callee.type !== AST_NODE_TYPES110.Identifier || current.callee.name !== "require" || current.arguments.length !== 1 || current.arguments[0]?.type === AST_NODE_TYPES110.SpreadElement) return null;
|
|
23846
23963
|
return stringValue(current.arguments[0]);
|
|
23847
23964
|
}
|
|
23848
23965
|
function newScope() {
|
|
@@ -23864,7 +23981,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23864
23981
|
const scopes = [newScope()];
|
|
23865
23982
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
23866
23983
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
23867
|
-
const bindingOf = (node) =>
|
|
23984
|
+
const bindingOf = (node) => ASTUtils68.findVariable(context.sourceCode.getScope(node), node.name);
|
|
23868
23985
|
const assertionKind = (node) => {
|
|
23869
23986
|
const binding = bindingOf(node);
|
|
23870
23987
|
if (binding === null || binding.defs.length === 0) {
|
|
@@ -23898,75 +24015,75 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23898
24015
|
const current = unwrap6(node);
|
|
23899
24016
|
const value = stringValue(current);
|
|
23900
24017
|
if (value !== null) return sourceSuffixRe.test(value);
|
|
23901
|
-
if (current.type ===
|
|
23902
|
-
if (current.type ===
|
|
24018
|
+
if (current.type === AST_NODE_TYPES110.Identifier) return visible("paths", current);
|
|
24019
|
+
if (current.type === AST_NODE_TYPES110.CallExpression || current.type === AST_NODE_TYPES110.NewExpression) {
|
|
23903
24020
|
const callee = unwrapExpression(current.callee);
|
|
23904
24021
|
const first = current.arguments[0];
|
|
23905
|
-
if (first === void 0 || first.type ===
|
|
23906
|
-
if (current.type ===
|
|
23907
|
-
if (callee.type ===
|
|
24022
|
+
if (first === void 0 || first.type === AST_NODE_TYPES110.SpreadElement) return false;
|
|
24023
|
+
if (current.type === AST_NODE_TYPES110.NewExpression && callee.type === AST_NODE_TYPES110.Identifier && callee.name === "URL" && (bindingOf(callee)?.defs.length ?? 0) === 0) return sourcePath(first);
|
|
24024
|
+
if (callee.type === AST_NODE_TYPES110.Identifier && bindingOf(callee)?.defs.some((definition) => definition.node.type === AST_NODE_TYPES110.ImportSpecifier && definition.node.imported.type === AST_NODE_TYPES110.Identifier && definition.node.imported.name === "fileURLToPath" && definition.node.parent.type === AST_NODE_TYPES110.ImportDeclaration && ["node:url", "url"].includes(String(definition.node.parent.source.value)))) return sourcePath(first);
|
|
23908
24025
|
}
|
|
23909
24026
|
return false;
|
|
23910
24027
|
};
|
|
23911
24028
|
const rawRead = (node) => {
|
|
23912
24029
|
const current = unwrap6(node);
|
|
23913
|
-
if (current.type !==
|
|
24030
|
+
if (current.type !== AST_NODE_TYPES110.CallExpression || current.arguments.length === 0) return false;
|
|
23914
24031
|
const callee = unwrap6(current.callee);
|
|
23915
|
-
const calleeReceiver = callee.type ===
|
|
23916
|
-
if (callee.type ===
|
|
24032
|
+
const calleeReceiver = callee.type === AST_NODE_TYPES110.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24033
|
+
if (callee.type === AST_NODE_TYPES110.Identifier) {
|
|
23917
24034
|
return visible("fsReaders", callee) && sourcePath(current.arguments[0]);
|
|
23918
24035
|
}
|
|
23919
|
-
if (callee.type !==
|
|
23920
|
-
const name2 =
|
|
24036
|
+
if (callee.type !== AST_NODE_TYPES110.MemberExpression) return false;
|
|
24037
|
+
const name2 = ASTUtils68.getPropertyName(callee);
|
|
23921
24038
|
const object = unwrap6(calleeReceiver);
|
|
23922
|
-
return name2 !== null && FS_READERS.has(name2) && object.type ===
|
|
24039
|
+
return name2 !== null && FS_READERS.has(name2) && object.type === AST_NODE_TYPES110.Identifier && visible("fsObjects", object) && sourcePath(current.arguments[0]);
|
|
23923
24040
|
};
|
|
23924
24041
|
const rawOrigins = (node) => {
|
|
23925
24042
|
const current = unwrap6(node);
|
|
23926
|
-
if (current.type ===
|
|
24043
|
+
if (current.type === AST_NODE_TYPES110.Identifier) return visibleRawOrigins(current);
|
|
23927
24044
|
if (rawRead(current)) return /* @__PURE__ */ new Set([`${current.range[0]}:${current.range[1]}`]);
|
|
23928
|
-
if (current.type ===
|
|
23929
|
-
if (current.type ===
|
|
23930
|
-
if (current.type !==
|
|
24045
|
+
if (current.type === AST_NODE_TYPES110.BinaryExpression && current.operator === "+") return /* @__PURE__ */ new Set([...rawOrigins(current.left), ...rawOrigins(current.right)]);
|
|
24046
|
+
if (current.type === AST_NODE_TYPES110.MemberExpression && ASTUtils68.getPropertyName(current) === "length") return rawOrigins(current.object);
|
|
24047
|
+
if (current.type !== AST_NODE_TYPES110.CallExpression) return /* @__PURE__ */ new Set();
|
|
23931
24048
|
const callee = unwrap6(current.callee);
|
|
23932
|
-
const calleeReceiver = callee.type ===
|
|
23933
|
-
if (callee.type !==
|
|
23934
|
-
const name2 =
|
|
24049
|
+
const calleeReceiver = callee.type === AST_NODE_TYPES110.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24050
|
+
if (callee.type !== AST_NODE_TYPES110.MemberExpression) return /* @__PURE__ */ new Set();
|
|
24051
|
+
const name2 = ASTUtils68.getPropertyName(callee);
|
|
23935
24052
|
return name2 !== null && TEXT_TRANSFORMS.has(name2) ? rawOrigins(calleeReceiver) : /* @__PURE__ */ new Set();
|
|
23936
24053
|
};
|
|
23937
24054
|
const evidenceOrigins = (node) => {
|
|
23938
24055
|
const current = unwrap6(node);
|
|
23939
24056
|
const direct = rawOrigins(current);
|
|
23940
24057
|
if (direct.size > 0) return direct;
|
|
23941
|
-
if (current.type ===
|
|
23942
|
-
if (current.type ===
|
|
23943
|
-
if (current.type !==
|
|
24058
|
+
if (current.type === AST_NODE_TYPES110.BinaryExpression || current.type === AST_NODE_TYPES110.LogicalExpression) return /* @__PURE__ */ new Set([...evidenceOrigins(current.left), ...evidenceOrigins(current.right)]);
|
|
24059
|
+
if (current.type === AST_NODE_TYPES110.UnaryExpression) return evidenceOrigins(current.argument);
|
|
24060
|
+
if (current.type !== AST_NODE_TYPES110.CallExpression) return /* @__PURE__ */ new Set();
|
|
23944
24061
|
const callee = unwrap6(current.callee);
|
|
23945
|
-
const calleeReceiver = callee.type ===
|
|
23946
|
-
if (callee.type !==
|
|
23947
|
-
const name2 =
|
|
24062
|
+
const calleeReceiver = callee.type === AST_NODE_TYPES110.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24063
|
+
if (callee.type !== AST_NODE_TYPES110.MemberExpression) return /* @__PURE__ */ new Set();
|
|
24064
|
+
const name2 = ASTUtils68.getPropertyName(callee);
|
|
23948
24065
|
if (name2 !== null && TEXT_PREDICATES.has(name2)) return rawOrigins(calleeReceiver);
|
|
23949
|
-
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type ===
|
|
24066
|
+
if (name2 !== null && REGEXP_PREDICATES.has(name2)) return new Set(current.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES110.SpreadElement ? [] : [...rawOrigins(argument)]));
|
|
23950
24067
|
return /* @__PURE__ */ new Set();
|
|
23951
24068
|
};
|
|
23952
24069
|
const rawAssertionOrigins = (node) => {
|
|
23953
24070
|
const callee = unwrap6(node.callee);
|
|
23954
|
-
const calleeReceiver = callee.type ===
|
|
23955
|
-
if (callee.type ===
|
|
23956
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
24071
|
+
const calleeReceiver = callee.type === AST_NODE_TYPES110.MemberExpression ? unwrapExpression(callee.object) : callee;
|
|
24072
|
+
if (callee.type === AST_NODE_TYPES110.Identifier && assertionKind(callee) === "assert") {
|
|
24073
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES110.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
23957
24074
|
}
|
|
23958
|
-
if (callee.type !==
|
|
23959
|
-
const matcher =
|
|
24075
|
+
if (callee.type !== AST_NODE_TYPES110.MemberExpression) return /* @__PURE__ */ new Set();
|
|
24076
|
+
const matcher = ASTUtils68.getPropertyName(callee);
|
|
23960
24077
|
if (matcher === null) return /* @__PURE__ */ new Set();
|
|
23961
24078
|
let receiver = unwrap6(calleeReceiver);
|
|
23962
|
-
while (receiver.type ===
|
|
23963
|
-
const expectCallee = receiver.type ===
|
|
23964
|
-
if (receiver.type ===
|
|
24079
|
+
while (receiver.type === AST_NODE_TYPES110.MemberExpression && EXPECT_MODIFIERS2.has(ASTUtils68.getPropertyName(receiver) ?? "")) receiver = unwrap6(receiver.object);
|
|
24080
|
+
const expectCallee = receiver.type === AST_NODE_TYPES110.CallExpression ? unwrapExpression(receiver.callee) : null;
|
|
24081
|
+
if (receiver.type === AST_NODE_TYPES110.CallExpression && expectCallee?.type === AST_NODE_TYPES110.Identifier && assertionKind(expectCallee) === "expect") {
|
|
23965
24082
|
if (!EXPECT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
23966
|
-
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type ===
|
|
24083
|
+
return new Set([...receiver.arguments, ...node.arguments].flatMap((argument) => argument.type === AST_NODE_TYPES110.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
23967
24084
|
}
|
|
23968
|
-
if (receiver.type !==
|
|
23969
|
-
return new Set(node.arguments.flatMap((argument) => argument.type ===
|
|
24085
|
+
if (receiver.type !== AST_NODE_TYPES110.Identifier || assertionKind(receiver) !== "assert" || !ASSERT_MATCHERS.has(matcher)) return /* @__PURE__ */ new Set();
|
|
24086
|
+
return new Set(node.arguments.flatMap((argument) => argument.type === AST_NODE_TYPES110.SpreadElement ? [] : [...evidenceOrigins(argument)]));
|
|
23970
24087
|
};
|
|
23971
24088
|
const declare = (node, state) => {
|
|
23972
24089
|
const name2 = bindingOf(node);
|
|
@@ -23988,7 +24105,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23988
24105
|
};
|
|
23989
24106
|
const sourceCollection = (node) => {
|
|
23990
24107
|
const current = unwrap6(node);
|
|
23991
|
-
return current.type ===
|
|
24108
|
+
return current.type === AST_NODE_TYPES110.ArrayExpression && current.elements.length > 0 && current.elements.every((element) => element !== null && element.type !== AST_NODE_TYPES110.SpreadElement && sourcePath(element));
|
|
23992
24109
|
};
|
|
23993
24110
|
const enterFunction = () => {
|
|
23994
24111
|
scopes.push(newScope());
|
|
@@ -23998,8 +24115,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
23998
24115
|
};
|
|
23999
24116
|
function declareFsReaders(pattern) {
|
|
24000
24117
|
for (const property of pattern.properties) {
|
|
24001
|
-
if (property.type !==
|
|
24002
|
-
const key = property.key.type ===
|
|
24118
|
+
if (property.type !== AST_NODE_TYPES110.Property || property.value.type !== AST_NODE_TYPES110.Identifier) continue;
|
|
24119
|
+
const key = property.key.type === AST_NODE_TYPES110.Identifier ? property.key.name : property.key.type === AST_NODE_TYPES110.Literal ? String(property.key.value) : "";
|
|
24003
24120
|
if (FS_READERS.has(key)) declare(property.value, { fsReader: true });
|
|
24004
24121
|
}
|
|
24005
24122
|
}
|
|
@@ -24008,8 +24125,8 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
24008
24125
|
const source = importSource(node);
|
|
24009
24126
|
if (source === null || !FS_MODULES.has(source)) return;
|
|
24010
24127
|
for (const specifier of node.specifiers) {
|
|
24011
|
-
if (specifier.type ===
|
|
24012
|
-
const imported = specifier.imported.type ===
|
|
24128
|
+
if (specifier.type === AST_NODE_TYPES110.ImportSpecifier) {
|
|
24129
|
+
const imported = specifier.imported.type === AST_NODE_TYPES110.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
24013
24130
|
if (FS_READERS.has(imported)) declare(specifier.local, { fsReader: true });
|
|
24014
24131
|
} else {
|
|
24015
24132
|
declare(specifier.local, { fsObject: true });
|
|
@@ -24022,26 +24139,26 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
24022
24139
|
if (node.init === null) return;
|
|
24023
24140
|
const required = requireSource(node.init);
|
|
24024
24141
|
const initializer = unwrap6(node.init);
|
|
24025
|
-
if (required !== null && initializer.type ===
|
|
24026
|
-
if (required !== null && FS_MODULES.has(required) && node.id.type ===
|
|
24142
|
+
if (required !== null && initializer.type === AST_NODE_TYPES110.CallExpression && initializer.callee.type === AST_NODE_TYPES110.Identifier && (bindingOf(initializer.callee)?.defs.length ?? 0) > 0) return;
|
|
24143
|
+
if (required !== null && FS_MODULES.has(required) && node.id.type === AST_NODE_TYPES110.Identifier) {
|
|
24027
24144
|
declare(node.id, { fsObject: true });
|
|
24028
24145
|
return;
|
|
24029
24146
|
}
|
|
24030
|
-
if (node.id.type ===
|
|
24147
|
+
if (node.id.type === AST_NODE_TYPES110.ObjectPattern && required !== null && FS_MODULES.has(required)) {
|
|
24031
24148
|
declareFsReaders(node.id);
|
|
24032
24149
|
return;
|
|
24033
24150
|
}
|
|
24034
|
-
if (node.id.type !==
|
|
24151
|
+
if (node.id.type !== AST_NODE_TYPES110.Identifier) return;
|
|
24035
24152
|
declare(node.id, { collection: sourceCollection(node.init), path: sourcePath(node.init), rawOrigins: rawOrigins(node.init) });
|
|
24036
24153
|
},
|
|
24037
24154
|
AssignmentExpression(node) {
|
|
24038
|
-
if (node.left.type ===
|
|
24155
|
+
if (node.left.type === AST_NODE_TYPES110.Identifier) declare(node.left, {});
|
|
24039
24156
|
},
|
|
24040
24157
|
ForOfStatement(node) {
|
|
24041
24158
|
const right = unwrap6(node.right);
|
|
24042
|
-
const collection = right.type ===
|
|
24043
|
-
const left = node.left.type ===
|
|
24044
|
-
if (collection && left?.type ===
|
|
24159
|
+
const collection = right.type === AST_NODE_TYPES110.Identifier && visible("collections", right);
|
|
24160
|
+
const left = node.left.type === AST_NODE_TYPES110.VariableDeclaration ? node.left.declarations[0]?.id : node.left;
|
|
24161
|
+
if (collection && left?.type === AST_NODE_TYPES110.Identifier) declare(left, { path: true });
|
|
24045
24162
|
},
|
|
24046
24163
|
CallExpression(node) {
|
|
24047
24164
|
const origins = rawAssertionOrigins(node);
|
|
@@ -24059,22 +24176,22 @@ var source_coupled_test_default = createSourceCoupledRule(
|
|
|
24059
24176
|
GENERAL_SOURCE_SUFFIX_RE
|
|
24060
24177
|
);
|
|
24061
24178
|
function importedAssertionKind(specifier) {
|
|
24062
|
-
if (specifier.type !==
|
|
24179
|
+
if (specifier.type !== AST_NODE_TYPES110.ImportSpecifier && specifier.type !== AST_NODE_TYPES110.ImportDefaultSpecifier && specifier.type !== AST_NODE_TYPES110.ImportNamespaceSpecifier || specifier.parent.type !== AST_NODE_TYPES110.ImportDeclaration) return null;
|
|
24063
24180
|
const source = importSource(specifier.parent);
|
|
24064
24181
|
if (source !== null && ASSERT_MODULES.has(source)) {
|
|
24065
|
-
if (specifier.type !==
|
|
24066
|
-
const imported2 = specifier.imported.type ===
|
|
24182
|
+
if (specifier.type !== AST_NODE_TYPES110.ImportSpecifier) return "assert";
|
|
24183
|
+
const imported2 = specifier.imported.type === AST_NODE_TYPES110.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
24067
24184
|
if (imported2 === "strict" || ASSERT_MATCHERS.has(imported2)) return "assert";
|
|
24068
24185
|
return null;
|
|
24069
24186
|
}
|
|
24070
|
-
if (source === null || !EXPECT_MODULES.has(source) || specifier.type !==
|
|
24071
|
-
const imported = specifier.imported.type ===
|
|
24187
|
+
if (source === null || !EXPECT_MODULES.has(source) || specifier.type !== AST_NODE_TYPES110.ImportSpecifier) return null;
|
|
24188
|
+
const imported = specifier.imported.type === AST_NODE_TYPES110.Identifier ? specifier.imported.name : String(specifier.imported.value);
|
|
24072
24189
|
if (imported === "assert" || imported === "expect") return imported;
|
|
24073
24190
|
return null;
|
|
24074
24191
|
}
|
|
24075
24192
|
|
|
24076
24193
|
// src/rules/sole-export-matches-filename.ts
|
|
24077
|
-
import { AST_NODE_TYPES as
|
|
24194
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES111 } from "@typescript-eslint/utils";
|
|
24078
24195
|
|
|
24079
24196
|
// src/rules/_is-framework-entrypoint.ts
|
|
24080
24197
|
import { readFileSync as readFileSync3 } from "fs";
|
|
@@ -24190,7 +24307,7 @@ var sole_export_matches_filename_default = createRule({
|
|
|
24190
24307
|
if (only === void 0) return;
|
|
24191
24308
|
if (isFrameworkEntrypoint(normalizedFilename, only.key)) return;
|
|
24192
24309
|
if (only.name === "onRouterTransitionStart" && /(?:^|\/)instrumentation-client\.[jt]s$/u.test(normalizedFilename)) return;
|
|
24193
|
-
if (only.name === "collections" && /(?:^|\/)src\/content\.config\.(?:ts|js|mjs)$/u.test(normalizedFilename) && program.body.some((statement) => statement.type ===
|
|
24310
|
+
if (only.name === "collections" && /(?:^|\/)src\/content\.config\.(?:ts|js|mjs)$/u.test(normalizedFilename) && program.body.some((statement) => statement.type === AST_NODE_TYPES111.ImportDeclaration && statement.source.value === "astro:content")) return;
|
|
24194
24311
|
const exportedStem = kebabCase(only.name);
|
|
24195
24312
|
if (exportedStem === "") return;
|
|
24196
24313
|
const expected = `${fileStem.startsWith("_") ? "_" : ""}${exportedStem}`;
|
|
@@ -24241,8 +24358,8 @@ var iac_source_coupled_test_default = createSourceCoupledRule(
|
|
|
24241
24358
|
|
|
24242
24359
|
// src/rules/require-pascal-case-zod-schema-name.ts
|
|
24243
24360
|
import {
|
|
24244
|
-
AST_NODE_TYPES as
|
|
24245
|
-
ASTUtils as
|
|
24361
|
+
AST_NODE_TYPES as AST_NODE_TYPES112,
|
|
24362
|
+
ASTUtils as ASTUtils69
|
|
24246
24363
|
} from "@typescript-eslint/utils";
|
|
24247
24364
|
var REQUIRE_PASCAL_CASE_ZOD_SCHEMA_NAME_DOCUMENTATION = {
|
|
24248
24365
|
summary: "Require confirmed module-level Zod schema contracts to use PascalCase with a `Schema` suffix.",
|
|
@@ -24375,19 +24492,19 @@ var SCHEMA_RETURNING_METHODS = /* @__PURE__ */ new Set([
|
|
|
24375
24492
|
"superRefine",
|
|
24376
24493
|
"transform"
|
|
24377
24494
|
]);
|
|
24378
|
-
var terminalMethodName = (callee) =>
|
|
24495
|
+
var terminalMethodName = (callee) => ASTUtils69.getPropertyName(callee) !== null ? ASTUtils69.getPropertyName(callee) ?? "" : null;
|
|
24379
24496
|
var calleeChainRoot2 = (node) => {
|
|
24380
24497
|
let current = node;
|
|
24381
24498
|
for (; ; ) {
|
|
24382
24499
|
current = unwrapExpression(current);
|
|
24383
|
-
if (current.type ===
|
|
24500
|
+
if (current.type === AST_NODE_TYPES112.Identifier) {
|
|
24384
24501
|
return current;
|
|
24385
24502
|
}
|
|
24386
|
-
if (current.type ===
|
|
24503
|
+
if (current.type === AST_NODE_TYPES112.MemberExpression) {
|
|
24387
24504
|
current = current.object;
|
|
24388
24505
|
continue;
|
|
24389
24506
|
}
|
|
24390
|
-
if (current.type ===
|
|
24507
|
+
if (current.type === AST_NODE_TYPES112.CallExpression) {
|
|
24391
24508
|
current = unwrapExpression(current.callee);
|
|
24392
24509
|
continue;
|
|
24393
24510
|
}
|
|
@@ -24399,13 +24516,13 @@ var chainMemberNames2 = (node) => {
|
|
|
24399
24516
|
let current = node;
|
|
24400
24517
|
for (; ; ) {
|
|
24401
24518
|
current = unwrapExpression(current);
|
|
24402
|
-
if (current.type ===
|
|
24403
|
-
if (
|
|
24404
|
-
names.push(
|
|
24519
|
+
if (current.type === AST_NODE_TYPES112.MemberExpression) {
|
|
24520
|
+
if (ASTUtils69.getPropertyName(current) === null) return [];
|
|
24521
|
+
names.push(ASTUtils69.getPropertyName(current) ?? "");
|
|
24405
24522
|
current = current.object;
|
|
24406
24523
|
continue;
|
|
24407
24524
|
}
|
|
24408
|
-
if (current.type ===
|
|
24525
|
+
if (current.type === AST_NODE_TYPES112.CallExpression) {
|
|
24409
24526
|
current = unwrapExpression(current.callee);
|
|
24410
24527
|
continue;
|
|
24411
24528
|
}
|
|
@@ -24416,9 +24533,9 @@ var chainMemberNames2 = (node) => {
|
|
|
24416
24533
|
};
|
|
24417
24534
|
var isModuleDeclarator = (node) => {
|
|
24418
24535
|
const declaration = node.parent;
|
|
24419
|
-
if (declaration.type !==
|
|
24536
|
+
if (declaration.type !== AST_NODE_TYPES112.VariableDeclaration) return false;
|
|
24420
24537
|
const owner = declaration.parent;
|
|
24421
|
-
return owner.type ===
|
|
24538
|
+
return owner.type === AST_NODE_TYPES112.Program || owner.type === AST_NODE_TYPES112.ExportNamedDeclaration && owner.parent.type === AST_NODE_TYPES112.Program;
|
|
24422
24539
|
};
|
|
24423
24540
|
var require_pascal_case_zod_schema_name_default = createRule({
|
|
24424
24541
|
name: "require-pascal-case-zod-schema-name",
|
|
@@ -24438,7 +24555,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24438
24555
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
24439
24556
|
const schemaBindings = /* @__PURE__ */ new Set();
|
|
24440
24557
|
function resolvedBinding(identifier) {
|
|
24441
|
-
return
|
|
24558
|
+
return ASTUtils69.findVariable(
|
|
24442
24559
|
context.sourceCode.getScope(identifier),
|
|
24443
24560
|
identifier.name
|
|
24444
24561
|
);
|
|
@@ -24449,10 +24566,10 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24449
24566
|
}
|
|
24450
24567
|
function isConfirmedSchema(expression) {
|
|
24451
24568
|
const init = unwrapExpression(expression);
|
|
24452
|
-
if (init.type ===
|
|
24453
|
-
if (init.type !==
|
|
24569
|
+
if (init.type === AST_NODE_TYPES112.Identifier) return isSchemaBinding(init);
|
|
24570
|
+
if (init.type !== AST_NODE_TYPES112.CallExpression) return false;
|
|
24454
24571
|
const callee = unwrapExpression(init.callee);
|
|
24455
|
-
if (callee.type !==
|
|
24572
|
+
if (callee.type !== AST_NODE_TYPES112.MemberExpression) {
|
|
24456
24573
|
return false;
|
|
24457
24574
|
}
|
|
24458
24575
|
const terminal = terminalMethodName(callee);
|
|
@@ -24482,7 +24599,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24482
24599
|
ImportDeclaration(node) {
|
|
24483
24600
|
if (!isZodModule(node.source.value)) return;
|
|
24484
24601
|
for (const specifier of node.specifiers) {
|
|
24485
|
-
if (specifier.type ===
|
|
24602
|
+
if (specifier.type === AST_NODE_TYPES112.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES112.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES112.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES112.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
24486
24603
|
recordZodBinding(specifier.local);
|
|
24487
24604
|
}
|
|
24488
24605
|
}
|
|
@@ -24491,7 +24608,7 @@ var require_pascal_case_zod_schema_name_default = createRule({
|
|
|
24491
24608
|
if (!isModuleDeclarator(node)) return;
|
|
24492
24609
|
const init = node.init;
|
|
24493
24610
|
if (init === null || init === void 0) return;
|
|
24494
|
-
if (node.id.type !==
|
|
24611
|
+
if (node.id.type !== AST_NODE_TYPES112.Identifier) return;
|
|
24495
24612
|
if (!isConfirmedSchema(init)) return;
|
|
24496
24613
|
const binding = resolvedBinding(node.id);
|
|
24497
24614
|
if (binding !== null) schemaBindings.add(binding);
|
|
@@ -24693,6 +24810,7 @@ var RULES = {
|
|
|
24693
24810
|
"prefer-whole-object-assertion": prefer_whole_object_assertion_default,
|
|
24694
24811
|
"repeated-static-call-cases": repeated_static_call_cases_default,
|
|
24695
24812
|
"prefer-zod-infer": prefer_zod_infer_default,
|
|
24813
|
+
"named-child-schema-type": named_child_schema_type_default,
|
|
24696
24814
|
"prefer-zod-parse-output-type": prefer_zod_parse_output_type_default,
|
|
24697
24815
|
"require-assert-never": require_assert_never_default,
|
|
24698
24816
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
@@ -24718,6 +24836,7 @@ var LIBRARY_IMPORT_POLICY = ["error", {
|
|
|
24718
24836
|
}];
|
|
24719
24837
|
var ADVISORY_RULES = [
|
|
24720
24838
|
"@sarj/excessive-commentary",
|
|
24839
|
+
"@sarj/named-child-schema-type",
|
|
24721
24840
|
"@sarj/no-bespoke-api-case-conversion",
|
|
24722
24841
|
"@sarj/no-duplicate-test-case",
|
|
24723
24842
|
"@sarj/no-json-stringify-object-equality",
|
|
@@ -24740,6 +24859,7 @@ var ADVISORY_RULES = [
|
|
|
24740
24859
|
"@sarj/require-sql-access-class"
|
|
24741
24860
|
];
|
|
24742
24861
|
var RECOMMENDED_RULES = {
|
|
24862
|
+
"@sarj/named-child-schema-type": "warn",
|
|
24743
24863
|
"@sarj/no-conditional-empty-object-spread": "error",
|
|
24744
24864
|
"@sarj/prefer-typed-reflection": "error",
|
|
24745
24865
|
"@sarj/no-broad-return-type": "error",
|
|
@@ -24857,6 +24977,7 @@ var RECOMMENDED_RULES = {
|
|
|
24857
24977
|
"@sarj/require-pascal-case-zod-schema-name": "error"
|
|
24858
24978
|
};
|
|
24859
24979
|
var STRICT_RULES = {
|
|
24980
|
+
"@sarj/named-child-schema-type": "warn",
|
|
24860
24981
|
"@sarj/no-conditional-empty-object-spread": "error",
|
|
24861
24982
|
"@sarj/prefer-typed-reflection": "error",
|
|
24862
24983
|
"@sarj/no-broad-return-type": "error",
|