@sarj/eslint-plugin 2.17.0 → 3.0.0
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 +494 -1103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -39
- package/dist/index.d.ts +0 -39
- package/dist/index.js +432 -1044
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1856,257 +1856,8 @@ var no_sentinel_return_on_catch_default = import_utils12.ESLintUtils.RuleCreator
|
|
|
1856
1856
|
}
|
|
1857
1857
|
});
|
|
1858
1858
|
|
|
1859
|
-
// src/rules/no-sequential-await.ts
|
|
1860
|
-
var import_utils13 = require("@typescript-eslint/utils");
|
|
1861
|
-
var ARRAY_ITERATION_METHODS = /* @__PURE__ */ new Set(["forEach", "map", "filter"]);
|
|
1862
|
-
var SEQUENTIAL_ITERABLE_HINT = /sort|reverse|ordered|sequence|hook|middleware|pipeline|preset|plugin|extension|\bstage|\bstep|\bphase|migration|chain|buffer|stream|teleport|chunk|\bqueue|drain/i;
|
|
1863
|
-
var BENCH_FILE_RE = /(^|[\\/])bench(marks?)?[\\/]|\.bench\.[cm]?[jt]sx?$/i;
|
|
1864
|
-
function isFunctionLike(node) {
|
|
1865
|
-
return node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
1866
|
-
}
|
|
1867
|
-
function isLoop(node) {
|
|
1868
|
-
return node.type === "ForStatement" || node.type === "ForOfStatement" || node.type === "ForInStatement" || node.type === "WhileStatement" || node.type === "DoWhileStatement";
|
|
1869
|
-
}
|
|
1870
|
-
function isNode2(value) {
|
|
1871
|
-
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
1872
|
-
}
|
|
1873
|
-
function visitScope(root, visit) {
|
|
1874
|
-
visit(root);
|
|
1875
|
-
for (const key of Object.keys(root)) {
|
|
1876
|
-
if (key === "parent") {
|
|
1877
|
-
continue;
|
|
1878
|
-
}
|
|
1879
|
-
const value = root[key];
|
|
1880
|
-
const children = Array.isArray(value) ? value : [value];
|
|
1881
|
-
for (const child of children) {
|
|
1882
|
-
if (isNode2(child) && !isFunctionLike(child) && !isLoop(child)) {
|
|
1883
|
-
visitScope(child, visit);
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
function collectAwaits(root) {
|
|
1889
|
-
const awaits = [];
|
|
1890
|
-
visitScope(root, (node) => {
|
|
1891
|
-
if (node.type === "AwaitExpression") {
|
|
1892
|
-
awaits.push(node);
|
|
1893
|
-
}
|
|
1894
|
-
});
|
|
1895
|
-
return awaits;
|
|
1896
|
-
}
|
|
1897
|
-
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
1898
|
-
function hasEarlyExit(root) {
|
|
1899
|
-
let found = false;
|
|
1900
|
-
visitScope(root, (node) => {
|
|
1901
|
-
if (node.type === "ReturnStatement" || node.type === "BreakStatement" || node.type === "ContinueStatement") {
|
|
1902
|
-
found = true;
|
|
1903
|
-
}
|
|
1904
|
-
});
|
|
1905
|
-
return found;
|
|
1906
|
-
}
|
|
1907
|
-
var TIMER_HELPER_RE = /^(sleep|timeout|delay|wait|pause|tick)$/i;
|
|
1908
|
-
function calleeName2(callee) {
|
|
1909
|
-
if (callee.type === "Identifier") return callee.name;
|
|
1910
|
-
if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier") {
|
|
1911
|
-
return callee.property.name;
|
|
1912
|
-
}
|
|
1913
|
-
return null;
|
|
1914
|
-
}
|
|
1915
|
-
function isTimerYield(node) {
|
|
1916
|
-
const arg = node.argument;
|
|
1917
|
-
if (arg.type === "NewExpression" && arg.callee.type === "Identifier" && arg.callee.name === "Promise") {
|
|
1918
|
-
return true;
|
|
1919
|
-
}
|
|
1920
|
-
if (arg.type === "CallExpression") {
|
|
1921
|
-
if (arg.callee.type === "MemberExpression" && !arg.callee.computed && arg.callee.object.type === "Identifier" && arg.callee.object.name === "Promise" && arg.callee.property.type === "Identifier" && (arg.callee.property.name === "resolve" || arg.callee.property.name === "reject")) {
|
|
1922
|
-
return true;
|
|
1923
|
-
}
|
|
1924
|
-
const name = calleeName2(arg.callee);
|
|
1925
|
-
return name !== null && TIMER_HELPER_RE.test(name);
|
|
1926
|
-
}
|
|
1927
|
-
return false;
|
|
1928
|
-
}
|
|
1929
|
-
var QUEUE_DRAIN_METHODS = /^(shift|pop|dequeue|next|poll)$/;
|
|
1930
|
-
function isQueueDrain(node) {
|
|
1931
|
-
const arg = node.argument;
|
|
1932
|
-
return arg.type === "CallExpression" && arg.callee.type === "MemberExpression" && !arg.callee.computed && arg.callee.property.type === "Identifier" && QUEUE_DRAIN_METHODS.test(arg.callee.property.name);
|
|
1933
|
-
}
|
|
1934
|
-
function hasAssertion(root) {
|
|
1935
|
-
let found = false;
|
|
1936
|
-
visitScope(root, (node) => {
|
|
1937
|
-
if (node.type !== "CallExpression") {
|
|
1938
|
-
return;
|
|
1939
|
-
}
|
|
1940
|
-
let callee = node.callee;
|
|
1941
|
-
while (callee.type === "MemberExpression") {
|
|
1942
|
-
callee = callee.object;
|
|
1943
|
-
}
|
|
1944
|
-
if (callee.type === "CallExpression") {
|
|
1945
|
-
callee = callee.callee;
|
|
1946
|
-
}
|
|
1947
|
-
if (callee.type === "Identifier" && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
1948
|
-
found = true;
|
|
1949
|
-
}
|
|
1950
|
-
});
|
|
1951
|
-
return found;
|
|
1952
|
-
}
|
|
1953
|
-
function referencesName(root, name) {
|
|
1954
|
-
let found = false;
|
|
1955
|
-
visitScope(root, (node) => {
|
|
1956
|
-
if (node.type === "Identifier" && node.name === name) {
|
|
1957
|
-
found = true;
|
|
1958
|
-
}
|
|
1959
|
-
});
|
|
1960
|
-
return found;
|
|
1961
|
-
}
|
|
1962
|
-
function isThreadedAccumulator(node) {
|
|
1963
|
-
const parent = node.parent;
|
|
1964
|
-
let target = null;
|
|
1965
|
-
if (parent.type === "AssignmentExpression" && parent.operator === "=" && parent.right === node && parent.left.type === "Identifier") {
|
|
1966
|
-
target = parent.left.name;
|
|
1967
|
-
} else if (parent.type === "VariableDeclarator" && parent.init === node && parent.id.type === "Identifier") {
|
|
1968
|
-
target = parent.id.name;
|
|
1969
|
-
}
|
|
1970
|
-
if (target === null) {
|
|
1971
|
-
return false;
|
|
1972
|
-
}
|
|
1973
|
-
return referencesName(node.argument, target);
|
|
1974
|
-
}
|
|
1975
|
-
function namesReadBy(test) {
|
|
1976
|
-
const names = /* @__PURE__ */ new Set();
|
|
1977
|
-
visitScope(test, (node) => {
|
|
1978
|
-
if (node.type === "Identifier") {
|
|
1979
|
-
names.add(node.name);
|
|
1980
|
-
}
|
|
1981
|
-
});
|
|
1982
|
-
return names;
|
|
1983
|
-
}
|
|
1984
|
-
function testStateIsAssignedInBody(test, body) {
|
|
1985
|
-
const testNames = namesReadBy(test);
|
|
1986
|
-
if (testNames.size === 0) {
|
|
1987
|
-
return false;
|
|
1988
|
-
}
|
|
1989
|
-
let found = false;
|
|
1990
|
-
visitScope(body, (node) => {
|
|
1991
|
-
if (node.type === "AssignmentExpression" && node.operator === "=" && node.left.type === "Identifier" && testNames.has(node.left.name)) {
|
|
1992
|
-
found = true;
|
|
1993
|
-
}
|
|
1994
|
-
});
|
|
1995
|
-
return found;
|
|
1996
|
-
}
|
|
1997
|
-
function shouldReport(awaits, earlyExit, iterableText, asserts = false) {
|
|
1998
|
-
if (awaits.length === 0) {
|
|
1999
|
-
return false;
|
|
2000
|
-
}
|
|
2001
|
-
if (earlyExit) {
|
|
2002
|
-
return false;
|
|
2003
|
-
}
|
|
2004
|
-
if (asserts) {
|
|
2005
|
-
return false;
|
|
2006
|
-
}
|
|
2007
|
-
if (iterableText !== null && SEQUENTIAL_ITERABLE_HINT.test(iterableText)) {
|
|
2008
|
-
return false;
|
|
2009
|
-
}
|
|
2010
|
-
return awaits.some(
|
|
2011
|
-
(node) => !isTimerYield(node) && !isThreadedAccumulator(node) && !isQueueDrain(node)
|
|
2012
|
-
);
|
|
2013
|
-
}
|
|
2014
|
-
var no_sequential_await_default = import_utils13.ESLintUtils.RuleCreator(
|
|
2015
|
-
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2016
|
-
)({
|
|
2017
|
-
name: "no-sequential-await",
|
|
2018
|
-
meta: {
|
|
2019
|
-
type: "problem",
|
|
2020
|
-
docs: {
|
|
2021
|
-
description: "Disallow serial `await` inside a loop; use `await Promise.all(...)` to run the operations concurrently."
|
|
2022
|
-
},
|
|
2023
|
-
schema: [],
|
|
2024
|
-
messages: {
|
|
2025
|
-
noSequentialAwait: "Avoid `await` inside a loop \u2014 it serializes I/O. Collect the promises and `await Promise.all(xs.map(async (x) => ...))` instead."
|
|
2026
|
-
}
|
|
2027
|
-
},
|
|
2028
|
-
defaultOptions: [],
|
|
2029
|
-
create(context) {
|
|
2030
|
-
if (isTestFile(context.filename) || BENCH_FILE_RE.test(context.filename)) {
|
|
2031
|
-
return {};
|
|
2032
|
-
}
|
|
2033
|
-
function loopParts(node) {
|
|
2034
|
-
if (node.type === "ForStatement") {
|
|
2035
|
-
return [node.body, node.test, node.update];
|
|
2036
|
-
}
|
|
2037
|
-
if (node.type === "ForOfStatement" || node.type === "ForInStatement") {
|
|
2038
|
-
return [node.body];
|
|
2039
|
-
}
|
|
2040
|
-
return [node.body, node.test];
|
|
2041
|
-
}
|
|
2042
|
-
function iterableTextOf(node) {
|
|
2043
|
-
if (node.type === "ForOfStatement" || node.type === "ForInStatement") {
|
|
2044
|
-
return context.sourceCode.getText(node.right);
|
|
2045
|
-
}
|
|
2046
|
-
return null;
|
|
2047
|
-
}
|
|
2048
|
-
function checkLoop(node) {
|
|
2049
|
-
if ((node.type === "WhileStatement" || node.type === "DoWhileStatement") && testStateIsAssignedInBody(node.test, node.body)) {
|
|
2050
|
-
return;
|
|
2051
|
-
}
|
|
2052
|
-
const awaits = [];
|
|
2053
|
-
let earlyExit = false;
|
|
2054
|
-
let asserts = false;
|
|
2055
|
-
for (const part of loopParts(node)) {
|
|
2056
|
-
if (part === null || isLoop(part)) {
|
|
2057
|
-
continue;
|
|
2058
|
-
}
|
|
2059
|
-
awaits.push(...collectAwaits(part));
|
|
2060
|
-
if (!earlyExit && hasEarlyExit(part)) {
|
|
2061
|
-
earlyExit = true;
|
|
2062
|
-
}
|
|
2063
|
-
if (!asserts && hasAssertion(part)) {
|
|
2064
|
-
asserts = true;
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
if (shouldReport(awaits, earlyExit, iterableTextOf(node), asserts)) {
|
|
2068
|
-
context.report({ node, messageId: "noSequentialAwait" });
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
return {
|
|
2072
|
-
ForStatement: checkLoop,
|
|
2073
|
-
ForInStatement: checkLoop,
|
|
2074
|
-
WhileStatement: checkLoop,
|
|
2075
|
-
DoWhileStatement: checkLoop,
|
|
2076
|
-
ForOfStatement(node) {
|
|
2077
|
-
if (node.await) {
|
|
2078
|
-
return;
|
|
2079
|
-
}
|
|
2080
|
-
checkLoop(node);
|
|
2081
|
-
},
|
|
2082
|
-
CallExpression(node) {
|
|
2083
|
-
const callee = node.callee;
|
|
2084
|
-
if (callee.type !== "MemberExpression" || callee.computed) {
|
|
2085
|
-
return;
|
|
2086
|
-
}
|
|
2087
|
-
if (callee.property.type !== "Identifier" || !ARRAY_ITERATION_METHODS.has(callee.property.name)) {
|
|
2088
|
-
return;
|
|
2089
|
-
}
|
|
2090
|
-
const callback = node.arguments[0];
|
|
2091
|
-
if (callback === void 0 || !isFunctionLike(callback) || !("async" in callback && callback.async)) {
|
|
2092
|
-
return;
|
|
2093
|
-
}
|
|
2094
|
-
if (callee.property.name !== "forEach" && node.parent.type !== "ExpressionStatement") {
|
|
2095
|
-
return;
|
|
2096
|
-
}
|
|
2097
|
-
const awaits = collectAwaits(callback.body);
|
|
2098
|
-
const earlyExit = hasEarlyExit(callback.body);
|
|
2099
|
-
const iterableText = context.sourceCode.getText(callee.object);
|
|
2100
|
-
if (shouldReport(awaits, earlyExit, iterableText, hasAssertion(callback.body))) {
|
|
2101
|
-
context.report({ node, messageId: "noSequentialAwait" });
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
};
|
|
2105
|
-
}
|
|
2106
|
-
});
|
|
2107
|
-
|
|
2108
1859
|
// src/rules/no-string-concat-in-loop.ts
|
|
2109
|
-
var
|
|
1860
|
+
var import_utils13 = require("@typescript-eslint/utils");
|
|
2110
1861
|
var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
2111
1862
|
"ForStatement",
|
|
2112
1863
|
"ForOfStatement",
|
|
@@ -2191,7 +1942,7 @@ function enclosingLoop(node) {
|
|
|
2191
1942
|
}
|
|
2192
1943
|
return null;
|
|
2193
1944
|
}
|
|
2194
|
-
var no_string_concat_in_loop_default =
|
|
1945
|
+
var no_string_concat_in_loop_default = import_utils13.ESLintUtils.RuleCreator(
|
|
2195
1946
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2196
1947
|
)({
|
|
2197
1948
|
name: "no-string-concat-in-loop",
|
|
@@ -2254,7 +2005,7 @@ var no_string_concat_in_loop_default = import_utils14.ESLintUtils.RuleCreator(
|
|
|
2254
2005
|
});
|
|
2255
2006
|
|
|
2256
2007
|
// src/rules/no-unnecessary-use-client.ts
|
|
2257
|
-
var
|
|
2008
|
+
var import_utils14 = require("@typescript-eslint/utils");
|
|
2258
2009
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
2259
2010
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
2260
2011
|
var ERROR_FILE_REGEX = /\b(?:global-)?error\.[jt]sx?$/;
|
|
@@ -2280,13 +2031,13 @@ var CLIENT_ONLY_PACKAGES_REGEX = /^(?:@radix-ui\/|framer-motion|react-dom|react-
|
|
|
2280
2031
|
var isBareSpecifier = (source) => !source.startsWith(".") && !source.startsWith("/") && !source.startsWith("@/") && !source.startsWith("~");
|
|
2281
2032
|
var jsxRootName = (name) => {
|
|
2282
2033
|
let current = name;
|
|
2283
|
-
while (current.type ===
|
|
2034
|
+
while (current.type === import_utils14.AST_NODE_TYPES.JSXMemberExpression) {
|
|
2284
2035
|
current = current.object;
|
|
2285
2036
|
}
|
|
2286
|
-
return current.type ===
|
|
2037
|
+
return current.type === import_utils14.AST_NODE_TYPES.JSXIdentifier ? current.name : "";
|
|
2287
2038
|
};
|
|
2288
2039
|
var subtreeReadsImportedBinding = (node, imported) => {
|
|
2289
|
-
if (node.type ===
|
|
2040
|
+
if (node.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
2290
2041
|
return imported.has(node.name);
|
|
2291
2042
|
}
|
|
2292
2043
|
for (const key of Object.keys(node)) {
|
|
@@ -2301,16 +2052,16 @@ var subtreeReadsImportedBinding = (node, imported) => {
|
|
|
2301
2052
|
return false;
|
|
2302
2053
|
};
|
|
2303
2054
|
var isUseClientDirective = (node) => {
|
|
2304
|
-
return node.type ===
|
|
2055
|
+
return node.type === import_utils14.AST_NODE_TYPES.ExpressionStatement && node.expression.type === import_utils14.AST_NODE_TYPES.Literal && node.expression.value === "use client";
|
|
2305
2056
|
};
|
|
2306
2057
|
var isGlobalReference = (node, context) => {
|
|
2307
2058
|
if (!BROWSER_GLOBALS.has(node.name)) return false;
|
|
2308
2059
|
const parent = node.parent;
|
|
2309
2060
|
if (parent !== void 0) {
|
|
2310
|
-
if (parent.type ===
|
|
2061
|
+
if (parent.type === import_utils14.AST_NODE_TYPES.MemberExpression && parent.property === node && !parent.computed) {
|
|
2311
2062
|
return false;
|
|
2312
2063
|
}
|
|
2313
|
-
if (parent.type ===
|
|
2064
|
+
if (parent.type === import_utils14.AST_NODE_TYPES.Property && parent.key === node && !parent.computed) {
|
|
2314
2065
|
return false;
|
|
2315
2066
|
}
|
|
2316
2067
|
if (parent.type.startsWith("TS")) {
|
|
@@ -2327,7 +2078,7 @@ var isGlobalReference = (node, context) => {
|
|
|
2327
2078
|
}
|
|
2328
2079
|
return true;
|
|
2329
2080
|
};
|
|
2330
|
-
var no_unnecessary_use_client_default =
|
|
2081
|
+
var no_unnecessary_use_client_default = import_utils14.ESLintUtils.RuleCreator(
|
|
2331
2082
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2332
2083
|
)({
|
|
2333
2084
|
name: "no-unnecessary-use-client",
|
|
@@ -2352,13 +2103,13 @@ var no_unnecessary_use_client_default = import_utils15.ESLintUtils.RuleCreator(
|
|
|
2352
2103
|
const importedLocals = /* @__PURE__ */ new Set();
|
|
2353
2104
|
const externalLocals = /* @__PURE__ */ new Set();
|
|
2354
2105
|
const markIfHookOrContext = (callee) => {
|
|
2355
|
-
if (callee.type ===
|
|
2106
|
+
if (callee.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
2356
2107
|
if (HOOK_REGEX.test(callee.name) || callee.name === "createContext") {
|
|
2357
2108
|
hasClientIndicator = true;
|
|
2358
2109
|
}
|
|
2359
2110
|
return;
|
|
2360
2111
|
}
|
|
2361
|
-
if (callee.type ===
|
|
2112
|
+
if (callee.type === import_utils14.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
2362
2113
|
const name = callee.property.name;
|
|
2363
2114
|
if (HOOK_REGEX.test(name) || name === "createContext") {
|
|
2364
2115
|
hasClientIndicator = true;
|
|
@@ -2368,7 +2119,7 @@ var no_unnecessary_use_client_default = import_utils15.ESLintUtils.RuleCreator(
|
|
|
2368
2119
|
return {
|
|
2369
2120
|
Program(node) {
|
|
2370
2121
|
for (const stmt of node.body) {
|
|
2371
|
-
if (stmt.type !==
|
|
2122
|
+
if (stmt.type !== import_utils14.AST_NODE_TYPES.ExpressionStatement) break;
|
|
2372
2123
|
if (isUseClientDirective(stmt)) {
|
|
2373
2124
|
directiveNode = stmt;
|
|
2374
2125
|
break;
|
|
@@ -2381,7 +2132,7 @@ var no_unnecessary_use_client_default = import_utils15.ESLintUtils.RuleCreator(
|
|
|
2381
2132
|
},
|
|
2382
2133
|
JSXAttribute(node) {
|
|
2383
2134
|
if (directiveNode === null) return;
|
|
2384
|
-
if (node.name.type ===
|
|
2135
|
+
if (node.name.type === import_utils14.AST_NODE_TYPES.JSXIdentifier && EVENT_PROP_REGEX.test(node.name.name)) {
|
|
2385
2136
|
hasClientIndicator = true;
|
|
2386
2137
|
}
|
|
2387
2138
|
},
|
|
@@ -2448,8 +2199,8 @@ var no_unnecessary_use_client_default = import_utils15.ESLintUtils.RuleCreator(
|
|
|
2448
2199
|
});
|
|
2449
2200
|
|
|
2450
2201
|
// src/rules/prefer-discriminated-union.ts
|
|
2202
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
2451
2203
|
var import_utils16 = require("@typescript-eslint/utils");
|
|
2452
|
-
var import_utils17 = require("@typescript-eslint/utils");
|
|
2453
2204
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
2454
2205
|
"success",
|
|
2455
2206
|
"ok",
|
|
@@ -2459,27 +2210,27 @@ var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
|
2459
2210
|
]);
|
|
2460
2211
|
var MIN_OPTIONAL_MEMBERS = 2;
|
|
2461
2212
|
function getMemberName(member) {
|
|
2462
|
-
if (member.type !==
|
|
2213
|
+
if (member.type !== import_utils16.AST_NODE_TYPES.TSPropertySignature) {
|
|
2463
2214
|
return null;
|
|
2464
2215
|
}
|
|
2465
2216
|
const { key } = member;
|
|
2466
|
-
if (key.type ===
|
|
2217
|
+
if (key.type === import_utils16.AST_NODE_TYPES.Identifier) {
|
|
2467
2218
|
return key.name;
|
|
2468
2219
|
}
|
|
2469
|
-
if (key.type ===
|
|
2220
|
+
if (key.type === import_utils16.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
2470
2221
|
return key.value;
|
|
2471
2222
|
}
|
|
2472
2223
|
return null;
|
|
2473
2224
|
}
|
|
2474
2225
|
function isBooleanTyped(member) {
|
|
2475
|
-
return member.typeAnnotation?.typeAnnotation.type ===
|
|
2226
|
+
return member.typeAnnotation?.typeAnnotation.type === import_utils16.AST_NODE_TYPES.TSBooleanKeyword;
|
|
2476
2227
|
}
|
|
2477
2228
|
function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
2478
2229
|
let hasStatusBoolean = false;
|
|
2479
2230
|
let optionalCount = 0;
|
|
2480
2231
|
let optionalPayloadCount = 0;
|
|
2481
2232
|
for (const member of typeLiteral.members) {
|
|
2482
|
-
if (member.type !==
|
|
2233
|
+
if (member.type !== import_utils16.AST_NODE_TYPES.TSPropertySignature) {
|
|
2483
2234
|
continue;
|
|
2484
2235
|
}
|
|
2485
2236
|
if (member.optional) {
|
|
@@ -2495,7 +2246,7 @@ function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
|
2495
2246
|
}
|
|
2496
2247
|
return hasStatusBoolean && optionalCount >= MIN_OPTIONAL_MEMBERS && optionalPayloadCount >= 1;
|
|
2497
2248
|
}
|
|
2498
|
-
var prefer_discriminated_union_default =
|
|
2249
|
+
var prefer_discriminated_union_default = import_utils15.ESLintUtils.RuleCreator(
|
|
2499
2250
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2500
2251
|
)({
|
|
2501
2252
|
name: "prefer-discriminated-union",
|
|
@@ -2523,7 +2274,7 @@ var prefer_discriminated_union_default = import_utils16.ESLintUtils.RuleCreator(
|
|
|
2523
2274
|
TSInterfaceDeclaration(node) {
|
|
2524
2275
|
const synthetic = {
|
|
2525
2276
|
...node.body,
|
|
2526
|
-
type:
|
|
2277
|
+
type: import_utils16.AST_NODE_TYPES.TSTypeLiteral,
|
|
2527
2278
|
members: node.body.body
|
|
2528
2279
|
};
|
|
2529
2280
|
checkTypeLiteral(synthetic, node);
|
|
@@ -2536,13 +2287,13 @@ var prefer_discriminated_union_default = import_utils16.ESLintUtils.RuleCreator(
|
|
|
2536
2287
|
});
|
|
2537
2288
|
|
|
2538
2289
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
2539
|
-
var
|
|
2290
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
2540
2291
|
var unwrap = (node) => {
|
|
2541
2292
|
let current = node;
|
|
2542
2293
|
while (current !== null && current !== void 0) {
|
|
2543
|
-
if (current.type ===
|
|
2294
|
+
if (current.type === import_utils17.AST_NODE_TYPES.TSAsExpression || current.type === import_utils17.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils17.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils17.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
2544
2295
|
current = current.expression;
|
|
2545
|
-
} else if (current.type ===
|
|
2296
|
+
} else if (current.type === import_utils17.AST_NODE_TYPES.ChainExpression) {
|
|
2546
2297
|
current = current.expression;
|
|
2547
2298
|
} else {
|
|
2548
2299
|
break;
|
|
@@ -2553,25 +2304,25 @@ var unwrap = (node) => {
|
|
|
2553
2304
|
var isRawPayloadSource = (node) => {
|
|
2554
2305
|
let current = unwrap(node);
|
|
2555
2306
|
if (current === null) return false;
|
|
2556
|
-
if (current.type ===
|
|
2307
|
+
if (current.type === import_utils17.AST_NODE_TYPES.AwaitExpression) {
|
|
2557
2308
|
current = unwrap(current.argument);
|
|
2558
2309
|
}
|
|
2559
|
-
if (current === null || current.type !==
|
|
2310
|
+
if (current === null || current.type !== import_utils17.AST_NODE_TYPES.CallExpression) {
|
|
2560
2311
|
return false;
|
|
2561
2312
|
}
|
|
2562
2313
|
const callee = unwrap(current.callee);
|
|
2563
|
-
if (callee === null || callee.type !==
|
|
2314
|
+
if (callee === null || callee.type !== import_utils17.AST_NODE_TYPES.MemberExpression) {
|
|
2564
2315
|
return false;
|
|
2565
2316
|
}
|
|
2566
2317
|
const property = unwrap(callee.property);
|
|
2567
|
-
if (property === null || property.type !==
|
|
2318
|
+
if (property === null || property.type !== import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2568
2319
|
return false;
|
|
2569
2320
|
}
|
|
2570
2321
|
if (property.name === "json") {
|
|
2571
2322
|
return true;
|
|
2572
2323
|
}
|
|
2573
2324
|
const object = unwrap(callee.object);
|
|
2574
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
2325
|
+
return property.name === "parse" && object !== null && object.type === import_utils17.AST_NODE_TYPES.Identifier && object.name === "JSON" && // ...but not `JSON.parse(readFileSync(p, "utf8"))` — see isLocalFileRead.
|
|
2575
2326
|
!isLocalFileRead(current.arguments[0]);
|
|
2576
2327
|
};
|
|
2577
2328
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
@@ -2579,9 +2330,9 @@ var isLocalFileRead = (node) => {
|
|
|
2579
2330
|
let found = false;
|
|
2580
2331
|
const visit = (current) => {
|
|
2581
2332
|
if (found || current === null || current === void 0) return;
|
|
2582
|
-
if (current.type ===
|
|
2333
|
+
if (current.type === import_utils17.AST_NODE_TYPES.CallExpression) {
|
|
2583
2334
|
const callee = unwrap(current.callee);
|
|
2584
|
-
const name = callee?.type ===
|
|
2335
|
+
const name = callee?.type === import_utils17.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils17.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils17.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
2585
2336
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
2586
2337
|
found = true;
|
|
2587
2338
|
return;
|
|
@@ -2600,18 +2351,18 @@ var isLocalFileRead = (node) => {
|
|
|
2600
2351
|
visit(node);
|
|
2601
2352
|
return found;
|
|
2602
2353
|
};
|
|
2603
|
-
var
|
|
2354
|
+
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
2604
2355
|
var isInsideAssertion = (node) => {
|
|
2605
2356
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
2606
|
-
if (current.type !==
|
|
2357
|
+
if (current.type !== import_utils17.AST_NODE_TYPES.CallExpression) continue;
|
|
2607
2358
|
let callee = current.callee;
|
|
2608
|
-
while (callee.type ===
|
|
2359
|
+
while (callee.type === import_utils17.AST_NODE_TYPES.MemberExpression) {
|
|
2609
2360
|
callee = callee.object;
|
|
2610
2361
|
}
|
|
2611
|
-
if (callee.type ===
|
|
2362
|
+
if (callee.type === import_utils17.AST_NODE_TYPES.CallExpression) {
|
|
2612
2363
|
callee = callee.callee;
|
|
2613
2364
|
}
|
|
2614
|
-
if (callee.type ===
|
|
2365
|
+
if (callee.type === import_utils17.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
2615
2366
|
return true;
|
|
2616
2367
|
}
|
|
2617
2368
|
}
|
|
@@ -2632,17 +2383,17 @@ var isGuardTestPosition = (node) => {
|
|
|
2632
2383
|
let parent = current.parent;
|
|
2633
2384
|
while (parent !== void 0 && parent !== null) {
|
|
2634
2385
|
switch (parent.type) {
|
|
2635
|
-
case
|
|
2636
|
-
case
|
|
2637
|
-
case
|
|
2386
|
+
case import_utils17.AST_NODE_TYPES.UnaryExpression:
|
|
2387
|
+
case import_utils17.AST_NODE_TYPES.LogicalExpression:
|
|
2388
|
+
case import_utils17.AST_NODE_TYPES.ChainExpression:
|
|
2638
2389
|
current = parent;
|
|
2639
2390
|
parent = parent.parent;
|
|
2640
2391
|
continue;
|
|
2641
|
-
case
|
|
2642
|
-
case
|
|
2643
|
-
case
|
|
2644
|
-
case
|
|
2645
|
-
case
|
|
2392
|
+
case import_utils17.AST_NODE_TYPES.IfStatement:
|
|
2393
|
+
case import_utils17.AST_NODE_TYPES.ConditionalExpression:
|
|
2394
|
+
case import_utils17.AST_NODE_TYPES.WhileStatement:
|
|
2395
|
+
case import_utils17.AST_NODE_TYPES.DoWhileStatement:
|
|
2396
|
+
case import_utils17.AST_NODE_TYPES.ForStatement:
|
|
2646
2397
|
return parent.test === current;
|
|
2647
2398
|
default:
|
|
2648
2399
|
return false;
|
|
@@ -2652,13 +2403,13 @@ var isGuardTestPosition = (node) => {
|
|
|
2652
2403
|
};
|
|
2653
2404
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
2654
2405
|
const unwrapped = unwrap(node);
|
|
2655
|
-
if (unwrapped === null || unwrapped.type !==
|
|
2406
|
+
if (unwrapped === null || unwrapped.type !== import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2656
2407
|
return false;
|
|
2657
2408
|
}
|
|
2658
2409
|
const variable = findVariable2(scope, unwrapped.name);
|
|
2659
2410
|
return variable !== null && tracked.has(variable);
|
|
2660
2411
|
};
|
|
2661
|
-
var prefer_schema_for_api_payload_default =
|
|
2412
|
+
var prefer_schema_for_api_payload_default = import_utils17.ESLintUtils.RuleCreator(
|
|
2662
2413
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2663
2414
|
)({
|
|
2664
2415
|
name: "prefer-schema-for-api-payload",
|
|
@@ -2689,11 +2440,11 @@ var prefer_schema_for_api_payload_default = import_utils18.ESLintUtils.RuleCreat
|
|
|
2689
2440
|
return {
|
|
2690
2441
|
VariableDeclarator(node) {
|
|
2691
2442
|
const scope = context.sourceCode.getScope(node);
|
|
2692
|
-
if (node.id.type ===
|
|
2443
|
+
if (node.id.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2693
2444
|
trackInitializer(node);
|
|
2694
2445
|
return;
|
|
2695
2446
|
}
|
|
2696
|
-
if (node.id.type ===
|
|
2447
|
+
if (node.id.type === import_utils17.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils17.AST_NODE_TYPES.ArrayPattern) {
|
|
2697
2448
|
if (isRawPayloadSource(node.init)) {
|
|
2698
2449
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
2699
2450
|
return;
|
|
@@ -2705,7 +2456,7 @@ var prefer_schema_for_api_payload_default = import_utils18.ESLintUtils.RuleCreat
|
|
|
2705
2456
|
},
|
|
2706
2457
|
AssignmentExpression(node) {
|
|
2707
2458
|
const scope = context.sourceCode.getScope(node);
|
|
2708
|
-
if (node.left.type ===
|
|
2459
|
+
if (node.left.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2709
2460
|
const variable = findVariable2(scope, node.left.name);
|
|
2710
2461
|
if (variable === null) return;
|
|
2711
2462
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -2715,7 +2466,7 @@ var prefer_schema_for_api_payload_default = import_utils18.ESLintUtils.RuleCreat
|
|
|
2715
2466
|
}
|
|
2716
2467
|
return;
|
|
2717
2468
|
}
|
|
2718
|
-
if (node.left.type ===
|
|
2469
|
+
if (node.left.type === import_utils17.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils17.AST_NODE_TYPES.ArrayPattern) {
|
|
2719
2470
|
if (isRawPayloadSource(node.right)) {
|
|
2720
2471
|
context.report({
|
|
2721
2472
|
node: node.left,
|
|
@@ -2732,15 +2483,15 @@ var prefer_schema_for_api_payload_default = import_utils18.ESLintUtils.RuleCreat
|
|
|
2732
2483
|
}
|
|
2733
2484
|
},
|
|
2734
2485
|
CallExpression(node) {
|
|
2735
|
-
if (node.callee.type !==
|
|
2486
|
+
if (node.callee.type !== import_utils17.AST_NODE_TYPES.Identifier) return;
|
|
2736
2487
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
2737
2488
|
return;
|
|
2738
2489
|
}
|
|
2739
2490
|
const scope = context.sourceCode.getScope(node);
|
|
2740
2491
|
for (const arg of node.arguments) {
|
|
2741
|
-
if (arg.type ===
|
|
2492
|
+
if (arg.type === import_utils17.AST_NODE_TYPES.SpreadElement) continue;
|
|
2742
2493
|
const unwrapped = unwrap(arg);
|
|
2743
|
-
if (unwrapped === null || unwrapped.type !==
|
|
2494
|
+
if (unwrapped === null || unwrapped.type !== import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2744
2495
|
continue;
|
|
2745
2496
|
}
|
|
2746
2497
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -2753,13 +2504,13 @@ var prefer_schema_for_api_payload_default = import_utils18.ESLintUtils.RuleCreat
|
|
|
2753
2504
|
const obj = unwrap(node.object);
|
|
2754
2505
|
if (isRawPayloadSource(obj)) {
|
|
2755
2506
|
const parent = node.parent;
|
|
2756
|
-
if (parent.type ===
|
|
2507
|
+
if (parent.type === import_utils17.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils17.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse")) {
|
|
2757
2508
|
return;
|
|
2758
2509
|
}
|
|
2759
2510
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
2760
2511
|
return;
|
|
2761
2512
|
}
|
|
2762
|
-
if (obj !== null && obj.type ===
|
|
2513
|
+
if (obj !== null && obj.type === import_utils17.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
2763
2514
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
2764
2515
|
const variable = findVariable2(scope, obj.name);
|
|
2765
2516
|
if (variable !== null) {
|
|
@@ -2772,7 +2523,7 @@ var prefer_schema_for_api_payload_default = import_utils18.ESLintUtils.RuleCreat
|
|
|
2772
2523
|
});
|
|
2773
2524
|
|
|
2774
2525
|
// src/rules/prefer-semantic-colors.ts
|
|
2775
|
-
var
|
|
2526
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
2776
2527
|
var import_fs = require("fs");
|
|
2777
2528
|
var import_path = require("path");
|
|
2778
2529
|
|
|
@@ -2825,6 +2576,7 @@ var DETECTION_FILES = [
|
|
|
2825
2576
|
"src/styles/globals.css",
|
|
2826
2577
|
"styles/globals.css"
|
|
2827
2578
|
];
|
|
2579
|
+
var MAX_UPWARD_DEPTH = 8;
|
|
2828
2580
|
var semanticTokenCache = /* @__PURE__ */ new Map();
|
|
2829
2581
|
var SVG_DEFS_CONTAINERS = /* @__PURE__ */ new Set([
|
|
2830
2582
|
"mask",
|
|
@@ -2846,8 +2598,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
2846
2598
|
]);
|
|
2847
2599
|
function jsxElementName(node) {
|
|
2848
2600
|
const name = node.openingElement.name;
|
|
2849
|
-
if (name.type ===
|
|
2850
|
-
if (name.type ===
|
|
2601
|
+
if (name.type === import_utils18.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
2602
|
+
if (name.type === import_utils18.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils18.AST_NODE_TYPES.JSXIdentifier) {
|
|
2851
2603
|
return name.property.name;
|
|
2852
2604
|
}
|
|
2853
2605
|
return null;
|
|
@@ -2858,7 +2610,7 @@ function isSvgLikeElementName(name) {
|
|
|
2858
2610
|
var isInsideSvg = (node) => {
|
|
2859
2611
|
let current = node.parent;
|
|
2860
2612
|
while (current !== void 0 && current !== null) {
|
|
2861
|
-
if (current.type ===
|
|
2613
|
+
if (current.type === import_utils18.AST_NODE_TYPES.JSXElement) {
|
|
2862
2614
|
const name = jsxElementName(current);
|
|
2863
2615
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
2864
2616
|
}
|
|
@@ -2869,7 +2621,7 @@ var isInsideSvg = (node) => {
|
|
|
2869
2621
|
var isInsideIconFactoryPath = (node) => {
|
|
2870
2622
|
let current = node.parent;
|
|
2871
2623
|
while (current !== void 0 && current !== null) {
|
|
2872
|
-
if (current.type ===
|
|
2624
|
+
if (current.type === import_utils18.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils18.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils18.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils18.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
2873
2625
|
return true;
|
|
2874
2626
|
}
|
|
2875
2627
|
current = current.parent;
|
|
@@ -2879,9 +2631,15 @@ var isInsideIconFactoryPath = (node) => {
|
|
|
2879
2631
|
var hasSemanticTokenSystem = (filename) => {
|
|
2880
2632
|
let dir = (0, import_path.dirname)(filename);
|
|
2881
2633
|
const root = (0, import_path.parse)(dir).root;
|
|
2882
|
-
|
|
2634
|
+
const visited = [];
|
|
2635
|
+
let answer;
|
|
2636
|
+
for (let depth = 0; depth < MAX_UPWARD_DEPTH; depth += 1) {
|
|
2883
2637
|
const cached = semanticTokenCache.get(dir);
|
|
2884
|
-
if (cached !== void 0)
|
|
2638
|
+
if (cached !== void 0) {
|
|
2639
|
+
answer = cached;
|
|
2640
|
+
break;
|
|
2641
|
+
}
|
|
2642
|
+
visited.push(dir);
|
|
2885
2643
|
let found = false;
|
|
2886
2644
|
for (const rel of DETECTION_FILES) {
|
|
2887
2645
|
const candidate = (0, import_path.join)(dir, rel);
|
|
@@ -2898,18 +2656,26 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
2898
2656
|
} catch {
|
|
2899
2657
|
}
|
|
2900
2658
|
}
|
|
2901
|
-
|
|
2902
|
-
|
|
2659
|
+
if (found) {
|
|
2660
|
+
answer = true;
|
|
2661
|
+
break;
|
|
2662
|
+
}
|
|
2663
|
+
if (dir === root) {
|
|
2664
|
+
answer = false;
|
|
2665
|
+
break;
|
|
2666
|
+
}
|
|
2903
2667
|
dir = (0, import_path.dirname)(dir);
|
|
2904
2668
|
}
|
|
2905
|
-
return false;
|
|
2669
|
+
if (answer === void 0) return false;
|
|
2670
|
+
for (const seen of visited) semanticTokenCache.set(seen, answer);
|
|
2671
|
+
return answer;
|
|
2906
2672
|
};
|
|
2907
2673
|
var propName = (key) => {
|
|
2908
|
-
if (key.type ===
|
|
2909
|
-
if (key.type ===
|
|
2674
|
+
if (key.type === import_utils18.AST_NODE_TYPES.Identifier) return key.name;
|
|
2675
|
+
if (key.type === import_utils18.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
2910
2676
|
return null;
|
|
2911
2677
|
};
|
|
2912
|
-
var prefer_semantic_colors_default =
|
|
2678
|
+
var prefer_semantic_colors_default = import_utils18.ESLintUtils.RuleCreator(
|
|
2913
2679
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2914
2680
|
)({
|
|
2915
2681
|
name: "prefer-semantic-colors",
|
|
@@ -2952,27 +2718,27 @@ var prefer_semantic_colors_default = import_utils19.ESLintUtils.RuleCreator(
|
|
|
2952
2718
|
const checkClassNode = (node) => {
|
|
2953
2719
|
if (node === null) return;
|
|
2954
2720
|
switch (node.type) {
|
|
2955
|
-
case
|
|
2721
|
+
case import_utils18.AST_NODE_TYPES.Literal:
|
|
2956
2722
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
2957
2723
|
break;
|
|
2958
|
-
case
|
|
2724
|
+
case import_utils18.AST_NODE_TYPES.TemplateLiteral:
|
|
2959
2725
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
2960
2726
|
break;
|
|
2961
|
-
case
|
|
2727
|
+
case import_utils18.AST_NODE_TYPES.ArrayExpression:
|
|
2962
2728
|
for (const element of node.elements) {
|
|
2963
|
-
if (element !== null && element.type !==
|
|
2729
|
+
if (element !== null && element.type !== import_utils18.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
2964
2730
|
}
|
|
2965
2731
|
break;
|
|
2966
|
-
case
|
|
2732
|
+
case import_utils18.AST_NODE_TYPES.ObjectExpression:
|
|
2967
2733
|
for (const property of node.properties) {
|
|
2968
|
-
if (property.type ===
|
|
2734
|
+
if (property.type === import_utils18.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
2969
2735
|
}
|
|
2970
2736
|
break;
|
|
2971
|
-
case
|
|
2737
|
+
case import_utils18.AST_NODE_TYPES.ConditionalExpression:
|
|
2972
2738
|
checkClassNode(node.consequent);
|
|
2973
2739
|
checkClassNode(node.alternate);
|
|
2974
2740
|
break;
|
|
2975
|
-
case
|
|
2741
|
+
case import_utils18.AST_NODE_TYPES.LogicalExpression:
|
|
2976
2742
|
checkClassNode(node.right);
|
|
2977
2743
|
break;
|
|
2978
2744
|
default:
|
|
@@ -2980,29 +2746,29 @@ var prefer_semantic_colors_default = import_utils19.ESLintUtils.RuleCreator(
|
|
|
2980
2746
|
}
|
|
2981
2747
|
};
|
|
2982
2748
|
const checkColorValueNode = (node) => {
|
|
2983
|
-
if (node.type ===
|
|
2749
|
+
if (node.type === import_utils18.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value)) {
|
|
2984
2750
|
context.report({ node, messageId: "inlineColor", data: { value: node.value } });
|
|
2985
2751
|
}
|
|
2986
2752
|
};
|
|
2987
2753
|
return {
|
|
2988
2754
|
"JSXAttribute[name.name='className']"(node) {
|
|
2989
2755
|
if (node.value === null) return;
|
|
2990
|
-
if (node.value.type ===
|
|
2991
|
-
else if (node.value.type ===
|
|
2992
|
-
if (node.value.expression.type !==
|
|
2756
|
+
if (node.value.type === import_utils18.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
2757
|
+
else if (node.value.type === import_utils18.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
2758
|
+
if (node.value.expression.type !== import_utils18.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
2993
2759
|
checkClassNode(node.value.expression);
|
|
2994
2760
|
}
|
|
2995
2761
|
}
|
|
2996
2762
|
},
|
|
2997
2763
|
CallExpression(node) {
|
|
2998
|
-
if (node.callee.type ===
|
|
2764
|
+
if (node.callee.type === import_utils18.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
2999
2765
|
for (const arg of node.arguments) {
|
|
3000
|
-
if (arg.type !==
|
|
2766
|
+
if (arg.type !== import_utils18.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
3001
2767
|
}
|
|
3002
2768
|
}
|
|
3003
2769
|
},
|
|
3004
2770
|
VariableDeclarator(node) {
|
|
3005
|
-
if (node.id.type ===
|
|
2771
|
+
if (node.id.type === import_utils18.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
3006
2772
|
checkClassNode(node.init);
|
|
3007
2773
|
}
|
|
3008
2774
|
},
|
|
@@ -3014,7 +2780,7 @@ var prefer_semantic_colors_default = import_utils19.ESLintUtils.RuleCreator(
|
|
|
3014
2780
|
// Neutral drawing literals and anything inside an SVG defs container are
|
|
3015
2781
|
// structural, not UI tokens, so they never fire.
|
|
3016
2782
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
3017
|
-
if (node.value?.type !==
|
|
2783
|
+
if (node.value?.type !== import_utils18.AST_NODE_TYPES.Literal) return;
|
|
3018
2784
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
3019
2785
|
return;
|
|
3020
2786
|
}
|
|
@@ -3031,7 +2797,7 @@ var prefer_semantic_colors_default = import_utils19.ESLintUtils.RuleCreator(
|
|
|
3031
2797
|
});
|
|
3032
2798
|
|
|
3033
2799
|
// src/rules/prefer-server-actions.ts
|
|
3034
|
-
var
|
|
2800
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
3035
2801
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
3036
2802
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
3037
2803
|
var SKIP_FILE_REGEX = /(?:\.test\.[jt]sx?$|\.spec\.[jt]sx?$|-(?:test|spec)\.[jt]sx?$|\/tests?\/|\/__tests__\/|\/__testfixtures__\/|\/scripts?\/|\/app\/api\/.*\/route\.[jt]sx?$|\/pages\/api\/)/;
|
|
@@ -3111,7 +2877,7 @@ function getPropertyNode(objNode, propName2) {
|
|
|
3111
2877
|
}
|
|
3112
2878
|
return null;
|
|
3113
2879
|
}
|
|
3114
|
-
var prefer_server_actions_default =
|
|
2880
|
+
var prefer_server_actions_default = import_utils19.ESLintUtils.RuleCreator(
|
|
3115
2881
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3116
2882
|
)({
|
|
3117
2883
|
name: "prefer-server-actions",
|
|
@@ -3185,116 +2951,37 @@ var prefer_server_actions_default = import_utils20.ESLintUtils.RuleCreator(
|
|
|
3185
2951
|
}
|
|
3186
2952
|
});
|
|
3187
2953
|
|
|
3188
|
-
// src/rules/prefer-shadcn.ts
|
|
3189
|
-
var import_utils21 = require("@typescript-eslint/utils");
|
|
3190
|
-
var REPLACEMENTS = {
|
|
3191
|
-
select: "Select",
|
|
3192
|
-
textarea: "Textarea",
|
|
3193
|
-
dialog: "Dialog"
|
|
3194
|
-
};
|
|
3195
|
-
var INPUT_TYPE_REPLACEMENTS = {
|
|
3196
|
-
checkbox: "Checkbox",
|
|
3197
|
-
radio: "RadioGroup",
|
|
3198
|
-
range: "Slider"
|
|
3199
|
-
};
|
|
3200
|
-
var SKIPPED_INPUT_TYPES = /* @__PURE__ */ new Set(["file", "hidden"]);
|
|
3201
|
-
var kebabCase = (component) => component.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3202
|
-
var literalTypeAttr = (node) => {
|
|
3203
|
-
for (const attribute of node.attributes) {
|
|
3204
|
-
if (attribute.type !== import_utils21.AST_NODE_TYPES.JSXAttribute || attribute.name.type !== import_utils21.AST_NODE_TYPES.JSXIdentifier || attribute.name.name !== "type") {
|
|
3205
|
-
continue;
|
|
3206
|
-
}
|
|
3207
|
-
if (attribute.value?.type === import_utils21.AST_NODE_TYPES.Literal && typeof attribute.value.value === "string") {
|
|
3208
|
-
return { kind: "literal", value: attribute.value.value.toLowerCase() };
|
|
3209
|
-
}
|
|
3210
|
-
return { kind: "dynamic" };
|
|
3211
|
-
}
|
|
3212
|
-
return null;
|
|
3213
|
-
};
|
|
3214
|
-
var hasFileAcceptAttr = (node) => node.attributes.some(
|
|
3215
|
-
(attribute) => attribute.type === import_utils21.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils21.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "accept"
|
|
3216
|
-
);
|
|
3217
|
-
var resolveInputReplacement = (node) => {
|
|
3218
|
-
const typeAttr = literalTypeAttr(node);
|
|
3219
|
-
if (hasFileAcceptAttr(node)) return null;
|
|
3220
|
-
if (typeAttr === null || typeAttr.kind === "dynamic") return "Input";
|
|
3221
|
-
if (SKIPPED_INPUT_TYPES.has(typeAttr.value)) return null;
|
|
3222
|
-
return INPUT_TYPE_REPLACEMENTS[typeAttr.value] ?? "Input";
|
|
3223
|
-
};
|
|
3224
|
-
var prefer_shadcn_default = import_utils21.ESLintUtils.RuleCreator(
|
|
3225
|
-
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3226
|
-
)({
|
|
3227
|
-
name: "prefer-shadcn",
|
|
3228
|
-
meta: {
|
|
3229
|
-
type: "suggestion",
|
|
3230
|
-
docs: {
|
|
3231
|
-
description: "Prefer shadcn/ui form primitives over native `<input>`, `<select>`, `<textarea>`, and `<dialog>` elements."
|
|
3232
|
-
},
|
|
3233
|
-
schema: [],
|
|
3234
|
-
messages: {
|
|
3235
|
-
preferShadcn: "Use the shadcn <{{replacement}}> component from @/components/ui/{{lowercase}} instead of native <{{element}}>."
|
|
3236
|
-
}
|
|
3237
|
-
},
|
|
3238
|
-
defaultOptions: [],
|
|
3239
|
-
create(context) {
|
|
3240
|
-
if (isTestFile(context.filename) || isStoryFile(context.filename)) {
|
|
3241
|
-
return {};
|
|
3242
|
-
}
|
|
3243
|
-
return {
|
|
3244
|
-
JSXOpeningElement(node) {
|
|
3245
|
-
if (node.name.type !== "JSXIdentifier") {
|
|
3246
|
-
return;
|
|
3247
|
-
}
|
|
3248
|
-
const elementName = node.name.name;
|
|
3249
|
-
const replacement = elementName === "input" ? resolveInputReplacement(node) : REPLACEMENTS[elementName];
|
|
3250
|
-
if (replacement === void 0 || replacement === null) {
|
|
3251
|
-
return;
|
|
3252
|
-
}
|
|
3253
|
-
context.report({
|
|
3254
|
-
node,
|
|
3255
|
-
messageId: "preferShadcn",
|
|
3256
|
-
data: {
|
|
3257
|
-
element: elementName,
|
|
3258
|
-
replacement,
|
|
3259
|
-
lowercase: kebabCase(replacement)
|
|
3260
|
-
}
|
|
3261
|
-
});
|
|
3262
|
-
}
|
|
3263
|
-
};
|
|
3264
|
-
}
|
|
3265
|
-
});
|
|
3266
|
-
|
|
3267
2954
|
// src/rules/require-assert-never.ts
|
|
3268
|
-
var
|
|
2955
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
3269
2956
|
var isAssertNeverCall = (expression) => {
|
|
3270
|
-
if (expression.type !==
|
|
2957
|
+
if (expression.type !== import_utils20.AST_NODE_TYPES.CallExpression) return false;
|
|
3271
2958
|
const callee = expression.callee;
|
|
3272
|
-
if (callee.type ===
|
|
2959
|
+
if (callee.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3273
2960
|
return callee.name === "assertNever";
|
|
3274
2961
|
}
|
|
3275
|
-
if (callee.type ===
|
|
2962
|
+
if (callee.type === import_utils20.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
3276
2963
|
return callee.property.name === "assertNever";
|
|
3277
2964
|
}
|
|
3278
2965
|
return false;
|
|
3279
2966
|
};
|
|
3280
2967
|
var statementContainsAssertNever = (statement) => {
|
|
3281
|
-
if (statement.type ===
|
|
2968
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.ExpressionStatement) {
|
|
3282
2969
|
return isAssertNeverCall(statement.expression);
|
|
3283
2970
|
}
|
|
3284
|
-
if (statement.type ===
|
|
2971
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.ThrowStatement) {
|
|
3285
2972
|
return isAssertNeverCall(statement.argument);
|
|
3286
2973
|
}
|
|
3287
|
-
if (statement.type ===
|
|
2974
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.ReturnStatement) {
|
|
3288
2975
|
return statement.argument !== null && isAssertNeverCall(statement.argument);
|
|
3289
2976
|
}
|
|
3290
|
-
if (statement.type ===
|
|
2977
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.BlockStatement) {
|
|
3291
2978
|
return statement.body.some(statementContainsAssertNever);
|
|
3292
2979
|
}
|
|
3293
2980
|
return false;
|
|
3294
2981
|
};
|
|
3295
2982
|
var isRuntimeHandlingStatement = (statement) => {
|
|
3296
|
-
if (statement.type ===
|
|
3297
|
-
if (statement.type ===
|
|
2983
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.EmptyStatement) return false;
|
|
2984
|
+
if (statement.type === import_utils20.AST_NODE_TYPES.BlockStatement) {
|
|
3298
2985
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
3299
2986
|
}
|
|
3300
2987
|
return true;
|
|
@@ -3310,12 +2997,12 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
3310
2997
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
3311
2998
|
}
|
|
3312
2999
|
const only = defaultCase.consequent[0];
|
|
3313
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
3000
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils20.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
3314
3001
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
3315
3002
|
}
|
|
3316
3003
|
return false;
|
|
3317
3004
|
};
|
|
3318
|
-
var require_assert_never_default =
|
|
3005
|
+
var require_assert_never_default = import_utils20.ESLintUtils.RuleCreator(
|
|
3319
3006
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3320
3007
|
)({
|
|
3321
3008
|
name: "require-assert-never",
|
|
@@ -3353,7 +3040,7 @@ var require_assert_never_default = import_utils22.ESLintUtils.RuleCreator(
|
|
|
3353
3040
|
});
|
|
3354
3041
|
|
|
3355
3042
|
// src/rules/require-zod-form-validation.ts
|
|
3356
|
-
var
|
|
3043
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
3357
3044
|
|
|
3358
3045
|
// src/rules/_zod.ts
|
|
3359
3046
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -3364,14 +3051,14 @@ var ZOD_SCHEMA_NAME_RE = /Schema$|^Z[A-Z]/;
|
|
|
3364
3051
|
var looksLikeZodSchema = (node) => {
|
|
3365
3052
|
let current = node;
|
|
3366
3053
|
while (true) {
|
|
3367
|
-
if (current.type ===
|
|
3054
|
+
if (current.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3368
3055
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
3369
3056
|
}
|
|
3370
|
-
if (current.type ===
|
|
3057
|
+
if (current.type === import_utils21.AST_NODE_TYPES.CallExpression) {
|
|
3371
3058
|
current = current.callee;
|
|
3372
3059
|
continue;
|
|
3373
3060
|
}
|
|
3374
|
-
if (current.type ===
|
|
3061
|
+
if (current.type === import_utils21.AST_NODE_TYPES.MemberExpression) {
|
|
3375
3062
|
current = current.object;
|
|
3376
3063
|
continue;
|
|
3377
3064
|
}
|
|
@@ -3379,25 +3066,25 @@ var looksLikeZodSchema = (node) => {
|
|
|
3379
3066
|
}
|
|
3380
3067
|
};
|
|
3381
3068
|
var isZodParseCall = (node) => {
|
|
3382
|
-
if (node.type !==
|
|
3069
|
+
if (node.type !== import_utils21.AST_NODE_TYPES.CallExpression) return false;
|
|
3383
3070
|
const callee = node.callee;
|
|
3384
|
-
if (callee.type !==
|
|
3071
|
+
if (callee.type !== import_utils21.AST_NODE_TYPES.MemberExpression) return false;
|
|
3385
3072
|
if (callee.computed) return false;
|
|
3386
|
-
if (callee.property.type !==
|
|
3073
|
+
if (callee.property.type !== import_utils21.AST_NODE_TYPES.Identifier) return false;
|
|
3387
3074
|
const method = callee.property.name;
|
|
3388
3075
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
3389
3076
|
return looksLikeZodSchema(callee.object);
|
|
3390
3077
|
};
|
|
3391
3078
|
var isFormDataMethodCall = (node) => {
|
|
3392
3079
|
let current = node;
|
|
3393
|
-
if (current.type ===
|
|
3080
|
+
if (current.type === import_utils21.AST_NODE_TYPES.AwaitExpression) {
|
|
3394
3081
|
current = current.argument;
|
|
3395
3082
|
}
|
|
3396
|
-
if (current.type !==
|
|
3083
|
+
if (current.type !== import_utils21.AST_NODE_TYPES.CallExpression) return false;
|
|
3397
3084
|
const callee = current.callee;
|
|
3398
|
-
return callee.type ===
|
|
3085
|
+
return callee.type === import_utils21.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils21.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
3399
3086
|
};
|
|
3400
|
-
var require_zod_form_validation_default =
|
|
3087
|
+
var require_zod_form_validation_default = import_utils21.ESLintUtils.RuleCreator(
|
|
3401
3088
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3402
3089
|
)({
|
|
3403
3090
|
name: "require-zod-form-validation",
|
|
@@ -3417,14 +3104,14 @@ var require_zod_form_validation_default = import_utils23.ESLintUtils.RuleCreator
|
|
|
3417
3104
|
return {};
|
|
3418
3105
|
}
|
|
3419
3106
|
const isFormSourceIdentifier = (node) => {
|
|
3420
|
-
if (node.type !==
|
|
3107
|
+
if (node.type !== import_utils21.AST_NODE_TYPES.Identifier) return false;
|
|
3421
3108
|
if (/formdata/i.test(node.name)) return true;
|
|
3422
3109
|
let scope = context.sourceCode.getScope(node);
|
|
3423
3110
|
while (scope !== null) {
|
|
3424
3111
|
const variable = scope.set.get(node.name);
|
|
3425
3112
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
3426
3113
|
const def = variable.defs[0];
|
|
3427
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
3114
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils21.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
3428
3115
|
return isFormDataMethodCall(def.node.init);
|
|
3429
3116
|
}
|
|
3430
3117
|
return false;
|
|
@@ -3435,8 +3122,8 @@ var require_zod_form_validation_default = import_utils23.ESLintUtils.RuleCreator
|
|
|
3435
3122
|
};
|
|
3436
3123
|
const isFormDataGetCall = (node) => {
|
|
3437
3124
|
const callee = node.callee;
|
|
3438
|
-
if (callee.type !==
|
|
3439
|
-
if (callee.property.type !==
|
|
3125
|
+
if (callee.type !== import_utils21.AST_NODE_TYPES.MemberExpression) return false;
|
|
3126
|
+
if (callee.property.type !== import_utils21.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
3440
3127
|
return false;
|
|
3441
3128
|
}
|
|
3442
3129
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -3451,11 +3138,11 @@ var require_zod_form_validation_default = import_utils23.ESLintUtils.RuleCreator
|
|
|
3451
3138
|
};
|
|
3452
3139
|
const isInstanceofNarrowing = (node) => {
|
|
3453
3140
|
const parent = node.parent;
|
|
3454
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
3141
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils21.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node;
|
|
3455
3142
|
};
|
|
3456
3143
|
const boundDeclarator = (node) => {
|
|
3457
3144
|
const parent = node.parent;
|
|
3458
|
-
if (parent.type ===
|
|
3145
|
+
if (parent.type === import_utils21.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils21.AST_NODE_TYPES.Identifier) {
|
|
3459
3146
|
return parent;
|
|
3460
3147
|
}
|
|
3461
3148
|
return null;
|
|
@@ -3483,7 +3170,7 @@ var require_zod_form_validation_default = import_utils23.ESLintUtils.RuleCreator
|
|
|
3483
3170
|
});
|
|
3484
3171
|
|
|
3485
3172
|
// src/rules/zod-naming-convention.ts
|
|
3486
|
-
var
|
|
3173
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
3487
3174
|
var CONVENTIONS = {
|
|
3488
3175
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
3489
3176
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -3507,15 +3194,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
3507
3194
|
"registry",
|
|
3508
3195
|
"implement"
|
|
3509
3196
|
]);
|
|
3510
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
3197
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils22.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
3511
3198
|
var calleeChainStartsWithZ = (node) => {
|
|
3512
3199
|
let current = node;
|
|
3513
|
-
while (current.type ===
|
|
3200
|
+
while (current.type === import_utils22.AST_NODE_TYPES.MemberExpression) {
|
|
3514
3201
|
const receiver = current.object;
|
|
3515
|
-
if (receiver.type ===
|
|
3202
|
+
if (receiver.type === import_utils22.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
3516
3203
|
return true;
|
|
3517
3204
|
}
|
|
3518
|
-
if (receiver.type ===
|
|
3205
|
+
if (receiver.type === import_utils22.AST_NODE_TYPES.CallExpression) {
|
|
3519
3206
|
current = receiver.callee;
|
|
3520
3207
|
continue;
|
|
3521
3208
|
}
|
|
@@ -3523,7 +3210,7 @@ var calleeChainStartsWithZ = (node) => {
|
|
|
3523
3210
|
}
|
|
3524
3211
|
return false;
|
|
3525
3212
|
};
|
|
3526
|
-
var zod_naming_convention_default =
|
|
3213
|
+
var zod_naming_convention_default = import_utils22.ESLintUtils.RuleCreator(
|
|
3527
3214
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3528
3215
|
)({
|
|
3529
3216
|
name: "zod-naming-convention",
|
|
@@ -3562,13 +3249,13 @@ var zod_naming_convention_default = import_utils24.ESLintUtils.RuleCreator(
|
|
|
3562
3249
|
VariableDeclarator(node) {
|
|
3563
3250
|
const init = node.init;
|
|
3564
3251
|
if (init === null || init === void 0) return;
|
|
3565
|
-
if (init.type !==
|
|
3252
|
+
if (init.type !== import_utils22.AST_NODE_TYPES.CallExpression) return;
|
|
3566
3253
|
const callee = init.callee;
|
|
3567
|
-
if (callee.type !==
|
|
3254
|
+
if (callee.type !== import_utils22.AST_NODE_TYPES.MemberExpression) return;
|
|
3568
3255
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
3569
3256
|
const terminal = terminalMethodName(callee);
|
|
3570
3257
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
3571
|
-
if (node.id.type !==
|
|
3258
|
+
if (node.id.type !== import_utils22.AST_NODE_TYPES.Identifier) return;
|
|
3572
3259
|
if (test.test(node.id.name)) return;
|
|
3573
3260
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
3574
3261
|
context.report({
|
|
@@ -3581,7 +3268,7 @@ var zod_naming_convention_default = import_utils24.ESLintUtils.RuleCreator(
|
|
|
3581
3268
|
});
|
|
3582
3269
|
|
|
3583
3270
|
// src/rules/no-cors-wildcard-with-credentials.ts
|
|
3584
|
-
var
|
|
3271
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
3585
3272
|
var ACAO_HEADER = "access-control-allow-origin";
|
|
3586
3273
|
var ACAC_HEADER = "access-control-allow-credentials";
|
|
3587
3274
|
var HEADER_SET_METHODS = /* @__PURE__ */ new Set(["setheader", "set", "append"]);
|
|
@@ -3613,17 +3300,17 @@ function subtreeContainsStarLiteral(node) {
|
|
|
3613
3300
|
const value = node[key];
|
|
3614
3301
|
if (Array.isArray(value)) {
|
|
3615
3302
|
for (const child of value) {
|
|
3616
|
-
if (
|
|
3303
|
+
if (isNode2(child) && subtreeContainsStarLiteral(child)) {
|
|
3617
3304
|
return true;
|
|
3618
3305
|
}
|
|
3619
3306
|
}
|
|
3620
|
-
} else if (
|
|
3307
|
+
} else if (isNode2(value) && subtreeContainsStarLiteral(value)) {
|
|
3621
3308
|
return true;
|
|
3622
3309
|
}
|
|
3623
3310
|
}
|
|
3624
3311
|
return false;
|
|
3625
3312
|
}
|
|
3626
|
-
function
|
|
3313
|
+
function isNode2(value) {
|
|
3627
3314
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
3628
3315
|
}
|
|
3629
3316
|
function propertyKeyName(prop) {
|
|
@@ -3639,7 +3326,7 @@ function propertyKeyName(prop) {
|
|
|
3639
3326
|
}
|
|
3640
3327
|
return void 0;
|
|
3641
3328
|
}
|
|
3642
|
-
function
|
|
3329
|
+
function calleeName2(node) {
|
|
3643
3330
|
const callee = node.callee;
|
|
3644
3331
|
if (callee.type === "Identifier") {
|
|
3645
3332
|
return callee.name;
|
|
@@ -3650,7 +3337,7 @@ function calleeName3(node) {
|
|
|
3650
3337
|
return void 0;
|
|
3651
3338
|
}
|
|
3652
3339
|
function isCorsWildcardCredentialsCall(node) {
|
|
3653
|
-
const name =
|
|
3340
|
+
const name = calleeName2(node);
|
|
3654
3341
|
if (name === void 0 || name.toLowerCase() !== "cors") {
|
|
3655
3342
|
return false;
|
|
3656
3343
|
}
|
|
@@ -3723,7 +3410,7 @@ function enclosingScope(node) {
|
|
|
3723
3410
|
}
|
|
3724
3411
|
return void 0;
|
|
3725
3412
|
}
|
|
3726
|
-
var no_cors_wildcard_with_credentials_default =
|
|
3413
|
+
var no_cors_wildcard_with_credentials_default = import_utils23.ESLintUtils.RuleCreator(
|
|
3727
3414
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3728
3415
|
)({
|
|
3729
3416
|
name: "no-cors-wildcard-with-credentials",
|
|
@@ -3791,9 +3478,9 @@ var no_cors_wildcard_with_credentials_default = import_utils25.ESLintUtils.RuleC
|
|
|
3791
3478
|
});
|
|
3792
3479
|
|
|
3793
3480
|
// src/rules/no-silent-promise-catch.ts
|
|
3794
|
-
var
|
|
3481
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
3795
3482
|
function isBodyParseCall(node) {
|
|
3796
|
-
return node.type ===
|
|
3483
|
+
return node.type === import_utils24.AST_NODE_TYPES.CallExpression && node.arguments.length === 0 && node.callee.type === import_utils24.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils24.AST_NODE_TYPES.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
3797
3484
|
}
|
|
3798
3485
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
3799
3486
|
"cancel",
|
|
@@ -3808,21 +3495,21 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
3808
3495
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
3809
3496
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
3810
3497
|
function isTeardownCall(node) {
|
|
3811
|
-
return node.type ===
|
|
3498
|
+
return node.type === import_utils24.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils24.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils24.AST_NODE_TYPES.Identifier && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
3812
3499
|
}
|
|
3813
3500
|
function isSilentExpression(node) {
|
|
3814
3501
|
switch (node.type) {
|
|
3815
|
-
case
|
|
3502
|
+
case import_utils24.AST_NODE_TYPES.Literal:
|
|
3816
3503
|
return !("regex" in node);
|
|
3817
|
-
case
|
|
3504
|
+
case import_utils24.AST_NODE_TYPES.Identifier:
|
|
3818
3505
|
return node.name === "undefined";
|
|
3819
|
-
case
|
|
3820
|
-
return node.operator === "void" && node.argument.type ===
|
|
3821
|
-
case
|
|
3506
|
+
case import_utils24.AST_NODE_TYPES.UnaryExpression:
|
|
3507
|
+
return node.operator === "void" && node.argument.type === import_utils24.AST_NODE_TYPES.Literal;
|
|
3508
|
+
case import_utils24.AST_NODE_TYPES.ObjectExpression:
|
|
3822
3509
|
return node.properties.length === 0;
|
|
3823
|
-
case
|
|
3510
|
+
case import_utils24.AST_NODE_TYPES.ArrayExpression:
|
|
3824
3511
|
return node.elements.length === 0;
|
|
3825
|
-
case
|
|
3512
|
+
case import_utils24.AST_NODE_TYPES.TSAsExpression:
|
|
3826
3513
|
return isSilentExpression(node.expression);
|
|
3827
3514
|
default:
|
|
3828
3515
|
return false;
|
|
@@ -3830,7 +3517,7 @@ function isSilentExpression(node) {
|
|
|
3830
3517
|
}
|
|
3831
3518
|
function isSilentHandler(handler) {
|
|
3832
3519
|
const body = handler.body;
|
|
3833
|
-
if (body.type !==
|
|
3520
|
+
if (body.type !== import_utils24.AST_NODE_TYPES.BlockStatement) {
|
|
3834
3521
|
return isSilentExpression(body);
|
|
3835
3522
|
}
|
|
3836
3523
|
if (body.body.length === 0) {
|
|
@@ -3838,13 +3525,13 @@ function isSilentHandler(handler) {
|
|
|
3838
3525
|
}
|
|
3839
3526
|
if (body.body.length === 1) {
|
|
3840
3527
|
const only = body.body[0];
|
|
3841
|
-
if (only !== void 0 && only.type ===
|
|
3528
|
+
if (only !== void 0 && only.type === import_utils24.AST_NODE_TYPES.ReturnStatement) {
|
|
3842
3529
|
return only.argument === null || isSilentExpression(only.argument);
|
|
3843
3530
|
}
|
|
3844
3531
|
}
|
|
3845
3532
|
return false;
|
|
3846
3533
|
}
|
|
3847
|
-
var no_silent_promise_catch_default =
|
|
3534
|
+
var no_silent_promise_catch_default = import_utils24.ESLintUtils.RuleCreator(
|
|
3848
3535
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3849
3536
|
)({
|
|
3850
3537
|
name: "no-silent-promise-catch",
|
|
@@ -3869,7 +3556,7 @@ var no_silent_promise_catch_default = import_utils26.ESLintUtils.RuleCreator(
|
|
|
3869
3556
|
return true;
|
|
3870
3557
|
}
|
|
3871
3558
|
let statement = call;
|
|
3872
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
3559
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== import_utils24.AST_NODE_TYPES.VariableDeclaration) {
|
|
3873
3560
|
statement = statement.parent;
|
|
3874
3561
|
}
|
|
3875
3562
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -3881,7 +3568,7 @@ var no_silent_promise_catch_default = import_utils26.ESLintUtils.RuleCreator(
|
|
|
3881
3568
|
};
|
|
3882
3569
|
return {
|
|
3883
3570
|
CallExpression(node) {
|
|
3884
|
-
if (node.callee.type !==
|
|
3571
|
+
if (node.callee.type !== import_utils24.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.property.type !== import_utils24.AST_NODE_TYPES.Identifier || node.callee.property.name !== "catch") {
|
|
3885
3572
|
return;
|
|
3886
3573
|
}
|
|
3887
3574
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -3890,14 +3577,14 @@ var no_silent_promise_catch_default = import_utils26.ESLintUtils.RuleCreator(
|
|
|
3890
3577
|
if (isTeardownCall(node.callee.object)) {
|
|
3891
3578
|
return;
|
|
3892
3579
|
}
|
|
3893
|
-
if (node.parent.type ===
|
|
3580
|
+
if (node.parent.type === import_utils24.AST_NODE_TYPES.MemberExpression && node.parent.object === node) {
|
|
3894
3581
|
return;
|
|
3895
3582
|
}
|
|
3896
3583
|
if (node.arguments.length !== 1) {
|
|
3897
3584
|
return;
|
|
3898
3585
|
}
|
|
3899
3586
|
const handler = node.arguments[0];
|
|
3900
|
-
if (handler === void 0 || handler.type !==
|
|
3587
|
+
if (handler === void 0 || handler.type !== import_utils24.AST_NODE_TYPES.ArrowFunctionExpression && handler.type !== import_utils24.AST_NODE_TYPES.FunctionExpression) {
|
|
3901
3588
|
return;
|
|
3902
3589
|
}
|
|
3903
3590
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -3912,7 +3599,7 @@ var no_silent_promise_catch_default = import_utils26.ESLintUtils.RuleCreator(
|
|
|
3912
3599
|
});
|
|
3913
3600
|
|
|
3914
3601
|
// src/rules/require-fetch-timeout.ts
|
|
3915
|
-
var
|
|
3602
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
3916
3603
|
var CODEMOD_FIXTURE_RE = /[\\/]__testfixtures__[\\/]/;
|
|
3917
3604
|
var GLOBAL_OBJECTS = /* @__PURE__ */ new Set([
|
|
3918
3605
|
"globalThis",
|
|
@@ -3929,14 +3616,14 @@ function matchesAnyPattern2(filename, patterns) {
|
|
|
3929
3616
|
return false;
|
|
3930
3617
|
}
|
|
3931
3618
|
function initProvablyLacksSignal(init) {
|
|
3932
|
-
if (init.type !==
|
|
3619
|
+
if (init.type !== import_utils25.AST_NODE_TYPES.ObjectExpression) {
|
|
3933
3620
|
return false;
|
|
3934
3621
|
}
|
|
3935
3622
|
for (const prop of init.properties) {
|
|
3936
|
-
if (prop.type ===
|
|
3623
|
+
if (prop.type === import_utils25.AST_NODE_TYPES.SpreadElement) {
|
|
3937
3624
|
return false;
|
|
3938
3625
|
}
|
|
3939
|
-
if (prop.key.type ===
|
|
3626
|
+
if (prop.key.type === import_utils25.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils25.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
3940
3627
|
return false;
|
|
3941
3628
|
}
|
|
3942
3629
|
if (prop.computed) {
|
|
@@ -3946,9 +3633,9 @@ function initProvablyLacksSignal(init) {
|
|
|
3946
3633
|
return true;
|
|
3947
3634
|
}
|
|
3948
3635
|
function isStringish(node) {
|
|
3949
|
-
return node.type ===
|
|
3636
|
+
return node.type === import_utils25.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils25.AST_NODE_TYPES.TemplateLiteral;
|
|
3950
3637
|
}
|
|
3951
|
-
var require_fetch_timeout_default =
|
|
3638
|
+
var require_fetch_timeout_default = import_utils25.ESLintUtils.RuleCreator(
|
|
3952
3639
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3953
3640
|
)({
|
|
3954
3641
|
name: "require-fetch-timeout",
|
|
@@ -3985,14 +3672,14 @@ var require_fetch_timeout_default = import_utils27.ESLintUtils.RuleCreator(
|
|
|
3985
3672
|
}
|
|
3986
3673
|
function resolvesToGlobal(identifier) {
|
|
3987
3674
|
const scope = context.sourceCode.getScope(identifier);
|
|
3988
|
-
const variable =
|
|
3675
|
+
const variable = import_utils25.ASTUtils.findVariable(scope, identifier.name);
|
|
3989
3676
|
return variable === null || variable.defs.length === 0;
|
|
3990
3677
|
}
|
|
3991
3678
|
function isGlobalFetchCall2(callee) {
|
|
3992
|
-
if (callee.type ===
|
|
3679
|
+
if (callee.type === import_utils25.AST_NODE_TYPES.Identifier) {
|
|
3993
3680
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
3994
3681
|
}
|
|
3995
|
-
return callee.type ===
|
|
3682
|
+
return callee.type === import_utils25.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils25.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils25.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
3996
3683
|
}
|
|
3997
3684
|
return {
|
|
3998
3685
|
CallExpression(node) {
|
|
@@ -4011,100 +3698,13 @@ var require_fetch_timeout_default = import_utils27.ESLintUtils.RuleCreator(
|
|
|
4011
3698
|
}
|
|
4012
3699
|
});
|
|
4013
3700
|
|
|
4014
|
-
// src/rules/require-schema-validate-search.ts
|
|
4015
|
-
var import_utils28 = require("@typescript-eslint/utils");
|
|
4016
|
-
var VALIDATOR_METHODS = /* @__PURE__ */ new Set([
|
|
4017
|
-
"parse",
|
|
4018
|
-
"safeParse",
|
|
4019
|
-
"decode"
|
|
4020
|
-
]);
|
|
4021
|
-
function isConstTypeAnnotation(typeAnnotation) {
|
|
4022
|
-
return typeAnnotation.type === import_utils28.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeName.type === import_utils28.AST_NODE_TYPES.Identifier && typeAnnotation.typeName.name === "const";
|
|
4023
|
-
}
|
|
4024
|
-
function isValidatorCall(node) {
|
|
4025
|
-
return node.callee.type === import_utils28.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.property.type === import_utils28.AST_NODE_TYPES.Identifier && VALIDATOR_METHODS.has(node.callee.property.name);
|
|
4026
|
-
}
|
|
4027
|
-
function findCastExpression(node, insideValidatorArg) {
|
|
4028
|
-
if ((node.type === import_utils28.AST_NODE_TYPES.TSAsExpression || node.type === import_utils28.AST_NODE_TYPES.TSTypeAssertion) && !isConstTypeAnnotation(node.typeAnnotation) && !insideValidatorArg) {
|
|
4029
|
-
return node;
|
|
4030
|
-
}
|
|
4031
|
-
if (node.type === import_utils28.AST_NODE_TYPES.CallExpression && isValidatorCall(node)) {
|
|
4032
|
-
const inCallee = findCastExpression(node.callee, insideValidatorArg);
|
|
4033
|
-
if (inCallee !== null) {
|
|
4034
|
-
return inCallee;
|
|
4035
|
-
}
|
|
4036
|
-
for (const arg of node.arguments) {
|
|
4037
|
-
const found = findCastExpression(arg, true);
|
|
4038
|
-
if (found !== null) {
|
|
4039
|
-
return found;
|
|
4040
|
-
}
|
|
4041
|
-
}
|
|
4042
|
-
return null;
|
|
4043
|
-
}
|
|
4044
|
-
for (const key of Object.keys(node)) {
|
|
4045
|
-
if (key === "parent") {
|
|
4046
|
-
continue;
|
|
4047
|
-
}
|
|
4048
|
-
const value = node[key];
|
|
4049
|
-
const children = Array.isArray(value) ? value : [value];
|
|
4050
|
-
for (const child of children) {
|
|
4051
|
-
if (child !== null && typeof child === "object" && "type" in child && typeof child.type === "string") {
|
|
4052
|
-
const found = findCastExpression(
|
|
4053
|
-
child,
|
|
4054
|
-
insideValidatorArg
|
|
4055
|
-
);
|
|
4056
|
-
if (found !== null) {
|
|
4057
|
-
return found;
|
|
4058
|
-
}
|
|
4059
|
-
}
|
|
4060
|
-
}
|
|
4061
|
-
}
|
|
4062
|
-
return null;
|
|
4063
|
-
}
|
|
4064
|
-
var require_schema_validate_search_default = import_utils28.ESLintUtils.RuleCreator(
|
|
4065
|
-
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4066
|
-
)({
|
|
4067
|
-
name: "require-schema-validate-search",
|
|
4068
|
-
meta: {
|
|
4069
|
-
type: "problem",
|
|
4070
|
-
docs: {
|
|
4071
|
-
description: "Disallow `as` casts inside hand-rolled `validateSearch` functions; use a schema validator (e.g. zodValidator) so search params are validated at runtime."
|
|
4072
|
-
},
|
|
4073
|
-
schema: [],
|
|
4074
|
-
messages: {
|
|
4075
|
-
castInValidateSearch: "This `validateSearch` asserts the search-param shape with `as` instead of validating it \u2014 malformed query params flow through typed as clean data. Use a schema validator (e.g. `zodValidator(searchSchema)` or `searchSchema.parse`) instead of casting."
|
|
4076
|
-
}
|
|
4077
|
-
},
|
|
4078
|
-
defaultOptions: [],
|
|
4079
|
-
create(context) {
|
|
4080
|
-
if (isTestFile(context.filename)) {
|
|
4081
|
-
return {};
|
|
4082
|
-
}
|
|
4083
|
-
return {
|
|
4084
|
-
Property(node) {
|
|
4085
|
-
const isValidateSearchKey = !node.computed && node.key.type === import_utils28.AST_NODE_TYPES.Identifier && node.key.name === "validateSearch" || node.key.type === import_utils28.AST_NODE_TYPES.Literal && node.key.value === "validateSearch";
|
|
4086
|
-
if (!isValidateSearchKey) {
|
|
4087
|
-
return;
|
|
4088
|
-
}
|
|
4089
|
-
if (node.value.type !== import_utils28.AST_NODE_TYPES.ArrowFunctionExpression && node.value.type !== import_utils28.AST_NODE_TYPES.FunctionExpression) {
|
|
4090
|
-
return;
|
|
4091
|
-
}
|
|
4092
|
-
const cast = findCastExpression(node.value.body, false);
|
|
4093
|
-
if (cast !== null) {
|
|
4094
|
-
context.report({ node: cast, messageId: "castInValidateSearch" });
|
|
4095
|
-
}
|
|
4096
|
-
}
|
|
4097
|
-
};
|
|
4098
|
-
}
|
|
4099
|
-
});
|
|
4100
|
-
|
|
4101
3701
|
// src/rules/no-fat-try-blocks.ts
|
|
4102
|
-
var
|
|
3702
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
4103
3703
|
var MAX_TRY_BODY_STATEMENTS = 3;
|
|
4104
3704
|
var NESTED_FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
3705
|
+
import_utils26.AST_NODE_TYPES.FunctionDeclaration,
|
|
3706
|
+
import_utils26.AST_NODE_TYPES.FunctionExpression,
|
|
3707
|
+
import_utils26.AST_NODE_TYPES.ArrowFunctionExpression
|
|
4108
3708
|
]);
|
|
4109
3709
|
var PURE_METHODS = /* @__PURE__ */ new Set([
|
|
4110
3710
|
"map",
|
|
@@ -4197,25 +3797,25 @@ var PURE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4197
3797
|
"Response",
|
|
4198
3798
|
"AbortController"
|
|
4199
3799
|
]);
|
|
4200
|
-
function
|
|
3800
|
+
function isNode3(value) {
|
|
4201
3801
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
4202
3802
|
}
|
|
4203
3803
|
function isPureCall(node) {
|
|
4204
3804
|
const callee = node.callee;
|
|
4205
|
-
if (callee.type !==
|
|
3805
|
+
if (callee.type !== import_utils26.AST_NODE_TYPES.MemberExpression) {
|
|
4206
3806
|
return false;
|
|
4207
3807
|
}
|
|
4208
3808
|
const property = callee.property;
|
|
4209
|
-
if (property.type !==
|
|
3809
|
+
if (property.type !== import_utils26.AST_NODE_TYPES.Identifier) {
|
|
4210
3810
|
return false;
|
|
4211
3811
|
}
|
|
4212
|
-
if (callee.object.type ===
|
|
3812
|
+
if (callee.object.type === import_utils26.AST_NODE_TYPES.Identifier && PURE_NAMESPACES.has(callee.object.name)) {
|
|
4213
3813
|
return true;
|
|
4214
3814
|
}
|
|
4215
3815
|
return PURE_METHODS.has(property.name);
|
|
4216
3816
|
}
|
|
4217
3817
|
function isPureNew(node) {
|
|
4218
|
-
return node.callee.type ===
|
|
3818
|
+
return node.callee.type === import_utils26.AST_NODE_TYPES.Identifier && PURE_CONSTRUCTORS.has(node.callee.name);
|
|
4219
3819
|
}
|
|
4220
3820
|
function subtreeMatches(stmt, predicate) {
|
|
4221
3821
|
let found = false;
|
|
@@ -4237,11 +3837,11 @@ function subtreeMatches(stmt, predicate) {
|
|
|
4237
3837
|
const value = current[key];
|
|
4238
3838
|
if (Array.isArray(value)) {
|
|
4239
3839
|
for (const child of value) {
|
|
4240
|
-
if (
|
|
3840
|
+
if (isNode3(child)) {
|
|
4241
3841
|
visit(child);
|
|
4242
3842
|
}
|
|
4243
3843
|
}
|
|
4244
|
-
} else if (
|
|
3844
|
+
} else if (isNode3(value)) {
|
|
4245
3845
|
visit(value);
|
|
4246
3846
|
}
|
|
4247
3847
|
if (found) {
|
|
@@ -4252,20 +3852,20 @@ function subtreeMatches(stmt, predicate) {
|
|
|
4252
3852
|
visit(stmt);
|
|
4253
3853
|
return found;
|
|
4254
3854
|
}
|
|
4255
|
-
var hasAwait = (node) => subtreeMatches(node, (n) => n.type ===
|
|
3855
|
+
var hasAwait = (node) => subtreeMatches(node, (n) => n.type === import_utils26.AST_NODE_TYPES.AwaitExpression);
|
|
4256
3856
|
var hasThrowingCallOrNew = (node) => subtreeMatches(
|
|
4257
3857
|
node,
|
|
4258
|
-
(n) => n.type ===
|
|
3858
|
+
(n) => n.type === import_utils26.AST_NODE_TYPES.CallExpression && !isPureCall(n) || n.type === import_utils26.AST_NODE_TYPES.NewExpression && !isPureNew(n)
|
|
4259
3859
|
);
|
|
4260
3860
|
function unwrap2(expr) {
|
|
4261
3861
|
let current = expr;
|
|
4262
|
-
while (current.type ===
|
|
3862
|
+
while (current.type === import_utils26.AST_NODE_TYPES.ChainExpression || current.type === import_utils26.AST_NODE_TYPES.TSNonNullExpression) {
|
|
4263
3863
|
current = current.expression;
|
|
4264
3864
|
}
|
|
4265
3865
|
return current;
|
|
4266
3866
|
}
|
|
4267
3867
|
function isBareCallStatement(stmt) {
|
|
4268
|
-
return stmt.type ===
|
|
3868
|
+
return stmt.type === import_utils26.AST_NODE_TYPES.ExpressionStatement && unwrap2(stmt.expression).type === import_utils26.AST_NODE_TYPES.CallExpression;
|
|
4269
3869
|
}
|
|
4270
3870
|
function canThrow(stmt) {
|
|
4271
3871
|
if (hasAwait(stmt)) {
|
|
@@ -4274,10 +3874,10 @@ function canThrow(stmt) {
|
|
|
4274
3874
|
if (isBareCallStatement(stmt)) {
|
|
4275
3875
|
return false;
|
|
4276
3876
|
}
|
|
4277
|
-
if (stmt.type ===
|
|
3877
|
+
if (stmt.type === import_utils26.AST_NODE_TYPES.BlockStatement) {
|
|
4278
3878
|
return stmt.body.some(canThrow);
|
|
4279
3879
|
}
|
|
4280
|
-
if (stmt.type ===
|
|
3880
|
+
if (stmt.type === import_utils26.AST_NODE_TYPES.IfStatement) {
|
|
4281
3881
|
return hasThrowingCallOrNew(stmt.test) || canThrow(stmt.consequent) || stmt.alternate !== null && canThrow(stmt.alternate);
|
|
4282
3882
|
}
|
|
4283
3883
|
return hasThrowingCallOrNew(stmt);
|
|
@@ -4288,9 +3888,9 @@ function handlerRethrows(handler) {
|
|
|
4288
3888
|
}
|
|
4289
3889
|
const body = handler.body.body;
|
|
4290
3890
|
const last = body[body.length - 1];
|
|
4291
|
-
return last !== void 0 && last.type ===
|
|
3891
|
+
return last !== void 0 && last.type === import_utils26.AST_NODE_TYPES.ThrowStatement;
|
|
4292
3892
|
}
|
|
4293
|
-
var no_fat_try_blocks_default =
|
|
3893
|
+
var no_fat_try_blocks_default = import_utils26.ESLintUtils.RuleCreator(
|
|
4294
3894
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4295
3895
|
)({
|
|
4296
3896
|
name: "no-fat-try-blocks",
|
|
@@ -4334,7 +3934,7 @@ var no_fat_try_blocks_default = import_utils29.ESLintUtils.RuleCreator(
|
|
|
4334
3934
|
});
|
|
4335
3935
|
|
|
4336
3936
|
// src/rules/no-secret-in-log.ts
|
|
4337
|
-
var
|
|
3937
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
4338
3938
|
|
|
4339
3939
|
// src/rules/_secret_names.ts
|
|
4340
3940
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -4596,7 +4196,7 @@ function propertyKeyName2(prop) {
|
|
|
4596
4196
|
}
|
|
4597
4197
|
return null;
|
|
4598
4198
|
}
|
|
4599
|
-
var no_secret_in_log_default =
|
|
4199
|
+
var no_secret_in_log_default = import_utils27.ESLintUtils.RuleCreator(
|
|
4600
4200
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4601
4201
|
)({
|
|
4602
4202
|
name: "no-secret-in-log",
|
|
@@ -4672,74 +4272,25 @@ var no_secret_in_log_default = import_utils30.ESLintUtils.RuleCreator(
|
|
|
4672
4272
|
}
|
|
4673
4273
|
});
|
|
4674
4274
|
|
|
4675
|
-
// src/rules/no-unsafe-cast.ts
|
|
4676
|
-
var import_utils31 = require("@typescript-eslint/utils");
|
|
4677
|
-
var import_utils32 = require("@typescript-eslint/utils");
|
|
4678
|
-
function isAnyAnnotation(node) {
|
|
4679
|
-
return node.type === import_utils32.AST_NODE_TYPES.TSAnyKeyword;
|
|
4680
|
-
}
|
|
4681
|
-
function isConstAssertion(typeAnnotation) {
|
|
4682
|
-
return typeAnnotation.type === import_utils32.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeName.type === import_utils32.AST_NODE_TYPES.Identifier && typeAnnotation.typeName.name === "const";
|
|
4683
|
-
}
|
|
4684
|
-
var no_unsafe_cast_default = import_utils31.ESLintUtils.RuleCreator(
|
|
4685
|
-
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4686
|
-
)({
|
|
4687
|
-
name: "no-unsafe-cast",
|
|
4688
|
-
meta: {
|
|
4689
|
-
type: "problem",
|
|
4690
|
-
docs: {
|
|
4691
|
-
description: "Disallow `as any`/`<any>` casts and `as unknown as T` double-casts, which fully disable type checking."
|
|
4692
|
-
},
|
|
4693
|
-
schema: [],
|
|
4694
|
-
messages: {
|
|
4695
|
-
asAny: "`as any` disables type checking on this value. Narrow with a type guard, model the shape, or cast to a specific type instead.",
|
|
4696
|
-
doubleCast: "`as unknown as T` double-cast bypasses the compiler's structural check. Prefer a runtime validator (e.g. a zod schema) or an accurate type at the boundary."
|
|
4697
|
-
}
|
|
4698
|
-
},
|
|
4699
|
-
defaultOptions: [],
|
|
4700
|
-
create(context) {
|
|
4701
|
-
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
4702
|
-
return {};
|
|
4703
|
-
}
|
|
4704
|
-
function checkAssertion(node) {
|
|
4705
|
-
if (isConstAssertion(node.typeAnnotation)) {
|
|
4706
|
-
return;
|
|
4707
|
-
}
|
|
4708
|
-
if (isAnyAnnotation(node.typeAnnotation)) {
|
|
4709
|
-
context.report({ node, messageId: "asAny" });
|
|
4710
|
-
return;
|
|
4711
|
-
}
|
|
4712
|
-
const inner = node.expression;
|
|
4713
|
-
if (inner.type === import_utils32.AST_NODE_TYPES.TSAsExpression || inner.type === import_utils32.AST_NODE_TYPES.TSTypeAssertion) {
|
|
4714
|
-
context.report({ node, messageId: "doubleCast" });
|
|
4715
|
-
}
|
|
4716
|
-
}
|
|
4717
|
-
return {
|
|
4718
|
-
TSAsExpression: checkAssertion,
|
|
4719
|
-
TSTypeAssertion: checkAssertion
|
|
4720
|
-
};
|
|
4721
|
-
}
|
|
4722
|
-
});
|
|
4723
|
-
|
|
4724
4275
|
// src/rules/no-unsafe-mock-casting.ts
|
|
4725
|
-
var
|
|
4726
|
-
var
|
|
4276
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
4277
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
4727
4278
|
function isMockTypeReference(node) {
|
|
4728
|
-
if (node.type !==
|
|
4279
|
+
if (node.type !== import_utils29.AST_NODE_TYPES.TSTypeReference) {
|
|
4729
4280
|
return false;
|
|
4730
4281
|
}
|
|
4731
4282
|
const typeName = node.typeName;
|
|
4732
|
-
if (typeName.type ===
|
|
4283
|
+
if (typeName.type === import_utils29.AST_NODE_TYPES.Identifier) {
|
|
4733
4284
|
const name = typeName.name;
|
|
4734
4285
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
4735
4286
|
}
|
|
4736
|
-
if (typeName.type ===
|
|
4287
|
+
if (typeName.type === import_utils29.AST_NODE_TYPES.TSQualifiedName) {
|
|
4737
4288
|
const rightName = typeName.right.name;
|
|
4738
4289
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
4739
4290
|
}
|
|
4740
4291
|
return false;
|
|
4741
4292
|
}
|
|
4742
|
-
var no_unsafe_mock_casting_default =
|
|
4293
|
+
var no_unsafe_mock_casting_default = import_utils28.ESLintUtils.RuleCreator(
|
|
4743
4294
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4744
4295
|
)({
|
|
4745
4296
|
name: "no-unsafe-mock-casting",
|
|
@@ -4771,7 +4322,7 @@ var no_unsafe_mock_casting_default = import_utils33.ESLintUtils.RuleCreator(
|
|
|
4771
4322
|
});
|
|
4772
4323
|
|
|
4773
4324
|
// src/rules/prefer-string-literal-union.ts
|
|
4774
|
-
var
|
|
4325
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
4775
4326
|
var ts = __toESM(require("typescript"), 1);
|
|
4776
4327
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
4777
4328
|
"status",
|
|
@@ -4814,19 +4365,19 @@ function isChoiceLikeName(name) {
|
|
|
4814
4365
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
4815
4366
|
}
|
|
4816
4367
|
function keyName(key) {
|
|
4817
|
-
if (key.type ===
|
|
4368
|
+
if (key.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4818
4369
|
return key.name;
|
|
4819
4370
|
}
|
|
4820
|
-
if (key.type ===
|
|
4371
|
+
if (key.type === import_utils30.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
4821
4372
|
return key.value;
|
|
4822
4373
|
}
|
|
4823
4374
|
return null;
|
|
4824
4375
|
}
|
|
4825
4376
|
function isStringLiteralMember(t) {
|
|
4826
|
-
return t.type ===
|
|
4377
|
+
return t.type === import_utils30.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils30.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
4827
4378
|
}
|
|
4828
4379
|
function isStringLiteralUnion(node) {
|
|
4829
|
-
if (node?.type !==
|
|
4380
|
+
if (node?.type !== import_utils30.AST_NODE_TYPES.TSUnionType) {
|
|
4830
4381
|
return false;
|
|
4831
4382
|
}
|
|
4832
4383
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -4855,12 +4406,12 @@ function bindingSourceExpression(decl) {
|
|
|
4855
4406
|
return ts.isForOfStatement(node) ? node.expression : node.initializer;
|
|
4856
4407
|
}
|
|
4857
4408
|
function refKey(node) {
|
|
4858
|
-
if (node.type ===
|
|
4409
|
+
if (node.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4859
4410
|
return node.name;
|
|
4860
4411
|
}
|
|
4861
|
-
if (node.type ===
|
|
4412
|
+
if (node.type === import_utils30.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
4862
4413
|
const inner = refKey(node.object);
|
|
4863
|
-
if (inner === null || node.property.type !==
|
|
4414
|
+
if (inner === null || node.property.type !== import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4864
4415
|
return null;
|
|
4865
4416
|
}
|
|
4866
4417
|
return `${inner}.${node.property.name}`;
|
|
@@ -4868,12 +4419,12 @@ function refKey(node) {
|
|
|
4868
4419
|
return null;
|
|
4869
4420
|
}
|
|
4870
4421
|
function strLiteral(node) {
|
|
4871
|
-
if (node.type ===
|
|
4422
|
+
if (node.type === import_utils30.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
4872
4423
|
return node.value;
|
|
4873
4424
|
}
|
|
4874
4425
|
return null;
|
|
4875
4426
|
}
|
|
4876
|
-
var prefer_string_literal_union_default =
|
|
4427
|
+
var prefer_string_literal_union_default = import_utils30.ESLintUtils.RuleCreator(
|
|
4877
4428
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4878
4429
|
)({
|
|
4879
4430
|
name: "prefer-string-literal-union",
|
|
@@ -4911,7 +4462,7 @@ var prefer_string_literal_union_default = import_utils35.ESLintUtils.RuleCreator
|
|
|
4911
4462
|
);
|
|
4912
4463
|
let services;
|
|
4913
4464
|
try {
|
|
4914
|
-
services =
|
|
4465
|
+
services = import_utils30.ESLintUtils.getParserServices(context);
|
|
4915
4466
|
} catch {
|
|
4916
4467
|
services = null;
|
|
4917
4468
|
}
|
|
@@ -5023,7 +4574,7 @@ var prefer_string_literal_union_default = import_utils35.ESLintUtils.RuleCreator
|
|
|
5023
4574
|
containersWithUnion.add(container);
|
|
5024
4575
|
return;
|
|
5025
4576
|
}
|
|
5026
|
-
if (typeNode?.type !==
|
|
4577
|
+
if (typeNode?.type !== import_utils30.AST_NODE_TYPES.TSStringKeyword) {
|
|
5027
4578
|
return;
|
|
5028
4579
|
}
|
|
5029
4580
|
const name = keyName(key);
|
|
@@ -5111,10 +4662,10 @@ var prefer_string_literal_union_default = import_utils35.ESLintUtils.RuleCreator
|
|
|
5111
4662
|
}
|
|
5112
4663
|
};
|
|
5113
4664
|
function refKeyText(node) {
|
|
5114
|
-
if (node.type ===
|
|
4665
|
+
if (node.type === import_utils30.AST_NODE_TYPES.BinaryExpression) {
|
|
5115
4666
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
5116
4667
|
}
|
|
5117
|
-
if (node.type ===
|
|
4668
|
+
if (node.type === import_utils30.AST_NODE_TYPES.SwitchStatement) {
|
|
5118
4669
|
return refKey(node.discriminant) ?? "value";
|
|
5119
4670
|
}
|
|
5120
4671
|
return "value";
|
|
@@ -5123,11 +4674,11 @@ var prefer_string_literal_union_default = import_utils35.ESLintUtils.RuleCreator
|
|
|
5123
4674
|
});
|
|
5124
4675
|
|
|
5125
4676
|
// src/rules/prefer-zod-enum.ts
|
|
5126
|
-
var
|
|
4677
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
5127
4678
|
function isZodModule(source) {
|
|
5128
4679
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
5129
4680
|
}
|
|
5130
|
-
var prefer_zod_enum_default =
|
|
4681
|
+
var prefer_zod_enum_default = import_utils31.ESLintUtils.RuleCreator(
|
|
5131
4682
|
(name) => `https://github.com/sarj-ai/standards/tree/main/packages/typescript#${name}`
|
|
5132
4683
|
)({
|
|
5133
4684
|
name: "prefer-zod-enum",
|
|
@@ -5148,20 +4699,20 @@ var prefer_zod_enum_default = import_utils36.ESLintUtils.RuleCreator(
|
|
|
5148
4699
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
5149
4700
|
function enumValues(node) {
|
|
5150
4701
|
const callee = node.callee;
|
|
5151
|
-
if (callee.type !==
|
|
4702
|
+
if (callee.type !== import_utils31.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils31.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils31.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
5152
4703
|
return null;
|
|
5153
4704
|
}
|
|
5154
4705
|
const argument = node.arguments[0];
|
|
5155
|
-
if (argument === void 0 || argument.type !==
|
|
4706
|
+
if (argument === void 0 || argument.type !== import_utils31.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
5156
4707
|
return null;
|
|
5157
4708
|
}
|
|
5158
4709
|
const values = [];
|
|
5159
4710
|
for (const element of argument.elements) {
|
|
5160
|
-
if (element === null || element.type !==
|
|
4711
|
+
if (element === null || element.type !== import_utils31.AST_NODE_TYPES.CallExpression || element.arguments.length !== 1 || element.callee.type !== import_utils31.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils31.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils31.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
5161
4712
|
return null;
|
|
5162
4713
|
}
|
|
5163
4714
|
const value = element.arguments[0];
|
|
5164
|
-
if (value === void 0 || value.type !==
|
|
4715
|
+
if (value === void 0 || value.type !== import_utils31.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
5165
4716
|
return null;
|
|
5166
4717
|
}
|
|
5167
4718
|
values.push(value);
|
|
@@ -5170,11 +4721,11 @@ var prefer_zod_enum_default = import_utils36.ESLintUtils.RuleCreator(
|
|
|
5170
4721
|
}
|
|
5171
4722
|
function buildFix(node, values) {
|
|
5172
4723
|
const argument = node.arguments[0];
|
|
5173
|
-
if (argument === void 0 || argument.type !==
|
|
4724
|
+
if (argument === void 0 || argument.type !== import_utils31.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
5174
4725
|
return void 0;
|
|
5175
4726
|
}
|
|
5176
4727
|
const callee = node.callee;
|
|
5177
|
-
if (callee.type !==
|
|
4728
|
+
if (callee.type !== import_utils31.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils31.AST_NODE_TYPES.Identifier) {
|
|
5178
4729
|
return void 0;
|
|
5179
4730
|
}
|
|
5180
4731
|
return (fixer) => [
|
|
@@ -5191,7 +4742,7 @@ var prefer_zod_enum_default = import_utils36.ESLintUtils.RuleCreator(
|
|
|
5191
4742
|
return;
|
|
5192
4743
|
}
|
|
5193
4744
|
for (const specifier of node.specifiers) {
|
|
5194
|
-
if (specifier.type ===
|
|
4745
|
+
if (specifier.type === import_utils31.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils31.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils31.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils31.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
5195
4746
|
zodNamespaces.add(specifier.local.name);
|
|
5196
4747
|
}
|
|
5197
4748
|
}
|
|
@@ -5212,157 +4763,11 @@ var prefer_zod_enum_default = import_utils36.ESLintUtils.RuleCreator(
|
|
|
5212
4763
|
}
|
|
5213
4764
|
});
|
|
5214
4765
|
|
|
5215
|
-
// src/rules/single-public-export.ts
|
|
5216
|
-
var import_utils37 = require("@typescript-eslint/utils");
|
|
5217
|
-
var JUNK_DRAWER_STEMS = /* @__PURE__ */ new Set([
|
|
5218
|
-
"util",
|
|
5219
|
-
"utils",
|
|
5220
|
-
"helper",
|
|
5221
|
-
"helpers",
|
|
5222
|
-
"common",
|
|
5223
|
-
"constant",
|
|
5224
|
-
"constants",
|
|
5225
|
-
"type",
|
|
5226
|
-
"types",
|
|
5227
|
-
"model",
|
|
5228
|
-
"models",
|
|
5229
|
-
"shared",
|
|
5230
|
-
"misc"
|
|
5231
|
-
]);
|
|
5232
|
-
var CONVENTIONAL_BUCKET_EXPORTS = /* @__PURE__ */ new Set(["cn"]);
|
|
5233
|
-
var ACRONYM_OVERRIDES = [
|
|
5234
|
-
[/OAuth/g, "Oauth"],
|
|
5235
|
-
[/GraphQL/g, "Graphql"],
|
|
5236
|
-
[/gRPC/g, "Grpc"]
|
|
5237
|
-
];
|
|
5238
|
-
var CAMEL_BOUNDARY_RE = /(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g;
|
|
5239
|
-
var TEST_FILE_RE = /\.(test|spec)\.[cm]?[jt]sx?$/i;
|
|
5240
|
-
var SCRIPT_EXT_RE = /\.[cm]?[jt]sx?$/i;
|
|
5241
|
-
var basename = (filename) => filename.split(/[/\\]/).pop() ?? filename;
|
|
5242
|
-
var stemOf = (base) => base.replace(SCRIPT_EXT_RE, "");
|
|
5243
|
-
var kebabCase2 = (name) => {
|
|
5244
|
-
let normalized = name;
|
|
5245
|
-
for (const [pattern, replacement] of ACRONYM_OVERRIDES) {
|
|
5246
|
-
normalized = normalized.replace(pattern, replacement);
|
|
5247
|
-
}
|
|
5248
|
-
return normalized.replace(CAMEL_BOUNDARY_RE, "-").toLowerCase();
|
|
5249
|
-
};
|
|
5250
|
-
var isFunctionExpression = (node) => node !== null && (node.type === import_utils37.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils37.AST_NODE_TYPES.FunctionExpression);
|
|
5251
|
-
var functionConstName = (decl) => {
|
|
5252
|
-
if (decl.declarations.length !== 1) return null;
|
|
5253
|
-
const [declarator] = decl.declarations;
|
|
5254
|
-
if (declarator === void 0) return null;
|
|
5255
|
-
if (declarator.id.type !== import_utils37.AST_NODE_TYPES.Identifier) return null;
|
|
5256
|
-
if (!isFunctionExpression(declarator.init)) return null;
|
|
5257
|
-
return declarator.id.name;
|
|
5258
|
-
};
|
|
5259
|
-
var summarizeExports = (body) => {
|
|
5260
|
-
let names = 0;
|
|
5261
|
-
let hasReExport = false;
|
|
5262
|
-
let candidate = null;
|
|
5263
|
-
const addCandidate = (name, node) => {
|
|
5264
|
-
names += 1;
|
|
5265
|
-
candidate = { name, node };
|
|
5266
|
-
};
|
|
5267
|
-
for (const statement of body) {
|
|
5268
|
-
switch (statement.type) {
|
|
5269
|
-
case import_utils37.AST_NODE_TYPES.ExportAllDeclaration:
|
|
5270
|
-
hasReExport = true;
|
|
5271
|
-
break;
|
|
5272
|
-
case import_utils37.AST_NODE_TYPES.ExportDefaultDeclaration: {
|
|
5273
|
-
names += 1;
|
|
5274
|
-
const decl = statement.declaration;
|
|
5275
|
-
if (decl.type === import_utils37.AST_NODE_TYPES.FunctionDeclaration && decl.id !== null) {
|
|
5276
|
-
candidate = { name: decl.id.name, node: statement };
|
|
5277
|
-
} else if (decl.type === import_utils37.AST_NODE_TYPES.ClassDeclaration && decl.id !== null) {
|
|
5278
|
-
candidate = { name: decl.id.name, node: statement };
|
|
5279
|
-
}
|
|
5280
|
-
break;
|
|
5281
|
-
}
|
|
5282
|
-
case import_utils37.AST_NODE_TYPES.ExportNamedDeclaration: {
|
|
5283
|
-
if (statement.source !== null) {
|
|
5284
|
-
hasReExport = true;
|
|
5285
|
-
break;
|
|
5286
|
-
}
|
|
5287
|
-
const decl = statement.declaration;
|
|
5288
|
-
if (decl === null) {
|
|
5289
|
-
names += statement.specifiers.length;
|
|
5290
|
-
break;
|
|
5291
|
-
}
|
|
5292
|
-
switch (decl.type) {
|
|
5293
|
-
case import_utils37.AST_NODE_TYPES.FunctionDeclaration:
|
|
5294
|
-
if (decl.id !== null) addCandidate(decl.id.name, statement);
|
|
5295
|
-
else names += 1;
|
|
5296
|
-
break;
|
|
5297
|
-
case import_utils37.AST_NODE_TYPES.ClassDeclaration:
|
|
5298
|
-
if (decl.id !== null) addCandidate(decl.id.name, statement);
|
|
5299
|
-
else names += 1;
|
|
5300
|
-
break;
|
|
5301
|
-
case import_utils37.AST_NODE_TYPES.VariableDeclaration: {
|
|
5302
|
-
const fnName = functionConstName(decl);
|
|
5303
|
-
if (fnName !== null && decl.declarations.length === 1) {
|
|
5304
|
-
addCandidate(fnName, statement);
|
|
5305
|
-
} else {
|
|
5306
|
-
names += decl.declarations.length;
|
|
5307
|
-
}
|
|
5308
|
-
break;
|
|
5309
|
-
}
|
|
5310
|
-
default:
|
|
5311
|
-
names += 1;
|
|
5312
|
-
}
|
|
5313
|
-
break;
|
|
5314
|
-
}
|
|
5315
|
-
default:
|
|
5316
|
-
break;
|
|
5317
|
-
}
|
|
5318
|
-
}
|
|
5319
|
-
return { names, hasReExport, candidate };
|
|
5320
|
-
};
|
|
5321
|
-
var single_public_export_default = import_utils37.ESLintUtils.RuleCreator(
|
|
5322
|
-
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5323
|
-
)({
|
|
5324
|
-
name: "single-public-export",
|
|
5325
|
-
meta: {
|
|
5326
|
-
type: "suggestion",
|
|
5327
|
-
docs: {
|
|
5328
|
-
description: "A junk-drawer module stem (`utils`, `helpers`, `types`, ...) with a single public function/class/const export should be renamed after that export."
|
|
5329
|
-
},
|
|
5330
|
-
schema: [],
|
|
5331
|
-
messages: {
|
|
5332
|
-
renameJunkDrawer: "Module stem `{{stem}}` is a generic junk-drawer name; its sole public export is `{{name}}` \u2014 rename the file to `{{expected}}.ts` to describe its responsibility."
|
|
5333
|
-
}
|
|
5334
|
-
},
|
|
5335
|
-
defaultOptions: [],
|
|
5336
|
-
create(context) {
|
|
5337
|
-
const base = basename(context.filename);
|
|
5338
|
-
if (base.endsWith(".d.ts")) return {};
|
|
5339
|
-
if (TEST_FILE_RE.test(base)) return {};
|
|
5340
|
-
if (isTestFile(context.filename)) return {};
|
|
5341
|
-
const stem3 = stemOf(base);
|
|
5342
|
-
if (!JUNK_DRAWER_STEMS.has(stem3.toLowerCase())) return {};
|
|
5343
|
-
return {
|
|
5344
|
-
Program(node) {
|
|
5345
|
-
const { names, hasReExport, candidate } = summarizeExports(node.body);
|
|
5346
|
-
if (hasReExport) return;
|
|
5347
|
-
if (names !== 1 || candidate === null) return;
|
|
5348
|
-
if (CONVENTIONAL_BUCKET_EXPORTS.has(candidate.name)) return;
|
|
5349
|
-
const expected = kebabCase2(candidate.name);
|
|
5350
|
-
if (stem3 === expected) return;
|
|
5351
|
-
context.report({
|
|
5352
|
-
node: candidate.node,
|
|
5353
|
-
messageId: "renameJunkDrawer",
|
|
5354
|
-
data: { stem: stem3, name: candidate.name, expected }
|
|
5355
|
-
});
|
|
5356
|
-
}
|
|
5357
|
-
};
|
|
5358
|
-
}
|
|
5359
|
-
});
|
|
5360
|
-
|
|
5361
4766
|
// src/rules/no-offset-pagination.ts
|
|
5362
|
-
var
|
|
4767
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
5363
4768
|
|
|
5364
4769
|
// src/rules/_sql.ts
|
|
5365
|
-
var
|
|
4770
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
5366
4771
|
function stripSqlNoise(text) {
|
|
5367
4772
|
const out = [...text];
|
|
5368
4773
|
const n = text.length;
|
|
@@ -5423,13 +4828,13 @@ function stripSqlNoise(text) {
|
|
|
5423
4828
|
var SUBSTITUTION_MARKER = "?";
|
|
5424
4829
|
function sqlTextOf(node) {
|
|
5425
4830
|
switch (node.type) {
|
|
5426
|
-
case
|
|
4831
|
+
case import_utils32.AST_NODE_TYPES.Literal:
|
|
5427
4832
|
return typeof node.value === "string" ? node.value : null;
|
|
5428
|
-
case
|
|
4833
|
+
case import_utils32.AST_NODE_TYPES.TemplateLiteral:
|
|
5429
4834
|
return node.quasis.map((q) => q.value.cooked ?? q.value.raw).join(SUBSTITUTION_MARKER);
|
|
5430
|
-
case
|
|
4835
|
+
case import_utils32.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
5431
4836
|
return sqlTextOf(node.quasi);
|
|
5432
|
-
case
|
|
4837
|
+
case import_utils32.AST_NODE_TYPES.BinaryExpression: {
|
|
5433
4838
|
if (node.operator !== "+") {
|
|
5434
4839
|
return null;
|
|
5435
4840
|
}
|
|
@@ -5437,7 +4842,7 @@ function sqlTextOf(node) {
|
|
|
5437
4842
|
const right = sqlTextOf(node.right);
|
|
5438
4843
|
return left !== null && right !== null ? left + right : null;
|
|
5439
4844
|
}
|
|
5440
|
-
case
|
|
4845
|
+
case import_utils32.AST_NODE_TYPES.ArrayExpression: {
|
|
5441
4846
|
const parts = [];
|
|
5442
4847
|
for (const element of node.elements) {
|
|
5443
4848
|
if (element === null) {
|
|
@@ -5457,7 +4862,7 @@ function sqlTextOf(node) {
|
|
|
5457
4862
|
}
|
|
5458
4863
|
function isJoinedFragmentArray(node) {
|
|
5459
4864
|
const parent = node.parent;
|
|
5460
|
-
return parent?.type ===
|
|
4865
|
+
return parent?.type === import_utils32.AST_NODE_TYPES.MemberExpression && parent.object === node && !parent.computed && parent.property.type === import_utils32.AST_NODE_TYPES.Identifier && parent.property.name === "join" && parent.parent?.type === import_utils32.AST_NODE_TYPES.CallExpression;
|
|
5461
4866
|
}
|
|
5462
4867
|
function markConsumed(node, consumed) {
|
|
5463
4868
|
consumed.add(node);
|
|
@@ -5507,7 +4912,7 @@ function createSqlListener(handler) {
|
|
|
5507
4912
|
// src/rules/no-offset-pagination.ts
|
|
5508
4913
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:%s|%\(\w+\)s|\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
5509
4914
|
var OFFSET_GATE = /offset/i;
|
|
5510
|
-
var no_offset_pagination_default =
|
|
4915
|
+
var no_offset_pagination_default = import_utils33.ESLintUtils.RuleCreator(
|
|
5511
4916
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5512
4917
|
)({
|
|
5513
4918
|
name: "no-offset-pagination",
|
|
@@ -5536,15 +4941,15 @@ var no_offset_pagination_default = import_utils39.ESLintUtils.RuleCreator(
|
|
|
5536
4941
|
});
|
|
5537
4942
|
|
|
5538
4943
|
// src/rules/no-positional-tuple-return.ts
|
|
5539
|
-
var
|
|
4944
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
5540
4945
|
var MIN_ELEMENTS = 2;
|
|
5541
4946
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
5542
4947
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
5543
4948
|
function tupleReturnType(node) {
|
|
5544
|
-
if (node.type ===
|
|
4949
|
+
if (node.type === import_utils34.AST_NODE_TYPES.TSTupleType) {
|
|
5545
4950
|
return node;
|
|
5546
4951
|
}
|
|
5547
|
-
if (node.type ===
|
|
4952
|
+
if (node.type === import_utils34.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils34.AST_NODE_TYPES.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
5548
4953
|
const argument = node.typeArguments?.params[0];
|
|
5549
4954
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
5550
4955
|
}
|
|
@@ -5558,30 +4963,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
5558
4963
|
if (elements.length < MIN_ELEMENTS) {
|
|
5559
4964
|
return true;
|
|
5560
4965
|
}
|
|
5561
|
-
if (elements.some((element) => element.type ===
|
|
4966
|
+
if (elements.some((element) => element.type === import_utils34.AST_NODE_TYPES.TSRestType)) {
|
|
5562
4967
|
return true;
|
|
5563
4968
|
}
|
|
5564
|
-
if (elements.some((element) => element.type ===
|
|
4969
|
+
if (elements.some((element) => element.type === import_utils34.AST_NODE_TYPES.TSNamedTupleMember)) {
|
|
5565
4970
|
return true;
|
|
5566
4971
|
}
|
|
5567
|
-
if (elements[0]?.type ===
|
|
4972
|
+
if (elements[0]?.type === import_utils34.AST_NODE_TYPES.TSLiteralType) {
|
|
5568
4973
|
return true;
|
|
5569
4974
|
}
|
|
5570
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type ===
|
|
4975
|
+
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === import_utils34.AST_NODE_TYPES.TSFunctionType)) {
|
|
5571
4976
|
return true;
|
|
5572
4977
|
}
|
|
5573
4978
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
5574
4979
|
return texts.size === 1;
|
|
5575
4980
|
}
|
|
5576
4981
|
function functionName(node) {
|
|
5577
|
-
if (node.type ===
|
|
4982
|
+
if (node.type === import_utils34.AST_NODE_TYPES.FunctionDeclaration) {
|
|
5578
4983
|
return node.id?.name ?? null;
|
|
5579
4984
|
}
|
|
5580
4985
|
const parent = node.parent;
|
|
5581
|
-
if (parent?.type ===
|
|
4986
|
+
if (parent?.type === import_utils34.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils34.AST_NODE_TYPES.Identifier) {
|
|
5582
4987
|
return parent.id.name;
|
|
5583
4988
|
}
|
|
5584
|
-
if ((parent?.type ===
|
|
4989
|
+
if ((parent?.type === import_utils34.AST_NODE_TYPES.MethodDefinition || parent?.type === import_utils34.AST_NODE_TYPES.PropertyDefinition || parent?.type === import_utils34.AST_NODE_TYPES.Property) && parent.key.type === import_utils34.AST_NODE_TYPES.Identifier) {
|
|
5585
4990
|
return parent.key.name;
|
|
5586
4991
|
}
|
|
5587
4992
|
return null;
|
|
@@ -5589,7 +4994,7 @@ function functionName(node) {
|
|
|
5589
4994
|
function isInlineExported(node) {
|
|
5590
4995
|
for (let current = node; current != null; current = current.parent) {
|
|
5591
4996
|
const parent = current.parent;
|
|
5592
|
-
if (parent?.type ===
|
|
4997
|
+
if (parent?.type === import_utils34.AST_NODE_TYPES.ExportNamedDeclaration || parent?.type === import_utils34.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
5593
4998
|
return true;
|
|
5594
4999
|
}
|
|
5595
5000
|
}
|
|
@@ -5598,18 +5003,18 @@ function isInlineExported(node) {
|
|
|
5598
5003
|
function moduleScopeBindingName(node) {
|
|
5599
5004
|
let current = node;
|
|
5600
5005
|
let child = node;
|
|
5601
|
-
while (current.parent != null && current.parent.type !==
|
|
5006
|
+
while (current.parent != null && current.parent.type !== import_utils34.AST_NODE_TYPES.Program) {
|
|
5602
5007
|
child = current;
|
|
5603
5008
|
current = current.parent;
|
|
5604
5009
|
}
|
|
5605
|
-
if (current.parent?.type !==
|
|
5010
|
+
if (current.parent?.type !== import_utils34.AST_NODE_TYPES.Program) {
|
|
5606
5011
|
return null;
|
|
5607
5012
|
}
|
|
5608
|
-
if (current.type ===
|
|
5013
|
+
if (current.type === import_utils34.AST_NODE_TYPES.FunctionDeclaration || current.type === import_utils34.AST_NODE_TYPES.ClassDeclaration) {
|
|
5609
5014
|
return current.id?.name ?? null;
|
|
5610
5015
|
}
|
|
5611
|
-
if (current.type ===
|
|
5612
|
-
if (child.type !==
|
|
5016
|
+
if (current.type === import_utils34.AST_NODE_TYPES.VariableDeclaration) {
|
|
5017
|
+
if (child.type !== import_utils34.AST_NODE_TYPES.VariableDeclarator || child.id.type !== import_utils34.AST_NODE_TYPES.Identifier) {
|
|
5613
5018
|
return null;
|
|
5614
5019
|
}
|
|
5615
5020
|
return child.id.name;
|
|
@@ -5619,19 +5024,19 @@ function moduleScopeBindingName(node) {
|
|
|
5619
5024
|
function specifierExportedNames(program) {
|
|
5620
5025
|
const names = /* @__PURE__ */ new Set();
|
|
5621
5026
|
for (const statement of program.body) {
|
|
5622
|
-
if (statement.type ===
|
|
5027
|
+
if (statement.type === import_utils34.AST_NODE_TYPES.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
5623
5028
|
for (const specifier of statement.specifiers) {
|
|
5624
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
5029
|
+
if (specifier.exportKind !== "type" && specifier.local.type === import_utils34.AST_NODE_TYPES.Identifier) {
|
|
5625
5030
|
names.add(specifier.local.name);
|
|
5626
5031
|
}
|
|
5627
5032
|
}
|
|
5628
5033
|
continue;
|
|
5629
5034
|
}
|
|
5630
|
-
if (statement.type ===
|
|
5035
|
+
if (statement.type === import_utils34.AST_NODE_TYPES.ExportDefaultDeclaration && statement.declaration.type === import_utils34.AST_NODE_TYPES.Identifier) {
|
|
5631
5036
|
names.add(statement.declaration.name);
|
|
5632
5037
|
continue;
|
|
5633
5038
|
}
|
|
5634
|
-
if (statement.type ===
|
|
5039
|
+
if (statement.type === import_utils34.AST_NODE_TYPES.TSExportAssignment && statement.expression.type === import_utils34.AST_NODE_TYPES.Identifier) {
|
|
5635
5040
|
names.add(statement.expression.name);
|
|
5636
5041
|
}
|
|
5637
5042
|
}
|
|
@@ -5647,7 +5052,7 @@ function isExported(node, specifierExports) {
|
|
|
5647
5052
|
const binding = moduleScopeBindingName(node);
|
|
5648
5053
|
return binding !== null && specifierExports.has(binding);
|
|
5649
5054
|
}
|
|
5650
|
-
var no_positional_tuple_return_default =
|
|
5055
|
+
var no_positional_tuple_return_default = import_utils34.ESLintUtils.RuleCreator(
|
|
5651
5056
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5652
5057
|
)({
|
|
5653
5058
|
name: "no-positional-tuple-return",
|
|
@@ -5695,16 +5100,16 @@ var no_positional_tuple_return_default = import_utils40.ESLintUtils.RuleCreator(
|
|
|
5695
5100
|
});
|
|
5696
5101
|
|
|
5697
5102
|
// src/rules/no-repeated-string-literal.ts
|
|
5698
|
-
var
|
|
5103
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
5699
5104
|
var MIN_LENGTH = 40;
|
|
5700
5105
|
var MIN_DISTINCT_SCOPES = 2;
|
|
5701
5106
|
var PREVIEW_LENGTH = 40;
|
|
5702
5107
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
5703
5108
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
5704
5109
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5110
|
+
import_utils35.AST_NODE_TYPES.FunctionDeclaration,
|
|
5111
|
+
import_utils35.AST_NODE_TYPES.FunctionExpression,
|
|
5112
|
+
import_utils35.AST_NODE_TYPES.ArrowFunctionExpression
|
|
5708
5113
|
]);
|
|
5709
5114
|
function isStructured(value) {
|
|
5710
5115
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -5726,9 +5131,9 @@ function isScaffolding(node) {
|
|
|
5726
5131
|
if (parent === void 0) {
|
|
5727
5132
|
return true;
|
|
5728
5133
|
}
|
|
5729
|
-
return parent.type ===
|
|
5134
|
+
return parent.type === import_utils35.AST_NODE_TYPES.ImportDeclaration || parent.type === import_utils35.AST_NODE_TYPES.ExportNamedDeclaration || parent.type === import_utils35.AST_NODE_TYPES.ExportAllDeclaration || parent.type === import_utils35.AST_NODE_TYPES.TSImportType || parent.type === import_utils35.AST_NODE_TYPES.JSXAttribute || parent.type === import_utils35.AST_NODE_TYPES.TSLiteralType;
|
|
5730
5135
|
}
|
|
5731
|
-
var no_repeated_string_literal_default =
|
|
5136
|
+
var no_repeated_string_literal_default = import_utils35.ESLintUtils.RuleCreator(
|
|
5732
5137
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5733
5138
|
)({
|
|
5734
5139
|
name: "no-repeated-string-literal",
|
|
@@ -5768,7 +5173,7 @@ var no_repeated_string_literal_default = import_utils41.ESLintUtils.RuleCreator(
|
|
|
5768
5173
|
}
|
|
5769
5174
|
},
|
|
5770
5175
|
TemplateLiteral(node) {
|
|
5771
|
-
if (node.parent.type ===
|
|
5176
|
+
if (node.parent.type === import_utils35.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
5772
5177
|
return;
|
|
5773
5178
|
}
|
|
5774
5179
|
const [only] = node.quasis;
|
|
@@ -5802,7 +5207,7 @@ var no_repeated_string_literal_default = import_utils41.ESLintUtils.RuleCreator(
|
|
|
5802
5207
|
});
|
|
5803
5208
|
|
|
5804
5209
|
// src/rules/no-select-star.ts
|
|
5805
|
-
var
|
|
5210
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5806
5211
|
var QUERY_SHAPE = /\bSELECT\b[\s\S]*?\bFROM\b/i;
|
|
5807
5212
|
var SELECT_KEYWORD = /\bSELECT\b/gi;
|
|
5808
5213
|
var FROM_KEYWORD = /^FROM\b/i;
|
|
@@ -5842,7 +5247,7 @@ function hasRealSelectStar(sql) {
|
|
|
5842
5247
|
}
|
|
5843
5248
|
return false;
|
|
5844
5249
|
}
|
|
5845
|
-
var no_select_star_default =
|
|
5250
|
+
var no_select_star_default = import_utils36.ESLintUtils.RuleCreator(
|
|
5846
5251
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5847
5252
|
)({
|
|
5848
5253
|
name: "no-select-star",
|
|
@@ -5871,7 +5276,7 @@ var no_select_star_default = import_utils42.ESLintUtils.RuleCreator(
|
|
|
5871
5276
|
});
|
|
5872
5277
|
|
|
5873
5278
|
// src/rules/no-sleep-in-test-body.ts
|
|
5874
|
-
var
|
|
5279
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5875
5280
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
5876
5281
|
var TEST_CALLERS = /* @__PURE__ */ new Set([
|
|
5877
5282
|
"it",
|
|
@@ -5880,34 +5285,34 @@ var TEST_CALLERS = /* @__PURE__ */ new Set([
|
|
|
5880
5285
|
"afterEach"
|
|
5881
5286
|
]);
|
|
5882
5287
|
var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5288
|
+
import_utils37.AST_NODE_TYPES.FunctionDeclaration,
|
|
5289
|
+
import_utils37.AST_NODE_TYPES.FunctionExpression,
|
|
5290
|
+
import_utils37.AST_NODE_TYPES.ArrowFunctionExpression
|
|
5886
5291
|
]);
|
|
5887
5292
|
function isNonzeroNumericLiteral(node) {
|
|
5888
|
-
return node?.type ===
|
|
5293
|
+
return node?.type === import_utils37.AST_NODE_TYPES.Literal && typeof node.value === "number" && node.value !== 0;
|
|
5889
5294
|
}
|
|
5890
5295
|
function isTimedSetTimeout(node) {
|
|
5891
|
-
return node.type ===
|
|
5296
|
+
return node.type === import_utils37.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils37.AST_NODE_TYPES.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
5892
5297
|
}
|
|
5893
5298
|
function isPromiseSleep(node) {
|
|
5894
|
-
if (node.callee.type !==
|
|
5299
|
+
if (node.callee.type !== import_utils37.AST_NODE_TYPES.Identifier || node.callee.name !== "Promise") {
|
|
5895
5300
|
return false;
|
|
5896
5301
|
}
|
|
5897
5302
|
const executor = node.arguments[0];
|
|
5898
|
-
if (executor?.type !==
|
|
5303
|
+
if (executor?.type !== import_utils37.AST_NODE_TYPES.ArrowFunctionExpression && executor?.type !== import_utils37.AST_NODE_TYPES.FunctionExpression) {
|
|
5899
5304
|
return false;
|
|
5900
5305
|
}
|
|
5901
5306
|
const body = executor.body;
|
|
5902
|
-
if (body.type !==
|
|
5307
|
+
if (body.type !== import_utils37.AST_NODE_TYPES.BlockStatement) {
|
|
5903
5308
|
return isTimedSetTimeout(body);
|
|
5904
5309
|
}
|
|
5905
5310
|
return body.body.some(
|
|
5906
|
-
(stmt) => stmt.type ===
|
|
5311
|
+
(stmt) => stmt.type === import_utils37.AST_NODE_TYPES.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
5907
5312
|
);
|
|
5908
5313
|
}
|
|
5909
5314
|
function isHelperSleep(node) {
|
|
5910
|
-
return node.callee.type ===
|
|
5315
|
+
return node.callee.type === import_utils37.AST_NODE_TYPES.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
5911
5316
|
}
|
|
5912
5317
|
function nearestEnclosingFunction(node) {
|
|
5913
5318
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -5915,7 +5320,7 @@ function nearestEnclosingFunction(node) {
|
|
|
5915
5320
|
continue;
|
|
5916
5321
|
}
|
|
5917
5322
|
const grandparent = current.parent;
|
|
5918
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
5323
|
+
const isPromiseExecutor = grandparent?.type === import_utils37.AST_NODE_TYPES.NewExpression && isPromiseSleep(grandparent);
|
|
5919
5324
|
if (!isPromiseExecutor) {
|
|
5920
5325
|
return current;
|
|
5921
5326
|
}
|
|
@@ -5923,29 +5328,29 @@ function nearestEnclosingFunction(node) {
|
|
|
5923
5328
|
return null;
|
|
5924
5329
|
}
|
|
5925
5330
|
function testCallerName(callee) {
|
|
5926
|
-
if (callee.type ===
|
|
5331
|
+
if (callee.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
5927
5332
|
return callee.name;
|
|
5928
5333
|
}
|
|
5929
|
-
if (callee.type ===
|
|
5334
|
+
if (callee.type === import_utils37.AST_NODE_TYPES.MemberExpression) {
|
|
5930
5335
|
return testCallerName(callee.object);
|
|
5931
5336
|
}
|
|
5932
|
-
if (callee.type ===
|
|
5337
|
+
if (callee.type === import_utils37.AST_NODE_TYPES.CallExpression) {
|
|
5933
5338
|
return testCallerName(callee.callee);
|
|
5934
5339
|
}
|
|
5935
|
-
if (callee.type ===
|
|
5340
|
+
if (callee.type === import_utils37.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
5936
5341
|
return testCallerName(callee.tag);
|
|
5937
5342
|
}
|
|
5938
5343
|
return null;
|
|
5939
5344
|
}
|
|
5940
5345
|
function isTestBody(fn) {
|
|
5941
5346
|
const call = fn.parent;
|
|
5942
|
-
if (call?.type !==
|
|
5347
|
+
if (call?.type !== import_utils37.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
5943
5348
|
return false;
|
|
5944
5349
|
}
|
|
5945
5350
|
const name = testCallerName(call.callee);
|
|
5946
5351
|
return name !== null && TEST_CALLERS.has(name);
|
|
5947
5352
|
}
|
|
5948
|
-
var no_sleep_in_test_body_default =
|
|
5353
|
+
var no_sleep_in_test_body_default = import_utils37.ESLintUtils.RuleCreator(
|
|
5949
5354
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5950
5355
|
)({
|
|
5951
5356
|
name: "no-sleep-in-test-body",
|
|
@@ -5987,12 +5392,12 @@ var no_sleep_in_test_body_default = import_utils43.ESLintUtils.RuleCreator(
|
|
|
5987
5392
|
});
|
|
5988
5393
|
|
|
5989
5394
|
// src/rules/no-conditional-in-test.ts
|
|
5990
|
-
var
|
|
5395
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
5991
5396
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set(["it", "test"]);
|
|
5992
5397
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5398
|
+
import_utils38.AST_NODE_TYPES.FunctionDeclaration,
|
|
5399
|
+
import_utils38.AST_NODE_TYPES.FunctionExpression,
|
|
5400
|
+
import_utils38.AST_NODE_TYPES.ArrowFunctionExpression
|
|
5996
5401
|
]);
|
|
5997
5402
|
function nearestEnclosingFunction2(node) {
|
|
5998
5403
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -6003,29 +5408,29 @@ function nearestEnclosingFunction2(node) {
|
|
|
6003
5408
|
return null;
|
|
6004
5409
|
}
|
|
6005
5410
|
function testCallerName2(callee) {
|
|
6006
|
-
if (callee.type ===
|
|
5411
|
+
if (callee.type === import_utils38.AST_NODE_TYPES.Identifier) {
|
|
6007
5412
|
return callee.name;
|
|
6008
5413
|
}
|
|
6009
|
-
if (callee.type ===
|
|
5414
|
+
if (callee.type === import_utils38.AST_NODE_TYPES.MemberExpression) {
|
|
6010
5415
|
return testCallerName2(callee.object);
|
|
6011
5416
|
}
|
|
6012
|
-
if (callee.type ===
|
|
5417
|
+
if (callee.type === import_utils38.AST_NODE_TYPES.CallExpression) {
|
|
6013
5418
|
return testCallerName2(callee.callee);
|
|
6014
5419
|
}
|
|
6015
|
-
if (callee.type ===
|
|
5420
|
+
if (callee.type === import_utils38.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
6016
5421
|
return testCallerName2(callee.tag);
|
|
6017
5422
|
}
|
|
6018
5423
|
return null;
|
|
6019
5424
|
}
|
|
6020
5425
|
function isTestBody2(fn) {
|
|
6021
5426
|
const call = fn.parent;
|
|
6022
|
-
if (call?.type !==
|
|
5427
|
+
if (call?.type !== import_utils38.AST_NODE_TYPES.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
6023
5428
|
return false;
|
|
6024
5429
|
}
|
|
6025
5430
|
const name = testCallerName2(call.callee);
|
|
6026
5431
|
return name !== null && TEST_CALLERS2.has(name);
|
|
6027
5432
|
}
|
|
6028
|
-
var no_conditional_in_test_default =
|
|
5433
|
+
var no_conditional_in_test_default = import_utils38.ESLintUtils.RuleCreator(
|
|
6029
5434
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6030
5435
|
)({
|
|
6031
5436
|
name: "no-conditional-in-test",
|
|
@@ -6069,7 +5474,7 @@ var no_conditional_in_test_default = import_utils44.ESLintUtils.RuleCreator(
|
|
|
6069
5474
|
});
|
|
6070
5475
|
|
|
6071
5476
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6072
|
-
var
|
|
5477
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
6073
5478
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6074
5479
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6075
5480
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6082,36 +5487,36 @@ function isConstantReference(identifier) {
|
|
|
6082
5487
|
}
|
|
6083
5488
|
function isExcludedOperand(node) {
|
|
6084
5489
|
switch (node.type) {
|
|
6085
|
-
case
|
|
5490
|
+
case import_utils39.AST_NODE_TYPES.Literal:
|
|
6086
5491
|
return true;
|
|
6087
|
-
case
|
|
5492
|
+
case import_utils39.AST_NODE_TYPES.TemplateLiteral:
|
|
6088
5493
|
return node.expressions.length === 0;
|
|
6089
|
-
case
|
|
5494
|
+
case import_utils39.AST_NODE_TYPES.Identifier:
|
|
6090
5495
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6091
|
-
case
|
|
6092
|
-
return !node.computed && node.property.type ===
|
|
5496
|
+
case import_utils39.AST_NODE_TYPES.MemberExpression:
|
|
5497
|
+
return !node.computed && node.property.type === import_utils39.AST_NODE_TYPES.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6093
5498
|
default:
|
|
6094
5499
|
return false;
|
|
6095
5500
|
}
|
|
6096
5501
|
}
|
|
6097
5502
|
function operandName(node) {
|
|
6098
|
-
if (node.type ===
|
|
5503
|
+
if (node.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
6099
5504
|
return node.name;
|
|
6100
5505
|
}
|
|
6101
|
-
if (node.type ===
|
|
5506
|
+
if (node.type === import_utils39.AST_NODE_TYPES.MemberExpression && !node.computed && node.property.type === import_utils39.AST_NODE_TYPES.Identifier) {
|
|
6102
5507
|
return node.property.name;
|
|
6103
5508
|
}
|
|
6104
5509
|
return null;
|
|
6105
5510
|
}
|
|
6106
5511
|
function isSecretOperand(node) {
|
|
6107
|
-
if (node.type ===
|
|
5512
|
+
if (node.type === import_utils39.AST_NODE_TYPES.TemplateLiteral) {
|
|
6108
5513
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6109
5514
|
}
|
|
6110
5515
|
const name = operandName(node);
|
|
6111
5516
|
return name !== null && isAuthSecretName(name);
|
|
6112
5517
|
}
|
|
6113
5518
|
function secretNameOf(node) {
|
|
6114
|
-
if (node.type ===
|
|
5519
|
+
if (node.type === import_utils39.AST_NODE_TYPES.TemplateLiteral) {
|
|
6115
5520
|
for (const expression of node.expressions) {
|
|
6116
5521
|
const nested = secretNameOf(expression);
|
|
6117
5522
|
if (nested !== null) {
|
|
@@ -6122,7 +5527,7 @@ function secretNameOf(node) {
|
|
|
6122
5527
|
}
|
|
6123
5528
|
return operandName(node);
|
|
6124
5529
|
}
|
|
6125
|
-
var prefer_constant_time_secret_compare_default =
|
|
5530
|
+
var prefer_constant_time_secret_compare_default = import_utils39.ESLintUtils.RuleCreator(
|
|
6126
5531
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6127
5532
|
)({
|
|
6128
5533
|
name: "prefer-constant-time-secret-compare",
|
|
@@ -6165,11 +5570,11 @@ var prefer_constant_time_secret_compare_default = import_utils45.ESLintUtils.Rul
|
|
|
6165
5570
|
});
|
|
6166
5571
|
|
|
6167
5572
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
6168
|
-
var
|
|
5573
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
6169
5574
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
6170
5575
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
6171
5576
|
var INSERT_GATE = /insert/i;
|
|
6172
|
-
var store_insert_requires_on_conflict_default =
|
|
5577
|
+
var store_insert_requires_on_conflict_default = import_utils40.ESLintUtils.RuleCreator(
|
|
6173
5578
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6174
5579
|
)({
|
|
6175
5580
|
name: "store-insert-requires-on-conflict",
|
|
@@ -6198,17 +5603,17 @@ var store_insert_requires_on_conflict_default = import_utils46.ESLintUtils.RuleC
|
|
|
6198
5603
|
});
|
|
6199
5604
|
|
|
6200
5605
|
// src/rules/no-dynamic-sql.ts
|
|
6201
|
-
var
|
|
5606
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
6202
5607
|
var DEFAULT_METHODS = ["prepare", "exec", "query"];
|
|
6203
5608
|
var CONSTANT_CASE_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
6204
5609
|
function isStaticFragment(expression) {
|
|
6205
|
-
if (expression.type ===
|
|
5610
|
+
if (expression.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
6206
5611
|
return CONSTANT_CASE_RE.test(expression.name);
|
|
6207
5612
|
}
|
|
6208
|
-
if (expression.type ===
|
|
5613
|
+
if (expression.type === import_utils41.AST_NODE_TYPES.MemberExpression && !expression.computed && expression.property.type === import_utils41.AST_NODE_TYPES.Identifier) {
|
|
6209
5614
|
return CONSTANT_CASE_RE.test(expression.property.name);
|
|
6210
5615
|
}
|
|
6211
|
-
if (expression.type ===
|
|
5616
|
+
if (expression.type === import_utils41.AST_NODE_TYPES.Literal) {
|
|
6212
5617
|
return typeof expression.value === "string";
|
|
6213
5618
|
}
|
|
6214
5619
|
return false;
|
|
@@ -6219,36 +5624,36 @@ function runtimeInterpolations(template) {
|
|
|
6219
5624
|
);
|
|
6220
5625
|
}
|
|
6221
5626
|
function concatOperands(node) {
|
|
6222
|
-
if (node.type ===
|
|
5627
|
+
if (node.type === import_utils41.AST_NODE_TYPES.BinaryExpression && node.operator === "+") {
|
|
6223
5628
|
return [...concatOperands(node.left), ...concatOperands(node.right)];
|
|
6224
5629
|
}
|
|
6225
5630
|
return [node];
|
|
6226
5631
|
}
|
|
6227
5632
|
function runtimeConcatOperands(node) {
|
|
6228
|
-
if (node.type !==
|
|
5633
|
+
if (node.type !== import_utils41.AST_NODE_TYPES.BinaryExpression || node.operator !== "+") {
|
|
6229
5634
|
return [];
|
|
6230
5635
|
}
|
|
6231
5636
|
const operands = concatOperands(node);
|
|
6232
5637
|
const hasStringLiteral = operands.some(
|
|
6233
|
-
(operand) => operand.type ===
|
|
5638
|
+
(operand) => operand.type === import_utils41.AST_NODE_TYPES.Literal && typeof operand.value === "string"
|
|
6234
5639
|
);
|
|
6235
5640
|
if (!hasStringLiteral) {
|
|
6236
5641
|
return [];
|
|
6237
5642
|
}
|
|
6238
5643
|
return operands.filter(
|
|
6239
|
-
(operand) => operand.type !==
|
|
5644
|
+
(operand) => operand.type !== import_utils41.AST_NODE_TYPES.Literal && !isStaticFragment(operand)
|
|
6240
5645
|
);
|
|
6241
5646
|
}
|
|
6242
5647
|
var SQL_STATEMENT_RE = /\b(?:select\s|insert\s+into\b|insert\s+or\b|update\s+\w|delete\s+from\b|replace\s+into\b|merge\s+into\b|upsert\s+into\b|create\s+(?:temp(?:orary)?\s+)?(?:table|index|view|trigger|schema|database)\b|alter\s+table\b|drop\s+(?:table|index|view|trigger)\b|truncate\s+table\b|pragma\s+\w|with\s+\w+\s+as\s*\(|from\s+\w+\s+where\b)/i;
|
|
6243
5648
|
var RUNTIME_MARKER = " ? ";
|
|
6244
5649
|
function staticStatementText(node) {
|
|
6245
|
-
if (node.type ===
|
|
5650
|
+
if (node.type === import_utils41.AST_NODE_TYPES.TemplateLiteral) {
|
|
6246
5651
|
return node.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join(RUNTIME_MARKER);
|
|
6247
5652
|
}
|
|
6248
|
-
if (node.type ===
|
|
5653
|
+
if (node.type === import_utils41.AST_NODE_TYPES.Literal) {
|
|
6249
5654
|
return typeof node.value === "string" ? node.value : RUNTIME_MARKER;
|
|
6250
5655
|
}
|
|
6251
|
-
if (node.type ===
|
|
5656
|
+
if (node.type === import_utils41.AST_NODE_TYPES.BinaryExpression && node.operator === "+") {
|
|
6252
5657
|
return staticStatementText(node.left) + staticStatementText(node.right);
|
|
6253
5658
|
}
|
|
6254
5659
|
return RUNTIME_MARKER;
|
|
@@ -6258,13 +5663,13 @@ function looksLikeSql(node) {
|
|
|
6258
5663
|
}
|
|
6259
5664
|
function statementMethodName(node, methods) {
|
|
6260
5665
|
const callee = node.callee;
|
|
6261
|
-
if (callee.type !==
|
|
5666
|
+
if (callee.type !== import_utils41.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils41.AST_NODE_TYPES.Identifier) {
|
|
6262
5667
|
return null;
|
|
6263
5668
|
}
|
|
6264
5669
|
const name = callee.property.name;
|
|
6265
5670
|
return methods.has(name) ? name : null;
|
|
6266
5671
|
}
|
|
6267
|
-
var no_dynamic_sql_default =
|
|
5672
|
+
var no_dynamic_sql_default = import_utils41.ESLintUtils.RuleCreator(
|
|
6268
5673
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6269
5674
|
)({
|
|
6270
5675
|
name: "no-dynamic-sql",
|
|
@@ -6303,7 +5708,7 @@ var no_dynamic_sql_default = import_utils47.ESLintUtils.RuleCreator(
|
|
|
6303
5708
|
if (statement === void 0 || !looksLikeSql(statement)) {
|
|
6304
5709
|
return;
|
|
6305
5710
|
}
|
|
6306
|
-
const offenders = statement.type ===
|
|
5711
|
+
const offenders = statement.type === import_utils41.AST_NODE_TYPES.TemplateLiteral ? runtimeInterpolations(statement) : runtimeConcatOperands(statement);
|
|
6307
5712
|
for (const offender of offenders) {
|
|
6308
5713
|
context.report({
|
|
6309
5714
|
node: offender,
|
|
@@ -6317,7 +5722,7 @@ var no_dynamic_sql_default = import_utils47.ESLintUtils.RuleCreator(
|
|
|
6317
5722
|
});
|
|
6318
5723
|
|
|
6319
5724
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
6320
|
-
var
|
|
5725
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
6321
5726
|
var DEFAULT_ALLOW = [
|
|
6322
5727
|
"[\\\\/]clients?[\\\\/]",
|
|
6323
5728
|
"-client\\.[cm]?[jt]sx?$",
|
|
@@ -6381,7 +5786,7 @@ function compile(patterns) {
|
|
|
6381
5786
|
}
|
|
6382
5787
|
return compiled;
|
|
6383
5788
|
}
|
|
6384
|
-
var no_raw_fetch_outside_clients_default =
|
|
5789
|
+
var no_raw_fetch_outside_clients_default = import_utils42.ESLintUtils.RuleCreator(
|
|
6385
5790
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6386
5791
|
)({
|
|
6387
5792
|
name: "no-raw-fetch-outside-clients",
|
|
@@ -6429,7 +5834,7 @@ var no_raw_fetch_outside_clients_default = import_utils48.ESLintUtils.RuleCreato
|
|
|
6429
5834
|
});
|
|
6430
5835
|
|
|
6431
5836
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
6432
|
-
var
|
|
5837
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
6433
5838
|
var DEFAULT_METHODS2 = [
|
|
6434
5839
|
"prepare",
|
|
6435
5840
|
"put",
|
|
@@ -6448,7 +5853,7 @@ function compile2(patterns) {
|
|
|
6448
5853
|
}
|
|
6449
5854
|
function storageMethodName(node, methods) {
|
|
6450
5855
|
const callee = node.callee;
|
|
6451
|
-
if (callee.type !==
|
|
5856
|
+
if (callee.type !== import_utils43.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6452
5857
|
return null;
|
|
6453
5858
|
}
|
|
6454
5859
|
const name = callee.property.name;
|
|
@@ -6460,7 +5865,7 @@ function storageMethodName(node, methods) {
|
|
|
6460
5865
|
}
|
|
6461
5866
|
return name;
|
|
6462
5867
|
}
|
|
6463
|
-
var no_storage_in_stateless_modules_default =
|
|
5868
|
+
var no_storage_in_stateless_modules_default = import_utils43.ESLintUtils.RuleCreator(
|
|
6464
5869
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6465
5870
|
)({
|
|
6466
5871
|
name: "no-storage-in-stateless-modules",
|
|
@@ -6518,7 +5923,7 @@ var no_storage_in_stateless_modules_default = import_utils49.ESLintUtils.RuleCre
|
|
|
6518
5923
|
});
|
|
6519
5924
|
|
|
6520
5925
|
// src/rules/no-zod-native-enum.ts
|
|
6521
|
-
var
|
|
5926
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
6522
5927
|
var ts2 = __toESM(require("typescript"), 1);
|
|
6523
5928
|
var IGNORE_PATTERNS2 = [
|
|
6524
5929
|
/[\\/]generated[\\/]/,
|
|
@@ -6536,7 +5941,7 @@ function isZodModule2(source) {
|
|
|
6536
5941
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
6537
5942
|
}
|
|
6538
5943
|
function unwrap3(node) {
|
|
6539
|
-
if (node.type ===
|
|
5944
|
+
if (node.type === import_utils44.AST_NODE_TYPES.TSAsExpression || node.type === import_utils44.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6540
5945
|
return unwrap3(node.expression);
|
|
6541
5946
|
}
|
|
6542
5947
|
return node;
|
|
@@ -6544,14 +5949,14 @@ function unwrap3(node) {
|
|
|
6544
5949
|
function stringValueTexts(node, sourceCode) {
|
|
6545
5950
|
const texts = [];
|
|
6546
5951
|
for (const prop of node.properties) {
|
|
6547
|
-
if (prop.type !==
|
|
5952
|
+
if (prop.type !== import_utils44.AST_NODE_TYPES.Property) {
|
|
6548
5953
|
return null;
|
|
6549
5954
|
}
|
|
6550
5955
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6551
5956
|
return null;
|
|
6552
5957
|
}
|
|
6553
5958
|
const value = prop.value;
|
|
6554
|
-
if (value.type !==
|
|
5959
|
+
if (value.type !== import_utils44.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
6555
5960
|
return null;
|
|
6556
5961
|
}
|
|
6557
5962
|
const text = sourceCode.getText(value);
|
|
@@ -6567,7 +5972,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6567
5972
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6568
5973
|
if (variable !== void 0) {
|
|
6569
5974
|
return variable.defs.some(
|
|
6570
|
-
(def) => def.node.type ===
|
|
5975
|
+
(def) => def.node.type === import_utils44.AST_NODE_TYPES.TSEnumDeclaration
|
|
6571
5976
|
);
|
|
6572
5977
|
}
|
|
6573
5978
|
current = current.upper;
|
|
@@ -6587,7 +5992,7 @@ function resolvesToImportedEnum(node, services) {
|
|
|
6587
5992
|
}
|
|
6588
5993
|
return (symbol.flags & ENUM_SYMBOL_FLAGS) !== 0;
|
|
6589
5994
|
}
|
|
6590
|
-
var no_zod_native_enum_default =
|
|
5995
|
+
var no_zod_native_enum_default = import_utils44.ESLintUtils.RuleCreator(
|
|
6591
5996
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6592
5997
|
)({
|
|
6593
5998
|
name: "no-zod-native-enum",
|
|
@@ -6614,32 +6019,32 @@ var no_zod_native_enum_default = import_utils50.ESLintUtils.RuleCreator(
|
|
|
6614
6019
|
}
|
|
6615
6020
|
let services;
|
|
6616
6021
|
try {
|
|
6617
|
-
services =
|
|
6022
|
+
services = import_utils44.ESLintUtils.getParserServices(context);
|
|
6618
6023
|
} catch {
|
|
6619
6024
|
services = null;
|
|
6620
6025
|
}
|
|
6621
6026
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6622
6027
|
function isZodMemberCall(node, api) {
|
|
6623
6028
|
const callee = node.callee;
|
|
6624
|
-
if (callee.type ===
|
|
6029
|
+
if (callee.type === import_utils44.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6625
6030
|
return callee.property.name === api;
|
|
6626
6031
|
}
|
|
6627
|
-
if (callee.type ===
|
|
6032
|
+
if (callee.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6628
6033
|
return zodImportedNames.get(callee.name) === api;
|
|
6629
6034
|
}
|
|
6630
6035
|
return false;
|
|
6631
6036
|
}
|
|
6632
6037
|
function buildFix(node) {
|
|
6633
6038
|
const callee = node.callee;
|
|
6634
|
-
if (callee.type !==
|
|
6039
|
+
if (callee.type !== import_utils44.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6635
6040
|
return null;
|
|
6636
6041
|
}
|
|
6637
6042
|
const arg = node.arguments[0];
|
|
6638
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6043
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === import_utils44.AST_NODE_TYPES.SpreadElement) {
|
|
6639
6044
|
return null;
|
|
6640
6045
|
}
|
|
6641
6046
|
const inner = unwrap3(arg);
|
|
6642
|
-
if (inner.type !==
|
|
6047
|
+
if (inner.type !== import_utils44.AST_NODE_TYPES.ObjectExpression) {
|
|
6643
6048
|
return null;
|
|
6644
6049
|
}
|
|
6645
6050
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6659,7 +6064,7 @@ var no_zod_native_enum_default = import_utils50.ESLintUtils.RuleCreator(
|
|
|
6659
6064
|
return;
|
|
6660
6065
|
}
|
|
6661
6066
|
for (const spec of node.specifiers) {
|
|
6662
|
-
if (spec.type ===
|
|
6067
|
+
if (spec.type === import_utils44.AST_NODE_TYPES.ImportSpecifier && spec.imported.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6663
6068
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6664
6069
|
}
|
|
6665
6070
|
}
|
|
@@ -6678,7 +6083,7 @@ var no_zod_native_enum_default = import_utils50.ESLintUtils.RuleCreator(
|
|
|
6678
6083
|
return;
|
|
6679
6084
|
}
|
|
6680
6085
|
const arg = node.arguments[0];
|
|
6681
|
-
if (arg === void 0 || arg.type !==
|
|
6086
|
+
if (arg === void 0 || arg.type !== import_utils44.AST_NODE_TYPES.Identifier) {
|
|
6682
6087
|
return;
|
|
6683
6088
|
}
|
|
6684
6089
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6695,7 +6100,7 @@ var no_zod_native_enum_default = import_utils50.ESLintUtils.RuleCreator(
|
|
|
6695
6100
|
});
|
|
6696
6101
|
|
|
6697
6102
|
// src/rules/prefer-module-level-constant.ts
|
|
6698
|
-
var
|
|
6103
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
6699
6104
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6700
6105
|
var MAX_LITERAL_DEPTH = 4;
|
|
6701
6106
|
var IGNORE_PATTERNS3 = [
|
|
@@ -6731,9 +6136,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6731
6136
|
"assign"
|
|
6732
6137
|
]);
|
|
6733
6138
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6139
|
+
import_utils45.AST_NODE_TYPES.FunctionDeclaration,
|
|
6140
|
+
import_utils45.AST_NODE_TYPES.FunctionExpression,
|
|
6141
|
+
import_utils45.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6737
6142
|
]);
|
|
6738
6143
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6739
6144
|
function isIgnoredFile3(filename, sourceText) {
|
|
@@ -6746,13 +6151,13 @@ function isTestFile2(filename) {
|
|
|
6746
6151
|
return TEST_FILE_PATTERNS.some((re) => re.test(filename));
|
|
6747
6152
|
}
|
|
6748
6153
|
function unwrap4(node) {
|
|
6749
|
-
if (node.type ===
|
|
6154
|
+
if (node.type === import_utils45.AST_NODE_TYPES.TSAsExpression || node.type === import_utils45.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils45.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6750
6155
|
return unwrap4(node.expression);
|
|
6751
6156
|
}
|
|
6752
6157
|
return node;
|
|
6753
6158
|
}
|
|
6754
6159
|
function isRegexLiteral(node) {
|
|
6755
|
-
return node.type ===
|
|
6160
|
+
return node.type === import_utils45.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6756
6161
|
}
|
|
6757
6162
|
function isLiteralOnly(node, depth) {
|
|
6758
6163
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6760,29 +6165,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6760
6165
|
}
|
|
6761
6166
|
const inner = unwrap4(node);
|
|
6762
6167
|
switch (inner.type) {
|
|
6763
|
-
case
|
|
6168
|
+
case import_utils45.AST_NODE_TYPES.Literal: {
|
|
6764
6169
|
return true;
|
|
6765
6170
|
}
|
|
6766
|
-
case
|
|
6171
|
+
case import_utils45.AST_NODE_TYPES.TemplateLiteral: {
|
|
6767
6172
|
return inner.expressions.length === 0;
|
|
6768
6173
|
}
|
|
6769
|
-
case
|
|
6770
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6174
|
+
case import_utils45.AST_NODE_TYPES.UnaryExpression: {
|
|
6175
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils45.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6771
6176
|
}
|
|
6772
|
-
case
|
|
6177
|
+
case import_utils45.AST_NODE_TYPES.ArrayExpression: {
|
|
6773
6178
|
return inner.elements.every(
|
|
6774
|
-
(el) => el !== null && el.type !==
|
|
6179
|
+
(el) => el !== null && el.type !== import_utils45.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6775
6180
|
);
|
|
6776
6181
|
}
|
|
6777
|
-
case
|
|
6182
|
+
case import_utils45.AST_NODE_TYPES.ObjectExpression: {
|
|
6778
6183
|
return inner.properties.every((prop) => {
|
|
6779
|
-
if (prop.type !==
|
|
6184
|
+
if (prop.type !== import_utils45.AST_NODE_TYPES.Property) {
|
|
6780
6185
|
return false;
|
|
6781
6186
|
}
|
|
6782
6187
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6783
6188
|
return false;
|
|
6784
6189
|
}
|
|
6785
|
-
if (prop.computed && prop.key.type !==
|
|
6190
|
+
if (prop.computed && prop.key.type !== import_utils45.AST_NODE_TYPES.Literal) {
|
|
6786
6191
|
return false;
|
|
6787
6192
|
}
|
|
6788
6193
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6795,7 +6200,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6795
6200
|
}
|
|
6796
6201
|
function unwrapObjectFreeze(node) {
|
|
6797
6202
|
const inner = unwrap4(node);
|
|
6798
|
-
if (inner.type ===
|
|
6203
|
+
if (inner.type === import_utils45.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils45.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils45.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils45.AST_NODE_TYPES.SpreadElement) {
|
|
6799
6204
|
return unwrap4(inner.arguments[0]);
|
|
6800
6205
|
}
|
|
6801
6206
|
return inner;
|
|
@@ -6811,19 +6216,19 @@ function classify(init, checkRegex) {
|
|
|
6811
6216
|
}
|
|
6812
6217
|
return { kind: "regex", size: 1 };
|
|
6813
6218
|
}
|
|
6814
|
-
if (node.type ===
|
|
6219
|
+
if (node.type === import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
6815
6220
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6816
6221
|
}
|
|
6817
|
-
if (node.type ===
|
|
6222
|
+
if (node.type === import_utils45.AST_NODE_TYPES.ObjectExpression) {
|
|
6818
6223
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6819
6224
|
}
|
|
6820
|
-
if (node.type ===
|
|
6225
|
+
if (node.type === import_utils45.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils45.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6821
6226
|
const arg = node.arguments[0];
|
|
6822
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6227
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils45.AST_NODE_TYPES.SpreadElement) {
|
|
6823
6228
|
return null;
|
|
6824
6229
|
}
|
|
6825
6230
|
const entries = unwrap4(arg);
|
|
6826
|
-
if (entries.type !==
|
|
6231
|
+
if (entries.type !== import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
6827
6232
|
return null;
|
|
6828
6233
|
}
|
|
6829
6234
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6852,10 +6257,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6852
6257
|
);
|
|
6853
6258
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6854
6259
|
const callee = node.callee;
|
|
6855
|
-
if (callee.type ===
|
|
6260
|
+
if (callee.type === import_utils45.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6856
6261
|
return true;
|
|
6857
6262
|
}
|
|
6858
|
-
if (callee.type !==
|
|
6263
|
+
if (callee.type !== import_utils45.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils45.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6859
6264
|
return false;
|
|
6860
6265
|
}
|
|
6861
6266
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6869,43 +6274,43 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6869
6274
|
}
|
|
6870
6275
|
function isSafeRead(identifier) {
|
|
6871
6276
|
const parent = identifier.parent;
|
|
6872
|
-
if (parent.type ===
|
|
6277
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.MemberExpression) {
|
|
6873
6278
|
if (parent.object !== identifier) {
|
|
6874
6279
|
return true;
|
|
6875
6280
|
}
|
|
6876
6281
|
const grandparent = parent.parent;
|
|
6877
|
-
if (grandparent.type ===
|
|
6282
|
+
if (grandparent.type === import_utils45.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6878
6283
|
return false;
|
|
6879
6284
|
}
|
|
6880
|
-
if (grandparent.type ===
|
|
6285
|
+
if (grandparent.type === import_utils45.AST_NODE_TYPES.UpdateExpression) {
|
|
6881
6286
|
return false;
|
|
6882
6287
|
}
|
|
6883
|
-
if (grandparent.type ===
|
|
6288
|
+
if (grandparent.type === import_utils45.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6884
6289
|
return false;
|
|
6885
6290
|
}
|
|
6886
|
-
if (!parent.computed && parent.property.type ===
|
|
6291
|
+
if (!parent.computed && parent.property.type === import_utils45.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === import_utils45.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
6887
6292
|
return false;
|
|
6888
6293
|
}
|
|
6889
6294
|
return true;
|
|
6890
6295
|
}
|
|
6891
|
-
if (parent.type ===
|
|
6296
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6892
6297
|
return true;
|
|
6893
6298
|
}
|
|
6894
|
-
if (parent.type ===
|
|
6299
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.SpreadElement) {
|
|
6895
6300
|
return true;
|
|
6896
6301
|
}
|
|
6897
|
-
if (parent.type ===
|
|
6302
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.BinaryExpression) {
|
|
6898
6303
|
return true;
|
|
6899
6304
|
}
|
|
6900
|
-
if (parent.type ===
|
|
6305
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6901
6306
|
return true;
|
|
6902
6307
|
}
|
|
6903
|
-
if (parent.type ===
|
|
6308
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6904
6309
|
return true;
|
|
6905
6310
|
}
|
|
6906
6311
|
return false;
|
|
6907
6312
|
}
|
|
6908
|
-
var prefer_module_level_constant_default =
|
|
6313
|
+
var prefer_module_level_constant_default = import_utils45.ESLintUtils.RuleCreator(
|
|
6909
6314
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6910
6315
|
)({
|
|
6911
6316
|
name: "prefer-module-level-constant",
|
|
@@ -6957,7 +6362,7 @@ var prefer_module_level_constant_default = import_utils51.ESLintUtils.RuleCreato
|
|
|
6957
6362
|
if (reference.isWrite()) {
|
|
6958
6363
|
return false;
|
|
6959
6364
|
}
|
|
6960
|
-
if (reference.identifier.type !==
|
|
6365
|
+
if (reference.identifier.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
6961
6366
|
return false;
|
|
6962
6367
|
}
|
|
6963
6368
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6969,10 +6374,10 @@ var prefer_module_level_constant_default = import_utils51.ESLintUtils.RuleCreato
|
|
|
6969
6374
|
return {
|
|
6970
6375
|
VariableDeclarator(node) {
|
|
6971
6376
|
const declaration = node.parent;
|
|
6972
|
-
if (declaration.type !==
|
|
6377
|
+
if (declaration.type !== import_utils45.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6973
6378
|
return;
|
|
6974
6379
|
}
|
|
6975
|
-
if (node.id.type !==
|
|
6380
|
+
if (node.id.type !== import_utils45.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
6976
6381
|
return;
|
|
6977
6382
|
}
|
|
6978
6383
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6999,7 +6404,7 @@ var prefer_module_level_constant_default = import_utils51.ESLintUtils.RuleCreato
|
|
|
6999
6404
|
});
|
|
7000
6405
|
|
|
7001
6406
|
// src/rules/jsdoc-restates-signature.ts
|
|
7002
|
-
var
|
|
6407
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
7003
6408
|
var VALUE_TAGS = /* @__PURE__ */ new Set([
|
|
7004
6409
|
"alpha",
|
|
7005
6410
|
"author",
|
|
@@ -7082,30 +6487,30 @@ function declarationNames(node) {
|
|
|
7082
6487
|
switch (node.type) {
|
|
7083
6488
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
7084
6489
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
7085
|
-
case
|
|
7086
|
-
case
|
|
6490
|
+
case import_utils46.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
6491
|
+
case import_utils46.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
7087
6492
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
7088
|
-
case
|
|
7089
|
-
case
|
|
6493
|
+
case import_utils46.AST_NODE_TYPES.FunctionDeclaration:
|
|
6494
|
+
case import_utils46.AST_NODE_TYPES.TSDeclareFunction:
|
|
7090
6495
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
7091
|
-
case
|
|
7092
|
-
case
|
|
7093
|
-
case
|
|
7094
|
-
case
|
|
6496
|
+
case import_utils46.AST_NODE_TYPES.ClassDeclaration:
|
|
6497
|
+
case import_utils46.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
6498
|
+
case import_utils46.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
6499
|
+
case import_utils46.AST_NODE_TYPES.TSEnumDeclaration:
|
|
7095
6500
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
7096
|
-
case
|
|
6501
|
+
case import_utils46.AST_NODE_TYPES.VariableDeclaration: {
|
|
7097
6502
|
const declarator = node.declarations[0];
|
|
7098
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
6503
|
+
if (declarator === void 0 || declarator.id.type !== import_utils46.AST_NODE_TYPES.Identifier) return null;
|
|
7099
6504
|
const init = declarator.init;
|
|
7100
|
-
const params = init != null && (init.type ===
|
|
6505
|
+
const params = init != null && (init.type === import_utils46.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils46.AST_NODE_TYPES.FunctionExpression) ? paramNames(init.params) : [];
|
|
7101
6506
|
return { name: declarator.id.name, params };
|
|
7102
6507
|
}
|
|
7103
|
-
case
|
|
7104
|
-
case
|
|
7105
|
-
case
|
|
7106
|
-
case
|
|
7107
|
-
if (node.key.type !==
|
|
7108
|
-
const params = node.type ===
|
|
6508
|
+
case import_utils46.AST_NODE_TYPES.MethodDefinition:
|
|
6509
|
+
case import_utils46.AST_NODE_TYPES.PropertyDefinition:
|
|
6510
|
+
case import_utils46.AST_NODE_TYPES.TSMethodSignature:
|
|
6511
|
+
case import_utils46.AST_NODE_TYPES.TSPropertySignature: {
|
|
6512
|
+
if (node.key.type !== import_utils46.AST_NODE_TYPES.Identifier) return null;
|
|
6513
|
+
const params = node.type === import_utils46.AST_NODE_TYPES.MethodDefinition ? paramNames(node.value.params) : node.type === import_utils46.AST_NODE_TYPES.TSMethodSignature ? paramNames(node.params) : [];
|
|
7109
6514
|
return { name: node.key.name, params };
|
|
7110
6515
|
}
|
|
7111
6516
|
default:
|
|
@@ -7115,9 +6520,9 @@ function declarationNames(node) {
|
|
|
7115
6520
|
function paramNames(params) {
|
|
7116
6521
|
const names = [];
|
|
7117
6522
|
for (const param of params) {
|
|
7118
|
-
const target = param.type ===
|
|
7119
|
-
if (target.type ===
|
|
7120
|
-
else if (target.type ===
|
|
6523
|
+
const target = param.type === import_utils46.AST_NODE_TYPES.AssignmentPattern ? param.left : param;
|
|
6524
|
+
if (target.type === import_utils46.AST_NODE_TYPES.Identifier) names.push(target.name);
|
|
6525
|
+
else if (target.type === import_utils46.AST_NODE_TYPES.TSParameterProperty) continue;
|
|
7121
6526
|
}
|
|
7122
6527
|
return names;
|
|
7123
6528
|
}
|
|
@@ -7126,7 +6531,7 @@ function tokensOf(names) {
|
|
|
7126
6531
|
for (const name of names) for (const part of splitIdentifier(name)) tokens.add(part);
|
|
7127
6532
|
return tokens;
|
|
7128
6533
|
}
|
|
7129
|
-
var jsdoc_restates_signature_default =
|
|
6534
|
+
var jsdoc_restates_signature_default = import_utils46.ESLintUtils.RuleCreator(
|
|
7130
6535
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7131
6536
|
)({
|
|
7132
6537
|
name: "jsdoc-restates-signature",
|
|
@@ -7162,7 +6567,7 @@ var jsdoc_restates_signature_default = import_utils52.ESLintUtils.RuleCreator(
|
|
|
7162
6567
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
7163
6568
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
7164
6569
|
let declaration = null;
|
|
7165
|
-
while (node != null && node.type !==
|
|
6570
|
+
while (node != null && node.type !== import_utils46.AST_NODE_TYPES.Program) {
|
|
7166
6571
|
declaration = declarationNames(node);
|
|
7167
6572
|
if (declaration !== null) break;
|
|
7168
6573
|
node = node.parent ?? null;
|
|
@@ -7217,7 +6622,7 @@ var jsdoc_restates_signature_default = import_utils52.ESLintUtils.RuleCreator(
|
|
|
7217
6622
|
});
|
|
7218
6623
|
|
|
7219
6624
|
// src/rules/no-restated-comment.ts
|
|
7220
|
-
var
|
|
6625
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
7221
6626
|
var MAX_WORDS = 8;
|
|
7222
6627
|
var MIN_CONTENT_TOKENS = 2;
|
|
7223
6628
|
var DIRECTIVE_RE3 = /^(eslint\b|eslint-|sarj-noqa\b|@ts-|prettier-ignore|prettier\b|biome-|c8\b|v8\b|istanbul\b|@type\b|@vite|webpack|<reference|<amd|global\b|noinspection|todo\b|fixme\b|hack\b|xxx\b)/i;
|
|
@@ -7241,7 +6646,7 @@ function headsSiblingRun(node) {
|
|
|
7241
6646
|
const next = index >= 0 ? body[index + 1] : void 0;
|
|
7242
6647
|
return next !== void 0 && next.type === node.type;
|
|
7243
6648
|
}
|
|
7244
|
-
var no_restated_comment_default =
|
|
6649
|
+
var no_restated_comment_default = import_utils47.ESLintUtils.RuleCreator(
|
|
7245
6650
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7246
6651
|
)({
|
|
7247
6652
|
name: "no-restated-comment",
|
|
@@ -7269,7 +6674,7 @@ var no_restated_comment_default = import_utils53.ESLintUtils.RuleCreator(
|
|
|
7269
6674
|
function labelsASiblingRun(comment) {
|
|
7270
6675
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
7271
6676
|
if (token === null) return false;
|
|
7272
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
6677
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== import_utils47.AST_NODE_TYPES.Program; node = node.parent) {
|
|
7273
6678
|
if (headsSiblingRun(node)) return true;
|
|
7274
6679
|
}
|
|
7275
6680
|
return false;
|
|
@@ -7309,7 +6714,7 @@ var no_restated_comment_default = import_utils53.ESLintUtils.RuleCreator(
|
|
|
7309
6714
|
});
|
|
7310
6715
|
|
|
7311
6716
|
// src/rules/trailing-value-narration.ts
|
|
7312
|
-
var
|
|
6717
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
7313
6718
|
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
7314
6719
|
var WORD_RE3 = /[A-Za-z]+(?:'[a-z]+)?|\d+(?:\.\d+)?/g;
|
|
7315
6720
|
var UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -7393,7 +6798,7 @@ function narratesValue(body, code) {
|
|
|
7393
6798
|
(word) => STOPWORDS3.has(word) || UNIT_WORDS.has(word) || commentNumbers.has(word) || identifiers.has(word) || stems.has(stem(word))
|
|
7394
6799
|
);
|
|
7395
6800
|
}
|
|
7396
|
-
var trailing_value_narration_default =
|
|
6801
|
+
var trailing_value_narration_default = import_utils48.ESLintUtils.RuleCreator(
|
|
7397
6802
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7398
6803
|
)({
|
|
7399
6804
|
name: "trailing-value-narration",
|
|
@@ -7434,7 +6839,7 @@ var trailing_value_narration_default = import_utils54.ESLintUtils.RuleCreator(
|
|
|
7434
6839
|
});
|
|
7435
6840
|
|
|
7436
6841
|
// src/rules/no-tautological-expect.ts
|
|
7437
|
-
var
|
|
6842
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
7438
6843
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
7439
6844
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
7440
6845
|
"toBeDefined",
|
|
@@ -7448,17 +6853,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
7448
6853
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
7449
6854
|
function isLiteral(node) {
|
|
7450
6855
|
switch (node.type) {
|
|
7451
|
-
case
|
|
6856
|
+
case import_utils49.AST_NODE_TYPES.Literal:
|
|
7452
6857
|
return true;
|
|
7453
|
-
case
|
|
6858
|
+
case import_utils49.AST_NODE_TYPES.TemplateLiteral:
|
|
7454
6859
|
return node.expressions.length === 0;
|
|
7455
|
-
case
|
|
6860
|
+
case import_utils49.AST_NODE_TYPES.UnaryExpression:
|
|
7456
6861
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
7457
|
-
case
|
|
6862
|
+
case import_utils49.AST_NODE_TYPES.ArrayExpression:
|
|
7458
6863
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
7459
|
-
case
|
|
6864
|
+
case import_utils49.AST_NODE_TYPES.ObjectExpression:
|
|
7460
6865
|
return node.properties.every(
|
|
7461
|
-
(property) => property.type ===
|
|
6866
|
+
(property) => property.type === import_utils49.AST_NODE_TYPES.Property && !property.computed && isLiteral(property.value)
|
|
7462
6867
|
);
|
|
7463
6868
|
default:
|
|
7464
6869
|
return false;
|
|
@@ -7466,12 +6871,12 @@ function isLiteral(node) {
|
|
|
7466
6871
|
}
|
|
7467
6872
|
function expectOperand(callee) {
|
|
7468
6873
|
const receiver = callee.object;
|
|
7469
|
-
if (receiver.type !==
|
|
6874
|
+
if (receiver.type !== import_utils49.AST_NODE_TYPES.CallExpression || receiver.callee.type !== import_utils49.AST_NODE_TYPES.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
7470
6875
|
return null;
|
|
7471
6876
|
}
|
|
7472
6877
|
return receiver.arguments[0] ?? null;
|
|
7473
6878
|
}
|
|
7474
|
-
var no_tautological_expect_default =
|
|
6879
|
+
var no_tautological_expect_default = import_utils49.ESLintUtils.RuleCreator(
|
|
7475
6880
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7476
6881
|
)({
|
|
7477
6882
|
name: "no-tautological-expect",
|
|
@@ -7498,10 +6903,10 @@ var no_tautological_expect_default = import_utils55.ESLintUtils.RuleCreator(
|
|
|
7498
6903
|
return {
|
|
7499
6904
|
CallExpression(node) {
|
|
7500
6905
|
const callee = node.callee;
|
|
7501
|
-
if (callee.type !==
|
|
6906
|
+
if (callee.type !== import_utils49.AST_NODE_TYPES.MemberExpression || callee.computed) {
|
|
7502
6907
|
return;
|
|
7503
6908
|
}
|
|
7504
|
-
if (callee.property.type !==
|
|
6909
|
+
if (callee.property.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
7505
6910
|
return;
|
|
7506
6911
|
}
|
|
7507
6912
|
const matcher = callee.property.name;
|
|
@@ -7535,26 +6940,26 @@ var no_tautological_expect_default = import_utils55.ESLintUtils.RuleCreator(
|
|
|
7535
6940
|
});
|
|
7536
6941
|
|
|
7537
6942
|
// src/rules/require-interface-for-injected-service.ts
|
|
7538
|
-
var
|
|
6943
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7539
6944
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
7540
6945
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
7541
6946
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
7542
6947
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
7543
6948
|
var ROUTER_FACTORY_NAME = "Router";
|
|
7544
6949
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
7545
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
7546
|
-
var qualifiedName = (name) => name.type ===
|
|
6950
|
+
var isExportedClass = (node) => node.parent.type === import_utils50.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils50.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
6951
|
+
var qualifiedName = (name) => name.type === import_utils50.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils50.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
7547
6952
|
var typeReferenceName = (annotated) => {
|
|
7548
6953
|
let target = annotated;
|
|
7549
|
-
if (target.type ===
|
|
7550
|
-
if (target.type ===
|
|
7551
|
-
if (target.type !==
|
|
6954
|
+
if (target.type === import_utils50.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
6955
|
+
if (target.type === import_utils50.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
6956
|
+
if (target.type !== import_utils50.AST_NODE_TYPES.Identifier) return null;
|
|
7552
6957
|
const annotation = target.typeAnnotation?.typeAnnotation;
|
|
7553
|
-
if (annotation === void 0 || annotation.type !==
|
|
6958
|
+
if (annotation === void 0 || annotation.type !== import_utils50.AST_NODE_TYPES.TSTypeReference) {
|
|
7554
6959
|
return null;
|
|
7555
6960
|
}
|
|
7556
6961
|
const { typeName } = annotation;
|
|
7557
|
-
const rightmost = typeName.type ===
|
|
6962
|
+
const rightmost = typeName.type === import_utils50.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils50.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
7558
6963
|
if (rightmost === null) return null;
|
|
7559
6964
|
return { name: target.name, typeName: rightmost, display: qualifiedName(typeName) };
|
|
7560
6965
|
};
|
|
@@ -7564,17 +6969,17 @@ var readConstructor = (ctor) => {
|
|
|
7564
6969
|
let constructedFields = 0;
|
|
7565
6970
|
if (body !== null && body !== void 0) {
|
|
7566
6971
|
for (const statement of body.body) {
|
|
7567
|
-
if (statement.type !==
|
|
6972
|
+
if (statement.type !== import_utils50.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
7568
6973
|
const expression = statement.expression;
|
|
7569
|
-
if (expression.type !==
|
|
6974
|
+
if (expression.type !== import_utils50.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils50.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils50.AST_NODE_TYPES.ThisExpression) {
|
|
7570
6975
|
continue;
|
|
7571
6976
|
}
|
|
7572
6977
|
const source = expression.right;
|
|
7573
|
-
if (source.type ===
|
|
6978
|
+
if (source.type === import_utils50.AST_NODE_TYPES.NewExpression) {
|
|
7574
6979
|
constructedFields += 1;
|
|
7575
|
-
} else if (source.type ===
|
|
6980
|
+
} else if (source.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7576
6981
|
storedFrom.add(source.name);
|
|
7577
|
-
} else if (source.type ===
|
|
6982
|
+
} else if (source.type === import_utils50.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7578
6983
|
storedFrom.add(source.object.name);
|
|
7579
6984
|
}
|
|
7580
6985
|
}
|
|
@@ -7583,7 +6988,7 @@ var readConstructor = (ctor) => {
|
|
|
7583
6988
|
for (const parameter of ctor.value.params) {
|
|
7584
6989
|
const reference = typeReferenceName(parameter);
|
|
7585
6990
|
if (reference === null) continue;
|
|
7586
|
-
const stored = parameter.type ===
|
|
6991
|
+
const stored = parameter.type === import_utils50.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
7587
6992
|
if (!stored) continue;
|
|
7588
6993
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
7589
6994
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -7613,19 +7018,19 @@ var subtreeHas = (root, found) => {
|
|
|
7613
7018
|
return hit;
|
|
7614
7019
|
};
|
|
7615
7020
|
var isFrameworkWiring = (body) => subtreeHas(body, (node) => {
|
|
7616
|
-
if (node.type ===
|
|
7021
|
+
if (node.type === import_utils50.AST_NODE_TYPES.CallExpression) {
|
|
7617
7022
|
const { callee } = node;
|
|
7618
|
-
if (callee.type ===
|
|
7619
|
-
return callee.type ===
|
|
7023
|
+
if (callee.type === import_utils50.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
7024
|
+
return callee.type === import_utils50.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils50.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
7620
7025
|
}
|
|
7621
|
-
return node.type ===
|
|
7026
|
+
return node.type === import_utils50.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils50.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
7622
7027
|
});
|
|
7623
7028
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
7624
7029
|
var fileInterfaceNames = (program) => {
|
|
7625
7030
|
const names = [];
|
|
7626
7031
|
for (const statement of program.body) {
|
|
7627
|
-
const declaration = statement.type ===
|
|
7628
|
-
if (declaration?.type ===
|
|
7032
|
+
const declaration = statement.type === import_utils50.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
7033
|
+
if (declaration?.type === import_utils50.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
7629
7034
|
}
|
|
7630
7035
|
return names;
|
|
7631
7036
|
};
|
|
@@ -7643,16 +7048,16 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
7643
7048
|
var publicMethodNames = (body) => {
|
|
7644
7049
|
const names = [];
|
|
7645
7050
|
for (const member of body.body) {
|
|
7646
|
-
if (member.type !==
|
|
7051
|
+
if (member.type !== import_utils50.AST_NODE_TYPES.MethodDefinition) continue;
|
|
7647
7052
|
if (member.kind !== "method" || member.static) continue;
|
|
7648
7053
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
7649
|
-
if (member.key.type ===
|
|
7650
|
-
if (member.key.type ===
|
|
7054
|
+
if (member.key.type === import_utils50.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
7055
|
+
if (member.key.type === import_utils50.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
7651
7056
|
else names.push("\u2026");
|
|
7652
7057
|
}
|
|
7653
7058
|
return names;
|
|
7654
7059
|
};
|
|
7655
|
-
var require_interface_for_injected_service_default =
|
|
7060
|
+
var require_interface_for_injected_service_default = import_utils50.ESLintUtils.RuleCreator(
|
|
7656
7061
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7657
7062
|
)({
|
|
7658
7063
|
name: "require-interface-for-injected-service",
|
|
@@ -7680,7 +7085,7 @@ var require_interface_for_injected_service_default = import_utils56.ESLintUtils.
|
|
|
7680
7085
|
if (node.implements.length > 0) return;
|
|
7681
7086
|
if (node.decorators.length > 0) return;
|
|
7682
7087
|
const ctor = node.body.body.find(
|
|
7683
|
-
(member) => member.type ===
|
|
7088
|
+
(member) => member.type === import_utils50.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
7684
7089
|
);
|
|
7685
7090
|
if (ctor === void 0) return;
|
|
7686
7091
|
const { collaborators, constructedFields } = readConstructor(ctor);
|
|
@@ -7705,26 +7110,26 @@ var require_interface_for_injected_service_default = import_utils56.ESLintUtils.
|
|
|
7705
7110
|
});
|
|
7706
7111
|
|
|
7707
7112
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7708
|
-
var
|
|
7113
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7709
7114
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7710
7115
|
function propertyName(node) {
|
|
7711
7116
|
const key = node.key;
|
|
7712
|
-
if (key.type ===
|
|
7713
|
-
if (key.type ===
|
|
7117
|
+
if (key.type === import_utils51.AST_NODE_TYPES.Identifier) return key.name;
|
|
7118
|
+
if (key.type === import_utils51.AST_NODE_TYPES.Literal) return String(key.value);
|
|
7714
7119
|
return "collection";
|
|
7715
7120
|
}
|
|
7716
7121
|
function isArrayType(node) {
|
|
7717
|
-
if (node.type ===
|
|
7718
|
-
return node.type ===
|
|
7122
|
+
if (node.type === import_utils51.AST_NODE_TYPES.TSArrayType) return true;
|
|
7123
|
+
return node.type === import_utils51.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils51.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7719
7124
|
}
|
|
7720
7125
|
function isNullishType(node) {
|
|
7721
|
-
return node.type ===
|
|
7126
|
+
return node.type === import_utils51.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils51.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7722
7127
|
}
|
|
7723
7128
|
function isNullableArrayOnly(node) {
|
|
7724
7129
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
7725
7130
|
return values.length > 0 && values.length < node.types.length && values.every(isArrayType);
|
|
7726
7131
|
}
|
|
7727
|
-
var prefer_non_nullable_collection_default =
|
|
7132
|
+
var prefer_non_nullable_collection_default = import_utils51.ESLintUtils.RuleCreator(
|
|
7728
7133
|
(name) => `https://github.com/sarj-ai/standards/tree/main/packages/typescript#${name}`
|
|
7729
7134
|
)({
|
|
7730
7135
|
name: "prefer-non-nullable-collection",
|
|
@@ -7747,7 +7152,7 @@ var prefer_non_nullable_collection_default = import_utils57.ESLintUtils.RuleCrea
|
|
|
7747
7152
|
function checkOptionalProperty(node) {
|
|
7748
7153
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7749
7154
|
if (annotation === void 0) return;
|
|
7750
|
-
if (annotation.type !==
|
|
7155
|
+
if (annotation.type !== import_utils51.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7751
7156
|
return;
|
|
7752
7157
|
}
|
|
7753
7158
|
context.report({
|
|
@@ -7760,7 +7165,7 @@ var prefer_non_nullable_collection_default = import_utils57.ESLintUtils.RuleCrea
|
|
|
7760
7165
|
TSPropertySignature: checkOptionalProperty,
|
|
7761
7166
|
PropertyDefinition: checkOptionalProperty,
|
|
7762
7167
|
TSTypeAliasDeclaration(node) {
|
|
7763
|
-
if (node.typeAnnotation.type !==
|
|
7168
|
+
if (node.typeAnnotation.type !== import_utils51.AST_NODE_TYPES.TSUnionType) return;
|
|
7764
7169
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7765
7170
|
context.report({
|
|
7766
7171
|
node,
|
|
@@ -7773,41 +7178,41 @@ var prefer_non_nullable_collection_default = import_utils57.ESLintUtils.RuleCrea
|
|
|
7773
7178
|
});
|
|
7774
7179
|
|
|
7775
7180
|
// src/rules/primary-export-file-name.ts
|
|
7776
|
-
var
|
|
7777
|
-
var
|
|
7181
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7182
|
+
var CONVENTIONAL_BUCKET_EXPORTS = /* @__PURE__ */ new Set(["cn"]);
|
|
7778
7183
|
var GENERIC_ENTRYPOINTS = /* @__PURE__ */ new Set(["main", "run", "cli", "setup", "teardown", "execute"]);
|
|
7779
|
-
var
|
|
7184
|
+
var ACRONYM_OVERRIDES = [
|
|
7780
7185
|
[/OAuth/g, "Oauth"],
|
|
7781
7186
|
[/GraphQL/g, "Graphql"],
|
|
7782
7187
|
[/gRPC/g, "Grpc"]
|
|
7783
7188
|
];
|
|
7784
|
-
var
|
|
7785
|
-
var
|
|
7786
|
-
var
|
|
7787
|
-
var
|
|
7189
|
+
var CAMEL_BOUNDARY_RE = /(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g;
|
|
7190
|
+
var basename = (filename) => filename.split(/[/\\]/).pop() ?? filename;
|
|
7191
|
+
var stemOf = (base) => base.replace(/\.(test|spec|config|d|stories)\.[cm]?[jt]sx?$/i, "").replace(/\.[cm]?[jt]sx?$/i, "");
|
|
7192
|
+
var kebabCase = (name) => {
|
|
7788
7193
|
let normalized = name;
|
|
7789
|
-
for (const [pattern, replacement] of
|
|
7194
|
+
for (const [pattern, replacement] of ACRONYM_OVERRIDES) {
|
|
7790
7195
|
normalized = normalized.replace(pattern, replacement);
|
|
7791
7196
|
}
|
|
7792
|
-
return normalized.replace(
|
|
7197
|
+
return normalized.replace(CAMEL_BOUNDARY_RE, "-").toLowerCase();
|
|
7793
7198
|
};
|
|
7794
|
-
var isFunctionOrClass = (node) => node.type ===
|
|
7199
|
+
var isFunctionOrClass = (node) => node.type === import_utils52.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils52.AST_NODE_TYPES.FunctionExpression;
|
|
7795
7200
|
var findPrimaryExport = (body) => {
|
|
7796
7201
|
let exportCount = 0;
|
|
7797
7202
|
let primaryCandidate = null;
|
|
7798
7203
|
for (const statement of body) {
|
|
7799
|
-
if (statement.type ===
|
|
7204
|
+
if (statement.type === import_utils52.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
7800
7205
|
return null;
|
|
7801
7206
|
}
|
|
7802
|
-
if (statement.type ===
|
|
7207
|
+
if (statement.type === import_utils52.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
7803
7208
|
exportCount += 1;
|
|
7804
7209
|
const decl = statement.declaration;
|
|
7805
|
-
if ((decl.type ===
|
|
7210
|
+
if ((decl.type === import_utils52.AST_NODE_TYPES.FunctionDeclaration || decl.type === import_utils52.AST_NODE_TYPES.ClassDeclaration) && decl.id !== null) {
|
|
7806
7211
|
primaryCandidate = { name: decl.id.name, node: statement, isDefault: true };
|
|
7807
|
-
} else if (decl.type ===
|
|
7212
|
+
} else if (decl.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7808
7213
|
primaryCandidate = { name: decl.name, node: statement, isDefault: true };
|
|
7809
7214
|
}
|
|
7810
|
-
} else if (statement.type ===
|
|
7215
|
+
} else if (statement.type === import_utils52.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
7811
7216
|
if (statement.source !== null) {
|
|
7812
7217
|
return null;
|
|
7813
7218
|
}
|
|
@@ -7816,27 +7221,27 @@ var findPrimaryExport = (body) => {
|
|
|
7816
7221
|
exportCount += statement.specifiers.length;
|
|
7817
7222
|
if (statement.specifiers.length === 1 && primaryCandidate === null) {
|
|
7818
7223
|
const spec = statement.specifiers[0];
|
|
7819
|
-
if (spec && spec.exported.type ===
|
|
7224
|
+
if (spec && spec.exported.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7820
7225
|
primaryCandidate = { name: spec.exported.name, node: statement, isDefault: false };
|
|
7821
7226
|
}
|
|
7822
7227
|
}
|
|
7823
|
-
} else if (decl.type ===
|
|
7228
|
+
} else if (decl.type === import_utils52.AST_NODE_TYPES.FunctionDeclaration || decl.type === import_utils52.AST_NODE_TYPES.ClassDeclaration) {
|
|
7824
7229
|
if (decl.id !== null) {
|
|
7825
7230
|
exportCount += 1;
|
|
7826
7231
|
if (primaryCandidate === null) {
|
|
7827
7232
|
primaryCandidate = { name: decl.id.name, node: statement, isDefault: false };
|
|
7828
7233
|
}
|
|
7829
7234
|
}
|
|
7830
|
-
} else if (decl.type ===
|
|
7235
|
+
} else if (decl.type === import_utils52.AST_NODE_TYPES.VariableDeclaration) {
|
|
7831
7236
|
for (const declarator of decl.declarations) {
|
|
7832
|
-
if (declarator.id.type ===
|
|
7237
|
+
if (declarator.id.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7833
7238
|
exportCount += 1;
|
|
7834
7239
|
if (primaryCandidate === null && declarator.init && isFunctionOrClass(declarator.init)) {
|
|
7835
7240
|
primaryCandidate = { name: declarator.id.name, node: statement, isDefault: false };
|
|
7836
7241
|
}
|
|
7837
7242
|
}
|
|
7838
7243
|
}
|
|
7839
|
-
} else if (decl.type ===
|
|
7244
|
+
} else if (decl.type === import_utils52.AST_NODE_TYPES.TSTypeAliasDeclaration || decl.type === import_utils52.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
7840
7245
|
exportCount += 1;
|
|
7841
7246
|
if (primaryCandidate === null) {
|
|
7842
7247
|
primaryCandidate = { name: decl.id.name, node: statement, isDefault: false };
|
|
@@ -7849,7 +7254,7 @@ var findPrimaryExport = (body) => {
|
|
|
7849
7254
|
}
|
|
7850
7255
|
return { ...primaryCandidate, count: exportCount };
|
|
7851
7256
|
};
|
|
7852
|
-
var primary_export_file_name_default =
|
|
7257
|
+
var primary_export_file_name_default = import_utils52.ESLintUtils.RuleCreator(
|
|
7853
7258
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7854
7259
|
)({
|
|
7855
7260
|
name: "primary-export-file-name",
|
|
@@ -7865,10 +7270,10 @@ var primary_export_file_name_default = import_utils58.ESLintUtils.RuleCreator(
|
|
|
7865
7270
|
},
|
|
7866
7271
|
defaultOptions: [],
|
|
7867
7272
|
create(context) {
|
|
7868
|
-
const base =
|
|
7273
|
+
const base = basename(context.filename);
|
|
7869
7274
|
if (base.endsWith(".d.ts") || base.startsWith("index.") || base.startsWith("_")) return {};
|
|
7870
7275
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
7871
|
-
const stem3 =
|
|
7276
|
+
const stem3 = stemOf(base);
|
|
7872
7277
|
if (stem3 === "page" || stem3 === "layout" || stem3 === "loading" || stem3 === "error" || stem3 === "not-found" || stem3 === "route" || stem3 === "__root" || stem3 === "config" || stem3 === "constants" || stem3 === "types" || stem3.startsWith("$") || stem3.startsWith("[")) {
|
|
7873
7278
|
return {};
|
|
7874
7279
|
}
|
|
@@ -7876,8 +7281,8 @@ var primary_export_file_name_default = import_utils58.ESLintUtils.RuleCreator(
|
|
|
7876
7281
|
Program(node) {
|
|
7877
7282
|
const primary = findPrimaryExport(node.body);
|
|
7878
7283
|
if (primary === null) return;
|
|
7879
|
-
if (
|
|
7880
|
-
const expectedStem =
|
|
7284
|
+
if (CONVENTIONAL_BUCKET_EXPORTS.has(primary.name) || GENERIC_ENTRYPOINTS.has(primary.name)) return;
|
|
7285
|
+
const expectedStem = kebabCase(primary.name);
|
|
7881
7286
|
if (stem3 === expectedStem) return;
|
|
7882
7287
|
const ext = base.endsWith(".tsx") ? ".tsx" : ".ts";
|
|
7883
7288
|
context.report({
|
|
@@ -7891,7 +7296,7 @@ var primary_export_file_name_default = import_utils58.ESLintUtils.RuleCreator(
|
|
|
7891
7296
|
});
|
|
7892
7297
|
|
|
7893
7298
|
// src/rules/no-implicit-attribute-access.ts
|
|
7894
|
-
var
|
|
7299
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7895
7300
|
var EXCLUDED_BASES = /* @__PURE__ */ new Set([
|
|
7896
7301
|
"environ",
|
|
7897
7302
|
"headers",
|
|
@@ -7907,15 +7312,15 @@ var EXCLUDED_BASES = /* @__PURE__ */ new Set([
|
|
|
7907
7312
|
"sessionStorage"
|
|
7908
7313
|
]);
|
|
7909
7314
|
function getBaseName(node) {
|
|
7910
|
-
if (node.type ===
|
|
7315
|
+
if (node.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7911
7316
|
return node.name;
|
|
7912
7317
|
}
|
|
7913
|
-
if (node.type ===
|
|
7318
|
+
if (node.type === import_utils53.AST_NODE_TYPES.MemberExpression && node.property.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7914
7319
|
return node.property.name;
|
|
7915
7320
|
}
|
|
7916
7321
|
return null;
|
|
7917
7322
|
}
|
|
7918
|
-
var no_implicit_attribute_access_default =
|
|
7323
|
+
var no_implicit_attribute_access_default = import_utils53.ESLintUtils.RuleCreator(
|
|
7919
7324
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7920
7325
|
)({
|
|
7921
7326
|
name: "no-implicit-attribute-access",
|
|
@@ -7936,7 +7341,7 @@ var no_implicit_attribute_access_default = import_utils59.ESLintUtils.RuleCreato
|
|
|
7936
7341
|
if (!node.computed) {
|
|
7937
7342
|
return;
|
|
7938
7343
|
}
|
|
7939
|
-
if (node.property.type ===
|
|
7344
|
+
if (node.property.type === import_utils53.AST_NODE_TYPES.Literal && typeof node.property.value === "string") {
|
|
7940
7345
|
const baseName = getBaseName(node.object);
|
|
7941
7346
|
if (!baseName || !EXCLUDED_BASES.has(baseName)) {
|
|
7942
7347
|
context.report({
|
|
@@ -7949,11 +7354,11 @@ var no_implicit_attribute_access_default = import_utils59.ESLintUtils.RuleCreato
|
|
|
7949
7354
|
},
|
|
7950
7355
|
CallExpression(node) {
|
|
7951
7356
|
const callee = node.callee;
|
|
7952
|
-
if (callee.type ===
|
|
7953
|
-
const method = callee.property.type ===
|
|
7357
|
+
if (callee.type === import_utils53.AST_NODE_TYPES.MemberExpression) {
|
|
7358
|
+
const method = callee.property.type === import_utils53.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
7954
7359
|
if (method === "get") {
|
|
7955
7360
|
const arg = node.arguments[0];
|
|
7956
|
-
if (arg && arg.type ===
|
|
7361
|
+
if (arg && arg.type === import_utils53.AST_NODE_TYPES.Literal && typeof arg.value === "string") {
|
|
7957
7362
|
const baseName = getBaseName(callee.object);
|
|
7958
7363
|
if (!baseName || !EXCLUDED_BASES.has(baseName)) {
|
|
7959
7364
|
context.report({
|
|
@@ -7971,8 +7376,8 @@ var no_implicit_attribute_access_default = import_utils59.ESLintUtils.RuleCreato
|
|
|
7971
7376
|
});
|
|
7972
7377
|
|
|
7973
7378
|
// src/rules/strict-test-assertions.ts
|
|
7974
|
-
var
|
|
7975
|
-
var strict_test_assertions_default =
|
|
7379
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
7380
|
+
var strict_test_assertions_default = import_utils54.ESLintUtils.RuleCreator.withoutDocs({
|
|
7976
7381
|
meta: {
|
|
7977
7382
|
type: "suggestion",
|
|
7978
7383
|
docs: {
|
|
@@ -7990,9 +7395,9 @@ var strict_test_assertions_default = import_utils60.ESLintUtils.RuleCreator.with
|
|
|
7990
7395
|
let currentObject = null;
|
|
7991
7396
|
let sequence = [];
|
|
7992
7397
|
function getExpectObject(expr) {
|
|
7993
|
-
if (expr.type ===
|
|
7398
|
+
if (expr.type === import_utils54.AST_NODE_TYPES.CallExpression && expr.callee.type === import_utils54.AST_NODE_TYPES.MemberExpression && expr.callee.object.type === import_utils54.AST_NODE_TYPES.CallExpression && expr.callee.object.callee.type === import_utils54.AST_NODE_TYPES.Identifier && expr.callee.object.callee.name === "expect" && expr.callee.object.arguments.length === 1) {
|
|
7994
7399
|
const arg = expr.callee.object.arguments.at(0);
|
|
7995
|
-
if (arg?.type ===
|
|
7400
|
+
if (arg?.type === import_utils54.AST_NODE_TYPES.MemberExpression) {
|
|
7996
7401
|
return arg.object;
|
|
7997
7402
|
}
|
|
7998
7403
|
}
|
|
@@ -8008,12 +7413,12 @@ var strict_test_assertions_default = import_utils60.ESLintUtils.RuleCreator.with
|
|
|
8008
7413
|
if (!currentObject) return null;
|
|
8009
7414
|
const objectText = context.sourceCode.getText(currentObject);
|
|
8010
7415
|
const props = sequence.map((stmt) => {
|
|
8011
|
-
if (stmt.expression.type !==
|
|
7416
|
+
if (stmt.expression.type !== import_utils54.AST_NODE_TYPES.CallExpression || stmt.expression.callee.type !== import_utils54.AST_NODE_TYPES.MemberExpression || stmt.expression.callee.object.type !== import_utils54.AST_NODE_TYPES.CallExpression) {
|
|
8012
7417
|
return null;
|
|
8013
7418
|
}
|
|
8014
7419
|
const actual = stmt.expression.callee.object.arguments.at(0);
|
|
8015
7420
|
const expected = stmt.expression.arguments.at(0);
|
|
8016
|
-
if (actual?.type ===
|
|
7421
|
+
if (actual?.type === import_utils54.AST_NODE_TYPES.MemberExpression && actual.property.type === import_utils54.AST_NODE_TYPES.Identifier && expected) {
|
|
8017
7422
|
const propName2 = actual.property.name;
|
|
8018
7423
|
const valText = context.sourceCode.getText(expected);
|
|
8019
7424
|
return `${propName2}: ${valText}`;
|
|
@@ -8031,7 +7436,7 @@ var strict_test_assertions_default = import_utils60.ESLintUtils.RuleCreator.with
|
|
|
8031
7436
|
}
|
|
8032
7437
|
}
|
|
8033
7438
|
for (const statement of body) {
|
|
8034
|
-
if (statement.type ===
|
|
7439
|
+
if (statement.type === import_utils54.AST_NODE_TYPES.ExpressionStatement) {
|
|
8035
7440
|
const obj = getExpectObject(statement.expression);
|
|
8036
7441
|
if (obj && currentObject && context.sourceCode.getText(obj) === context.sourceCode.getText(currentObject)) {
|
|
8037
7442
|
sequence.push(statement);
|
|
@@ -8065,8 +7470,8 @@ var strict_test_assertions_default = import_utils60.ESLintUtils.RuleCreator.with
|
|
|
8065
7470
|
});
|
|
8066
7471
|
|
|
8067
7472
|
// src/rules/no-async-callback-in-waitfor.ts
|
|
8068
|
-
var
|
|
8069
|
-
var no_async_callback_in_waitfor_default =
|
|
7473
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
7474
|
+
var no_async_callback_in_waitfor_default = import_utils55.ESLintUtils.RuleCreator(
|
|
8070
7475
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
8071
7476
|
)({
|
|
8072
7477
|
name: "no-async-callback-in-waitfor",
|
|
@@ -8087,9 +7492,9 @@ var no_async_callback_in_waitfor_default = import_utils61.ESLintUtils.RuleCreato
|
|
|
8087
7492
|
}
|
|
8088
7493
|
return {
|
|
8089
7494
|
CallExpression(node) {
|
|
8090
|
-
if (node.callee.type ===
|
|
7495
|
+
if (node.callee.type === import_utils55.AST_NODE_TYPES.Identifier && node.callee.name === "waitFor") {
|
|
8091
7496
|
const callback = node.arguments[0];
|
|
8092
|
-
if (callback && (callback.type ===
|
|
7497
|
+
if (callback && (callback.type === import_utils55.AST_NODE_TYPES.ArrowFunctionExpression || callback.type === import_utils55.AST_NODE_TYPES.FunctionExpression) && callback.async) {
|
|
8093
7498
|
context.report({
|
|
8094
7499
|
node: callback,
|
|
8095
7500
|
messageId: "noAsyncCallbackInWaitFor"
|
|
@@ -8102,8 +7507,8 @@ var no_async_callback_in_waitfor_default = import_utils61.ESLintUtils.RuleCreato
|
|
|
8102
7507
|
});
|
|
8103
7508
|
|
|
8104
7509
|
// src/rules/prefer-setup-file-mocks.ts
|
|
8105
|
-
var
|
|
8106
|
-
var prefer_setup_file_mocks_default =
|
|
7510
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
7511
|
+
var prefer_setup_file_mocks_default = import_utils56.ESLintUtils.RuleCreator(
|
|
8107
7512
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
8108
7513
|
)({
|
|
8109
7514
|
name: "prefer-setup-file-mocks",
|
|
@@ -8124,7 +7529,7 @@ var prefer_setup_file_mocks_default = import_utils62.ESLintUtils.RuleCreator(
|
|
|
8124
7529
|
}
|
|
8125
7530
|
return {
|
|
8126
7531
|
CallExpression(node) {
|
|
8127
|
-
if (node.callee.type ===
|
|
7532
|
+
if (node.callee.type === import_utils56.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils56.AST_NODE_TYPES.Identifier && (node.callee.object.name === "vi" || node.callee.object.name === "jest") && node.callee.property.type === import_utils56.AST_NODE_TYPES.Identifier && node.callee.property.name === "mock") {
|
|
8128
7533
|
context.report({
|
|
8129
7534
|
node,
|
|
8130
7535
|
messageId: "preferSetupFileMocks"
|
|
@@ -8147,29 +7552,24 @@ var rules = {
|
|
|
8147
7552
|
"no-log-only-catch": no_log_only_catch_default,
|
|
8148
7553
|
"no-raw-env": no_raw_env_default,
|
|
8149
7554
|
"no-sentinel-return-on-catch": no_sentinel_return_on_catch_default,
|
|
8150
|
-
"no-sequential-await": no_sequential_await_default,
|
|
8151
7555
|
"no-string-concat-in-loop": no_string_concat_in_loop_default,
|
|
8152
7556
|
"no-unnecessary-use-client": no_unnecessary_use_client_default,
|
|
8153
7557
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
8154
7558
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
8155
7559
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
8156
7560
|
"prefer-server-actions": prefer_server_actions_default,
|
|
8157
|
-
"prefer-shadcn": prefer_shadcn_default,
|
|
8158
7561
|
"require-assert-never": require_assert_never_default,
|
|
8159
7562
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
8160
7563
|
"zod-naming-convention": zod_naming_convention_default,
|
|
8161
7564
|
"no-cors-wildcard-with-credentials": no_cors_wildcard_with_credentials_default,
|
|
8162
7565
|
"no-fat-try-blocks": no_fat_try_blocks_default,
|
|
8163
7566
|
"no-secret-in-log": no_secret_in_log_default,
|
|
8164
|
-
"no-unsafe-cast": no_unsafe_cast_default,
|
|
8165
7567
|
"no-unsafe-mock-casting": no_unsafe_mock_casting_default,
|
|
8166
7568
|
"prefer-string-literal-union": prefer_string_literal_union_default,
|
|
8167
7569
|
"prefer-zod-enum": prefer_zod_enum_default,
|
|
8168
|
-
"single-public-export": single_public_export_default,
|
|
8169
7570
|
"primary-export-file-name": primary_export_file_name_default,
|
|
8170
7571
|
"no-silent-promise-catch": no_silent_promise_catch_default,
|
|
8171
7572
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
8172
|
-
"require-schema-validate-search": require_schema_validate_search_default,
|
|
8173
7573
|
"no-offset-pagination": no_offset_pagination_default,
|
|
8174
7574
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
8175
7575
|
"no-repeated-string-literal": no_repeated_string_literal_default,
|
|
@@ -8197,7 +7597,7 @@ var rules = {
|
|
|
8197
7597
|
var plugin = {
|
|
8198
7598
|
meta: {
|
|
8199
7599
|
name: "@sarj/eslint-plugin",
|
|
8200
|
-
version: "
|
|
7600
|
+
version: "3.0.0"
|
|
8201
7601
|
},
|
|
8202
7602
|
rules,
|
|
8203
7603
|
configs: {
|
|
@@ -8214,7 +7614,6 @@ var plugin = {
|
|
|
8214
7614
|
"@sarj/no-unnecessary-use-client": "warn",
|
|
8215
7615
|
"@sarj/prefer-schema-for-api-payload": "warn",
|
|
8216
7616
|
// Distilled from sarj-audit skills — warn in recommended, error in strict.
|
|
8217
|
-
"@sarj/no-sequential-await": "warn",
|
|
8218
7617
|
"@sarj/no-sentinel-return-on-catch": "warn",
|
|
8219
7618
|
"@sarj/no-log-only-catch": "warn",
|
|
8220
7619
|
"@sarj/no-insecure-random-id": "warn",
|
|
@@ -8231,16 +7630,13 @@ var plugin = {
|
|
|
8231
7630
|
"@sarj/no-fat-try-blocks": "warn",
|
|
8232
7631
|
"@sarj/no-cors-wildcard-with-credentials": "warn",
|
|
8233
7632
|
"@sarj/no-secret-in-log": "warn",
|
|
8234
|
-
"@sarj/no-unsafe-cast": "warn",
|
|
8235
7633
|
"@sarj/no-unsafe-mock-casting": "warn",
|
|
8236
|
-
"@sarj/single-public-export": "warn",
|
|
8237
7634
|
"@sarj/primary-export-file-name": "warn",
|
|
8238
7635
|
"@sarj/prefer-string-literal-union": "warn",
|
|
8239
7636
|
"@sarj/prefer-zod-enum": "warn",
|
|
8240
7637
|
// Mined from 2y of PR review feedback + 5-repo code-smell audit (2026-07).
|
|
8241
7638
|
"@sarj/require-fetch-timeout": "warn",
|
|
8242
7639
|
"@sarj/no-silent-promise-catch": "warn",
|
|
8243
|
-
"@sarj/require-schema-validate-search": "warn",
|
|
8244
7640
|
// Second SARJ port wave — the TS/Python parity gap. Each targets a
|
|
8245
7641
|
// defect class seen in production Workers code: timing-leaky secret
|
|
8246
7642
|
// compares, non-idempotent store writes under queue redelivery,
|
|
@@ -8301,14 +7697,12 @@ var plugin = {
|
|
|
8301
7697
|
"@sarj/ban-loose-type-guards-in-tests": "error",
|
|
8302
7698
|
"@sarj/enforce-file-structure": "error",
|
|
8303
7699
|
"@sarj/no-raw-env": "error",
|
|
8304
|
-
"@sarj/prefer-shadcn": "error",
|
|
8305
7700
|
"@sarj/no-enum": "error",
|
|
8306
7701
|
"@sarj/no-client-side-data-fetching": "error",
|
|
8307
7702
|
"@sarj/prefer-server-actions": "error",
|
|
8308
7703
|
"@sarj/no-unnecessary-use-client": "error",
|
|
8309
7704
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
8310
7705
|
// Distilled from sarj-audit skills.
|
|
8311
|
-
"@sarj/no-sequential-await": "error",
|
|
8312
7706
|
"@sarj/no-sentinel-return-on-catch": "error",
|
|
8313
7707
|
"@sarj/no-log-only-catch": "error",
|
|
8314
7708
|
"@sarj/no-insecure-random-id": "error",
|
|
@@ -8326,9 +7720,7 @@ var plugin = {
|
|
|
8326
7720
|
"@sarj/no-fat-try-blocks": "error",
|
|
8327
7721
|
"@sarj/no-cors-wildcard-with-credentials": "error",
|
|
8328
7722
|
"@sarj/no-secret-in-log": "error",
|
|
8329
|
-
"@sarj/no-unsafe-cast": "error",
|
|
8330
7723
|
"@sarj/no-unsafe-mock-casting": "error",
|
|
8331
|
-
"@sarj/single-public-export": "error",
|
|
8332
7724
|
"@sarj/primary-export-file-name": "error",
|
|
8333
7725
|
// Promoted to error 2026-07-25 — strict means strict (user directive).
|
|
8334
7726
|
"@sarj/prefer-string-literal-union": "error",
|
|
@@ -8336,7 +7728,6 @@ var plugin = {
|
|
|
8336
7728
|
// Mined from 2y of PR review feedback + 5-repo code-smell audit (2026-07).
|
|
8337
7729
|
"@sarj/require-fetch-timeout": "error",
|
|
8338
7730
|
"@sarj/no-silent-promise-catch": "error",
|
|
8339
|
-
"@sarj/require-schema-validate-search": "error",
|
|
8340
7731
|
// Second SARJ port wave — the TS/Python parity gap.
|
|
8341
7732
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
8342
7733
|
"@sarj/store-insert-requires-on-conflict": "error",
|