@sarj/eslint-plugin 15.6.2 → 15.6.4
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 +625 -435
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +623 -430
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1054,20 +1054,20 @@ var noCommentCruftDocumentation = {
|
|
|
1054
1054
|
],
|
|
1055
1055
|
examples: [
|
|
1056
1056
|
{
|
|
1057
|
-
id: "
|
|
1058
|
-
title: "A
|
|
1057
|
+
id: "owned-context",
|
|
1058
|
+
title: "A reference records why the counter changes",
|
|
1059
1059
|
outcome: "no-match",
|
|
1060
|
-
files: [{ path: "src/
|
|
1061
|
-
focusPath: "src/
|
|
1060
|
+
files: [{ path: "src/counter.ts", source: "// increment the counter for PLT-812\ncounter += 1;" }],
|
|
1061
|
+
focusPath: "src/counter.ts",
|
|
1062
1062
|
expectedCount: 0,
|
|
1063
1063
|
public: true
|
|
1064
1064
|
},
|
|
1065
1065
|
{
|
|
1066
|
-
id: "
|
|
1067
|
-
title: "A
|
|
1066
|
+
id: "redundant-narration",
|
|
1067
|
+
title: "A comment repeats the statement below",
|
|
1068
1068
|
outcome: "match",
|
|
1069
|
-
files: [{ path: "src/
|
|
1070
|
-
focusPath: "src/
|
|
1069
|
+
files: [{ path: "src/counter.ts", source: "// increment the counter\ncounter += 1;" }],
|
|
1070
|
+
focusPath: "src/counter.ts",
|
|
1071
1071
|
expectedCount: 1,
|
|
1072
1072
|
public: true
|
|
1073
1073
|
}
|
|
@@ -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
|
}
|
|
@@ -4179,8 +4201,51 @@ var noLongCommentDocumentation = {
|
|
|
4179
4201
|
category: "maintainability",
|
|
4180
4202
|
limitations: ["Only JSDoc blocks are inspected; structured API docs, tests, scripts, generated files, and versioned dependencies are excluded."],
|
|
4181
4203
|
examples: [
|
|
4182
|
-
{
|
|
4183
|
-
|
|
4204
|
+
{
|
|
4205
|
+
id: "structured-jsdoc",
|
|
4206
|
+
title: "Paragraphs separate a component's durable constraints",
|
|
4207
|
+
outcome: "no-match",
|
|
4208
|
+
files: [{
|
|
4209
|
+
path: "src/composer.ts",
|
|
4210
|
+
source: [
|
|
4211
|
+
"/**",
|
|
4212
|
+
" * Shared composer.",
|
|
4213
|
+
" *",
|
|
4214
|
+
" * It serves the room. It serves task comments. It stays visually calm. It accepts attachments.",
|
|
4215
|
+
" *",
|
|
4216
|
+
" * The `tone` prop supplies task styling. The `leadingTools` prop supplies controls.",
|
|
4217
|
+
" * The parent owns uploads. The component owns focus.",
|
|
4218
|
+
" */",
|
|
4219
|
+
"",
|
|
4220
|
+
"export const Composer = forwardRef(function Composer() { return null; });"
|
|
4221
|
+
].join("\n")
|
|
4222
|
+
}],
|
|
4223
|
+
focusPath: "src/composer.ts",
|
|
4224
|
+
expectedCount: 0,
|
|
4225
|
+
public: true
|
|
4226
|
+
},
|
|
4227
|
+
{
|
|
4228
|
+
id: "prose-wall",
|
|
4229
|
+
title: "One paragraph narrates a chart's design history",
|
|
4230
|
+
outcome: "match",
|
|
4231
|
+
files: [{
|
|
4232
|
+
path: "src/chart.ts",
|
|
4233
|
+
source: `/**
|
|
4234
|
+
* The ports chart shows arrivals and departures across the network.
|
|
4235
|
+
* It was originally a line chart, but the lines crossed too often.
|
|
4236
|
+
* Bars make adjacent ports easier to compare at a glance.
|
|
4237
|
+
* The axis starts at zero so visual differences stay proportional.
|
|
4238
|
+
* A single series uses the site navy for brand consistency.
|
|
4239
|
+
* Empty ports use a neutral ink so missing traffic remains visible.
|
|
4240
|
+
* Tooltip values repeat the units shown on the vertical axis.
|
|
4241
|
+
* The chart intentionally keeps labels horizontal on wide screens.
|
|
4242
|
+
*/
|
|
4243
|
+
export function PortBars() { return null; }`
|
|
4244
|
+
}],
|
|
4245
|
+
focusPath: "src/chart.ts",
|
|
4246
|
+
expectedCount: 1,
|
|
4247
|
+
public: true
|
|
4248
|
+
}
|
|
4184
4249
|
]
|
|
4185
4250
|
};
|
|
4186
4251
|
var EXCESSIVE_SENTENCE_COUNT = 8;
|
|
@@ -7464,10 +7529,10 @@ var noTypedDocSectionsDocumentation = {
|
|
|
7464
7529
|
public: true
|
|
7465
7530
|
},
|
|
7466
7531
|
{
|
|
7467
|
-
id: "
|
|
7468
|
-
title: "Do not
|
|
7532
|
+
id: "restated-parameter",
|
|
7533
|
+
title: "Do not expand a typed parameter's name",
|
|
7469
7534
|
outcome: "match",
|
|
7470
|
-
files: [{ path: "src/client.ts", source: "/** @param
|
|
7535
|
+
files: [{ path: "src/client.ts", source: "/** @param userId the user identifier */\nexport function fetchValue(userId: string): number { return 1; }" }],
|
|
7471
7536
|
focusPath: "src/client.ts",
|
|
7472
7537
|
expectedCount: 1,
|
|
7473
7538
|
public: true
|
|
@@ -10851,8 +10916,130 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
10851
10916
|
}
|
|
10852
10917
|
});
|
|
10853
10918
|
|
|
10854
|
-
// src/rules/prefer-
|
|
10919
|
+
// src/rules/prefer-await-in-async-return.ts
|
|
10855
10920
|
var import_utils57 = require("@typescript-eslint/utils");
|
|
10921
|
+
var ts2 = __toESM(require("typescript"), 1);
|
|
10922
|
+
var preferAwaitInAsyncReturnDocumentation = {
|
|
10923
|
+
summary: "Prefer explicit `await` when an async function directly returns one typed Promise `.then` transform.",
|
|
10924
|
+
rationale: "Mixing a directly returned Promise callback into otherwise async control flow makes sequencing and failures harder to read.",
|
|
10925
|
+
remediation: "Await the Promise, then return the transformed value with ordinary async statements.",
|
|
10926
|
+
category: "maintainability",
|
|
10927
|
+
since: "15.6.3",
|
|
10928
|
+
limitations: [
|
|
10929
|
+
"Only a single directly returned `.then` call with an inline callback is checked.",
|
|
10930
|
+
"The receiver must be proven Promise-like by TypeScript; untyped files and larger chains are intentionally ignored."
|
|
10931
|
+
],
|
|
10932
|
+
examples: [
|
|
10933
|
+
{
|
|
10934
|
+
id: "explicit-async-transform",
|
|
10935
|
+
title: "Use explicit async control flow",
|
|
10936
|
+
outcome: "no-match",
|
|
10937
|
+
files: [{
|
|
10938
|
+
path: "src/load.ts",
|
|
10939
|
+
source: "async function load() { const value = await Promise.resolve(1); return value + 1; }"
|
|
10940
|
+
}],
|
|
10941
|
+
focusPath: "src/load.ts",
|
|
10942
|
+
expectedCount: 0,
|
|
10943
|
+
public: true
|
|
10944
|
+
},
|
|
10945
|
+
{
|
|
10946
|
+
id: "returned-then-transform",
|
|
10947
|
+
title: "Do not directly return a Promise callback chain from async code",
|
|
10948
|
+
outcome: "match",
|
|
10949
|
+
files: [{
|
|
10950
|
+
path: "src/load.ts",
|
|
10951
|
+
source: "async function load() { return Promise.resolve(1).then((value) => value + 1); }"
|
|
10952
|
+
}],
|
|
10953
|
+
focusPath: "src/load.ts",
|
|
10954
|
+
expectedCount: 1,
|
|
10955
|
+
public: true
|
|
10956
|
+
}
|
|
10957
|
+
]
|
|
10958
|
+
};
|
|
10959
|
+
function isDirectAsyncReturn(node) {
|
|
10960
|
+
const parent = node.parent;
|
|
10961
|
+
if (parent.type === import_utils57.AST_NODE_TYPES.ArrowFunctionExpression && parent.body === node) {
|
|
10962
|
+
return parent.async && !parent.generator;
|
|
10963
|
+
}
|
|
10964
|
+
if (parent.type !== import_utils57.AST_NODE_TYPES.ReturnStatement || parent.argument !== node) {
|
|
10965
|
+
return false;
|
|
10966
|
+
}
|
|
10967
|
+
let owner = parent.parent;
|
|
10968
|
+
while (owner !== void 0 && !isRuntimeFunction(owner)) {
|
|
10969
|
+
owner = owner.parent;
|
|
10970
|
+
}
|
|
10971
|
+
return owner !== void 0 && owner.async && !owner.generator;
|
|
10972
|
+
}
|
|
10973
|
+
function isRuntimeFunction(node) {
|
|
10974
|
+
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;
|
|
10975
|
+
}
|
|
10976
|
+
function promiseThenReceiver(node) {
|
|
10977
|
+
const callee = node.callee;
|
|
10978
|
+
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) {
|
|
10979
|
+
return null;
|
|
10980
|
+
}
|
|
10981
|
+
const callback = node.arguments[0];
|
|
10982
|
+
if (callback === void 0 || callback.type !== import_utils57.AST_NODE_TYPES.ArrowFunctionExpression && callback.type !== import_utils57.AST_NODE_TYPES.FunctionExpression) {
|
|
10983
|
+
return null;
|
|
10984
|
+
}
|
|
10985
|
+
return callee.object;
|
|
10986
|
+
}
|
|
10987
|
+
function isProvenPromiseLike(node, services) {
|
|
10988
|
+
const checker = services.program.getTypeChecker();
|
|
10989
|
+
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
|
|
10990
|
+
const receiverType = checker.getTypeAtLocation(tsNode);
|
|
10991
|
+
if ((receiverType.flags & (ts2.TypeFlags.Any | ts2.TypeFlags.Unknown | ts2.TypeFlags.Never)) !== 0) {
|
|
10992
|
+
return false;
|
|
10993
|
+
}
|
|
10994
|
+
const thenSymbol = checker.getPropertyOfType(receiverType, "then");
|
|
10995
|
+
const hasBuiltInPromiseDeclaration = thenSymbol?.declarations?.some(
|
|
10996
|
+
(declaration) => {
|
|
10997
|
+
let owner = declaration.parent;
|
|
10998
|
+
while (owner !== void 0 && !ts2.isInterfaceDeclaration(owner)) {
|
|
10999
|
+
owner = owner.parent;
|
|
11000
|
+
}
|
|
11001
|
+
return owner !== void 0 && (owner.name.text === "Promise" || owner.name.text === "PromiseLike") && services.program.isSourceFileDefaultLibrary(owner.getSourceFile());
|
|
11002
|
+
}
|
|
11003
|
+
) ?? false;
|
|
11004
|
+
return hasBuiltInPromiseDeclaration;
|
|
11005
|
+
}
|
|
11006
|
+
var prefer_await_in_async_return_default = createRule({
|
|
11007
|
+
name: "prefer-await-in-async-return",
|
|
11008
|
+
documentation: preferAwaitInAsyncReturnDocumentation,
|
|
11009
|
+
meta: {
|
|
11010
|
+
type: "suggestion",
|
|
11011
|
+
docs: {
|
|
11012
|
+
description: "Prefer explicit `await` when an async function directly returns one typed Promise `.then` transform."
|
|
11013
|
+
},
|
|
11014
|
+
schema: [],
|
|
11015
|
+
messages: {
|
|
11016
|
+
preferAwait: "This async function directly returns a Promise `.then` transform. Await the Promise, then return the transformed value with explicit async control flow."
|
|
11017
|
+
}
|
|
11018
|
+
},
|
|
11019
|
+
defaultOptions: [],
|
|
11020
|
+
create(context) {
|
|
11021
|
+
let services;
|
|
11022
|
+
try {
|
|
11023
|
+
services = import_utils57.ESLintUtils.getParserServices(context);
|
|
11024
|
+
} catch {
|
|
11025
|
+
services = null;
|
|
11026
|
+
}
|
|
11027
|
+
if (services === null) return {};
|
|
11028
|
+
return {
|
|
11029
|
+
CallExpression(node) {
|
|
11030
|
+
if (!isDirectAsyncReturn(node)) return;
|
|
11031
|
+
const receiver = promiseThenReceiver(node);
|
|
11032
|
+
if (receiver === null || !isProvenPromiseLike(receiver, services)) {
|
|
11033
|
+
return;
|
|
11034
|
+
}
|
|
11035
|
+
context.report({ node, messageId: "preferAwait" });
|
|
11036
|
+
}
|
|
11037
|
+
};
|
|
11038
|
+
}
|
|
11039
|
+
});
|
|
11040
|
+
|
|
11041
|
+
// src/rules/prefer-schema-for-api-payload.ts
|
|
11042
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
10856
11043
|
var preferSchemaForApiPayloadDocumentation = {
|
|
10857
11044
|
summary: "Require Zod (or similar) schema validation on `response.json()` / `JSON.parse()` results before property access.",
|
|
10858
11045
|
rationale: "External JSON is untrusted at runtime even when its expected TypeScript shape is known statically.",
|
|
@@ -10867,9 +11054,9 @@ var preferSchemaForApiPayloadDocumentation = {
|
|
|
10867
11054
|
var unwrap4 = (node) => {
|
|
10868
11055
|
let current = node;
|
|
10869
11056
|
while (current !== null && current !== void 0) {
|
|
10870
|
-
if (current.type ===
|
|
11057
|
+
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
11058
|
current = current.expression;
|
|
10872
|
-
} else if (current.type ===
|
|
11059
|
+
} else if (current.type === import_utils58.AST_NODE_TYPES.ChainExpression) {
|
|
10873
11060
|
current = current.expression;
|
|
10874
11061
|
} else {
|
|
10875
11062
|
break;
|
|
@@ -10884,23 +11071,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
10884
11071
|
]);
|
|
10885
11072
|
var isSchemaParseReference = (node) => {
|
|
10886
11073
|
const inner = unwrap4(node);
|
|
10887
|
-
return inner !== null && inner.type ===
|
|
11074
|
+
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
11075
|
};
|
|
10889
11076
|
var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
10890
11077
|
let current = unwrap4(node);
|
|
10891
11078
|
if (current === null) return false;
|
|
10892
|
-
if (current.type ===
|
|
11079
|
+
if (current.type === import_utils58.AST_NODE_TYPES.AwaitExpression) {
|
|
10893
11080
|
current = unwrap4(current.argument);
|
|
10894
11081
|
}
|
|
10895
|
-
if (current === null || current.type !==
|
|
11082
|
+
if (current === null || current.type !== import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
10896
11083
|
return false;
|
|
10897
11084
|
}
|
|
10898
11085
|
const callee = unwrap4(current.callee);
|
|
10899
|
-
if (callee === null || callee.type !==
|
|
11086
|
+
if (callee === null || callee.type !== import_utils58.AST_NODE_TYPES.MemberExpression) {
|
|
10900
11087
|
return false;
|
|
10901
11088
|
}
|
|
10902
11089
|
const property = unwrap4(callee.property);
|
|
10903
|
-
if (property === null || property.type !==
|
|
11090
|
+
if (property === null || property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
10904
11091
|
return false;
|
|
10905
11092
|
}
|
|
10906
11093
|
if (property.name === "json") {
|
|
@@ -10910,17 +11097,17 @@ var isRawPayloadSource = (node, isKnownLocalText) => {
|
|
|
10910
11097
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
10911
11098
|
}
|
|
10912
11099
|
const object = unwrap4(callee.object);
|
|
10913
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
11100
|
+
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
11101
|
};
|
|
10915
11102
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
10916
11103
|
var isDirectLocalFileRead = (node) => {
|
|
10917
11104
|
let current = unwrap4(node);
|
|
10918
|
-
if (current?.type ===
|
|
11105
|
+
if (current?.type === import_utils58.AST_NODE_TYPES.AwaitExpression) {
|
|
10919
11106
|
current = unwrap4(current.argument);
|
|
10920
11107
|
}
|
|
10921
|
-
if (current?.type !==
|
|
11108
|
+
if (current?.type !== import_utils58.AST_NODE_TYPES.CallExpression) return false;
|
|
10922
11109
|
const callee = unwrap4(current.callee);
|
|
10923
|
-
const name = callee?.type ===
|
|
11110
|
+
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
11111
|
return name !== null && FILE_READ_RE.test(name);
|
|
10925
11112
|
};
|
|
10926
11113
|
var isLocalFileRead = (node) => {
|
|
@@ -10947,15 +11134,15 @@ var isLocalFileRead = (node) => {
|
|
|
10947
11134
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
10948
11135
|
var isInsideAssertion = (node) => {
|
|
10949
11136
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
10950
|
-
if (current.type !==
|
|
11137
|
+
if (current.type !== import_utils58.AST_NODE_TYPES.CallExpression) continue;
|
|
10951
11138
|
let callee = current.callee;
|
|
10952
|
-
while (callee.type ===
|
|
11139
|
+
while (callee.type === import_utils58.AST_NODE_TYPES.MemberExpression) {
|
|
10953
11140
|
callee = callee.object;
|
|
10954
11141
|
}
|
|
10955
|
-
if (callee.type ===
|
|
11142
|
+
if (callee.type === import_utils58.AST_NODE_TYPES.CallExpression) {
|
|
10956
11143
|
callee = callee.callee;
|
|
10957
11144
|
}
|
|
10958
|
-
if (callee.type ===
|
|
11145
|
+
if (callee.type === import_utils58.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
10959
11146
|
return true;
|
|
10960
11147
|
}
|
|
10961
11148
|
}
|
|
@@ -10974,22 +11161,22 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
10974
11161
|
var isValidationRead = (node) => {
|
|
10975
11162
|
let current = node;
|
|
10976
11163
|
let parent = current.parent;
|
|
10977
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
11164
|
+
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
11165
|
current = parent;
|
|
10979
11166
|
parent = parent.parent;
|
|
10980
11167
|
}
|
|
10981
11168
|
if (parent === null || parent === void 0) return false;
|
|
10982
|
-
if (parent.type ===
|
|
11169
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
10983
11170
|
return true;
|
|
10984
11171
|
}
|
|
10985
|
-
if (parent.type !==
|
|
11172
|
+
if (parent.type !== import_utils58.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
10986
11173
|
return false;
|
|
10987
11174
|
}
|
|
10988
11175
|
const callee = parent.callee;
|
|
10989
|
-
if (callee.type ===
|
|
11176
|
+
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
11177
|
return parent.arguments.length === 1;
|
|
10991
11178
|
}
|
|
10992
|
-
return callee.type ===
|
|
11179
|
+
return callee.type === import_utils58.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
10993
11180
|
};
|
|
10994
11181
|
var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
10995
11182
|
"bigint",
|
|
@@ -11000,13 +11187,13 @@ var PRIMITIVE_TYPEOF_RESULTS = /* @__PURE__ */ new Set([
|
|
|
11000
11187
|
"undefined"
|
|
11001
11188
|
]);
|
|
11002
11189
|
var bindingValidationPolarity = (test, bindingName) => {
|
|
11003
|
-
if (test.type ===
|
|
11190
|
+
if (test.type === import_utils58.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
11004
11191
|
const inner = bindingValidationPolarity(test.argument, bindingName);
|
|
11005
11192
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
11006
11193
|
}
|
|
11007
|
-
if (test.type ===
|
|
11008
|
-
const typeofName = (node) => node.type ===
|
|
11009
|
-
const literalType = (node) => node.type ===
|
|
11194
|
+
if (test.type === import_utils58.AST_NODE_TYPES.BinaryExpression) {
|
|
11195
|
+
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;
|
|
11196
|
+
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
11197
|
const matches = typeofName(test.left) === bindingName && literalType(test.right) !== null || typeofName(test.right) === bindingName && literalType(test.left) !== null;
|
|
11011
11198
|
if (!matches) return null;
|
|
11012
11199
|
if (test.operator === "===" || test.operator === "==") {
|
|
@@ -11014,9 +11201,9 @@ var bindingValidationPolarity = (test, bindingName) => {
|
|
|
11014
11201
|
}
|
|
11015
11202
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
11016
11203
|
}
|
|
11017
|
-
return test.type ===
|
|
11204
|
+
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
11205
|
};
|
|
11019
|
-
var plainMemberAccess = (node) => node.type ===
|
|
11206
|
+
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
11207
|
var isSamePlainMember = (node, access) => {
|
|
11021
11208
|
const candidate = plainMemberAccess(node);
|
|
11022
11209
|
return candidate !== null && candidate.object === access.object && candidate.property === access.property;
|
|
@@ -11024,19 +11211,19 @@ var isSamePlainMember = (node, access) => {
|
|
|
11024
11211
|
var nodeWithin2 = (node, container) => node.range[0] >= container.range[0] && node.range[1] <= container.range[1];
|
|
11025
11212
|
var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
11026
11213
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11027
|
-
if (current.type ===
|
|
11214
|
+
if (current.type === import_utils58.AST_NODE_TYPES.ConditionalExpression) {
|
|
11028
11215
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
11029
11216
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
11030
11217
|
return true;
|
|
11031
11218
|
}
|
|
11032
11219
|
}
|
|
11033
|
-
if (current.type ===
|
|
11220
|
+
if (current.type === import_utils58.AST_NODE_TYPES.IfStatement) {
|
|
11034
11221
|
const polarity = bindingValidationPolarity(current.test, bindingName);
|
|
11035
11222
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
11036
11223
|
return true;
|
|
11037
11224
|
}
|
|
11038
11225
|
}
|
|
11039
|
-
if (current.type ===
|
|
11226
|
+
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
11227
|
return false;
|
|
11041
11228
|
}
|
|
11042
11229
|
}
|
|
@@ -11044,32 +11231,32 @@ var isUseWithinValidatedBranch = (node, bindingName) => {
|
|
|
11044
11231
|
};
|
|
11045
11232
|
var isMemberUseWithinValidatedBranch = (node, access) => {
|
|
11046
11233
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11047
|
-
if (current.type ===
|
|
11234
|
+
if (current.type === import_utils58.AST_NODE_TYPES.ConditionalExpression) {
|
|
11048
11235
|
const polarity = memberValidationPolarity(current.test, access);
|
|
11049
11236
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && nodeWithin2(node, current.alternate)) {
|
|
11050
11237
|
return true;
|
|
11051
11238
|
}
|
|
11052
11239
|
}
|
|
11053
|
-
if (current.type ===
|
|
11240
|
+
if (current.type === import_utils58.AST_NODE_TYPES.IfStatement) {
|
|
11054
11241
|
const polarity = memberValidationPolarity(current.test, access);
|
|
11055
11242
|
if (polarity === "valid-when-true" && nodeWithin2(node, current.consequent) || polarity === "valid-when-false" && current.alternate !== null && nodeWithin2(node, current.alternate)) {
|
|
11056
11243
|
return true;
|
|
11057
11244
|
}
|
|
11058
11245
|
}
|
|
11059
|
-
if (current.type ===
|
|
11246
|
+
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
11247
|
return false;
|
|
11061
11248
|
}
|
|
11062
11249
|
}
|
|
11063
11250
|
return false;
|
|
11064
11251
|
};
|
|
11065
11252
|
var memberValidationPolarity = (test, access) => {
|
|
11066
|
-
if (test.type ===
|
|
11253
|
+
if (test.type === import_utils58.AST_NODE_TYPES.UnaryExpression && test.operator === "!") {
|
|
11067
11254
|
const inner = memberValidationPolarity(test.argument, access);
|
|
11068
11255
|
return inner === "valid-when-true" ? "valid-when-false" : inner === "valid-when-false" ? "valid-when-true" : null;
|
|
11069
11256
|
}
|
|
11070
|
-
if (test.type ===
|
|
11071
|
-
const isMatchingTypeof = (node) => node.type ===
|
|
11072
|
-
const isPrimitiveType = (node) => node.type ===
|
|
11257
|
+
if (test.type === import_utils58.AST_NODE_TYPES.BinaryExpression) {
|
|
11258
|
+
const isMatchingTypeof = (node) => node.type === import_utils58.AST_NODE_TYPES.UnaryExpression && node.operator === "typeof" && isSamePlainMember(node.argument, access);
|
|
11259
|
+
const isPrimitiveType = (node) => node.type === import_utils58.AST_NODE_TYPES.Literal && typeof node.value === "string" && PRIMITIVE_TYPEOF_RESULTS.has(node.value);
|
|
11073
11260
|
if (!(isMatchingTypeof(test.left) && isPrimitiveType(test.right) || isMatchingTypeof(test.right) && isPrimitiveType(test.left))) {
|
|
11074
11261
|
return null;
|
|
11075
11262
|
}
|
|
@@ -11078,15 +11265,15 @@ var memberValidationPolarity = (test, access) => {
|
|
|
11078
11265
|
}
|
|
11079
11266
|
return test.operator === "!==" || test.operator === "!=" ? "valid-when-false" : null;
|
|
11080
11267
|
}
|
|
11081
|
-
return test.type ===
|
|
11268
|
+
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
11269
|
};
|
|
11083
11270
|
var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
11084
11271
|
const isValidationReference = (identifier) => {
|
|
11085
11272
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11086
|
-
if ((current.type ===
|
|
11273
|
+
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
11274
|
return true;
|
|
11088
11275
|
}
|
|
11089
|
-
if (current.type !==
|
|
11276
|
+
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
11277
|
return false;
|
|
11091
11278
|
}
|
|
11092
11279
|
}
|
|
@@ -11094,7 +11281,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11094
11281
|
};
|
|
11095
11282
|
const isGuardedUse = (identifier) => {
|
|
11096
11283
|
for (let current = identifier.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
11097
|
-
if (current.type ===
|
|
11284
|
+
if (current.type === import_utils58.AST_NODE_TYPES.ConditionalExpression) {
|
|
11098
11285
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
11099
11286
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
11100
11287
|
return true;
|
|
@@ -11103,7 +11290,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11103
11290
|
return true;
|
|
11104
11291
|
}
|
|
11105
11292
|
}
|
|
11106
|
-
if (current.type ===
|
|
11293
|
+
if (current.type === import_utils58.AST_NODE_TYPES.IfStatement) {
|
|
11107
11294
|
const polarity = bindingValidationPolarity(current.test, identifier.name);
|
|
11108
11295
|
if (polarity === "valid-when-true" && nodeWithin2(identifier, current.consequent)) {
|
|
11109
11296
|
return true;
|
|
@@ -11112,14 +11299,14 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11112
11299
|
return true;
|
|
11113
11300
|
}
|
|
11114
11301
|
}
|
|
11115
|
-
if (current.type ===
|
|
11302
|
+
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
11303
|
return false;
|
|
11117
11304
|
}
|
|
11118
11305
|
}
|
|
11119
11306
|
return false;
|
|
11120
11307
|
};
|
|
11121
11308
|
const declarator = member.parent;
|
|
11122
|
-
if (declarator.type !==
|
|
11309
|
+
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
11310
|
return false;
|
|
11124
11311
|
}
|
|
11125
11312
|
const extracted = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
@@ -11127,7 +11314,7 @@ var isFullyValidatedExtractedBinding = (member, source, context) => {
|
|
|
11127
11314
|
let hasValueUse = false;
|
|
11128
11315
|
for (const reference of extracted.references) {
|
|
11129
11316
|
const identifier = reference.identifier;
|
|
11130
|
-
if (identifier.type !==
|
|
11317
|
+
if (identifier.type !== import_utils58.AST_NODE_TYPES.Identifier) return false;
|
|
11131
11318
|
if (nodeWithin2(identifier, declarator)) continue;
|
|
11132
11319
|
if (isValidationReference(identifier)) continue;
|
|
11133
11320
|
hasValueUse = true;
|
|
@@ -11140,17 +11327,17 @@ var isGuardTestPosition = (node) => {
|
|
|
11140
11327
|
let parent = current.parent;
|
|
11141
11328
|
while (parent !== void 0 && parent !== null) {
|
|
11142
11329
|
switch (parent.type) {
|
|
11143
|
-
case
|
|
11144
|
-
case
|
|
11145
|
-
case
|
|
11330
|
+
case import_utils58.AST_NODE_TYPES.UnaryExpression:
|
|
11331
|
+
case import_utils58.AST_NODE_TYPES.LogicalExpression:
|
|
11332
|
+
case import_utils58.AST_NODE_TYPES.ChainExpression:
|
|
11146
11333
|
current = parent;
|
|
11147
11334
|
parent = parent.parent;
|
|
11148
11335
|
continue;
|
|
11149
|
-
case
|
|
11150
|
-
case
|
|
11151
|
-
case
|
|
11152
|
-
case
|
|
11153
|
-
case
|
|
11336
|
+
case import_utils58.AST_NODE_TYPES.IfStatement:
|
|
11337
|
+
case import_utils58.AST_NODE_TYPES.ConditionalExpression:
|
|
11338
|
+
case import_utils58.AST_NODE_TYPES.WhileStatement:
|
|
11339
|
+
case import_utils58.AST_NODE_TYPES.DoWhileStatement:
|
|
11340
|
+
case import_utils58.AST_NODE_TYPES.ForStatement:
|
|
11154
11341
|
return parent.test === current;
|
|
11155
11342
|
default:
|
|
11156
11343
|
return false;
|
|
@@ -11160,7 +11347,7 @@ var isGuardTestPosition = (node) => {
|
|
|
11160
11347
|
};
|
|
11161
11348
|
var unvalidatedVariableRef = (node, scope, tracked) => {
|
|
11162
11349
|
const unwrapped = unwrap4(node);
|
|
11163
|
-
if (unwrapped === null || unwrapped.type !==
|
|
11350
|
+
if (unwrapped === null || unwrapped.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11164
11351
|
return null;
|
|
11165
11352
|
}
|
|
11166
11353
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -11189,7 +11376,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11189
11376
|
const localFileTextVariables = /* @__PURE__ */ new Set();
|
|
11190
11377
|
const localFileTextRef = (node, scope) => {
|
|
11191
11378
|
const unwrapped = unwrap4(node);
|
|
11192
|
-
if (unwrapped?.type !==
|
|
11379
|
+
if (unwrapped?.type !== import_utils58.AST_NODE_TYPES.Identifier) return null;
|
|
11193
11380
|
const variable = findVariable2(scope, unwrapped.name);
|
|
11194
11381
|
return variable !== null && localFileTextVariables.has(variable) ? variable : null;
|
|
11195
11382
|
};
|
|
@@ -11258,7 +11445,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11258
11445
|
return {
|
|
11259
11446
|
VariableDeclarator(node) {
|
|
11260
11447
|
const scope = context.sourceCode.getScope(node);
|
|
11261
|
-
if (node.id.type ===
|
|
11448
|
+
if (node.id.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11262
11449
|
const variable = context.sourceCode.getDeclaredVariables(node)[0];
|
|
11263
11450
|
if (variable !== void 0) {
|
|
11264
11451
|
updateLocalFileText(variable, node.init, scope);
|
|
@@ -11266,7 +11453,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11266
11453
|
trackInitializer(node, scope);
|
|
11267
11454
|
return;
|
|
11268
11455
|
}
|
|
11269
|
-
if (node.id.type ===
|
|
11456
|
+
if (node.id.type === import_utils58.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils58.AST_NODE_TYPES.ArrayPattern) {
|
|
11270
11457
|
if (isRawPayloadSource(
|
|
11271
11458
|
node.init,
|
|
11272
11459
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
@@ -11283,7 +11470,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11283
11470
|
},
|
|
11284
11471
|
AssignmentExpression(node) {
|
|
11285
11472
|
const scope = context.sourceCode.getScope(node);
|
|
11286
|
-
if (node.left.type ===
|
|
11473
|
+
if (node.left.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11287
11474
|
const variable = findVariable2(scope, node.left.name);
|
|
11288
11475
|
if (variable === null) return;
|
|
11289
11476
|
const isLocalText = (candidate) => localFileTextRef(candidate, scope) !== null;
|
|
@@ -11297,7 +11484,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11297
11484
|
}
|
|
11298
11485
|
return;
|
|
11299
11486
|
}
|
|
11300
|
-
if (node.left.type ===
|
|
11487
|
+
if (node.left.type === import_utils58.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils58.AST_NODE_TYPES.ArrayPattern) {
|
|
11301
11488
|
if (isRawPayloadSource(
|
|
11302
11489
|
node.right,
|
|
11303
11490
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
@@ -11317,15 +11504,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11317
11504
|
}
|
|
11318
11505
|
},
|
|
11319
11506
|
CallExpression(node) {
|
|
11320
|
-
if (node.callee.type !==
|
|
11507
|
+
if (node.callee.type !== import_utils58.AST_NODE_TYPES.Identifier) return;
|
|
11321
11508
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
11322
11509
|
return;
|
|
11323
11510
|
}
|
|
11324
11511
|
const scope = context.sourceCode.getScope(node);
|
|
11325
11512
|
for (const arg of node.arguments) {
|
|
11326
|
-
if (arg.type ===
|
|
11513
|
+
if (arg.type === import_utils58.AST_NODE_TYPES.SpreadElement) continue;
|
|
11327
11514
|
const unwrapped = unwrap4(arg);
|
|
11328
|
-
if (unwrapped === null || unwrapped.type !==
|
|
11515
|
+
if (unwrapped === null || unwrapped.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11329
11516
|
continue;
|
|
11330
11517
|
}
|
|
11331
11518
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -11342,14 +11529,14 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11342
11529
|
(candidate) => localFileTextRef(candidate, scope) !== null
|
|
11343
11530
|
)) {
|
|
11344
11531
|
const parent = node.parent;
|
|
11345
|
-
if (parent.type ===
|
|
11532
|
+
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
11533
|
return;
|
|
11347
11534
|
}
|
|
11348
11535
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
11349
11536
|
return;
|
|
11350
11537
|
}
|
|
11351
|
-
const variable = obj?.type ===
|
|
11352
|
-
if (variable !== null && obj?.type ===
|
|
11538
|
+
const variable = obj?.type === import_utils58.AST_NODE_TYPES.Identifier ? unvalidatedVariableRef(obj, scope, unvalidatedVariables) : null;
|
|
11539
|
+
if (variable !== null && obj?.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
11353
11540
|
if (isUseWithinValidatedBranch(node, obj.name)) {
|
|
11354
11541
|
return;
|
|
11355
11542
|
}
|
|
@@ -11369,7 +11556,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
11369
11556
|
});
|
|
11370
11557
|
|
|
11371
11558
|
// src/rules/prefer-semantic-colors.ts
|
|
11372
|
-
var
|
|
11559
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
11373
11560
|
var import_fs = require("fs");
|
|
11374
11561
|
var import_path = require("path");
|
|
11375
11562
|
|
|
@@ -11481,7 +11668,7 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
11481
11668
|
var isInsideSvg = (node) => {
|
|
11482
11669
|
let current = node.parent;
|
|
11483
11670
|
while (current !== void 0 && current !== null) {
|
|
11484
|
-
if (current.type ===
|
|
11671
|
+
if (current.type === import_utils59.AST_NODE_TYPES.JSXElement) {
|
|
11485
11672
|
const name = jsxElementName(current);
|
|
11486
11673
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
11487
11674
|
}
|
|
@@ -11491,8 +11678,8 @@ var isInsideSvg = (node) => {
|
|
|
11491
11678
|
};
|
|
11492
11679
|
function jsxElementName(node) {
|
|
11493
11680
|
const name = node.openingElement.name;
|
|
11494
|
-
if (name.type ===
|
|
11495
|
-
if (name.type ===
|
|
11681
|
+
if (name.type === import_utils59.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
11682
|
+
if (name.type === import_utils59.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils59.AST_NODE_TYPES.JSXIdentifier) {
|
|
11496
11683
|
return name.property.name;
|
|
11497
11684
|
}
|
|
11498
11685
|
return null;
|
|
@@ -11518,7 +11705,7 @@ function isSvgLikeElementName(name) {
|
|
|
11518
11705
|
var isInsideIconFactoryPath = (node) => {
|
|
11519
11706
|
let current = node.parent;
|
|
11520
11707
|
while (current !== void 0 && current !== null) {
|
|
11521
|
-
if (current.type ===
|
|
11708
|
+
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
11709
|
return true;
|
|
11523
11710
|
}
|
|
11524
11711
|
current = current.parent;
|
|
@@ -11652,12 +11839,12 @@ var expandWorkspaceGlob = (root, glob) => {
|
|
|
11652
11839
|
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
11840
|
};
|
|
11654
11841
|
var propName = (key) => {
|
|
11655
|
-
if (key.type ===
|
|
11656
|
-
if (key.type ===
|
|
11842
|
+
if (key.type === import_utils59.AST_NODE_TYPES.Identifier) return key.name;
|
|
11843
|
+
if (key.type === import_utils59.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
11657
11844
|
return null;
|
|
11658
11845
|
};
|
|
11659
11846
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
11660
|
-
if (statement.type !==
|
|
11847
|
+
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
11848
|
return false;
|
|
11662
11849
|
}
|
|
11663
11850
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -11710,27 +11897,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11710
11897
|
const checkClassNode = (node) => {
|
|
11711
11898
|
if (node === null) return;
|
|
11712
11899
|
switch (node.type) {
|
|
11713
|
-
case
|
|
11900
|
+
case import_utils59.AST_NODE_TYPES.Literal:
|
|
11714
11901
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
11715
11902
|
break;
|
|
11716
|
-
case
|
|
11903
|
+
case import_utils59.AST_NODE_TYPES.TemplateLiteral:
|
|
11717
11904
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
11718
11905
|
break;
|
|
11719
|
-
case
|
|
11906
|
+
case import_utils59.AST_NODE_TYPES.ArrayExpression:
|
|
11720
11907
|
for (const element of node.elements) {
|
|
11721
|
-
if (element !== null && element.type !==
|
|
11908
|
+
if (element !== null && element.type !== import_utils59.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
11722
11909
|
}
|
|
11723
11910
|
break;
|
|
11724
|
-
case
|
|
11911
|
+
case import_utils59.AST_NODE_TYPES.ObjectExpression:
|
|
11725
11912
|
for (const property of node.properties) {
|
|
11726
|
-
if (property.type ===
|
|
11913
|
+
if (property.type === import_utils59.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
11727
11914
|
}
|
|
11728
11915
|
break;
|
|
11729
|
-
case
|
|
11916
|
+
case import_utils59.AST_NODE_TYPES.ConditionalExpression:
|
|
11730
11917
|
checkClassNode(node.consequent);
|
|
11731
11918
|
checkClassNode(node.alternate);
|
|
11732
11919
|
break;
|
|
11733
|
-
case
|
|
11920
|
+
case import_utils59.AST_NODE_TYPES.LogicalExpression:
|
|
11734
11921
|
checkClassNode(node.right);
|
|
11735
11922
|
break;
|
|
11736
11923
|
default:
|
|
@@ -11738,32 +11925,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11738
11925
|
}
|
|
11739
11926
|
};
|
|
11740
11927
|
const checkColorValueNode = (node) => {
|
|
11741
|
-
if (node.type ===
|
|
11928
|
+
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
11929
|
report(node, "inlineColor", { value: node.value });
|
|
11743
11930
|
}
|
|
11744
11931
|
};
|
|
11745
11932
|
return {
|
|
11746
11933
|
"JSXAttribute[name.name='className']"(node) {
|
|
11747
11934
|
if (node.value === null) return;
|
|
11748
|
-
if (node.value.type ===
|
|
11749
|
-
else if (node.value.type ===
|
|
11750
|
-
if (node.value.expression.type !==
|
|
11935
|
+
if (node.value.type === import_utils59.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
11936
|
+
else if (node.value.type === import_utils59.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
11937
|
+
if (node.value.expression.type !== import_utils59.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
11751
11938
|
checkClassNode(node.value.expression);
|
|
11752
11939
|
}
|
|
11753
11940
|
}
|
|
11754
11941
|
},
|
|
11755
11942
|
CallExpression(node) {
|
|
11756
|
-
if (node.callee.type ===
|
|
11943
|
+
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
11944
|
importsEmailOrPdfRenderer = true;
|
|
11758
11945
|
}
|
|
11759
|
-
if (node.callee.type ===
|
|
11946
|
+
if (node.callee.type === import_utils59.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
11760
11947
|
for (const arg of node.arguments) {
|
|
11761
|
-
if (arg.type !==
|
|
11948
|
+
if (arg.type !== import_utils59.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
11762
11949
|
}
|
|
11763
11950
|
}
|
|
11764
11951
|
},
|
|
11765
11952
|
VariableDeclarator(node) {
|
|
11766
|
-
if (node.id.type ===
|
|
11953
|
+
if (node.id.type === import_utils59.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
11767
11954
|
checkClassNode(node.init);
|
|
11768
11955
|
}
|
|
11769
11956
|
},
|
|
@@ -11773,9 +11960,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11773
11960
|
},
|
|
11774
11961
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
11775
11962
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
11776
|
-
if (node.value?.type !==
|
|
11963
|
+
if (node.value?.type !== import_utils59.AST_NODE_TYPES.Literal) return;
|
|
11777
11964
|
const owner = node.parent.name;
|
|
11778
|
-
if (owner.type ===
|
|
11965
|
+
if (owner.type === import_utils59.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
11779
11966
|
return;
|
|
11780
11967
|
}
|
|
11781
11968
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -11789,7 +11976,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11789
11976
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
11790
11977
|
},
|
|
11791
11978
|
ImportExpression(node) {
|
|
11792
|
-
if (node.source.type ===
|
|
11979
|
+
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
11980
|
importsEmailOrPdfRenderer = true;
|
|
11794
11981
|
}
|
|
11795
11982
|
},
|
|
@@ -11802,7 +11989,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
11802
11989
|
});
|
|
11803
11990
|
|
|
11804
11991
|
// src/rules/prefer-server-actions.ts
|
|
11805
|
-
var
|
|
11992
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
11806
11993
|
var preferServerActionsDocumentation = {
|
|
11807
11994
|
summary: "Prefer Next.js Server Actions over /api/* mutations.",
|
|
11808
11995
|
rationale: "Server Actions preserve typed application calls and avoid an internal JSON request-response boundary.",
|
|
@@ -11991,7 +12178,7 @@ var prefer_server_actions_default = createRule({
|
|
|
11991
12178
|
});
|
|
11992
12179
|
|
|
11993
12180
|
// src/rules/prefer-whole-object-assertion.ts
|
|
11994
|
-
var
|
|
12181
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
11995
12182
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
11996
12183
|
var SYNTHETIC_LITERAL_MATCHERS = /* @__PURE__ */ new Map([
|
|
11997
12184
|
["toBeNull", "null"],
|
|
@@ -12016,11 +12203,11 @@ var preferWholeObjectAssertionDocumentation = {
|
|
|
12016
12203
|
};
|
|
12017
12204
|
function literalText(node, getText) {
|
|
12018
12205
|
switch (node.type) {
|
|
12019
|
-
case
|
|
12206
|
+
case import_utils61.AST_NODE_TYPES.Literal:
|
|
12020
12207
|
return "regex" in node ? null : getText(node);
|
|
12021
|
-
case
|
|
12208
|
+
case import_utils61.AST_NODE_TYPES.TemplateLiteral:
|
|
12022
12209
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
12023
|
-
case
|
|
12210
|
+
case import_utils61.AST_NODE_TYPES.UnaryExpression:
|
|
12024
12211
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
12025
12212
|
default:
|
|
12026
12213
|
return null;
|
|
@@ -12028,15 +12215,15 @@ function literalText(node, getText) {
|
|
|
12028
12215
|
}
|
|
12029
12216
|
function isPureReceiver(node) {
|
|
12030
12217
|
switch (node.type) {
|
|
12031
|
-
case
|
|
12032
|
-
case
|
|
12218
|
+
case import_utils61.AST_NODE_TYPES.Identifier:
|
|
12219
|
+
case import_utils61.AST_NODE_TYPES.ThisExpression:
|
|
12033
12220
|
return true;
|
|
12034
|
-
case
|
|
12221
|
+
case import_utils61.AST_NODE_TYPES.MemberExpression:
|
|
12035
12222
|
if (node.optional) {
|
|
12036
12223
|
return false;
|
|
12037
12224
|
}
|
|
12038
12225
|
if (node.computed) {
|
|
12039
|
-
return node.property.type ===
|
|
12226
|
+
return node.property.type === import_utils61.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
12040
12227
|
}
|
|
12041
12228
|
return isPureReceiver(node.object);
|
|
12042
12229
|
default:
|
|
@@ -12044,7 +12231,7 @@ function isPureReceiver(node) {
|
|
|
12044
12231
|
}
|
|
12045
12232
|
}
|
|
12046
12233
|
function literalIndex(node) {
|
|
12047
|
-
if (node.type !==
|
|
12234
|
+
if (node.type !== import_utils61.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
12048
12235
|
return null;
|
|
12049
12236
|
}
|
|
12050
12237
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -12071,24 +12258,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12071
12258
|
}
|
|
12072
12259
|
const { sourceCode } = context;
|
|
12073
12260
|
function parseAssertion(statement) {
|
|
12074
|
-
if (statement.type !==
|
|
12261
|
+
if (statement.type !== import_utils61.AST_NODE_TYPES.ExpressionStatement) {
|
|
12075
12262
|
return null;
|
|
12076
12263
|
}
|
|
12077
12264
|
const call = statement.expression;
|
|
12078
|
-
if (call.type !==
|
|
12265
|
+
if (call.type !== import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
12079
12266
|
return null;
|
|
12080
12267
|
}
|
|
12081
12268
|
const callee = call.callee;
|
|
12082
|
-
if (callee.type !==
|
|
12269
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
12083
12270
|
return null;
|
|
12084
12271
|
}
|
|
12085
12272
|
const matcher = callee.property.name;
|
|
12086
12273
|
const expectCall = callee.object;
|
|
12087
|
-
if (expectCall.type !==
|
|
12274
|
+
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
12275
|
return null;
|
|
12089
12276
|
}
|
|
12090
12277
|
const actual = expectCall.arguments[0];
|
|
12091
|
-
if (actual === void 0 || actual.type !==
|
|
12278
|
+
if (actual === void 0 || actual.type !== import_utils61.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
12092
12279
|
return null;
|
|
12093
12280
|
}
|
|
12094
12281
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -12102,7 +12289,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12102
12289
|
}
|
|
12103
12290
|
key = { kind: "index", index };
|
|
12104
12291
|
} else {
|
|
12105
|
-
if (actual.property.type !==
|
|
12292
|
+
if (actual.property.type !== import_utils61.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
12106
12293
|
return null;
|
|
12107
12294
|
}
|
|
12108
12295
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -12115,7 +12302,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12115
12302
|
return null;
|
|
12116
12303
|
}
|
|
12117
12304
|
const expected = call.arguments[0];
|
|
12118
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
12305
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils61.AST_NODE_TYPES.SpreadElement) {
|
|
12119
12306
|
return null;
|
|
12120
12307
|
}
|
|
12121
12308
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -12230,7 +12417,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
12230
12417
|
});
|
|
12231
12418
|
|
|
12232
12419
|
// src/rules/prefer-zod-infer.ts
|
|
12233
|
-
var
|
|
12420
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
12234
12421
|
var preferZodInferDocumentation = {
|
|
12235
12422
|
summary: "Derive a type from its Zod schema with `z.infer` instead of hand-writing a twin declaration beside it.",
|
|
12236
12423
|
rationale: "A derived type stays synchronized when the runtime schema changes.",
|
|
@@ -12283,47 +12470,47 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
12283
12470
|
"Schema"
|
|
12284
12471
|
]);
|
|
12285
12472
|
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: [
|
|
12473
|
+
string: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12474
|
+
email: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12475
|
+
url: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12476
|
+
uuid: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12477
|
+
ulid: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12478
|
+
cuid: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12479
|
+
cuid2: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12480
|
+
nanoid: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12481
|
+
iso: [import_utils62.AST_NODE_TYPES.TSStringKeyword],
|
|
12482
|
+
number: [import_utils62.AST_NODE_TYPES.TSNumberKeyword],
|
|
12483
|
+
int: [import_utils62.AST_NODE_TYPES.TSNumberKeyword],
|
|
12484
|
+
float32: [import_utils62.AST_NODE_TYPES.TSNumberKeyword],
|
|
12485
|
+
float64: [import_utils62.AST_NODE_TYPES.TSNumberKeyword],
|
|
12486
|
+
boolean: [import_utils62.AST_NODE_TYPES.TSBooleanKeyword],
|
|
12487
|
+
bigint: [import_utils62.AST_NODE_TYPES.TSBigIntKeyword],
|
|
12488
|
+
symbol: [import_utils62.AST_NODE_TYPES.TSSymbolKeyword],
|
|
12489
|
+
any: [import_utils62.AST_NODE_TYPES.TSAnyKeyword],
|
|
12490
|
+
unknown: [import_utils62.AST_NODE_TYPES.TSUnknownKeyword],
|
|
12491
|
+
never: [import_utils62.AST_NODE_TYPES.TSNeverKeyword],
|
|
12492
|
+
void: [import_utils62.AST_NODE_TYPES.TSVoidKeyword],
|
|
12493
|
+
null: [import_utils62.AST_NODE_TYPES.TSNullKeyword],
|
|
12494
|
+
undefined: [import_utils62.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
12495
|
+
literal: [import_utils62.AST_NODE_TYPES.TSLiteralType],
|
|
12496
|
+
date: [import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12497
|
+
array: [import_utils62.AST_NODE_TYPES.TSArrayType, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12498
|
+
tuple: [import_utils62.AST_NODE_TYPES.TSTupleType],
|
|
12499
|
+
object: [import_utils62.AST_NODE_TYPES.TSTypeLiteral, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12500
|
+
strictObject: [import_utils62.AST_NODE_TYPES.TSTypeLiteral, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12501
|
+
looseObject: [import_utils62.AST_NODE_TYPES.TSTypeLiteral, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12502
|
+
record: [import_utils62.AST_NODE_TYPES.TSTypeReference, import_utils62.AST_NODE_TYPES.TSTypeLiteral],
|
|
12503
|
+
map: [import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12504
|
+
set: [import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12505
|
+
promise: [import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12506
|
+
enum: [import_utils62.AST_NODE_TYPES.TSUnionType, import_utils62.AST_NODE_TYPES.TSTypeReference, import_utils62.AST_NODE_TYPES.TSLiteralType],
|
|
12507
|
+
nativeEnum: [import_utils62.AST_NODE_TYPES.TSUnionType, import_utils62.AST_NODE_TYPES.TSTypeReference, import_utils62.AST_NODE_TYPES.TSLiteralType],
|
|
12508
|
+
union: [import_utils62.AST_NODE_TYPES.TSUnionType, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12509
|
+
discriminatedUnion: [import_utils62.AST_NODE_TYPES.TSUnionType, import_utils62.AST_NODE_TYPES.TSTypeReference],
|
|
12510
|
+
intersection: [import_utils62.AST_NODE_TYPES.TSIntersectionType, import_utils62.AST_NODE_TYPES.TSTypeReference]
|
|
12324
12511
|
};
|
|
12325
12512
|
function primitiveLiteralKey(node) {
|
|
12326
|
-
if (node.type !==
|
|
12513
|
+
if (node.type !== import_utils62.AST_NODE_TYPES.Literal) {
|
|
12327
12514
|
return null;
|
|
12328
12515
|
}
|
|
12329
12516
|
if (node.value === null) {
|
|
@@ -12355,13 +12542,13 @@ function staticZodDomain(leaf, call) {
|
|
|
12355
12542
|
}
|
|
12356
12543
|
if (leaf === "literal") {
|
|
12357
12544
|
const [argument] = call.arguments;
|
|
12358
|
-
if (argument === void 0 || argument.type ===
|
|
12545
|
+
if (argument === void 0 || argument.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12359
12546
|
return null;
|
|
12360
12547
|
}
|
|
12361
|
-
if (argument.type ===
|
|
12548
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ArrayExpression) {
|
|
12362
12549
|
return exactDomain(
|
|
12363
12550
|
argument.elements.map(
|
|
12364
|
-
(element) => element === null || element.type ===
|
|
12551
|
+
(element) => element === null || element.type === import_utils62.AST_NODE_TYPES.SpreadElement ? null : primitiveLiteralKey(element)
|
|
12365
12552
|
)
|
|
12366
12553
|
);
|
|
12367
12554
|
}
|
|
@@ -12369,13 +12556,13 @@ function staticZodDomain(leaf, call) {
|
|
|
12369
12556
|
}
|
|
12370
12557
|
if (leaf === "enum") {
|
|
12371
12558
|
const [argument] = call.arguments;
|
|
12372
|
-
if (argument === void 0 || argument.type ===
|
|
12559
|
+
if (argument === void 0 || argument.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12373
12560
|
return null;
|
|
12374
12561
|
}
|
|
12375
|
-
if (argument.type ===
|
|
12562
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ArrayExpression) {
|
|
12376
12563
|
return exactDomain(
|
|
12377
12564
|
argument.elements.map((element) => {
|
|
12378
|
-
if (element === null || element.type ===
|
|
12565
|
+
if (element === null || element.type === import_utils62.AST_NODE_TYPES.SpreadElement) {
|
|
12379
12566
|
return null;
|
|
12380
12567
|
}
|
|
12381
12568
|
const key = primitiveLiteralKey(element);
|
|
@@ -12383,10 +12570,10 @@ function staticZodDomain(leaf, call) {
|
|
|
12383
12570
|
})
|
|
12384
12571
|
);
|
|
12385
12572
|
}
|
|
12386
|
-
if (argument.type ===
|
|
12573
|
+
if (argument.type === import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
12387
12574
|
return exactDomain(
|
|
12388
12575
|
argument.properties.map((property) => {
|
|
12389
|
-
if (property.type !==
|
|
12576
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
12390
12577
|
return null;
|
|
12391
12578
|
}
|
|
12392
12579
|
const key = primitiveLiteralKey(property.value);
|
|
@@ -12413,15 +12600,15 @@ function sameDomain(left, right) {
|
|
|
12413
12600
|
return true;
|
|
12414
12601
|
}
|
|
12415
12602
|
function isExportedDeclaration(node) {
|
|
12416
|
-
return node.parent?.type ===
|
|
12603
|
+
return node.parent?.type === import_utils62.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
12417
12604
|
}
|
|
12418
12605
|
function isModuleLevelConst(node) {
|
|
12419
12606
|
const declaration = node.parent;
|
|
12420
|
-
if (declaration.type !==
|
|
12607
|
+
if (declaration.type !== import_utils62.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const") {
|
|
12421
12608
|
return false;
|
|
12422
12609
|
}
|
|
12423
12610
|
const container = declaration.parent;
|
|
12424
|
-
return container.type ===
|
|
12611
|
+
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
12612
|
}
|
|
12426
12613
|
function normalizeSchemaName(name) {
|
|
12427
12614
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -12430,20 +12617,20 @@ function normalizeTypeName(name) {
|
|
|
12430
12617
|
return name.replace(/Type$/, "").toLowerCase();
|
|
12431
12618
|
}
|
|
12432
12619
|
function unwrapNullish(annotation) {
|
|
12433
|
-
if (annotation.type !==
|
|
12620
|
+
if (annotation.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12434
12621
|
return {
|
|
12435
12622
|
core: annotation,
|
|
12436
|
-
nullable: annotation.type ===
|
|
12623
|
+
nullable: annotation.type === import_utils62.AST_NODE_TYPES.TSNullKeyword
|
|
12437
12624
|
};
|
|
12438
12625
|
}
|
|
12439
12626
|
const rest = [];
|
|
12440
12627
|
let nullable = false;
|
|
12441
12628
|
for (const member of annotation.types) {
|
|
12442
|
-
if (member.type ===
|
|
12629
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSNullKeyword) {
|
|
12443
12630
|
nullable = true;
|
|
12444
12631
|
continue;
|
|
12445
12632
|
}
|
|
12446
|
-
if (member.type ===
|
|
12633
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
12447
12634
|
continue;
|
|
12448
12635
|
}
|
|
12449
12636
|
rest.push(member);
|
|
@@ -12477,18 +12664,18 @@ function leafAgrees(field, annotation) {
|
|
|
12477
12664
|
return null;
|
|
12478
12665
|
}
|
|
12479
12666
|
if (leaf === "date") {
|
|
12480
|
-
return core.type ===
|
|
12667
|
+
return core.type === import_utils62.AST_NODE_TYPES.TSTypeReference && core.typeName.type === import_utils62.AST_NODE_TYPES.Identifier && core.typeName.name === "Date";
|
|
12481
12668
|
}
|
|
12482
12669
|
return expected.includes(core.type);
|
|
12483
12670
|
}
|
|
12484
12671
|
function typeLiteralDomain(annotation) {
|
|
12485
|
-
const members = annotation.type ===
|
|
12672
|
+
const members = annotation.type === import_utils62.AST_NODE_TYPES.TSUnionType ? annotation.types : [annotation];
|
|
12486
12673
|
const keys = [];
|
|
12487
12674
|
for (const member of members) {
|
|
12488
|
-
if (member.type ===
|
|
12675
|
+
if (member.type === import_utils62.AST_NODE_TYPES.TSNullKeyword) {
|
|
12489
12676
|
continue;
|
|
12490
12677
|
}
|
|
12491
|
-
if (member.type !==
|
|
12678
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSLiteralType) {
|
|
12492
12679
|
return null;
|
|
12493
12680
|
}
|
|
12494
12681
|
keys.push(primitiveLiteralKey(member.literal));
|
|
@@ -12496,11 +12683,11 @@ function typeLiteralDomain(annotation) {
|
|
|
12496
12683
|
return exactDomain(keys);
|
|
12497
12684
|
}
|
|
12498
12685
|
function staticStringUnionDomain(node) {
|
|
12499
|
-
if (node.type !==
|
|
12686
|
+
if (node.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12500
12687
|
return null;
|
|
12501
12688
|
}
|
|
12502
12689
|
const keys = node.types.map((member) => {
|
|
12503
|
-
if (member.type !==
|
|
12690
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSLiteralType) {
|
|
12504
12691
|
return null;
|
|
12505
12692
|
}
|
|
12506
12693
|
const key = primitiveLiteralKey(member.literal);
|
|
@@ -12568,14 +12755,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
12568
12755
|
function zodCallChain(node) {
|
|
12569
12756
|
const chain = [];
|
|
12570
12757
|
let current = node;
|
|
12571
|
-
while (current.type ===
|
|
12758
|
+
while (current.type === import_utils62.AST_NODE_TYPES.CallExpression) {
|
|
12572
12759
|
const callee = current.callee;
|
|
12573
|
-
if (callee.type !==
|
|
12760
|
+
if (callee.type !== import_utils62.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12574
12761
|
return null;
|
|
12575
12762
|
}
|
|
12576
12763
|
chain.push(current);
|
|
12577
12764
|
const receiver = callee.object;
|
|
12578
|
-
if (receiver.type ===
|
|
12765
|
+
if (receiver.type === import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12579
12766
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
12580
12767
|
}
|
|
12581
12768
|
current = receiver;
|
|
@@ -12584,14 +12771,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
12584
12771
|
}
|
|
12585
12772
|
function methodName2(call) {
|
|
12586
12773
|
const callee = call.callee;
|
|
12587
|
-
return callee.type ===
|
|
12774
|
+
return callee.type === import_utils62.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils62.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
12588
12775
|
}
|
|
12589
12776
|
function recordZodImport(node) {
|
|
12590
12777
|
if (!isZodModule(node.source.value)) {
|
|
12591
12778
|
return;
|
|
12592
12779
|
}
|
|
12593
12780
|
for (const specifier of node.specifiers) {
|
|
12594
|
-
if (specifier.type ===
|
|
12781
|
+
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
12782
|
zodNamespaces.add(specifier.local.name);
|
|
12596
12783
|
}
|
|
12597
12784
|
}
|
|
@@ -12601,13 +12788,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
12601
12788
|
let current = node;
|
|
12602
12789
|
let leaf = null;
|
|
12603
12790
|
let leafCall = null;
|
|
12604
|
-
while (current.type ===
|
|
12791
|
+
while (current.type === import_utils62.AST_NODE_TYPES.CallExpression) {
|
|
12605
12792
|
const callee = current.callee;
|
|
12606
|
-
if (callee.type !==
|
|
12793
|
+
if (callee.type !== import_utils62.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12607
12794
|
break;
|
|
12608
12795
|
}
|
|
12609
12796
|
const receiver = callee.object;
|
|
12610
|
-
if (receiver.type ===
|
|
12797
|
+
if (receiver.type === import_utils62.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
12611
12798
|
leaf = callee.property.name;
|
|
12612
12799
|
leafCall = current;
|
|
12613
12800
|
break;
|
|
@@ -12638,20 +12825,20 @@ var prefer_zod_infer_default = createRule({
|
|
|
12638
12825
|
return domain instanceof Set && domain.size >= 2 ? domain : null;
|
|
12639
12826
|
}
|
|
12640
12827
|
function inferredSchemaName(node) {
|
|
12641
|
-
if (node.type !==
|
|
12828
|
+
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
12829
|
return null;
|
|
12643
12830
|
}
|
|
12644
12831
|
const arguments_ = node.typeArguments?.params ?? [];
|
|
12645
12832
|
const [argument] = arguments_;
|
|
12646
|
-
return arguments_.length === 1 && argument?.type ===
|
|
12833
|
+
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
12834
|
}
|
|
12648
12835
|
function recordLiteralUnions(members, owner, ownerName, exported) {
|
|
12649
12836
|
for (const member of members) {
|
|
12650
|
-
if (member.type !==
|
|
12837
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSPropertySignature || member.computed || member.optional || member.readonly || member.typeAnnotation === void 0) {
|
|
12651
12838
|
continue;
|
|
12652
12839
|
}
|
|
12653
12840
|
const key = member.key;
|
|
12654
|
-
const propertyName3 = key.type ===
|
|
12841
|
+
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
12842
|
if (propertyName3 === null) {
|
|
12656
12843
|
continue;
|
|
12657
12844
|
}
|
|
@@ -12661,7 +12848,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12661
12848
|
}
|
|
12662
12849
|
const annotation = member.typeAnnotation.typeAnnotation;
|
|
12663
12850
|
const domain = staticStringUnionDomain(annotation);
|
|
12664
|
-
if (domain === null || annotation.type !==
|
|
12851
|
+
if (domain === null || annotation.type !== import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
12665
12852
|
continue;
|
|
12666
12853
|
}
|
|
12667
12854
|
literalUnionOccurrences.push({
|
|
@@ -12692,16 +12879,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
12692
12879
|
return null;
|
|
12693
12880
|
}
|
|
12694
12881
|
const shape = base.arguments[0];
|
|
12695
|
-
if (shape === void 0 || shape.type !==
|
|
12882
|
+
if (shape === void 0 || shape.type !== import_utils62.AST_NODE_TYPES.ObjectExpression) {
|
|
12696
12883
|
return null;
|
|
12697
12884
|
}
|
|
12698
12885
|
const fields = /* @__PURE__ */ new Map();
|
|
12699
12886
|
for (const property of shape.properties) {
|
|
12700
|
-
if (property.type !==
|
|
12887
|
+
if (property.type !== import_utils62.AST_NODE_TYPES.Property || property.computed) {
|
|
12701
12888
|
return null;
|
|
12702
12889
|
}
|
|
12703
12890
|
const { key } = property;
|
|
12704
|
-
const name = key.type ===
|
|
12891
|
+
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
12892
|
if (name === null) {
|
|
12706
12893
|
return null;
|
|
12707
12894
|
}
|
|
@@ -12712,11 +12899,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
12712
12899
|
function typeMembers(members) {
|
|
12713
12900
|
const result = /* @__PURE__ */ new Map();
|
|
12714
12901
|
for (const member of members) {
|
|
12715
|
-
if (member.type !==
|
|
12902
|
+
if (member.type !== import_utils62.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
12716
12903
|
return null;
|
|
12717
12904
|
}
|
|
12718
12905
|
const { key } = member;
|
|
12719
|
-
const name = key.type ===
|
|
12906
|
+
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
12907
|
if (name === null) {
|
|
12721
12908
|
return null;
|
|
12722
12909
|
}
|
|
@@ -12731,8 +12918,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
12731
12918
|
return result.size === 0 ? null : result;
|
|
12732
12919
|
}
|
|
12733
12920
|
function collectConstrainedNames(node) {
|
|
12734
|
-
if (node.type ===
|
|
12735
|
-
if (node.typeName.type ===
|
|
12921
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSTypeReference) {
|
|
12922
|
+
if (node.typeName.type === import_utils62.AST_NODE_TYPES.Identifier) {
|
|
12736
12923
|
constrainedTypeNames.add(node.typeName.name);
|
|
12737
12924
|
}
|
|
12738
12925
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -12740,11 +12927,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
12740
12927
|
}
|
|
12741
12928
|
return;
|
|
12742
12929
|
}
|
|
12743
|
-
if (node.type ===
|
|
12930
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSArrayType) {
|
|
12744
12931
|
collectConstrainedNames(node.elementType);
|
|
12745
12932
|
return;
|
|
12746
12933
|
}
|
|
12747
|
-
if (node.type ===
|
|
12934
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSUnionType || node.type === import_utils62.AST_NODE_TYPES.TSIntersectionType) {
|
|
12748
12935
|
for (const member of node.types) {
|
|
12749
12936
|
collectConstrainedNames(member);
|
|
12750
12937
|
}
|
|
@@ -12788,7 +12975,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12788
12975
|
return {
|
|
12789
12976
|
Program(node) {
|
|
12790
12977
|
for (const statement of node.body) {
|
|
12791
|
-
if (statement.type ===
|
|
12978
|
+
if (statement.type === import_utils62.AST_NODE_TYPES.ImportDeclaration) {
|
|
12792
12979
|
recordZodImport(statement);
|
|
12793
12980
|
}
|
|
12794
12981
|
}
|
|
@@ -12797,7 +12984,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12797
12984
|
recordZodImport(node);
|
|
12798
12985
|
},
|
|
12799
12986
|
VariableDeclarator(node) {
|
|
12800
|
-
if (node.id.type !==
|
|
12987
|
+
if (node.id.type !== import_utils62.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
12801
12988
|
return;
|
|
12802
12989
|
}
|
|
12803
12990
|
const fields = schemaFields(node.init);
|
|
@@ -12814,14 +13001,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
12814
13001
|
},
|
|
12815
13002
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
12816
13003
|
"MemberExpression[computed=false]"(node) {
|
|
12817
|
-
if (node.object.type ===
|
|
13004
|
+
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
13005
|
reshapedSchemaNames.add(node.object.name);
|
|
12819
13006
|
}
|
|
12820
13007
|
},
|
|
12821
13008
|
/** Records every type argument carried by a Zod constraint. */
|
|
12822
13009
|
TSTypeReference(node) {
|
|
12823
13010
|
const { typeName } = node;
|
|
12824
|
-
const referenced = typeName.type ===
|
|
13011
|
+
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
13012
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
12826
13013
|
return;
|
|
12827
13014
|
}
|
|
@@ -12853,7 +13040,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12853
13040
|
typeName: node.id.name
|
|
12854
13041
|
});
|
|
12855
13042
|
}
|
|
12856
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
13043
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
12857
13044
|
return;
|
|
12858
13045
|
}
|
|
12859
13046
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -12952,7 +13139,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
12952
13139
|
});
|
|
12953
13140
|
|
|
12954
13141
|
// src/rules/require-assert-never.ts
|
|
12955
|
-
var
|
|
13142
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
12956
13143
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
12957
13144
|
var requireAssertNeverDocumentation = {
|
|
12958
13145
|
summary: "Require an empty switch default to call `assertNever` so discriminated unions remain exhaustive at compile time.",
|
|
@@ -12965,14 +13152,14 @@ var requireAssertNeverDocumentation = {
|
|
|
12965
13152
|
]
|
|
12966
13153
|
};
|
|
12967
13154
|
var isRuntimeHandlingStatement = (statement) => {
|
|
12968
|
-
if (statement.type ===
|
|
12969
|
-
if (statement.type ===
|
|
13155
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.EmptyStatement) return false;
|
|
13156
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.BreakStatement) {
|
|
12970
13157
|
return statement.label !== null;
|
|
12971
13158
|
}
|
|
12972
|
-
if (statement.type ===
|
|
13159
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.TSTypeAliasDeclaration || statement.type === import_utils63.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
12973
13160
|
return false;
|
|
12974
13161
|
}
|
|
12975
|
-
if (statement.type ===
|
|
13162
|
+
if (statement.type === import_utils63.AST_NODE_TYPES.BlockStatement) {
|
|
12976
13163
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
12977
13164
|
}
|
|
12978
13165
|
return true;
|
|
@@ -12988,7 +13175,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
12988
13175
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
12989
13176
|
}
|
|
12990
13177
|
const only = defaultCase.consequent[0];
|
|
12991
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
13178
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils63.AST_NODE_TYPES.BlockStatement && !only.body.some(isRuntimeHandlingStatement)) {
|
|
12992
13179
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
12993
13180
|
}
|
|
12994
13181
|
return false;
|
|
@@ -13044,7 +13231,7 @@ var require_assert_never_default = createRule({
|
|
|
13044
13231
|
create(context) {
|
|
13045
13232
|
let services;
|
|
13046
13233
|
try {
|
|
13047
|
-
services =
|
|
13234
|
+
services = import_utils63.ESLintUtils.getParserServices(context);
|
|
13048
13235
|
} catch {
|
|
13049
13236
|
services = null;
|
|
13050
13237
|
}
|
|
@@ -13071,7 +13258,7 @@ var require_assert_never_default = createRule({
|
|
|
13071
13258
|
});
|
|
13072
13259
|
|
|
13073
13260
|
// src/rules/require-fetch-timeout.ts
|
|
13074
|
-
var
|
|
13261
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
13075
13262
|
var requireFetchTimeoutDocumentation = {
|
|
13076
13263
|
summary: "Require an abort `signal` (e.g. `AbortSignal.timeout(ms)`) on global `fetch()` calls so stalled upstreams cannot hang the caller forever.",
|
|
13077
13264
|
rationale: "An unbounded request can occupy work indefinitely when an upstream stalls.",
|
|
@@ -13097,14 +13284,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
13097
13284
|
return false;
|
|
13098
13285
|
}
|
|
13099
13286
|
function initProvablyLacksSignal(init) {
|
|
13100
|
-
if (init.type !==
|
|
13287
|
+
if (init.type !== import_utils64.AST_NODE_TYPES.ObjectExpression) {
|
|
13101
13288
|
return false;
|
|
13102
13289
|
}
|
|
13103
13290
|
for (const prop of init.properties) {
|
|
13104
|
-
if (prop.type ===
|
|
13291
|
+
if (prop.type === import_utils64.AST_NODE_TYPES.SpreadElement) {
|
|
13105
13292
|
return false;
|
|
13106
13293
|
}
|
|
13107
|
-
if (prop.key.type ===
|
|
13294
|
+
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
13295
|
return false;
|
|
13109
13296
|
}
|
|
13110
13297
|
if (prop.computed) {
|
|
@@ -13114,7 +13301,7 @@ function initProvablyLacksSignal(init) {
|
|
|
13114
13301
|
return true;
|
|
13115
13302
|
}
|
|
13116
13303
|
function isInlineUrl(node, resolvesToGlobal) {
|
|
13117
|
-
return node.type ===
|
|
13304
|
+
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
13305
|
}
|
|
13119
13306
|
var require_fetch_timeout_default = createRule({
|
|
13120
13307
|
name: "require-fetch-timeout",
|
|
@@ -13152,30 +13339,30 @@ var require_fetch_timeout_default = createRule({
|
|
|
13152
13339
|
}
|
|
13153
13340
|
function resolvesToGlobal(identifier) {
|
|
13154
13341
|
const scope = context.sourceCode.getScope(identifier);
|
|
13155
|
-
const variable =
|
|
13342
|
+
const variable = import_utils64.ASTUtils.findVariable(scope, identifier.name);
|
|
13156
13343
|
return variable === null || variable.defs.length === 0;
|
|
13157
13344
|
}
|
|
13158
13345
|
function isGlobalFetchCall2(callee) {
|
|
13159
|
-
if (callee.type ===
|
|
13346
|
+
if (callee.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
13160
13347
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
13161
13348
|
}
|
|
13162
|
-
return callee.type ===
|
|
13349
|
+
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
13350
|
}
|
|
13164
13351
|
function localConstInitProvablyLacksSignal(identifier) {
|
|
13165
|
-
const variable =
|
|
13352
|
+
const variable = import_utils64.ASTUtils.findVariable(
|
|
13166
13353
|
context.sourceCode.getScope(identifier),
|
|
13167
13354
|
identifier.name
|
|
13168
13355
|
);
|
|
13169
13356
|
if (variable?.defs.length !== 1) return false;
|
|
13170
13357
|
const definition = variable.defs[0];
|
|
13171
|
-
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !==
|
|
13358
|
+
if (definition?.type !== "Variable" || definition.parent.kind !== "const" || definition.node.init?.type !== import_utils64.AST_NODE_TYPES.ObjectExpression || !initProvablyLacksSignal(definition.node.init)) {
|
|
13172
13359
|
return false;
|
|
13173
13360
|
}
|
|
13174
13361
|
for (const reference of variable.references) {
|
|
13175
13362
|
const ref = reference.identifier;
|
|
13176
13363
|
if (ref === identifier || ref === definition.name) continue;
|
|
13177
13364
|
const member = ref.parent;
|
|
13178
|
-
if (member.type !==
|
|
13365
|
+
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
13366
|
return false;
|
|
13180
13367
|
}
|
|
13181
13368
|
}
|
|
@@ -13190,7 +13377,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
13190
13377
|
if (node.arguments.length === 1 && first !== void 0 && !isInlineUrl(first, resolvesToGlobal)) {
|
|
13191
13378
|
return;
|
|
13192
13379
|
}
|
|
13193
|
-
if (init === void 0 || initProvablyLacksSignal(init) || init.type ===
|
|
13380
|
+
if (init === void 0 || initProvablyLacksSignal(init) || init.type === import_utils64.AST_NODE_TYPES.Identifier && localConstInitProvablyLacksSignal(init)) {
|
|
13194
13381
|
context.report({ node, messageId: "missingSignal" });
|
|
13195
13382
|
}
|
|
13196
13383
|
}
|
|
@@ -13199,7 +13386,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
13199
13386
|
});
|
|
13200
13387
|
|
|
13201
13388
|
// src/rules/require-port-for-service.ts
|
|
13202
|
-
var
|
|
13389
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
13203
13390
|
var requirePortForServiceDocumentation = {
|
|
13204
13391
|
summary: "Advise when an exported service with injected collaborators has public methods not covered by its declared ports.",
|
|
13205
13392
|
rationale: "A declared port keeps consumers coupled to the service capability instead of its concrete implementation.",
|
|
@@ -13224,45 +13411,45 @@ var ROUTER_FACTORY_NAME = "Router";
|
|
|
13224
13411
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
13225
13412
|
var STORAGE_ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set(["=", "&&=", "??=", "||="]);
|
|
13226
13413
|
var staticMemberName4 = (member) => {
|
|
13227
|
-
if (member.property.type ===
|
|
13228
|
-
if (!member.computed && member.property.type ===
|
|
13229
|
-
return member.computed && member.property.type ===
|
|
13414
|
+
if (member.property.type === import_utils65.AST_NODE_TYPES.PrivateIdentifier) return `#${member.property.name}`;
|
|
13415
|
+
if (!member.computed && member.property.type === import_utils65.AST_NODE_TYPES.Identifier) return member.property.name;
|
|
13416
|
+
return member.computed && member.property.type === import_utils65.AST_NODE_TYPES.Literal && typeof member.property.value === "string" ? member.property.value : null;
|
|
13230
13417
|
};
|
|
13231
13418
|
var detachedValueExports = (program) => {
|
|
13232
13419
|
const names = /* @__PURE__ */ new Set();
|
|
13233
13420
|
for (const statement of program.body) {
|
|
13234
|
-
if (statement.type ===
|
|
13421
|
+
if (statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration === null && statement.source === null && statement.exportKind !== "type") {
|
|
13235
13422
|
for (const specifier of statement.specifiers) {
|
|
13236
13423
|
if (specifier.exportKind !== "type") names.add(specifier.local.name);
|
|
13237
13424
|
}
|
|
13238
|
-
} else if (statement.type ===
|
|
13425
|
+
} else if (statement.type === import_utils65.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13239
13426
|
names.add(statement.declaration.name);
|
|
13240
|
-
} else if (statement.type ===
|
|
13427
|
+
} else if (statement.type === import_utils65.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13241
13428
|
names.add(statement.expression.name);
|
|
13242
13429
|
}
|
|
13243
13430
|
}
|
|
13244
13431
|
return names;
|
|
13245
13432
|
};
|
|
13246
|
-
var isExportedClass2 = (node, detached) => node.parent.type ===
|
|
13433
|
+
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
13434
|
var readTypeReference = (annotation) => {
|
|
13248
|
-
if (annotation?.type ===
|
|
13435
|
+
if (annotation?.type === import_utils65.AST_NODE_TYPES.TSUnionType) {
|
|
13249
13436
|
const members = annotation.types.filter(
|
|
13250
|
-
(member) => member.type !==
|
|
13437
|
+
(member) => member.type !== import_utils65.AST_NODE_TYPES.TSUndefinedKeyword && member.type !== import_utils65.AST_NODE_TYPES.TSNullKeyword
|
|
13251
13438
|
);
|
|
13252
13439
|
annotation = members.length === 1 ? members[0] : void 0;
|
|
13253
13440
|
}
|
|
13254
|
-
if (annotation === void 0 || annotation.type !==
|
|
13441
|
+
if (annotation === void 0 || annotation.type !== import_utils65.AST_NODE_TYPES.TSTypeReference) return null;
|
|
13255
13442
|
const { typeName } = annotation;
|
|
13256
|
-
const rightmost = typeName.type ===
|
|
13443
|
+
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
13444
|
if (rightmost === null) return null;
|
|
13258
13445
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
13259
13446
|
};
|
|
13260
|
-
var qualifiedName = (name) => name.type ===
|
|
13447
|
+
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
13448
|
var propertySignatureTypes = (members) => {
|
|
13262
13449
|
const types = /* @__PURE__ */ new Map();
|
|
13263
13450
|
for (const member of members) {
|
|
13264
|
-
if (member.type !==
|
|
13265
|
-
if (member.computed || member.key.type !==
|
|
13451
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13452
|
+
if (member.computed || member.key.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13266
13453
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
13267
13454
|
if (reference === null) continue;
|
|
13268
13455
|
types.set(member.key.name, reference);
|
|
@@ -13273,18 +13460,18 @@ var fileTypeIndex = (program) => {
|
|
|
13273
13460
|
const objects = /* @__PURE__ */ new Map();
|
|
13274
13461
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
13275
13462
|
for (const statement of program.body) {
|
|
13276
|
-
const declaration = statement.type ===
|
|
13277
|
-
if (declaration?.type ===
|
|
13463
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
13464
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
13278
13465
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
13279
13466
|
continue;
|
|
13280
13467
|
}
|
|
13281
|
-
if (declaration?.type !==
|
|
13468
|
+
if (declaration?.type !== import_utils65.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
13282
13469
|
const aliased = declaration.typeAnnotation;
|
|
13283
|
-
if (aliased.type ===
|
|
13470
|
+
if (aliased.type === import_utils65.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils65.AST_NODE_TYPES.TSConstructorType) {
|
|
13284
13471
|
functionAliases.add(declaration.id.name);
|
|
13285
13472
|
continue;
|
|
13286
13473
|
}
|
|
13287
|
-
const literals = aliased.type ===
|
|
13474
|
+
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
13475
|
if (literals.length === 0) continue;
|
|
13289
13476
|
const merged = /* @__PURE__ */ new Map();
|
|
13290
13477
|
for (const literal of literals) {
|
|
@@ -13312,10 +13499,10 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13312
13499
|
while (pending.length > 0) {
|
|
13313
13500
|
const current = pending.pop();
|
|
13314
13501
|
if (current === void 0) break;
|
|
13315
|
-
if (current.type ===
|
|
13316
|
-
const expression = current.type ===
|
|
13317
|
-
const storedField = expression?.type ===
|
|
13318
|
-
if (expression?.type !==
|
|
13502
|
+
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;
|
|
13503
|
+
const expression = current.type === import_utils65.AST_NODE_TYPES.ExpressionStatement ? current.expression : null;
|
|
13504
|
+
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;
|
|
13505
|
+
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
13506
|
for (const key of Object.keys(current)) {
|
|
13320
13507
|
if (key === "parent") continue;
|
|
13321
13508
|
const value = current[key];
|
|
@@ -13328,14 +13515,14 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13328
13515
|
continue;
|
|
13329
13516
|
}
|
|
13330
13517
|
let source = expression.right;
|
|
13331
|
-
while (source.type ===
|
|
13332
|
-
if (source.type ===
|
|
13518
|
+
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;
|
|
13519
|
+
if (source.type === import_utils65.AST_NODE_TYPES.NewExpression) {
|
|
13333
13520
|
constructedFields += 1;
|
|
13334
|
-
} else if (source.type ===
|
|
13521
|
+
} else if (source.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13335
13522
|
const fields = storedFieldsFrom.get(source.name) ?? /* @__PURE__ */ new Set();
|
|
13336
13523
|
fields.add(storedField);
|
|
13337
13524
|
storedFieldsFrom.set(source.name, fields);
|
|
13338
|
-
} else if (source.type ===
|
|
13525
|
+
} else if (source.type === import_utils65.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13339
13526
|
const fields = storedFieldsFrom.get(source.object.name) ?? /* @__PURE__ */ new Set();
|
|
13340
13527
|
fields.add(storedField);
|
|
13341
13528
|
storedFieldsFrom.set(source.object.name, fields);
|
|
@@ -13345,7 +13532,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13345
13532
|
const collaborators = [];
|
|
13346
13533
|
for (const parameter of ctor.value.params) {
|
|
13347
13534
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
13348
|
-
const fields = parameter.type ===
|
|
13535
|
+
const fields = parameter.type === import_utils65.AST_NODE_TYPES.TSParameterProperty ? [reference.name] : [...storedFieldsFrom.get(reference.name) ?? []];
|
|
13349
13536
|
if (fields.length === 0) continue;
|
|
13350
13537
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
13351
13538
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -13360,8 +13547,8 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
13360
13547
|
};
|
|
13361
13548
|
var parameterCollaborators = (parameter, declared) => {
|
|
13362
13549
|
let target = parameter;
|
|
13363
|
-
if (target.type ===
|
|
13364
|
-
if (target.type ===
|
|
13550
|
+
if (target.type === import_utils65.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
13551
|
+
if (target.type === import_utils65.AST_NODE_TYPES.ObjectPattern) {
|
|
13365
13552
|
return objectPatternCollaborators(target, declared);
|
|
13366
13553
|
}
|
|
13367
13554
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -13369,9 +13556,9 @@ var parameterCollaborators = (parameter, declared) => {
|
|
|
13369
13556
|
};
|
|
13370
13557
|
var namedParameterCollaborator = (annotated) => {
|
|
13371
13558
|
let target = annotated;
|
|
13372
|
-
if (target.type ===
|
|
13373
|
-
if (target.type ===
|
|
13374
|
-
if (target.type !==
|
|
13559
|
+
if (target.type === import_utils65.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
13560
|
+
if (target.type === import_utils65.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
13561
|
+
if (target.type !== import_utils65.AST_NODE_TYPES.Identifier) return null;
|
|
13375
13562
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
13376
13563
|
if (reference === null) return null;
|
|
13377
13564
|
return { name: target.name, ...reference, fields: [] };
|
|
@@ -13383,11 +13570,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
13383
13570
|
if (members === null) return [];
|
|
13384
13571
|
const collaborators = [];
|
|
13385
13572
|
for (const property of pattern.properties) {
|
|
13386
|
-
if (property.type !==
|
|
13387
|
-
if (property.key.type !==
|
|
13573
|
+
if (property.type !== import_utils65.AST_NODE_TYPES.Property || property.computed) continue;
|
|
13574
|
+
if (property.key.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13388
13575
|
const key = property.key.name;
|
|
13389
|
-
const bound = property.value.type ===
|
|
13390
|
-
if (bound.type !==
|
|
13576
|
+
const bound = property.value.type === import_utils65.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
13577
|
+
if (bound.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13391
13578
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
13392
13579
|
const reference = members.get(key);
|
|
13393
13580
|
if (reference === void 0) continue;
|
|
@@ -13396,21 +13583,21 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
13396
13583
|
return collaborators;
|
|
13397
13584
|
};
|
|
13398
13585
|
var bagMemberTypes = (annotation, declared) => {
|
|
13399
|
-
if (annotation.type ===
|
|
13586
|
+
if (annotation.type === import_utils65.AST_NODE_TYPES.TSTypeLiteral) {
|
|
13400
13587
|
return propertySignatureTypes(annotation.members);
|
|
13401
13588
|
}
|
|
13402
|
-
if (annotation.type !==
|
|
13589
|
+
if (annotation.type !== import_utils65.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13403
13590
|
return null;
|
|
13404
13591
|
}
|
|
13405
13592
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
13406
13593
|
};
|
|
13407
13594
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
13408
|
-
if (node.type ===
|
|
13595
|
+
if (node.type === import_utils65.AST_NODE_TYPES.CallExpression) {
|
|
13409
13596
|
const { callee } = node;
|
|
13410
|
-
if (callee.type ===
|
|
13411
|
-
return callee.type ===
|
|
13597
|
+
if (callee.type === import_utils65.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
13598
|
+
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
13599
|
}
|
|
13413
|
-
return node.type ===
|
|
13600
|
+
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
13601
|
});
|
|
13415
13602
|
var subtreeHas = (root, found) => {
|
|
13416
13603
|
let hit = false;
|
|
@@ -13437,19 +13624,19 @@ var invokedInstanceField = (call) => {
|
|
|
13437
13624
|
const direct = instanceField(call.callee);
|
|
13438
13625
|
if (direct !== null) return direct;
|
|
13439
13626
|
let callee = call.callee;
|
|
13440
|
-
while (callee.type ===
|
|
13441
|
-
return callee.type ===
|
|
13627
|
+
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;
|
|
13628
|
+
return callee.type === import_utils65.AST_NODE_TYPES.MemberExpression ? instanceField(callee.object) : null;
|
|
13442
13629
|
};
|
|
13443
13630
|
var instanceField = (candidate) => {
|
|
13444
13631
|
let node = candidate;
|
|
13445
|
-
while (node.type ===
|
|
13446
|
-
return node.type ===
|
|
13632
|
+
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;
|
|
13633
|
+
return node.type === import_utils65.AST_NODE_TYPES.MemberExpression && node.object.type === import_utils65.AST_NODE_TYPES.ThisExpression ? staticMemberName4(node) : null;
|
|
13447
13634
|
};
|
|
13448
13635
|
var behaviorallyInvokedFields = (body2) => {
|
|
13449
13636
|
const invoked = /* @__PURE__ */ new Set();
|
|
13450
13637
|
const visit = (current) => {
|
|
13451
|
-
if (current.type ===
|
|
13452
|
-
if (current.type ===
|
|
13638
|
+
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;
|
|
13639
|
+
if (current.type === import_utils65.AST_NODE_TYPES.CallExpression) {
|
|
13453
13640
|
const field = invokedInstanceField(current);
|
|
13454
13641
|
if (field !== null) invoked.add(field);
|
|
13455
13642
|
}
|
|
@@ -13462,14 +13649,14 @@ var behaviorallyInvokedFields = (body2) => {
|
|
|
13462
13649
|
}
|
|
13463
13650
|
};
|
|
13464
13651
|
for (const member of body2.body) {
|
|
13465
|
-
if (member.type ===
|
|
13466
|
-
if (member.type ===
|
|
13652
|
+
if (member.type === import_utils65.AST_NODE_TYPES.StaticBlock || member.static) continue;
|
|
13653
|
+
if (member.type === import_utils65.AST_NODE_TYPES.MethodDefinition) {
|
|
13467
13654
|
if (member.value.body !== null && member.value.body !== void 0) visit(member.value.body);
|
|
13468
13655
|
continue;
|
|
13469
13656
|
}
|
|
13470
|
-
if (member.type !==
|
|
13657
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.PropertyDefinition || member.value === null) continue;
|
|
13471
13658
|
visit(
|
|
13472
|
-
member.value.type ===
|
|
13659
|
+
member.value.type === import_utils65.AST_NODE_TYPES.ArrowFunctionExpression ? member.value.body : member.value
|
|
13473
13660
|
);
|
|
13474
13661
|
}
|
|
13475
13662
|
return invoked;
|
|
@@ -13489,25 +13676,25 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
13489
13676
|
var fileInterfaceNames = (program) => {
|
|
13490
13677
|
const names = [];
|
|
13491
13678
|
for (const statement of program.body) {
|
|
13492
|
-
const declaration = statement.type ===
|
|
13493
|
-
if (declaration?.type ===
|
|
13679
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
13680
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
13494
13681
|
}
|
|
13495
13682
|
return names;
|
|
13496
13683
|
};
|
|
13497
13684
|
var publicMethodNames = (body2, functionAliases) => {
|
|
13498
13685
|
const names = [];
|
|
13499
13686
|
for (const member of body2.body) {
|
|
13500
|
-
if (member.type ===
|
|
13687
|
+
if (member.type === import_utils65.AST_NODE_TYPES.PropertyDefinition) {
|
|
13501
13688
|
if (member.static || member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
13502
|
-
if (member.value?.type !==
|
|
13503
|
-
names.push(member.key.type ===
|
|
13689
|
+
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;
|
|
13690
|
+
names.push(member.key.type === import_utils65.AST_NODE_TYPES.Identifier ? member.key.name : "\u2026");
|
|
13504
13691
|
continue;
|
|
13505
13692
|
}
|
|
13506
|
-
if (member.type !==
|
|
13693
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.MethodDefinition) continue;
|
|
13507
13694
|
if (member.kind !== "method" || member.static) continue;
|
|
13508
13695
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
13509
|
-
if (member.key.type ===
|
|
13510
|
-
if (member.key.type ===
|
|
13696
|
+
if (member.key.type === import_utils65.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
13697
|
+
if (member.key.type === import_utils65.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
13511
13698
|
else names.push("\u2026");
|
|
13512
13699
|
}
|
|
13513
13700
|
return names;
|
|
@@ -13515,13 +13702,13 @@ var publicMethodNames = (body2, functionAliases) => {
|
|
|
13515
13702
|
var isFluentConstructionObject = (node, getText) => {
|
|
13516
13703
|
if (node.id === null) return false;
|
|
13517
13704
|
const methods = node.body.body.filter(
|
|
13518
|
-
(member) => member.type ===
|
|
13705
|
+
(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
13706
|
);
|
|
13520
13707
|
if (methods.length === 0) return false;
|
|
13521
13708
|
return methods.every((member) => {
|
|
13522
13709
|
const result = member.value.returnType?.typeAnnotation;
|
|
13523
13710
|
if (result === void 0) return false;
|
|
13524
|
-
const returnsOwnType = result.type ===
|
|
13711
|
+
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
13712
|
return returnsOwnType || FLUENT_BUILDER_NAME_RE.test(node.id?.name ?? "") && FLUENT_RESULT_TYPE_RE.test(getText(result));
|
|
13526
13713
|
});
|
|
13527
13714
|
};
|
|
@@ -13529,10 +13716,10 @@ function localClassAbstractness(program) {
|
|
|
13529
13716
|
const classes = /* @__PURE__ */ new Map();
|
|
13530
13717
|
const parents = /* @__PURE__ */ new Map();
|
|
13531
13718
|
for (const statement of program.body) {
|
|
13532
|
-
const declaration = statement.type ===
|
|
13533
|
-
if (declaration?.type ===
|
|
13719
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils65.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
13720
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.ClassDeclaration && declaration.id !== null) {
|
|
13534
13721
|
classes.set(declaration.id.name, declaration.abstract === true);
|
|
13535
|
-
if (declaration.superClass?.type ===
|
|
13722
|
+
if (declaration.superClass?.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13536
13723
|
parents.set(declaration.id.name, declaration.superClass.name);
|
|
13537
13724
|
}
|
|
13538
13725
|
}
|
|
@@ -13554,43 +13741,43 @@ function localInterfaceSurfaces(program) {
|
|
|
13554
13741
|
const parents = /* @__PURE__ */ new Map();
|
|
13555
13742
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
13556
13743
|
for (const statement of program.body) {
|
|
13557
|
-
const declaration = statement.type ===
|
|
13558
|
-
if (declaration?.type ===
|
|
13744
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
13745
|
+
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
13746
|
}
|
|
13560
13747
|
for (const statement of program.body) {
|
|
13561
|
-
const declaration = statement.type ===
|
|
13562
|
-
if (declaration?.type ===
|
|
13748
|
+
const declaration = statement.type === import_utils65.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
13749
|
+
if (declaration?.type === import_utils65.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
13563
13750
|
const callables2 = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
13564
|
-
const parts = declaration.typeAnnotation.type ===
|
|
13751
|
+
const parts = declaration.typeAnnotation.type === import_utils65.AST_NODE_TYPES.TSIntersectionType ? declaration.typeAnnotation.types : [declaration.typeAnnotation];
|
|
13565
13752
|
const inherited = parents.get(declaration.id.name) ?? [];
|
|
13566
13753
|
for (const part of parts) {
|
|
13567
|
-
if (part.type ===
|
|
13754
|
+
if (part.type === import_utils65.AST_NODE_TYPES.TSTypeReference && part.typeName.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
13568
13755
|
inherited.push(part.typeName.name);
|
|
13569
13756
|
continue;
|
|
13570
13757
|
}
|
|
13571
|
-
if (part.type !==
|
|
13758
|
+
if (part.type !== import_utils65.AST_NODE_TYPES.TSTypeLiteral) continue;
|
|
13572
13759
|
for (const member of part.members) {
|
|
13573
|
-
if (member.type !==
|
|
13574
|
-
if (member.computed || member.key.type !==
|
|
13575
|
-
if (member.type ===
|
|
13760
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13761
|
+
if (member.computed || member.key.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13762
|
+
if (member.type === import_utils65.AST_NODE_TYPES.TSMethodSignature) {
|
|
13576
13763
|
callables2.add(member.key.name);
|
|
13577
13764
|
continue;
|
|
13578
13765
|
}
|
|
13579
|
-
if (member.type !==
|
|
13766
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13580
13767
|
const annotation = member.typeAnnotation?.typeAnnotation;
|
|
13581
|
-
if (annotation?.type ===
|
|
13768
|
+
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
13769
|
}
|
|
13583
13770
|
}
|
|
13584
13771
|
interfaces.set(declaration.id.name, callables2);
|
|
13585
13772
|
parents.set(declaration.id.name, inherited);
|
|
13586
13773
|
continue;
|
|
13587
13774
|
}
|
|
13588
|
-
if (declaration?.type !==
|
|
13775
|
+
if (declaration?.type !== import_utils65.AST_NODE_TYPES.TSInterfaceDeclaration) continue;
|
|
13589
13776
|
const callables = interfaces.get(declaration.id.name) ?? /* @__PURE__ */ new Set();
|
|
13590
13777
|
for (const member of declaration.body.body) {
|
|
13591
|
-
if (member.type !==
|
|
13592
|
-
if (member.computed || member.key.type !==
|
|
13593
|
-
if (member.type ===
|
|
13778
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSMethodSignature && member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
13779
|
+
if (member.computed || member.key.type !== import_utils65.AST_NODE_TYPES.Identifier) continue;
|
|
13780
|
+
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
13781
|
}
|
|
13595
13782
|
interfaces.set(declaration.id.name, callables);
|
|
13596
13783
|
parents.set(
|
|
@@ -13598,7 +13785,7 @@ function localInterfaceSurfaces(program) {
|
|
|
13598
13785
|
[
|
|
13599
13786
|
...parents.get(declaration.id.name) ?? [],
|
|
13600
13787
|
...declaration.extends.flatMap(
|
|
13601
|
-
(heritage) => heritage.expression.type ===
|
|
13788
|
+
(heritage) => heritage.expression.type === import_utils65.AST_NODE_TYPES.Identifier ? [heritage.expression.name] : ["*"]
|
|
13602
13789
|
)
|
|
13603
13790
|
]
|
|
13604
13791
|
);
|
|
@@ -13625,7 +13812,7 @@ function localInterfaceSurfaces(program) {
|
|
|
13625
13812
|
}
|
|
13626
13813
|
function hasServicePort(node, methods, classes, interfaces) {
|
|
13627
13814
|
if (node.superClass !== null) {
|
|
13628
|
-
if (node.superClass.type !==
|
|
13815
|
+
if (node.superClass.type !== import_utils65.AST_NODE_TYPES.Identifier) return true;
|
|
13629
13816
|
const localAbstract = classes.get(node.superClass.name);
|
|
13630
13817
|
if (localAbstract === void 0 || localAbstract) return true;
|
|
13631
13818
|
}
|
|
@@ -13637,7 +13824,7 @@ function hasServicePort(node, methods, classes, interfaces) {
|
|
|
13637
13824
|
if (node.implements.length === 0) return false;
|
|
13638
13825
|
const combined = /* @__PURE__ */ new Set();
|
|
13639
13826
|
for (const implementation of node.implements) {
|
|
13640
|
-
if (implementation.expression.type !==
|
|
13827
|
+
if (implementation.expression.type !== import_utils65.AST_NODE_TYPES.Identifier) return true;
|
|
13641
13828
|
const name = implementation.expression.name;
|
|
13642
13829
|
const localAbstract = classes.get(name);
|
|
13643
13830
|
if (localAbstract === true) return true;
|
|
@@ -13680,7 +13867,7 @@ var require_port_for_service_default = createRule({
|
|
|
13680
13867
|
if (node.abstract === true) return;
|
|
13681
13868
|
if (node.decorators.length > 0) return;
|
|
13682
13869
|
const ctor = node.body.body.find(
|
|
13683
|
-
(member) => member.type ===
|
|
13870
|
+
(member) => member.type === import_utils65.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor" && member.value.body !== null && member.value.body !== void 0
|
|
13684
13871
|
);
|
|
13685
13872
|
if (ctor === void 0) return;
|
|
13686
13873
|
const constructorFacts = readConstructor(
|
|
@@ -13715,7 +13902,7 @@ var require_port_for_service_default = createRule({
|
|
|
13715
13902
|
});
|
|
13716
13903
|
|
|
13717
13904
|
// src/rules/require-static-next-matcher.ts
|
|
13718
|
-
var
|
|
13905
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
13719
13906
|
var requireStaticNextMatcherDocumentation = {
|
|
13720
13907
|
summary: "Require Next.js middleware and proxy matcher configuration to contain only build-time literals.",
|
|
13721
13908
|
rationale: "Next.js must statically analyze matcher values at build time; computed values are ignored.",
|
|
@@ -13728,34 +13915,34 @@ var requireStaticNextMatcherDocumentation = {
|
|
|
13728
13915
|
};
|
|
13729
13916
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
13730
13917
|
function unwrapExpression3(node) {
|
|
13731
|
-
if (node.type ===
|
|
13918
|
+
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
13919
|
return unwrapExpression3(node.expression);
|
|
13733
13920
|
}
|
|
13734
13921
|
return node;
|
|
13735
13922
|
}
|
|
13736
13923
|
function isStaticValue(node) {
|
|
13737
13924
|
const value = unwrapExpression3(node);
|
|
13738
|
-
if (value.type ===
|
|
13925
|
+
if (value.type === import_utils66.AST_NODE_TYPES.Literal) {
|
|
13739
13926
|
return true;
|
|
13740
13927
|
}
|
|
13741
|
-
if (value.type ===
|
|
13928
|
+
if (value.type === import_utils66.AST_NODE_TYPES.TemplateLiteral) {
|
|
13742
13929
|
return value.expressions.length === 0;
|
|
13743
13930
|
}
|
|
13744
|
-
if (value.type ===
|
|
13931
|
+
if (value.type === import_utils66.AST_NODE_TYPES.ArrayExpression) {
|
|
13745
13932
|
return value.elements.every(
|
|
13746
|
-
(element) => element !== null && element.type !==
|
|
13933
|
+
(element) => element !== null && element.type !== import_utils66.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
13747
13934
|
);
|
|
13748
13935
|
}
|
|
13749
|
-
if (value.type ===
|
|
13936
|
+
if (value.type === import_utils66.AST_NODE_TYPES.ObjectExpression) {
|
|
13750
13937
|
return value.properties.every(
|
|
13751
|
-
(property) => property.type ===
|
|
13938
|
+
(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
13939
|
);
|
|
13753
13940
|
}
|
|
13754
13941
|
return false;
|
|
13755
13942
|
}
|
|
13756
13943
|
function propertyName2(property) {
|
|
13757
13944
|
if (property.computed) return null;
|
|
13758
|
-
if (property.key.type ===
|
|
13945
|
+
if (property.key.type === import_utils66.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
13759
13946
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
13760
13947
|
}
|
|
13761
13948
|
var require_static_next_matcher_default = createRule({
|
|
@@ -13778,19 +13965,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
13778
13965
|
}
|
|
13779
13966
|
return {
|
|
13780
13967
|
ExportNamedDeclaration(node) {
|
|
13781
|
-
if (node.declaration?.type !==
|
|
13968
|
+
if (node.declaration?.type !== import_utils66.AST_NODE_TYPES.VariableDeclaration) {
|
|
13782
13969
|
return;
|
|
13783
13970
|
}
|
|
13784
13971
|
for (const declaration of node.declaration.declarations) {
|
|
13785
|
-
if (declaration.id.type !==
|
|
13972
|
+
if (declaration.id.type !== import_utils66.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
13786
13973
|
continue;
|
|
13787
13974
|
}
|
|
13788
13975
|
const config = unwrapExpression3(declaration.init);
|
|
13789
|
-
if (config.type !==
|
|
13976
|
+
if (config.type !== import_utils66.AST_NODE_TYPES.ObjectExpression) {
|
|
13790
13977
|
continue;
|
|
13791
13978
|
}
|
|
13792
13979
|
for (const property of config.properties) {
|
|
13793
|
-
if (property.type !==
|
|
13980
|
+
if (property.type !== import_utils66.AST_NODE_TYPES.Property || propertyName2(property) !== "matcher" || property.value.type === import_utils66.AST_NODE_TYPES.AssignmentPattern) {
|
|
13794
13981
|
continue;
|
|
13795
13982
|
}
|
|
13796
13983
|
if (!isStaticValue(property.value)) {
|
|
@@ -13804,7 +13991,7 @@ var require_static_next_matcher_default = createRule({
|
|
|
13804
13991
|
});
|
|
13805
13992
|
|
|
13806
13993
|
// src/rules/require-zod-form-validation.ts
|
|
13807
|
-
var
|
|
13994
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
13808
13995
|
var requireZodFormValidationDocumentation = {
|
|
13809
13996
|
summary: "Require Zod validation (`Schema.parse(...)` / `Schema.safeParse(...)`) when reading values out of a `FormData` object.",
|
|
13810
13997
|
rationale: "FormData values are untrusted strings or files and need runtime validation before use.",
|
|
@@ -13829,14 +14016,14 @@ var FORM_VALUE_METHODS = /* @__PURE__ */ new Set(["get", "getAll"]);
|
|
|
13829
14016
|
var zodReceiverRoot = (node) => {
|
|
13830
14017
|
let current = node;
|
|
13831
14018
|
while (true) {
|
|
13832
|
-
if (current.type ===
|
|
14019
|
+
if (current.type === import_utils67.AST_NODE_TYPES.Identifier) {
|
|
13833
14020
|
return current;
|
|
13834
14021
|
}
|
|
13835
|
-
if (current.type ===
|
|
14022
|
+
if (current.type === import_utils67.AST_NODE_TYPES.CallExpression) {
|
|
13836
14023
|
current = current.callee;
|
|
13837
14024
|
continue;
|
|
13838
14025
|
}
|
|
13839
|
-
if (current.type ===
|
|
14026
|
+
if (current.type === import_utils67.AST_NODE_TYPES.MemberExpression) {
|
|
13840
14027
|
current = current.object;
|
|
13841
14028
|
continue;
|
|
13842
14029
|
}
|
|
@@ -13845,12 +14032,12 @@ var zodReceiverRoot = (node) => {
|
|
|
13845
14032
|
};
|
|
13846
14033
|
var isFormDataMethodCall = (node) => {
|
|
13847
14034
|
let current = node;
|
|
13848
|
-
if (current.type ===
|
|
14035
|
+
if (current.type === import_utils67.AST_NODE_TYPES.AwaitExpression) {
|
|
13849
14036
|
current = current.argument;
|
|
13850
14037
|
}
|
|
13851
|
-
if (current.type !==
|
|
14038
|
+
if (current.type !== import_utils67.AST_NODE_TYPES.CallExpression) return false;
|
|
13852
14039
|
const callee = current.callee;
|
|
13853
|
-
return callee.type ===
|
|
14040
|
+
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
14041
|
};
|
|
13855
14042
|
var require_zod_form_validation_default = createRule({
|
|
13856
14043
|
name: "require-zod-form-validation",
|
|
@@ -13871,7 +14058,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13871
14058
|
return {};
|
|
13872
14059
|
}
|
|
13873
14060
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
13874
|
-
const resolvedBinding = (identifier) =>
|
|
14061
|
+
const resolvedBinding = (identifier) => import_utils67.ASTUtils.findVariable(
|
|
13875
14062
|
context.sourceCode.getScope(identifier),
|
|
13876
14063
|
identifier.name
|
|
13877
14064
|
);
|
|
@@ -13881,16 +14068,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
13881
14068
|
return false;
|
|
13882
14069
|
}
|
|
13883
14070
|
const definition = binding.defs[0];
|
|
13884
|
-
if (definition?.type !== "Variable" || definition.node.type !==
|
|
14071
|
+
if (definition?.type !== "Variable" || definition.node.type !== import_utils67.AST_NODE_TYPES.VariableDeclarator) {
|
|
13885
14072
|
return false;
|
|
13886
14073
|
}
|
|
13887
14074
|
const init = definition.node.init;
|
|
13888
|
-
return init?.type ===
|
|
14075
|
+
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
14076
|
};
|
|
13890
14077
|
const isZodParseCall = (node) => {
|
|
13891
|
-
if (node.type !==
|
|
14078
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.CallExpression) return false;
|
|
13892
14079
|
const callee = node.callee;
|
|
13893
|
-
if (callee.type !==
|
|
14080
|
+
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
14081
|
return false;
|
|
13895
14082
|
}
|
|
13896
14083
|
const root = zodReceiverRoot(callee.object);
|
|
@@ -13899,14 +14086,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
13899
14086
|
return binding !== null && zodBindings.has(binding) || (root.name === "z" || ZOD_SCHEMA_NAME_RE.test(root.name)) && !isProvablyNonZodLocal(root);
|
|
13900
14087
|
};
|
|
13901
14088
|
const isFormSourceIdentifier = (node) => {
|
|
13902
|
-
if (node.type !==
|
|
14089
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.Identifier) return false;
|
|
13903
14090
|
const conventionalName = /formdata/i.test(node.name);
|
|
13904
14091
|
let scope = context.sourceCode.getScope(node);
|
|
13905
14092
|
while (scope !== null) {
|
|
13906
14093
|
const variable = scope.set.get(node.name);
|
|
13907
14094
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
13908
14095
|
const def = variable.defs[0];
|
|
13909
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
14096
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils67.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
13910
14097
|
return isFormDataMethodCall(def.node.init);
|
|
13911
14098
|
}
|
|
13912
14099
|
return def?.type === "Parameter" && conventionalName;
|
|
@@ -13917,8 +14104,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
13917
14104
|
};
|
|
13918
14105
|
const isFormDataGetCall = (node) => {
|
|
13919
14106
|
const callee = node.callee;
|
|
13920
|
-
if (callee.type !==
|
|
13921
|
-
if (callee.property.type !==
|
|
14107
|
+
if (callee.type !== import_utils67.AST_NODE_TYPES.MemberExpression) return false;
|
|
14108
|
+
if (callee.property.type !== import_utils67.AST_NODE_TYPES.Identifier || !FORM_VALUE_METHODS.has(callee.property.name)) {
|
|
13922
14109
|
return false;
|
|
13923
14110
|
}
|
|
13924
14111
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -13934,16 +14121,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
13934
14121
|
const hasZodParseAncestor = (node) => zodParseAncestor(node) !== null;
|
|
13935
14122
|
const isInstanceofNarrowing = (node) => {
|
|
13936
14123
|
const parent = node.parent;
|
|
13937
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
14124
|
+
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
14125
|
};
|
|
13939
14126
|
const boundDeclarator = (node) => {
|
|
13940
14127
|
let current = node;
|
|
13941
14128
|
let parent = current.parent;
|
|
13942
|
-
while ((parent.type ===
|
|
14129
|
+
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
14130
|
current = parent;
|
|
13944
14131
|
parent = current.parent;
|
|
13945
14132
|
}
|
|
13946
|
-
if (parent.type ===
|
|
14133
|
+
if (parent.type === import_utils67.AST_NODE_TYPES.VariableDeclarator && parent.init === current && parent.id.type === import_utils67.AST_NODE_TYPES.Identifier) {
|
|
13947
14134
|
return parent;
|
|
13948
14135
|
}
|
|
13949
14136
|
return null;
|
|
@@ -13952,7 +14139,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13952
14139
|
let current = node;
|
|
13953
14140
|
while (current.parent !== void 0) {
|
|
13954
14141
|
const parent = current.parent;
|
|
13955
|
-
if (parent.type ===
|
|
14142
|
+
if (parent.type === import_utils67.AST_NODE_TYPES.BlockStatement || parent.type === import_utils67.AST_NODE_TYPES.Program) {
|
|
13956
14143
|
return current;
|
|
13957
14144
|
}
|
|
13958
14145
|
current = parent;
|
|
@@ -13961,12 +14148,12 @@ var require_zod_form_validation_default = createRule({
|
|
|
13961
14148
|
};
|
|
13962
14149
|
const zodParseMethod = (call) => {
|
|
13963
14150
|
const callee = call.callee;
|
|
13964
|
-
return callee.type ===
|
|
14151
|
+
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
14152
|
};
|
|
13966
14153
|
const hasConditionalAncestorBeforeStatement = (node, statement) => {
|
|
13967
14154
|
let current = node.parent;
|
|
13968
14155
|
while (current !== void 0 && current !== statement) {
|
|
13969
|
-
if (current.type ===
|
|
14156
|
+
if (current.type === import_utils67.AST_NODE_TYPES.LogicalExpression || current.type === import_utils67.AST_NODE_TYPES.ConditionalExpression) {
|
|
13970
14157
|
return true;
|
|
13971
14158
|
}
|
|
13972
14159
|
current = current.parent;
|
|
@@ -13976,7 +14163,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13976
14163
|
const isAwaitedBeforeStatement = (node, statement) => {
|
|
13977
14164
|
let current = node.parent;
|
|
13978
14165
|
while (current !== void 0 && current !== statement) {
|
|
13979
|
-
if (current.type ===
|
|
14166
|
+
if (current.type === import_utils67.AST_NODE_TYPES.AwaitExpression) return true;
|
|
13980
14167
|
current = current.parent;
|
|
13981
14168
|
}
|
|
13982
14169
|
return false;
|
|
@@ -13989,7 +14176,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
13989
14176
|
if (declarationStatement === null || validationStatement === null || declarationStatement.parent !== validationStatement.parent || validationStatement.range[0] <= declarationStatement.range[1] || hasConditionalAncestorBeforeStatement(parse2, validationStatement)) {
|
|
13990
14177
|
return null;
|
|
13991
14178
|
}
|
|
13992
|
-
if (validationStatement.type !==
|
|
14179
|
+
if (validationStatement.type !== import_utils67.AST_NODE_TYPES.VariableDeclaration && validationStatement.type !== import_utils67.AST_NODE_TYPES.ExpressionStatement) {
|
|
13993
14180
|
return null;
|
|
13994
14181
|
}
|
|
13995
14182
|
const method = zodParseMethod(parse2);
|
|
@@ -14001,16 +14188,16 @@ var require_zod_form_validation_default = createRule({
|
|
|
14001
14188
|
};
|
|
14002
14189
|
const isSafePrevalidationInspection = (identifier) => {
|
|
14003
14190
|
const parent = identifier.parent;
|
|
14004
|
-
if (parent.type ===
|
|
14191
|
+
if (parent.type === import_utils67.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof") {
|
|
14005
14192
|
return true;
|
|
14006
14193
|
}
|
|
14007
|
-
if (parent.type !==
|
|
14194
|
+
if (parent.type !== import_utils67.AST_NODE_TYPES.BinaryExpression || parent.left !== identifier) {
|
|
14008
14195
|
return false;
|
|
14009
14196
|
}
|
|
14010
14197
|
if (parent.operator === "instanceof") {
|
|
14011
|
-
return parent.right.type ===
|
|
14198
|
+
return parent.right.type === import_utils67.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
14012
14199
|
}
|
|
14013
|
-
return ["===", "!==", "==", "!="].includes(parent.operator) && (parent.right.type ===
|
|
14200
|
+
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
14201
|
};
|
|
14015
14202
|
const isDescendantOf = (node, ancestor) => {
|
|
14016
14203
|
let current = node;
|
|
@@ -14021,23 +14208,23 @@ var require_zod_form_validation_default = createRule({
|
|
|
14021
14208
|
return false;
|
|
14022
14209
|
};
|
|
14023
14210
|
const blockTerminates = (node) => {
|
|
14024
|
-
if (node.type ===
|
|
14211
|
+
if (node.type === import_utils67.AST_NODE_TYPES.ReturnStatement || node.type === import_utils67.AST_NODE_TYPES.ThrowStatement) {
|
|
14025
14212
|
return true;
|
|
14026
14213
|
}
|
|
14027
|
-
if (node.type !==
|
|
14214
|
+
if (node.type !== import_utils67.AST_NODE_TYPES.BlockStatement || node.body.length === 0) return false;
|
|
14028
14215
|
const last = node.body.at(-1);
|
|
14029
14216
|
return last !== void 0 && blockTerminates(last);
|
|
14030
14217
|
};
|
|
14031
14218
|
const narrowingIf = (identifier) => {
|
|
14032
14219
|
const comparison = identifier.parent;
|
|
14033
|
-
if (comparison?.type !==
|
|
14220
|
+
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
14221
|
return null;
|
|
14035
14222
|
}
|
|
14036
14223
|
const maybeNegation = comparison.parent;
|
|
14037
|
-
const negated = maybeNegation?.type ===
|
|
14224
|
+
const negated = maybeNegation?.type === import_utils67.AST_NODE_TYPES.UnaryExpression && maybeNegation.operator === "!";
|
|
14038
14225
|
const test = negated ? maybeNegation : comparison;
|
|
14039
14226
|
const branch = test.parent;
|
|
14040
|
-
return branch?.type ===
|
|
14227
|
+
return branch?.type === import_utils67.AST_NODE_TYPES.IfStatement && branch.test === test ? { branch, positive: !negated } : null;
|
|
14041
14228
|
};
|
|
14042
14229
|
const useDominatedByNarrowing = (use, narrowings) => narrowings.some(({ branch, positive }) => {
|
|
14043
14230
|
if (positive) return isDescendantOf(use, branch.consequent);
|
|
@@ -14057,7 +14244,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14057
14244
|
const variable = context.sourceCode.getDeclaredVariables(declarator)[0];
|
|
14058
14245
|
if (variable === void 0) return false;
|
|
14059
14246
|
const references = variable.references.filter((reference) => !reference.isWriteOnly()).map((reference) => reference.identifier).filter(
|
|
14060
|
-
(identifier) => identifier.type ===
|
|
14247
|
+
(identifier) => identifier.type === import_utils67.AST_NODE_TYPES.Identifier
|
|
14061
14248
|
);
|
|
14062
14249
|
if (references.length === 0) return false;
|
|
14063
14250
|
const narrowings = references.map(narrowingIf).filter(
|
|
@@ -14083,7 +14270,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14083
14270
|
ImportDeclaration(node) {
|
|
14084
14271
|
if (!isZodModule(node.source.value)) return;
|
|
14085
14272
|
for (const specifier of node.specifiers) {
|
|
14086
|
-
if (specifier.type ===
|
|
14273
|
+
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
14274
|
const binding = resolvedBinding(specifier.local);
|
|
14088
14275
|
if (binding !== null) zodBindings.add(binding);
|
|
14089
14276
|
}
|
|
@@ -14104,7 +14291,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
14104
14291
|
});
|
|
14105
14292
|
|
|
14106
14293
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
14107
|
-
var
|
|
14294
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
14108
14295
|
var storeInsertRequiresOnConflictDocumentation = {
|
|
14109
14296
|
summary: "Require embedded inserts in explicitly replayable callables to carry conflict handling.",
|
|
14110
14297
|
rationale: "A callable named as an enqueue, seed, migration, schedule, ensure, or upsert promises replay safety.",
|
|
@@ -14168,7 +14355,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
14168
14355
|
});
|
|
14169
14356
|
|
|
14170
14357
|
// src/rules/stepdown.ts
|
|
14171
|
-
var
|
|
14358
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
14172
14359
|
var stepdownDocumentation = {
|
|
14173
14360
|
summary: "Place a private helper below its sole direct same-scope caller.",
|
|
14174
14361
|
rationale: "Caller-first ordering lets a reader follow the main flow before descending into implementation details.",
|
|
@@ -14185,7 +14372,7 @@ var stepdownDocumentation = {
|
|
|
14185
14372
|
]
|
|
14186
14373
|
};
|
|
14187
14374
|
function isFunction(node) {
|
|
14188
|
-
return node.type ===
|
|
14375
|
+
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
14376
|
}
|
|
14190
14377
|
function reportMisordered(context, candidates, scopeDefinitions, calls, pinned, canMove = () => true) {
|
|
14191
14378
|
const byName = new Map(scopeDefinitions.map((definition) => [definition.name, definition]));
|
|
@@ -14280,8 +14467,8 @@ function moduleScope(context, program) {
|
|
|
14280
14467
|
for (const node of declarations) counts.set(node.name, (counts.get(node.name) ?? 0) + 1);
|
|
14281
14468
|
const overloadNames = new Set(
|
|
14282
14469
|
program.body.flatMap((statement) => {
|
|
14283
|
-
const node = statement.type ===
|
|
14284
|
-
return node?.type ===
|
|
14470
|
+
const node = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
14471
|
+
return node?.type === import_utils69.AST_NODE_TYPES.TSDeclareFunction && node.id !== null ? [node.id.name] : [];
|
|
14285
14472
|
})
|
|
14286
14473
|
);
|
|
14287
14474
|
const exported = exportedNames(program);
|
|
@@ -14305,7 +14492,7 @@ function moduleScope(context, program) {
|
|
|
14305
14492
|
const nearestFunction = [...ancestors].reverse().find(isFunction);
|
|
14306
14493
|
const parent = identifier.parent;
|
|
14307
14494
|
const callerDefinition = nearestFunction === void 0 ? void 0 : byFunction.get(nearestFunction);
|
|
14308
|
-
if (callerDefinition === void 0 || parent.type !==
|
|
14495
|
+
if (callerDefinition === void 0 || parent.type !== import_utils69.AST_NODE_TYPES.CallExpression || parent.callee !== identifier) {
|
|
14309
14496
|
pinned.add(definition.name);
|
|
14310
14497
|
continue;
|
|
14311
14498
|
}
|
|
@@ -14320,38 +14507,38 @@ function moduleScope(context, program) {
|
|
|
14320
14507
|
function exportedNames(program) {
|
|
14321
14508
|
const names = /* @__PURE__ */ new Set();
|
|
14322
14509
|
for (const statement of program.body) {
|
|
14323
|
-
if (statement.type !==
|
|
14324
|
-
if (statement.declaration?.type ===
|
|
14510
|
+
if (statement.type !== import_utils69.AST_NODE_TYPES.ExportNamedDeclaration || statement.exportKind === "type" || statement.source !== null) continue;
|
|
14511
|
+
if (statement.declaration?.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration && statement.declaration.id !== null) {
|
|
14325
14512
|
names.add(statement.declaration.id.name);
|
|
14326
14513
|
}
|
|
14327
|
-
if (statement.declaration?.type ===
|
|
14514
|
+
if (statement.declaration?.type === import_utils69.AST_NODE_TYPES.VariableDeclaration) {
|
|
14328
14515
|
for (const declarator of statement.declaration.declarations) {
|
|
14329
|
-
if (declarator.id.type ===
|
|
14516
|
+
if (declarator.id.type === import_utils69.AST_NODE_TYPES.Identifier) names.add(declarator.id.name);
|
|
14330
14517
|
}
|
|
14331
14518
|
}
|
|
14332
14519
|
for (const specifier of statement.specifiers) {
|
|
14333
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
14520
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils69.AST_NODE_TYPES.Identifier) {
|
|
14334
14521
|
names.add(specifier.local.name);
|
|
14335
14522
|
}
|
|
14336
14523
|
}
|
|
14337
14524
|
}
|
|
14338
14525
|
for (const statement of program.body) {
|
|
14339
|
-
if (statement.type ===
|
|
14340
|
-
if (statement.type ===
|
|
14526
|
+
if (statement.type === import_utils69.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils69.AST_NODE_TYPES.Identifier) names.add(statement.declaration.name);
|
|
14527
|
+
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
14528
|
}
|
|
14342
14529
|
return names;
|
|
14343
14530
|
}
|
|
14344
14531
|
function moduleDefinitions(program) {
|
|
14345
14532
|
const definitions = [];
|
|
14346
14533
|
for (const statement of program.body) {
|
|
14347
|
-
const node = statement.type ===
|
|
14348
|
-
if (node?.type ===
|
|
14534
|
+
const node = statement.type === import_utils69.AST_NODE_TYPES.ExportNamedDeclaration || statement.type === import_utils69.AST_NODE_TYPES.ExportDefaultDeclaration ? statement.declaration : statement;
|
|
14535
|
+
if (node?.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration && node.id !== null && node.body !== null) {
|
|
14349
14536
|
definitions.push({ name: node.id.name, node, functionNode: node, bindingNode: node });
|
|
14350
14537
|
continue;
|
|
14351
14538
|
}
|
|
14352
|
-
if (node?.type !==
|
|
14539
|
+
if (node?.type !== import_utils69.AST_NODE_TYPES.VariableDeclaration || node.kind !== "const") continue;
|
|
14353
14540
|
for (const declarator of node.declarations) {
|
|
14354
|
-
if (declarator.id.type ===
|
|
14541
|
+
if (declarator.id.type === import_utils69.AST_NODE_TYPES.Identifier && declarator.init !== null && isFunction(declarator.init)) {
|
|
14355
14542
|
definitions.push({
|
|
14356
14543
|
name: declarator.id.name,
|
|
14357
14544
|
node: declarator,
|
|
@@ -14364,21 +14551,21 @@ function moduleDefinitions(program) {
|
|
|
14364
14551
|
return definitions;
|
|
14365
14552
|
}
|
|
14366
14553
|
function methodName(node) {
|
|
14367
|
-
if (node.key.type ===
|
|
14368
|
-
return !node.computed && node.key.type ===
|
|
14554
|
+
if (node.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier) return `#${node.key.name}`;
|
|
14555
|
+
return !node.computed && node.key.type === import_utils69.AST_NODE_TYPES.Identifier ? node.key.name : null;
|
|
14369
14556
|
}
|
|
14370
14557
|
function referencedMethod(context, node, classVariables) {
|
|
14371
|
-
const objectVariable = node.object.type ===
|
|
14558
|
+
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
14559
|
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 ===
|
|
14560
|
+
if (node.object.type !== import_utils69.AST_NODE_TYPES.ThisExpression && !isClassReference) return null;
|
|
14561
|
+
if (node.property.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
14562
|
+
if (!node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
14563
|
+
return node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
14377
14564
|
}
|
|
14378
14565
|
function referencedPropertyName(node) {
|
|
14379
|
-
if (node.property.type ===
|
|
14380
|
-
if (!node.computed && node.property.type ===
|
|
14381
|
-
return node.computed && node.property.type ===
|
|
14566
|
+
if (node.property.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier) return `#${node.property.name}`;
|
|
14567
|
+
if (!node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Identifier) return node.property.name;
|
|
14568
|
+
return node.computed && node.property.type === import_utils69.AST_NODE_TYPES.Literal && typeof node.property.value === "string" ? node.property.value : null;
|
|
14382
14569
|
}
|
|
14383
14570
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
14384
14571
|
visit(node, nestedFunction);
|
|
@@ -14394,7 +14581,7 @@ function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
|
14394
14581
|
}
|
|
14395
14582
|
function classScope(context, node, computedReferenceNames) {
|
|
14396
14583
|
const methods = node.body.body.filter(
|
|
14397
|
-
(member) => member.type ===
|
|
14584
|
+
(member) => member.type === import_utils69.AST_NODE_TYPES.MethodDefinition
|
|
14398
14585
|
);
|
|
14399
14586
|
const counts = /* @__PURE__ */ new Map();
|
|
14400
14587
|
for (const method of methods) {
|
|
@@ -14402,8 +14589,8 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14402
14589
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
14403
14590
|
}
|
|
14404
14591
|
for (const member of node.body.body) {
|
|
14405
|
-
if (member.type !==
|
|
14406
|
-
const name = !member.computed && member.key.type ===
|
|
14592
|
+
if (member.type !== import_utils69.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
14593
|
+
const name = !member.computed && member.key.type === import_utils69.AST_NODE_TYPES.Identifier ? member.key.name : null;
|
|
14407
14594
|
if (name !== null) counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
14408
14595
|
}
|
|
14409
14596
|
const scopeDefinitions = methods.flatMap((method) => {
|
|
@@ -14412,7 +14599,7 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14412
14599
|
});
|
|
14413
14600
|
const definitions = methods.flatMap((method) => {
|
|
14414
14601
|
const name = methodName(method);
|
|
14415
|
-
const isPrivate = method.accessibility === "private" || method.key.type ===
|
|
14602
|
+
const isPrivate = method.accessibility === "private" || method.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier;
|
|
14416
14603
|
return name !== null && isPrivate && counts.get(name) === 1 && method.decorators.length === 0 ? [{ name, node: method }] : [];
|
|
14417
14604
|
});
|
|
14418
14605
|
if (definitions.length === 0) return;
|
|
@@ -14421,11 +14608,11 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14421
14608
|
const pinned = /* @__PURE__ */ new Set();
|
|
14422
14609
|
const classVariables = /* @__PURE__ */ new Set();
|
|
14423
14610
|
if (node.id !== null) {
|
|
14424
|
-
const internal =
|
|
14611
|
+
const internal = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(node), node.id.name);
|
|
14425
14612
|
if (internal !== null) classVariables.add(internal);
|
|
14426
14613
|
}
|
|
14427
|
-
if (node.type ===
|
|
14428
|
-
const outer =
|
|
14614
|
+
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) {
|
|
14615
|
+
const outer = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(node.parent), node.parent.id.name);
|
|
14429
14616
|
if (outer !== null) classVariables.add(outer);
|
|
14430
14617
|
}
|
|
14431
14618
|
for (const method of methods) {
|
|
@@ -14441,27 +14628,27 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14441
14628
|
}
|
|
14442
14629
|
const thisValue = (value) => {
|
|
14443
14630
|
let current = value;
|
|
14444
|
-
while (current?.type ===
|
|
14445
|
-
return current?.type ===
|
|
14631
|
+
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;
|
|
14632
|
+
return current?.type === import_utils69.AST_NODE_TYPES.ThisExpression;
|
|
14446
14633
|
};
|
|
14447
14634
|
const collectAlias = (current, nestedFunction) => {
|
|
14448
|
-
if (nestedFunction || current.type !==
|
|
14449
|
-
if (current.type ===
|
|
14450
|
-
const binding = current.type ===
|
|
14451
|
-
const value = current.type ===
|
|
14635
|
+
if (nestedFunction || current.type !== import_utils69.AST_NODE_TYPES.VariableDeclarator && current.type !== import_utils69.AST_NODE_TYPES.AssignmentPattern) return;
|
|
14636
|
+
if (current.type === import_utils69.AST_NODE_TYPES.VariableDeclarator && (current.parent.type !== import_utils69.AST_NODE_TYPES.VariableDeclaration || current.parent.kind !== "const")) return;
|
|
14637
|
+
const binding = current.type === import_utils69.AST_NODE_TYPES.VariableDeclarator ? current.id : current.left;
|
|
14638
|
+
const value = current.type === import_utils69.AST_NODE_TYPES.VariableDeclarator ? current.init : current.right;
|
|
14452
14639
|
if (!thisValue(value)) return;
|
|
14453
|
-
if (binding.type ===
|
|
14640
|
+
if (binding.type === import_utils69.AST_NODE_TYPES.ObjectPattern) {
|
|
14454
14641
|
for (const property of binding.properties) {
|
|
14455
|
-
if (property.type ===
|
|
14642
|
+
if (property.type === import_utils69.AST_NODE_TYPES.RestElement) {
|
|
14456
14643
|
for (const name of privateNames) pinned.add(name);
|
|
14457
|
-
} else if (property.key.type ===
|
|
14644
|
+
} else if (property.key.type === import_utils69.AST_NODE_TYPES.Identifier && privateNames.has(property.key.name)) {
|
|
14458
14645
|
pinned.add(property.key.name);
|
|
14459
14646
|
}
|
|
14460
14647
|
}
|
|
14461
14648
|
return;
|
|
14462
14649
|
}
|
|
14463
|
-
if (binding.type !==
|
|
14464
|
-
const variable =
|
|
14650
|
+
if (binding.type !== import_utils69.AST_NODE_TYPES.Identifier) return;
|
|
14651
|
+
const variable = import_utils69.ASTUtils.findVariable(context.sourceCode.getScope(binding), binding.name);
|
|
14465
14652
|
if (variable !== null) {
|
|
14466
14653
|
methodClassVariables.add(variable);
|
|
14467
14654
|
methodAliases.add(variable);
|
|
@@ -14474,16 +14661,16 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14474
14661
|
walk(statement, context.sourceCode.visitorKeys, collectAlias);
|
|
14475
14662
|
}
|
|
14476
14663
|
const visitCall = (current, nestedFunction) => {
|
|
14477
|
-
if (current.type ===
|
|
14664
|
+
if (current.type === import_utils69.AST_NODE_TYPES.VariableDeclarator && current.id.type === import_utils69.AST_NODE_TYPES.ObjectPattern && thisValue(current.init)) {
|
|
14478
14665
|
for (const property of current.id.properties) {
|
|
14479
|
-
if (property.type ===
|
|
14666
|
+
if (property.type === import_utils69.AST_NODE_TYPES.RestElement) {
|
|
14480
14667
|
for (const name of privateNames) pinned.add(name);
|
|
14481
14668
|
continue;
|
|
14482
14669
|
}
|
|
14483
|
-
if (property.type ===
|
|
14670
|
+
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
14671
|
}
|
|
14485
14672
|
}
|
|
14486
|
-
if (current.type !==
|
|
14673
|
+
if (current.type !== import_utils69.AST_NODE_TYPES.MemberExpression) return;
|
|
14487
14674
|
const target = referencedMethod(context, current, methodClassVariables);
|
|
14488
14675
|
if (target === null) {
|
|
14489
14676
|
const possibleTarget = referencedPropertyName(current);
|
|
@@ -14491,12 +14678,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14491
14678
|
return;
|
|
14492
14679
|
}
|
|
14493
14680
|
if (!privateNames.has(target)) return;
|
|
14494
|
-
const objectVariable = current.object.type ===
|
|
14681
|
+
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
14682
|
if (objectVariable !== null && methodAliases.has(objectVariable)) {
|
|
14496
14683
|
pinned.add(target);
|
|
14497
14684
|
return;
|
|
14498
14685
|
}
|
|
14499
|
-
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !==
|
|
14686
|
+
if (current.computed || nestedFunction || parameterDecoratorNodes.has(current) || current.parent.type !== import_utils69.AST_NODE_TYPES.CallExpression || current.parent.callee !== current) {
|
|
14500
14687
|
pinned.add(target);
|
|
14501
14688
|
return;
|
|
14502
14689
|
}
|
|
@@ -14516,9 +14703,9 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14516
14703
|
}
|
|
14517
14704
|
}
|
|
14518
14705
|
for (const member of node.body.body) {
|
|
14519
|
-
if (member.type ===
|
|
14706
|
+
if (member.type === import_utils69.AST_NODE_TYPES.MethodDefinition || member.type === import_utils69.AST_NODE_TYPES.TSAbstractMethodDefinition) continue;
|
|
14520
14707
|
walk(member, context.sourceCode.visitorKeys, (current) => {
|
|
14521
|
-
if (current.type !==
|
|
14708
|
+
if (current.type !== import_utils69.AST_NODE_TYPES.MemberExpression) return;
|
|
14522
14709
|
const target = referencedMethod(context, current, classVariables);
|
|
14523
14710
|
const possibleTarget = target ?? referencedPropertyName(current);
|
|
14524
14711
|
if (possibleTarget !== null && privateNames.has(possibleTarget)) pinned.add(possibleTarget);
|
|
@@ -14528,14 +14715,14 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14528
14715
|
const accessibility = new Map(
|
|
14529
14716
|
scopeDefinitions.map((definition) => {
|
|
14530
14717
|
const method = definition.node;
|
|
14531
|
-
const accessibility2 = method.key.type ===
|
|
14718
|
+
const accessibility2 = method.key.type === import_utils69.AST_NODE_TYPES.PrivateIdentifier ? "private" : method.accessibility ?? "public";
|
|
14532
14719
|
return [definition.name, accessibility2];
|
|
14533
14720
|
})
|
|
14534
14721
|
);
|
|
14535
14722
|
const methodByName = new Map(scopeDefinitions.map((definition) => [definition.name, definition.node]));
|
|
14536
14723
|
for (const [caller, callees] of calls) {
|
|
14537
14724
|
const callerMethod = methodByName.get(caller);
|
|
14538
|
-
if (accessibility.get(caller) === "private" && callerMethod?.type ===
|
|
14725
|
+
if (accessibility.get(caller) === "private" && callerMethod?.type === import_utils69.AST_NODE_TYPES.MethodDefinition && callerMethod.decorators.length === 0) continue;
|
|
14539
14726
|
for (const callee of callees) pinned.add(callee);
|
|
14540
14727
|
}
|
|
14541
14728
|
const memberIndexes = new Map(node.body.body.map((member, index) => [member, index]));
|
|
@@ -14552,12 +14739,12 @@ function classScope(context, node, computedReferenceNames) {
|
|
|
14552
14739
|
}
|
|
14553
14740
|
function isClassRuntimeBarrier(member) {
|
|
14554
14741
|
switch (member.type) {
|
|
14555
|
-
case
|
|
14742
|
+
case import_utils69.AST_NODE_TYPES.StaticBlock:
|
|
14556
14743
|
return true;
|
|
14557
|
-
case
|
|
14558
|
-
case
|
|
14744
|
+
case import_utils69.AST_NODE_TYPES.PropertyDefinition:
|
|
14745
|
+
case import_utils69.AST_NODE_TYPES.AccessorProperty:
|
|
14559
14746
|
return member.static || member.computed || member.decorators.length > 0 || member.value !== null;
|
|
14560
|
-
case
|
|
14747
|
+
case import_utils69.AST_NODE_TYPES.MethodDefinition:
|
|
14561
14748
|
return member.computed || member.decorators.length > 0;
|
|
14562
14749
|
default:
|
|
14563
14750
|
return false;
|
|
@@ -14589,7 +14776,7 @@ var stepdown_default = createRule({
|
|
|
14589
14776
|
moduleScope(context, program);
|
|
14590
14777
|
const computedReferenceNames = /* @__PURE__ */ new Set();
|
|
14591
14778
|
walk(program, context.sourceCode.visitorKeys, (node) => {
|
|
14592
|
-
if (node.type ===
|
|
14779
|
+
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
14780
|
});
|
|
14594
14781
|
for (const node of classes) classScope(context, node, computedReferenceNames);
|
|
14595
14782
|
}
|
|
@@ -14598,7 +14785,7 @@ var stepdown_default = createRule({
|
|
|
14598
14785
|
});
|
|
14599
14786
|
|
|
14600
14787
|
// src/rules/zod-naming-convention.ts
|
|
14601
|
-
var
|
|
14788
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
14602
14789
|
var zodNamingConventionDocumentation = {
|
|
14603
14790
|
summary: "Enforce a consistent Zod schema naming convention \u2014 a `Z` prefix (`ZUser`) or a `Schema` suffix (`userSchema`); both are accepted by default.",
|
|
14604
14791
|
rationale: "A recognizable schema name distinguishes runtime validators from ordinary values at each use site.",
|
|
@@ -14639,18 +14826,18 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
14639
14826
|
"prettifyError",
|
|
14640
14827
|
"treeifyError"
|
|
14641
14828
|
]);
|
|
14642
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
14829
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils70.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
14643
14830
|
var calleeChainRoot = (node) => {
|
|
14644
14831
|
let current = node;
|
|
14645
14832
|
for (; ; ) {
|
|
14646
|
-
if (current.type ===
|
|
14833
|
+
if (current.type === import_utils70.AST_NODE_TYPES.Identifier) {
|
|
14647
14834
|
return current;
|
|
14648
14835
|
}
|
|
14649
|
-
if (current.type ===
|
|
14836
|
+
if (current.type === import_utils70.AST_NODE_TYPES.MemberExpression) {
|
|
14650
14837
|
current = current.object;
|
|
14651
14838
|
continue;
|
|
14652
14839
|
}
|
|
14653
|
-
if (current.type ===
|
|
14840
|
+
if (current.type === import_utils70.AST_NODE_TYPES.CallExpression) {
|
|
14654
14841
|
current = current.callee;
|
|
14655
14842
|
continue;
|
|
14656
14843
|
}
|
|
@@ -14690,7 +14877,7 @@ var zod_naming_convention_default = createRule({
|
|
|
14690
14877
|
const acceptsSchemaWord = convention !== "prefix";
|
|
14691
14878
|
const zodBindings = /* @__PURE__ */ new Set();
|
|
14692
14879
|
function resolvedBinding(identifier) {
|
|
14693
|
-
return
|
|
14880
|
+
return import_utils70.ASTUtils.findVariable(
|
|
14694
14881
|
context.sourceCode.getScope(identifier),
|
|
14695
14882
|
identifier.name
|
|
14696
14883
|
);
|
|
@@ -14712,7 +14899,7 @@ var zod_naming_convention_default = createRule({
|
|
|
14712
14899
|
ImportDeclaration(node) {
|
|
14713
14900
|
if (!isZodModule(node.source.value)) return;
|
|
14714
14901
|
for (const specifier of node.specifiers) {
|
|
14715
|
-
if (specifier.type ===
|
|
14902
|
+
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
14903
|
recordZodBinding(specifier.local);
|
|
14717
14904
|
}
|
|
14718
14905
|
}
|
|
@@ -14720,13 +14907,13 @@ var zod_naming_convention_default = createRule({
|
|
|
14720
14907
|
VariableDeclarator(node) {
|
|
14721
14908
|
const init = node.init;
|
|
14722
14909
|
if (init === null || init === void 0) return;
|
|
14723
|
-
if (init.type !==
|
|
14910
|
+
if (init.type !== import_utils70.AST_NODE_TYPES.CallExpression) return;
|
|
14724
14911
|
const callee = init.callee;
|
|
14725
|
-
if (callee.type !==
|
|
14912
|
+
if (callee.type !== import_utils70.AST_NODE_TYPES.MemberExpression) return;
|
|
14726
14913
|
if (!isZodChain(callee)) return;
|
|
14727
14914
|
const terminal = terminalMethodName(callee);
|
|
14728
14915
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
14729
|
-
if (node.id.type !==
|
|
14916
|
+
if (node.id.type !== import_utils70.AST_NODE_TYPES.Identifier) return;
|
|
14730
14917
|
if (test.test(node.id.name)) return;
|
|
14731
14918
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
14732
14919
|
context.report({
|
|
@@ -14870,6 +15057,7 @@ var rules = {
|
|
|
14870
15057
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
14871
15058
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
14872
15059
|
"prefer-non-nullable-collection": prefer_non_nullable_collection_default,
|
|
15060
|
+
"prefer-await-in-async-return": prefer_await_in_async_return_default,
|
|
14873
15061
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
14874
15062
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
14875
15063
|
"prefer-server-actions": prefer_server_actions_default,
|
|
@@ -14886,7 +15074,7 @@ var rules = {
|
|
|
14886
15074
|
};
|
|
14887
15075
|
var meta = {
|
|
14888
15076
|
name: "@sarj/eslint-plugin",
|
|
14889
|
-
version: "15.6.
|
|
15077
|
+
version: "15.6.4"
|
|
14890
15078
|
};
|
|
14891
15079
|
var applicationOnlyRules = [
|
|
14892
15080
|
"no-restricted-library-load",
|
|
@@ -14937,6 +15125,7 @@ var recommendedRules = {
|
|
|
14937
15125
|
"@sarj/prefer-module-level-constant": "error",
|
|
14938
15126
|
"@sarj/prefer-module-level-schema": "error",
|
|
14939
15127
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
15128
|
+
"@sarj/prefer-await-in-async-return": "error",
|
|
14940
15129
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
14941
15130
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
14942
15131
|
"@sarj/prefer-server-actions": "error",
|
|
@@ -14999,6 +15188,7 @@ var strictRules = {
|
|
|
14999
15188
|
"@sarj/prefer-module-level-constant": "error",
|
|
15000
15189
|
"@sarj/prefer-module-level-schema": "error",
|
|
15001
15190
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
15191
|
+
"@sarj/prefer-await-in-async-return": "error",
|
|
15002
15192
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
15003
15193
|
"@sarj/prefer-semantic-colors": ["error", { requireSemanticTokens: true }],
|
|
15004
15194
|
"@sarj/prefer-server-actions": "error",
|