@sarj/eslint-plugin 15.6.2 → 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 +569 -422
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +567 -417
- 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
|
}
|
|
@@ -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.",
|
|
@@ -12283,47 +12427,47 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
12283
12427
|
"Schema"
|
|
12284
12428
|
]);
|
|
12285
12429
|
var LEAF_NODE_TYPES = {
|
|
12286
|
-
string: [
|
|
12287
|
-
email: [
|
|
12288
|
-
url: [
|
|
12289
|
-
uuid: [
|
|
12290
|
-
ulid: [
|
|
12291
|
-
cuid: [
|
|
12292
|
-
cuid2: [
|
|
12293
|
-
nanoid: [
|
|
12294
|
-
iso: [
|
|
12295
|
-
number: [
|
|
12296
|
-
int: [
|
|
12297
|
-
float32: [
|
|
12298
|
-
float64: [
|
|
12299
|
-
boolean: [
|
|
12300
|
-
bigint: [
|
|
12301
|
-
symbol: [
|
|
12302
|
-
any: [
|
|
12303
|
-
unknown: [
|
|
12304
|
-
never: [
|
|
12305
|
-
void: [
|
|
12306
|
-
null: [
|
|
12307
|
-
undefined: [
|
|
12308
|
-
literal: [
|
|
12309
|
-
date: [
|
|
12310
|
-
array: [
|
|
12311
|
-
tuple: [
|
|
12312
|
-
object: [
|
|
12313
|
-
strictObject: [
|
|
12314
|
-
looseObject: [
|
|
12315
|
-
record: [
|
|
12316
|
-
map: [
|
|
12317
|
-
set: [
|
|
12318
|
-
promise: [
|
|
12319
|
-
enum: [
|
|
12320
|
-
nativeEnum: [
|
|
12321
|
-
union: [
|
|
12322
|
-
discriminatedUnion: [
|
|
12323
|
-
intersection: [
|
|
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]
|
|
12324
12468
|
};
|
|
12325
12469
|
function primitiveLiteralKey(node) {
|
|
12326
|
-
if (node.type !==
|
|
12470
|
+
if (node.type !== import_utils62.AST_NODE_TYPES.Literal) {
|
|
12327
12471
|
return null;
|
|
12328
12472
|
}
|
|
12329
12473
|
if (node.value === null) {
|
|
@@ -12355,13 +12499,13 @@ function staticZodDomain(leaf, call) {
|
|
|
12355
12499
|
}
|
|
12356
12500
|
if (leaf === "literal") {
|
|
12357
12501
|
const [argument] = call.arguments;
|
|
12358
|
-
if (argument === void 0 || argument.type ===
|
|
12502
|
+
if (argument === void 0 || argument.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12359
12503
|
return null;
|
|
12360
12504
|
}
|
|
12361
|
-
if (argument.type ===
|
|
12505
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ArrayExpression) {
|
|
12362
12506
|
return exactDomain(
|
|
12363
12507
|
argument.elements.map(
|
|
12364
|
-
(element) => element === null || element.type ===
|
|
12508
|
+
(element) => element === null || element.type === import_utils62.AST_NODE_TYPES.SpreadElement ? null : primitiveLiteralKey(element)
|
|
12365
12509
|
)
|
|
12366
12510
|
);
|
|
12367
12511
|
}
|
|
@@ -12369,13 +12513,13 @@ function staticZodDomain(leaf, call) {
|
|
|
12369
12513
|
}
|
|
12370
12514
|
if (leaf === "enum") {
|
|
12371
12515
|
const [argument] = call.arguments;
|
|
12372
|
-
if (argument === void 0 || argument.type ===
|
|
12516
|
+
if (argument === void 0 || argument.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12373
12517
|
return null;
|
|
12374
12518
|
}
|
|
12375
|
-
if (argument.type ===
|
|
12519
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ArrayExpression) {
|
|
12376
12520
|
return exactDomain(
|
|
12377
12521
|
argument.elements.map((element) => {
|
|
12378
|
-
if (element === null || element.type ===
|
|
12522
|
+
if (element === null || element.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12379
12523
|
return null;
|
|
12380
12524
|
}
|
|
12381
12525
|
const key = primitiveLiteralKey(element);
|
|
@@ -12383,10 +12527,10 @@ function staticZodDomain(leaf, call) {
|
|
|
12383
12527
|
})
|
|
12384
12528
|
);
|
|
12385
12529
|
}
|
|
12386
|
-
if (argument.type ===
|
|
12530
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
12387
12531
|
return exactDomain(
|
|
12388
12532
|
argument.properties.map((property) => {
|
|
12389
|
-
if (property.type !==
|
|
12533
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
12390
12534
|
return null;
|
|
12391
12535
|
}
|
|
12392
12536
|
const key = primitiveLiteralKey(property.value);
|
|
@@ -12413,15 +12557,15 @@ function sameDomain(left, right) {
|
|
|
12413
12557
|
return true;
|
|
12414
12558
|
}
|
|
12415
12559
|
function isExportedDeclaration(node) {
|
|
12416
|
-
return node.parent?.type ===
|
|
12560
|
+
return node.parent?.type === import_utils62.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
12417
12561
|
}
|
|
12418
12562
|
function isModuleLevelConst(node) {
|
|
12419
12563
|
const declaration = node.parent;
|
|
12420
|
-
if (declaration.type !==
|
|
12564
|
+
if (declaration.type !== import_utils62.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const") {
|
|
12421
12565
|
return false;
|
|
12422
12566
|
}
|
|
12423
12567
|
const container = declaration.parent;
|
|
12424
|
-
return container.type ===
|
|
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;
|
|
12425
12569
|
}
|
|
12426
12570
|
function normalizeSchemaName(name) {
|
|
12427
12571
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -12430,20 +12574,20 @@ function normalizeTypeName(name) {
|
|
|
12430
12574
|
return name.replace(/Type$/, "").toLowerCase();
|
|
12431
12575
|
}
|
|
12432
12576
|
function unwrapNullish(annotation) {
|
|
12433
|
-
if (annotation.type !==
|
|
12577
|
+
if (annotation.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12434
12578
|
return {
|
|
12435
12579
|
core: annotation,
|
|
12436
|
-
nullable: annotation.type ===
|
|
12580
|
+
nullable: annotation.type === import_utils62.AST_NODE_TYPES.TSNullKeyword
|
|
12437
12581
|
};
|
|
12438
12582
|
}
|
|
12439
12583
|
const rest = [];
|
|
12440
12584
|
let nullable = false;
|
|
12441
12585
|
for (const member of annotation.types) {
|
|
12442
|
-
if (member.type ===
|
|
12586
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSNullKeyword) {
|
|
12443
12587
|
nullable = true;
|
|
12444
12588
|
continue;
|
|
12445
12589
|
}
|
|
12446
|
-
if (member.type ===
|
|
12590
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
12447
12591
|
continue;
|
|
12448
12592
|
}
|
|
12449
12593
|
rest.push(member);
|
|
@@ -12477,18 +12621,18 @@ function leafAgrees(field, annotation) {
|
|
|
12477
12621
|
return null;
|
|
12478
12622
|
}
|
|
12479
12623
|
if (leaf === "date") {
|
|
12480
|
-
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";
|
|
12481
12625
|
}
|
|
12482
12626
|
return expected.includes(core.type);
|
|
12483
12627
|
}
|
|
12484
12628
|
function typeLiteralDomain(annotation) {
|
|
12485
|
-
const members = annotation.type ===
|
|
12629
|
+
const members = annotation.type === import_utils62.AST_NODE_TYPES.TSUnionType ? annotation.types : [annotation];
|
|
12486
12630
|
const keys = [];
|
|
12487
12631
|
for (const member of members) {
|
|
12488
|
-
if (member.type ===
|
|
12632
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSNullKeyword) {
|
|
12489
12633
|
continue;
|
|
12490
12634
|
}
|
|
12491
|
-
if (member.type !==
|
|
12635
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSLiteralType) {
|
|
12492
12636
|
return null;
|
|
12493
12637
|
}
|
|
12494
12638
|
keys.push(primitiveLiteralKey(member.literal));
|
|
@@ -12496,11 +12640,11 @@ function typeLiteralDomain(annotation) {
|
|
|
12496
12640
|
return exactDomain(keys);
|
|
12497
12641
|
}
|
|
12498
12642
|
function staticStringUnionDomain(node) {
|
|
12499
|
-
if (node.type !==
|
|
12643
|
+
if (node.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12500
12644
|
return null;
|
|
12501
12645
|
}
|
|
12502
12646
|
const keys = node.types.map((member) => {
|
|
12503
|
-
if (member.type !==
|
|
12647
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSLiteralType) {
|
|
12504
12648
|
return null;
|
|
12505
12649
|
}
|
|
12506
12650
|
const key = primitiveLiteralKey(member.literal);
|
|
@@ -12568,14 +12712,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
12568
12712
|
function zodCallChain(node) {
|
|
12569
12713
|
const chain = [];
|
|
12570
12714
|
let current = node;
|
|
12571
|
-
while (current.type ===
|
|
12715
|
+
while (current.type === import_utils62.AST_NODE_TYPES.CallExpression) {
|
|
12572
12716
|
const callee = current.callee;
|
|
12573
|
-
if (callee.type !==
|
|
12717
|
+
if (callee.type !== import_utils62.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12574
12718
|
return null;
|
|
12575
12719
|
}
|
|
12576
12720
|
chain.push(current);
|
|
12577
12721
|
const receiver = callee.object;
|
|
12578
|
-
if (receiver.type ===
|
|
12722
|
+
if (receiver.type === import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12579
12723
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
12580
12724
|
}
|
|
12581
12725
|
current = receiver;
|
|
@@ -12584,14 +12728,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
12584
12728
|
}
|
|
12585
12729
|
function methodName2(call) {
|
|
12586
12730
|
const callee = call.callee;
|
|
12587
|
-
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 : "";
|
|
12588
12732
|
}
|
|
12589
12733
|
function recordZodImport(node) {
|
|
12590
12734
|
if (!isZodModule(node.source.value)) {
|
|
12591
12735
|
return;
|
|
12592
12736
|
}
|
|
12593
12737
|
for (const specifier of node.specifiers) {
|
|
12594
|
-
if (specifier.type ===
|
|
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") {
|
|
12595
12739
|
zodNamespaces.add(specifier.local.name);
|
|
12596
12740
|
}
|
|
12597
12741
|
}
|
|
@@ -12601,13 +12745,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
12601
12745
|
let current = node;
|
|
12602
12746
|
let leaf = null;
|
|
12603
12747
|
let leafCall = null;
|
|
12604
|
-
while (current.type ===
|
|
12748
|
+
while (current.type === import_utils62.AST_NODE_TYPES.CallExpression) {
|
|
12605
12749
|
const callee = current.callee;
|
|
12606
|
-
if (callee.type !==
|
|
12750
|
+
if (callee.type !== import_utils62.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12607
12751
|
break;
|
|
12608
12752
|
}
|
|
12609
12753
|
const receiver = callee.object;
|
|
12610
|
-
if (receiver.type ===
|
|
12754
|
+
if (receiver.type === import_utils62.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
12611
12755
|
leaf = callee.property.name;
|
|
12612
12756
|
leafCall = current;
|
|
12613
12757
|
break;
|
|
@@ -12638,20 +12782,20 @@ var prefer_zod_infer_default = createRule({
|
|
|
12638
12782
|
return domain instanceof Set && domain.size >= 2 ? domain : null;
|
|
12639
12783
|
}
|
|
12640
12784
|
function inferredSchemaName(node) {
|
|
12641
|
-
if (node.type !==
|
|
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") {
|
|
12642
12786
|
return null;
|
|
12643
12787
|
}
|
|
12644
12788
|
const arguments_ = node.typeArguments?.params ?? [];
|
|
12645
12789
|
const [argument] = arguments_;
|
|
12646
|
-
return arguments_.length === 1 && argument?.type ===
|
|
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;
|
|
12647
12791
|
}
|
|
12648
12792
|
function recordLiteralUnions(members, owner, ownerName, exported) {
|
|
12649
12793
|
for (const member of members) {
|
|
12650
|
-
if (member.type !==
|
|
12794
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSPropertySignature || member.computed || member.optional || member.readonly || member.typeAnnotation === void 0) {
|
|
12651
12795
|
continue;
|
|
12652
12796
|
}
|
|
12653
12797
|
const key = member.key;
|
|
12654
|
-
const propertyName3 = key.type ===
|
|
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;
|
|
12655
12799
|
if (propertyName3 === null) {
|
|
12656
12800
|
continue;
|
|
12657
12801
|
}
|
|
@@ -12661,7 +12805,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12661
12805
|
}
|
|
12662
12806
|
const annotation = member.typeAnnotation.typeAnnotation;
|
|
12663
12807
|
const domain = staticStringUnionDomain(annotation);
|
|
12664
|
-
if (domain === null || annotation.type !==
|
|
12808
|
+
if (domain === null || annotation.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12665
12809
|
continue;
|
|
12666
12810
|
}
|
|
12667
12811
|
literalUnionOccurrences.push({
|
|
@@ -12692,16 +12836,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
12692
12836
|
return null;
|
|
12693
12837
|
}
|
|
12694
12838
|
const shape = base.arguments[0];
|
|
12695
|
-
if (shape === void 0 || shape.type !==
|
|
12839
|
+
if (shape === void 0 || shape.type !== import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
12696
12840
|
return null;
|
|
12697
12841
|
}
|
|
12698
12842
|
const fields = /* @__PURE__ */ new Map();
|
|
12699
12843
|
for (const property of shape.properties) {
|
|
12700
|
-
if (property.type !==
|
|
12844
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || property.computed) {
|
|
12701
12845
|
return null;
|
|
12702
12846
|
}
|
|
12703
12847
|
const { key } = property;
|
|
12704
|
-
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;
|
|
12705
12849
|
if (name === null) {
|
|
12706
12850
|
return null;
|
|
12707
12851
|
}
|
|
@@ -12712,11 +12856,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
12712
12856
|
function typeMembers(members) {
|
|
12713
12857
|
const result = /* @__PURE__ */ new Map();
|
|
12714
12858
|
for (const member of members) {
|
|
12715
|
-
if (member.type !==
|
|
12859
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
12716
12860
|
return null;
|
|
12717
12861
|
}
|
|
12718
12862
|
const { key } = member;
|
|
12719
|
-
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;
|
|
12720
12864
|
if (name === null) {
|
|
12721
12865
|
return null;
|
|
12722
12866
|
}
|
|
@@ -12731,8 +12875,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
12731
12875
|
return result.size === 0 ? null : result;
|
|
12732
12876
|
}
|
|
12733
12877
|
function collectConstrainedNames(node) {
|
|
12734
|
-
if (node.type ===
|
|
12735
|
-
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) {
|
|
12736
12880
|
constrainedTypeNames.add(node.typeName.name);
|
|
12737
12881
|
}
|
|
12738
12882
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -12740,11 +12884,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
12740
12884
|
}
|
|
12741
12885
|
return;
|
|
12742
12886
|
}
|
|
12743
|
-
if (node.type ===
|
|
12887
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSArrayType) {
|
|
12744
12888
|
collectConstrainedNames(node.elementType);
|
|
12745
12889
|
return;
|
|
12746
12890
|
}
|
|
12747
|
-
if (node.type ===
|
|
12891
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSUnionType || node.type === import_utils62.AST_NODE_TYPES.TSIntersectionType) {
|
|
12748
12892
|
for (const member of node.types) {
|
|
12749
12893
|
collectConstrainedNames(member);
|
|
12750
12894
|
}
|
|
@@ -12788,7 +12932,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12788
12932
|
return {
|
|
12789
12933
|
Program(node) {
|
|
12790
12934
|
for (const statement of node.body) {
|
|
12791
|
-
if (statement.type ===
|
|
12935
|
+
if (statement.type === import_utils62.AST_NODE_TYPES.ImportDeclaration) {
|
|
12792
12936
|
recordZodImport(statement);
|
|
12793
12937
|
}
|
|
12794
12938
|
}
|
|
@@ -12797,7 +12941,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12797
12941
|
recordZodImport(node);
|
|
12798
12942
|
},
|
|
12799
12943
|
VariableDeclarator(node) {
|
|
12800
|
-
if (node.id.type !==
|
|
12944
|
+
if (node.id.type !== import_utils62.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
12801
12945
|
return;
|
|
12802
12946
|
}
|
|
12803
12947
|
const fields = schemaFields(node.init);
|
|
@@ -12814,14 +12958,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
12814
12958
|
},
|
|
12815
12959
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
12816
12960
|
"MemberExpression[computed=false]"(node) {
|
|
12817
|
-
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)) {
|
|
12818
12962
|
reshapedSchemaNames.add(node.object.name);
|
|
12819
12963
|
}
|
|
12820
12964
|
},
|
|
12821
12965
|
/** Records every type argument carried by a Zod constraint. */
|
|
12822
12966
|
TSTypeReference(node) {
|
|
12823
12967
|
const { typeName } = node;
|
|
12824
|
-
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;
|
|
12825
12969
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
12826
12970
|
return;
|
|
12827
12971
|
}
|
|
@@ -12853,7 +12997,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12853
12997
|
typeName: node.id.name
|
|
12854
12998
|
});
|
|
12855
12999
|
}
|
|
12856
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
13000
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
12857
13001
|
return;
|
|
12858
13002
|
}
|
|
12859
13003
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -12952,7 +13096,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12952
13096
|
});
|
|
12953
13097
|
|
|
12954
13098
|
// src/rules/require-assert-never.ts
|
|
12955
|
-
var
|
|
13099
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
12956
13100
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
12957
13101
|
var requireAssertNeverDocumentation = {
|
|
12958
13102
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
@@ -12965,14 +13109,14 @@ var requireAssertNeverDocumentation = {
|
|
|
12965
13109
|
]
|
|
12966
13110
|
};
|
|
12967
13111
|
var isRuntimeHandlingStatement = (statement) => {
|
|
12968
|
-
if (statement.type ===
|
|
12969
|
-
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) {
|
|
12970
13114
|
return statement.label !== null;
|
|
12971
13115
|
}
|
|
12972
|
-
if (statement.type ===
|
|
13116
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.TSTypeAliasDeclaration || statement.type === import_utils63.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
12973
13117
|
return false;
|
|
12974
13118
|
}
|
|
12975
|
-
if (statement.type ===
|
|
13119
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.BlockStatement) {
|
|
12976
13120
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
12977
13121
|
}
|
|
12978
13122
|
return true;
|
|
@@ -12988,7 +13132,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
12988
13132
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
12989
13133
|
}
|
|
12990
13134
|
const only = defaultCase.consequent[0];
|
|
12991
|
-
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)) {
|
|
12992
13136
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
12993
13137
|
}
|
|
12994
13138
|
return false;
|
|
@@ -13044,7 +13188,7 @@ var require_assert_never_default = createRule({
|
|
|
13044
13188
|
create(context) {
|
|
13045
13189
|
let services;
|
|
13046
13190
|
try {
|
|
13047
|
-
services =
|
|
13191
|
+
services = import_utils63.ESLintUtils.getParserServices(context);
|
|
13048
13192
|
} catch {
|
|
13049
13193
|
services = null;
|
|
13050
13194
|
}
|
|
@@ -13071,7 +13215,7 @@ var require_assert_never_default = createRule({
|
|
|
13071
13215
|
});
|
|
13072
13216
|
|
|
13073
13217
|
// src/rules/require-fetch-timeout.ts
|
|
13074
|
-
var
|
|
13218
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
13075
13219
|
var requireFetchTimeoutDocumentation = {
|
|
13076
13220
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
13077
13221
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -13097,14 +13241,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
13097
13241
|
return false;
|
|
13098
13242
|
}
|
|
13099
13243
|
function initProvablyLacksSignal(init) {
|
|
13100
|
-
if (init.type !==
|
|
13244
|
+
if (init.type !== import_utils64.AST_NODE_TYPES.ObjectExpression) {
|
|
13101
13245
|
return false;
|
|
13102
13246
|
}
|
|
13103
13247
|
for (const prop of init.properties) {
|
|
13104
|
-
if (prop.type ===
|
|
13248
|
+
if (prop.type === import_utils64.AST_NODE_TYPES.SpreadElement) {
|
|
13105
13249
|
return false;
|
|
13106
13250
|
}
|
|
13107
|
-
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") {
|
|
13108
13252
|
return false;
|
|
13109
13253
|
}
|
|
13110
13254
|
if (prop.computed) {
|
|
@@ -13114,7 +13258,7 @@ function initProvablyLacksSignal(init) {
|
|
|
13114
13258
|
return true;
|
|
13115
13259
|
}
|
|
13116
13260
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
13117
|
-
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);
|
|
13118
13262
|
}
|
|
13119
13263
|
var require_fetch_timeout_default = createRule({
|
|
13120
13264
|
name: "require-fetch-timeout",
|
|
@@ -13152,30 +13296,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
13152
13296
|
}
|
|
13153
13297
|
function resolvesToGlobal(identifier) {
|
|
13154
13298
|
const scope = context.sourceCode.getScope(identifier);
|
|
13155
|
-
const variable =
|
|
13299
|
+
const variable = import_utils64.ASTUtils.findVariable(scope, identifier.name);
|
|
13156
13300
|
return variable === null || variable.defs.length === 0;
|
|
13157
13301
|
}
|
|
13158
13302
|
function isGlobalFetchCall2(callee) {
|
|
13159
|
-
if (callee.type ===
|
|
13303
|
+
if (callee.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
13160
13304
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
13161
13305
|
}
|
|
13162
|
-
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);
|
|
13163
13307
|
}
|
|
13164
13308
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
13165
|
-
const variable =
|
|
13309
|
+
const variable = import_utils64.ASTUtils.findVariable(
|
|
13166
13310
|
context.sourceCode.getScope(identifier),
|
|
13167
13311
|
identifier.name
|
|
13168
13312
|
);
|
|
13169
13313
|
if (variable?.defs.length !== 1) return false;
|
|
13170
13314
|
const definition = variable.defs[0];
|
|
13171
|
-
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)) {
|
|
13172
13316
|
return false;
|
|
13173
13317
|
}
|
|
13174
13318
|
for (const reference of variable.references) {
|
|
13175
13319
|
const ref = reference.identifier;
|
|
13176
13320
|
if (ref === identifier || ref === definition.name) continue;
|
|
13177
13321
|
const member = ref.parent;
|
|
13178
|
-
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) {
|
|
13179
13323
|
return false;
|
|
13180
13324
|
}
|
|
13181
13325
|
}
|
|
@@ -13190,7 +13334,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
13190
13334
|
if (node.arguments.length === 1 && first !== void 0 && !isInlineUrl(first, resolvesToGlobal)) {
|
|
13191
13335
|
return;
|
|
13192
13336
|
}
|
|
13193
|
-
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)) {
|
|
13194
13338
|
context.report({ node, messageId: "missingSignal" });
|
|
13195
13339
|
}
|
|
13196
13340
|
}
|
|
@@ -13199,7 +13343,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
13199
13343
|
});
|
|
13200
13344
|
|
|
13201
13345
|
// src/rules/require-port-for-service.ts
|
|
13202
|
-
var
|
|
13346
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
13203
13347
|
var requirePortForServiceDocumentation = {
|
|
13204
13348
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
13205
13349
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -13224,45 +13368,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
13224
13368
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
13225
13369
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
13226
13370
|
var staticMemberName4 = (member) => {
|
|
13227
|
-
if (member.property.type ===
|
|
13228
|
-
if (!member.computed && member.property.type ===
|
|
13229
|
-
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;
|
|
13230
13374
|
};
|
|
13231
13375
|
var detachedValueExports = (program) => {
|
|
13232
13376
|
const names = /* @__PURE__ */ new Set();
|
|
13233
13377
|
for (const statement of program.body) {
|
|
13234
|
-
if (statement.type ===
|
|
13378
|
+
if (statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
13235
13379
|
for (const specifier of statement.specifiers) {
|
|
13236
13380
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
13237
13381
|
}
|
|
13238
|
-
} else if (statement.type ===
|
|
13382
|
+
} else if (statement.type === import_utils65.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13239
13383
|
names.add(statement.declaration.name);
|
|
13240
|
-
} else if (statement.type ===
|
|
13384
|
+
} else if (statement.type === import_utils65.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13241
13385
|
names.add(statement.expression.name);
|
|
13242
13386
|
}
|
|
13243
13387
|
}
|
|
13244
13388
|
return names;
|
|
13245
13389
|
};
|
|
13246
|
-
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);
|
|
13247
13391
|
var readTypeReference = (annotation) => {
|
|
13248
|
-
if (annotation?.type ===
|
|
13392
|
+
if (annotation?.type === import_utils65.AST_NODE_TYPES.TSUnionType) {
|
|
13249
13393
|
const members = annotation.types.filter(
|
|
13250
|
-
(member) => member.type !==
|
|
13394
|
+
(member) => member.type !== import_utils65.AST_NODE_TYPES.TSUndefinedKeyword && member.type !== import_utils65.AST_NODE_TYPES.TSNullKeyword
|
|
13251
13395
|
);
|
|
13252
13396
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
13253
13397
|
}
|
|
13254
|
-
if (annotation === void 0 || annotation.type !==
|
|
13398
|
+
if (annotation === void 0 || annotation.type !== import_utils65.AST_NODE_TYPES.TSTypeReference) return null;
|
|
13255
13399
|
const { typeName } = annotation;
|
|
13256
|
-
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;
|
|
13257
13401
|
if (rightmost === null) return null;
|
|
13258
13402
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
13259
13403
|
};
|
|
13260
|
-
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}` : "";
|
|
13261
13405
|
var propertySignatureTypes = (members) => {
|
|
13262
13406
|
const types = /* @__PURE__ */ new Map();
|
|
13263
13407
|
for (const member of members) {
|
|
13264
|
-
if (member.type !==
|
|
13265
|
-
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;
|
|
13266
13410
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
13267
13411
|
if (reference === null) continue;
|
|
13268
13412
|
types.set(member.key.name, reference);
|
|
@@ -13273,18 +13417,18 @@ var fileTypeIndex = (program) => {
|
|
|
13273
13417
|
const objects = /* @__PURE__ */ new Map();
|
|
13274
13418
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
13275
13419
|
for (const statement of program.body) {
|
|
13276
|
-
const declaration = statement.type ===
|
|
13277
|
-
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) {
|
|
13278
13422
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
13279
13423
|
continue;
|
|
13280
13424
|
}
|
|
13281
|
-
if (declaration?.type !==
|
|
13425
|
+
if (declaration?.type !== import_utils65.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
13282
13426
|
const aliased = declaration.typeAnnotation;
|
|
13283
|
-
if (aliased.type ===
|
|
13427
|
+
if (aliased.type === import_utils65.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils65.AST_NODE_TYPES.TSConstructorType) {
|
|
13284
13428
|
functionAliases.add(declaration.id.name);
|
|
13285
13429
|
continue;
|
|
13286
13430
|
}
|
|
13287
|
-
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) : [];
|
|
13288
13432
|
if (literals.length === 0) continue;
|
|
13289
13433
|
const merged = /* @__PURE__ */ new Map();
|
|
13290
13434
|
for (const literal of literals) {
|
|
@@ -13312,10 +13456,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13312
13456
|
while (pending.length > 0) {
|
|
13313
13457
|
const current = pending.pop();
|
|
13314
13458
|
if (current === void 0) break;
|
|
13315
|
-
if (current.type ===
|
|
13316
|
-
const expression = current.type ===
|
|
13317
|
-
const storedField = expression?.type ===
|
|
13318
|
-
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) {
|
|
13319
13463
|
for (const key of Object.keys(current)) {
|
|
13320
13464
|
if (key === "parent") continue;
|
|
13321
13465
|
const value = current[key];
|
|
@@ -13328,14 +13472,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13328
13472
|
continue;
|
|
13329
13473
|
}
|
|
13330
13474
|
let source = expression.right;
|
|
13331
|
-
while (source.type ===
|
|
13332
|
-
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) {
|
|
13333
13477
|
constructedFields += 1;
|
|
13334
|
-
} else if (source.type ===
|
|
13478
|
+
} else if (source.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13335
13479
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
13336
13480
|
fields.add(storedField);
|
|
13337
13481
|
storedFieldsFrom.set(source.name, fields);
|
|
13338
|
-
} else if (source.type ===
|
|
13482
|
+
} else if (source.type === import_utils65.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13339
13483
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
13340
13484
|
fields.add(storedField);
|
|
13341
13485
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -13345,7 +13489,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13345
13489
|
const collaborators = [];
|
|
13346
13490
|
for (const parameter of ctor.value.params) {
|
|
13347
13491
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
13348
|
-
const fields = parameter.type ===
|
|
13492
|
+
const fields = parameter.type === import_utils65.AST_NODE_TYPES.TSParameterProperty ? [reference.name] : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
13349
13493
|
if (fields.length === 0) continue;
|
|
13350
13494
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
13351
13495
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -13360,8 +13504,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13360
13504
|
};
|
|
13361
13505
|
var parameterCollaborators = (parameter, declared) => {
|
|
13362
13506
|
let target = parameter;
|
|
13363
|
-
if (target.type ===
|
|
13364
|
-
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) {
|
|
13365
13509
|
return objectPatternCollaborators(target, declared);
|
|
13366
13510
|
}
|
|
13367
13511
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -13369,9 +13513,9 @@ var parameterCollaborators = (parameter, declared) => {
|
|
|
13369
13513
|
};
|
|
13370
13514
|
var namedParameterCollaborator = (annotated) => {
|
|
13371
13515
|
let target = annotated;
|
|
13372
|
-
if (target.type ===
|
|
13373
|
-
if (target.type ===
|
|
13374
|
-
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;
|
|
13375
13519
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
13376
13520
|
if (reference === null) return null;
|
|
13377
13521
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -13383,11 +13527,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
13383
13527
|
if (members === null) return [];
|
|
13384
13528
|
const collaborators = [];
|
|
13385
13529
|
for (const property of pattern.properties) {
|
|
13386
|
-
if (property.type !==
|
|
13387
|
-
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;
|
|
13388
13532
|
const key = property.key.name;
|
|
13389
|
-
const bound = property.value.type ===
|
|
13390
|
-
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;
|
|
13391
13535
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
13392
13536
|
const reference = members.get(key);
|
|
13393
13537
|
if (reference === void 0) continue;
|
|
@@ -13396,21 +13540,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
13396
13540
|
return collaborators;
|
|
13397
13541
|
};
|
|
13398
13542
|
var bagMemberTypes = (annotation, declared) => {
|
|
13399
|
-
if (annotation.type ===
|
|
13543
|
+
if (annotation.type === import_utils65.AST_NODE_TYPES.TSTypeLiteral) {
|
|
13400
13544
|
return propertySignatureTypes(annotation.members);
|
|
13401
13545
|
}
|
|
13402
|
-
if (annotation.type !==
|
|
13546
|
+
if (annotation.type !== import_utils65.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13403
13547
|
return null;
|
|
13404
13548
|
}
|
|
13405
13549
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
13406
13550
|
};
|
|
13407
13551
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
13408
|
-
if (node.type ===
|
|
13552
|
+
if (node.type === import_utils65.AST_NODE_TYPES.CallExpression) {
|
|
13409
13553
|
const { callee } = node;
|
|
13410
|
-
if (callee.type ===
|
|
13411
|
-
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;
|
|
13412
13556
|
}
|
|
13413
|
-
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);
|
|
13414
13558
|
});
|
|
13415
13559
|
var subtreeHas = (root, found) => {
|
|
13416
13560
|
let hit = false;
|
|
@@ -13437,19 +13581,19 @@ var invokedInstanceField = (call) => {
|
|
|
13437
13581
|
const direct = instanceField(call.callee);
|
|
13438
13582
|
if (direct !== null) return direct;
|
|
13439
13583
|
let callee = call.callee;
|
|
13440
|
-
while (callee.type ===
|
|
13441
|
-
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;
|
|
13442
13586
|
};
|
|
13443
13587
|
var instanceField = (candidate) => {
|
|
13444
13588
|
let node = candidate;
|
|
13445
|
-
while (node.type ===
|
|
13446
|
-
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;
|
|
13447
13591
|
};
|
|
13448
13592
|
var behaviorallyInvokedFields = (body2) => {
|
|
13449
13593
|
const invoked = /* @__PURE__ */ new Set();
|
|
13450
13594
|
const visit = (current) => {
|
|
13451
|
-
if (current.type ===
|
|
13452
|
-
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) {
|
|
13453
13597
|
const field = invokedInstanceField(current);
|
|
13454
13598
|
if (field !== null) invoked.add(field);
|
|
13455
13599
|
}
|
|
@@ -13462,14 +13606,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
13462
13606
|
}
|
|
13463
13607
|
};
|
|
13464
13608
|
for (const member of body2.body) {
|
|
13465
|
-
if (member.type ===
|
|
13466
|
-
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) {
|
|
13467
13611
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
13468
13612
|
continue;
|
|
13469
13613
|
}
|
|
13470
|
-
if (member.type !==
|
|
13614
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.PropertyDefinition || member.value === null) continue;
|
|
13471
13615
|
visit(
|
|
13472
|
-
member.value.type ===
|
|
13616
|
+
member.value.type === import_utils65.AST_NODE_TYPES.ArrowFunctionExpression ? member.value.body : member.value
|
|
13473
13617
|
);
|
|
13474
13618
|
}
|
|
13475
13619
|
return invoked;
|
|
@@ -13489,25 +13633,25 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
13489
13633
|
var fileInterfaceNames = (program) => {
|
|
13490
13634
|
const names = [];
|
|
13491
13635
|
for (const statement of program.body) {
|
|
13492
|
-
const declaration = statement.type ===
|
|
13493
|
-
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);
|
|
13494
13638
|
}
|
|
13495
13639
|
return names;
|
|
13496
13640
|
};
|
|
13497
13641
|
var publicMethodNames = (body2, functionAliases) => {
|
|
13498
13642
|
const names = [];
|
|
13499
13643
|
for (const member of body2.body) {
|
|
13500
|
-
if (member.type ===
|
|
13644
|
+
if (member.type === import_utils65.AST_NODE_TYPES.PropertyDefinition) {
|
|
13501
13645
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
13502
|
-
if (member.value?.type !==
|
|
13503
|
-
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");
|
|
13504
13648
|
continue;
|
|
13505
13649
|
}
|
|
13506
|
-
if (member.type !==
|
|
13650
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.MethodDefinition) continue;
|
|
13507
13651
|
if (member.kind !== "method" || member.static) continue;
|
|
13508
13652
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
13509
|
-
if (member.key.type ===
|
|
13510
|
-
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);
|
|
13511
13655
|
else names.push("\u2026");
|
|
13512
13656
|
}
|
|
13513
13657
|
return names;
|
|
@@ -13515,13 +13659,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
13515
13659
|
var isFluentConstructionObject = (node, getText) => {
|
|
13516
13660
|
if (node.id === null) return false;
|
|
13517
13661
|
const methods = node.body.body.filter(
|
|
13518
|
-
(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
|
|
13519
13663
|
);
|
|
13520
13664
|
if (methods.length === 0) return false;
|
|
13521
13665
|
return methods.every((member) => {
|
|
13522
13666
|
const result = member.value.returnType?.typeAnnotation;
|
|
13523
13667
|
if (result === void 0) return false;
|
|
13524
|
-
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;
|
|
13525
13669
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
13526
13670
|
});
|
|
13527
13671
|
};
|
|
@@ -13529,10 +13673,10 @@ function localClassAbstractness(program) {
|
|
|
13529
13673
|
const classes = /* @__PURE__ */ new Map();
|
|
13530
13674
|
const parents = /* @__PURE__ */ new Map();
|
|
13531
13675
|
for (const statement of program.body) {
|
|
13532
|
-
const declaration = statement.type ===
|
|
13533
|
-
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) {
|
|
13534
13678
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
13535
|
-
if (declaration.superClass?.type ===
|
|
13679
|
+
if (declaration.superClass?.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13536
13680
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
13537
13681
|
}
|
|
13538
13682
|
}
|
|
@@ -13554,43 +13698,43 @@ function localInterfaceSurfaces(program) {
|
|
|
13554
13698
|
const parents = /* @__PURE__ */ new Map();
|
|
13555
13699
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
13556
13700
|
for (const statement of program.body) {
|
|
13557
|
-
const declaration = statement.type ===
|
|
13558
|
-
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);
|
|
13559
13703
|
}
|
|
13560
13704
|
for (const statement of program.body) {
|
|
13561
|
-
const declaration = statement.type ===
|
|
13562
|
-
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) {
|
|
13563
13707
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
13564
|
-
const parts = declaration.typeAnnotation.type ===
|
|
13708
|
+
const parts = declaration.typeAnnotation.type === import_utils65.AST_NODE_TYPES.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
13565
13709
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
13566
13710
|
for (const part of parts) {
|
|
13567
|
-
if (part.type ===
|
|
13711
|
+
if (part.type === import_utils65.AST_NODE_TYPES.TSTypeReference && part.typeName.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13568
13712
|
inherited.push(part.typeName.name);
|
|
13569
13713
|
continue;
|
|
13570
13714
|
}
|
|
13571
|
-
if (part.type !==
|
|
13715
|
+
if (part.type !== import_utils65.AST_NODE_TYPES.TSTypeLiteral) continue;
|
|
13572
13716
|
for (const member of part.members) {
|
|
13573
|
-
if (member.type !==
|
|
13574
|
-
if (member.computed || member.key.type !==
|
|
13575
|
-
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) {
|
|
13576
13720
|
callables2.add(member.key.name);
|
|
13577
13721
|
continue;
|
|
13578
13722
|
}
|
|
13579
|
-
if (member.type !==
|
|
13723
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13580
13724
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
13581
|
-
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);
|
|
13582
13726
|
}
|
|
13583
13727
|
}
|
|
13584
13728
|
interfaces.set(declaration.id.name, callables2);
|
|
13585
13729
|
parents.set(declaration.id.name, inherited);
|
|
13586
13730
|
continue;
|
|
13587
13731
|
}
|
|
13588
|
-
if (declaration?.type !==
|
|
13732
|
+
if (declaration?.type !== import_utils65.AST_NODE_TYPES.TSInterfaceDeclaration) continue;
|
|
13589
13733
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
13590
13734
|
for (const member of declaration.body.body) {
|
|
13591
|
-
if (member.type !==
|
|
13592
|
-
if (member.computed || member.key.type !==
|
|
13593
|
-
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);
|
|
13594
13738
|
}
|
|
13595
13739
|
interfaces.set(declaration.id.name, callables);
|
|
13596
13740
|
parents.set(
|
|
@@ -13598,7 +13742,7 @@ function localInterfaceSurfaces(program) {
|
|
|
13598
13742
|
[
|
|
13599
13743
|
...parents.get(declaration.id.name) ?? [],
|
|
13600
13744
|
...declaration.extends.flatMap(
|
|
13601
|
-
(heritage) => heritage.expression.type ===
|
|
13745
|
+
(heritage) => heritage.expression.type === import_utils65.AST_NODE_TYPES.Identifier ? [heritage.expression.name] : ["*"]
|
|
13602
13746
|
)
|
|
13603
13747
|
]
|
|
13604
13748
|
);
|
|
@@ -13625,7 +13769,7 @@ function localInterfaceSurfaces(program) {
|
|
|
13625
13769
|
}
|
|
13626
13770
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
13627
13771
|
if (node.superClass !== null) {
|
|
13628
|
-
if (node.superClass.type !==
|
|
13772
|
+
if (node.superClass.type !== import_utils65.AST_NODE_TYPES.Identifier) return true;
|
|
13629
13773
|
const localAbstract = classes.get(node.superClass.name);
|
|
13630
13774
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
13631
13775
|
}
|
|
@@ -13637,7 +13781,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
13637
13781
|
if (node.implements.length === 0) return false;
|
|
13638
13782
|
const combined = /* @__PURE__ */ new Set();
|
|
13639
13783
|
for (const implementation of node.implements) {
|
|
13640
|
-
if (implementation.expression.type !==
|
|
13784
|
+
if (implementation.expression.type !== import_utils65.AST_NODE_TYPES.Identifier) return true;
|
|
13641
13785
|
const name = implementation.expression.name;
|
|
13642
13786
|
const localAbstract = classes.get(name);
|
|
13643
13787
|
if (localAbstract === true) return true;
|
|
@@ -13680,7 +13824,7 @@ var require_port_for_service_default = createRule({
|
|
|
13680
13824
|
if (node.abstract === true) return;
|
|
13681
13825
|
if (node.decorators.length > 0) return;
|
|
13682
13826
|
const ctor = node.body.body.find(
|
|
13683
|
-
(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
|
|
13684
13828
|
);
|
|
13685
13829
|
if (ctor === void 0) return;
|
|
13686
13830
|
const constructorFacts = readConstructor(
|
|
@@ -13715,7 +13859,7 @@ var require_port_for_service_default = createRule({
|
|
|
13715
13859
|
});
|
|
13716
13860
|
|
|
13717
13861
|
// src/rules/require-static-next-matcher.ts
|
|
13718
|
-
var
|
|
13862
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
13719
13863
|
var requireStaticNextMatcherDocumentation = {
|
|
13720
13864
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
13721
13865
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -13728,34 +13872,34 @@ var requireStaticNextMatcherDocumentation = {
|
|
|
13728
13872
|
};
|
|
13729
13873
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
13730
13874
|
function unwrapExpression3(node) {
|
|
13731
|
-
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) {
|
|
13732
13876
|
return unwrapExpression3(node.expression);
|
|
13733
13877
|
}
|
|
13734
13878
|
return node;
|
|
13735
13879
|
}
|
|
13736
13880
|
function isStaticValue(node) {
|
|
13737
13881
|
const value = unwrapExpression3(node);
|
|
13738
|
-
if (value.type ===
|
|
13882
|
+
if (value.type === import_utils66.AST_NODE_TYPES.Literal) {
|
|
13739
13883
|
return true;
|
|
13740
13884
|
}
|
|
13741
|
-
if (value.type ===
|
|
13885
|
+
if (value.type === import_utils66.AST_NODE_TYPES.TemplateLiteral) {
|
|
13742
13886
|
return value.expressions.length === 0;
|
|
13743
13887
|
}
|
|
13744
|
-
if (value.type ===
|
|
13888
|
+
if (value.type === import_utils66.AST_NODE_TYPES.ArrayExpression) {
|
|
13745
13889
|
return value.elements.every(
|
|
13746
|
-
(element) => element !== null && element.type !==
|
|
13890
|
+
(element) => element !== null && element.type !== import_utils66.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
13747
13891
|
);
|
|
13748
13892
|
}
|
|
13749
|
-
if (value.type ===
|
|
13893
|
+
if (value.type === import_utils66.AST_NODE_TYPES.ObjectExpression) {
|
|
13750
13894
|
return value.properties.every(
|
|
13751
|
-
(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)
|
|
13752
13896
|
);
|
|
13753
13897
|
}
|
|
13754
13898
|
return false;
|
|
13755
13899
|
}
|
|
13756
13900
|
function propertyName2(property) {
|
|
13757
13901
|
if (property.computed) return null;
|
|
13758
|
-
if (property.key.type ===
|
|
13902
|
+
if (property.key.type === import_utils66.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
13759
13903
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
13760
13904
|
}
|
|
13761
13905
|
var require_static_next_matcher_default = createRule({
|
|
@@ -13778,19 +13922,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
13778
13922
|
}
|
|
13779
13923
|
return {
|
|
13780
13924
|
ExportNamedDeclaration(node) {
|
|
13781
|
-
if (node.declaration?.type !==
|
|
13925
|
+
if (node.declaration?.type !== import_utils66.AST_NODE_TYPES.VariableDeclaration) {
|
|
13782
13926
|
return;
|
|
13783
13927
|
}
|
|
13784
13928
|
for (const declaration of node.declaration.declarations) {
|
|
13785
|
-
if (declaration.id.type !==
|
|
13929
|
+
if (declaration.id.type !== import_utils66.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
13786
13930
|
continue;
|
|
13787
13931
|
}
|
|
13788
13932
|
const config = unwrapExpression3(declaration.init);
|
|
13789
|
-
if (config.type !==
|
|
13933
|
+
if (config.type !== import_utils66.AST_NODE_TYPES.ObjectExpression) {
|
|
13790
13934
|
continue;
|
|
13791
13935
|
}
|
|
13792
13936
|
for (const property of config.properties) {
|
|
13793
|
-
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) {
|
|
13794
13938
|
continue;
|
|
13795
13939
|
}
|
|
13796
13940
|
if (!isStaticValue(property.value)) {
|
|
@@ -13804,7 +13948,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
13804
13948
|
});
|
|
13805
13949
|
|
|
13806
13950
|
// src/rules/require-zod-form-validation.ts
|
|
13807
|
-
var
|
|
13951
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
13808
13952
|
var requireZodFormValidationDocumentation = {
|
|
13809
13953
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
13810
13954
|
rationale: "FormData values are untrusted strings or files and need runtime validation before use.",
|
|
@@ -13829,14 +13973,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
13829
13973
|
var zodReceiverRoot = (node) => {
|
|
13830
13974
|
let current = node;
|
|
13831
13975
|
while (true) {
|
|
13832
|
-
if (current.type ===
|
|
13976
|
+
if (current.type === import_utils67.AST_NODE_TYPES.Identifier) {
|
|
13833
13977
|
return current;
|
|
13834
13978
|
}
|
|
13835
|
-
if (current.type ===
|
|
13979
|
+
if (current.type === import_utils67.AST_NODE_TYPES.CallExpression) {
|
|
13836
13980
|
current = current.callee;
|
|
13837
13981
|
continue;
|
|
13838
13982
|
}
|
|
13839
|
-
if (current.type ===
|
|
13983
|
+
if (current.type === import_utils67.AST_NODE_TYPES.MemberExpression) {
|
|
13840
13984
|
current = current.object;
|
|
13841
13985
|
continue;
|
|
13842
13986
|
}
|
|
@@ -13845,12 +13989,12 @@ var zodReceiverRoot = (node) => {
|
|
|
13845
13989
|
};
|
|
13846
13990
|
var isFormDataMethodCall = (node) => {
|
|
13847
13991
|
let current = node;
|
|
13848
|
-
if (current.type ===
|
|
13992
|
+
if (current.type === import_utils67.AST_NODE_TYPES.AwaitExpression) {
|
|
13849
13993
|
current = current.argument;
|
|
13850
13994
|
}
|
|
13851
|
-
if (current.type !==
|
|
13995
|
+
if (current.type !== import_utils67.AST_NODE_TYPES.CallExpression) return false;
|
|
13852
13996
|
const callee = current.callee;
|
|
13853
|
-
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";
|
|
13854
13998
|
};
|
|
13855
13999
|
var require_zod_form_validation_default = createRule({
|
|
13856
14000
|
name: "require-zod-form-validation",
|
|
@@ -13871,7 +14015,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13871
14015
|
return {};
|
|
13872
14016
|
}
|
|
13873
14017
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
13874
|
-
const resolvedBinding = (identifier) =>
|
|
14018
|
+
const resolvedBinding = (identifier) => import_utils67.ASTUtils.findVariable(
|
|
13875
14019
|
context.sourceCode.getScope(identifier),
|
|
13876
14020
|
identifier.name
|
|
13877
14021
|
);
|
|
@@ -13881,16 +14025,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
13881
14025
|
return false;
|
|
13882
14026
|
}
|
|
13883
14027
|
const definition = binding.defs[0];
|
|
13884
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
14028
|
+
if (definition?.type !== "Variable" || definition.node.type !== import_utils67.AST_NODE_TYPES.VariableDeclarator) {
|
|
13885
14029
|
return false;
|
|
13886
14030
|
}
|
|
13887
14031
|
const init = definition.node.init;
|
|
13888
|
-
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;
|
|
13889
14033
|
};
|
|
13890
14034
|
const isZodParseCall = (node) => {
|
|
13891
|
-
if (node.type !==
|
|
14035
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.CallExpression) return false;
|
|
13892
14036
|
const callee = node.callee;
|
|
13893
|
-
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)) {
|
|
13894
14038
|
return false;
|
|
13895
14039
|
}
|
|
13896
14040
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -13899,14 +14043,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
13899
14043
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
13900
14044
|
};
|
|
13901
14045
|
const isFormSourceIdentifier = (node) => {
|
|
13902
|
-
if (node.type !==
|
|
14046
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.Identifier) return false;
|
|
13903
14047
|
const conventionalName = /formdata/i.test(node.name);
|
|
13904
14048
|
let scope = context.sourceCode.getScope(node);
|
|
13905
14049
|
while (scope !== null) {
|
|
13906
14050
|
const variable = scope.set.get(node.name);
|
|
13907
14051
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
13908
14052
|
const def = variable.defs[0];
|
|
13909
|
-
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) {
|
|
13910
14054
|
return isFormDataMethodCall(def.node.init);
|
|
13911
14055
|
}
|
|
13912
14056
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -13917,8 +14061,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
13917
14061
|
};
|
|
13918
14062
|
const isFormDataGetCall = (node) => {
|
|
13919
14063
|
const callee = node.callee;
|
|
13920
|
-
if (callee.type !==
|
|
13921
|
-
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)) {
|
|
13922
14066
|
return false;
|
|
13923
14067
|
}
|
|
13924
14068
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -13934,16 +14078,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
13934
14078
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
13935
14079
|
const isInstanceofNarrowing = (node) => {
|
|
13936
14080
|
const parent = node.parent;
|
|
13937
|
-
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");
|
|
13938
14082
|
};
|
|
13939
14083
|
const boundDeclarator = (node) => {
|
|
13940
14084
|
let current = node;
|
|
13941
14085
|
let parent = current.parent;
|
|
13942
|
-
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) {
|
|
13943
14087
|
current = parent;
|
|
13944
14088
|
parent = current.parent;
|
|
13945
14089
|
}
|
|
13946
|
-
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) {
|
|
13947
14091
|
return parent;
|
|
13948
14092
|
}
|
|
13949
14093
|
return null;
|
|
@@ -13952,7 +14096,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13952
14096
|
let current = node;
|
|
13953
14097
|
while (current.parent !== void 0) {
|
|
13954
14098
|
const parent = current.parent;
|
|
13955
|
-
if (parent.type ===
|
|
14099
|
+
if (parent.type === import_utils67.AST_NODE_TYPES.BlockStatement || parent.type === import_utils67.AST_NODE_TYPES.Program) {
|
|
13956
14100
|
return current;
|
|
13957
14101
|
}
|
|
13958
14102
|
current = parent;
|
|
@@ -13961,12 +14105,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
13961
14105
|
};
|
|
13962
14106
|
const zodParseMethod = (call) => {
|
|
13963
14107
|
const callee = call.callee;
|
|
13964
|
-
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;
|
|
13965
14109
|
};
|
|
13966
14110
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
13967
14111
|
let current = node.parent;
|
|
13968
14112
|
while (current !== void 0 && current !== statement) {
|
|
13969
|
-
if (current.type ===
|
|
14113
|
+
if (current.type === import_utils67.AST_NODE_TYPES.LogicalExpression || current.type === import_utils67.AST_NODE_TYPES.ConditionalExpression) {
|
|
13970
14114
|
return true;
|
|
13971
14115
|
}
|
|
13972
14116
|
current = current.parent;
|
|
@@ -13976,7 +14120,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13976
14120
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
13977
14121
|
let current = node.parent;
|
|
13978
14122
|
while (current !== void 0 && current !== statement) {
|
|
13979
|
-
if (current.type ===
|
|
14123
|
+
if (current.type === import_utils67.AST_NODE_TYPES.AwaitExpression) return true;
|
|
13980
14124
|
current = current.parent;
|
|
13981
14125
|
}
|
|
13982
14126
|
return false;
|
|
@@ -13989,7 +14133,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13989
14133
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
13990
14134
|
return null;
|
|
13991
14135
|
}
|
|
13992
|
-
if (validationStatement.type !==
|
|
14136
|
+
if (validationStatement.type !== import_utils67.AST_NODE_TYPES.VariableDeclaration && validationStatement.type !== import_utils67.AST_NODE_TYPES.ExpressionStatement) {
|
|
13993
14137
|
return null;
|
|
13994
14138
|
}
|
|
13995
14139
|
const method = zodParseMethod(parse2);
|
|
@@ -14001,16 +14145,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
14001
14145
|
};
|
|
14002
14146
|
const isSafePrevalidationInspection = (identifier) => {
|
|
14003
14147
|
const parent = identifier.parent;
|
|
14004
|
-
if (parent.type ===
|
|
14148
|
+
if (parent.type === import_utils67.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof") {
|
|
14005
14149
|
return true;
|
|
14006
14150
|
}
|
|
14007
|
-
if (parent.type !==
|
|
14151
|
+
if (parent.type !== import_utils67.AST_NODE_TYPES.BinaryExpression || parent.left !== identifier) {
|
|
14008
14152
|
return false;
|
|
14009
14153
|
}
|
|
14010
14154
|
if (parent.operator === "instanceof") {
|
|
14011
|
-
return parent.right.type ===
|
|
14155
|
+
return parent.right.type === import_utils67.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
14012
14156
|
}
|
|
14013
|
-
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");
|
|
14014
14158
|
};
|
|
14015
14159
|
const isDescendantOf = (node, ancestor) => {
|
|
14016
14160
|
let current = node;
|
|
@@ -14021,23 +14165,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
14021
14165
|
return false;
|
|
14022
14166
|
};
|
|
14023
14167
|
const blockTerminates = (node) => {
|
|
14024
|
-
if (node.type ===
|
|
14168
|
+
if (node.type === import_utils67.AST_NODE_TYPES.ReturnStatement || node.type === import_utils67.AST_NODE_TYPES.ThrowStatement) {
|
|
14025
14169
|
return true;
|
|
14026
14170
|
}
|
|
14027
|
-
if (node.type !==
|
|
14171
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.BlockStatement || node.body.length === 0) return false;
|
|
14028
14172
|
const last = node.body.at(-1);
|
|
14029
14173
|
return last !== void 0 && blockTerminates(last);
|
|
14030
14174
|
};
|
|
14031
14175
|
const narrowingIf = (identifier) => {
|
|
14032
14176
|
const comparison = identifier.parent;
|
|
14033
|
-
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") {
|
|
14034
14178
|
return null;
|
|
14035
14179
|
}
|
|
14036
14180
|
const maybeNegation = comparison.parent;
|
|
14037
|
-
const negated = maybeNegation?.type ===
|
|
14181
|
+
const negated = maybeNegation?.type === import_utils67.AST_NODE_TYPES.UnaryExpression && maybeNegation.operator === "!";
|
|
14038
14182
|
const test = negated ? maybeNegation : comparison;
|
|
14039
14183
|
const branch = test.parent;
|
|
14040
|
-
return branch?.type ===
|
|
14184
|
+
return branch?.type === import_utils67.AST_NODE_TYPES.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
14041
14185
|
};
|
|
14042
14186
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
14043
14187
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -14057,7 +14201,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14057
14201
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
14058
14202
|
if (variable === void 0) return false;
|
|
14059
14203
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
14060
|
-
(identifier) => identifier.type ===
|
|
14204
|
+
(identifier) => identifier.type === import_utils67.AST_NODE_TYPES.Identifier
|
|
14061
14205
|
);
|
|
14062
14206
|
if (references.length === 0) return false;
|
|
14063
14207
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -14083,7 +14227,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14083
14227
|
ImportDeclaration(node) {
|
|
14084
14228
|
if (!isZodModule(node.source.value)) return;
|
|
14085
14229
|
for (const specifier of node.specifiers) {
|
|
14086
|
-
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")) {
|
|
14087
14231
|
const binding = resolvedBinding(specifier.local);
|
|
14088
14232
|
if (binding !== null) zodBindings.add(binding);
|
|
14089
14233
|
}
|
|
@@ -14104,7 +14248,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14104
14248
|
});
|
|
14105
14249
|
|
|
14106
14250
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
14107
|
-
var
|
|
14251
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
14108
14252
|
var storeInsertRequiresOnConflictDocumentation = {
|
|
14109
14253
|
summary: "Require embedded inserts in explicitly replayable callables to carry conflict handling.",
|
|
14110
14254
|
rationale: "A callable named as an enqueue, seed, migration, schedule, ensure, or upsert promises replay safety.",
|
|
@@ -14168,7 +14312,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
14168
14312
|
});
|
|
14169
14313
|
|
|
14170
14314
|
// src/rules/stepdown.ts
|
|
14171
|
-
var
|
|
14315
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
14172
14316
|
var stepdownDocumentation = {
|
|
14173
14317
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
14174
14318
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -14185,7 +14329,7 @@ var stepdownDocumentation = {
|
|
|
14185
14329
|
]
|
|
14186
14330
|
};
|
|
14187
14331
|
function isFunction(node) {
|
|
14188
|
-
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;
|
|
14189
14333
|
}
|
|
14190
14334
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true) {
|
|
14191
14335
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -14280,8 +14424,8 @@ function moduleScope(context, program) {
|
|
|
14280
14424
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
14281
14425
|
const overloadNames = new Set(
|
|
14282
14426
|
program.body.flatMap((statement) => {
|
|
14283
|
-
const node = statement.type ===
|
|
14284
|
-
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] : [];
|
|
14285
14429
|
})
|
|
14286
14430
|
);
|
|
14287
14431
|
const exported = exportedNames(program);
|
|
@@ -14305,7 +14449,7 @@ function moduleScope(context, program) {
|
|
|
14305
14449
|
const nearestFunction = [...ancestors].reverse().find(isFunction);
|
|
14306
14450
|
const parent = identifier.parent;
|
|
14307
14451
|
const callerDefinition = nearestFunction === void 0 ? void 0 : byFunction.get(nearestFunction);
|
|
14308
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
14452
|
+
if (callerDefinition === void 0 || parent.type !== import_utils69.AST_NODE_TYPES.CallExpression || parent.callee !== identifier) {
|
|
14309
14453
|
pinned.add(definition.name);
|
|
14310
14454
|
continue;
|
|
14311
14455
|
}
|
|
@@ -14320,38 +14464,38 @@ function moduleScope(context, program) {
|
|
|
14320
14464
|
function exportedNames(program) {
|
|
14321
14465
|
const names = /* @__PURE__ */ new Set();
|
|
14322
14466
|
for (const statement of program.body) {
|
|
14323
|
-
if (statement.type !==
|
|
14324
|
-
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) {
|
|
14325
14469
|
names.add(statement.declaration.id.name);
|
|
14326
14470
|
}
|
|
14327
|
-
if (statement.declaration?.type ===
|
|
14471
|
+
if (statement.declaration?.type === import_utils69.AST_NODE_TYPES.VariableDeclaration) {
|
|
14328
14472
|
for (const declarator of statement.declaration.declarations) {
|
|
14329
|
-
if (declarator.id.type ===
|
|
14473
|
+
if (declarator.id.type === import_utils69.AST_NODE_TYPES.Identifier) names.add(declarator.id.name);
|
|
14330
14474
|
}
|
|
14331
14475
|
}
|
|
14332
14476
|
for (const specifier of statement.specifiers) {
|
|
14333
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
14477
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14334
14478
|
names.add(specifier.local.name);
|
|
14335
14479
|
}
|
|
14336
14480
|
}
|
|
14337
14481
|
}
|
|
14338
14482
|
for (const statement of program.body) {
|
|
14339
|
-
if (statement.type ===
|
|
14340
|
-
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);
|
|
14341
14485
|
}
|
|
14342
14486
|
return names;
|
|
14343
14487
|
}
|
|
14344
14488
|
function moduleDefinitions(program) {
|
|
14345
14489
|
const definitions = [];
|
|
14346
14490
|
for (const statement of program.body) {
|
|
14347
|
-
const node = statement.type ===
|
|
14348
|
-
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) {
|
|
14349
14493
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
14350
14494
|
continue;
|
|
14351
14495
|
}
|
|
14352
|
-
if (node?.type !==
|
|
14496
|
+
if (node?.type !== import_utils69.AST_NODE_TYPES.VariableDeclaration || node.kind !== "const") continue;
|
|
14353
14497
|
for (const declarator of node.declarations) {
|
|
14354
|
-
if (declarator.id.type ===
|
|
14498
|
+
if (declarator.id.type === import_utils69.AST_NODE_TYPES.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
14355
14499
|
definitions.push({
|
|
14356
14500
|
name: declarator.id.name,
|
|
14357
14501
|
node: declarator,
|
|
@@ -14364,21 +14508,21 @@ function moduleDefinitions(program) {
|
|
|
14364
14508
|
return definitions;
|
|
14365
14509
|
}
|
|
14366
14510
|
function methodName(node) {
|
|
14367
|
-
if (node.key.type ===
|
|
14368
|
-
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;
|
|
14369
14513
|
}
|
|
14370
14514
|
function referencedMethod(context, node, classVariables) {
|
|
14371
|
-
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;
|
|
14372
14516
|
const isClassReference = objectVariable !== null && classVariables.has(objectVariable);
|
|
14373
|
-
if (node.object.type !==
|
|
14374
|
-
if (node.property.type ===
|
|
14375
|
-
if (!node.computed && node.property.type ===
|
|
14376
|
-
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;
|
|
14377
14521
|
}
|
|
14378
14522
|
function referencedPropertyName(node) {
|
|
14379
|
-
if (node.property.type ===
|
|
14380
|
-
if (!node.computed && node.property.type ===
|
|
14381
|
-
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;
|
|
14382
14526
|
}
|
|
14383
14527
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
14384
14528
|
visit(node, nestedFunction);
|
|
@@ -14394,7 +14538,7 @@ function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
14394
14538
|
}
|
|
14395
14539
|
function classScope(context, node, computedReferenceNames) {
|
|
14396
14540
|
const methods = node.body.body.filter(
|
|
14397
|
-
(member) => member.type ===
|
|
14541
|
+
(member) => member.type === import_utils69.AST_NODE_TYPES.MethodDefinition
|
|
14398
14542
|
);
|
|
14399
14543
|
const counts = /* @__PURE__ */ new Map();
|
|
14400
14544
|
for (const method of methods) {
|
|
@@ -14402,8 +14546,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14402
14546
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
14403
14547
|
}
|
|
14404
14548
|
for (const member of node.body.body) {
|
|
14405
|
-
if (member.type !==
|
|
14406
|
-
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;
|
|
14407
14551
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
14408
14552
|
}
|
|
14409
14553
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -14412,7 +14556,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14412
14556
|
});
|
|
14413
14557
|
const definitions = methods.flatMap((method) => {
|
|
14414
14558
|
const name = methodName(method);
|
|
14415
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
14559
|
+
const isPrivate = method.accessibility === "private" || method.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier;
|
|
14416
14560
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
14417
14561
|
});
|
|
14418
14562
|
if (definitions.length === 0) return;
|
|
@@ -14421,11 +14565,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14421
14565
|
const pinned = /* @__PURE__ */ new Set();
|
|
14422
14566
|
const classVariables = /* @__PURE__ */ new Set();
|
|
14423
14567
|
if (node.id !== null) {
|
|
14424
|
-
const internal =
|
|
14568
|
+
const internal = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
14425
14569
|
if (internal !== null) classVariables.add(internal);
|
|
14426
14570
|
}
|
|
14427
|
-
if (node.type ===
|
|
14428
|
-
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);
|
|
14429
14573
|
if (outer !== null) classVariables.add(outer);
|
|
14430
14574
|
}
|
|
14431
14575
|
for (const method of methods) {
|
|
@@ -14441,27 +14585,27 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14441
14585
|
}
|
|
14442
14586
|
const thisValue = (value) => {
|
|
14443
14587
|
let current = value;
|
|
14444
|
-
while (current?.type ===
|
|
14445
|
-
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;
|
|
14446
14590
|
};
|
|
14447
14591
|
const collectAlias = (current, nestedFunction) => {
|
|
14448
|
-
if (nestedFunction || current.type !==
|
|
14449
|
-
if (current.type ===
|
|
14450
|
-
const binding = current.type ===
|
|
14451
|
-
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;
|
|
14452
14596
|
if (!thisValue(value)) return;
|
|
14453
|
-
if (binding.type ===
|
|
14597
|
+
if (binding.type === import_utils69.AST_NODE_TYPES.ObjectPattern) {
|
|
14454
14598
|
for (const property of binding.properties) {
|
|
14455
|
-
if (property.type ===
|
|
14599
|
+
if (property.type === import_utils69.AST_NODE_TYPES.RestElement) {
|
|
14456
14600
|
for (const name of privateNames) pinned.add(name);
|
|
14457
|
-
} else if (property.key.type ===
|
|
14601
|
+
} else if (property.key.type === import_utils69.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) {
|
|
14458
14602
|
pinned.add(property.key.name);
|
|
14459
14603
|
}
|
|
14460
14604
|
}
|
|
14461
14605
|
return;
|
|
14462
14606
|
}
|
|
14463
|
-
if (binding.type !==
|
|
14464
|
-
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);
|
|
14465
14609
|
if (variable !== null) {
|
|
14466
14610
|
methodClassVariables.add(variable);
|
|
14467
14611
|
methodAliases.add(variable);
|
|
@@ -14474,16 +14618,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14474
14618
|
walk(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
14475
14619
|
}
|
|
14476
14620
|
const visitCall = (current, nestedFunction) => {
|
|
14477
|
-
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)) {
|
|
14478
14622
|
for (const property of current.id.properties) {
|
|
14479
|
-
if (property.type ===
|
|
14623
|
+
if (property.type === import_utils69.AST_NODE_TYPES.RestElement) {
|
|
14480
14624
|
for (const name of privateNames) pinned.add(name);
|
|
14481
14625
|
continue;
|
|
14482
14626
|
}
|
|
14483
|
-
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);
|
|
14484
14628
|
}
|
|
14485
14629
|
}
|
|
14486
|
-
if (current.type !==
|
|
14630
|
+
if (current.type !== import_utils69.AST_NODE_TYPES.MemberExpression) return;
|
|
14487
14631
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
14488
14632
|
if (target === null) {
|
|
14489
14633
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -14491,12 +14635,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14491
14635
|
return;
|
|
14492
14636
|
}
|
|
14493
14637
|
if (!privateNames.has(target)) return;
|
|
14494
|
-
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;
|
|
14495
14639
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
14496
14640
|
pinned.add(target);
|
|
14497
14641
|
return;
|
|
14498
14642
|
}
|
|
14499
|
-
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) {
|
|
14500
14644
|
pinned.add(target);
|
|
14501
14645
|
return;
|
|
14502
14646
|
}
|
|
@@ -14516,9 +14660,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14516
14660
|
}
|
|
14517
14661
|
}
|
|
14518
14662
|
for (const member of node.body.body) {
|
|
14519
|
-
if (member.type ===
|
|
14663
|
+
if (member.type === import_utils69.AST_NODE_TYPES.MethodDefinition || member.type === import_utils69.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
14520
14664
|
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
14521
|
-
if (current.type !==
|
|
14665
|
+
if (current.type !== import_utils69.AST_NODE_TYPES.MemberExpression) return;
|
|
14522
14666
|
const target = referencedMethod(context, current, classVariables);
|
|
14523
14667
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
14524
14668
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -14528,14 +14672,14 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14528
14672
|
const accessibility = new Map(
|
|
14529
14673
|
scopeDefinitions.map((definition) => {
|
|
14530
14674
|
const method = definition.node;
|
|
14531
|
-
const accessibility2 = method.key.type ===
|
|
14675
|
+
const accessibility2 = method.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier ? "private" : method.accessibility ?? "public";
|
|
14532
14676
|
return [definition.name, accessibility2];
|
|
14533
14677
|
})
|
|
14534
14678
|
);
|
|
14535
14679
|
const methodByName = new Map(scopeDefinitions.map((definition) => [definition.name, definition.node]));
|
|
14536
14680
|
for (const [caller, callees] of calls) {
|
|
14537
14681
|
const callerMethod = methodByName.get(caller);
|
|
14538
|
-
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;
|
|
14539
14683
|
for (const callee of callees) pinned.add(callee);
|
|
14540
14684
|
}
|
|
14541
14685
|
const memberIndexes = new Map(node.body.body.map((member, index) => [member, index]));
|
|
@@ -14552,12 +14696,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14552
14696
|
}
|
|
14553
14697
|
function isClassRuntimeBarrier(member) {
|
|
14554
14698
|
switch (member.type) {
|
|
14555
|
-
case
|
|
14699
|
+
case import_utils69.AST_NODE_TYPES.StaticBlock:
|
|
14556
14700
|
return true;
|
|
14557
|
-
case
|
|
14558
|
-
case
|
|
14701
|
+
case import_utils69.AST_NODE_TYPES.PropertyDefinition:
|
|
14702
|
+
case import_utils69.AST_NODE_TYPES.AccessorProperty:
|
|
14559
14703
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
14560
|
-
case
|
|
14704
|
+
case import_utils69.AST_NODE_TYPES.MethodDefinition:
|
|
14561
14705
|
return member.computed || member.decorators.length > 0;
|
|
14562
14706
|
default:
|
|
14563
14707
|
return false;
|
|
@@ -14589,7 +14733,7 @@ var stepdown_default = createRule({
|
|
|
14589
14733
|
moduleScope(context, program);
|
|
14590
14734
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
14591
14735
|
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
14592
|
-
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);
|
|
14593
14737
|
});
|
|
14594
14738
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
14595
14739
|
}
|
|
@@ -14598,7 +14742,7 @@ var stepdown_default = createRule({
|
|
|
14598
14742
|
});
|
|
14599
14743
|
|
|
14600
14744
|
// src/rules/zod-naming-convention.ts
|
|
14601
|
-
var
|
|
14745
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
14602
14746
|
var zodNamingConventionDocumentation = {
|
|
14603
14747
|
summary: "Enforce a consistent Zod schema naming convention \u2014 a `Z` prefix (`ZUser`) or a `Schema` suffix (`userSchema`); both are accepted by default.",
|
|
14604
14748
|
rationale: "A recognizable schema name distinguishes runtime validators from ordinary values at each use site.",
|
|
@@ -14639,18 +14783,18 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
14639
14783
|
"prettifyError",
|
|
14640
14784
|
"treeifyError"
|
|
14641
14785
|
]);
|
|
14642
|
-
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;
|
|
14643
14787
|
var calleeChainRoot = (node) => {
|
|
14644
14788
|
let current = node;
|
|
14645
14789
|
for (; ; ) {
|
|
14646
|
-
if (current.type ===
|
|
14790
|
+
if (current.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
14647
14791
|
return current;
|
|
14648
14792
|
}
|
|
14649
|
-
if (current.type ===
|
|
14793
|
+
if (current.type === import_utils70.AST_NODE_TYPES.MemberExpression) {
|
|
14650
14794
|
current = current.object;
|
|
14651
14795
|
continue;
|
|
14652
14796
|
}
|
|
14653
|
-
if (current.type ===
|
|
14797
|
+
if (current.type === import_utils70.AST_NODE_TYPES.CallExpression) {
|
|
14654
14798
|
current = current.callee;
|
|
14655
14799
|
continue;
|
|
14656
14800
|
}
|
|
@@ -14690,7 +14834,7 @@ var zod_naming_convention_default = createRule({
|
|
|
14690
14834
|
const acceptsSchemaWord = convention !== "prefix";
|
|
14691
14835
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
14692
14836
|
function resolvedBinding(identifier) {
|
|
14693
|
-
return
|
|
14837
|
+
return import_utils70.ASTUtils.findVariable(
|
|
14694
14838
|
context.sourceCode.getScope(identifier),
|
|
14695
14839
|
identifier.name
|
|
14696
14840
|
);
|
|
@@ -14712,7 +14856,7 @@ var zod_naming_convention_default = createRule({
|
|
|
14712
14856
|
ImportDeclaration(node) {
|
|
14713
14857
|
if (!isZodModule(node.source.value)) return;
|
|
14714
14858
|
for (const specifier of node.specifiers) {
|
|
14715
|
-
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")) {
|
|
14716
14860
|
recordZodBinding(specifier.local);
|
|
14717
14861
|
}
|
|
14718
14862
|
}
|
|
@@ -14720,13 +14864,13 @@ var zod_naming_convention_default = createRule({
|
|
|
14720
14864
|
VariableDeclarator(node) {
|
|
14721
14865
|
const init = node.init;
|
|
14722
14866
|
if (init === null || init === void 0) return;
|
|
14723
|
-
if (init.type !==
|
|
14867
|
+
if (init.type !== import_utils70.AST_NODE_TYPES.CallExpression) return;
|
|
14724
14868
|
const callee = init.callee;
|
|
14725
|
-
if (callee.type !==
|
|
14869
|
+
if (callee.type !== import_utils70.AST_NODE_TYPES.MemberExpression) return;
|
|
14726
14870
|
if (!isZodChain(callee)) return;
|
|
14727
14871
|
const terminal = terminalMethodName(callee);
|
|
14728
14872
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
14729
|
-
if (node.id.type !==
|
|
14873
|
+
if (node.id.type !== import_utils70.AST_NODE_TYPES.Identifier) return;
|
|
14730
14874
|
if (test.test(node.id.name)) return;
|
|
14731
14875
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
14732
14876
|
context.report({
|
|
@@ -14870,6 +15014,7 @@ var rules = {
|
|
|
14870
15014
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
14871
15015
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
14872
15016
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
15017
|
+
"prefer-await-in-async-return": prefer_await_in_async_return_default,
|
|
14873
15018
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
14874
15019
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
14875
15020
|
"prefer-server-actions": prefer_server_actions_default,
|
|
@@ -14886,7 +15031,7 @@ var rules = {
|
|
|
14886
15031
|
};
|
|
14887
15032
|
var meta = {
|
|
14888
15033
|
name: "@sarj/eslint-plugin",
|
|
14889
|
-
version: "15.6.
|
|
15034
|
+
version: "15.6.3"
|
|
14890
15035
|
};
|
|
14891
15036
|
var applicationOnlyRules = [
|
|
14892
15037
|
"no-restricted-library-load",
|
|
@@ -14937,6 +15082,7 @@ var recommendedRules = {
|
|
|
14937
15082
|
"@sarj/prefer-module-level-constant": "error",
|
|
14938
15083
|
"@sarj/prefer-module-level-schema": "error",
|
|
14939
15084
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
15085
|
+
"@sarj/prefer-await-in-async-return": "error",
|
|
14940
15086
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
14941
15087
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
14942
15088
|
"@sarj/prefer-server-actions": "error",
|
|
@@ -14999,6 +15145,7 @@ var strictRules = {
|
|
|
14999
15145
|
"@sarj/prefer-module-level-constant": "error",
|
|
15000
15146
|
"@sarj/prefer-module-level-schema": "error",
|
|
15001
15147
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
15148
|
+
"@sarj/prefer-await-in-async-return": "error",
|
|
15002
15149
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
15003
15150
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
15004
15151
|
"@sarj/prefer-server-actions": "error",
|