@sarj/eslint-plugin 15.6.1 → 15.6.3
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 +867 -415
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +865 -410
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2557,6 +2557,25 @@ var hasThrowingCallOrNew = (node) => subtreeMatches(
|
|
|
2557
2557
|
function isBareCallStatement(stmt) {
|
|
2558
2558
|
return stmt.type === import_utils11.AST_NODE_TYPES.ExpressionStatement && unwrap(stmt.expression).type === import_utils11.AST_NODE_TYPES.CallExpression;
|
|
2559
2559
|
}
|
|
2560
|
+
function isSimpleCatchFinallyOrchestration(node) {
|
|
2561
|
+
const handler = node.handler;
|
|
2562
|
+
const finalizer = node.finalizer;
|
|
2563
|
+
return handler !== null && handler.param === null && isSingleSimpleCall(handler.body.body) && finalizer !== null && isSingleSimpleCall(finalizer.body);
|
|
2564
|
+
}
|
|
2565
|
+
function isSingleSimpleCall(body2) {
|
|
2566
|
+
const statement = body2[0];
|
|
2567
|
+
return body2.length === 1 && statement !== void 0 && isSimpleBareCallStatement(statement);
|
|
2568
|
+
}
|
|
2569
|
+
function isSimpleBareCallStatement(stmt) {
|
|
2570
|
+
if (!isBareCallStatement(stmt)) {
|
|
2571
|
+
return false;
|
|
2572
|
+
}
|
|
2573
|
+
return !subtreeMatches(
|
|
2574
|
+
stmt,
|
|
2575
|
+
(node) => node.type === import_utils11.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils11.AST_NODE_TYPES.FunctionExpression || node.type === import_utils11.AST_NODE_TYPES.AssignmentExpression || node.type === import_utils11.AST_NODE_TYPES.UpdateExpression || node.type === import_utils11.AST_NODE_TYPES.AwaitExpression,
|
|
2576
|
+
true
|
|
2577
|
+
);
|
|
2578
|
+
}
|
|
2560
2579
|
function handlerRethrows(handler) {
|
|
2561
2580
|
if (handler === null) {
|
|
2562
2581
|
return false;
|
|
@@ -2728,6 +2747,9 @@ var no_fat_try_blocks_default = createRule({
|
|
|
2728
2747
|
if (handlerRethrows(node.handler)) {
|
|
2729
2748
|
return;
|
|
2730
2749
|
}
|
|
2750
|
+
if (isSimpleCatchFinallyOrchestration(node)) {
|
|
2751
|
+
return;
|
|
2752
|
+
}
|
|
2731
2753
|
if (isTerminalErrorBoundary(node)) {
|
|
2732
2754
|
return;
|
|
2733
2755
|
}
|
|
@@ -5648,9 +5670,9 @@ var no_restated_jsdoc_default = createRule({
|
|
|
5648
5670
|
continue;
|
|
5649
5671
|
}
|
|
5650
5672
|
if ((paramTags.length > 0 || returnTags.length > 0) && documentsTypedFunction(sourceCode, comment)) continue;
|
|
5651
|
-
const
|
|
5673
|
+
const nameTokens2 = tokensOf([declaration.name]);
|
|
5652
5674
|
const paramTokens = tokensOf(declaration.params);
|
|
5653
|
-
const known = /* @__PURE__ */ new Set([...
|
|
5675
|
+
const known = /* @__PURE__ */ new Set([...nameTokens2, ...paramTokens]);
|
|
5654
5676
|
let addsNothing = covered(describedText, known);
|
|
5655
5677
|
for (const tag of paramTags) {
|
|
5656
5678
|
const text = tag.text.replace(/^\{[^}]*\}\s*/, "");
|
|
@@ -5665,7 +5687,7 @@ var no_restated_jsdoc_default = createRule({
|
|
|
5665
5687
|
addsNothing = false;
|
|
5666
5688
|
break;
|
|
5667
5689
|
}
|
|
5668
|
-
const own = /* @__PURE__ */ new Set([...splitIdentifier(path.split(".").pop() ?? ""), ...
|
|
5690
|
+
const own = /* @__PURE__ */ new Set([...splitIdentifier(path.split(".").pop() ?? ""), ...nameTokens2]);
|
|
5669
5691
|
if (!covered(match[2] ?? "", own)) {
|
|
5670
5692
|
addsNothing = false;
|
|
5671
5693
|
break;
|
|
@@ -10851,8 +10873,130 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
10851
10873
|
}
|
|
10852
10874
|
});
|
|
10853
10875
|
|
|
10854
|
-
// src/rules/prefer-
|
|
10876
|
+
// src/rules/prefer-await-in-async-return.ts
|
|
10855
10877
|
var import_utils57 = require("@typescript-eslint/utils");
|
|
10878
|
+
var ts2 = __toESM(require("typescript"), 1);
|
|
10879
|
+
var preferAwaitInAsyncReturnDocumentation = {
|
|
10880
|
+
summary: "Prefer explicit `await` when an async function directly returns one typed Promise `.then` transform.",
|
|
10881
|
+
rationale: "Mixing a directly returned Promise callback into otherwise async control flow makes sequencing and failures harder to read.",
|
|
10882
|
+
remediation: "Await the Promise, then return the transformed value with ordinary async statements.",
|
|
10883
|
+
category: "maintainability",
|
|
10884
|
+
since: "15.6.3",
|
|
10885
|
+
limitations: [
|
|
10886
|
+
"Only a single directly returned `.then` call with an inline callback is checked.",
|
|
10887
|
+
"The receiver must be proven Promise-like by TypeScript; untyped files and larger chains are intentionally ignored."
|
|
10888
|
+
],
|
|
10889
|
+
examples: [
|
|
10890
|
+
{
|
|
10891
|
+
id: "explicit-async-transform",
|
|
10892
|
+
title: "Use explicit async control flow",
|
|
10893
|
+
outcome: "no-match",
|
|
10894
|
+
files: [{
|
|
10895
|
+
path: "src/load.ts",
|
|
10896
|
+
source: "async function load() { const value = await Promise.resolve(1); return value + 1; }"
|
|
10897
|
+
}],
|
|
10898
|
+
focusPath: "src/load.ts",
|
|
10899
|
+
expectedCount: 0,
|
|
10900
|
+
public: true
|
|
10901
|
+
},
|
|
10902
|
+
{
|
|
10903
|
+
id: "returned-then-transform",
|
|
10904
|
+
title: "Do not directly return a Promise callback chain from async code",
|
|
10905
|
+
outcome: "match",
|
|
10906
|
+
files: [{
|
|
10907
|
+
path: "src/load.ts",
|
|
10908
|
+
source: "async function load() { return Promise.resolve(1).then((value) => value + 1); }"
|
|
10909
|
+
}],
|
|
10910
|
+
focusPath: "src/load.ts",
|
|
10911
|
+
expectedCount: 1,
|
|
10912
|
+
public: true
|
|
10913
|
+
}
|
|
10914
|
+
]
|
|
10915
|
+
};
|
|
10916
|
+
function isDirectAsyncReturn(node) {
|
|
10917
|
+
const parent = node.parent;
|
|
10918
|
+
if (parent.type === import_utils57.AST_NODE_TYPES.ArrowFunctionExpression && parent.body === node) {
|
|
10919
|
+
return parent.async && !parent.generator;
|
|
10920
|
+
}
|
|
10921
|
+
if (parent.type !== import_utils57.AST_NODE_TYPES.ReturnStatement || parent.argument !== node) {
|
|
10922
|
+
return false;
|
|
10923
|
+
}
|
|
10924
|
+
let owner = parent.parent;
|
|
10925
|
+
while (owner !== void 0 && !isRuntimeFunction(owner)) {
|
|
10926
|
+
owner = owner.parent;
|
|
10927
|
+
}
|
|
10928
|
+
return owner !== void 0 && owner.async && !owner.generator;
|
|
10929
|
+
}
|
|
10930
|
+
function isRuntimeFunction(node) {
|
|
10931
|
+
return node.type === import_utils57.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils57.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils57.AST_NODE_TYPES.FunctionExpression;
|
|
10932
|
+
}
|
|
10933
|
+
function promiseThenReceiver(node) {
|
|
10934
|
+
const callee = node.callee;
|
|
10935
|
+
if (callee.type !== import_utils57.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.property.type !== import_utils57.AST_NODE_TYPES.Identifier || callee.property.name !== "then" || node.optional || node.arguments.length !== 1) {
|
|
10936
|
+
return null;
|
|
10937
|
+
}
|
|
10938
|
+
const callback = node.arguments[0];
|
|
10939
|
+
if (callback === void 0 || callback.type !== import_utils57.AST_NODE_TYPES.ArrowFunctionExpression && callback.type !== import_utils57.AST_NODE_TYPES.FunctionExpression) {
|
|
10940
|
+
return null;
|
|
10941
|
+
}
|
|
10942
|
+
return callee.object;
|
|
10943
|
+
}
|
|
10944
|
+
function isProvenPromiseLike(node, services) {
|
|
10945
|
+
const checker = services.program.getTypeChecker();
|
|
10946
|
+
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
|
|
10947
|
+
const receiverType = checker.getTypeAtLocation(tsNode);
|
|
10948
|
+
if ((receiverType.flags & (ts2.TypeFlags.Any | ts2.TypeFlags.Unknown | ts2.TypeFlags.Never)) !== 0) {
|
|
10949
|
+
return false;
|
|
10950
|
+
}
|
|
10951
|
+
const thenSymbol = checker.getPropertyOfType(receiverType, "then");
|
|
10952
|
+
const hasBuiltInPromiseDeclaration = thenSymbol?.declarations?.some(
|
|
10953
|
+
(declaration) => {
|
|
10954
|
+
let owner = declaration.parent;
|
|
10955
|
+
while (owner !== void 0 && !ts2.isInterfaceDeclaration(owner)) {
|
|
10956
|
+
owner = owner.parent;
|
|
10957
|
+
}
|
|
10958
|
+
return owner !== void 0 && (owner.name.text === "Promise" || owner.name.text === "PromiseLike") && services.program.isSourceFileDefaultLibrary(owner.getSourceFile());
|
|
10959
|
+
}
|
|
10960
|
+
) ?? false;
|
|
10961
|
+
return hasBuiltInPromiseDeclaration;
|
|
10962
|
+
}
|
|
10963
|
+
var prefer_await_in_async_return_default = createRule({
|
|
10964
|
+
name: "prefer-await-in-async-return",
|
|
10965
|
+
documentation: preferAwaitInAsyncReturnDocumentation,
|
|
10966
|
+
meta: {
|
|
10967
|
+
type: "suggestion",
|
|
10968
|
+
docs: {
|
|
10969
|
+
description: "Prefer explicit `await` when an async function directly returns one typed Promise `.then` transform."
|
|
10970
|
+
},
|
|
10971
|
+
schema: [],
|
|
10972
|
+
messages: {
|
|
10973
|
+
preferAwait: "This async function directly returns a Promise `.then` transform. Await the Promise, then return the transformed value with explicit async control flow."
|
|
10974
|
+
}
|
|
10975
|
+
},
|
|
10976
|
+
defaultOptions: [],
|
|
10977
|
+
create(context) {
|
|
10978
|
+
let services;
|
|
10979
|
+
try {
|
|
10980
|
+
services = import_utils57.ESLintUtils.getParserServices(context);
|
|
10981
|
+
} catch {
|
|
10982
|
+
services = null;
|
|
10983
|
+
}
|
|
10984
|
+
if (services === null) return {};
|
|
10985
|
+
return {
|
|
10986
|
+
CallExpression(node) {
|
|
10987
|
+
if (!isDirectAsyncReturn(node)) return;
|
|
10988
|
+
const receiver = promiseThenReceiver(node);
|
|
10989
|
+
if (receiver === null || !isProvenPromiseLike(receiver, services)) {
|
|
10990
|
+
return;
|
|
10991
|
+
}
|
|
10992
|
+
context.report({ node, messageId: "preferAwait" });
|
|
10993
|
+
}
|
|
10994
|
+
};
|
|
10995
|
+
}
|
|
10996
|
+
});
|
|
10997
|
+
|
|
10998
|
+
// src/rules/prefer-schema-for-api-payload.ts
|
|
10999
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
10856
11000
|
var preferSchemaForApiPayloadDocumentation = {
|
|
10857
11001
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
10858
11002
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -10867,9 +11011,9 @@ var preferSchemaForApiPayloadDocumentation = {
|
|
|
10867
11011
|
var unwrap4 = (node) => {
|
|
10868
11012
|
let current = node;
|
|
10869
11013
|
while (current !== null && current !== void 0) {
|
|
10870
|
-
if (current.type ===
|
|
11014
|
+
if (current.type === import_utils58.AST_NODE_TYPES.TSAsExpression || current.type === import_utils58.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils58.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils58.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
10871
11015
|
current = current.expression;
|
|
10872
|
-
} else if (current.type ===
|
|
11016
|
+
} else if (current.type === import_utils58.AST_NODE_TYPES.ChainExpression) {
|
|
10873
11017
|
current = current.expression;
|
|
10874
11018
|
} else {
|
|
10875
11019
|
break;
|
|
@@ -10884,23 +11028,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
10884
11028
|
]);
|
|
10885
11029
|
var isSchemaParseReference = (node) => {
|
|
10886
11030
|
const inner = unwrap4(node);
|
|
10887
|
-
return inner !== null && inner.type ===
|
|
11031
|
+
return inner !== null && inner.type === import_utils58.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils58.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
10888
11032
|
};
|
|
10889
11033
|
var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
10890
11034
|
let current = unwrap4(node);
|
|
10891
11035
|
if (current === null) return false;
|
|
10892
|
-
if (current.type ===
|
|
11036
|
+
if (current.type === import_utils58.AST_NODE_TYPES.AwaitExpression) {
|
|
10893
11037
|
current = unwrap4(current.argument);
|
|
10894
11038
|
}
|
|
10895
|
-
if (current === null || current.type !==
|
|
11039
|
+
if (current === null || current.type !== import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
10896
11040
|
return false;
|
|
10897
11041
|
}
|
|
10898
11042
|
const callee = unwrap4(current.callee);
|
|
10899
|
-
if (callee === null || callee.type !==
|
|
11043
|
+
if (callee === null || callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression) {
|
|
10900
11044
|
return false;
|
|
10901
11045
|
}
|
|
10902
11046
|
const property = unwrap4(callee.property);
|
|
10903
|
-
if (property === null || property.type !==
|
|
11047
|
+
if (property === null || property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
10904
11048
|
return false;
|
|
10905
11049
|
}
|
|
10906
11050
|
if (property.name === "json") {
|
|
@@ -10910,17 +11054,17 @@ var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
|
10910
11054
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
10911
11055
|
}
|
|
10912
11056
|
const object = unwrap4(callee.object);
|
|
10913
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
11057
|
+
return property.name === "parse" && object !== null && object.type === import_utils58.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]) && isKnownLocalText?.(current.arguments[0]) !== true;
|
|
10914
11058
|
};
|
|
10915
11059
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
10916
11060
|
var isDirectLocalFileRead = (node) => {
|
|
10917
11061
|
let current = unwrap4(node);
|
|
10918
|
-
if (current?.type ===
|
|
11062
|
+
if (current?.type === import_utils58.AST_NODE_TYPES.AwaitExpression) {
|
|
10919
11063
|
current = unwrap4(current.argument);
|
|
10920
11064
|
}
|
|
10921
|
-
if (current?.type !==
|
|
11065
|
+
if (current?.type !== import_utils58.AST_NODE_TYPES.CallExpression) return false;
|
|
10922
11066
|
const callee = unwrap4(current.callee);
|
|
10923
|
-
const name = callee?.type ===
|
|
11067
|
+
const name = callee?.type === import_utils58.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils58.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils58.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
10924
11068
|
return name !== null && FILE_READ_RE.test(name);
|
|
10925
11069
|
};
|
|
10926
11070
|
var isLocalFileRead = (node) => {
|
|
@@ -10947,15 +11091,15 @@ var isLocalFileRead = (node) => {
|
|
|
10947
11091
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
10948
11092
|
var isInsideAssertion = (node) => {
|
|
10949
11093
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
10950
|
-
if (current.type !==
|
|
11094
|
+
if (current.type !== import_utils58.AST_NODE_TYPES.CallExpression) continue;
|
|
10951
11095
|
let callee = current.callee;
|
|
10952
|
-
while (callee.type ===
|
|
11096
|
+
while (callee.type === import_utils58.AST_NODE_TYPES.MemberExpression) {
|
|
10953
11097
|
callee = callee.object;
|
|
10954
11098
|
}
|
|
10955
|
-
if (callee.type ===
|
|
11099
|
+
if (callee.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
10956
11100
|
callee = callee.callee;
|
|
10957
11101
|
}
|
|
10958
|
-
if (callee.type ===
|
|
11102
|
+
if (callee.type === import_utils58.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
10959
11103
|
return true;
|
|
10960
11104
|
}
|
|
10961
11105
|
}
|
|
@@ -10974,22 +11118,22 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
10974
11118
|
var isValidationRead = (node) => {
|
|
10975
11119
|
let current = node;
|
|
10976
11120
|
let parent = current.parent;
|
|
10977
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
11121
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils58.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils58.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils58.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils58.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils58.AST_NODE_TYPES.ChainExpression)) {
|
|
10978
11122
|
current = parent;
|
|
10979
11123
|
parent = parent.parent;
|
|
10980
11124
|
}
|
|
10981
11125
|
if (parent === null || parent === void 0) return false;
|
|
10982
|
-
if (parent.type ===
|
|
11126
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
10983
11127
|
return true;
|
|
10984
11128
|
}
|
|
10985
|
-
if (parent.type !==
|
|
11129
|
+
if (parent.type !== import_utils58.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
10986
11130
|
return false;
|
|
10987
11131
|
}
|
|
10988
11132
|
const callee = parent.callee;
|
|
10989
|
-
if (callee.type ===
|
|
11133
|
+
if (callee.type === import_utils58.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils58.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils58.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
10990
11134
|
return parent.arguments.length === 1;
|
|
10991
11135
|
}
|
|
10992
|
-
return callee.type ===
|
|
11136
|
+
return callee.type === import_utils58.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
10993
11137
|
};
|
|
10994
11138
|
var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
10995
11139
|
"bigint",
|
|
@@ -11000,13 +11144,13 @@ var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
|
11000
11144
|
"undefined"
|
|
11001
11145
|
]);
|
|
11002
11146
|
var bindingValidationPolarity = (test, bindingName) => {
|
|
11003
|
-
if (test.type ===
|
|
11147
|
+
if (test.type === import_utils58.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
11004
11148
|
const inner = bindingValidationPolarity(test.argument, bindingName);
|
|
11005
11149
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
11006
11150
|
}
|
|
11007
|
-
if (test.type ===
|
|
11008
|
-
const typeofName = (node) => node.type ===
|
|
11009
|
-
const literalType = (node) => node.type ===
|
|
11151
|
+
if (test.type === import_utils58.AST_NODE_TYPES.BinaryExpression) {
|
|
11152
|
+
const typeofName = (node) => node.type === import_utils58.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && node.argument.type === import_utils58.AST_NODE_TYPES.Identifier ? node.argument.name : null;
|
|
11153
|
+
const literalType = (node) => node.type === import_utils58.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value) ? node.value : null;
|
|
11010
11154
|
const matches = typeofName(test.left) === bindingName && literalType(test.right) !== null || typeofName(test.right) === bindingName && literalType(test.left) !== null;
|
|
11011
11155
|
if (!matches) return null;
|
|
11012
11156
|
if (test.operator === "===" || test.operator === "==") {
|
|
@@ -11014,9 +11158,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
11014
11158
|
}
|
|
11015
11159
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
11016
11160
|
}
|
|
11017
|
-
return test.type ===
|
|
11161
|
+
return test.type === import_utils58.AST_NODE_TYPES.CallExpression && test.arguments.length === 1 && test.arguments[0]?.type === import_utils58.AST_NODE_TYPES.Identifier && test.arguments[0].name === bindingName && test.callee.type === import_utils58.AST_NODE_TYPES.MemberExpression && !test.callee.computed && test.callee.object.type === import_utils58.AST_NODE_TYPES.Identifier && test.callee.object.name === "Array" && test.callee.property.type === import_utils58.AST_NODE_TYPES.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
11018
11162
|
};
|
|
11019
|
-
var plainMemberAccess = (node) => node.type ===
|
|
11163
|
+
var plainMemberAccess = (node) => node.type === import_utils58.AST_NODE_TYPES.MemberExpression && !node.computed && node.object.type === import_utils58.AST_NODE_TYPES.Identifier && node.property.type === import_utils58.AST_NODE_TYPES.Identifier ? { object: node.object.name, property: node.property.name } : null;
|
|
11020
11164
|
var isSamePlainMember = (node, access) => {
|
|
11021
11165
|
const candidate = plainMemberAccess(node);
|
|
11022
11166
|
return candidate !== null && candidate.object === access.object && candidate.property === access.property;
|
|
@@ -11024,19 +11168,19 @@ var isSamePlainMember = (node, access) => {
|
|
|
11024
11168
|
var nodeWithin2 = (node, container) => node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
11025
11169
|
var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
11026
11170
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11027
|
-
if (current.type ===
|
|
11171
|
+
if (current.type === import_utils58.AST_NODE_TYPES.ConditionalExpression) {
|
|
11028
11172
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
11029
11173
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
11030
11174
|
return true;
|
|
11031
11175
|
}
|
|
11032
11176
|
}
|
|
11033
|
-
if (current.type ===
|
|
11177
|
+
if (current.type === import_utils58.AST_NODE_TYPES.IfStatement) {
|
|
11034
11178
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
11035
11179
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
11036
11180
|
return true;
|
|
11037
11181
|
}
|
|
11038
11182
|
}
|
|
11039
|
-
if (current.type ===
|
|
11183
|
+
if (current.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils58.AST_NODE_TYPES.FunctionExpression || current.type === import_utils58.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
11040
11184
|
return false;
|
|
11041
11185
|
}
|
|
11042
11186
|
}
|
|
@@ -11044,32 +11188,32 @@ var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
|
11044
11188
|
};
|
|
11045
11189
|
var isMemberUseWithinValidatedBranch = (node, access) => {
|
|
11046
11190
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11047
|
-
if (current.type ===
|
|
11191
|
+
if (current.type === import_utils58.AST_NODE_TYPES.ConditionalExpression) {
|
|
11048
11192
|
const polarity = memberValidationPolarity(current.test, access);
|
|
11049
11193
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
11050
11194
|
return true;
|
|
11051
11195
|
}
|
|
11052
11196
|
}
|
|
11053
|
-
if (current.type ===
|
|
11197
|
+
if (current.type === import_utils58.AST_NODE_TYPES.IfStatement) {
|
|
11054
11198
|
const polarity = memberValidationPolarity(current.test, access);
|
|
11055
11199
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
11056
11200
|
return true;
|
|
11057
11201
|
}
|
|
11058
11202
|
}
|
|
11059
|
-
if (current.type ===
|
|
11203
|
+
if (current.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils58.AST_NODE_TYPES.FunctionExpression || current.type === import_utils58.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
11060
11204
|
return false;
|
|
11061
11205
|
}
|
|
11062
11206
|
}
|
|
11063
11207
|
return false;
|
|
11064
11208
|
};
|
|
11065
11209
|
var memberValidationPolarity = (test, access) => {
|
|
11066
|
-
if (test.type ===
|
|
11210
|
+
if (test.type === import_utils58.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
11067
11211
|
const inner = memberValidationPolarity(test.argument, access);
|
|
11068
11212
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
11069
11213
|
}
|
|
11070
|
-
if (test.type ===
|
|
11071
|
-
const isMatchingTypeof = (node) => node.type ===
|
|
11072
|
-
const isPrimitiveType = (node) => node.type ===
|
|
11214
|
+
if (test.type === import_utils58.AST_NODE_TYPES.BinaryExpression) {
|
|
11215
|
+
const isMatchingTypeof = (node) => node.type === import_utils58.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && isSamePlainMember(node.argument, access);
|
|
11216
|
+
const isPrimitiveType = (node) => node.type === import_utils58.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value);
|
|
11073
11217
|
if (!(isMatchingTypeof(test.left) && isPrimitiveType(test.right) || isMatchingTypeof(test.right) && isPrimitiveType(test.left))) {
|
|
11074
11218
|
return null;
|
|
11075
11219
|
}
|
|
@@ -11078,15 +11222,15 @@ var memberValidationPolarity = (test, access) => {
|
|
|
11078
11222
|
}
|
|
11079
11223
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
11080
11224
|
}
|
|
11081
|
-
return test.type ===
|
|
11225
|
+
return test.type === import_utils58.AST_NODE_TYPES.CallExpression && test.arguments.length === 1 && test.arguments[0] !== void 0 && test.arguments[0].type !== import_utils58.AST_NODE_TYPES.SpreadElement && isSamePlainMember(test.arguments[0], access) && test.callee.type === import_utils58.AST_NODE_TYPES.MemberExpression && !test.callee.computed && test.callee.object.type === import_utils58.AST_NODE_TYPES.Identifier && test.callee.object.name === "Array" && test.callee.property.type === import_utils58.AST_NODE_TYPES.Identifier && test.callee.property.name === "isArray" ? "valid-when-true" : null;
|
|
11082
11226
|
};
|
|
11083
11227
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
11084
11228
|
const isValidationReference = (identifier) => {
|
|
11085
11229
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11086
|
-
if ((current.type ===
|
|
11230
|
+
if ((current.type === import_utils58.AST_NODE_TYPES.BinaryExpression || current.type === import_utils58.AST_NODE_TYPES.CallExpression || current.type === import_utils58.AST_NODE_TYPES.UnaryExpression) && bindingValidationPolarity(current, identifier.name) !== null) {
|
|
11087
11231
|
return true;
|
|
11088
11232
|
}
|
|
11089
|
-
if (current.type !==
|
|
11233
|
+
if (current.type !== import_utils58.AST_NODE_TYPES.UnaryExpression && current.type !== import_utils58.AST_NODE_TYPES.MemberExpression && current.type !== import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
11090
11234
|
return false;
|
|
11091
11235
|
}
|
|
11092
11236
|
}
|
|
@@ -11094,7 +11238,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11094
11238
|
};
|
|
11095
11239
|
const isGuardedUse = (identifier) => {
|
|
11096
11240
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11097
|
-
if (current.type ===
|
|
11241
|
+
if (current.type === import_utils58.AST_NODE_TYPES.ConditionalExpression) {
|
|
11098
11242
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
11099
11243
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
11100
11244
|
return true;
|
|
@@ -11103,7 +11247,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11103
11247
|
return true;
|
|
11104
11248
|
}
|
|
11105
11249
|
}
|
|
11106
|
-
if (current.type ===
|
|
11250
|
+
if (current.type === import_utils58.AST_NODE_TYPES.IfStatement) {
|
|
11107
11251
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
11108
11252
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
11109
11253
|
return true;
|
|
@@ -11112,14 +11256,14 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11112
11256
|
return true;
|
|
11113
11257
|
}
|
|
11114
11258
|
}
|
|
11115
|
-
if (current.type ===
|
|
11259
|
+
if (current.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils58.AST_NODE_TYPES.FunctionExpression || current.type === import_utils58.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
11116
11260
|
return false;
|
|
11117
11261
|
}
|
|
11118
11262
|
}
|
|
11119
11263
|
return false;
|
|
11120
11264
|
};
|
|
11121
11265
|
const declarator = member.parent;
|
|
11122
|
-
if (declarator.type !==
|
|
11266
|
+
if (declarator.type !== import_utils58.AST_NODE_TYPES.VariableDeclarator || declarator.init !== member || declarator.id.type !== import_utils58.AST_NODE_TYPES.Identifier || declarator.parent.type !== import_utils58.AST_NODE_TYPES.VariableDeclaration || declarator.parent.kind !== "const") {
|
|
11123
11267
|
return false;
|
|
11124
11268
|
}
|
|
11125
11269
|
const extracted = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -11127,7 +11271,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11127
11271
|
let hasValueUse = false;
|
|
11128
11272
|
for (const reference of extracted.references) {
|
|
11129
11273
|
const identifier = reference.identifier;
|
|
11130
|
-
if (identifier.type !==
|
|
11274
|
+
if (identifier.type !== import_utils58.AST_NODE_TYPES.Identifier) return false;
|
|
11131
11275
|
if (nodeWithin2(identifier, declarator)) continue;
|
|
11132
11276
|
if (isValidationReference(identifier)) continue;
|
|
11133
11277
|
hasValueUse = true;
|
|
@@ -11140,17 +11284,17 @@ var isGuardTestPosition = (node) => {
|
|
|
11140
11284
|
let parent = current.parent;
|
|
11141
11285
|
while (parent !== void 0 && parent !== null) {
|
|
11142
11286
|
switch (parent.type) {
|
|
11143
|
-
case
|
|
11144
|
-
case
|
|
11145
|
-
case
|
|
11287
|
+
case import_utils58.AST_NODE_TYPES.UnaryExpression:
|
|
11288
|
+
case import_utils58.AST_NODE_TYPES.LogicalExpression:
|
|
11289
|
+
case import_utils58.AST_NODE_TYPES.ChainExpression:
|
|
11146
11290
|
current = parent;
|
|
11147
11291
|
parent = parent.parent;
|
|
11148
11292
|
continue;
|
|
11149
|
-
case
|
|
11150
|
-
case
|
|
11151
|
-
case
|
|
11152
|
-
case
|
|
11153
|
-
case
|
|
11293
|
+
case import_utils58.AST_NODE_TYPES.IfStatement:
|
|
11294
|
+
case import_utils58.AST_NODE_TYPES.ConditionalExpression:
|
|
11295
|
+
case import_utils58.AST_NODE_TYPES.WhileStatement:
|
|
11296
|
+
case import_utils58.AST_NODE_TYPES.DoWhileStatement:
|
|
11297
|
+
case import_utils58.AST_NODE_TYPES.ForStatement:
|
|
11154
11298
|
return parent.test === current;
|
|
11155
11299
|
default:
|
|
11156
11300
|
return false;
|
|
@@ -11160,7 +11304,7 @@ var isGuardTestPosition = (node) => {
|
|
|
11160
11304
|
};
|
|
11161
11305
|
var unvalidatedVariableRef = (node, scope, tracked) => {
|
|
11162
11306
|
const unwrapped = unwrap4(node);
|
|
11163
|
-
if (unwrapped === null || unwrapped.type !==
|
|
11307
|
+
if (unwrapped === null || unwrapped.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11164
11308
|
return null;
|
|
11165
11309
|
}
|
|
11166
11310
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -11189,7 +11333,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11189
11333
|
const localFileTextVariables = /* @__PURE__ */ new Set();
|
|
11190
11334
|
const localFileTextRef = (node, scope) => {
|
|
11191
11335
|
const unwrapped = unwrap4(node);
|
|
11192
|
-
if (unwrapped?.type !==
|
|
11336
|
+
if (unwrapped?.type !== import_utils58.AST_NODE_TYPES.Identifier) return null;
|
|
11193
11337
|
const variable = findVariable2(scope, unwrapped.name);
|
|
11194
11338
|
return variable !== null && localFileTextVariables.has(variable) ? variable : null;
|
|
11195
11339
|
};
|
|
@@ -11258,7 +11402,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11258
11402
|
return {
|
|
11259
11403
|
VariableDeclarator(node) {
|
|
11260
11404
|
const scope = context.sourceCode.getScope(node);
|
|
11261
|
-
if (node.id.type ===
|
|
11405
|
+
if (node.id.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11262
11406
|
const variable = context.sourceCode.getDeclaredVariables(node)[0];
|
|
11263
11407
|
if (variable !== void 0) {
|
|
11264
11408
|
updateLocalFileText(variable, node.init, scope);
|
|
@@ -11266,7 +11410,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11266
11410
|
trackInitializer(node, scope);
|
|
11267
11411
|
return;
|
|
11268
11412
|
}
|
|
11269
|
-
if (node.id.type ===
|
|
11413
|
+
if (node.id.type === import_utils58.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils58.AST_NODE_TYPES.ArrayPattern) {
|
|
11270
11414
|
if (isRawPayloadSource(
|
|
11271
11415
|
node.init,
|
|
11272
11416
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
@@ -11283,7 +11427,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11283
11427
|
},
|
|
11284
11428
|
AssignmentExpression(node) {
|
|
11285
11429
|
const scope = context.sourceCode.getScope(node);
|
|
11286
|
-
if (node.left.type ===
|
|
11430
|
+
if (node.left.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11287
11431
|
const variable = findVariable2(scope, node.left.name);
|
|
11288
11432
|
if (variable === null) return;
|
|
11289
11433
|
const isLocalText = (candidate) => localFileTextRef(candidate, scope) !== null;
|
|
@@ -11297,7 +11441,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11297
11441
|
}
|
|
11298
11442
|
return;
|
|
11299
11443
|
}
|
|
11300
|
-
if (node.left.type ===
|
|
11444
|
+
if (node.left.type === import_utils58.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils58.AST_NODE_TYPES.ArrayPattern) {
|
|
11301
11445
|
if (isRawPayloadSource(
|
|
11302
11446
|
node.right,
|
|
11303
11447
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
@@ -11317,15 +11461,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11317
11461
|
}
|
|
11318
11462
|
},
|
|
11319
11463
|
CallExpression(node) {
|
|
11320
|
-
if (node.callee.type !==
|
|
11464
|
+
if (node.callee.type !== import_utils58.AST_NODE_TYPES.Identifier) return;
|
|
11321
11465
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
11322
11466
|
return;
|
|
11323
11467
|
}
|
|
11324
11468
|
const scope = context.sourceCode.getScope(node);
|
|
11325
11469
|
for (const arg of node.arguments) {
|
|
11326
|
-
if (arg.type ===
|
|
11470
|
+
if (arg.type === import_utils58.AST_NODE_TYPES.SpreadElement) continue;
|
|
11327
11471
|
const unwrapped = unwrap4(arg);
|
|
11328
|
-
if (unwrapped === null || unwrapped.type !==
|
|
11472
|
+
if (unwrapped === null || unwrapped.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11329
11473
|
continue;
|
|
11330
11474
|
}
|
|
11331
11475
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -11342,14 +11486,14 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11342
11486
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
11343
11487
|
)) {
|
|
11344
11488
|
const parent = node.parent;
|
|
11345
|
-
if (parent.type ===
|
|
11489
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils58.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
11346
11490
|
return;
|
|
11347
11491
|
}
|
|
11348
11492
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
11349
11493
|
return;
|
|
11350
11494
|
}
|
|
11351
|
-
const variable = obj?.type ===
|
|
11352
|
-
if (variable !== null && obj?.type ===
|
|
11495
|
+
const variable = obj?.type === import_utils58.AST_NODE_TYPES.Identifier ? unvalidatedVariableRef(obj, scope, unvalidatedVariables) : null;
|
|
11496
|
+
if (variable !== null && obj?.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11353
11497
|
if (isUseWithinValidatedBranch(node, obj.name)) {
|
|
11354
11498
|
return;
|
|
11355
11499
|
}
|
|
@@ -11369,7 +11513,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11369
11513
|
});
|
|
11370
11514
|
|
|
11371
11515
|
// src/rules/prefer-semantic-colors.ts
|
|
11372
|
-
var
|
|
11516
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
11373
11517
|
var import_fs = require("fs");
|
|
11374
11518
|
var import_path = require("path");
|
|
11375
11519
|
|
|
@@ -11481,7 +11625,7 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
11481
11625
|
var isInsideSvg = (node) => {
|
|
11482
11626
|
let current = node.parent;
|
|
11483
11627
|
while (current !== void 0 && current !== null) {
|
|
11484
|
-
if (current.type ===
|
|
11628
|
+
if (current.type === import_utils59.AST_NODE_TYPES.JSXElement) {
|
|
11485
11629
|
const name = jsxElementName(current);
|
|
11486
11630
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
11487
11631
|
}
|
|
@@ -11491,8 +11635,8 @@ var isInsideSvg = (node) => {
|
|
|
11491
11635
|
};
|
|
11492
11636
|
function jsxElementName(node) {
|
|
11493
11637
|
const name = node.openingElement.name;
|
|
11494
|
-
if (name.type ===
|
|
11495
|
-
if (name.type ===
|
|
11638
|
+
if (name.type === import_utils59.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
11639
|
+
if (name.type === import_utils59.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils59.AST_NODE_TYPES.JSXIdentifier) {
|
|
11496
11640
|
return name.property.name;
|
|
11497
11641
|
}
|
|
11498
11642
|
return null;
|
|
@@ -11518,7 +11662,7 @@ function isSvgLikeElementName(name) {
|
|
|
11518
11662
|
var isInsideIconFactoryPath = (node) => {
|
|
11519
11663
|
let current = node.parent;
|
|
11520
11664
|
while (current !== void 0 && current !== null) {
|
|
11521
|
-
if (current.type ===
|
|
11665
|
+
if (current.type === import_utils59.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils59.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils59.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils59.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
11522
11666
|
return true;
|
|
11523
11667
|
}
|
|
11524
11668
|
current = current.parent;
|
|
@@ -11652,12 +11796,12 @@ var expandWorkspaceGlob = (root, glob) => {
|
|
|
11652
11796
|
return (0, import_fs.readdirSync)(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => (0, import_path.join)(parent, entry.name));
|
|
11653
11797
|
};
|
|
11654
11798
|
var propName = (key) => {
|
|
11655
|
-
if (key.type ===
|
|
11656
|
-
if (key.type ===
|
|
11799
|
+
if (key.type === import_utils59.AST_NODE_TYPES.Identifier) return key.name;
|
|
11800
|
+
if (key.type === import_utils59.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
11657
11801
|
return null;
|
|
11658
11802
|
};
|
|
11659
11803
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
11660
|
-
if (statement.type !==
|
|
11804
|
+
if (statement.type !== import_utils59.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils59.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils59.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
11661
11805
|
return false;
|
|
11662
11806
|
}
|
|
11663
11807
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -11710,27 +11854,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11710
11854
|
const checkClassNode = (node) => {
|
|
11711
11855
|
if (node === null) return;
|
|
11712
11856
|
switch (node.type) {
|
|
11713
|
-
case
|
|
11857
|
+
case import_utils59.AST_NODE_TYPES.Literal:
|
|
11714
11858
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
11715
11859
|
break;
|
|
11716
|
-
case
|
|
11860
|
+
case import_utils59.AST_NODE_TYPES.TemplateLiteral:
|
|
11717
11861
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
11718
11862
|
break;
|
|
11719
|
-
case
|
|
11863
|
+
case import_utils59.AST_NODE_TYPES.ArrayExpression:
|
|
11720
11864
|
for (const element of node.elements) {
|
|
11721
|
-
if (element !== null && element.type !==
|
|
11865
|
+
if (element !== null && element.type !== import_utils59.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
11722
11866
|
}
|
|
11723
11867
|
break;
|
|
11724
|
-
case
|
|
11868
|
+
case import_utils59.AST_NODE_TYPES.ObjectExpression:
|
|
11725
11869
|
for (const property of node.properties) {
|
|
11726
|
-
if (property.type ===
|
|
11870
|
+
if (property.type === import_utils59.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
11727
11871
|
}
|
|
11728
11872
|
break;
|
|
11729
|
-
case
|
|
11873
|
+
case import_utils59.AST_NODE_TYPES.ConditionalExpression:
|
|
11730
11874
|
checkClassNode(node.consequent);
|
|
11731
11875
|
checkClassNode(node.alternate);
|
|
11732
11876
|
break;
|
|
11733
|
-
case
|
|
11877
|
+
case import_utils59.AST_NODE_TYPES.LogicalExpression:
|
|
11734
11878
|
checkClassNode(node.right);
|
|
11735
11879
|
break;
|
|
11736
11880
|
default:
|
|
@@ -11738,32 +11882,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11738
11882
|
}
|
|
11739
11883
|
};
|
|
11740
11884
|
const checkColorValueNode = (node) => {
|
|
11741
|
-
if (node.type ===
|
|
11885
|
+
if (node.type === import_utils59.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
11742
11886
|
report(node, "inlineColor", { value: node.value });
|
|
11743
11887
|
}
|
|
11744
11888
|
};
|
|
11745
11889
|
return {
|
|
11746
11890
|
"JSXAttribute[name.name='className']"(node) {
|
|
11747
11891
|
if (node.value === null) return;
|
|
11748
|
-
if (node.value.type ===
|
|
11749
|
-
else if (node.value.type ===
|
|
11750
|
-
if (node.value.expression.type !==
|
|
11892
|
+
if (node.value.type === import_utils59.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
11893
|
+
else if (node.value.type === import_utils59.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
11894
|
+
if (node.value.expression.type !== import_utils59.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
11751
11895
|
checkClassNode(node.value.expression);
|
|
11752
11896
|
}
|
|
11753
11897
|
}
|
|
11754
11898
|
},
|
|
11755
11899
|
CallExpression(node) {
|
|
11756
|
-
if (node.callee.type ===
|
|
11900
|
+
if (node.callee.type === import_utils59.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils59.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
11757
11901
|
importsEmailOrPdfRenderer = true;
|
|
11758
11902
|
}
|
|
11759
|
-
if (node.callee.type ===
|
|
11903
|
+
if (node.callee.type === import_utils59.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
11760
11904
|
for (const arg of node.arguments) {
|
|
11761
|
-
if (arg.type !==
|
|
11905
|
+
if (arg.type !== import_utils59.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
11762
11906
|
}
|
|
11763
11907
|
}
|
|
11764
11908
|
},
|
|
11765
11909
|
VariableDeclarator(node) {
|
|
11766
|
-
if (node.id.type ===
|
|
11910
|
+
if (node.id.type === import_utils59.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
11767
11911
|
checkClassNode(node.init);
|
|
11768
11912
|
}
|
|
11769
11913
|
},
|
|
@@ -11773,9 +11917,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11773
11917
|
},
|
|
11774
11918
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
11775
11919
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
11776
|
-
if (node.value?.type !==
|
|
11920
|
+
if (node.value?.type !== import_utils59.AST_NODE_TYPES.Literal) return;
|
|
11777
11921
|
const owner = node.parent.name;
|
|
11778
|
-
if (owner.type ===
|
|
11922
|
+
if (owner.type === import_utils59.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
11779
11923
|
return;
|
|
11780
11924
|
}
|
|
11781
11925
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -11789,7 +11933,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11789
11933
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
11790
11934
|
},
|
|
11791
11935
|
ImportExpression(node) {
|
|
11792
|
-
if (node.source.type ===
|
|
11936
|
+
if (node.source.type === import_utils59.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
11793
11937
|
importsEmailOrPdfRenderer = true;
|
|
11794
11938
|
}
|
|
11795
11939
|
},
|
|
@@ -11802,7 +11946,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11802
11946
|
});
|
|
11803
11947
|
|
|
11804
11948
|
// src/rules/prefer-server-actions.ts
|
|
11805
|
-
var
|
|
11949
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
11806
11950
|
var preferServerActionsDocumentation = {
|
|
11807
11951
|
summary: "Prefer Next.js Server Actions over /api/* mutations.",
|
|
11808
11952
|
rationale: "Server Actions preserve typed application calls and avoid an internal JSON request-response boundary.",
|
|
@@ -11991,7 +12135,7 @@ var prefer_server_actions_default = createRule({
|
|
|
11991
12135
|
});
|
|
11992
12136
|
|
|
11993
12137
|
// src/rules/prefer-whole-object-assertion.ts
|
|
11994
|
-
var
|
|
12138
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
11995
12139
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
11996
12140
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
11997
12141
|
["toBeNull", "null"],
|
|
@@ -12016,11 +12160,11 @@ var preferWholeObjectAssertionDocumentation = {
|
|
|
12016
12160
|
};
|
|
12017
12161
|
function literalText(node, getText) {
|
|
12018
12162
|
switch (node.type) {
|
|
12019
|
-
case
|
|
12163
|
+
case import_utils61.AST_NODE_TYPES.Literal:
|
|
12020
12164
|
return "regex" in node ? null : getText(node);
|
|
12021
|
-
case
|
|
12165
|
+
case import_utils61.AST_NODE_TYPES.TemplateLiteral:
|
|
12022
12166
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
12023
|
-
case
|
|
12167
|
+
case import_utils61.AST_NODE_TYPES.UnaryExpression:
|
|
12024
12168
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
12025
12169
|
default:
|
|
12026
12170
|
return null;
|
|
@@ -12028,15 +12172,15 @@ function literalText(node, getText) {
|
|
|
12028
12172
|
}
|
|
12029
12173
|
function isPureReceiver(node) {
|
|
12030
12174
|
switch (node.type) {
|
|
12031
|
-
case
|
|
12032
|
-
case
|
|
12175
|
+
case import_utils61.AST_NODE_TYPES.Identifier:
|
|
12176
|
+
case import_utils61.AST_NODE_TYPES.ThisExpression:
|
|
12033
12177
|
return true;
|
|
12034
|
-
case
|
|
12178
|
+
case import_utils61.AST_NODE_TYPES.MemberExpression:
|
|
12035
12179
|
if (node.optional) {
|
|
12036
12180
|
return false;
|
|
12037
12181
|
}
|
|
12038
12182
|
if (node.computed) {
|
|
12039
|
-
return node.property.type ===
|
|
12183
|
+
return node.property.type === import_utils61.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
12040
12184
|
}
|
|
12041
12185
|
return isPureReceiver(node.object);
|
|
12042
12186
|
default:
|
|
@@ -12044,7 +12188,7 @@ function isPureReceiver(node) {
|
|
|
12044
12188
|
}
|
|
12045
12189
|
}
|
|
12046
12190
|
function literalIndex(node) {
|
|
12047
|
-
if (node.type !==
|
|
12191
|
+
if (node.type !== import_utils61.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
12048
12192
|
return null;
|
|
12049
12193
|
}
|
|
12050
12194
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -12071,24 +12215,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12071
12215
|
}
|
|
12072
12216
|
const { sourceCode } = context;
|
|
12073
12217
|
function parseAssertion(statement) {
|
|
12074
|
-
if (statement.type !==
|
|
12218
|
+
if (statement.type !== import_utils61.AST_NODE_TYPES.ExpressionStatement) {
|
|
12075
12219
|
return null;
|
|
12076
12220
|
}
|
|
12077
12221
|
const call = statement.expression;
|
|
12078
|
-
if (call.type !==
|
|
12222
|
+
if (call.type !== import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
12079
12223
|
return null;
|
|
12080
12224
|
}
|
|
12081
12225
|
const callee = call.callee;
|
|
12082
|
-
if (callee.type !==
|
|
12226
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
12083
12227
|
return null;
|
|
12084
12228
|
}
|
|
12085
12229
|
const matcher = callee.property.name;
|
|
12086
12230
|
const expectCall = callee.object;
|
|
12087
|
-
if (expectCall.type !==
|
|
12231
|
+
if (expectCall.type !== import_utils61.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils61.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
12088
12232
|
return null;
|
|
12089
12233
|
}
|
|
12090
12234
|
const actual = expectCall.arguments[0];
|
|
12091
|
-
if (actual === void 0 || actual.type !==
|
|
12235
|
+
if (actual === void 0 || actual.type !== import_utils61.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
12092
12236
|
return null;
|
|
12093
12237
|
}
|
|
12094
12238
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -12102,7 +12246,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12102
12246
|
}
|
|
12103
12247
|
key = { kind: "index", index };
|
|
12104
12248
|
} else {
|
|
12105
|
-
if (actual.property.type !==
|
|
12249
|
+
if (actual.property.type !== import_utils61.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
12106
12250
|
return null;
|
|
12107
12251
|
}
|
|
12108
12252
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -12115,7 +12259,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12115
12259
|
return null;
|
|
12116
12260
|
}
|
|
12117
12261
|
const expected = call.arguments[0];
|
|
12118
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
12262
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils61.AST_NODE_TYPES.SpreadElement) {
|
|
12119
12263
|
return null;
|
|
12120
12264
|
}
|
|
12121
12265
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -12230,7 +12374,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12230
12374
|
});
|
|
12231
12375
|
|
|
12232
12376
|
// src/rules/prefer-zod-infer.ts
|
|
12233
|
-
var
|
|
12377
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
12234
12378
|
var preferZodInferDocumentation = {
|
|
12235
12379
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
12236
12380
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -12254,6 +12398,14 @@ var OPTIONAL_MODIFIERS = /* @__PURE__ */ new Set([
|
|
|
12254
12398
|
"nullish"
|
|
12255
12399
|
]);
|
|
12256
12400
|
var NULLABLE_MODIFIERS = /* @__PURE__ */ new Set(["nullable", "nullish"]);
|
|
12401
|
+
var DOMAIN_PRESERVING_MODIFIERS = /* @__PURE__ */ new Set([
|
|
12402
|
+
...SHAPE_PRESERVING_METHODS,
|
|
12403
|
+
...OPTIONAL_MODIFIERS,
|
|
12404
|
+
...NULLABLE_MODIFIERS,
|
|
12405
|
+
"catch",
|
|
12406
|
+
"default",
|
|
12407
|
+
"prefault"
|
|
12408
|
+
]);
|
|
12257
12409
|
var RESHAPING_MODIFIERS = /* @__PURE__ */ new Set([
|
|
12258
12410
|
"transform",
|
|
12259
12411
|
"pipe",
|
|
@@ -12275,45 +12427,146 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
12275
12427
|
"Schema"
|
|
12276
12428
|
]);
|
|
12277
12429
|
var LEAF_NODE_TYPES = {
|
|
12278
|
-
string: [
|
|
12279
|
-
email: [
|
|
12280
|
-
url: [
|
|
12281
|
-
uuid: [
|
|
12282
|
-
ulid: [
|
|
12283
|
-
cuid: [
|
|
12284
|
-
cuid2: [
|
|
12285
|
-
nanoid: [
|
|
12286
|
-
iso: [
|
|
12287
|
-
number: [
|
|
12288
|
-
int: [
|
|
12289
|
-
float32: [
|
|
12290
|
-
float64: [
|
|
12291
|
-
boolean: [
|
|
12292
|
-
bigint: [
|
|
12293
|
-
symbol: [
|
|
12294
|
-
any: [
|
|
12295
|
-
unknown: [
|
|
12296
|
-
never: [
|
|
12297
|
-
void: [
|
|
12298
|
-
null: [
|
|
12299
|
-
undefined: [
|
|
12300
|
-
literal: [
|
|
12301
|
-
date: [
|
|
12302
|
-
array: [
|
|
12303
|
-
tuple: [
|
|
12304
|
-
object: [
|
|
12305
|
-
strictObject: [
|
|
12306
|
-
looseObject: [
|
|
12307
|
-
record: [
|
|
12308
|
-
map: [
|
|
12309
|
-
set: [
|
|
12310
|
-
promise: [
|
|
12311
|
-
enum: [
|
|
12312
|
-
nativeEnum: [
|
|
12313
|
-
union: [
|
|
12314
|
-
discriminatedUnion: [
|
|
12315
|
-
intersection: [
|
|
12316
|
-
};
|
|
12430
|
+
string: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12431
|
+
email: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12432
|
+
url: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12433
|
+
uuid: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12434
|
+
ulid: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12435
|
+
cuid: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12436
|
+
cuid2: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12437
|
+
nanoid: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12438
|
+
iso: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12439
|
+
number: [import_utils62.AST_NODE_TYPES.TSNumberKeyword],
|
|
12440
|
+
int: [import_utils62.AST_NODE_TYPES.TSNumberKeyword],
|
|
12441
|
+
float32: [import_utils62.AST_NODE_TYPES.TSNumberKeyword],
|
|
12442
|
+
float64: [import_utils62.AST_NODE_TYPES.TSNumberKeyword],
|
|
12443
|
+
boolean: [import_utils62.AST_NODE_TYPES.TSBooleanKeyword],
|
|
12444
|
+
bigint: [import_utils62.AST_NODE_TYPES.TSBigIntKeyword],
|
|
12445
|
+
symbol: [import_utils62.AST_NODE_TYPES.TSSymbolKeyword],
|
|
12446
|
+
any: [import_utils62.AST_NODE_TYPES.TSAnyKeyword],
|
|
12447
|
+
unknown: [import_utils62.AST_NODE_TYPES.TSUnknownKeyword],
|
|
12448
|
+
never: [import_utils62.AST_NODE_TYPES.TSNeverKeyword],
|
|
12449
|
+
void: [import_utils62.AST_NODE_TYPES.TSVoidKeyword],
|
|
12450
|
+
null: [import_utils62.AST_NODE_TYPES.TSNullKeyword],
|
|
12451
|
+
undefined: [import_utils62.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
12452
|
+
literal: [import_utils62.AST_NODE_TYPES.TSLiteralType],
|
|
12453
|
+
date: [import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12454
|
+
array: [import_utils62.AST_NODE_TYPES.TSArrayType, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12455
|
+
tuple: [import_utils62.AST_NODE_TYPES.TSTupleType],
|
|
12456
|
+
object: [import_utils62.AST_NODE_TYPES.TSTypeLiteral, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12457
|
+
strictObject: [import_utils62.AST_NODE_TYPES.TSTypeLiteral, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12458
|
+
looseObject: [import_utils62.AST_NODE_TYPES.TSTypeLiteral, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12459
|
+
record: [import_utils62.AST_NODE_TYPES.TSTypeReference, import_utils62.AST_NODE_TYPES.TSTypeLiteral],
|
|
12460
|
+
map: [import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12461
|
+
set: [import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12462
|
+
promise: [import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12463
|
+
enum: [import_utils62.AST_NODE_TYPES.TSUnionType, import_utils62.AST_NODE_TYPES.TSTypeReference, import_utils62.AST_NODE_TYPES.TSLiteralType],
|
|
12464
|
+
nativeEnum: [import_utils62.AST_NODE_TYPES.TSUnionType, import_utils62.AST_NODE_TYPES.TSTypeReference, import_utils62.AST_NODE_TYPES.TSLiteralType],
|
|
12465
|
+
union: [import_utils62.AST_NODE_TYPES.TSUnionType, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12466
|
+
discriminatedUnion: [import_utils62.AST_NODE_TYPES.TSUnionType, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12467
|
+
intersection: [import_utils62.AST_NODE_TYPES.TSIntersectionType, import_utils62.AST_NODE_TYPES.TSTypeReference]
|
|
12468
|
+
};
|
|
12469
|
+
function primitiveLiteralKey(node) {
|
|
12470
|
+
if (node.type !== import_utils62.AST_NODE_TYPES.Literal) {
|
|
12471
|
+
return null;
|
|
12472
|
+
}
|
|
12473
|
+
if (node.value === null) {
|
|
12474
|
+
return "null";
|
|
12475
|
+
}
|
|
12476
|
+
switch (typeof node.value) {
|
|
12477
|
+
case "string":
|
|
12478
|
+
return `string:${node.value}`;
|
|
12479
|
+
case "number":
|
|
12480
|
+
return `number:${String(node.value)}`;
|
|
12481
|
+
case "boolean":
|
|
12482
|
+
return `boolean:${String(node.value)}`;
|
|
12483
|
+
case "bigint":
|
|
12484
|
+
return `bigint:${String(node.value)}`;
|
|
12485
|
+
default:
|
|
12486
|
+
return null;
|
|
12487
|
+
}
|
|
12488
|
+
}
|
|
12489
|
+
function exactDomain(keys) {
|
|
12490
|
+
if (keys.length === 0 || keys.some((key) => key === null)) {
|
|
12491
|
+
return null;
|
|
12492
|
+
}
|
|
12493
|
+
const domain = new Set(keys);
|
|
12494
|
+
return domain.size === keys.length ? domain : null;
|
|
12495
|
+
}
|
|
12496
|
+
function staticZodDomain(leaf, call) {
|
|
12497
|
+
if (leaf === null || call === null) {
|
|
12498
|
+
return void 0;
|
|
12499
|
+
}
|
|
12500
|
+
if (leaf === "literal") {
|
|
12501
|
+
const [argument] = call.arguments;
|
|
12502
|
+
if (argument === void 0 || argument.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12503
|
+
return null;
|
|
12504
|
+
}
|
|
12505
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ArrayExpression) {
|
|
12506
|
+
return exactDomain(
|
|
12507
|
+
argument.elements.map(
|
|
12508
|
+
(element) => element === null || element.type === import_utils62.AST_NODE_TYPES.SpreadElement ? null : primitiveLiteralKey(element)
|
|
12509
|
+
)
|
|
12510
|
+
);
|
|
12511
|
+
}
|
|
12512
|
+
return exactDomain([primitiveLiteralKey(argument)]);
|
|
12513
|
+
}
|
|
12514
|
+
if (leaf === "enum") {
|
|
12515
|
+
const [argument] = call.arguments;
|
|
12516
|
+
if (argument === void 0 || argument.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12517
|
+
return null;
|
|
12518
|
+
}
|
|
12519
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ArrayExpression) {
|
|
12520
|
+
return exactDomain(
|
|
12521
|
+
argument.elements.map((element) => {
|
|
12522
|
+
if (element === null || element.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12523
|
+
return null;
|
|
12524
|
+
}
|
|
12525
|
+
const key = primitiveLiteralKey(element);
|
|
12526
|
+
return key?.startsWith("string:") === true ? key : null;
|
|
12527
|
+
})
|
|
12528
|
+
);
|
|
12529
|
+
}
|
|
12530
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
12531
|
+
return exactDomain(
|
|
12532
|
+
argument.properties.map((property) => {
|
|
12533
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
12534
|
+
return null;
|
|
12535
|
+
}
|
|
12536
|
+
const key = primitiveLiteralKey(property.value);
|
|
12537
|
+
return key?.startsWith("string:") === true ? key : null;
|
|
12538
|
+
})
|
|
12539
|
+
);
|
|
12540
|
+
}
|
|
12541
|
+
return null;
|
|
12542
|
+
}
|
|
12543
|
+
if (leaf === "nativeEnum" || leaf === "union" || leaf === "discriminatedUnion") {
|
|
12544
|
+
return null;
|
|
12545
|
+
}
|
|
12546
|
+
return void 0;
|
|
12547
|
+
}
|
|
12548
|
+
function sameDomain(left, right) {
|
|
12549
|
+
if (left.size !== right.size) {
|
|
12550
|
+
return false;
|
|
12551
|
+
}
|
|
12552
|
+
for (const value of left) {
|
|
12553
|
+
if (!right.has(value)) {
|
|
12554
|
+
return false;
|
|
12555
|
+
}
|
|
12556
|
+
}
|
|
12557
|
+
return true;
|
|
12558
|
+
}
|
|
12559
|
+
function isExportedDeclaration(node) {
|
|
12560
|
+
return node.parent?.type === import_utils62.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
12561
|
+
}
|
|
12562
|
+
function isModuleLevelConst(node) {
|
|
12563
|
+
const declaration = node.parent;
|
|
12564
|
+
if (declaration.type !== import_utils62.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const") {
|
|
12565
|
+
return false;
|
|
12566
|
+
}
|
|
12567
|
+
const container = declaration.parent;
|
|
12568
|
+
return container.type === import_utils62.AST_NODE_TYPES.Program || container.type === import_utils62.AST_NODE_TYPES.ExportNamedDeclaration && container.parent.type === import_utils62.AST_NODE_TYPES.Program;
|
|
12569
|
+
}
|
|
12317
12570
|
function normalizeSchemaName(name) {
|
|
12318
12571
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
12319
12572
|
}
|
|
@@ -12321,20 +12574,20 @@ function normalizeTypeName(name) {
|
|
|
12321
12574
|
return name.replace(/Type$/, "").toLowerCase();
|
|
12322
12575
|
}
|
|
12323
12576
|
function unwrapNullish(annotation) {
|
|
12324
|
-
if (annotation.type !==
|
|
12577
|
+
if (annotation.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12325
12578
|
return {
|
|
12326
12579
|
core: annotation,
|
|
12327
|
-
nullable: annotation.type ===
|
|
12580
|
+
nullable: annotation.type === import_utils62.AST_NODE_TYPES.TSNullKeyword
|
|
12328
12581
|
};
|
|
12329
12582
|
}
|
|
12330
12583
|
const rest = [];
|
|
12331
12584
|
let nullable = false;
|
|
12332
12585
|
for (const member of annotation.types) {
|
|
12333
|
-
if (member.type ===
|
|
12586
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSNullKeyword) {
|
|
12334
12587
|
nullable = true;
|
|
12335
12588
|
continue;
|
|
12336
12589
|
}
|
|
12337
|
-
if (member.type ===
|
|
12590
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
12338
12591
|
continue;
|
|
12339
12592
|
}
|
|
12340
12593
|
rest.push(member);
|
|
@@ -12344,7 +12597,18 @@ function unwrapNullish(annotation) {
|
|
|
12344
12597
|
}
|
|
12345
12598
|
return { core: rest.length === 0 ? null : annotation, nullable };
|
|
12346
12599
|
}
|
|
12347
|
-
function leafAgrees(
|
|
12600
|
+
function leafAgrees(field, annotation) {
|
|
12601
|
+
if (field.domain === null) {
|
|
12602
|
+
return false;
|
|
12603
|
+
}
|
|
12604
|
+
if (field.domain !== void 0) {
|
|
12605
|
+
if (annotation === null) {
|
|
12606
|
+
return false;
|
|
12607
|
+
}
|
|
12608
|
+
const annotationDomain = typeLiteralDomain(annotation);
|
|
12609
|
+
return annotationDomain !== null && sameDomain(field.domain, annotationDomain);
|
|
12610
|
+
}
|
|
12611
|
+
const { leaf } = field;
|
|
12348
12612
|
if (leaf === null || annotation === null) {
|
|
12349
12613
|
return null;
|
|
12350
12614
|
}
|
|
@@ -12357,10 +12621,51 @@ function leafAgrees(leaf, annotation) {
|
|
|
12357
12621
|
return null;
|
|
12358
12622
|
}
|
|
12359
12623
|
if (leaf === "date") {
|
|
12360
|
-
return core.type ===
|
|
12624
|
+
return core.type === import_utils62.AST_NODE_TYPES.TSTypeReference && core.typeName.type === import_utils62.AST_NODE_TYPES.Identifier && core.typeName.name === "Date";
|
|
12361
12625
|
}
|
|
12362
12626
|
return expected.includes(core.type);
|
|
12363
12627
|
}
|
|
12628
|
+
function typeLiteralDomain(annotation) {
|
|
12629
|
+
const members = annotation.type === import_utils62.AST_NODE_TYPES.TSUnionType ? annotation.types : [annotation];
|
|
12630
|
+
const keys = [];
|
|
12631
|
+
for (const member of members) {
|
|
12632
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSNullKeyword) {
|
|
12633
|
+
continue;
|
|
12634
|
+
}
|
|
12635
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSLiteralType) {
|
|
12636
|
+
return null;
|
|
12637
|
+
}
|
|
12638
|
+
keys.push(primitiveLiteralKey(member.literal));
|
|
12639
|
+
}
|
|
12640
|
+
return exactDomain(keys);
|
|
12641
|
+
}
|
|
12642
|
+
function staticStringUnionDomain(node) {
|
|
12643
|
+
if (node.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12644
|
+
return null;
|
|
12645
|
+
}
|
|
12646
|
+
const keys = node.types.map((member) => {
|
|
12647
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSLiteralType) {
|
|
12648
|
+
return null;
|
|
12649
|
+
}
|
|
12650
|
+
const key = primitiveLiteralKey(member.literal);
|
|
12651
|
+
return key?.startsWith("string:") === true ? key : null;
|
|
12652
|
+
});
|
|
12653
|
+
const domain = exactDomain(keys);
|
|
12654
|
+
return domain !== null && domain.size >= 2 ? domain : null;
|
|
12655
|
+
}
|
|
12656
|
+
function nameTokens(name) {
|
|
12657
|
+
return name.replace(/([a-z\d])([A-Z])/gu, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/gu, "$1 $2").split(/[^A-Za-z\d]+/u).filter((token) => token !== "").map((token) => token.toLowerCase());
|
|
12658
|
+
}
|
|
12659
|
+
function schemaNameTokens(name) {
|
|
12660
|
+
const tokens = nameTokens(name);
|
|
12661
|
+
const withoutPrefix = tokens[0] === "z" ? tokens.slice(1) : tokens;
|
|
12662
|
+
return withoutPrefix.at(-1) === "schema" ? withoutPrefix.slice(0, -1) : withoutPrefix;
|
|
12663
|
+
}
|
|
12664
|
+
function endsWithTokens(candidate, suffix) {
|
|
12665
|
+
return suffix.length >= 2 && candidate.length >= suffix.length && suffix.every(
|
|
12666
|
+
(segment, index) => candidate[candidate.length - suffix.length + index] === segment
|
|
12667
|
+
);
|
|
12668
|
+
}
|
|
12364
12669
|
var prefer_zod_infer_default = createRule({
|
|
12365
12670
|
name: "prefer-zod-infer",
|
|
12366
12671
|
documentation: preferZodInferDocumentation,
|
|
@@ -12383,7 +12688,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
12383
12688
|
}
|
|
12384
12689
|
],
|
|
12385
12690
|
messages: {
|
|
12386
|
-
handWrittenTwin: "`{{typeName}}` restates the shape of the Zod schema `{{schemaName}}` declared in this module. Derive it instead \u2014 `type {{typeName}} = z.infer<typeof {{schemaName}}>` \u2014 so a field added to the schema cannot silently leave the type behind."
|
|
12691
|
+
handWrittenTwin: "`{{typeName}}` restates the shape of the Zod schema `{{schemaName}}` declared in this module. Derive it instead \u2014 `type {{typeName}} = z.infer<typeof {{schemaName}}>` \u2014 so a field added to the schema cannot silently leave the type behind.",
|
|
12692
|
+
repeatedEnumUnion: "`{{propertyName}}` repeats the literal domain already named by `{{typeName}}` and `{{schemaName}}` in multiple object types. Reuse `{{typeName}}` so the accepted values have one source of truth."
|
|
12387
12693
|
}
|
|
12388
12694
|
},
|
|
12389
12695
|
defaultOptions: [{}],
|
|
@@ -12397,20 +12703,23 @@ var prefer_zod_infer_default = createRule({
|
|
|
12397
12703
|
}
|
|
12398
12704
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
12399
12705
|
const schemas = [];
|
|
12706
|
+
const enumSchemas = [];
|
|
12707
|
+
const inferredAliases = [];
|
|
12708
|
+
const literalUnionOccurrences = [];
|
|
12400
12709
|
const typeDeclarations = [];
|
|
12401
12710
|
const constrainedTypeNames = /* @__PURE__ */ new Set();
|
|
12402
12711
|
const reshapedSchemaNames = /* @__PURE__ */ new Set();
|
|
12403
12712
|
function zodCallChain(node) {
|
|
12404
12713
|
const chain = [];
|
|
12405
12714
|
let current = node;
|
|
12406
|
-
while (current.type ===
|
|
12715
|
+
while (current.type === import_utils62.AST_NODE_TYPES.CallExpression) {
|
|
12407
12716
|
const callee = current.callee;
|
|
12408
|
-
if (callee.type !==
|
|
12717
|
+
if (callee.type !== import_utils62.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12409
12718
|
return null;
|
|
12410
12719
|
}
|
|
12411
12720
|
chain.push(current);
|
|
12412
12721
|
const receiver = callee.object;
|
|
12413
|
-
if (receiver.type ===
|
|
12722
|
+
if (receiver.type === import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12414
12723
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
12415
12724
|
}
|
|
12416
12725
|
current = receiver;
|
|
@@ -12419,32 +12728,97 @@ var prefer_zod_infer_default = createRule({
|
|
|
12419
12728
|
}
|
|
12420
12729
|
function methodName2(call) {
|
|
12421
12730
|
const callee = call.callee;
|
|
12422
|
-
return callee.type ===
|
|
12731
|
+
return callee.type === import_utils62.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils62.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
12732
|
+
}
|
|
12733
|
+
function recordZodImport(node) {
|
|
12734
|
+
if (!isZodModule(node.source.value)) {
|
|
12735
|
+
return;
|
|
12736
|
+
}
|
|
12737
|
+
for (const specifier of node.specifiers) {
|
|
12738
|
+
if (specifier.type === import_utils62.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils62.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils62.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils62.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
12739
|
+
zodNamespaces.add(specifier.local.name);
|
|
12740
|
+
}
|
|
12741
|
+
}
|
|
12423
12742
|
}
|
|
12424
12743
|
function schemaField(node) {
|
|
12425
12744
|
const modifiers = [];
|
|
12426
12745
|
let current = node;
|
|
12427
12746
|
let leaf = null;
|
|
12428
|
-
|
|
12747
|
+
let leafCall = null;
|
|
12748
|
+
while (current.type === import_utils62.AST_NODE_TYPES.CallExpression) {
|
|
12429
12749
|
const callee = current.callee;
|
|
12430
|
-
if (callee.type !==
|
|
12750
|
+
if (callee.type !== import_utils62.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12431
12751
|
break;
|
|
12432
12752
|
}
|
|
12433
12753
|
const receiver = callee.object;
|
|
12434
|
-
if (receiver.type ===
|
|
12754
|
+
if (receiver.type === import_utils62.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
12435
12755
|
leaf = callee.property.name;
|
|
12756
|
+
leafCall = current;
|
|
12436
12757
|
break;
|
|
12437
12758
|
}
|
|
12438
12759
|
modifiers.push(callee.property.name);
|
|
12439
12760
|
current = receiver;
|
|
12440
12761
|
}
|
|
12441
12762
|
return {
|
|
12763
|
+
domain: modifiers.every(
|
|
12764
|
+
(name) => DOMAIN_PRESERVING_MODIFIERS.has(name)
|
|
12765
|
+
) ? staticZodDomain(leaf, leafCall) : null,
|
|
12442
12766
|
leaf,
|
|
12443
12767
|
optional: modifiers.some((name) => OPTIONAL_MODIFIERS.has(name)),
|
|
12444
12768
|
nullable: modifiers.some((name) => NULLABLE_MODIFIERS.has(name)),
|
|
12445
12769
|
reshaped: modifiers.some((name) => RESHAPING_MODIFIERS.has(name))
|
|
12446
12770
|
};
|
|
12447
12771
|
}
|
|
12772
|
+
function enumSchemaDomain(init) {
|
|
12773
|
+
const chain = zodCallChain(init);
|
|
12774
|
+
if (chain === null || chain.length !== 1) {
|
|
12775
|
+
return null;
|
|
12776
|
+
}
|
|
12777
|
+
const [call] = chain;
|
|
12778
|
+
if (call === void 0 || methodName2(call) !== "enum") {
|
|
12779
|
+
return null;
|
|
12780
|
+
}
|
|
12781
|
+
const domain = staticZodDomain("enum", call);
|
|
12782
|
+
return domain instanceof Set && domain.size >= 2 ? domain : null;
|
|
12783
|
+
}
|
|
12784
|
+
function inferredSchemaName(node) {
|
|
12785
|
+
if (node.type !== import_utils62.AST_NODE_TYPES.TSTypeReference || node.typeName.type !== import_utils62.AST_NODE_TYPES.TSQualifiedName || node.typeName.left.type !== import_utils62.AST_NODE_TYPES.Identifier || !zodNamespaces.has(node.typeName.left.name) || node.typeName.right.name !== "infer") {
|
|
12786
|
+
return null;
|
|
12787
|
+
}
|
|
12788
|
+
const arguments_ = node.typeArguments?.params ?? [];
|
|
12789
|
+
const [argument] = arguments_;
|
|
12790
|
+
return arguments_.length === 1 && argument?.type === import_utils62.AST_NODE_TYPES.TSTypeQuery && argument.exprName.type === import_utils62.AST_NODE_TYPES.Identifier ? argument.exprName.name : null;
|
|
12791
|
+
}
|
|
12792
|
+
function recordLiteralUnions(members, owner, ownerName, exported) {
|
|
12793
|
+
for (const member of members) {
|
|
12794
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSPropertySignature || member.computed || member.optional || member.readonly || member.typeAnnotation === void 0) {
|
|
12795
|
+
continue;
|
|
12796
|
+
}
|
|
12797
|
+
const key = member.key;
|
|
12798
|
+
const propertyName3 = key.type === import_utils62.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils62.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
12799
|
+
if (propertyName3 === null) {
|
|
12800
|
+
continue;
|
|
12801
|
+
}
|
|
12802
|
+
const propertyTokens = nameTokens(propertyName3);
|
|
12803
|
+
if (propertyTokens.length < 2) {
|
|
12804
|
+
continue;
|
|
12805
|
+
}
|
|
12806
|
+
const annotation = member.typeAnnotation.typeAnnotation;
|
|
12807
|
+
const domain = staticStringUnionDomain(annotation);
|
|
12808
|
+
if (domain === null || annotation.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12809
|
+
continue;
|
|
12810
|
+
}
|
|
12811
|
+
literalUnionOccurrences.push({
|
|
12812
|
+
domain,
|
|
12813
|
+
exported,
|
|
12814
|
+
node: annotation,
|
|
12815
|
+
owner,
|
|
12816
|
+
ownerName,
|
|
12817
|
+
propertyName: propertyName3,
|
|
12818
|
+
propertyTokens
|
|
12819
|
+
});
|
|
12820
|
+
}
|
|
12821
|
+
}
|
|
12448
12822
|
function schemaFields(init) {
|
|
12449
12823
|
const chain = zodCallChain(init);
|
|
12450
12824
|
if (chain === null || chain.length === 0) {
|
|
@@ -12462,16 +12836,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
12462
12836
|
return null;
|
|
12463
12837
|
}
|
|
12464
12838
|
const shape = base.arguments[0];
|
|
12465
|
-
if (shape === void 0 || shape.type !==
|
|
12839
|
+
if (shape === void 0 || shape.type !== import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
12466
12840
|
return null;
|
|
12467
12841
|
}
|
|
12468
12842
|
const fields = /* @__PURE__ */ new Map();
|
|
12469
12843
|
for (const property of shape.properties) {
|
|
12470
|
-
if (property.type !==
|
|
12844
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || property.computed) {
|
|
12471
12845
|
return null;
|
|
12472
12846
|
}
|
|
12473
12847
|
const { key } = property;
|
|
12474
|
-
const name = key.type ===
|
|
12848
|
+
const name = key.type === import_utils62.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils62.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
12475
12849
|
if (name === null) {
|
|
12476
12850
|
return null;
|
|
12477
12851
|
}
|
|
@@ -12482,11 +12856,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
12482
12856
|
function typeMembers(members) {
|
|
12483
12857
|
const result = /* @__PURE__ */ new Map();
|
|
12484
12858
|
for (const member of members) {
|
|
12485
|
-
if (member.type !==
|
|
12859
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
12486
12860
|
return null;
|
|
12487
12861
|
}
|
|
12488
12862
|
const { key } = member;
|
|
12489
|
-
const name = key.type ===
|
|
12863
|
+
const name = key.type === import_utils62.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils62.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
12490
12864
|
if (name === null) {
|
|
12491
12865
|
return null;
|
|
12492
12866
|
}
|
|
@@ -12501,8 +12875,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
12501
12875
|
return result.size === 0 ? null : result;
|
|
12502
12876
|
}
|
|
12503
12877
|
function collectConstrainedNames(node) {
|
|
12504
|
-
if (node.type ===
|
|
12505
|
-
if (node.typeName.type ===
|
|
12878
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSTypeReference) {
|
|
12879
|
+
if (node.typeName.type === import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12506
12880
|
constrainedTypeNames.add(node.typeName.name);
|
|
12507
12881
|
}
|
|
12508
12882
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -12510,11 +12884,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
12510
12884
|
}
|
|
12511
12885
|
return;
|
|
12512
12886
|
}
|
|
12513
|
-
if (node.type ===
|
|
12887
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSArrayType) {
|
|
12514
12888
|
collectConstrainedNames(node.elementType);
|
|
12515
12889
|
return;
|
|
12516
12890
|
}
|
|
12517
|
-
if (node.type ===
|
|
12891
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSUnionType || node.type === import_utils62.AST_NODE_TYPES.TSIntersectionType) {
|
|
12518
12892
|
for (const member of node.types) {
|
|
12519
12893
|
collectConstrainedNames(member);
|
|
12520
12894
|
}
|
|
@@ -12545,7 +12919,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12545
12919
|
if (member.readonly) {
|
|
12546
12920
|
return false;
|
|
12547
12921
|
}
|
|
12548
|
-
const agrees = leafAgrees(field
|
|
12922
|
+
const agrees = leafAgrees(field, member.annotation);
|
|
12549
12923
|
if (agrees === false) {
|
|
12550
12924
|
return false;
|
|
12551
12925
|
}
|
|
@@ -12556,35 +12930,42 @@ var prefer_zod_infer_default = createRule({
|
|
|
12556
12930
|
return agreements > 0;
|
|
12557
12931
|
}
|
|
12558
12932
|
return {
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
|
|
12563
|
-
for (const specifier of node.specifiers) {
|
|
12564
|
-
if (specifier.type === import_utils61.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils61.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils61.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils61.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
12565
|
-
zodNamespaces.add(specifier.local.name);
|
|
12933
|
+
Program(node) {
|
|
12934
|
+
for (const statement of node.body) {
|
|
12935
|
+
if (statement.type === import_utils62.AST_NODE_TYPES.ImportDeclaration) {
|
|
12936
|
+
recordZodImport(statement);
|
|
12566
12937
|
}
|
|
12567
12938
|
}
|
|
12568
12939
|
},
|
|
12940
|
+
ImportDeclaration(node) {
|
|
12941
|
+
recordZodImport(node);
|
|
12942
|
+
},
|
|
12569
12943
|
VariableDeclarator(node) {
|
|
12570
|
-
if (node.id.type !==
|
|
12944
|
+
if (node.id.type !== import_utils62.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
12571
12945
|
return;
|
|
12572
12946
|
}
|
|
12573
12947
|
const fields = schemaFields(node.init);
|
|
12574
12948
|
if (fields !== null) {
|
|
12575
12949
|
schemas.push({ name: node.id.name, fields });
|
|
12576
12950
|
}
|
|
12951
|
+
if (isModuleLevelConst(node)) {
|
|
12952
|
+
const domain = enumSchemaDomain(node.init);
|
|
12953
|
+
const tokens = schemaNameTokens(node.id.name);
|
|
12954
|
+
if (domain !== null && tokens.length >= 2) {
|
|
12955
|
+
enumSchemas.push({ domain, name: node.id.name, tokens });
|
|
12956
|
+
}
|
|
12957
|
+
}
|
|
12577
12958
|
},
|
|
12578
12959
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
12579
12960
|
"MemberExpression[computed=false]"(node) {
|
|
12580
|
-
if (node.object.type ===
|
|
12961
|
+
if (node.object.type === import_utils62.AST_NODE_TYPES.Identifier && node.property.type === import_utils62.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
12581
12962
|
reshapedSchemaNames.add(node.object.name);
|
|
12582
12963
|
}
|
|
12583
12964
|
},
|
|
12584
12965
|
/** Records every type argument carried by a Zod constraint. */
|
|
12585
12966
|
TSTypeReference(node) {
|
|
12586
12967
|
const { typeName } = node;
|
|
12587
|
-
const referenced = typeName.type ===
|
|
12968
|
+
const referenced = typeName.type === import_utils62.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils62.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils62.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
12588
12969
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
12589
12970
|
return;
|
|
12590
12971
|
}
|
|
@@ -12600,20 +12981,38 @@ var prefer_zod_infer_default = createRule({
|
|
|
12600
12981
|
if (members !== null) {
|
|
12601
12982
|
typeDeclarations.push({ name: node.id.name, node: node.id, members });
|
|
12602
12983
|
}
|
|
12984
|
+
recordLiteralUnions(
|
|
12985
|
+
node.body.body,
|
|
12986
|
+
node,
|
|
12987
|
+
node.id.name,
|
|
12988
|
+
isExportedDeclaration(node)
|
|
12989
|
+
);
|
|
12603
12990
|
},
|
|
12604
12991
|
TSTypeAliasDeclaration(node) {
|
|
12605
|
-
|
|
12992
|
+
const schemaName = inferredSchemaName(node.typeAnnotation);
|
|
12993
|
+
if (schemaName !== null) {
|
|
12994
|
+
inferredAliases.push({
|
|
12995
|
+
exported: isExportedDeclaration(node),
|
|
12996
|
+
schemaName,
|
|
12997
|
+
typeName: node.id.name
|
|
12998
|
+
});
|
|
12999
|
+
}
|
|
13000
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
12606
13001
|
return;
|
|
12607
13002
|
}
|
|
12608
13003
|
const members = typeMembers(node.typeAnnotation.members);
|
|
12609
13004
|
if (members !== null) {
|
|
12610
13005
|
typeDeclarations.push({ name: node.id.name, node: node.id, members });
|
|
12611
13006
|
}
|
|
13007
|
+
recordLiteralUnions(
|
|
13008
|
+
node.typeAnnotation.members,
|
|
13009
|
+
node,
|
|
13010
|
+
node.id.name,
|
|
13011
|
+
isExportedDeclaration(node)
|
|
13012
|
+
);
|
|
12612
13013
|
},
|
|
12613
13014
|
"Program:exit"() {
|
|
12614
|
-
|
|
12615
|
-
return;
|
|
12616
|
-
}
|
|
13015
|
+
const twinTypeNames = /* @__PURE__ */ new Set();
|
|
12617
13016
|
const byName = /* @__PURE__ */ new Map();
|
|
12618
13017
|
for (const schema of schemas) {
|
|
12619
13018
|
const key = normalizeSchemaName(schema.name);
|
|
@@ -12635,19 +13034,69 @@ var prefer_zod_infer_default = createRule({
|
|
|
12635
13034
|
if (!isTwin(schema.fields, declaration.members)) {
|
|
12636
13035
|
continue;
|
|
12637
13036
|
}
|
|
13037
|
+
twinTypeNames.add(declaration.name);
|
|
12638
13038
|
context.report({
|
|
12639
13039
|
node: declaration.node,
|
|
12640
13040
|
messageId: "handWrittenTwin",
|
|
12641
13041
|
data: { typeName: declaration.name, schemaName: schema.name }
|
|
12642
13042
|
});
|
|
12643
13043
|
}
|
|
13044
|
+
const aliasesBySchema = /* @__PURE__ */ new Map();
|
|
13045
|
+
for (const alias of inferredAliases) {
|
|
13046
|
+
const aliases = aliasesBySchema.get(alias.schemaName) ?? [];
|
|
13047
|
+
aliases.push(alias);
|
|
13048
|
+
aliasesBySchema.set(alias.schemaName, aliases);
|
|
13049
|
+
}
|
|
13050
|
+
const groups = /* @__PURE__ */ new Map();
|
|
13051
|
+
for (const occurrence of literalUnionOccurrences) {
|
|
13052
|
+
const { ownerName } = occurrence;
|
|
13053
|
+
if (twinTypeNames.has(ownerName ?? "") || ownerName !== null && ignorePatterns.some((pattern) => pattern.test(ownerName))) {
|
|
13054
|
+
continue;
|
|
13055
|
+
}
|
|
13056
|
+
const candidates = enumSchemas.filter(
|
|
13057
|
+
(schema2) => sameDomain(schema2.domain, occurrence.domain) && endsWithTokens(schema2.tokens, occurrence.propertyTokens) && (aliasesBySchema.get(schema2.name)?.length ?? 0) === 1
|
|
13058
|
+
);
|
|
13059
|
+
const [schema] = candidates;
|
|
13060
|
+
if (candidates.length !== 1 || schema === void 0) {
|
|
13061
|
+
continue;
|
|
13062
|
+
}
|
|
13063
|
+
const [alias] = aliasesBySchema.get(schema.name) ?? [];
|
|
13064
|
+
if (alias === void 0 || occurrence.exported && !alias.exported) {
|
|
13065
|
+
continue;
|
|
13066
|
+
}
|
|
13067
|
+
const key = `${schema.name}\0${occurrence.propertyName}`;
|
|
13068
|
+
const group = groups.get(key);
|
|
13069
|
+
if (group === void 0) {
|
|
13070
|
+
groups.set(key, { alias, occurrences: [occurrence], schema });
|
|
13071
|
+
} else {
|
|
13072
|
+
group.occurrences.push(occurrence);
|
|
13073
|
+
}
|
|
13074
|
+
}
|
|
13075
|
+
for (const { alias, occurrences, schema } of groups.values()) {
|
|
13076
|
+
if (new Set(occurrences.map(({ ownerName }) => ownerName)).size < 2 || new Set(occurrences.map(({ owner }) => owner)).size < 2) {
|
|
13077
|
+
continue;
|
|
13078
|
+
}
|
|
13079
|
+
const [first] = occurrences;
|
|
13080
|
+
if (first === void 0) {
|
|
13081
|
+
continue;
|
|
13082
|
+
}
|
|
13083
|
+
context.report({
|
|
13084
|
+
node: first.node,
|
|
13085
|
+
messageId: "repeatedEnumUnion",
|
|
13086
|
+
data: {
|
|
13087
|
+
propertyName: first.propertyName,
|
|
13088
|
+
schemaName: schema.name,
|
|
13089
|
+
typeName: alias.typeName
|
|
13090
|
+
}
|
|
13091
|
+
});
|
|
13092
|
+
}
|
|
12644
13093
|
}
|
|
12645
13094
|
};
|
|
12646
13095
|
}
|
|
12647
13096
|
});
|
|
12648
13097
|
|
|
12649
13098
|
// src/rules/require-assert-never.ts
|
|
12650
|
-
var
|
|
13099
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
12651
13100
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
12652
13101
|
var requireAssertNeverDocumentation = {
|
|
12653
13102
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
@@ -12660,14 +13109,14 @@ var requireAssertNeverDocumentation = {
|
|
|
12660
13109
|
]
|
|
12661
13110
|
};
|
|
12662
13111
|
var isRuntimeHandlingStatement = (statement) => {
|
|
12663
|
-
if (statement.type ===
|
|
12664
|
-
if (statement.type ===
|
|
13112
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.EmptyStatement) return false;
|
|
13113
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.BreakStatement) {
|
|
12665
13114
|
return statement.label !== null;
|
|
12666
13115
|
}
|
|
12667
|
-
if (statement.type ===
|
|
13116
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.TSTypeAliasDeclaration || statement.type === import_utils63.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
12668
13117
|
return false;
|
|
12669
13118
|
}
|
|
12670
|
-
if (statement.type ===
|
|
13119
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.BlockStatement) {
|
|
12671
13120
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
12672
13121
|
}
|
|
12673
13122
|
return true;
|
|
@@ -12683,7 +13132,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
12683
13132
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
12684
13133
|
}
|
|
12685
13134
|
const only = defaultCase.consequent[0];
|
|
12686
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
13135
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils63.AST_NODE_TYPES.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
12687
13136
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
12688
13137
|
}
|
|
12689
13138
|
return false;
|
|
@@ -12739,7 +13188,7 @@ var require_assert_never_default = createRule({
|
|
|
12739
13188
|
create(context) {
|
|
12740
13189
|
let services;
|
|
12741
13190
|
try {
|
|
12742
|
-
services =
|
|
13191
|
+
services = import_utils63.ESLintUtils.getParserServices(context);
|
|
12743
13192
|
} catch {
|
|
12744
13193
|
services = null;
|
|
12745
13194
|
}
|
|
@@ -12766,7 +13215,7 @@ var require_assert_never_default = createRule({
|
|
|
12766
13215
|
});
|
|
12767
13216
|
|
|
12768
13217
|
// src/rules/require-fetch-timeout.ts
|
|
12769
|
-
var
|
|
13218
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
12770
13219
|
var requireFetchTimeoutDocumentation = {
|
|
12771
13220
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
12772
13221
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -12792,14 +13241,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
12792
13241
|
return false;
|
|
12793
13242
|
}
|
|
12794
13243
|
function initProvablyLacksSignal(init) {
|
|
12795
|
-
if (init.type !==
|
|
13244
|
+
if (init.type !== import_utils64.AST_NODE_TYPES.ObjectExpression) {
|
|
12796
13245
|
return false;
|
|
12797
13246
|
}
|
|
12798
13247
|
for (const prop of init.properties) {
|
|
12799
|
-
if (prop.type ===
|
|
13248
|
+
if (prop.type === import_utils64.AST_NODE_TYPES.SpreadElement) {
|
|
12800
13249
|
return false;
|
|
12801
13250
|
}
|
|
12802
|
-
if (prop.key.type ===
|
|
13251
|
+
if (prop.key.type === import_utils64.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils64.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
12803
13252
|
return false;
|
|
12804
13253
|
}
|
|
12805
13254
|
if (prop.computed) {
|
|
@@ -12809,7 +13258,7 @@ function initProvablyLacksSignal(init) {
|
|
|
12809
13258
|
return true;
|
|
12810
13259
|
}
|
|
12811
13260
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
12812
|
-
return node.type ===
|
|
13261
|
+
return node.type === import_utils64.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils64.AST_NODE_TYPES.TemplateLiteral || node.type === import_utils64.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils64.AST_NODE_TYPES.Identifier && node.callee.name === "URL" && resolvesToGlobal(node.callee);
|
|
12813
13262
|
}
|
|
12814
13263
|
var require_fetch_timeout_default = createRule({
|
|
12815
13264
|
name: "require-fetch-timeout",
|
|
@@ -12847,30 +13296,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
12847
13296
|
}
|
|
12848
13297
|
function resolvesToGlobal(identifier) {
|
|
12849
13298
|
const scope = context.sourceCode.getScope(identifier);
|
|
12850
|
-
const variable =
|
|
13299
|
+
const variable = import_utils64.ASTUtils.findVariable(scope, identifier.name);
|
|
12851
13300
|
return variable === null || variable.defs.length === 0;
|
|
12852
13301
|
}
|
|
12853
13302
|
function isGlobalFetchCall2(callee) {
|
|
12854
|
-
if (callee.type ===
|
|
13303
|
+
if (callee.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
12855
13304
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
12856
13305
|
}
|
|
12857
|
-
return callee.type ===
|
|
13306
|
+
return callee.type === import_utils64.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils64.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils64.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
12858
13307
|
}
|
|
12859
13308
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
12860
|
-
const variable =
|
|
13309
|
+
const variable = import_utils64.ASTUtils.findVariable(
|
|
12861
13310
|
context.sourceCode.getScope(identifier),
|
|
12862
13311
|
identifier.name
|
|
12863
13312
|
);
|
|
12864
13313
|
if (variable?.defs.length !== 1) return false;
|
|
12865
13314
|
const definition = variable.defs[0];
|
|
12866
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
13315
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== import_utils64.AST_NODE_TYPES.ObjectExpression || !initProvablyLacksSignal(definition.node.init)) {
|
|
12867
13316
|
return false;
|
|
12868
13317
|
}
|
|
12869
13318
|
for (const reference of variable.references) {
|
|
12870
13319
|
const ref = reference.identifier;
|
|
12871
13320
|
if (ref === identifier || ref === definition.name) continue;
|
|
12872
13321
|
const member = ref.parent;
|
|
12873
|
-
if (member.type !==
|
|
13322
|
+
if (member.type !== import_utils64.AST_NODE_TYPES.MemberExpression || member.object !== ref || member.computed || member.property.type !== import_utils64.AST_NODE_TYPES.Identifier || member.property.name === "signal" || member.parent.type !== import_utils64.AST_NODE_TYPES.AssignmentExpression || member.parent.left !== member) {
|
|
12874
13323
|
return false;
|
|
12875
13324
|
}
|
|
12876
13325
|
}
|
|
@@ -12885,7 +13334,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
12885
13334
|
if (node.arguments.length === 1 && first !== void 0 && !isInlineUrl(first, resolvesToGlobal)) {
|
|
12886
13335
|
return;
|
|
12887
13336
|
}
|
|
12888
|
-
if (init === void 0 || initProvablyLacksSignal(init) || init.type ===
|
|
13337
|
+
if (init === void 0 || initProvablyLacksSignal(init) || init.type === import_utils64.AST_NODE_TYPES.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
12889
13338
|
context.report({ node, messageId: "missingSignal" });
|
|
12890
13339
|
}
|
|
12891
13340
|
}
|
|
@@ -12894,7 +13343,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
12894
13343
|
});
|
|
12895
13344
|
|
|
12896
13345
|
// src/rules/require-port-for-service.ts
|
|
12897
|
-
var
|
|
13346
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
12898
13347
|
var requirePortForServiceDocumentation = {
|
|
12899
13348
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
12900
13349
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -12919,45 +13368,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
12919
13368
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
12920
13369
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
12921
13370
|
var staticMemberName4 = (member) => {
|
|
12922
|
-
if (member.property.type ===
|
|
12923
|
-
if (!member.computed && member.property.type ===
|
|
12924
|
-
return member.computed && member.property.type ===
|
|
13371
|
+
if (member.property.type === import_utils65.AST_NODE_TYPES.PrivateIdentifier) return `#${member.property.name}`;
|
|
13372
|
+
if (!member.computed && member.property.type === import_utils65.AST_NODE_TYPES.Identifier) return member.property.name;
|
|
13373
|
+
return member.computed && member.property.type === import_utils65.AST_NODE_TYPES.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
12925
13374
|
};
|
|
12926
13375
|
var detachedValueExports = (program) => {
|
|
12927
13376
|
const names = /* @__PURE__ */ new Set();
|
|
12928
13377
|
for (const statement of program.body) {
|
|
12929
|
-
if (statement.type ===
|
|
13378
|
+
if (statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
12930
13379
|
for (const specifier of statement.specifiers) {
|
|
12931
13380
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
12932
13381
|
}
|
|
12933
|
-
} else if (statement.type ===
|
|
13382
|
+
} else if (statement.type === import_utils65.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
12934
13383
|
names.add(statement.declaration.name);
|
|
12935
|
-
} else if (statement.type ===
|
|
13384
|
+
} else if (statement.type === import_utils65.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
12936
13385
|
names.add(statement.expression.name);
|
|
12937
13386
|
}
|
|
12938
13387
|
}
|
|
12939
13388
|
return names;
|
|
12940
13389
|
};
|
|
12941
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
13390
|
+
var isExportedClass2 = (node, detached) => node.parent.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils65.AST_NODE_TYPES.ExportDefaultDeclaration || node.id !== null && detached.has(node.id.name);
|
|
12942
13391
|
var readTypeReference = (annotation) => {
|
|
12943
|
-
if (annotation?.type ===
|
|
13392
|
+
if (annotation?.type === import_utils65.AST_NODE_TYPES.TSUnionType) {
|
|
12944
13393
|
const members = annotation.types.filter(
|
|
12945
|
-
(member) => member.type !==
|
|
13394
|
+
(member) => member.type !== import_utils65.AST_NODE_TYPES.TSUndefinedKeyword && member.type !== import_utils65.AST_NODE_TYPES.TSNullKeyword
|
|
12946
13395
|
);
|
|
12947
13396
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
12948
13397
|
}
|
|
12949
|
-
if (annotation === void 0 || annotation.type !==
|
|
13398
|
+
if (annotation === void 0 || annotation.type !== import_utils65.AST_NODE_TYPES.TSTypeReference) return null;
|
|
12950
13399
|
const { typeName } = annotation;
|
|
12951
|
-
const rightmost = typeName.type ===
|
|
13400
|
+
const rightmost = typeName.type === import_utils65.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils65.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
12952
13401
|
if (rightmost === null) return null;
|
|
12953
13402
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
12954
13403
|
};
|
|
12955
|
-
var qualifiedName = (name) => name.type ===
|
|
13404
|
+
var qualifiedName = (name) => name.type === import_utils65.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils65.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
12956
13405
|
var propertySignatureTypes = (members) => {
|
|
12957
13406
|
const types = /* @__PURE__ */ new Map();
|
|
12958
13407
|
for (const member of members) {
|
|
12959
|
-
if (member.type !==
|
|
12960
|
-
if (member.computed || member.key.type !==
|
|
13408
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13409
|
+
if (member.computed || member.key.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
12961
13410
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
12962
13411
|
if (reference === null) continue;
|
|
12963
13412
|
types.set(member.key.name, reference);
|
|
@@ -12968,18 +13417,18 @@ var fileTypeIndex = (program) => {
|
|
|
12968
13417
|
const objects = /* @__PURE__ */ new Map();
|
|
12969
13418
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
12970
13419
|
for (const statement of program.body) {
|
|
12971
|
-
const declaration = statement.type ===
|
|
12972
|
-
if (declaration?.type ===
|
|
13420
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
13421
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
12973
13422
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
12974
13423
|
continue;
|
|
12975
13424
|
}
|
|
12976
|
-
if (declaration?.type !==
|
|
13425
|
+
if (declaration?.type !== import_utils65.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
12977
13426
|
const aliased = declaration.typeAnnotation;
|
|
12978
|
-
if (aliased.type ===
|
|
13427
|
+
if (aliased.type === import_utils65.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils65.AST_NODE_TYPES.TSConstructorType) {
|
|
12979
13428
|
functionAliases.add(declaration.id.name);
|
|
12980
13429
|
continue;
|
|
12981
13430
|
}
|
|
12982
|
-
const literals = aliased.type ===
|
|
13431
|
+
const literals = aliased.type === import_utils65.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils65.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils65.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
12983
13432
|
if (literals.length === 0) continue;
|
|
12984
13433
|
const merged = /* @__PURE__ */ new Map();
|
|
12985
13434
|
for (const literal of literals) {
|
|
@@ -13007,10 +13456,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13007
13456
|
while (pending.length > 0) {
|
|
13008
13457
|
const current = pending.pop();
|
|
13009
13458
|
if (current === void 0) break;
|
|
13010
|
-
if (current.type ===
|
|
13011
|
-
const expression = current.type ===
|
|
13012
|
-
const storedField = expression?.type ===
|
|
13013
|
-
if (expression?.type !==
|
|
13459
|
+
if (current.type === import_utils65.AST_NODE_TYPES.ArrowFunctionExpression || current.type === import_utils65.AST_NODE_TYPES.FunctionExpression || current.type === import_utils65.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils65.AST_NODE_TYPES.ClassExpression || current.type === import_utils65.AST_NODE_TYPES.ClassDeclaration) continue;
|
|
13460
|
+
const expression = current.type === import_utils65.AST_NODE_TYPES.ExpressionStatement ? current.expression : null;
|
|
13461
|
+
const storedField = expression?.type === import_utils65.AST_NODE_TYPES.AssignmentExpression && expression.left.type === import_utils65.AST_NODE_TYPES.MemberExpression && expression.left.object.type === import_utils65.AST_NODE_TYPES.ThisExpression ? staticMemberName4(expression.left) : null;
|
|
13462
|
+
if (expression?.type !== import_utils65.AST_NODE_TYPES.AssignmentExpression || !STORAGE_ASSIGNMENT_OPERATORS.has(expression.operator) || expression.left.type !== import_utils65.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils65.AST_NODE_TYPES.ThisExpression || storedField === null) {
|
|
13014
13463
|
for (const key of Object.keys(current)) {
|
|
13015
13464
|
if (key === "parent") continue;
|
|
13016
13465
|
const value = current[key];
|
|
@@ -13023,14 +13472,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13023
13472
|
continue;
|
|
13024
13473
|
}
|
|
13025
13474
|
let source = expression.right;
|
|
13026
|
-
while (source.type ===
|
|
13027
|
-
if (source.type ===
|
|
13475
|
+
while (source.type === import_utils65.AST_NODE_TYPES.TSNonNullExpression || source.type === import_utils65.AST_NODE_TYPES.TSAsExpression || source.type === import_utils65.AST_NODE_TYPES.TSSatisfiesExpression || source.type === import_utils65.AST_NODE_TYPES.TSTypeAssertion) source = source.expression;
|
|
13476
|
+
if (source.type === import_utils65.AST_NODE_TYPES.NewExpression) {
|
|
13028
13477
|
constructedFields += 1;
|
|
13029
|
-
} else if (source.type ===
|
|
13478
|
+
} else if (source.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13030
13479
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
13031
13480
|
fields.add(storedField);
|
|
13032
13481
|
storedFieldsFrom.set(source.name, fields);
|
|
13033
|
-
} else if (source.type ===
|
|
13482
|
+
} else if (source.type === import_utils65.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13034
13483
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
13035
13484
|
fields.add(storedField);
|
|
13036
13485
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -13040,7 +13489,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13040
13489
|
const collaborators = [];
|
|
13041
13490
|
for (const parameter of ctor.value.params) {
|
|
13042
13491
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
13043
|
-
const fields = parameter.type ===
|
|
13492
|
+
const fields = parameter.type === import_utils65.AST_NODE_TYPES.TSParameterProperty ? [reference.name] : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
13044
13493
|
if (fields.length === 0) continue;
|
|
13045
13494
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
13046
13495
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -13055,8 +13504,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13055
13504
|
};
|
|
13056
13505
|
var parameterCollaborators = (parameter, declared) => {
|
|
13057
13506
|
let target = parameter;
|
|
13058
|
-
if (target.type ===
|
|
13059
|
-
if (target.type ===
|
|
13507
|
+
if (target.type === import_utils65.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
13508
|
+
if (target.type === import_utils65.AST_NODE_TYPES.ObjectPattern) {
|
|
13060
13509
|
return objectPatternCollaborators(target, declared);
|
|
13061
13510
|
}
|
|
13062
13511
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -13064,9 +13513,9 @@ var parameterCollaborators = (parameter, declared) => {
|
|
|
13064
13513
|
};
|
|
13065
13514
|
var namedParameterCollaborator = (annotated) => {
|
|
13066
13515
|
let target = annotated;
|
|
13067
|
-
if (target.type ===
|
|
13068
|
-
if (target.type ===
|
|
13069
|
-
if (target.type !==
|
|
13516
|
+
if (target.type === import_utils65.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
13517
|
+
if (target.type === import_utils65.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
13518
|
+
if (target.type !== import_utils65.AST_NODE_TYPES.Identifier) return null;
|
|
13070
13519
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
13071
13520
|
if (reference === null) return null;
|
|
13072
13521
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -13078,11 +13527,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
13078
13527
|
if (members === null) return [];
|
|
13079
13528
|
const collaborators = [];
|
|
13080
13529
|
for (const property of pattern.properties) {
|
|
13081
|
-
if (property.type !==
|
|
13082
|
-
if (property.key.type !==
|
|
13530
|
+
if (property.type !== import_utils65.AST_NODE_TYPES.Property || property.computed) continue;
|
|
13531
|
+
if (property.key.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13083
13532
|
const key = property.key.name;
|
|
13084
|
-
const bound = property.value.type ===
|
|
13085
|
-
if (bound.type !==
|
|
13533
|
+
const bound = property.value.type === import_utils65.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
13534
|
+
if (bound.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13086
13535
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
13087
13536
|
const reference = members.get(key);
|
|
13088
13537
|
if (reference === void 0) continue;
|
|
@@ -13091,21 +13540,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
13091
13540
|
return collaborators;
|
|
13092
13541
|
};
|
|
13093
13542
|
var bagMemberTypes = (annotation, declared) => {
|
|
13094
|
-
if (annotation.type ===
|
|
13543
|
+
if (annotation.type === import_utils65.AST_NODE_TYPES.TSTypeLiteral) {
|
|
13095
13544
|
return propertySignatureTypes(annotation.members);
|
|
13096
13545
|
}
|
|
13097
|
-
if (annotation.type !==
|
|
13546
|
+
if (annotation.type !== import_utils65.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13098
13547
|
return null;
|
|
13099
13548
|
}
|
|
13100
13549
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
13101
13550
|
};
|
|
13102
13551
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
13103
|
-
if (node.type ===
|
|
13552
|
+
if (node.type === import_utils65.AST_NODE_TYPES.CallExpression) {
|
|
13104
13553
|
const { callee } = node;
|
|
13105
|
-
if (callee.type ===
|
|
13106
|
-
return callee.type ===
|
|
13554
|
+
if (callee.type === import_utils65.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
13555
|
+
return callee.type === import_utils65.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils65.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
13107
13556
|
}
|
|
13108
|
-
return node.type ===
|
|
13557
|
+
return node.type === import_utils65.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils65.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
13109
13558
|
});
|
|
13110
13559
|
var subtreeHas = (root, found) => {
|
|
13111
13560
|
let hit = false;
|
|
@@ -13132,19 +13581,19 @@ var invokedInstanceField = (call) => {
|
|
|
13132
13581
|
const direct = instanceField(call.callee);
|
|
13133
13582
|
if (direct !== null) return direct;
|
|
13134
13583
|
let callee = call.callee;
|
|
13135
|
-
while (callee.type ===
|
|
13136
|
-
return callee.type ===
|
|
13584
|
+
while (callee.type === import_utils65.AST_NODE_TYPES.ChainExpression || callee.type === import_utils65.AST_NODE_TYPES.TSAsExpression || callee.type === import_utils65.AST_NODE_TYPES.TSNonNullExpression || callee.type === import_utils65.AST_NODE_TYPES.TSSatisfiesExpression || callee.type === import_utils65.AST_NODE_TYPES.TSTypeAssertion) callee = callee.expression;
|
|
13585
|
+
return callee.type === import_utils65.AST_NODE_TYPES.MemberExpression ? instanceField(callee.object) : null;
|
|
13137
13586
|
};
|
|
13138
13587
|
var instanceField = (candidate) => {
|
|
13139
13588
|
let node = candidate;
|
|
13140
|
-
while (node.type ===
|
|
13141
|
-
return node.type ===
|
|
13589
|
+
while (node.type === import_utils65.AST_NODE_TYPES.ChainExpression || node.type === import_utils65.AST_NODE_TYPES.TSAsExpression || node.type === import_utils65.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils65.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils65.AST_NODE_TYPES.TSTypeAssertion) node = node.expression;
|
|
13590
|
+
return node.type === import_utils65.AST_NODE_TYPES.MemberExpression && node.object.type === import_utils65.AST_NODE_TYPES.ThisExpression ? staticMemberName4(node) : null;
|
|
13142
13591
|
};
|
|
13143
13592
|
var behaviorallyInvokedFields = (body2) => {
|
|
13144
13593
|
const invoked = /* @__PURE__ */ new Set();
|
|
13145
13594
|
const visit = (current) => {
|
|
13146
|
-
if (current.type ===
|
|
13147
|
-
if (current.type ===
|
|
13595
|
+
if (current.type === import_utils65.AST_NODE_TYPES.ClassDeclaration || current.type === import_utils65.AST_NODE_TYPES.ClassExpression || current.type === import_utils65.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils65.AST_NODE_TYPES.FunctionExpression) return;
|
|
13596
|
+
if (current.type === import_utils65.AST_NODE_TYPES.CallExpression) {
|
|
13148
13597
|
const field = invokedInstanceField(current);
|
|
13149
13598
|
if (field !== null) invoked.add(field);
|
|
13150
13599
|
}
|
|
@@ -13157,14 +13606,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
13157
13606
|
}
|
|
13158
13607
|
};
|
|
13159
13608
|
for (const member of body2.body) {
|
|
13160
|
-
if (member.type ===
|
|
13161
|
-
if (member.type ===
|
|
13609
|
+
if (member.type === import_utils65.AST_NODE_TYPES.StaticBlock || member.static) continue;
|
|
13610
|
+
if (member.type === import_utils65.AST_NODE_TYPES.MethodDefinition) {
|
|
13162
13611
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
13163
13612
|
continue;
|
|
13164
13613
|
}
|
|
13165
|
-
if (member.type !==
|
|
13614
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.PropertyDefinition || member.value === null) continue;
|
|
13166
13615
|
visit(
|
|
13167
|
-
member.value.type ===
|
|
13616
|
+
member.value.type === import_utils65.AST_NODE_TYPES.ArrowFunctionExpression ? member.value.body : member.value
|
|
13168
13617
|
);
|
|
13169
13618
|
}
|
|
13170
13619
|
return invoked;
|
|
@@ -13184,25 +13633,25 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
13184
13633
|
var fileInterfaceNames = (program) => {
|
|
13185
13634
|
const names = [];
|
|
13186
13635
|
for (const statement of program.body) {
|
|
13187
|
-
const declaration = statement.type ===
|
|
13188
|
-
if (declaration?.type ===
|
|
13636
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
13637
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
13189
13638
|
}
|
|
13190
13639
|
return names;
|
|
13191
13640
|
};
|
|
13192
13641
|
var publicMethodNames = (body2, functionAliases) => {
|
|
13193
13642
|
const names = [];
|
|
13194
13643
|
for (const member of body2.body) {
|
|
13195
|
-
if (member.type ===
|
|
13644
|
+
if (member.type === import_utils65.AST_NODE_TYPES.PropertyDefinition) {
|
|
13196
13645
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
13197
|
-
if (member.value?.type !==
|
|
13198
|
-
names.push(member.key.type ===
|
|
13646
|
+
if (member.value?.type !== import_utils65.AST_NODE_TYPES.ArrowFunctionExpression && member.value?.type !== import_utils65.AST_NODE_TYPES.FunctionExpression && member.typeAnnotation?.typeAnnotation.type !== import_utils65.AST_NODE_TYPES.TSFunctionType && !(member.typeAnnotation?.typeAnnotation.type === import_utils65.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils65.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name))) continue;
|
|
13647
|
+
names.push(member.key.type === import_utils65.AST_NODE_TYPES.Identifier ? member.key.name : "\u2026");
|
|
13199
13648
|
continue;
|
|
13200
13649
|
}
|
|
13201
|
-
if (member.type !==
|
|
13650
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.MethodDefinition) continue;
|
|
13202
13651
|
if (member.kind !== "method" || member.static) continue;
|
|
13203
13652
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
13204
|
-
if (member.key.type ===
|
|
13205
|
-
if (member.key.type ===
|
|
13653
|
+
if (member.key.type === import_utils65.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
13654
|
+
if (member.key.type === import_utils65.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
13206
13655
|
else names.push("\u2026");
|
|
13207
13656
|
}
|
|
13208
13657
|
return names;
|
|
@@ -13210,13 +13659,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
13210
13659
|
var isFluentConstructionObject = (node, getText) => {
|
|
13211
13660
|
if (node.id === null) return false;
|
|
13212
13661
|
const methods = node.body.body.filter(
|
|
13213
|
-
(member) => member.type ===
|
|
13662
|
+
(member) => member.type === import_utils65.AST_NODE_TYPES.MethodDefinition && member.kind === "method" && !member.static && member.accessibility !== "private" && member.accessibility !== "protected" && member.value.body !== null
|
|
13214
13663
|
);
|
|
13215
13664
|
if (methods.length === 0) return false;
|
|
13216
13665
|
return methods.every((member) => {
|
|
13217
13666
|
const result = member.value.returnType?.typeAnnotation;
|
|
13218
13667
|
if (result === void 0) return false;
|
|
13219
|
-
const returnsOwnType = result.type ===
|
|
13668
|
+
const returnsOwnType = result.type === import_utils65.AST_NODE_TYPES.TSTypeReference && result.typeName.type === import_utils65.AST_NODE_TYPES.Identifier && result.typeName.name === node.id?.name;
|
|
13220
13669
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
13221
13670
|
});
|
|
13222
13671
|
};
|
|
@@ -13224,10 +13673,10 @@ function localClassAbstractness(program) {
|
|
|
13224
13673
|
const classes = /* @__PURE__ */ new Map();
|
|
13225
13674
|
const parents = /* @__PURE__ */ new Map();
|
|
13226
13675
|
for (const statement of program.body) {
|
|
13227
|
-
const declaration = statement.type ===
|
|
13228
|
-
if (declaration?.type ===
|
|
13676
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils65.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
13677
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.ClassDeclaration && declaration.id !== null) {
|
|
13229
13678
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
13230
|
-
if (declaration.superClass?.type ===
|
|
13679
|
+
if (declaration.superClass?.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13231
13680
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
13232
13681
|
}
|
|
13233
13682
|
}
|
|
@@ -13249,43 +13698,43 @@ function localInterfaceSurfaces(program) {
|
|
|
13249
13698
|
const parents = /* @__PURE__ */ new Map();
|
|
13250
13699
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
13251
13700
|
for (const statement of program.body) {
|
|
13252
|
-
const declaration = statement.type ===
|
|
13253
|
-
if (declaration?.type ===
|
|
13701
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
13702
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.TSTypeAliasDeclaration && (declaration.typeAnnotation.type === import_utils65.AST_NODE_TYPES.TSFunctionType || declaration.typeAnnotation.type === import_utils65.AST_NODE_TYPES.TSConstructorType)) functionAliases.add(declaration.id.name);
|
|
13254
13703
|
}
|
|
13255
13704
|
for (const statement of program.body) {
|
|
13256
|
-
const declaration = statement.type ===
|
|
13257
|
-
if (declaration?.type ===
|
|
13705
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
13706
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
13258
13707
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
13259
|
-
const parts = declaration.typeAnnotation.type ===
|
|
13708
|
+
const parts = declaration.typeAnnotation.type === import_utils65.AST_NODE_TYPES.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
13260
13709
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
13261
13710
|
for (const part of parts) {
|
|
13262
|
-
if (part.type ===
|
|
13711
|
+
if (part.type === import_utils65.AST_NODE_TYPES.TSTypeReference && part.typeName.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13263
13712
|
inherited.push(part.typeName.name);
|
|
13264
13713
|
continue;
|
|
13265
13714
|
}
|
|
13266
|
-
if (part.type !==
|
|
13715
|
+
if (part.type !== import_utils65.AST_NODE_TYPES.TSTypeLiteral) continue;
|
|
13267
13716
|
for (const member of part.members) {
|
|
13268
|
-
if (member.type !==
|
|
13269
|
-
if (member.computed || member.key.type !==
|
|
13270
|
-
if (member.type ===
|
|
13717
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13718
|
+
if (member.computed || member.key.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13719
|
+
if (member.type === import_utils65.AST_NODE_TYPES.TSMethodSignature) {
|
|
13271
13720
|
callables2.add(member.key.name);
|
|
13272
13721
|
continue;
|
|
13273
13722
|
}
|
|
13274
|
-
if (member.type !==
|
|
13723
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13275
13724
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
13276
|
-
if (annotation?.type ===
|
|
13725
|
+
if (annotation?.type === import_utils65.AST_NODE_TYPES.TSFunctionType || annotation?.type === import_utils65.AST_NODE_TYPES.TSTypeReference && annotation.typeName.type === import_utils65.AST_NODE_TYPES.Identifier && functionAliases.has(annotation.typeName.name)) callables2.add(member.key.name);
|
|
13277
13726
|
}
|
|
13278
13727
|
}
|
|
13279
13728
|
interfaces.set(declaration.id.name, callables2);
|
|
13280
13729
|
parents.set(declaration.id.name, inherited);
|
|
13281
13730
|
continue;
|
|
13282
13731
|
}
|
|
13283
|
-
if (declaration?.type !==
|
|
13732
|
+
if (declaration?.type !== import_utils65.AST_NODE_TYPES.TSInterfaceDeclaration) continue;
|
|
13284
13733
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
13285
13734
|
for (const member of declaration.body.body) {
|
|
13286
|
-
if (member.type !==
|
|
13287
|
-
if (member.computed || member.key.type !==
|
|
13288
|
-
if (member.type ===
|
|
13735
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13736
|
+
if (member.computed || member.key.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13737
|
+
if (member.type === import_utils65.AST_NODE_TYPES.TSMethodSignature || member.typeAnnotation?.typeAnnotation.type === import_utils65.AST_NODE_TYPES.TSFunctionType || member.typeAnnotation?.typeAnnotation.type === import_utils65.AST_NODE_TYPES.TSTypeReference && member.typeAnnotation.typeAnnotation.typeName.type === import_utils65.AST_NODE_TYPES.Identifier && functionAliases.has(member.typeAnnotation.typeAnnotation.typeName.name)) callables.add(member.key.name);
|
|
13289
13738
|
}
|
|
13290
13739
|
interfaces.set(declaration.id.name, callables);
|
|
13291
13740
|
parents.set(
|
|
@@ -13293,7 +13742,7 @@ function localInterfaceSurfaces(program) {
|
|
|
13293
13742
|
[
|
|
13294
13743
|
...parents.get(declaration.id.name) ?? [],
|
|
13295
13744
|
...declaration.extends.flatMap(
|
|
13296
|
-
(heritage) => heritage.expression.type ===
|
|
13745
|
+
(heritage) => heritage.expression.type === import_utils65.AST_NODE_TYPES.Identifier ? [heritage.expression.name] : ["*"]
|
|
13297
13746
|
)
|
|
13298
13747
|
]
|
|
13299
13748
|
);
|
|
@@ -13320,7 +13769,7 @@ function localInterfaceSurfaces(program) {
|
|
|
13320
13769
|
}
|
|
13321
13770
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
13322
13771
|
if (node.superClass !== null) {
|
|
13323
|
-
if (node.superClass.type !==
|
|
13772
|
+
if (node.superClass.type !== import_utils65.AST_NODE_TYPES.Identifier) return true;
|
|
13324
13773
|
const localAbstract = classes.get(node.superClass.name);
|
|
13325
13774
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
13326
13775
|
}
|
|
@@ -13332,7 +13781,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
13332
13781
|
if (node.implements.length === 0) return false;
|
|
13333
13782
|
const combined = /* @__PURE__ */ new Set();
|
|
13334
13783
|
for (const implementation of node.implements) {
|
|
13335
|
-
if (implementation.expression.type !==
|
|
13784
|
+
if (implementation.expression.type !== import_utils65.AST_NODE_TYPES.Identifier) return true;
|
|
13336
13785
|
const name = implementation.expression.name;
|
|
13337
13786
|
const localAbstract = classes.get(name);
|
|
13338
13787
|
if (localAbstract === true) return true;
|
|
@@ -13375,7 +13824,7 @@ var require_port_for_service_default = createRule({
|
|
|
13375
13824
|
if (node.abstract === true) return;
|
|
13376
13825
|
if (node.decorators.length > 0) return;
|
|
13377
13826
|
const ctor = node.body.body.find(
|
|
13378
|
-
(member) => member.type ===
|
|
13827
|
+
(member) => member.type === import_utils65.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
13379
13828
|
);
|
|
13380
13829
|
if (ctor === void 0) return;
|
|
13381
13830
|
const constructorFacts = readConstructor(
|
|
@@ -13410,7 +13859,7 @@ var require_port_for_service_default = createRule({
|
|
|
13410
13859
|
});
|
|
13411
13860
|
|
|
13412
13861
|
// src/rules/require-static-next-matcher.ts
|
|
13413
|
-
var
|
|
13862
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
13414
13863
|
var requireStaticNextMatcherDocumentation = {
|
|
13415
13864
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
13416
13865
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -13423,34 +13872,34 @@ var requireStaticNextMatcherDocumentation = {
|
|
|
13423
13872
|
};
|
|
13424
13873
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
13425
13874
|
function unwrapExpression3(node) {
|
|
13426
|
-
if (node.type ===
|
|
13875
|
+
if (node.type === import_utils66.AST_NODE_TYPES.TSAsExpression || node.type === import_utils66.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils66.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils66.AST_NODE_TYPES.TSTypeAssertion) {
|
|
13427
13876
|
return unwrapExpression3(node.expression);
|
|
13428
13877
|
}
|
|
13429
13878
|
return node;
|
|
13430
13879
|
}
|
|
13431
13880
|
function isStaticValue(node) {
|
|
13432
13881
|
const value = unwrapExpression3(node);
|
|
13433
|
-
if (value.type ===
|
|
13882
|
+
if (value.type === import_utils66.AST_NODE_TYPES.Literal) {
|
|
13434
13883
|
return true;
|
|
13435
13884
|
}
|
|
13436
|
-
if (value.type ===
|
|
13885
|
+
if (value.type === import_utils66.AST_NODE_TYPES.TemplateLiteral) {
|
|
13437
13886
|
return value.expressions.length === 0;
|
|
13438
13887
|
}
|
|
13439
|
-
if (value.type ===
|
|
13888
|
+
if (value.type === import_utils66.AST_NODE_TYPES.ArrayExpression) {
|
|
13440
13889
|
return value.elements.every(
|
|
13441
|
-
(element) => element !== null && element.type !==
|
|
13890
|
+
(element) => element !== null && element.type !== import_utils66.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
13442
13891
|
);
|
|
13443
13892
|
}
|
|
13444
|
-
if (value.type ===
|
|
13893
|
+
if (value.type === import_utils66.AST_NODE_TYPES.ObjectExpression) {
|
|
13445
13894
|
return value.properties.every(
|
|
13446
|
-
(property) => property.type ===
|
|
13895
|
+
(property) => property.type === import_utils66.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils66.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
13447
13896
|
);
|
|
13448
13897
|
}
|
|
13449
13898
|
return false;
|
|
13450
13899
|
}
|
|
13451
13900
|
function propertyName2(property) {
|
|
13452
13901
|
if (property.computed) return null;
|
|
13453
|
-
if (property.key.type ===
|
|
13902
|
+
if (property.key.type === import_utils66.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
13454
13903
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
13455
13904
|
}
|
|
13456
13905
|
var require_static_next_matcher_default = createRule({
|
|
@@ -13473,19 +13922,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
13473
13922
|
}
|
|
13474
13923
|
return {
|
|
13475
13924
|
ExportNamedDeclaration(node) {
|
|
13476
|
-
if (node.declaration?.type !==
|
|
13925
|
+
if (node.declaration?.type !== import_utils66.AST_NODE_TYPES.VariableDeclaration) {
|
|
13477
13926
|
return;
|
|
13478
13927
|
}
|
|
13479
13928
|
for (const declaration of node.declaration.declarations) {
|
|
13480
|
-
if (declaration.id.type !==
|
|
13929
|
+
if (declaration.id.type !== import_utils66.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
13481
13930
|
continue;
|
|
13482
13931
|
}
|
|
13483
13932
|
const config = unwrapExpression3(declaration.init);
|
|
13484
|
-
if (config.type !==
|
|
13933
|
+
if (config.type !== import_utils66.AST_NODE_TYPES.ObjectExpression) {
|
|
13485
13934
|
continue;
|
|
13486
13935
|
}
|
|
13487
13936
|
for (const property of config.properties) {
|
|
13488
|
-
if (property.type !==
|
|
13937
|
+
if (property.type !== import_utils66.AST_NODE_TYPES.Property || propertyName2(property) !== "matcher" || property.value.type === import_utils66.AST_NODE_TYPES.AssignmentPattern) {
|
|
13489
13938
|
continue;
|
|
13490
13939
|
}
|
|
13491
13940
|
if (!isStaticValue(property.value)) {
|
|
@@ -13499,7 +13948,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
13499
13948
|
});
|
|
13500
13949
|
|
|
13501
13950
|
// src/rules/require-zod-form-validation.ts
|
|
13502
|
-
var
|
|
13951
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
13503
13952
|
var requireZodFormValidationDocumentation = {
|
|
13504
13953
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
13505
13954
|
rationale: "FormData values are untrusted strings or files and need runtime validation before use.",
|
|
@@ -13524,14 +13973,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
13524
13973
|
var zodReceiverRoot = (node) => {
|
|
13525
13974
|
let current = node;
|
|
13526
13975
|
while (true) {
|
|
13527
|
-
if (current.type ===
|
|
13976
|
+
if (current.type === import_utils67.AST_NODE_TYPES.Identifier) {
|
|
13528
13977
|
return current;
|
|
13529
13978
|
}
|
|
13530
|
-
if (current.type ===
|
|
13979
|
+
if (current.type === import_utils67.AST_NODE_TYPES.CallExpression) {
|
|
13531
13980
|
current = current.callee;
|
|
13532
13981
|
continue;
|
|
13533
13982
|
}
|
|
13534
|
-
if (current.type ===
|
|
13983
|
+
if (current.type === import_utils67.AST_NODE_TYPES.MemberExpression) {
|
|
13535
13984
|
current = current.object;
|
|
13536
13985
|
continue;
|
|
13537
13986
|
}
|
|
@@ -13540,12 +13989,12 @@ var zodReceiverRoot = (node) => {
|
|
|
13540
13989
|
};
|
|
13541
13990
|
var isFormDataMethodCall = (node) => {
|
|
13542
13991
|
let current = node;
|
|
13543
|
-
if (current.type ===
|
|
13992
|
+
if (current.type === import_utils67.AST_NODE_TYPES.AwaitExpression) {
|
|
13544
13993
|
current = current.argument;
|
|
13545
13994
|
}
|
|
13546
|
-
if (current.type !==
|
|
13995
|
+
if (current.type !== import_utils67.AST_NODE_TYPES.CallExpression) return false;
|
|
13547
13996
|
const callee = current.callee;
|
|
13548
|
-
return callee.type ===
|
|
13997
|
+
return callee.type === import_utils67.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils67.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
13549
13998
|
};
|
|
13550
13999
|
var require_zod_form_validation_default = createRule({
|
|
13551
14000
|
name: "require-zod-form-validation",
|
|
@@ -13566,7 +14015,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13566
14015
|
return {};
|
|
13567
14016
|
}
|
|
13568
14017
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
13569
|
-
const resolvedBinding = (identifier) =>
|
|
14018
|
+
const resolvedBinding = (identifier) => import_utils67.ASTUtils.findVariable(
|
|
13570
14019
|
context.sourceCode.getScope(identifier),
|
|
13571
14020
|
identifier.name
|
|
13572
14021
|
);
|
|
@@ -13576,16 +14025,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
13576
14025
|
return false;
|
|
13577
14026
|
}
|
|
13578
14027
|
const definition = binding.defs[0];
|
|
13579
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
14028
|
+
if (definition?.type !== "Variable" || definition.node.type !== import_utils67.AST_NODE_TYPES.VariableDeclarator) {
|
|
13580
14029
|
return false;
|
|
13581
14030
|
}
|
|
13582
14031
|
const init = definition.node.init;
|
|
13583
|
-
return init?.type ===
|
|
14032
|
+
return init?.type === import_utils67.AST_NODE_TYPES.ObjectExpression || init?.type === import_utils67.AST_NODE_TYPES.ArrayExpression || init?.type === import_utils67.AST_NODE_TYPES.Literal || init?.type === import_utils67.AST_NODE_TYPES.ArrowFunctionExpression || init?.type === import_utils67.AST_NODE_TYPES.FunctionExpression;
|
|
13584
14033
|
};
|
|
13585
14034
|
const isZodParseCall = (node) => {
|
|
13586
|
-
if (node.type !==
|
|
14035
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.CallExpression) return false;
|
|
13587
14036
|
const callee = node.callee;
|
|
13588
|
-
if (callee.type !==
|
|
14037
|
+
if (callee.type !== import_utils67.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils67.AST_NODE_TYPES.Identifier || !ZOD_PARSE_METHODS.has(callee.property.name)) {
|
|
13589
14038
|
return false;
|
|
13590
14039
|
}
|
|
13591
14040
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -13594,14 +14043,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
13594
14043
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
13595
14044
|
};
|
|
13596
14045
|
const isFormSourceIdentifier = (node) => {
|
|
13597
|
-
if (node.type !==
|
|
14046
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.Identifier) return false;
|
|
13598
14047
|
const conventionalName = /formdata/i.test(node.name);
|
|
13599
14048
|
let scope = context.sourceCode.getScope(node);
|
|
13600
14049
|
while (scope !== null) {
|
|
13601
14050
|
const variable = scope.set.get(node.name);
|
|
13602
14051
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
13603
14052
|
const def = variable.defs[0];
|
|
13604
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
14053
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils67.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
13605
14054
|
return isFormDataMethodCall(def.node.init);
|
|
13606
14055
|
}
|
|
13607
14056
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -13612,8 +14061,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
13612
14061
|
};
|
|
13613
14062
|
const isFormDataGetCall = (node) => {
|
|
13614
14063
|
const callee = node.callee;
|
|
13615
|
-
if (callee.type !==
|
|
13616
|
-
if (callee.property.type !==
|
|
14064
|
+
if (callee.type !== import_utils67.AST_NODE_TYPES.MemberExpression) return false;
|
|
14065
|
+
if (callee.property.type !== import_utils67.AST_NODE_TYPES.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
13617
14066
|
return false;
|
|
13618
14067
|
}
|
|
13619
14068
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -13629,16 +14078,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
13629
14078
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
13630
14079
|
const isInstanceofNarrowing = (node) => {
|
|
13631
14080
|
const parent = node.parent;
|
|
13632
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
14081
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils67.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils67.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
13633
14082
|
};
|
|
13634
14083
|
const boundDeclarator = (node) => {
|
|
13635
14084
|
let current = node;
|
|
13636
14085
|
let parent = current.parent;
|
|
13637
|
-
while ((parent.type ===
|
|
14086
|
+
while ((parent.type === import_utils67.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils67.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils67.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils67.AST_NODE_TYPES.ChainExpression) && parent.expression === current) {
|
|
13638
14087
|
current = parent;
|
|
13639
14088
|
parent = current.parent;
|
|
13640
14089
|
}
|
|
13641
|
-
if (parent.type ===
|
|
14090
|
+
if (parent.type === import_utils67.AST_NODE_TYPES.VariableDeclarator && parent.init === current && parent.id.type === import_utils67.AST_NODE_TYPES.Identifier) {
|
|
13642
14091
|
return parent;
|
|
13643
14092
|
}
|
|
13644
14093
|
return null;
|
|
@@ -13647,7 +14096,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13647
14096
|
let current = node;
|
|
13648
14097
|
while (current.parent !== void 0) {
|
|
13649
14098
|
const parent = current.parent;
|
|
13650
|
-
if (parent.type ===
|
|
14099
|
+
if (parent.type === import_utils67.AST_NODE_TYPES.BlockStatement || parent.type === import_utils67.AST_NODE_TYPES.Program) {
|
|
13651
14100
|
return current;
|
|
13652
14101
|
}
|
|
13653
14102
|
current = parent;
|
|
@@ -13656,12 +14105,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
13656
14105
|
};
|
|
13657
14106
|
const zodParseMethod = (call) => {
|
|
13658
14107
|
const callee = call.callee;
|
|
13659
|
-
return callee.type ===
|
|
14108
|
+
return callee.type === import_utils67.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils67.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
13660
14109
|
};
|
|
13661
14110
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
13662
14111
|
let current = node.parent;
|
|
13663
14112
|
while (current !== void 0 && current !== statement) {
|
|
13664
|
-
if (current.type ===
|
|
14113
|
+
if (current.type === import_utils67.AST_NODE_TYPES.LogicalExpression || current.type === import_utils67.AST_NODE_TYPES.ConditionalExpression) {
|
|
13665
14114
|
return true;
|
|
13666
14115
|
}
|
|
13667
14116
|
current = current.parent;
|
|
@@ -13671,7 +14120,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13671
14120
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
13672
14121
|
let current = node.parent;
|
|
13673
14122
|
while (current !== void 0 && current !== statement) {
|
|
13674
|
-
if (current.type ===
|
|
14123
|
+
if (current.type === import_utils67.AST_NODE_TYPES.AwaitExpression) return true;
|
|
13675
14124
|
current = current.parent;
|
|
13676
14125
|
}
|
|
13677
14126
|
return false;
|
|
@@ -13684,7 +14133,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13684
14133
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
13685
14134
|
return null;
|
|
13686
14135
|
}
|
|
13687
|
-
if (validationStatement.type !==
|
|
14136
|
+
if (validationStatement.type !== import_utils67.AST_NODE_TYPES.VariableDeclaration && validationStatement.type !== import_utils67.AST_NODE_TYPES.ExpressionStatement) {
|
|
13688
14137
|
return null;
|
|
13689
14138
|
}
|
|
13690
14139
|
const method = zodParseMethod(parse2);
|
|
@@ -13696,16 +14145,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
13696
14145
|
};
|
|
13697
14146
|
const isSafePrevalidationInspection = (identifier) => {
|
|
13698
14147
|
const parent = identifier.parent;
|
|
13699
|
-
if (parent.type ===
|
|
14148
|
+
if (parent.type === import_utils67.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof") {
|
|
13700
14149
|
return true;
|
|
13701
14150
|
}
|
|
13702
|
-
if (parent.type !==
|
|
14151
|
+
if (parent.type !== import_utils67.AST_NODE_TYPES.BinaryExpression || parent.left !== identifier) {
|
|
13703
14152
|
return false;
|
|
13704
14153
|
}
|
|
13705
14154
|
if (parent.operator === "instanceof") {
|
|
13706
|
-
return parent.right.type ===
|
|
14155
|
+
return parent.right.type === import_utils67.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
13707
14156
|
}
|
|
13708
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
14157
|
+
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type === import_utils67.AST_NODE_TYPES.Literal && parent.right.value === null || parent.right.type === import_utils67.AST_NODE_TYPES.Identifier && parent.right.name === "undefined");
|
|
13709
14158
|
};
|
|
13710
14159
|
const isDescendantOf = (node, ancestor) => {
|
|
13711
14160
|
let current = node;
|
|
@@ -13716,23 +14165,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
13716
14165
|
return false;
|
|
13717
14166
|
};
|
|
13718
14167
|
const blockTerminates = (node) => {
|
|
13719
|
-
if (node.type ===
|
|
14168
|
+
if (node.type === import_utils67.AST_NODE_TYPES.ReturnStatement || node.type === import_utils67.AST_NODE_TYPES.ThrowStatement) {
|
|
13720
14169
|
return true;
|
|
13721
14170
|
}
|
|
13722
|
-
if (node.type !==
|
|
14171
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.BlockStatement || node.body.length === 0) return false;
|
|
13723
14172
|
const last = node.body.at(-1);
|
|
13724
14173
|
return last !== void 0 && blockTerminates(last);
|
|
13725
14174
|
};
|
|
13726
14175
|
const narrowingIf = (identifier) => {
|
|
13727
14176
|
const comparison = identifier.parent;
|
|
13728
|
-
if (comparison?.type !==
|
|
14177
|
+
if (comparison?.type !== import_utils67.AST_NODE_TYPES.BinaryExpression || comparison.operator !== "instanceof" || comparison.left !== identifier || comparison.right.type !== import_utils67.AST_NODE_TYPES.Identifier || comparison.right.name !== "File" && comparison.right.name !== "Blob") {
|
|
13729
14178
|
return null;
|
|
13730
14179
|
}
|
|
13731
14180
|
const maybeNegation = comparison.parent;
|
|
13732
|
-
const negated = maybeNegation?.type ===
|
|
14181
|
+
const negated = maybeNegation?.type === import_utils67.AST_NODE_TYPES.UnaryExpression && maybeNegation.operator === "!";
|
|
13733
14182
|
const test = negated ? maybeNegation : comparison;
|
|
13734
14183
|
const branch = test.parent;
|
|
13735
|
-
return branch?.type ===
|
|
14184
|
+
return branch?.type === import_utils67.AST_NODE_TYPES.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
13736
14185
|
};
|
|
13737
14186
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
13738
14187
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -13752,7 +14201,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13752
14201
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
13753
14202
|
if (variable === void 0) return false;
|
|
13754
14203
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
13755
|
-
(identifier) => identifier.type ===
|
|
14204
|
+
(identifier) => identifier.type === import_utils67.AST_NODE_TYPES.Identifier
|
|
13756
14205
|
);
|
|
13757
14206
|
if (references.length === 0) return false;
|
|
13758
14207
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -13778,7 +14227,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13778
14227
|
ImportDeclaration(node) {
|
|
13779
14228
|
if (!isZodModule(node.source.value)) return;
|
|
13780
14229
|
for (const specifier of node.specifiers) {
|
|
13781
|
-
if (specifier.type ===
|
|
14230
|
+
if (specifier.type === import_utils67.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils67.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils67.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils67.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
13782
14231
|
const binding = resolvedBinding(specifier.local);
|
|
13783
14232
|
if (binding !== null) zodBindings.add(binding);
|
|
13784
14233
|
}
|
|
@@ -13799,7 +14248,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13799
14248
|
});
|
|
13800
14249
|
|
|
13801
14250
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
13802
|
-
var
|
|
14251
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
13803
14252
|
var storeInsertRequiresOnConflictDocumentation = {
|
|
13804
14253
|
summary: "Require embedded inserts in explicitly replayable callables to carry conflict handling.",
|
|
13805
14254
|
rationale: "A callable named as an enqueue, seed, migration, schedule, ensure, or upsert promises replay safety.",
|
|
@@ -13863,7 +14312,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
13863
14312
|
});
|
|
13864
14313
|
|
|
13865
14314
|
// src/rules/stepdown.ts
|
|
13866
|
-
var
|
|
14315
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
13867
14316
|
var stepdownDocumentation = {
|
|
13868
14317
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
13869
14318
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -13880,7 +14329,7 @@ var stepdownDocumentation = {
|
|
|
13880
14329
|
]
|
|
13881
14330
|
};
|
|
13882
14331
|
function isFunction(node) {
|
|
13883
|
-
return node.type ===
|
|
14332
|
+
return node.type === import_utils69.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils69.AST_NODE_TYPES.FunctionExpression;
|
|
13884
14333
|
}
|
|
13885
14334
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true) {
|
|
13886
14335
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -13975,8 +14424,8 @@ function moduleScope(context, program) {
|
|
|
13975
14424
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
13976
14425
|
const overloadNames = new Set(
|
|
13977
14426
|
program.body.flatMap((statement) => {
|
|
13978
|
-
const node = statement.type ===
|
|
13979
|
-
return node?.type ===
|
|
14427
|
+
const node = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14428
|
+
return node?.type === import_utils69.AST_NODE_TYPES.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
13980
14429
|
})
|
|
13981
14430
|
);
|
|
13982
14431
|
const exported = exportedNames(program);
|
|
@@ -14000,7 +14449,7 @@ function moduleScope(context, program) {
|
|
|
14000
14449
|
const nearestFunction = [...ancestors].reverse().find(isFunction);
|
|
14001
14450
|
const parent = identifier.parent;
|
|
14002
14451
|
const callerDefinition = nearestFunction === void 0 ? void 0 : byFunction.get(nearestFunction);
|
|
14003
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
14452
|
+
if (callerDefinition === void 0 || parent.type !== import_utils69.AST_NODE_TYPES.CallExpression || parent.callee !== identifier) {
|
|
14004
14453
|
pinned.add(definition.name);
|
|
14005
14454
|
continue;
|
|
14006
14455
|
}
|
|
@@ -14015,38 +14464,38 @@ function moduleScope(context, program) {
|
|
|
14015
14464
|
function exportedNames(program) {
|
|
14016
14465
|
const names = /* @__PURE__ */ new Set();
|
|
14017
14466
|
for (const statement of program.body) {
|
|
14018
|
-
if (statement.type !==
|
|
14019
|
-
if (statement.declaration?.type ===
|
|
14467
|
+
if (statement.type !== import_utils69.AST_NODE_TYPES.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
14468
|
+
if (statement.declaration?.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) {
|
|
14020
14469
|
names.add(statement.declaration.id.name);
|
|
14021
14470
|
}
|
|
14022
|
-
if (statement.declaration?.type ===
|
|
14471
|
+
if (statement.declaration?.type === import_utils69.AST_NODE_TYPES.VariableDeclaration) {
|
|
14023
14472
|
for (const declarator of statement.declaration.declarations) {
|
|
14024
|
-
if (declarator.id.type ===
|
|
14473
|
+
if (declarator.id.type === import_utils69.AST_NODE_TYPES.Identifier) names.add(declarator.id.name);
|
|
14025
14474
|
}
|
|
14026
14475
|
}
|
|
14027
14476
|
for (const specifier of statement.specifiers) {
|
|
14028
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
14477
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14029
14478
|
names.add(specifier.local.name);
|
|
14030
14479
|
}
|
|
14031
14480
|
}
|
|
14032
14481
|
}
|
|
14033
14482
|
for (const statement of program.body) {
|
|
14034
|
-
if (statement.type ===
|
|
14035
|
-
if (statement.type ===
|
|
14483
|
+
if (statement.type === import_utils69.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils69.AST_NODE_TYPES.Identifier) names.add(statement.declaration.name);
|
|
14484
|
+
if (statement.type === import_utils69.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) names.add(statement.declaration.id.name);
|
|
14036
14485
|
}
|
|
14037
14486
|
return names;
|
|
14038
14487
|
}
|
|
14039
14488
|
function moduleDefinitions(program) {
|
|
14040
14489
|
const definitions = [];
|
|
14041
14490
|
for (const statement of program.body) {
|
|
14042
|
-
const node = statement.type ===
|
|
14043
|
-
if (node?.type ===
|
|
14491
|
+
const node = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils69.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
14492
|
+
if (node?.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
14044
14493
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
14045
14494
|
continue;
|
|
14046
14495
|
}
|
|
14047
|
-
if (node?.type !==
|
|
14496
|
+
if (node?.type !== import_utils69.AST_NODE_TYPES.VariableDeclaration || node.kind !== "const") continue;
|
|
14048
14497
|
for (const declarator of node.declarations) {
|
|
14049
|
-
if (declarator.id.type ===
|
|
14498
|
+
if (declarator.id.type === import_utils69.AST_NODE_TYPES.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
14050
14499
|
definitions.push({
|
|
14051
14500
|
name: declarator.id.name,
|
|
14052
14501
|
node: declarator,
|
|
@@ -14059,21 +14508,21 @@ function moduleDefinitions(program) {
|
|
|
14059
14508
|
return definitions;
|
|
14060
14509
|
}
|
|
14061
14510
|
function methodName(node) {
|
|
14062
|
-
if (node.key.type ===
|
|
14063
|
-
return !node.computed && node.key.type ===
|
|
14511
|
+
if (node.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier) return `#${node.key.name}`;
|
|
14512
|
+
return !node.computed && node.key.type === import_utils69.AST_NODE_TYPES.Identifier ? node.key.name : null;
|
|
14064
14513
|
}
|
|
14065
14514
|
function referencedMethod(context, node, classVariables) {
|
|
14066
|
-
const objectVariable = node.object.type ===
|
|
14515
|
+
const objectVariable = node.object.type === import_utils69.AST_NODE_TYPES.Identifier ? import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(node.object), node.object.name) : null;
|
|
14067
14516
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
14068
|
-
if (node.object.type !==
|
|
14069
|
-
if (node.property.type ===
|
|
14070
|
-
if (!node.computed && node.property.type ===
|
|
14071
|
-
return node.computed && node.property.type ===
|
|
14517
|
+
if (node.object.type !== import_utils69.AST_NODE_TYPES.ThisExpression && !isClassReference) return null;
|
|
14518
|
+
if (node.property.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
14519
|
+
if (!node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
14520
|
+
return node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
14072
14521
|
}
|
|
14073
14522
|
function referencedPropertyName(node) {
|
|
14074
|
-
if (node.property.type ===
|
|
14075
|
-
if (!node.computed && node.property.type ===
|
|
14076
|
-
return node.computed && node.property.type ===
|
|
14523
|
+
if (node.property.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
14524
|
+
if (!node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
14525
|
+
return node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
14077
14526
|
}
|
|
14078
14527
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
14079
14528
|
visit(node, nestedFunction);
|
|
@@ -14089,7 +14538,7 @@ function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
14089
14538
|
}
|
|
14090
14539
|
function classScope(context, node, computedReferenceNames) {
|
|
14091
14540
|
const methods = node.body.body.filter(
|
|
14092
|
-
(member) => member.type ===
|
|
14541
|
+
(member) => member.type === import_utils69.AST_NODE_TYPES.MethodDefinition
|
|
14093
14542
|
);
|
|
14094
14543
|
const counts = /* @__PURE__ */ new Map();
|
|
14095
14544
|
for (const method of methods) {
|
|
@@ -14097,8 +14546,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14097
14546
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
14098
14547
|
}
|
|
14099
14548
|
for (const member of node.body.body) {
|
|
14100
|
-
if (member.type !==
|
|
14101
|
-
const name = !member.computed && member.key.type ===
|
|
14549
|
+
if (member.type !== import_utils69.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
14550
|
+
const name = !member.computed && member.key.type === import_utils69.AST_NODE_TYPES.Identifier ? member.key.name : null;
|
|
14102
14551
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
14103
14552
|
}
|
|
14104
14553
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -14107,7 +14556,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14107
14556
|
});
|
|
14108
14557
|
const definitions = methods.flatMap((method) => {
|
|
14109
14558
|
const name = methodName(method);
|
|
14110
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
14559
|
+
const isPrivate = method.accessibility === "private" || method.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier;
|
|
14111
14560
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
14112
14561
|
});
|
|
14113
14562
|
if (definitions.length === 0) return;
|
|
@@ -14116,11 +14565,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14116
14565
|
const pinned = /* @__PURE__ */ new Set();
|
|
14117
14566
|
const classVariables = /* @__PURE__ */ new Set();
|
|
14118
14567
|
if (node.id !== null) {
|
|
14119
|
-
const internal =
|
|
14568
|
+
const internal = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
14120
14569
|
if (internal !== null) classVariables.add(internal);
|
|
14121
14570
|
}
|
|
14122
|
-
if (node.type ===
|
|
14123
|
-
const outer =
|
|
14571
|
+
if (node.type === import_utils69.AST_NODE_TYPES.ClassExpression && node.parent.type === import_utils69.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14572
|
+
const outer = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
14124
14573
|
if (outer !== null) classVariables.add(outer);
|
|
14125
14574
|
}
|
|
14126
14575
|
for (const method of methods) {
|
|
@@ -14136,27 +14585,27 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14136
14585
|
}
|
|
14137
14586
|
const thisValue = (value) => {
|
|
14138
14587
|
let current = value;
|
|
14139
|
-
while (current?.type ===
|
|
14140
|
-
return current?.type ===
|
|
14588
|
+
while (current?.type === import_utils69.AST_NODE_TYPES.TSAsExpression || current?.type === import_utils69.AST_NODE_TYPES.TSSatisfiesExpression || current?.type === import_utils69.AST_NODE_TYPES.TSNonNullExpression) current = current.expression;
|
|
14589
|
+
return current?.type === import_utils69.AST_NODE_TYPES.ThisExpression;
|
|
14141
14590
|
};
|
|
14142
14591
|
const collectAlias = (current, nestedFunction) => {
|
|
14143
|
-
if (nestedFunction || current.type !==
|
|
14144
|
-
if (current.type ===
|
|
14145
|
-
const binding = current.type ===
|
|
14146
|
-
const value = current.type ===
|
|
14592
|
+
if (nestedFunction || current.type !== import_utils69.AST_NODE_TYPES.VariableDeclarator && current.type !== import_utils69.AST_NODE_TYPES.AssignmentPattern) return;
|
|
14593
|
+
if (current.type === import_utils69.AST_NODE_TYPES.VariableDeclarator && (current.parent.type !== import_utils69.AST_NODE_TYPES.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
14594
|
+
const binding = current.type === import_utils69.AST_NODE_TYPES.VariableDeclarator ? current.id : current.left;
|
|
14595
|
+
const value = current.type === import_utils69.AST_NODE_TYPES.VariableDeclarator ? current.init : current.right;
|
|
14147
14596
|
if (!thisValue(value)) return;
|
|
14148
|
-
if (binding.type ===
|
|
14597
|
+
if (binding.type === import_utils69.AST_NODE_TYPES.ObjectPattern) {
|
|
14149
14598
|
for (const property of binding.properties) {
|
|
14150
|
-
if (property.type ===
|
|
14599
|
+
if (property.type === import_utils69.AST_NODE_TYPES.RestElement) {
|
|
14151
14600
|
for (const name of privateNames) pinned.add(name);
|
|
14152
|
-
} else if (property.key.type ===
|
|
14601
|
+
} else if (property.key.type === import_utils69.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) {
|
|
14153
14602
|
pinned.add(property.key.name);
|
|
14154
14603
|
}
|
|
14155
14604
|
}
|
|
14156
14605
|
return;
|
|
14157
14606
|
}
|
|
14158
|
-
if (binding.type !==
|
|
14159
|
-
const variable =
|
|
14607
|
+
if (binding.type !== import_utils69.AST_NODE_TYPES.Identifier) return;
|
|
14608
|
+
const variable = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
14160
14609
|
if (variable !== null) {
|
|
14161
14610
|
methodClassVariables.add(variable);
|
|
14162
14611
|
methodAliases.add(variable);
|
|
@@ -14169,16 +14618,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14169
14618
|
walk(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
14170
14619
|
}
|
|
14171
14620
|
const visitCall = (current, nestedFunction) => {
|
|
14172
|
-
if (current.type ===
|
|
14621
|
+
if (current.type === import_utils69.AST_NODE_TYPES.VariableDeclarator && current.id.type === import_utils69.AST_NODE_TYPES.ObjectPattern && thisValue(current.init)) {
|
|
14173
14622
|
for (const property of current.id.properties) {
|
|
14174
|
-
if (property.type ===
|
|
14623
|
+
if (property.type === import_utils69.AST_NODE_TYPES.RestElement) {
|
|
14175
14624
|
for (const name of privateNames) pinned.add(name);
|
|
14176
14625
|
continue;
|
|
14177
14626
|
}
|
|
14178
|
-
if (property.type ===
|
|
14627
|
+
if (property.type === import_utils69.AST_NODE_TYPES.Property && property.key.type === import_utils69.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) pinned.add(property.key.name);
|
|
14179
14628
|
}
|
|
14180
14629
|
}
|
|
14181
|
-
if (current.type !==
|
|
14630
|
+
if (current.type !== import_utils69.AST_NODE_TYPES.MemberExpression) return;
|
|
14182
14631
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
14183
14632
|
if (target === null) {
|
|
14184
14633
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -14186,12 +14635,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14186
14635
|
return;
|
|
14187
14636
|
}
|
|
14188
14637
|
if (!privateNames.has(target)) return;
|
|
14189
|
-
const objectVariable = current.object.type ===
|
|
14638
|
+
const objectVariable = current.object.type === import_utils69.AST_NODE_TYPES.Identifier ? import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(current.object), current.object.name) : null;
|
|
14190
14639
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
14191
14640
|
pinned.add(target);
|
|
14192
14641
|
return;
|
|
14193
14642
|
}
|
|
14194
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
14643
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== import_utils69.AST_NODE_TYPES.CallExpression || current.parent.callee !== current) {
|
|
14195
14644
|
pinned.add(target);
|
|
14196
14645
|
return;
|
|
14197
14646
|
}
|
|
@@ -14211,9 +14660,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14211
14660
|
}
|
|
14212
14661
|
}
|
|
14213
14662
|
for (const member of node.body.body) {
|
|
14214
|
-
if (member.type ===
|
|
14663
|
+
if (member.type === import_utils69.AST_NODE_TYPES.MethodDefinition || member.type === import_utils69.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
14215
14664
|
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
14216
|
-
if (current.type !==
|
|
14665
|
+
if (current.type !== import_utils69.AST_NODE_TYPES.MemberExpression) return;
|
|
14217
14666
|
const target = referencedMethod(context, current, classVariables);
|
|
14218
14667
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
14219
14668
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -14223,14 +14672,14 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14223
14672
|
const accessibility = new Map(
|
|
14224
14673
|
scopeDefinitions.map((definition) => {
|
|
14225
14674
|
const method = definition.node;
|
|
14226
|
-
const accessibility2 = method.key.type ===
|
|
14675
|
+
const accessibility2 = method.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier ? "private" : method.accessibility ?? "public";
|
|
14227
14676
|
return [definition.name, accessibility2];
|
|
14228
14677
|
})
|
|
14229
14678
|
);
|
|
14230
14679
|
const methodByName = new Map(scopeDefinitions.map((definition) => [definition.name, definition.node]));
|
|
14231
14680
|
for (const [caller, callees] of calls) {
|
|
14232
14681
|
const callerMethod = methodByName.get(caller);
|
|
14233
|
-
if (accessibility.get(caller) === "private" && callerMethod?.type ===
|
|
14682
|
+
if (accessibility.get(caller) === "private" && callerMethod?.type === import_utils69.AST_NODE_TYPES.MethodDefinition && callerMethod.decorators.length === 0) continue;
|
|
14234
14683
|
for (const callee of callees) pinned.add(callee);
|
|
14235
14684
|
}
|
|
14236
14685
|
const memberIndexes = new Map(node.body.body.map((member, index) => [member, index]));
|
|
@@ -14247,12 +14696,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14247
14696
|
}
|
|
14248
14697
|
function isClassRuntimeBarrier(member) {
|
|
14249
14698
|
switch (member.type) {
|
|
14250
|
-
case
|
|
14699
|
+
case import_utils69.AST_NODE_TYPES.StaticBlock:
|
|
14251
14700
|
return true;
|
|
14252
|
-
case
|
|
14253
|
-
case
|
|
14701
|
+
case import_utils69.AST_NODE_TYPES.PropertyDefinition:
|
|
14702
|
+
case import_utils69.AST_NODE_TYPES.AccessorProperty:
|
|
14254
14703
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
14255
|
-
case
|
|
14704
|
+
case import_utils69.AST_NODE_TYPES.MethodDefinition:
|
|
14256
14705
|
return member.computed || member.decorators.length > 0;
|
|
14257
14706
|
default:
|
|
14258
14707
|
return false;
|
|
@@ -14284,7 +14733,7 @@ var stepdown_default = createRule({
|
|
|
14284
14733
|
moduleScope(context, program);
|
|
14285
14734
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
14286
14735
|
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
14287
|
-
if (node.type ===
|
|
14736
|
+
if (node.type === import_utils69.AST_NODE_TYPES.MemberExpression && node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Literal && typeof node.property.value === "string") computedReferenceNames.add(node.property.value);
|
|
14288
14737
|
});
|
|
14289
14738
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
14290
14739
|
}
|
|
@@ -14293,7 +14742,7 @@ var stepdown_default = createRule({
|
|
|
14293
14742
|
});
|
|
14294
14743
|
|
|
14295
14744
|
// src/rules/zod-naming-convention.ts
|
|
14296
|
-
var
|
|
14745
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
14297
14746
|
var zodNamingConventionDocumentation = {
|
|
14298
14747
|
summary: "Enforce a consistent Zod schema naming convention \u2014 a `Z` prefix (`ZUser`) or a `Schema` suffix (`userSchema`); both are accepted by default.",
|
|
14299
14748
|
rationale: "A recognizable schema name distinguishes runtime validators from ordinary values at each use site.",
|
|
@@ -14334,18 +14783,18 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
14334
14783
|
"prettifyError",
|
|
14335
14784
|
"treeifyError"
|
|
14336
14785
|
]);
|
|
14337
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
14786
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils70.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
14338
14787
|
var calleeChainRoot = (node) => {
|
|
14339
14788
|
let current = node;
|
|
14340
14789
|
for (; ; ) {
|
|
14341
|
-
if (current.type ===
|
|
14790
|
+
if (current.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
14342
14791
|
return current;
|
|
14343
14792
|
}
|
|
14344
|
-
if (current.type ===
|
|
14793
|
+
if (current.type === import_utils70.AST_NODE_TYPES.MemberExpression) {
|
|
14345
14794
|
current = current.object;
|
|
14346
14795
|
continue;
|
|
14347
14796
|
}
|
|
14348
|
-
if (current.type ===
|
|
14797
|
+
if (current.type === import_utils70.AST_NODE_TYPES.CallExpression) {
|
|
14349
14798
|
current = current.callee;
|
|
14350
14799
|
continue;
|
|
14351
14800
|
}
|
|
@@ -14385,7 +14834,7 @@ var zod_naming_convention_default = createRule({
|
|
|
14385
14834
|
const acceptsSchemaWord = convention !== "prefix";
|
|
14386
14835
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
14387
14836
|
function resolvedBinding(identifier) {
|
|
14388
|
-
return
|
|
14837
|
+
return import_utils70.ASTUtils.findVariable(
|
|
14389
14838
|
context.sourceCode.getScope(identifier),
|
|
14390
14839
|
identifier.name
|
|
14391
14840
|
);
|
|
@@ -14407,7 +14856,7 @@ var zod_naming_convention_default = createRule({
|
|
|
14407
14856
|
ImportDeclaration(node) {
|
|
14408
14857
|
if (!isZodModule(node.source.value)) return;
|
|
14409
14858
|
for (const specifier of node.specifiers) {
|
|
14410
|
-
if (specifier.type ===
|
|
14859
|
+
if (specifier.type === import_utils70.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils70.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils70.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils70.AST_NODE_TYPES.Identifier ? specifier.imported.name === "z" : specifier.imported.value === "z")) {
|
|
14411
14860
|
recordZodBinding(specifier.local);
|
|
14412
14861
|
}
|
|
14413
14862
|
}
|
|
@@ -14415,13 +14864,13 @@ var zod_naming_convention_default = createRule({
|
|
|
14415
14864
|
VariableDeclarator(node) {
|
|
14416
14865
|
const init = node.init;
|
|
14417
14866
|
if (init === null || init === void 0) return;
|
|
14418
|
-
if (init.type !==
|
|
14867
|
+
if (init.type !== import_utils70.AST_NODE_TYPES.CallExpression) return;
|
|
14419
14868
|
const callee = init.callee;
|
|
14420
|
-
if (callee.type !==
|
|
14869
|
+
if (callee.type !== import_utils70.AST_NODE_TYPES.MemberExpression) return;
|
|
14421
14870
|
if (!isZodChain(callee)) return;
|
|
14422
14871
|
const terminal = terminalMethodName(callee);
|
|
14423
14872
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
14424
|
-
if (node.id.type !==
|
|
14873
|
+
if (node.id.type !== import_utils70.AST_NODE_TYPES.Identifier) return;
|
|
14425
14874
|
if (test.test(node.id.name)) return;
|
|
14426
14875
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
14427
14876
|
context.report({
|
|
@@ -14565,6 +15014,7 @@ var rules = {
|
|
|
14565
15014
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
14566
15015
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
14567
15016
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
15017
|
+
"prefer-await-in-async-return": prefer_await_in_async_return_default,
|
|
14568
15018
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
14569
15019
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
14570
15020
|
"prefer-server-actions": prefer_server_actions_default,
|
|
@@ -14581,7 +15031,7 @@ var rules = {
|
|
|
14581
15031
|
};
|
|
14582
15032
|
var meta = {
|
|
14583
15033
|
name: "@sarj/eslint-plugin",
|
|
14584
|
-
version: "15.6.
|
|
15034
|
+
version: "15.6.3"
|
|
14585
15035
|
};
|
|
14586
15036
|
var applicationOnlyRules = [
|
|
14587
15037
|
"no-restricted-library-load",
|
|
@@ -14632,6 +15082,7 @@ var recommendedRules = {
|
|
|
14632
15082
|
"@sarj/prefer-module-level-constant": "error",
|
|
14633
15083
|
"@sarj/prefer-module-level-schema": "error",
|
|
14634
15084
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
15085
|
+
"@sarj/prefer-await-in-async-return": "error",
|
|
14635
15086
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
14636
15087
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
14637
15088
|
"@sarj/prefer-server-actions": "error",
|
|
@@ -14694,6 +15145,7 @@ var strictRules = {
|
|
|
14694
15145
|
"@sarj/prefer-module-level-constant": "error",
|
|
14695
15146
|
"@sarj/prefer-module-level-schema": "error",
|
|
14696
15147
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
15148
|
+
"@sarj/prefer-await-in-async-return": "error",
|
|
14697
15149
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
14698
15150
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
14699
15151
|
"@sarj/prefer-server-actions": "error",
|