@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.js
CHANGED
|
@@ -1825,257 +1825,8 @@ var no_sentinel_return_on_catch_default = ESLintUtils10.RuleCreator(
|
|
|
1825
1825
|
}
|
|
1826
1826
|
});
|
|
1827
1827
|
|
|
1828
|
-
// src/rules/no-sequential-await.ts
|
|
1829
|
-
import { ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
|
|
1830
|
-
var ARRAY_ITERATION_METHODS = /* @__PURE__ */ new Set(["forEach", "map", "filter"]);
|
|
1831
|
-
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;
|
|
1832
|
-
var BENCH_FILE_RE = /(^|[\\/])bench(marks?)?[\\/]|\.bench\.[cm]?[jt]sx?$/i;
|
|
1833
|
-
function isFunctionLike(node) {
|
|
1834
|
-
return node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
|
1835
|
-
}
|
|
1836
|
-
function isLoop(node) {
|
|
1837
|
-
return node.type === "ForStatement" || node.type === "ForOfStatement" || node.type === "ForInStatement" || node.type === "WhileStatement" || node.type === "DoWhileStatement";
|
|
1838
|
-
}
|
|
1839
|
-
function isNode2(value) {
|
|
1840
|
-
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
1841
|
-
}
|
|
1842
|
-
function visitScope(root, visit) {
|
|
1843
|
-
visit(root);
|
|
1844
|
-
for (const key of Object.keys(root)) {
|
|
1845
|
-
if (key === "parent") {
|
|
1846
|
-
continue;
|
|
1847
|
-
}
|
|
1848
|
-
const value = root[key];
|
|
1849
|
-
const children = Array.isArray(value) ? value : [value];
|
|
1850
|
-
for (const child of children) {
|
|
1851
|
-
if (isNode2(child) && !isFunctionLike(child) && !isLoop(child)) {
|
|
1852
|
-
visitScope(child, visit);
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
function collectAwaits(root) {
|
|
1858
|
-
const awaits = [];
|
|
1859
|
-
visitScope(root, (node) => {
|
|
1860
|
-
if (node.type === "AwaitExpression") {
|
|
1861
|
-
awaits.push(node);
|
|
1862
|
-
}
|
|
1863
|
-
});
|
|
1864
|
-
return awaits;
|
|
1865
|
-
}
|
|
1866
|
-
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
1867
|
-
function hasEarlyExit(root) {
|
|
1868
|
-
let found = false;
|
|
1869
|
-
visitScope(root, (node) => {
|
|
1870
|
-
if (node.type === "ReturnStatement" || node.type === "BreakStatement" || node.type === "ContinueStatement") {
|
|
1871
|
-
found = true;
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1874
|
-
return found;
|
|
1875
|
-
}
|
|
1876
|
-
var TIMER_HELPER_RE = /^(sleep|timeout|delay|wait|pause|tick)$/i;
|
|
1877
|
-
function calleeName2(callee) {
|
|
1878
|
-
if (callee.type === "Identifier") return callee.name;
|
|
1879
|
-
if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier") {
|
|
1880
|
-
return callee.property.name;
|
|
1881
|
-
}
|
|
1882
|
-
return null;
|
|
1883
|
-
}
|
|
1884
|
-
function isTimerYield(node) {
|
|
1885
|
-
const arg = node.argument;
|
|
1886
|
-
if (arg.type === "NewExpression" && arg.callee.type === "Identifier" && arg.callee.name === "Promise") {
|
|
1887
|
-
return true;
|
|
1888
|
-
}
|
|
1889
|
-
if (arg.type === "CallExpression") {
|
|
1890
|
-
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")) {
|
|
1891
|
-
return true;
|
|
1892
|
-
}
|
|
1893
|
-
const name = calleeName2(arg.callee);
|
|
1894
|
-
return name !== null && TIMER_HELPER_RE.test(name);
|
|
1895
|
-
}
|
|
1896
|
-
return false;
|
|
1897
|
-
}
|
|
1898
|
-
var QUEUE_DRAIN_METHODS = /^(shift|pop|dequeue|next|poll)$/;
|
|
1899
|
-
function isQueueDrain(node) {
|
|
1900
|
-
const arg = node.argument;
|
|
1901
|
-
return arg.type === "CallExpression" && arg.callee.type === "MemberExpression" && !arg.callee.computed && arg.callee.property.type === "Identifier" && QUEUE_DRAIN_METHODS.test(arg.callee.property.name);
|
|
1902
|
-
}
|
|
1903
|
-
function hasAssertion(root) {
|
|
1904
|
-
let found = false;
|
|
1905
|
-
visitScope(root, (node) => {
|
|
1906
|
-
if (node.type !== "CallExpression") {
|
|
1907
|
-
return;
|
|
1908
|
-
}
|
|
1909
|
-
let callee = node.callee;
|
|
1910
|
-
while (callee.type === "MemberExpression") {
|
|
1911
|
-
callee = callee.object;
|
|
1912
|
-
}
|
|
1913
|
-
if (callee.type === "CallExpression") {
|
|
1914
|
-
callee = callee.callee;
|
|
1915
|
-
}
|
|
1916
|
-
if (callee.type === "Identifier" && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
1917
|
-
found = true;
|
|
1918
|
-
}
|
|
1919
|
-
});
|
|
1920
|
-
return found;
|
|
1921
|
-
}
|
|
1922
|
-
function referencesName(root, name) {
|
|
1923
|
-
let found = false;
|
|
1924
|
-
visitScope(root, (node) => {
|
|
1925
|
-
if (node.type === "Identifier" && node.name === name) {
|
|
1926
|
-
found = true;
|
|
1927
|
-
}
|
|
1928
|
-
});
|
|
1929
|
-
return found;
|
|
1930
|
-
}
|
|
1931
|
-
function isThreadedAccumulator(node) {
|
|
1932
|
-
const parent = node.parent;
|
|
1933
|
-
let target = null;
|
|
1934
|
-
if (parent.type === "AssignmentExpression" && parent.operator === "=" && parent.right === node && parent.left.type === "Identifier") {
|
|
1935
|
-
target = parent.left.name;
|
|
1936
|
-
} else if (parent.type === "VariableDeclarator" && parent.init === node && parent.id.type === "Identifier") {
|
|
1937
|
-
target = parent.id.name;
|
|
1938
|
-
}
|
|
1939
|
-
if (target === null) {
|
|
1940
|
-
return false;
|
|
1941
|
-
}
|
|
1942
|
-
return referencesName(node.argument, target);
|
|
1943
|
-
}
|
|
1944
|
-
function namesReadBy(test) {
|
|
1945
|
-
const names = /* @__PURE__ */ new Set();
|
|
1946
|
-
visitScope(test, (node) => {
|
|
1947
|
-
if (node.type === "Identifier") {
|
|
1948
|
-
names.add(node.name);
|
|
1949
|
-
}
|
|
1950
|
-
});
|
|
1951
|
-
return names;
|
|
1952
|
-
}
|
|
1953
|
-
function testStateIsAssignedInBody(test, body) {
|
|
1954
|
-
const testNames = namesReadBy(test);
|
|
1955
|
-
if (testNames.size === 0) {
|
|
1956
|
-
return false;
|
|
1957
|
-
}
|
|
1958
|
-
let found = false;
|
|
1959
|
-
visitScope(body, (node) => {
|
|
1960
|
-
if (node.type === "AssignmentExpression" && node.operator === "=" && node.left.type === "Identifier" && testNames.has(node.left.name)) {
|
|
1961
|
-
found = true;
|
|
1962
|
-
}
|
|
1963
|
-
});
|
|
1964
|
-
return found;
|
|
1965
|
-
}
|
|
1966
|
-
function shouldReport(awaits, earlyExit, iterableText, asserts = false) {
|
|
1967
|
-
if (awaits.length === 0) {
|
|
1968
|
-
return false;
|
|
1969
|
-
}
|
|
1970
|
-
if (earlyExit) {
|
|
1971
|
-
return false;
|
|
1972
|
-
}
|
|
1973
|
-
if (asserts) {
|
|
1974
|
-
return false;
|
|
1975
|
-
}
|
|
1976
|
-
if (iterableText !== null && SEQUENTIAL_ITERABLE_HINT.test(iterableText)) {
|
|
1977
|
-
return false;
|
|
1978
|
-
}
|
|
1979
|
-
return awaits.some(
|
|
1980
|
-
(node) => !isTimerYield(node) && !isThreadedAccumulator(node) && !isQueueDrain(node)
|
|
1981
|
-
);
|
|
1982
|
-
}
|
|
1983
|
-
var no_sequential_await_default = ESLintUtils11.RuleCreator(
|
|
1984
|
-
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
1985
|
-
)({
|
|
1986
|
-
name: "no-sequential-await",
|
|
1987
|
-
meta: {
|
|
1988
|
-
type: "problem",
|
|
1989
|
-
docs: {
|
|
1990
|
-
description: "Disallow serial `await` inside a loop; use `await Promise.all(...)` to run the operations concurrently."
|
|
1991
|
-
},
|
|
1992
|
-
schema: [],
|
|
1993
|
-
messages: {
|
|
1994
|
-
noSequentialAwait: "Avoid `await` inside a loop \u2014 it serializes I/O. Collect the promises and `await Promise.all(xs.map(async (x) => ...))` instead."
|
|
1995
|
-
}
|
|
1996
|
-
},
|
|
1997
|
-
defaultOptions: [],
|
|
1998
|
-
create(context) {
|
|
1999
|
-
if (isTestFile(context.filename) || BENCH_FILE_RE.test(context.filename)) {
|
|
2000
|
-
return {};
|
|
2001
|
-
}
|
|
2002
|
-
function loopParts(node) {
|
|
2003
|
-
if (node.type === "ForStatement") {
|
|
2004
|
-
return [node.body, node.test, node.update];
|
|
2005
|
-
}
|
|
2006
|
-
if (node.type === "ForOfStatement" || node.type === "ForInStatement") {
|
|
2007
|
-
return [node.body];
|
|
2008
|
-
}
|
|
2009
|
-
return [node.body, node.test];
|
|
2010
|
-
}
|
|
2011
|
-
function iterableTextOf(node) {
|
|
2012
|
-
if (node.type === "ForOfStatement" || node.type === "ForInStatement") {
|
|
2013
|
-
return context.sourceCode.getText(node.right);
|
|
2014
|
-
}
|
|
2015
|
-
return null;
|
|
2016
|
-
}
|
|
2017
|
-
function checkLoop(node) {
|
|
2018
|
-
if ((node.type === "WhileStatement" || node.type === "DoWhileStatement") && testStateIsAssignedInBody(node.test, node.body)) {
|
|
2019
|
-
return;
|
|
2020
|
-
}
|
|
2021
|
-
const awaits = [];
|
|
2022
|
-
let earlyExit = false;
|
|
2023
|
-
let asserts = false;
|
|
2024
|
-
for (const part of loopParts(node)) {
|
|
2025
|
-
if (part === null || isLoop(part)) {
|
|
2026
|
-
continue;
|
|
2027
|
-
}
|
|
2028
|
-
awaits.push(...collectAwaits(part));
|
|
2029
|
-
if (!earlyExit && hasEarlyExit(part)) {
|
|
2030
|
-
earlyExit = true;
|
|
2031
|
-
}
|
|
2032
|
-
if (!asserts && hasAssertion(part)) {
|
|
2033
|
-
asserts = true;
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
if (shouldReport(awaits, earlyExit, iterableTextOf(node), asserts)) {
|
|
2037
|
-
context.report({ node, messageId: "noSequentialAwait" });
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
return {
|
|
2041
|
-
ForStatement: checkLoop,
|
|
2042
|
-
ForInStatement: checkLoop,
|
|
2043
|
-
WhileStatement: checkLoop,
|
|
2044
|
-
DoWhileStatement: checkLoop,
|
|
2045
|
-
ForOfStatement(node) {
|
|
2046
|
-
if (node.await) {
|
|
2047
|
-
return;
|
|
2048
|
-
}
|
|
2049
|
-
checkLoop(node);
|
|
2050
|
-
},
|
|
2051
|
-
CallExpression(node) {
|
|
2052
|
-
const callee = node.callee;
|
|
2053
|
-
if (callee.type !== "MemberExpression" || callee.computed) {
|
|
2054
|
-
return;
|
|
2055
|
-
}
|
|
2056
|
-
if (callee.property.type !== "Identifier" || !ARRAY_ITERATION_METHODS.has(callee.property.name)) {
|
|
2057
|
-
return;
|
|
2058
|
-
}
|
|
2059
|
-
const callback = node.arguments[0];
|
|
2060
|
-
if (callback === void 0 || !isFunctionLike(callback) || !("async" in callback && callback.async)) {
|
|
2061
|
-
return;
|
|
2062
|
-
}
|
|
2063
|
-
if (callee.property.name !== "forEach" && node.parent.type !== "ExpressionStatement") {
|
|
2064
|
-
return;
|
|
2065
|
-
}
|
|
2066
|
-
const awaits = collectAwaits(callback.body);
|
|
2067
|
-
const earlyExit = hasEarlyExit(callback.body);
|
|
2068
|
-
const iterableText = context.sourceCode.getText(callee.object);
|
|
2069
|
-
if (shouldReport(awaits, earlyExit, iterableText, hasAssertion(callback.body))) {
|
|
2070
|
-
context.report({ node, messageId: "noSequentialAwait" });
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
};
|
|
2074
|
-
}
|
|
2075
|
-
});
|
|
2076
|
-
|
|
2077
1828
|
// src/rules/no-string-concat-in-loop.ts
|
|
2078
|
-
import { ESLintUtils as
|
|
1829
|
+
import { ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
|
|
2079
1830
|
var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
2080
1831
|
"ForStatement",
|
|
2081
1832
|
"ForOfStatement",
|
|
@@ -2160,7 +1911,7 @@ function enclosingLoop(node) {
|
|
|
2160
1911
|
}
|
|
2161
1912
|
return null;
|
|
2162
1913
|
}
|
|
2163
|
-
var no_string_concat_in_loop_default =
|
|
1914
|
+
var no_string_concat_in_loop_default = ESLintUtils11.RuleCreator(
|
|
2164
1915
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2165
1916
|
)({
|
|
2166
1917
|
name: "no-string-concat-in-loop",
|
|
@@ -2225,7 +1976,7 @@ var no_string_concat_in_loop_default = ESLintUtils12.RuleCreator(
|
|
|
2225
1976
|
// src/rules/no-unnecessary-use-client.ts
|
|
2226
1977
|
import {
|
|
2227
1978
|
AST_NODE_TYPES as AST_NODE_TYPES6,
|
|
2228
|
-
ESLintUtils as
|
|
1979
|
+
ESLintUtils as ESLintUtils12
|
|
2229
1980
|
} from "@typescript-eslint/utils";
|
|
2230
1981
|
var HOOK_REGEX = /^use([A-Z]|$)/;
|
|
2231
1982
|
var EVENT_PROP_REGEX = /^on[A-Z]/;
|
|
@@ -2299,7 +2050,7 @@ var isGlobalReference = (node, context) => {
|
|
|
2299
2050
|
}
|
|
2300
2051
|
return true;
|
|
2301
2052
|
};
|
|
2302
|
-
var no_unnecessary_use_client_default =
|
|
2053
|
+
var no_unnecessary_use_client_default = ESLintUtils12.RuleCreator(
|
|
2303
2054
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2304
2055
|
)({
|
|
2305
2056
|
name: "no-unnecessary-use-client",
|
|
@@ -2420,7 +2171,7 @@ var no_unnecessary_use_client_default = ESLintUtils13.RuleCreator(
|
|
|
2420
2171
|
});
|
|
2421
2172
|
|
|
2422
2173
|
// src/rules/prefer-discriminated-union.ts
|
|
2423
|
-
import { ESLintUtils as
|
|
2174
|
+
import { ESLintUtils as ESLintUtils13 } from "@typescript-eslint/utils";
|
|
2424
2175
|
import { AST_NODE_TYPES as AST_NODE_TYPES7 } from "@typescript-eslint/utils";
|
|
2425
2176
|
var STATUS_MEMBER_NAMES = /* @__PURE__ */ new Set([
|
|
2426
2177
|
"success",
|
|
@@ -2467,7 +2218,7 @@ function looksLikeMutuallyExclusiveState(typeLiteral) {
|
|
|
2467
2218
|
}
|
|
2468
2219
|
return hasStatusBoolean && optionalCount >= MIN_OPTIONAL_MEMBERS && optionalPayloadCount >= 1;
|
|
2469
2220
|
}
|
|
2470
|
-
var prefer_discriminated_union_default =
|
|
2221
|
+
var prefer_discriminated_union_default = ESLintUtils13.RuleCreator(
|
|
2471
2222
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2472
2223
|
)({
|
|
2473
2224
|
name: "prefer-discriminated-union",
|
|
@@ -2510,7 +2261,7 @@ var prefer_discriminated_union_default = ESLintUtils14.RuleCreator(
|
|
|
2510
2261
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
2511
2262
|
import {
|
|
2512
2263
|
AST_NODE_TYPES as AST_NODE_TYPES8,
|
|
2513
|
-
ESLintUtils as
|
|
2264
|
+
ESLintUtils as ESLintUtils14
|
|
2514
2265
|
} from "@typescript-eslint/utils";
|
|
2515
2266
|
var unwrap = (node) => {
|
|
2516
2267
|
let current = node;
|
|
@@ -2575,7 +2326,7 @@ var isLocalFileRead = (node) => {
|
|
|
2575
2326
|
visit(node);
|
|
2576
2327
|
return found;
|
|
2577
2328
|
};
|
|
2578
|
-
var
|
|
2329
|
+
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
2579
2330
|
var isInsideAssertion = (node) => {
|
|
2580
2331
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
2581
2332
|
if (current.type !== AST_NODE_TYPES8.CallExpression) continue;
|
|
@@ -2586,7 +2337,7 @@ var isInsideAssertion = (node) => {
|
|
|
2586
2337
|
if (callee.type === AST_NODE_TYPES8.CallExpression) {
|
|
2587
2338
|
callee = callee.callee;
|
|
2588
2339
|
}
|
|
2589
|
-
if (callee.type === AST_NODE_TYPES8.Identifier &&
|
|
2340
|
+
if (callee.type === AST_NODE_TYPES8.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
2590
2341
|
return true;
|
|
2591
2342
|
}
|
|
2592
2343
|
}
|
|
@@ -2633,7 +2384,7 @@ var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
|
2633
2384
|
const variable = findVariable2(scope, unwrapped.name);
|
|
2634
2385
|
return variable !== null && tracked.has(variable);
|
|
2635
2386
|
};
|
|
2636
|
-
var prefer_schema_for_api_payload_default =
|
|
2387
|
+
var prefer_schema_for_api_payload_default = ESLintUtils14.RuleCreator(
|
|
2637
2388
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2638
2389
|
)({
|
|
2639
2390
|
name: "prefer-schema-for-api-payload",
|
|
@@ -2747,7 +2498,7 @@ var prefer_schema_for_api_payload_default = ESLintUtils15.RuleCreator(
|
|
|
2747
2498
|
});
|
|
2748
2499
|
|
|
2749
2500
|
// src/rules/prefer-semantic-colors.ts
|
|
2750
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as
|
|
2501
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils15 } from "@typescript-eslint/utils";
|
|
2751
2502
|
import { existsSync, readFileSync } from "fs";
|
|
2752
2503
|
import { dirname, join, parse } from "path";
|
|
2753
2504
|
|
|
@@ -2800,6 +2551,7 @@ var DETECTION_FILES = [
|
|
|
2800
2551
|
"src/styles/globals.css",
|
|
2801
2552
|
"styles/globals.css"
|
|
2802
2553
|
];
|
|
2554
|
+
var MAX_UPWARD_DEPTH = 8;
|
|
2803
2555
|
var semanticTokenCache = /* @__PURE__ */ new Map();
|
|
2804
2556
|
var SVG_DEFS_CONTAINERS = /* @__PURE__ */ new Set([
|
|
2805
2557
|
"mask",
|
|
@@ -2854,9 +2606,15 @@ var isInsideIconFactoryPath = (node) => {
|
|
|
2854
2606
|
var hasSemanticTokenSystem = (filename) => {
|
|
2855
2607
|
let dir = dirname(filename);
|
|
2856
2608
|
const root = parse(dir).root;
|
|
2857
|
-
|
|
2609
|
+
const visited = [];
|
|
2610
|
+
let answer;
|
|
2611
|
+
for (let depth = 0; depth < MAX_UPWARD_DEPTH; depth += 1) {
|
|
2858
2612
|
const cached = semanticTokenCache.get(dir);
|
|
2859
|
-
if (cached !== void 0)
|
|
2613
|
+
if (cached !== void 0) {
|
|
2614
|
+
answer = cached;
|
|
2615
|
+
break;
|
|
2616
|
+
}
|
|
2617
|
+
visited.push(dir);
|
|
2860
2618
|
let found = false;
|
|
2861
2619
|
for (const rel of DETECTION_FILES) {
|
|
2862
2620
|
const candidate = join(dir, rel);
|
|
@@ -2873,18 +2631,26 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
2873
2631
|
} catch {
|
|
2874
2632
|
}
|
|
2875
2633
|
}
|
|
2876
|
-
|
|
2877
|
-
|
|
2634
|
+
if (found) {
|
|
2635
|
+
answer = true;
|
|
2636
|
+
break;
|
|
2637
|
+
}
|
|
2638
|
+
if (dir === root) {
|
|
2639
|
+
answer = false;
|
|
2640
|
+
break;
|
|
2641
|
+
}
|
|
2878
2642
|
dir = dirname(dir);
|
|
2879
2643
|
}
|
|
2880
|
-
return false;
|
|
2644
|
+
if (answer === void 0) return false;
|
|
2645
|
+
for (const seen of visited) semanticTokenCache.set(seen, answer);
|
|
2646
|
+
return answer;
|
|
2881
2647
|
};
|
|
2882
2648
|
var propName = (key) => {
|
|
2883
2649
|
if (key.type === AST_NODE_TYPES9.Identifier) return key.name;
|
|
2884
2650
|
if (key.type === AST_NODE_TYPES9.Literal && typeof key.value === "string") return key.value;
|
|
2885
2651
|
return null;
|
|
2886
2652
|
};
|
|
2887
|
-
var prefer_semantic_colors_default =
|
|
2653
|
+
var prefer_semantic_colors_default = ESLintUtils15.RuleCreator(
|
|
2888
2654
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
2889
2655
|
)({
|
|
2890
2656
|
name: "prefer-semantic-colors",
|
|
@@ -3006,7 +2772,7 @@ var prefer_semantic_colors_default = ESLintUtils16.RuleCreator(
|
|
|
3006
2772
|
});
|
|
3007
2773
|
|
|
3008
2774
|
// src/rules/prefer-server-actions.ts
|
|
3009
|
-
import { ESLintUtils as
|
|
2775
|
+
import { ESLintUtils as ESLintUtils16 } from "@typescript-eslint/utils";
|
|
3010
2776
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
3011
2777
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
3012
2778
|
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\/)/;
|
|
@@ -3086,7 +2852,7 @@ function getPropertyNode(objNode, propName2) {
|
|
|
3086
2852
|
}
|
|
3087
2853
|
return null;
|
|
3088
2854
|
}
|
|
3089
|
-
var prefer_server_actions_default =
|
|
2855
|
+
var prefer_server_actions_default = ESLintUtils16.RuleCreator(
|
|
3090
2856
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3091
2857
|
)({
|
|
3092
2858
|
name: "prefer-server-actions",
|
|
@@ -3160,122 +2926,40 @@ var prefer_server_actions_default = ESLintUtils17.RuleCreator(
|
|
|
3160
2926
|
}
|
|
3161
2927
|
});
|
|
3162
2928
|
|
|
3163
|
-
// src/rules/prefer-shadcn.ts
|
|
3164
|
-
import {
|
|
3165
|
-
AST_NODE_TYPES as AST_NODE_TYPES10,
|
|
3166
|
-
ESLintUtils as ESLintUtils18
|
|
3167
|
-
} from "@typescript-eslint/utils";
|
|
3168
|
-
var REPLACEMENTS = {
|
|
3169
|
-
select: "Select",
|
|
3170
|
-
textarea: "Textarea",
|
|
3171
|
-
dialog: "Dialog"
|
|
3172
|
-
};
|
|
3173
|
-
var INPUT_TYPE_REPLACEMENTS = {
|
|
3174
|
-
checkbox: "Checkbox",
|
|
3175
|
-
radio: "RadioGroup",
|
|
3176
|
-
range: "Slider"
|
|
3177
|
-
};
|
|
3178
|
-
var SKIPPED_INPUT_TYPES = /* @__PURE__ */ new Set(["file", "hidden"]);
|
|
3179
|
-
var kebabCase = (component) => component.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3180
|
-
var literalTypeAttr = (node) => {
|
|
3181
|
-
for (const attribute of node.attributes) {
|
|
3182
|
-
if (attribute.type !== AST_NODE_TYPES10.JSXAttribute || attribute.name.type !== AST_NODE_TYPES10.JSXIdentifier || attribute.name.name !== "type") {
|
|
3183
|
-
continue;
|
|
3184
|
-
}
|
|
3185
|
-
if (attribute.value?.type === AST_NODE_TYPES10.Literal && typeof attribute.value.value === "string") {
|
|
3186
|
-
return { kind: "literal", value: attribute.value.value.toLowerCase() };
|
|
3187
|
-
}
|
|
3188
|
-
return { kind: "dynamic" };
|
|
3189
|
-
}
|
|
3190
|
-
return null;
|
|
3191
|
-
};
|
|
3192
|
-
var hasFileAcceptAttr = (node) => node.attributes.some(
|
|
3193
|
-
(attribute) => attribute.type === AST_NODE_TYPES10.JSXAttribute && attribute.name.type === AST_NODE_TYPES10.JSXIdentifier && attribute.name.name === "accept"
|
|
3194
|
-
);
|
|
3195
|
-
var resolveInputReplacement = (node) => {
|
|
3196
|
-
const typeAttr = literalTypeAttr(node);
|
|
3197
|
-
if (hasFileAcceptAttr(node)) return null;
|
|
3198
|
-
if (typeAttr === null || typeAttr.kind === "dynamic") return "Input";
|
|
3199
|
-
if (SKIPPED_INPUT_TYPES.has(typeAttr.value)) return null;
|
|
3200
|
-
return INPUT_TYPE_REPLACEMENTS[typeAttr.value] ?? "Input";
|
|
3201
|
-
};
|
|
3202
|
-
var prefer_shadcn_default = ESLintUtils18.RuleCreator(
|
|
3203
|
-
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3204
|
-
)({
|
|
3205
|
-
name: "prefer-shadcn",
|
|
3206
|
-
meta: {
|
|
3207
|
-
type: "suggestion",
|
|
3208
|
-
docs: {
|
|
3209
|
-
description: "Prefer shadcn/ui form primitives over native `<input>`, `<select>`, `<textarea>`, and `<dialog>` elements."
|
|
3210
|
-
},
|
|
3211
|
-
schema: [],
|
|
3212
|
-
messages: {
|
|
3213
|
-
preferShadcn: "Use the shadcn <{{replacement}}> component from @/components/ui/{{lowercase}} instead of native <{{element}}>."
|
|
3214
|
-
}
|
|
3215
|
-
},
|
|
3216
|
-
defaultOptions: [],
|
|
3217
|
-
create(context) {
|
|
3218
|
-
if (isTestFile(context.filename) || isStoryFile(context.filename)) {
|
|
3219
|
-
return {};
|
|
3220
|
-
}
|
|
3221
|
-
return {
|
|
3222
|
-
JSXOpeningElement(node) {
|
|
3223
|
-
if (node.name.type !== "JSXIdentifier") {
|
|
3224
|
-
return;
|
|
3225
|
-
}
|
|
3226
|
-
const elementName = node.name.name;
|
|
3227
|
-
const replacement = elementName === "input" ? resolveInputReplacement(node) : REPLACEMENTS[elementName];
|
|
3228
|
-
if (replacement === void 0 || replacement === null) {
|
|
3229
|
-
return;
|
|
3230
|
-
}
|
|
3231
|
-
context.report({
|
|
3232
|
-
node,
|
|
3233
|
-
messageId: "preferShadcn",
|
|
3234
|
-
data: {
|
|
3235
|
-
element: elementName,
|
|
3236
|
-
replacement,
|
|
3237
|
-
lowercase: kebabCase(replacement)
|
|
3238
|
-
}
|
|
3239
|
-
});
|
|
3240
|
-
}
|
|
3241
|
-
};
|
|
3242
|
-
}
|
|
3243
|
-
});
|
|
3244
|
-
|
|
3245
2929
|
// src/rules/require-assert-never.ts
|
|
3246
2930
|
import {
|
|
3247
|
-
ESLintUtils as
|
|
3248
|
-
AST_NODE_TYPES as
|
|
2931
|
+
ESLintUtils as ESLintUtils17,
|
|
2932
|
+
AST_NODE_TYPES as AST_NODE_TYPES10
|
|
3249
2933
|
} from "@typescript-eslint/utils";
|
|
3250
2934
|
var isAssertNeverCall = (expression) => {
|
|
3251
|
-
if (expression.type !==
|
|
2935
|
+
if (expression.type !== AST_NODE_TYPES10.CallExpression) return false;
|
|
3252
2936
|
const callee = expression.callee;
|
|
3253
|
-
if (callee.type ===
|
|
2937
|
+
if (callee.type === AST_NODE_TYPES10.Identifier) {
|
|
3254
2938
|
return callee.name === "assertNever";
|
|
3255
2939
|
}
|
|
3256
|
-
if (callee.type ===
|
|
2940
|
+
if (callee.type === AST_NODE_TYPES10.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES10.Identifier) {
|
|
3257
2941
|
return callee.property.name === "assertNever";
|
|
3258
2942
|
}
|
|
3259
2943
|
return false;
|
|
3260
2944
|
};
|
|
3261
2945
|
var statementContainsAssertNever = (statement) => {
|
|
3262
|
-
if (statement.type ===
|
|
2946
|
+
if (statement.type === AST_NODE_TYPES10.ExpressionStatement) {
|
|
3263
2947
|
return isAssertNeverCall(statement.expression);
|
|
3264
2948
|
}
|
|
3265
|
-
if (statement.type ===
|
|
2949
|
+
if (statement.type === AST_NODE_TYPES10.ThrowStatement) {
|
|
3266
2950
|
return isAssertNeverCall(statement.argument);
|
|
3267
2951
|
}
|
|
3268
|
-
if (statement.type ===
|
|
2952
|
+
if (statement.type === AST_NODE_TYPES10.ReturnStatement) {
|
|
3269
2953
|
return statement.argument !== null && isAssertNeverCall(statement.argument);
|
|
3270
2954
|
}
|
|
3271
|
-
if (statement.type ===
|
|
2955
|
+
if (statement.type === AST_NODE_TYPES10.BlockStatement) {
|
|
3272
2956
|
return statement.body.some(statementContainsAssertNever);
|
|
3273
2957
|
}
|
|
3274
2958
|
return false;
|
|
3275
2959
|
};
|
|
3276
2960
|
var isRuntimeHandlingStatement = (statement) => {
|
|
3277
|
-
if (statement.type ===
|
|
3278
|
-
if (statement.type ===
|
|
2961
|
+
if (statement.type === AST_NODE_TYPES10.EmptyStatement) return false;
|
|
2962
|
+
if (statement.type === AST_NODE_TYPES10.BlockStatement) {
|
|
3279
2963
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
3280
2964
|
}
|
|
3281
2965
|
return true;
|
|
@@ -3291,12 +2975,12 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
3291
2975
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
3292
2976
|
}
|
|
3293
2977
|
const only = defaultCase.consequent[0];
|
|
3294
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
2978
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES10.BlockStatement && only.body.length === 0) {
|
|
3295
2979
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
3296
2980
|
}
|
|
3297
2981
|
return false;
|
|
3298
2982
|
};
|
|
3299
|
-
var require_assert_never_default =
|
|
2983
|
+
var require_assert_never_default = ESLintUtils17.RuleCreator(
|
|
3300
2984
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3301
2985
|
)({
|
|
3302
2986
|
name: "require-assert-never",
|
|
@@ -3334,7 +3018,7 @@ var require_assert_never_default = ESLintUtils19.RuleCreator(
|
|
|
3334
3018
|
});
|
|
3335
3019
|
|
|
3336
3020
|
// src/rules/require-zod-form-validation.ts
|
|
3337
|
-
import { ESLintUtils as
|
|
3021
|
+
import { ESLintUtils as ESLintUtils18, AST_NODE_TYPES as AST_NODE_TYPES11 } from "@typescript-eslint/utils";
|
|
3338
3022
|
|
|
3339
3023
|
// src/rules/_zod.ts
|
|
3340
3024
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -3345,14 +3029,14 @@ var ZOD_SCHEMA_NAME_RE = /Schema$|^Z[A-Z]/;
|
|
|
3345
3029
|
var looksLikeZodSchema = (node) => {
|
|
3346
3030
|
let current = node;
|
|
3347
3031
|
while (true) {
|
|
3348
|
-
if (current.type ===
|
|
3032
|
+
if (current.type === AST_NODE_TYPES11.Identifier) {
|
|
3349
3033
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
3350
3034
|
}
|
|
3351
|
-
if (current.type ===
|
|
3035
|
+
if (current.type === AST_NODE_TYPES11.CallExpression) {
|
|
3352
3036
|
current = current.callee;
|
|
3353
3037
|
continue;
|
|
3354
3038
|
}
|
|
3355
|
-
if (current.type ===
|
|
3039
|
+
if (current.type === AST_NODE_TYPES11.MemberExpression) {
|
|
3356
3040
|
current = current.object;
|
|
3357
3041
|
continue;
|
|
3358
3042
|
}
|
|
@@ -3360,25 +3044,25 @@ var looksLikeZodSchema = (node) => {
|
|
|
3360
3044
|
}
|
|
3361
3045
|
};
|
|
3362
3046
|
var isZodParseCall = (node) => {
|
|
3363
|
-
if (node.type !==
|
|
3047
|
+
if (node.type !== AST_NODE_TYPES11.CallExpression) return false;
|
|
3364
3048
|
const callee = node.callee;
|
|
3365
|
-
if (callee.type !==
|
|
3049
|
+
if (callee.type !== AST_NODE_TYPES11.MemberExpression) return false;
|
|
3366
3050
|
if (callee.computed) return false;
|
|
3367
|
-
if (callee.property.type !==
|
|
3051
|
+
if (callee.property.type !== AST_NODE_TYPES11.Identifier) return false;
|
|
3368
3052
|
const method = callee.property.name;
|
|
3369
3053
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
3370
3054
|
return looksLikeZodSchema(callee.object);
|
|
3371
3055
|
};
|
|
3372
3056
|
var isFormDataMethodCall = (node) => {
|
|
3373
3057
|
let current = node;
|
|
3374
|
-
if (current.type ===
|
|
3058
|
+
if (current.type === AST_NODE_TYPES11.AwaitExpression) {
|
|
3375
3059
|
current = current.argument;
|
|
3376
3060
|
}
|
|
3377
|
-
if (current.type !==
|
|
3061
|
+
if (current.type !== AST_NODE_TYPES11.CallExpression) return false;
|
|
3378
3062
|
const callee = current.callee;
|
|
3379
|
-
return callee.type ===
|
|
3063
|
+
return callee.type === AST_NODE_TYPES11.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES11.Identifier && callee.property.name === "formData";
|
|
3380
3064
|
};
|
|
3381
|
-
var require_zod_form_validation_default =
|
|
3065
|
+
var require_zod_form_validation_default = ESLintUtils18.RuleCreator(
|
|
3382
3066
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3383
3067
|
)({
|
|
3384
3068
|
name: "require-zod-form-validation",
|
|
@@ -3398,14 +3082,14 @@ var require_zod_form_validation_default = ESLintUtils20.RuleCreator(
|
|
|
3398
3082
|
return {};
|
|
3399
3083
|
}
|
|
3400
3084
|
const isFormSourceIdentifier = (node) => {
|
|
3401
|
-
if (node.type !==
|
|
3085
|
+
if (node.type !== AST_NODE_TYPES11.Identifier) return false;
|
|
3402
3086
|
if (/formdata/i.test(node.name)) return true;
|
|
3403
3087
|
let scope = context.sourceCode.getScope(node);
|
|
3404
3088
|
while (scope !== null) {
|
|
3405
3089
|
const variable = scope.set.get(node.name);
|
|
3406
3090
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
3407
3091
|
const def = variable.defs[0];
|
|
3408
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
3092
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES11.VariableDeclarator && def.node.init !== null) {
|
|
3409
3093
|
return isFormDataMethodCall(def.node.init);
|
|
3410
3094
|
}
|
|
3411
3095
|
return false;
|
|
@@ -3416,8 +3100,8 @@ var require_zod_form_validation_default = ESLintUtils20.RuleCreator(
|
|
|
3416
3100
|
};
|
|
3417
3101
|
const isFormDataGetCall = (node) => {
|
|
3418
3102
|
const callee = node.callee;
|
|
3419
|
-
if (callee.type !==
|
|
3420
|
-
if (callee.property.type !==
|
|
3103
|
+
if (callee.type !== AST_NODE_TYPES11.MemberExpression) return false;
|
|
3104
|
+
if (callee.property.type !== AST_NODE_TYPES11.Identifier || callee.property.name !== "get") {
|
|
3421
3105
|
return false;
|
|
3422
3106
|
}
|
|
3423
3107
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -3432,11 +3116,11 @@ var require_zod_form_validation_default = ESLintUtils20.RuleCreator(
|
|
|
3432
3116
|
};
|
|
3433
3117
|
const isInstanceofNarrowing = (node) => {
|
|
3434
3118
|
const parent = node.parent;
|
|
3435
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
3119
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES11.BinaryExpression && parent.operator === "instanceof" && parent.left === node;
|
|
3436
3120
|
};
|
|
3437
3121
|
const boundDeclarator = (node) => {
|
|
3438
3122
|
const parent = node.parent;
|
|
3439
|
-
if (parent.type ===
|
|
3123
|
+
if (parent.type === AST_NODE_TYPES11.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES11.Identifier) {
|
|
3440
3124
|
return parent;
|
|
3441
3125
|
}
|
|
3442
3126
|
return null;
|
|
@@ -3464,7 +3148,7 @@ var require_zod_form_validation_default = ESLintUtils20.RuleCreator(
|
|
|
3464
3148
|
});
|
|
3465
3149
|
|
|
3466
3150
|
// src/rules/zod-naming-convention.ts
|
|
3467
|
-
import { ESLintUtils as
|
|
3151
|
+
import { ESLintUtils as ESLintUtils19, AST_NODE_TYPES as AST_NODE_TYPES12 } from "@typescript-eslint/utils";
|
|
3468
3152
|
var CONVENTIONS = {
|
|
3469
3153
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
3470
3154
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -3488,15 +3172,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
3488
3172
|
"registry",
|
|
3489
3173
|
"implement"
|
|
3490
3174
|
]);
|
|
3491
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
3175
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES12.Identifier ? callee.property.name : null;
|
|
3492
3176
|
var calleeChainStartsWithZ = (node) => {
|
|
3493
3177
|
let current = node;
|
|
3494
|
-
while (current.type ===
|
|
3178
|
+
while (current.type === AST_NODE_TYPES12.MemberExpression) {
|
|
3495
3179
|
const receiver = current.object;
|
|
3496
|
-
if (receiver.type ===
|
|
3180
|
+
if (receiver.type === AST_NODE_TYPES12.Identifier && receiver.name === "z") {
|
|
3497
3181
|
return true;
|
|
3498
3182
|
}
|
|
3499
|
-
if (receiver.type ===
|
|
3183
|
+
if (receiver.type === AST_NODE_TYPES12.CallExpression) {
|
|
3500
3184
|
current = receiver.callee;
|
|
3501
3185
|
continue;
|
|
3502
3186
|
}
|
|
@@ -3504,7 +3188,7 @@ var calleeChainStartsWithZ = (node) => {
|
|
|
3504
3188
|
}
|
|
3505
3189
|
return false;
|
|
3506
3190
|
};
|
|
3507
|
-
var zod_naming_convention_default =
|
|
3191
|
+
var zod_naming_convention_default = ESLintUtils19.RuleCreator(
|
|
3508
3192
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3509
3193
|
)({
|
|
3510
3194
|
name: "zod-naming-convention",
|
|
@@ -3543,13 +3227,13 @@ var zod_naming_convention_default = ESLintUtils21.RuleCreator(
|
|
|
3543
3227
|
VariableDeclarator(node) {
|
|
3544
3228
|
const init = node.init;
|
|
3545
3229
|
if (init === null || init === void 0) return;
|
|
3546
|
-
if (init.type !==
|
|
3230
|
+
if (init.type !== AST_NODE_TYPES12.CallExpression) return;
|
|
3547
3231
|
const callee = init.callee;
|
|
3548
|
-
if (callee.type !==
|
|
3232
|
+
if (callee.type !== AST_NODE_TYPES12.MemberExpression) return;
|
|
3549
3233
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
3550
3234
|
const terminal = terminalMethodName(callee);
|
|
3551
3235
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
3552
|
-
if (node.id.type !==
|
|
3236
|
+
if (node.id.type !== AST_NODE_TYPES12.Identifier) return;
|
|
3553
3237
|
if (test.test(node.id.name)) return;
|
|
3554
3238
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
3555
3239
|
context.report({
|
|
@@ -3562,7 +3246,7 @@ var zod_naming_convention_default = ESLintUtils21.RuleCreator(
|
|
|
3562
3246
|
});
|
|
3563
3247
|
|
|
3564
3248
|
// src/rules/no-cors-wildcard-with-credentials.ts
|
|
3565
|
-
import { ESLintUtils as
|
|
3249
|
+
import { ESLintUtils as ESLintUtils20 } from "@typescript-eslint/utils";
|
|
3566
3250
|
var ACAO_HEADER = "access-control-allow-origin";
|
|
3567
3251
|
var ACAC_HEADER = "access-control-allow-credentials";
|
|
3568
3252
|
var HEADER_SET_METHODS = /* @__PURE__ */ new Set(["setheader", "set", "append"]);
|
|
@@ -3594,17 +3278,17 @@ function subtreeContainsStarLiteral(node) {
|
|
|
3594
3278
|
const value = node[key];
|
|
3595
3279
|
if (Array.isArray(value)) {
|
|
3596
3280
|
for (const child of value) {
|
|
3597
|
-
if (
|
|
3281
|
+
if (isNode2(child) && subtreeContainsStarLiteral(child)) {
|
|
3598
3282
|
return true;
|
|
3599
3283
|
}
|
|
3600
3284
|
}
|
|
3601
|
-
} else if (
|
|
3285
|
+
} else if (isNode2(value) && subtreeContainsStarLiteral(value)) {
|
|
3602
3286
|
return true;
|
|
3603
3287
|
}
|
|
3604
3288
|
}
|
|
3605
3289
|
return false;
|
|
3606
3290
|
}
|
|
3607
|
-
function
|
|
3291
|
+
function isNode2(value) {
|
|
3608
3292
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
3609
3293
|
}
|
|
3610
3294
|
function propertyKeyName(prop) {
|
|
@@ -3620,7 +3304,7 @@ function propertyKeyName(prop) {
|
|
|
3620
3304
|
}
|
|
3621
3305
|
return void 0;
|
|
3622
3306
|
}
|
|
3623
|
-
function
|
|
3307
|
+
function calleeName2(node) {
|
|
3624
3308
|
const callee = node.callee;
|
|
3625
3309
|
if (callee.type === "Identifier") {
|
|
3626
3310
|
return callee.name;
|
|
@@ -3631,7 +3315,7 @@ function calleeName3(node) {
|
|
|
3631
3315
|
return void 0;
|
|
3632
3316
|
}
|
|
3633
3317
|
function isCorsWildcardCredentialsCall(node) {
|
|
3634
|
-
const name =
|
|
3318
|
+
const name = calleeName2(node);
|
|
3635
3319
|
if (name === void 0 || name.toLowerCase() !== "cors") {
|
|
3636
3320
|
return false;
|
|
3637
3321
|
}
|
|
@@ -3704,7 +3388,7 @@ function enclosingScope(node) {
|
|
|
3704
3388
|
}
|
|
3705
3389
|
return void 0;
|
|
3706
3390
|
}
|
|
3707
|
-
var no_cors_wildcard_with_credentials_default =
|
|
3391
|
+
var no_cors_wildcard_with_credentials_default = ESLintUtils20.RuleCreator(
|
|
3708
3392
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3709
3393
|
)({
|
|
3710
3394
|
name: "no-cors-wildcard-with-credentials",
|
|
@@ -3772,9 +3456,9 @@ var no_cors_wildcard_with_credentials_default = ESLintUtils22.RuleCreator(
|
|
|
3772
3456
|
});
|
|
3773
3457
|
|
|
3774
3458
|
// src/rules/no-silent-promise-catch.ts
|
|
3775
|
-
import { AST_NODE_TYPES as
|
|
3459
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES13, ESLintUtils as ESLintUtils21 } from "@typescript-eslint/utils";
|
|
3776
3460
|
function isBodyParseCall(node) {
|
|
3777
|
-
return node.type ===
|
|
3461
|
+
return node.type === AST_NODE_TYPES13.CallExpression && node.arguments.length === 0 && node.callee.type === AST_NODE_TYPES13.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES13.Identifier && (node.callee.property.name === "json" || node.callee.property.name === "text");
|
|
3778
3462
|
}
|
|
3779
3463
|
var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
3780
3464
|
"cancel",
|
|
@@ -3789,21 +3473,21 @@ var TEARDOWN_METHODS = /* @__PURE__ */ new Set([
|
|
|
3789
3473
|
var DIRECTIVE_COMMENT_RE = /^\s*(eslint-|@ts-|prettier-ignore|biome-ignore|c8 |v8 |istanbul )/;
|
|
3790
3474
|
var isExplanatory = (comment) => !DIRECTIVE_COMMENT_RE.test(comment.value);
|
|
3791
3475
|
function isTeardownCall(node) {
|
|
3792
|
-
return node.type ===
|
|
3476
|
+
return node.type === AST_NODE_TYPES13.CallExpression && node.callee.type === AST_NODE_TYPES13.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES13.Identifier && TEARDOWN_METHODS.has(node.callee.property.name);
|
|
3793
3477
|
}
|
|
3794
3478
|
function isSilentExpression(node) {
|
|
3795
3479
|
switch (node.type) {
|
|
3796
|
-
case
|
|
3480
|
+
case AST_NODE_TYPES13.Literal:
|
|
3797
3481
|
return !("regex" in node);
|
|
3798
|
-
case
|
|
3482
|
+
case AST_NODE_TYPES13.Identifier:
|
|
3799
3483
|
return node.name === "undefined";
|
|
3800
|
-
case
|
|
3801
|
-
return node.operator === "void" && node.argument.type ===
|
|
3802
|
-
case
|
|
3484
|
+
case AST_NODE_TYPES13.UnaryExpression:
|
|
3485
|
+
return node.operator === "void" && node.argument.type === AST_NODE_TYPES13.Literal;
|
|
3486
|
+
case AST_NODE_TYPES13.ObjectExpression:
|
|
3803
3487
|
return node.properties.length === 0;
|
|
3804
|
-
case
|
|
3488
|
+
case AST_NODE_TYPES13.ArrayExpression:
|
|
3805
3489
|
return node.elements.length === 0;
|
|
3806
|
-
case
|
|
3490
|
+
case AST_NODE_TYPES13.TSAsExpression:
|
|
3807
3491
|
return isSilentExpression(node.expression);
|
|
3808
3492
|
default:
|
|
3809
3493
|
return false;
|
|
@@ -3811,7 +3495,7 @@ function isSilentExpression(node) {
|
|
|
3811
3495
|
}
|
|
3812
3496
|
function isSilentHandler(handler) {
|
|
3813
3497
|
const body = handler.body;
|
|
3814
|
-
if (body.type !==
|
|
3498
|
+
if (body.type !== AST_NODE_TYPES13.BlockStatement) {
|
|
3815
3499
|
return isSilentExpression(body);
|
|
3816
3500
|
}
|
|
3817
3501
|
if (body.body.length === 0) {
|
|
@@ -3819,13 +3503,13 @@ function isSilentHandler(handler) {
|
|
|
3819
3503
|
}
|
|
3820
3504
|
if (body.body.length === 1) {
|
|
3821
3505
|
const only = body.body[0];
|
|
3822
|
-
if (only !== void 0 && only.type ===
|
|
3506
|
+
if (only !== void 0 && only.type === AST_NODE_TYPES13.ReturnStatement) {
|
|
3823
3507
|
return only.argument === null || isSilentExpression(only.argument);
|
|
3824
3508
|
}
|
|
3825
3509
|
}
|
|
3826
3510
|
return false;
|
|
3827
3511
|
}
|
|
3828
|
-
var no_silent_promise_catch_default =
|
|
3512
|
+
var no_silent_promise_catch_default = ESLintUtils21.RuleCreator(
|
|
3829
3513
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3830
3514
|
)({
|
|
3831
3515
|
name: "no-silent-promise-catch",
|
|
@@ -3850,7 +3534,7 @@ var no_silent_promise_catch_default = ESLintUtils23.RuleCreator(
|
|
|
3850
3534
|
return true;
|
|
3851
3535
|
}
|
|
3852
3536
|
let statement = call;
|
|
3853
|
-
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !==
|
|
3537
|
+
while (statement.parent !== void 0 && statement.parent !== null && !statement.type.endsWith("Statement") && statement.type !== AST_NODE_TYPES13.VariableDeclaration) {
|
|
3854
3538
|
statement = statement.parent;
|
|
3855
3539
|
}
|
|
3856
3540
|
if (sourceCode.getCommentsBefore(statement).some(isExplanatory)) {
|
|
@@ -3862,7 +3546,7 @@ var no_silent_promise_catch_default = ESLintUtils23.RuleCreator(
|
|
|
3862
3546
|
};
|
|
3863
3547
|
return {
|
|
3864
3548
|
CallExpression(node) {
|
|
3865
|
-
if (node.callee.type !==
|
|
3549
|
+
if (node.callee.type !== AST_NODE_TYPES13.MemberExpression || node.callee.computed || node.callee.property.type !== AST_NODE_TYPES13.Identifier || node.callee.property.name !== "catch") {
|
|
3866
3550
|
return;
|
|
3867
3551
|
}
|
|
3868
3552
|
if (isBodyParseCall(node.callee.object)) {
|
|
@@ -3871,14 +3555,14 @@ var no_silent_promise_catch_default = ESLintUtils23.RuleCreator(
|
|
|
3871
3555
|
if (isTeardownCall(node.callee.object)) {
|
|
3872
3556
|
return;
|
|
3873
3557
|
}
|
|
3874
|
-
if (node.parent.type ===
|
|
3558
|
+
if (node.parent.type === AST_NODE_TYPES13.MemberExpression && node.parent.object === node) {
|
|
3875
3559
|
return;
|
|
3876
3560
|
}
|
|
3877
3561
|
if (node.arguments.length !== 1) {
|
|
3878
3562
|
return;
|
|
3879
3563
|
}
|
|
3880
3564
|
const handler = node.arguments[0];
|
|
3881
|
-
if (handler === void 0 || handler.type !==
|
|
3565
|
+
if (handler === void 0 || handler.type !== AST_NODE_TYPES13.ArrowFunctionExpression && handler.type !== AST_NODE_TYPES13.FunctionExpression) {
|
|
3882
3566
|
return;
|
|
3883
3567
|
}
|
|
3884
3568
|
if (hasExplanatoryComment(node, handler)) {
|
|
@@ -3894,9 +3578,9 @@ var no_silent_promise_catch_default = ESLintUtils23.RuleCreator(
|
|
|
3894
3578
|
|
|
3895
3579
|
// src/rules/require-fetch-timeout.ts
|
|
3896
3580
|
import {
|
|
3897
|
-
AST_NODE_TYPES as
|
|
3581
|
+
AST_NODE_TYPES as AST_NODE_TYPES14,
|
|
3898
3582
|
ASTUtils,
|
|
3899
|
-
ESLintUtils as
|
|
3583
|
+
ESLintUtils as ESLintUtils22
|
|
3900
3584
|
} from "@typescript-eslint/utils";
|
|
3901
3585
|
var CODEMOD_FIXTURE_RE = /[\\/]__testfixtures__[\\/]/;
|
|
3902
3586
|
var GLOBAL_OBJECTS = /* @__PURE__ */ new Set([
|
|
@@ -3914,14 +3598,14 @@ function matchesAnyPattern2(filename, patterns) {
|
|
|
3914
3598
|
return false;
|
|
3915
3599
|
}
|
|
3916
3600
|
function initProvablyLacksSignal(init) {
|
|
3917
|
-
if (init.type !==
|
|
3601
|
+
if (init.type !== AST_NODE_TYPES14.ObjectExpression) {
|
|
3918
3602
|
return false;
|
|
3919
3603
|
}
|
|
3920
3604
|
for (const prop of init.properties) {
|
|
3921
|
-
if (prop.type ===
|
|
3605
|
+
if (prop.type === AST_NODE_TYPES14.SpreadElement) {
|
|
3922
3606
|
return false;
|
|
3923
3607
|
}
|
|
3924
|
-
if (prop.key.type ===
|
|
3608
|
+
if (prop.key.type === AST_NODE_TYPES14.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES14.Literal && prop.key.value === "signal") {
|
|
3925
3609
|
return false;
|
|
3926
3610
|
}
|
|
3927
3611
|
if (prop.computed) {
|
|
@@ -3931,9 +3615,9 @@ function initProvablyLacksSignal(init) {
|
|
|
3931
3615
|
return true;
|
|
3932
3616
|
}
|
|
3933
3617
|
function isStringish(node) {
|
|
3934
|
-
return node.type ===
|
|
3618
|
+
return node.type === AST_NODE_TYPES14.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES14.TemplateLiteral;
|
|
3935
3619
|
}
|
|
3936
|
-
var require_fetch_timeout_default =
|
|
3620
|
+
var require_fetch_timeout_default = ESLintUtils22.RuleCreator(
|
|
3937
3621
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
3938
3622
|
)({
|
|
3939
3623
|
name: "require-fetch-timeout",
|
|
@@ -3974,10 +3658,10 @@ var require_fetch_timeout_default = ESLintUtils24.RuleCreator(
|
|
|
3974
3658
|
return variable === null || variable.defs.length === 0;
|
|
3975
3659
|
}
|
|
3976
3660
|
function isGlobalFetchCall2(callee) {
|
|
3977
|
-
if (callee.type ===
|
|
3661
|
+
if (callee.type === AST_NODE_TYPES14.Identifier) {
|
|
3978
3662
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
3979
3663
|
}
|
|
3980
|
-
return callee.type ===
|
|
3664
|
+
return callee.type === AST_NODE_TYPES14.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES14.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES14.Identifier && GLOBAL_OBJECTS.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
3981
3665
|
}
|
|
3982
3666
|
return {
|
|
3983
3667
|
CallExpression(node) {
|
|
@@ -3996,103 +3680,16 @@ var require_fetch_timeout_default = ESLintUtils24.RuleCreator(
|
|
|
3996
3680
|
}
|
|
3997
3681
|
});
|
|
3998
3682
|
|
|
3999
|
-
// src/rules/require-schema-validate-search.ts
|
|
4000
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES16, ESLintUtils as ESLintUtils25 } from "@typescript-eslint/utils";
|
|
4001
|
-
var VALIDATOR_METHODS = /* @__PURE__ */ new Set([
|
|
4002
|
-
"parse",
|
|
4003
|
-
"safeParse",
|
|
4004
|
-
"decode"
|
|
4005
|
-
]);
|
|
4006
|
-
function isConstTypeAnnotation(typeAnnotation) {
|
|
4007
|
-
return typeAnnotation.type === AST_NODE_TYPES16.TSTypeReference && typeAnnotation.typeName.type === AST_NODE_TYPES16.Identifier && typeAnnotation.typeName.name === "const";
|
|
4008
|
-
}
|
|
4009
|
-
function isValidatorCall(node) {
|
|
4010
|
-
return node.callee.type === AST_NODE_TYPES16.MemberExpression && !node.callee.computed && node.callee.property.type === AST_NODE_TYPES16.Identifier && VALIDATOR_METHODS.has(node.callee.property.name);
|
|
4011
|
-
}
|
|
4012
|
-
function findCastExpression(node, insideValidatorArg) {
|
|
4013
|
-
if ((node.type === AST_NODE_TYPES16.TSAsExpression || node.type === AST_NODE_TYPES16.TSTypeAssertion) && !isConstTypeAnnotation(node.typeAnnotation) && !insideValidatorArg) {
|
|
4014
|
-
return node;
|
|
4015
|
-
}
|
|
4016
|
-
if (node.type === AST_NODE_TYPES16.CallExpression && isValidatorCall(node)) {
|
|
4017
|
-
const inCallee = findCastExpression(node.callee, insideValidatorArg);
|
|
4018
|
-
if (inCallee !== null) {
|
|
4019
|
-
return inCallee;
|
|
4020
|
-
}
|
|
4021
|
-
for (const arg of node.arguments) {
|
|
4022
|
-
const found = findCastExpression(arg, true);
|
|
4023
|
-
if (found !== null) {
|
|
4024
|
-
return found;
|
|
4025
|
-
}
|
|
4026
|
-
}
|
|
4027
|
-
return null;
|
|
4028
|
-
}
|
|
4029
|
-
for (const key of Object.keys(node)) {
|
|
4030
|
-
if (key === "parent") {
|
|
4031
|
-
continue;
|
|
4032
|
-
}
|
|
4033
|
-
const value = node[key];
|
|
4034
|
-
const children = Array.isArray(value) ? value : [value];
|
|
4035
|
-
for (const child of children) {
|
|
4036
|
-
if (child !== null && typeof child === "object" && "type" in child && typeof child.type === "string") {
|
|
4037
|
-
const found = findCastExpression(
|
|
4038
|
-
child,
|
|
4039
|
-
insideValidatorArg
|
|
4040
|
-
);
|
|
4041
|
-
if (found !== null) {
|
|
4042
|
-
return found;
|
|
4043
|
-
}
|
|
4044
|
-
}
|
|
4045
|
-
}
|
|
4046
|
-
}
|
|
4047
|
-
return null;
|
|
4048
|
-
}
|
|
4049
|
-
var require_schema_validate_search_default = ESLintUtils25.RuleCreator(
|
|
4050
|
-
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4051
|
-
)({
|
|
4052
|
-
name: "require-schema-validate-search",
|
|
4053
|
-
meta: {
|
|
4054
|
-
type: "problem",
|
|
4055
|
-
docs: {
|
|
4056
|
-
description: "Disallow `as` casts inside hand-rolled `validateSearch` functions; use a schema validator (e.g. zodValidator) so search params are validated at runtime."
|
|
4057
|
-
},
|
|
4058
|
-
schema: [],
|
|
4059
|
-
messages: {
|
|
4060
|
-
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."
|
|
4061
|
-
}
|
|
4062
|
-
},
|
|
4063
|
-
defaultOptions: [],
|
|
4064
|
-
create(context) {
|
|
4065
|
-
if (isTestFile(context.filename)) {
|
|
4066
|
-
return {};
|
|
4067
|
-
}
|
|
4068
|
-
return {
|
|
4069
|
-
Property(node) {
|
|
4070
|
-
const isValidateSearchKey = !node.computed && node.key.type === AST_NODE_TYPES16.Identifier && node.key.name === "validateSearch" || node.key.type === AST_NODE_TYPES16.Literal && node.key.value === "validateSearch";
|
|
4071
|
-
if (!isValidateSearchKey) {
|
|
4072
|
-
return;
|
|
4073
|
-
}
|
|
4074
|
-
if (node.value.type !== AST_NODE_TYPES16.ArrowFunctionExpression && node.value.type !== AST_NODE_TYPES16.FunctionExpression) {
|
|
4075
|
-
return;
|
|
4076
|
-
}
|
|
4077
|
-
const cast = findCastExpression(node.value.body, false);
|
|
4078
|
-
if (cast !== null) {
|
|
4079
|
-
context.report({ node: cast, messageId: "castInValidateSearch" });
|
|
4080
|
-
}
|
|
4081
|
-
}
|
|
4082
|
-
};
|
|
4083
|
-
}
|
|
4084
|
-
});
|
|
4085
|
-
|
|
4086
3683
|
// src/rules/no-fat-try-blocks.ts
|
|
4087
3684
|
import {
|
|
4088
|
-
ESLintUtils as
|
|
4089
|
-
AST_NODE_TYPES as
|
|
3685
|
+
ESLintUtils as ESLintUtils23,
|
|
3686
|
+
AST_NODE_TYPES as AST_NODE_TYPES15
|
|
4090
3687
|
} from "@typescript-eslint/utils";
|
|
4091
3688
|
var MAX_TRY_BODY_STATEMENTS = 3;
|
|
4092
3689
|
var NESTED_FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
3690
|
+
AST_NODE_TYPES15.FunctionDeclaration,
|
|
3691
|
+
AST_NODE_TYPES15.FunctionExpression,
|
|
3692
|
+
AST_NODE_TYPES15.ArrowFunctionExpression
|
|
4096
3693
|
]);
|
|
4097
3694
|
var PURE_METHODS = /* @__PURE__ */ new Set([
|
|
4098
3695
|
"map",
|
|
@@ -4185,25 +3782,25 @@ var PURE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4185
3782
|
"Response",
|
|
4186
3783
|
"AbortController"
|
|
4187
3784
|
]);
|
|
4188
|
-
function
|
|
3785
|
+
function isNode3(value) {
|
|
4189
3786
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
4190
3787
|
}
|
|
4191
3788
|
function isPureCall(node) {
|
|
4192
3789
|
const callee = node.callee;
|
|
4193
|
-
if (callee.type !==
|
|
3790
|
+
if (callee.type !== AST_NODE_TYPES15.MemberExpression) {
|
|
4194
3791
|
return false;
|
|
4195
3792
|
}
|
|
4196
3793
|
const property = callee.property;
|
|
4197
|
-
if (property.type !==
|
|
3794
|
+
if (property.type !== AST_NODE_TYPES15.Identifier) {
|
|
4198
3795
|
return false;
|
|
4199
3796
|
}
|
|
4200
|
-
if (callee.object.type ===
|
|
3797
|
+
if (callee.object.type === AST_NODE_TYPES15.Identifier && PURE_NAMESPACES.has(callee.object.name)) {
|
|
4201
3798
|
return true;
|
|
4202
3799
|
}
|
|
4203
3800
|
return PURE_METHODS.has(property.name);
|
|
4204
3801
|
}
|
|
4205
3802
|
function isPureNew(node) {
|
|
4206
|
-
return node.callee.type ===
|
|
3803
|
+
return node.callee.type === AST_NODE_TYPES15.Identifier && PURE_CONSTRUCTORS.has(node.callee.name);
|
|
4207
3804
|
}
|
|
4208
3805
|
function subtreeMatches(stmt, predicate) {
|
|
4209
3806
|
let found = false;
|
|
@@ -4225,11 +3822,11 @@ function subtreeMatches(stmt, predicate) {
|
|
|
4225
3822
|
const value = current[key];
|
|
4226
3823
|
if (Array.isArray(value)) {
|
|
4227
3824
|
for (const child of value) {
|
|
4228
|
-
if (
|
|
3825
|
+
if (isNode3(child)) {
|
|
4229
3826
|
visit(child);
|
|
4230
3827
|
}
|
|
4231
3828
|
}
|
|
4232
|
-
} else if (
|
|
3829
|
+
} else if (isNode3(value)) {
|
|
4233
3830
|
visit(value);
|
|
4234
3831
|
}
|
|
4235
3832
|
if (found) {
|
|
@@ -4240,20 +3837,20 @@ function subtreeMatches(stmt, predicate) {
|
|
|
4240
3837
|
visit(stmt);
|
|
4241
3838
|
return found;
|
|
4242
3839
|
}
|
|
4243
|
-
var hasAwait = (node) => subtreeMatches(node, (n) => n.type ===
|
|
3840
|
+
var hasAwait = (node) => subtreeMatches(node, (n) => n.type === AST_NODE_TYPES15.AwaitExpression);
|
|
4244
3841
|
var hasThrowingCallOrNew = (node) => subtreeMatches(
|
|
4245
3842
|
node,
|
|
4246
|
-
(n) => n.type ===
|
|
3843
|
+
(n) => n.type === AST_NODE_TYPES15.CallExpression && !isPureCall(n) || n.type === AST_NODE_TYPES15.NewExpression && !isPureNew(n)
|
|
4247
3844
|
);
|
|
4248
3845
|
function unwrap2(expr) {
|
|
4249
3846
|
let current = expr;
|
|
4250
|
-
while (current.type ===
|
|
3847
|
+
while (current.type === AST_NODE_TYPES15.ChainExpression || current.type === AST_NODE_TYPES15.TSNonNullExpression) {
|
|
4251
3848
|
current = current.expression;
|
|
4252
3849
|
}
|
|
4253
3850
|
return current;
|
|
4254
3851
|
}
|
|
4255
3852
|
function isBareCallStatement(stmt) {
|
|
4256
|
-
return stmt.type ===
|
|
3853
|
+
return stmt.type === AST_NODE_TYPES15.ExpressionStatement && unwrap2(stmt.expression).type === AST_NODE_TYPES15.CallExpression;
|
|
4257
3854
|
}
|
|
4258
3855
|
function canThrow(stmt) {
|
|
4259
3856
|
if (hasAwait(stmt)) {
|
|
@@ -4262,10 +3859,10 @@ function canThrow(stmt) {
|
|
|
4262
3859
|
if (isBareCallStatement(stmt)) {
|
|
4263
3860
|
return false;
|
|
4264
3861
|
}
|
|
4265
|
-
if (stmt.type ===
|
|
3862
|
+
if (stmt.type === AST_NODE_TYPES15.BlockStatement) {
|
|
4266
3863
|
return stmt.body.some(canThrow);
|
|
4267
3864
|
}
|
|
4268
|
-
if (stmt.type ===
|
|
3865
|
+
if (stmt.type === AST_NODE_TYPES15.IfStatement) {
|
|
4269
3866
|
return hasThrowingCallOrNew(stmt.test) || canThrow(stmt.consequent) || stmt.alternate !== null && canThrow(stmt.alternate);
|
|
4270
3867
|
}
|
|
4271
3868
|
return hasThrowingCallOrNew(stmt);
|
|
@@ -4276,9 +3873,9 @@ function handlerRethrows(handler) {
|
|
|
4276
3873
|
}
|
|
4277
3874
|
const body = handler.body.body;
|
|
4278
3875
|
const last = body[body.length - 1];
|
|
4279
|
-
return last !== void 0 && last.type ===
|
|
3876
|
+
return last !== void 0 && last.type === AST_NODE_TYPES15.ThrowStatement;
|
|
4280
3877
|
}
|
|
4281
|
-
var no_fat_try_blocks_default =
|
|
3878
|
+
var no_fat_try_blocks_default = ESLintUtils23.RuleCreator(
|
|
4282
3879
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4283
3880
|
)({
|
|
4284
3881
|
name: "no-fat-try-blocks",
|
|
@@ -4322,7 +3919,7 @@ var no_fat_try_blocks_default = ESLintUtils26.RuleCreator(
|
|
|
4322
3919
|
});
|
|
4323
3920
|
|
|
4324
3921
|
// src/rules/no-secret-in-log.ts
|
|
4325
|
-
import { ESLintUtils as
|
|
3922
|
+
import { ESLintUtils as ESLintUtils24 } from "@typescript-eslint/utils";
|
|
4326
3923
|
|
|
4327
3924
|
// src/rules/_secret_names.ts
|
|
4328
3925
|
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -4584,7 +4181,7 @@ function propertyKeyName2(prop) {
|
|
|
4584
4181
|
}
|
|
4585
4182
|
return null;
|
|
4586
4183
|
}
|
|
4587
|
-
var no_secret_in_log_default =
|
|
4184
|
+
var no_secret_in_log_default = ESLintUtils24.RuleCreator(
|
|
4588
4185
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4589
4186
|
)({
|
|
4590
4187
|
name: "no-secret-in-log",
|
|
@@ -4660,74 +4257,25 @@ var no_secret_in_log_default = ESLintUtils27.RuleCreator(
|
|
|
4660
4257
|
}
|
|
4661
4258
|
});
|
|
4662
4259
|
|
|
4663
|
-
// src/rules/no-unsafe-cast.ts
|
|
4664
|
-
import { ESLintUtils as ESLintUtils28 } from "@typescript-eslint/utils";
|
|
4665
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES18 } from "@typescript-eslint/utils";
|
|
4666
|
-
function isAnyAnnotation(node) {
|
|
4667
|
-
return node.type === AST_NODE_TYPES18.TSAnyKeyword;
|
|
4668
|
-
}
|
|
4669
|
-
function isConstAssertion(typeAnnotation) {
|
|
4670
|
-
return typeAnnotation.type === AST_NODE_TYPES18.TSTypeReference && typeAnnotation.typeName.type === AST_NODE_TYPES18.Identifier && typeAnnotation.typeName.name === "const";
|
|
4671
|
-
}
|
|
4672
|
-
var no_unsafe_cast_default = ESLintUtils28.RuleCreator(
|
|
4673
|
-
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4674
|
-
)({
|
|
4675
|
-
name: "no-unsafe-cast",
|
|
4676
|
-
meta: {
|
|
4677
|
-
type: "problem",
|
|
4678
|
-
docs: {
|
|
4679
|
-
description: "Disallow `as any`/`<any>` casts and `as unknown as T` double-casts, which fully disable type checking."
|
|
4680
|
-
},
|
|
4681
|
-
schema: [],
|
|
4682
|
-
messages: {
|
|
4683
|
-
asAny: "`as any` disables type checking on this value. Narrow with a type guard, model the shape, or cast to a specific type instead.",
|
|
4684
|
-
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."
|
|
4685
|
-
}
|
|
4686
|
-
},
|
|
4687
|
-
defaultOptions: [],
|
|
4688
|
-
create(context) {
|
|
4689
|
-
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
4690
|
-
return {};
|
|
4691
|
-
}
|
|
4692
|
-
function checkAssertion(node) {
|
|
4693
|
-
if (isConstAssertion(node.typeAnnotation)) {
|
|
4694
|
-
return;
|
|
4695
|
-
}
|
|
4696
|
-
if (isAnyAnnotation(node.typeAnnotation)) {
|
|
4697
|
-
context.report({ node, messageId: "asAny" });
|
|
4698
|
-
return;
|
|
4699
|
-
}
|
|
4700
|
-
const inner = node.expression;
|
|
4701
|
-
if (inner.type === AST_NODE_TYPES18.TSAsExpression || inner.type === AST_NODE_TYPES18.TSTypeAssertion) {
|
|
4702
|
-
context.report({ node, messageId: "doubleCast" });
|
|
4703
|
-
}
|
|
4704
|
-
}
|
|
4705
|
-
return {
|
|
4706
|
-
TSAsExpression: checkAssertion,
|
|
4707
|
-
TSTypeAssertion: checkAssertion
|
|
4708
|
-
};
|
|
4709
|
-
}
|
|
4710
|
-
});
|
|
4711
|
-
|
|
4712
4260
|
// src/rules/no-unsafe-mock-casting.ts
|
|
4713
|
-
import { ESLintUtils as
|
|
4714
|
-
import { AST_NODE_TYPES as
|
|
4261
|
+
import { ESLintUtils as ESLintUtils25 } from "@typescript-eslint/utils";
|
|
4262
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES16 } from "@typescript-eslint/utils";
|
|
4715
4263
|
function isMockTypeReference(node) {
|
|
4716
|
-
if (node.type !==
|
|
4264
|
+
if (node.type !== AST_NODE_TYPES16.TSTypeReference) {
|
|
4717
4265
|
return false;
|
|
4718
4266
|
}
|
|
4719
4267
|
const typeName = node.typeName;
|
|
4720
|
-
if (typeName.type ===
|
|
4268
|
+
if (typeName.type === AST_NODE_TYPES16.Identifier) {
|
|
4721
4269
|
const name = typeName.name;
|
|
4722
4270
|
return name === "Mock" || name === "MockInstance" || name === "SpyInstance";
|
|
4723
4271
|
}
|
|
4724
|
-
if (typeName.type ===
|
|
4272
|
+
if (typeName.type === AST_NODE_TYPES16.TSQualifiedName) {
|
|
4725
4273
|
const rightName = typeName.right.name;
|
|
4726
4274
|
return rightName === "Mock" || rightName === "MockInstance" || rightName === "SpyInstance";
|
|
4727
4275
|
}
|
|
4728
4276
|
return false;
|
|
4729
4277
|
}
|
|
4730
|
-
var no_unsafe_mock_casting_default =
|
|
4278
|
+
var no_unsafe_mock_casting_default = ESLintUtils25.RuleCreator(
|
|
4731
4279
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4732
4280
|
)({
|
|
4733
4281
|
name: "no-unsafe-mock-casting",
|
|
@@ -4760,8 +4308,8 @@ var no_unsafe_mock_casting_default = ESLintUtils29.RuleCreator(
|
|
|
4760
4308
|
|
|
4761
4309
|
// src/rules/prefer-string-literal-union.ts
|
|
4762
4310
|
import {
|
|
4763
|
-
ESLintUtils as
|
|
4764
|
-
AST_NODE_TYPES as
|
|
4311
|
+
ESLintUtils as ESLintUtils26,
|
|
4312
|
+
AST_NODE_TYPES as AST_NODE_TYPES17
|
|
4765
4313
|
} from "@typescript-eslint/utils";
|
|
4766
4314
|
import * as ts from "typescript";
|
|
4767
4315
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -4805,19 +4353,19 @@ function isChoiceLikeName(name) {
|
|
|
4805
4353
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
4806
4354
|
}
|
|
4807
4355
|
function keyName(key) {
|
|
4808
|
-
if (key.type ===
|
|
4356
|
+
if (key.type === AST_NODE_TYPES17.Identifier) {
|
|
4809
4357
|
return key.name;
|
|
4810
4358
|
}
|
|
4811
|
-
if (key.type ===
|
|
4359
|
+
if (key.type === AST_NODE_TYPES17.Literal && typeof key.value === "string") {
|
|
4812
4360
|
return key.value;
|
|
4813
4361
|
}
|
|
4814
4362
|
return null;
|
|
4815
4363
|
}
|
|
4816
4364
|
function isStringLiteralMember(t) {
|
|
4817
|
-
return t.type ===
|
|
4365
|
+
return t.type === AST_NODE_TYPES17.TSLiteralType && t.literal.type === AST_NODE_TYPES17.Literal && typeof t.literal.value === "string";
|
|
4818
4366
|
}
|
|
4819
4367
|
function isStringLiteralUnion(node) {
|
|
4820
|
-
if (node?.type !==
|
|
4368
|
+
if (node?.type !== AST_NODE_TYPES17.TSUnionType) {
|
|
4821
4369
|
return false;
|
|
4822
4370
|
}
|
|
4823
4371
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -4846,12 +4394,12 @@ function bindingSourceExpression(decl) {
|
|
|
4846
4394
|
return ts.isForOfStatement(node) ? node.expression : node.initializer;
|
|
4847
4395
|
}
|
|
4848
4396
|
function refKey(node) {
|
|
4849
|
-
if (node.type ===
|
|
4397
|
+
if (node.type === AST_NODE_TYPES17.Identifier) {
|
|
4850
4398
|
return node.name;
|
|
4851
4399
|
}
|
|
4852
|
-
if (node.type ===
|
|
4400
|
+
if (node.type === AST_NODE_TYPES17.MemberExpression && !node.computed) {
|
|
4853
4401
|
const inner = refKey(node.object);
|
|
4854
|
-
if (inner === null || node.property.type !==
|
|
4402
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES17.Identifier) {
|
|
4855
4403
|
return null;
|
|
4856
4404
|
}
|
|
4857
4405
|
return `${inner}.${node.property.name}`;
|
|
@@ -4859,12 +4407,12 @@ function refKey(node) {
|
|
|
4859
4407
|
return null;
|
|
4860
4408
|
}
|
|
4861
4409
|
function strLiteral(node) {
|
|
4862
|
-
if (node.type ===
|
|
4410
|
+
if (node.type === AST_NODE_TYPES17.Literal && typeof node.value === "string") {
|
|
4863
4411
|
return node.value;
|
|
4864
4412
|
}
|
|
4865
4413
|
return null;
|
|
4866
4414
|
}
|
|
4867
|
-
var prefer_string_literal_union_default =
|
|
4415
|
+
var prefer_string_literal_union_default = ESLintUtils26.RuleCreator(
|
|
4868
4416
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
4869
4417
|
)({
|
|
4870
4418
|
name: "prefer-string-literal-union",
|
|
@@ -4902,7 +4450,7 @@ var prefer_string_literal_union_default = ESLintUtils30.RuleCreator(
|
|
|
4902
4450
|
);
|
|
4903
4451
|
let services;
|
|
4904
4452
|
try {
|
|
4905
|
-
services =
|
|
4453
|
+
services = ESLintUtils26.getParserServices(context);
|
|
4906
4454
|
} catch {
|
|
4907
4455
|
services = null;
|
|
4908
4456
|
}
|
|
@@ -5014,7 +4562,7 @@ var prefer_string_literal_union_default = ESLintUtils30.RuleCreator(
|
|
|
5014
4562
|
containersWithUnion.add(container);
|
|
5015
4563
|
return;
|
|
5016
4564
|
}
|
|
5017
|
-
if (typeNode?.type !==
|
|
4565
|
+
if (typeNode?.type !== AST_NODE_TYPES17.TSStringKeyword) {
|
|
5018
4566
|
return;
|
|
5019
4567
|
}
|
|
5020
4568
|
const name = keyName(key);
|
|
@@ -5102,10 +4650,10 @@ var prefer_string_literal_union_default = ESLintUtils30.RuleCreator(
|
|
|
5102
4650
|
}
|
|
5103
4651
|
};
|
|
5104
4652
|
function refKeyText(node) {
|
|
5105
|
-
if (node.type ===
|
|
4653
|
+
if (node.type === AST_NODE_TYPES17.BinaryExpression) {
|
|
5106
4654
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
5107
4655
|
}
|
|
5108
|
-
if (node.type ===
|
|
4656
|
+
if (node.type === AST_NODE_TYPES17.SwitchStatement) {
|
|
5109
4657
|
return refKey(node.discriminant) ?? "value";
|
|
5110
4658
|
}
|
|
5111
4659
|
return "value";
|
|
@@ -5115,13 +4663,13 @@ var prefer_string_literal_union_default = ESLintUtils30.RuleCreator(
|
|
|
5115
4663
|
|
|
5116
4664
|
// src/rules/prefer-zod-enum.ts
|
|
5117
4665
|
import {
|
|
5118
|
-
AST_NODE_TYPES as
|
|
5119
|
-
ESLintUtils as
|
|
4666
|
+
AST_NODE_TYPES as AST_NODE_TYPES18,
|
|
4667
|
+
ESLintUtils as ESLintUtils27
|
|
5120
4668
|
} from "@typescript-eslint/utils";
|
|
5121
4669
|
function isZodModule(source) {
|
|
5122
4670
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
5123
4671
|
}
|
|
5124
|
-
var prefer_zod_enum_default =
|
|
4672
|
+
var prefer_zod_enum_default = ESLintUtils27.RuleCreator(
|
|
5125
4673
|
(name) => `https://github.com/sarj-ai/standards/tree/main/packages/typescript#${name}`
|
|
5126
4674
|
)({
|
|
5127
4675
|
name: "prefer-zod-enum",
|
|
@@ -5142,20 +4690,20 @@ var prefer_zod_enum_default = ESLintUtils31.RuleCreator(
|
|
|
5142
4690
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
5143
4691
|
function enumValues(node) {
|
|
5144
4692
|
const callee = node.callee;
|
|
5145
|
-
if (callee.type !==
|
|
4693
|
+
if (callee.type !== AST_NODE_TYPES18.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES18.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== AST_NODE_TYPES18.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
5146
4694
|
return null;
|
|
5147
4695
|
}
|
|
5148
4696
|
const argument = node.arguments[0];
|
|
5149
|
-
if (argument === void 0 || argument.type !==
|
|
4697
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES18.ArrayExpression || argument.elements.length === 0) {
|
|
5150
4698
|
return null;
|
|
5151
4699
|
}
|
|
5152
4700
|
const values = [];
|
|
5153
4701
|
for (const element of argument.elements) {
|
|
5154
|
-
if (element === null || element.type !==
|
|
4702
|
+
if (element === null || element.type !== AST_NODE_TYPES18.CallExpression || element.arguments.length !== 1 || element.callee.type !== AST_NODE_TYPES18.MemberExpression || element.callee.computed || element.callee.object.type !== AST_NODE_TYPES18.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== AST_NODE_TYPES18.Identifier || element.callee.property.name !== "literal") {
|
|
5155
4703
|
return null;
|
|
5156
4704
|
}
|
|
5157
4705
|
const value = element.arguments[0];
|
|
5158
|
-
if (value === void 0 || value.type !==
|
|
4706
|
+
if (value === void 0 || value.type !== AST_NODE_TYPES18.Literal || typeof value.value !== "string") {
|
|
5159
4707
|
return null;
|
|
5160
4708
|
}
|
|
5161
4709
|
values.push(value);
|
|
@@ -5164,11 +4712,11 @@ var prefer_zod_enum_default = ESLintUtils31.RuleCreator(
|
|
|
5164
4712
|
}
|
|
5165
4713
|
function buildFix(node, values) {
|
|
5166
4714
|
const argument = node.arguments[0];
|
|
5167
|
-
if (argument === void 0 || argument.type !==
|
|
4715
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES18.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
5168
4716
|
return void 0;
|
|
5169
4717
|
}
|
|
5170
4718
|
const callee = node.callee;
|
|
5171
|
-
if (callee.type !==
|
|
4719
|
+
if (callee.type !== AST_NODE_TYPES18.MemberExpression || callee.property.type !== AST_NODE_TYPES18.Identifier) {
|
|
5172
4720
|
return void 0;
|
|
5173
4721
|
}
|
|
5174
4722
|
return (fixer) => [
|
|
@@ -5185,7 +4733,7 @@ var prefer_zod_enum_default = ESLintUtils31.RuleCreator(
|
|
|
5185
4733
|
return;
|
|
5186
4734
|
}
|
|
5187
4735
|
for (const specifier of node.specifiers) {
|
|
5188
|
-
if (specifier.type ===
|
|
4736
|
+
if (specifier.type === AST_NODE_TYPES18.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES18.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES18.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES18.Identifier && specifier.imported.name === "z") {
|
|
5189
4737
|
zodNamespaces.add(specifier.local.name);
|
|
5190
4738
|
}
|
|
5191
4739
|
}
|
|
@@ -5206,157 +4754,11 @@ var prefer_zod_enum_default = ESLintUtils31.RuleCreator(
|
|
|
5206
4754
|
}
|
|
5207
4755
|
});
|
|
5208
4756
|
|
|
5209
|
-
// src/rules/single-public-export.ts
|
|
5210
|
-
import { ESLintUtils as ESLintUtils32, AST_NODE_TYPES as AST_NODE_TYPES22 } from "@typescript-eslint/utils";
|
|
5211
|
-
var JUNK_DRAWER_STEMS = /* @__PURE__ */ new Set([
|
|
5212
|
-
"util",
|
|
5213
|
-
"utils",
|
|
5214
|
-
"helper",
|
|
5215
|
-
"helpers",
|
|
5216
|
-
"common",
|
|
5217
|
-
"constant",
|
|
5218
|
-
"constants",
|
|
5219
|
-
"type",
|
|
5220
|
-
"types",
|
|
5221
|
-
"model",
|
|
5222
|
-
"models",
|
|
5223
|
-
"shared",
|
|
5224
|
-
"misc"
|
|
5225
|
-
]);
|
|
5226
|
-
var CONVENTIONAL_BUCKET_EXPORTS = /* @__PURE__ */ new Set(["cn"]);
|
|
5227
|
-
var ACRONYM_OVERRIDES = [
|
|
5228
|
-
[/OAuth/g, "Oauth"],
|
|
5229
|
-
[/GraphQL/g, "Graphql"],
|
|
5230
|
-
[/gRPC/g, "Grpc"]
|
|
5231
|
-
];
|
|
5232
|
-
var CAMEL_BOUNDARY_RE = /(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g;
|
|
5233
|
-
var TEST_FILE_RE = /\.(test|spec)\.[cm]?[jt]sx?$/i;
|
|
5234
|
-
var SCRIPT_EXT_RE = /\.[cm]?[jt]sx?$/i;
|
|
5235
|
-
var basename = (filename) => filename.split(/[/\\]/).pop() ?? filename;
|
|
5236
|
-
var stemOf = (base) => base.replace(SCRIPT_EXT_RE, "");
|
|
5237
|
-
var kebabCase2 = (name) => {
|
|
5238
|
-
let normalized = name;
|
|
5239
|
-
for (const [pattern, replacement] of ACRONYM_OVERRIDES) {
|
|
5240
|
-
normalized = normalized.replace(pattern, replacement);
|
|
5241
|
-
}
|
|
5242
|
-
return normalized.replace(CAMEL_BOUNDARY_RE, "-").toLowerCase();
|
|
5243
|
-
};
|
|
5244
|
-
var isFunctionExpression = (node) => node !== null && (node.type === AST_NODE_TYPES22.ArrowFunctionExpression || node.type === AST_NODE_TYPES22.FunctionExpression);
|
|
5245
|
-
var functionConstName = (decl) => {
|
|
5246
|
-
if (decl.declarations.length !== 1) return null;
|
|
5247
|
-
const [declarator] = decl.declarations;
|
|
5248
|
-
if (declarator === void 0) return null;
|
|
5249
|
-
if (declarator.id.type !== AST_NODE_TYPES22.Identifier) return null;
|
|
5250
|
-
if (!isFunctionExpression(declarator.init)) return null;
|
|
5251
|
-
return declarator.id.name;
|
|
5252
|
-
};
|
|
5253
|
-
var summarizeExports = (body) => {
|
|
5254
|
-
let names = 0;
|
|
5255
|
-
let hasReExport = false;
|
|
5256
|
-
let candidate = null;
|
|
5257
|
-
const addCandidate = (name, node) => {
|
|
5258
|
-
names += 1;
|
|
5259
|
-
candidate = { name, node };
|
|
5260
|
-
};
|
|
5261
|
-
for (const statement of body) {
|
|
5262
|
-
switch (statement.type) {
|
|
5263
|
-
case AST_NODE_TYPES22.ExportAllDeclaration:
|
|
5264
|
-
hasReExport = true;
|
|
5265
|
-
break;
|
|
5266
|
-
case AST_NODE_TYPES22.ExportDefaultDeclaration: {
|
|
5267
|
-
names += 1;
|
|
5268
|
-
const decl = statement.declaration;
|
|
5269
|
-
if (decl.type === AST_NODE_TYPES22.FunctionDeclaration && decl.id !== null) {
|
|
5270
|
-
candidate = { name: decl.id.name, node: statement };
|
|
5271
|
-
} else if (decl.type === AST_NODE_TYPES22.ClassDeclaration && decl.id !== null) {
|
|
5272
|
-
candidate = { name: decl.id.name, node: statement };
|
|
5273
|
-
}
|
|
5274
|
-
break;
|
|
5275
|
-
}
|
|
5276
|
-
case AST_NODE_TYPES22.ExportNamedDeclaration: {
|
|
5277
|
-
if (statement.source !== null) {
|
|
5278
|
-
hasReExport = true;
|
|
5279
|
-
break;
|
|
5280
|
-
}
|
|
5281
|
-
const decl = statement.declaration;
|
|
5282
|
-
if (decl === null) {
|
|
5283
|
-
names += statement.specifiers.length;
|
|
5284
|
-
break;
|
|
5285
|
-
}
|
|
5286
|
-
switch (decl.type) {
|
|
5287
|
-
case AST_NODE_TYPES22.FunctionDeclaration:
|
|
5288
|
-
if (decl.id !== null) addCandidate(decl.id.name, statement);
|
|
5289
|
-
else names += 1;
|
|
5290
|
-
break;
|
|
5291
|
-
case AST_NODE_TYPES22.ClassDeclaration:
|
|
5292
|
-
if (decl.id !== null) addCandidate(decl.id.name, statement);
|
|
5293
|
-
else names += 1;
|
|
5294
|
-
break;
|
|
5295
|
-
case AST_NODE_TYPES22.VariableDeclaration: {
|
|
5296
|
-
const fnName = functionConstName(decl);
|
|
5297
|
-
if (fnName !== null && decl.declarations.length === 1) {
|
|
5298
|
-
addCandidate(fnName, statement);
|
|
5299
|
-
} else {
|
|
5300
|
-
names += decl.declarations.length;
|
|
5301
|
-
}
|
|
5302
|
-
break;
|
|
5303
|
-
}
|
|
5304
|
-
default:
|
|
5305
|
-
names += 1;
|
|
5306
|
-
}
|
|
5307
|
-
break;
|
|
5308
|
-
}
|
|
5309
|
-
default:
|
|
5310
|
-
break;
|
|
5311
|
-
}
|
|
5312
|
-
}
|
|
5313
|
-
return { names, hasReExport, candidate };
|
|
5314
|
-
};
|
|
5315
|
-
var single_public_export_default = ESLintUtils32.RuleCreator(
|
|
5316
|
-
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5317
|
-
)({
|
|
5318
|
-
name: "single-public-export",
|
|
5319
|
-
meta: {
|
|
5320
|
-
type: "suggestion",
|
|
5321
|
-
docs: {
|
|
5322
|
-
description: "A junk-drawer module stem (`utils`, `helpers`, `types`, ...) with a single public function/class/const export should be renamed after that export."
|
|
5323
|
-
},
|
|
5324
|
-
schema: [],
|
|
5325
|
-
messages: {
|
|
5326
|
-
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."
|
|
5327
|
-
}
|
|
5328
|
-
},
|
|
5329
|
-
defaultOptions: [],
|
|
5330
|
-
create(context) {
|
|
5331
|
-
const base = basename(context.filename);
|
|
5332
|
-
if (base.endsWith(".d.ts")) return {};
|
|
5333
|
-
if (TEST_FILE_RE.test(base)) return {};
|
|
5334
|
-
if (isTestFile(context.filename)) return {};
|
|
5335
|
-
const stem3 = stemOf(base);
|
|
5336
|
-
if (!JUNK_DRAWER_STEMS.has(stem3.toLowerCase())) return {};
|
|
5337
|
-
return {
|
|
5338
|
-
Program(node) {
|
|
5339
|
-
const { names, hasReExport, candidate } = summarizeExports(node.body);
|
|
5340
|
-
if (hasReExport) return;
|
|
5341
|
-
if (names !== 1 || candidate === null) return;
|
|
5342
|
-
if (CONVENTIONAL_BUCKET_EXPORTS.has(candidate.name)) return;
|
|
5343
|
-
const expected = kebabCase2(candidate.name);
|
|
5344
|
-
if (stem3 === expected) return;
|
|
5345
|
-
context.report({
|
|
5346
|
-
node: candidate.node,
|
|
5347
|
-
messageId: "renameJunkDrawer",
|
|
5348
|
-
data: { stem: stem3, name: candidate.name, expected }
|
|
5349
|
-
});
|
|
5350
|
-
}
|
|
5351
|
-
};
|
|
5352
|
-
}
|
|
5353
|
-
});
|
|
5354
|
-
|
|
5355
4757
|
// src/rules/no-offset-pagination.ts
|
|
5356
|
-
import { ESLintUtils as
|
|
4758
|
+
import { ESLintUtils as ESLintUtils28 } from "@typescript-eslint/utils";
|
|
5357
4759
|
|
|
5358
4760
|
// src/rules/_sql.ts
|
|
5359
|
-
import { AST_NODE_TYPES as
|
|
4761
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES19 } from "@typescript-eslint/utils";
|
|
5360
4762
|
function stripSqlNoise(text) {
|
|
5361
4763
|
const out = [...text];
|
|
5362
4764
|
const n = text.length;
|
|
@@ -5417,13 +4819,13 @@ function stripSqlNoise(text) {
|
|
|
5417
4819
|
var SUBSTITUTION_MARKER = "?";
|
|
5418
4820
|
function sqlTextOf(node) {
|
|
5419
4821
|
switch (node.type) {
|
|
5420
|
-
case
|
|
4822
|
+
case AST_NODE_TYPES19.Literal:
|
|
5421
4823
|
return typeof node.value === "string" ? node.value : null;
|
|
5422
|
-
case
|
|
4824
|
+
case AST_NODE_TYPES19.TemplateLiteral:
|
|
5423
4825
|
return node.quasis.map((q) => q.value.cooked ?? q.value.raw).join(SUBSTITUTION_MARKER);
|
|
5424
|
-
case
|
|
4826
|
+
case AST_NODE_TYPES19.TaggedTemplateExpression:
|
|
5425
4827
|
return sqlTextOf(node.quasi);
|
|
5426
|
-
case
|
|
4828
|
+
case AST_NODE_TYPES19.BinaryExpression: {
|
|
5427
4829
|
if (node.operator !== "+") {
|
|
5428
4830
|
return null;
|
|
5429
4831
|
}
|
|
@@ -5431,7 +4833,7 @@ function sqlTextOf(node) {
|
|
|
5431
4833
|
const right = sqlTextOf(node.right);
|
|
5432
4834
|
return left !== null && right !== null ? left + right : null;
|
|
5433
4835
|
}
|
|
5434
|
-
case
|
|
4836
|
+
case AST_NODE_TYPES19.ArrayExpression: {
|
|
5435
4837
|
const parts = [];
|
|
5436
4838
|
for (const element of node.elements) {
|
|
5437
4839
|
if (element === null) {
|
|
@@ -5451,7 +4853,7 @@ function sqlTextOf(node) {
|
|
|
5451
4853
|
}
|
|
5452
4854
|
function isJoinedFragmentArray(node) {
|
|
5453
4855
|
const parent = node.parent;
|
|
5454
|
-
return parent?.type ===
|
|
4856
|
+
return parent?.type === AST_NODE_TYPES19.MemberExpression && parent.object === node && !parent.computed && parent.property.type === AST_NODE_TYPES19.Identifier && parent.property.name === "join" && parent.parent?.type === AST_NODE_TYPES19.CallExpression;
|
|
5455
4857
|
}
|
|
5456
4858
|
function markConsumed(node, consumed) {
|
|
5457
4859
|
consumed.add(node);
|
|
@@ -5501,7 +4903,7 @@ function createSqlListener(handler) {
|
|
|
5501
4903
|
// src/rules/no-offset-pagination.ts
|
|
5502
4904
|
var OFFSET_PAGINATION = /\bOFFSET\s+(?:%s|%\(\w+\)s|\?\d*|:\w+|@\w+|\$\d+|\d+)/i;
|
|
5503
4905
|
var OFFSET_GATE = /offset/i;
|
|
5504
|
-
var no_offset_pagination_default =
|
|
4906
|
+
var no_offset_pagination_default = ESLintUtils28.RuleCreator(
|
|
5505
4907
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5506
4908
|
)({
|
|
5507
4909
|
name: "no-offset-pagination",
|
|
@@ -5530,15 +4932,15 @@ var no_offset_pagination_default = ESLintUtils33.RuleCreator(
|
|
|
5530
4932
|
});
|
|
5531
4933
|
|
|
5532
4934
|
// src/rules/no-positional-tuple-return.ts
|
|
5533
|
-
import { AST_NODE_TYPES as
|
|
4935
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES20, ESLintUtils as ESLintUtils29 } from "@typescript-eslint/utils";
|
|
5534
4936
|
var MIN_ELEMENTS = 2;
|
|
5535
4937
|
var ACCESSOR_PAIR_LENGTH = 2;
|
|
5536
4938
|
var AWAITABLE_TYPES = /* @__PURE__ */ new Set(["Promise", "PromiseLike", "Awaited"]);
|
|
5537
4939
|
function tupleReturnType(node) {
|
|
5538
|
-
if (node.type ===
|
|
4940
|
+
if (node.type === AST_NODE_TYPES20.TSTupleType) {
|
|
5539
4941
|
return node;
|
|
5540
4942
|
}
|
|
5541
|
-
if (node.type ===
|
|
4943
|
+
if (node.type === AST_NODE_TYPES20.TSTypeReference && node.typeName.type === AST_NODE_TYPES20.Identifier && AWAITABLE_TYPES.has(node.typeName.name)) {
|
|
5542
4944
|
const argument = node.typeArguments?.params[0];
|
|
5543
4945
|
return argument === void 0 ? null : tupleReturnType(argument);
|
|
5544
4946
|
}
|
|
@@ -5552,30 +4954,30 @@ function isPermittedTuple(tuple, sourceCode) {
|
|
|
5552
4954
|
if (elements.length < MIN_ELEMENTS) {
|
|
5553
4955
|
return true;
|
|
5554
4956
|
}
|
|
5555
|
-
if (elements.some((element) => element.type ===
|
|
4957
|
+
if (elements.some((element) => element.type === AST_NODE_TYPES20.TSRestType)) {
|
|
5556
4958
|
return true;
|
|
5557
4959
|
}
|
|
5558
|
-
if (elements.some((element) => element.type ===
|
|
4960
|
+
if (elements.some((element) => element.type === AST_NODE_TYPES20.TSNamedTupleMember)) {
|
|
5559
4961
|
return true;
|
|
5560
4962
|
}
|
|
5561
|
-
if (elements[0]?.type ===
|
|
4963
|
+
if (elements[0]?.type === AST_NODE_TYPES20.TSLiteralType) {
|
|
5562
4964
|
return true;
|
|
5563
4965
|
}
|
|
5564
|
-
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type ===
|
|
4966
|
+
if (elements.length === ACCESSOR_PAIR_LENGTH && elements.some((element) => element.type === AST_NODE_TYPES20.TSFunctionType)) {
|
|
5565
4967
|
return true;
|
|
5566
4968
|
}
|
|
5567
4969
|
const texts = new Set(elements.map((element) => normalizedText(sourceCode, element)));
|
|
5568
4970
|
return texts.size === 1;
|
|
5569
4971
|
}
|
|
5570
4972
|
function functionName(node) {
|
|
5571
|
-
if (node.type ===
|
|
4973
|
+
if (node.type === AST_NODE_TYPES20.FunctionDeclaration) {
|
|
5572
4974
|
return node.id?.name ?? null;
|
|
5573
4975
|
}
|
|
5574
4976
|
const parent = node.parent;
|
|
5575
|
-
if (parent?.type ===
|
|
4977
|
+
if (parent?.type === AST_NODE_TYPES20.VariableDeclarator && parent.id.type === AST_NODE_TYPES20.Identifier) {
|
|
5576
4978
|
return parent.id.name;
|
|
5577
4979
|
}
|
|
5578
|
-
if ((parent?.type ===
|
|
4980
|
+
if ((parent?.type === AST_NODE_TYPES20.MethodDefinition || parent?.type === AST_NODE_TYPES20.PropertyDefinition || parent?.type === AST_NODE_TYPES20.Property) && parent.key.type === AST_NODE_TYPES20.Identifier) {
|
|
5579
4981
|
return parent.key.name;
|
|
5580
4982
|
}
|
|
5581
4983
|
return null;
|
|
@@ -5583,7 +4985,7 @@ function functionName(node) {
|
|
|
5583
4985
|
function isInlineExported(node) {
|
|
5584
4986
|
for (let current = node; current != null; current = current.parent) {
|
|
5585
4987
|
const parent = current.parent;
|
|
5586
|
-
if (parent?.type ===
|
|
4988
|
+
if (parent?.type === AST_NODE_TYPES20.ExportNamedDeclaration || parent?.type === AST_NODE_TYPES20.ExportDefaultDeclaration) {
|
|
5587
4989
|
return true;
|
|
5588
4990
|
}
|
|
5589
4991
|
}
|
|
@@ -5592,18 +4994,18 @@ function isInlineExported(node) {
|
|
|
5592
4994
|
function moduleScopeBindingName(node) {
|
|
5593
4995
|
let current = node;
|
|
5594
4996
|
let child = node;
|
|
5595
|
-
while (current.parent != null && current.parent.type !==
|
|
4997
|
+
while (current.parent != null && current.parent.type !== AST_NODE_TYPES20.Program) {
|
|
5596
4998
|
child = current;
|
|
5597
4999
|
current = current.parent;
|
|
5598
5000
|
}
|
|
5599
|
-
if (current.parent?.type !==
|
|
5001
|
+
if (current.parent?.type !== AST_NODE_TYPES20.Program) {
|
|
5600
5002
|
return null;
|
|
5601
5003
|
}
|
|
5602
|
-
if (current.type ===
|
|
5004
|
+
if (current.type === AST_NODE_TYPES20.FunctionDeclaration || current.type === AST_NODE_TYPES20.ClassDeclaration) {
|
|
5603
5005
|
return current.id?.name ?? null;
|
|
5604
5006
|
}
|
|
5605
|
-
if (current.type ===
|
|
5606
|
-
if (child.type !==
|
|
5007
|
+
if (current.type === AST_NODE_TYPES20.VariableDeclaration) {
|
|
5008
|
+
if (child.type !== AST_NODE_TYPES20.VariableDeclarator || child.id.type !== AST_NODE_TYPES20.Identifier) {
|
|
5607
5009
|
return null;
|
|
5608
5010
|
}
|
|
5609
5011
|
return child.id.name;
|
|
@@ -5613,19 +5015,19 @@ function moduleScopeBindingName(node) {
|
|
|
5613
5015
|
function specifierExportedNames(program) {
|
|
5614
5016
|
const names = /* @__PURE__ */ new Set();
|
|
5615
5017
|
for (const statement of program.body) {
|
|
5616
|
-
if (statement.type ===
|
|
5018
|
+
if (statement.type === AST_NODE_TYPES20.ExportNamedDeclaration && statement.declaration == null && statement.source == null && statement.exportKind !== "type") {
|
|
5617
5019
|
for (const specifier of statement.specifiers) {
|
|
5618
|
-
if (specifier.exportKind !== "type" && specifier.local.type ===
|
|
5020
|
+
if (specifier.exportKind !== "type" && specifier.local.type === AST_NODE_TYPES20.Identifier) {
|
|
5619
5021
|
names.add(specifier.local.name);
|
|
5620
5022
|
}
|
|
5621
5023
|
}
|
|
5622
5024
|
continue;
|
|
5623
5025
|
}
|
|
5624
|
-
if (statement.type ===
|
|
5026
|
+
if (statement.type === AST_NODE_TYPES20.ExportDefaultDeclaration && statement.declaration.type === AST_NODE_TYPES20.Identifier) {
|
|
5625
5027
|
names.add(statement.declaration.name);
|
|
5626
5028
|
continue;
|
|
5627
5029
|
}
|
|
5628
|
-
if (statement.type ===
|
|
5030
|
+
if (statement.type === AST_NODE_TYPES20.TSExportAssignment && statement.expression.type === AST_NODE_TYPES20.Identifier) {
|
|
5629
5031
|
names.add(statement.expression.name);
|
|
5630
5032
|
}
|
|
5631
5033
|
}
|
|
@@ -5641,7 +5043,7 @@ function isExported(node, specifierExports) {
|
|
|
5641
5043
|
const binding = moduleScopeBindingName(node);
|
|
5642
5044
|
return binding !== null && specifierExports.has(binding);
|
|
5643
5045
|
}
|
|
5644
|
-
var no_positional_tuple_return_default =
|
|
5046
|
+
var no_positional_tuple_return_default = ESLintUtils29.RuleCreator(
|
|
5645
5047
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5646
5048
|
)({
|
|
5647
5049
|
name: "no-positional-tuple-return",
|
|
@@ -5689,16 +5091,16 @@ var no_positional_tuple_return_default = ESLintUtils34.RuleCreator(
|
|
|
5689
5091
|
});
|
|
5690
5092
|
|
|
5691
5093
|
// src/rules/no-repeated-string-literal.ts
|
|
5692
|
-
import { AST_NODE_TYPES as
|
|
5094
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES21, ESLintUtils as ESLintUtils30 } from "@typescript-eslint/utils";
|
|
5693
5095
|
var MIN_LENGTH = 40;
|
|
5694
5096
|
var MIN_DISTINCT_SCOPES = 2;
|
|
5695
5097
|
var PREVIEW_LENGTH = 40;
|
|
5696
5098
|
var SQL_KEYWORD_RE = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|VALUES|ON CONFLICT|RETURNING|GROUP BY|ORDER BY)\b/;
|
|
5697
5099
|
var IDENTIFIER_RE = /^[a-z_][a-z0-9_.]*$/;
|
|
5698
5100
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5101
|
+
AST_NODE_TYPES21.FunctionDeclaration,
|
|
5102
|
+
AST_NODE_TYPES21.FunctionExpression,
|
|
5103
|
+
AST_NODE_TYPES21.ArrowFunctionExpression
|
|
5702
5104
|
]);
|
|
5703
5105
|
function isStructured(value) {
|
|
5704
5106
|
return value.includes("\n") || SQL_KEYWORD_RE.test(value) || IDENTIFIER_RE.test(value);
|
|
@@ -5720,9 +5122,9 @@ function isScaffolding(node) {
|
|
|
5720
5122
|
if (parent === void 0) {
|
|
5721
5123
|
return true;
|
|
5722
5124
|
}
|
|
5723
|
-
return parent.type ===
|
|
5125
|
+
return parent.type === AST_NODE_TYPES21.ImportDeclaration || parent.type === AST_NODE_TYPES21.ExportNamedDeclaration || parent.type === AST_NODE_TYPES21.ExportAllDeclaration || parent.type === AST_NODE_TYPES21.TSImportType || parent.type === AST_NODE_TYPES21.JSXAttribute || parent.type === AST_NODE_TYPES21.TSLiteralType;
|
|
5724
5126
|
}
|
|
5725
|
-
var no_repeated_string_literal_default =
|
|
5127
|
+
var no_repeated_string_literal_default = ESLintUtils30.RuleCreator(
|
|
5726
5128
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5727
5129
|
)({
|
|
5728
5130
|
name: "no-repeated-string-literal",
|
|
@@ -5762,7 +5164,7 @@ var no_repeated_string_literal_default = ESLintUtils35.RuleCreator(
|
|
|
5762
5164
|
}
|
|
5763
5165
|
},
|
|
5764
5166
|
TemplateLiteral(node) {
|
|
5765
|
-
if (node.parent.type ===
|
|
5167
|
+
if (node.parent.type === AST_NODE_TYPES21.TaggedTemplateExpression) {
|
|
5766
5168
|
return;
|
|
5767
5169
|
}
|
|
5768
5170
|
const [only] = node.quasis;
|
|
@@ -5796,7 +5198,7 @@ var no_repeated_string_literal_default = ESLintUtils35.RuleCreator(
|
|
|
5796
5198
|
});
|
|
5797
5199
|
|
|
5798
5200
|
// src/rules/no-select-star.ts
|
|
5799
|
-
import { ESLintUtils as
|
|
5201
|
+
import { ESLintUtils as ESLintUtils31 } from "@typescript-eslint/utils";
|
|
5800
5202
|
var QUERY_SHAPE = /\bSELECT\b[\s\S]*?\bFROM\b/i;
|
|
5801
5203
|
var SELECT_KEYWORD = /\bSELECT\b/gi;
|
|
5802
5204
|
var FROM_KEYWORD = /^FROM\b/i;
|
|
@@ -5836,7 +5238,7 @@ function hasRealSelectStar(sql) {
|
|
|
5836
5238
|
}
|
|
5837
5239
|
return false;
|
|
5838
5240
|
}
|
|
5839
|
-
var no_select_star_default =
|
|
5241
|
+
var no_select_star_default = ESLintUtils31.RuleCreator(
|
|
5840
5242
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5841
5243
|
)({
|
|
5842
5244
|
name: "no-select-star",
|
|
@@ -5865,7 +5267,7 @@ var no_select_star_default = ESLintUtils36.RuleCreator(
|
|
|
5865
5267
|
});
|
|
5866
5268
|
|
|
5867
5269
|
// src/rules/no-sleep-in-test-body.ts
|
|
5868
|
-
import { AST_NODE_TYPES as
|
|
5270
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES22, ESLintUtils as ESLintUtils32 } from "@typescript-eslint/utils";
|
|
5869
5271
|
var SLEEP_HELPERS = /* @__PURE__ */ new Set(["sleep", "delay", "wait", "pause"]);
|
|
5870
5272
|
var TEST_CALLERS = /* @__PURE__ */ new Set([
|
|
5871
5273
|
"it",
|
|
@@ -5874,34 +5276,34 @@ var TEST_CALLERS = /* @__PURE__ */ new Set([
|
|
|
5874
5276
|
"afterEach"
|
|
5875
5277
|
]);
|
|
5876
5278
|
var FUNCTION_TYPES2 = /* @__PURE__ */ new Set([
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5279
|
+
AST_NODE_TYPES22.FunctionDeclaration,
|
|
5280
|
+
AST_NODE_TYPES22.FunctionExpression,
|
|
5281
|
+
AST_NODE_TYPES22.ArrowFunctionExpression
|
|
5880
5282
|
]);
|
|
5881
5283
|
function isNonzeroNumericLiteral(node) {
|
|
5882
|
-
return node?.type ===
|
|
5284
|
+
return node?.type === AST_NODE_TYPES22.Literal && typeof node.value === "number" && node.value !== 0;
|
|
5883
5285
|
}
|
|
5884
5286
|
function isTimedSetTimeout(node) {
|
|
5885
|
-
return node.type ===
|
|
5287
|
+
return node.type === AST_NODE_TYPES22.CallExpression && node.callee.type === AST_NODE_TYPES22.Identifier && node.callee.name === "setTimeout" && node.arguments.length >= 2 && isNonzeroNumericLiteral(node.arguments[1]);
|
|
5886
5288
|
}
|
|
5887
5289
|
function isPromiseSleep(node) {
|
|
5888
|
-
if (node.callee.type !==
|
|
5290
|
+
if (node.callee.type !== AST_NODE_TYPES22.Identifier || node.callee.name !== "Promise") {
|
|
5889
5291
|
return false;
|
|
5890
5292
|
}
|
|
5891
5293
|
const executor = node.arguments[0];
|
|
5892
|
-
if (executor?.type !==
|
|
5294
|
+
if (executor?.type !== AST_NODE_TYPES22.ArrowFunctionExpression && executor?.type !== AST_NODE_TYPES22.FunctionExpression) {
|
|
5893
5295
|
return false;
|
|
5894
5296
|
}
|
|
5895
5297
|
const body = executor.body;
|
|
5896
|
-
if (body.type !==
|
|
5298
|
+
if (body.type !== AST_NODE_TYPES22.BlockStatement) {
|
|
5897
5299
|
return isTimedSetTimeout(body);
|
|
5898
5300
|
}
|
|
5899
5301
|
return body.body.some(
|
|
5900
|
-
(stmt) => stmt.type ===
|
|
5302
|
+
(stmt) => stmt.type === AST_NODE_TYPES22.ExpressionStatement && isTimedSetTimeout(stmt.expression)
|
|
5901
5303
|
);
|
|
5902
5304
|
}
|
|
5903
5305
|
function isHelperSleep(node) {
|
|
5904
|
-
return node.callee.type ===
|
|
5306
|
+
return node.callee.type === AST_NODE_TYPES22.Identifier && SLEEP_HELPERS.has(node.callee.name) && node.arguments.length >= 1 && isNonzeroNumericLiteral(node.arguments[0]);
|
|
5905
5307
|
}
|
|
5906
5308
|
function nearestEnclosingFunction(node) {
|
|
5907
5309
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -5909,7 +5311,7 @@ function nearestEnclosingFunction(node) {
|
|
|
5909
5311
|
continue;
|
|
5910
5312
|
}
|
|
5911
5313
|
const grandparent = current.parent;
|
|
5912
|
-
const isPromiseExecutor = grandparent?.type ===
|
|
5314
|
+
const isPromiseExecutor = grandparent?.type === AST_NODE_TYPES22.NewExpression && isPromiseSleep(grandparent);
|
|
5913
5315
|
if (!isPromiseExecutor) {
|
|
5914
5316
|
return current;
|
|
5915
5317
|
}
|
|
@@ -5917,29 +5319,29 @@ function nearestEnclosingFunction(node) {
|
|
|
5917
5319
|
return null;
|
|
5918
5320
|
}
|
|
5919
5321
|
function testCallerName(callee) {
|
|
5920
|
-
if (callee.type ===
|
|
5322
|
+
if (callee.type === AST_NODE_TYPES22.Identifier) {
|
|
5921
5323
|
return callee.name;
|
|
5922
5324
|
}
|
|
5923
|
-
if (callee.type ===
|
|
5325
|
+
if (callee.type === AST_NODE_TYPES22.MemberExpression) {
|
|
5924
5326
|
return testCallerName(callee.object);
|
|
5925
5327
|
}
|
|
5926
|
-
if (callee.type ===
|
|
5328
|
+
if (callee.type === AST_NODE_TYPES22.CallExpression) {
|
|
5927
5329
|
return testCallerName(callee.callee);
|
|
5928
5330
|
}
|
|
5929
|
-
if (callee.type ===
|
|
5331
|
+
if (callee.type === AST_NODE_TYPES22.TaggedTemplateExpression) {
|
|
5930
5332
|
return testCallerName(callee.tag);
|
|
5931
5333
|
}
|
|
5932
5334
|
return null;
|
|
5933
5335
|
}
|
|
5934
5336
|
function isTestBody(fn) {
|
|
5935
5337
|
const call = fn.parent;
|
|
5936
|
-
if (call?.type !==
|
|
5338
|
+
if (call?.type !== AST_NODE_TYPES22.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
5937
5339
|
return false;
|
|
5938
5340
|
}
|
|
5939
5341
|
const name = testCallerName(call.callee);
|
|
5940
5342
|
return name !== null && TEST_CALLERS.has(name);
|
|
5941
5343
|
}
|
|
5942
|
-
var no_sleep_in_test_body_default =
|
|
5344
|
+
var no_sleep_in_test_body_default = ESLintUtils32.RuleCreator(
|
|
5943
5345
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
5944
5346
|
)({
|
|
5945
5347
|
name: "no-sleep-in-test-body",
|
|
@@ -5981,12 +5383,12 @@ var no_sleep_in_test_body_default = ESLintUtils37.RuleCreator(
|
|
|
5981
5383
|
});
|
|
5982
5384
|
|
|
5983
5385
|
// src/rules/no-conditional-in-test.ts
|
|
5984
|
-
import { AST_NODE_TYPES as
|
|
5386
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES23, ESLintUtils as ESLintUtils33 } from "@typescript-eslint/utils";
|
|
5985
5387
|
var TEST_CALLERS2 = /* @__PURE__ */ new Set(["it", "test"]);
|
|
5986
5388
|
var FUNCTION_TYPES3 = /* @__PURE__ */ new Set([
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5389
|
+
AST_NODE_TYPES23.FunctionDeclaration,
|
|
5390
|
+
AST_NODE_TYPES23.FunctionExpression,
|
|
5391
|
+
AST_NODE_TYPES23.ArrowFunctionExpression
|
|
5990
5392
|
]);
|
|
5991
5393
|
function nearestEnclosingFunction2(node) {
|
|
5992
5394
|
for (let current = node.parent; current != null; current = current.parent) {
|
|
@@ -5997,29 +5399,29 @@ function nearestEnclosingFunction2(node) {
|
|
|
5997
5399
|
return null;
|
|
5998
5400
|
}
|
|
5999
5401
|
function testCallerName2(callee) {
|
|
6000
|
-
if (callee.type ===
|
|
5402
|
+
if (callee.type === AST_NODE_TYPES23.Identifier) {
|
|
6001
5403
|
return callee.name;
|
|
6002
5404
|
}
|
|
6003
|
-
if (callee.type ===
|
|
5405
|
+
if (callee.type === AST_NODE_TYPES23.MemberExpression) {
|
|
6004
5406
|
return testCallerName2(callee.object);
|
|
6005
5407
|
}
|
|
6006
|
-
if (callee.type ===
|
|
5408
|
+
if (callee.type === AST_NODE_TYPES23.CallExpression) {
|
|
6007
5409
|
return testCallerName2(callee.callee);
|
|
6008
5410
|
}
|
|
6009
|
-
if (callee.type ===
|
|
5411
|
+
if (callee.type === AST_NODE_TYPES23.TaggedTemplateExpression) {
|
|
6010
5412
|
return testCallerName2(callee.tag);
|
|
6011
5413
|
}
|
|
6012
5414
|
return null;
|
|
6013
5415
|
}
|
|
6014
5416
|
function isTestBody2(fn) {
|
|
6015
5417
|
const call = fn.parent;
|
|
6016
|
-
if (call?.type !==
|
|
5418
|
+
if (call?.type !== AST_NODE_TYPES23.CallExpression || !call.arguments.some((argument) => argument === fn)) {
|
|
6017
5419
|
return false;
|
|
6018
5420
|
}
|
|
6019
5421
|
const name = testCallerName2(call.callee);
|
|
6020
5422
|
return name !== null && TEST_CALLERS2.has(name);
|
|
6021
5423
|
}
|
|
6022
|
-
var no_conditional_in_test_default =
|
|
5424
|
+
var no_conditional_in_test_default = ESLintUtils33.RuleCreator(
|
|
6023
5425
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6024
5426
|
)({
|
|
6025
5427
|
name: "no-conditional-in-test",
|
|
@@ -6063,7 +5465,7 @@ var no_conditional_in_test_default = ESLintUtils38.RuleCreator(
|
|
|
6063
5465
|
});
|
|
6064
5466
|
|
|
6065
5467
|
// src/rules/prefer-constant-time-secret-compare.ts
|
|
6066
|
-
import { AST_NODE_TYPES as
|
|
5468
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES24, ESLintUtils as ESLintUtils34 } from "@typescript-eslint/utils";
|
|
6067
5469
|
var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
|
|
6068
5470
|
var SENTINEL_IDENTIFIERS = /* @__PURE__ */ new Set(["undefined", "NaN"]);
|
|
6069
5471
|
var SENTINEL_WORDS = /(^|_)(SENTINEL|EMPTY|NONE|NULL|UNSET|MISSING|PLACEHOLDER|DUMMY|FAKE|EXAMPLE)(_|$)/;
|
|
@@ -6076,36 +5478,36 @@ function isConstantReference(identifier) {
|
|
|
6076
5478
|
}
|
|
6077
5479
|
function isExcludedOperand(node) {
|
|
6078
5480
|
switch (node.type) {
|
|
6079
|
-
case
|
|
5481
|
+
case AST_NODE_TYPES24.Literal:
|
|
6080
5482
|
return true;
|
|
6081
|
-
case
|
|
5483
|
+
case AST_NODE_TYPES24.TemplateLiteral:
|
|
6082
5484
|
return node.expressions.length === 0;
|
|
6083
|
-
case
|
|
5485
|
+
case AST_NODE_TYPES24.Identifier:
|
|
6084
5486
|
return SENTINEL_IDENTIFIERS.has(node.name) || SENTINEL_PREFIX_RE.test(node.name) || isConstantReference(node.name);
|
|
6085
|
-
case
|
|
6086
|
-
return !node.computed && node.property.type ===
|
|
5487
|
+
case AST_NODE_TYPES24.MemberExpression:
|
|
5488
|
+
return !node.computed && node.property.type === AST_NODE_TYPES24.Identifier && (SENTINEL_PREFIX_RE.test(node.property.name) || isConstantReference(node.property.name));
|
|
6087
5489
|
default:
|
|
6088
5490
|
return false;
|
|
6089
5491
|
}
|
|
6090
5492
|
}
|
|
6091
5493
|
function operandName(node) {
|
|
6092
|
-
if (node.type ===
|
|
5494
|
+
if (node.type === AST_NODE_TYPES24.Identifier) {
|
|
6093
5495
|
return node.name;
|
|
6094
5496
|
}
|
|
6095
|
-
if (node.type ===
|
|
5497
|
+
if (node.type === AST_NODE_TYPES24.MemberExpression && !node.computed && node.property.type === AST_NODE_TYPES24.Identifier) {
|
|
6096
5498
|
return node.property.name;
|
|
6097
5499
|
}
|
|
6098
5500
|
return null;
|
|
6099
5501
|
}
|
|
6100
5502
|
function isSecretOperand(node) {
|
|
6101
|
-
if (node.type ===
|
|
5503
|
+
if (node.type === AST_NODE_TYPES24.TemplateLiteral) {
|
|
6102
5504
|
return node.expressions.some((expression) => isSecretOperand(expression));
|
|
6103
5505
|
}
|
|
6104
5506
|
const name = operandName(node);
|
|
6105
5507
|
return name !== null && isAuthSecretName(name);
|
|
6106
5508
|
}
|
|
6107
5509
|
function secretNameOf(node) {
|
|
6108
|
-
if (node.type ===
|
|
5510
|
+
if (node.type === AST_NODE_TYPES24.TemplateLiteral) {
|
|
6109
5511
|
for (const expression of node.expressions) {
|
|
6110
5512
|
const nested = secretNameOf(expression);
|
|
6111
5513
|
if (nested !== null) {
|
|
@@ -6116,7 +5518,7 @@ function secretNameOf(node) {
|
|
|
6116
5518
|
}
|
|
6117
5519
|
return operandName(node);
|
|
6118
5520
|
}
|
|
6119
|
-
var prefer_constant_time_secret_compare_default =
|
|
5521
|
+
var prefer_constant_time_secret_compare_default = ESLintUtils34.RuleCreator(
|
|
6120
5522
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6121
5523
|
)({
|
|
6122
5524
|
name: "prefer-constant-time-secret-compare",
|
|
@@ -6159,11 +5561,11 @@ var prefer_constant_time_secret_compare_default = ESLintUtils39.RuleCreator(
|
|
|
6159
5561
|
});
|
|
6160
5562
|
|
|
6161
5563
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
6162
|
-
import { ESLintUtils as
|
|
5564
|
+
import { ESLintUtils as ESLintUtils35 } from "@typescript-eslint/utils";
|
|
6163
5565
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
6164
5566
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
6165
5567
|
var INSERT_GATE = /insert/i;
|
|
6166
|
-
var store_insert_requires_on_conflict_default =
|
|
5568
|
+
var store_insert_requires_on_conflict_default = ESLintUtils35.RuleCreator(
|
|
6167
5569
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6168
5570
|
)({
|
|
6169
5571
|
name: "store-insert-requires-on-conflict",
|
|
@@ -6192,17 +5594,17 @@ var store_insert_requires_on_conflict_default = ESLintUtils40.RuleCreator(
|
|
|
6192
5594
|
});
|
|
6193
5595
|
|
|
6194
5596
|
// src/rules/no-dynamic-sql.ts
|
|
6195
|
-
import { AST_NODE_TYPES as
|
|
5597
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES25, ESLintUtils as ESLintUtils36 } from "@typescript-eslint/utils";
|
|
6196
5598
|
var DEFAULT_METHODS = ["prepare", "exec", "query"];
|
|
6197
5599
|
var CONSTANT_CASE_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
6198
5600
|
function isStaticFragment(expression) {
|
|
6199
|
-
if (expression.type ===
|
|
5601
|
+
if (expression.type === AST_NODE_TYPES25.Identifier) {
|
|
6200
5602
|
return CONSTANT_CASE_RE.test(expression.name);
|
|
6201
5603
|
}
|
|
6202
|
-
if (expression.type ===
|
|
5604
|
+
if (expression.type === AST_NODE_TYPES25.MemberExpression && !expression.computed && expression.property.type === AST_NODE_TYPES25.Identifier) {
|
|
6203
5605
|
return CONSTANT_CASE_RE.test(expression.property.name);
|
|
6204
5606
|
}
|
|
6205
|
-
if (expression.type ===
|
|
5607
|
+
if (expression.type === AST_NODE_TYPES25.Literal) {
|
|
6206
5608
|
return typeof expression.value === "string";
|
|
6207
5609
|
}
|
|
6208
5610
|
return false;
|
|
@@ -6213,36 +5615,36 @@ function runtimeInterpolations(template) {
|
|
|
6213
5615
|
);
|
|
6214
5616
|
}
|
|
6215
5617
|
function concatOperands(node) {
|
|
6216
|
-
if (node.type ===
|
|
5618
|
+
if (node.type === AST_NODE_TYPES25.BinaryExpression && node.operator === "+") {
|
|
6217
5619
|
return [...concatOperands(node.left), ...concatOperands(node.right)];
|
|
6218
5620
|
}
|
|
6219
5621
|
return [node];
|
|
6220
5622
|
}
|
|
6221
5623
|
function runtimeConcatOperands(node) {
|
|
6222
|
-
if (node.type !==
|
|
5624
|
+
if (node.type !== AST_NODE_TYPES25.BinaryExpression || node.operator !== "+") {
|
|
6223
5625
|
return [];
|
|
6224
5626
|
}
|
|
6225
5627
|
const operands = concatOperands(node);
|
|
6226
5628
|
const hasStringLiteral = operands.some(
|
|
6227
|
-
(operand) => operand.type ===
|
|
5629
|
+
(operand) => operand.type === AST_NODE_TYPES25.Literal && typeof operand.value === "string"
|
|
6228
5630
|
);
|
|
6229
5631
|
if (!hasStringLiteral) {
|
|
6230
5632
|
return [];
|
|
6231
5633
|
}
|
|
6232
5634
|
return operands.filter(
|
|
6233
|
-
(operand) => operand.type !==
|
|
5635
|
+
(operand) => operand.type !== AST_NODE_TYPES25.Literal && !isStaticFragment(operand)
|
|
6234
5636
|
);
|
|
6235
5637
|
}
|
|
6236
5638
|
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;
|
|
6237
5639
|
var RUNTIME_MARKER = " ? ";
|
|
6238
5640
|
function staticStatementText(node) {
|
|
6239
|
-
if (node.type ===
|
|
5641
|
+
if (node.type === AST_NODE_TYPES25.TemplateLiteral) {
|
|
6240
5642
|
return node.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join(RUNTIME_MARKER);
|
|
6241
5643
|
}
|
|
6242
|
-
if (node.type ===
|
|
5644
|
+
if (node.type === AST_NODE_TYPES25.Literal) {
|
|
6243
5645
|
return typeof node.value === "string" ? node.value : RUNTIME_MARKER;
|
|
6244
5646
|
}
|
|
6245
|
-
if (node.type ===
|
|
5647
|
+
if (node.type === AST_NODE_TYPES25.BinaryExpression && node.operator === "+") {
|
|
6246
5648
|
return staticStatementText(node.left) + staticStatementText(node.right);
|
|
6247
5649
|
}
|
|
6248
5650
|
return RUNTIME_MARKER;
|
|
@@ -6252,13 +5654,13 @@ function looksLikeSql(node) {
|
|
|
6252
5654
|
}
|
|
6253
5655
|
function statementMethodName(node, methods) {
|
|
6254
5656
|
const callee = node.callee;
|
|
6255
|
-
if (callee.type !==
|
|
5657
|
+
if (callee.type !== AST_NODE_TYPES25.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES25.Identifier) {
|
|
6256
5658
|
return null;
|
|
6257
5659
|
}
|
|
6258
5660
|
const name = callee.property.name;
|
|
6259
5661
|
return methods.has(name) ? name : null;
|
|
6260
5662
|
}
|
|
6261
|
-
var no_dynamic_sql_default =
|
|
5663
|
+
var no_dynamic_sql_default = ESLintUtils36.RuleCreator(
|
|
6262
5664
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6263
5665
|
)({
|
|
6264
5666
|
name: "no-dynamic-sql",
|
|
@@ -6297,7 +5699,7 @@ var no_dynamic_sql_default = ESLintUtils41.RuleCreator(
|
|
|
6297
5699
|
if (statement === void 0 || !looksLikeSql(statement)) {
|
|
6298
5700
|
return;
|
|
6299
5701
|
}
|
|
6300
|
-
const offenders = statement.type ===
|
|
5702
|
+
const offenders = statement.type === AST_NODE_TYPES25.TemplateLiteral ? runtimeInterpolations(statement) : runtimeConcatOperands(statement);
|
|
6301
5703
|
for (const offender of offenders) {
|
|
6302
5704
|
context.report({
|
|
6303
5705
|
node: offender,
|
|
@@ -6311,7 +5713,7 @@ var no_dynamic_sql_default = ESLintUtils41.RuleCreator(
|
|
|
6311
5713
|
});
|
|
6312
5714
|
|
|
6313
5715
|
// src/rules/no-raw-fetch-outside-clients.ts
|
|
6314
|
-
import { ESLintUtils as
|
|
5716
|
+
import { ESLintUtils as ESLintUtils37 } from "@typescript-eslint/utils";
|
|
6315
5717
|
var DEFAULT_ALLOW = [
|
|
6316
5718
|
"[\\\\/]clients?[\\\\/]",
|
|
6317
5719
|
"-client\\.[cm]?[jt]sx?$",
|
|
@@ -6375,7 +5777,7 @@ function compile(patterns) {
|
|
|
6375
5777
|
}
|
|
6376
5778
|
return compiled;
|
|
6377
5779
|
}
|
|
6378
|
-
var no_raw_fetch_outside_clients_default =
|
|
5780
|
+
var no_raw_fetch_outside_clients_default = ESLintUtils37.RuleCreator(
|
|
6379
5781
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6380
5782
|
)({
|
|
6381
5783
|
name: "no-raw-fetch-outside-clients",
|
|
@@ -6423,7 +5825,7 @@ var no_raw_fetch_outside_clients_default = ESLintUtils42.RuleCreator(
|
|
|
6423
5825
|
});
|
|
6424
5826
|
|
|
6425
5827
|
// src/rules/no-storage-in-stateless-modules.ts
|
|
6426
|
-
import { AST_NODE_TYPES as
|
|
5828
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES26, ESLintUtils as ESLintUtils38 } from "@typescript-eslint/utils";
|
|
6427
5829
|
var DEFAULT_METHODS2 = [
|
|
6428
5830
|
"prepare",
|
|
6429
5831
|
"put",
|
|
@@ -6442,7 +5844,7 @@ function compile2(patterns) {
|
|
|
6442
5844
|
}
|
|
6443
5845
|
function storageMethodName(node, methods) {
|
|
6444
5846
|
const callee = node.callee;
|
|
6445
|
-
if (callee.type !==
|
|
5847
|
+
if (callee.type !== AST_NODE_TYPES26.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES26.Identifier) {
|
|
6446
5848
|
return null;
|
|
6447
5849
|
}
|
|
6448
5850
|
const name = callee.property.name;
|
|
@@ -6454,7 +5856,7 @@ function storageMethodName(node, methods) {
|
|
|
6454
5856
|
}
|
|
6455
5857
|
return name;
|
|
6456
5858
|
}
|
|
6457
|
-
var no_storage_in_stateless_modules_default =
|
|
5859
|
+
var no_storage_in_stateless_modules_default = ESLintUtils38.RuleCreator(
|
|
6458
5860
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6459
5861
|
)({
|
|
6460
5862
|
name: "no-storage-in-stateless-modules",
|
|
@@ -6513,8 +5915,8 @@ var no_storage_in_stateless_modules_default = ESLintUtils43.RuleCreator(
|
|
|
6513
5915
|
|
|
6514
5916
|
// src/rules/no-zod-native-enum.ts
|
|
6515
5917
|
import {
|
|
6516
|
-
ESLintUtils as
|
|
6517
|
-
AST_NODE_TYPES as
|
|
5918
|
+
ESLintUtils as ESLintUtils39,
|
|
5919
|
+
AST_NODE_TYPES as AST_NODE_TYPES27
|
|
6518
5920
|
} from "@typescript-eslint/utils";
|
|
6519
5921
|
import * as ts2 from "typescript";
|
|
6520
5922
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6533,7 +5935,7 @@ function isZodModule2(source) {
|
|
|
6533
5935
|
return /(^|[/@-])zod([/-]|$)/.test(source);
|
|
6534
5936
|
}
|
|
6535
5937
|
function unwrap3(node) {
|
|
6536
|
-
if (node.type ===
|
|
5938
|
+
if (node.type === AST_NODE_TYPES27.TSAsExpression || node.type === AST_NODE_TYPES27.TSSatisfiesExpression) {
|
|
6537
5939
|
return unwrap3(node.expression);
|
|
6538
5940
|
}
|
|
6539
5941
|
return node;
|
|
@@ -6541,14 +5943,14 @@ function unwrap3(node) {
|
|
|
6541
5943
|
function stringValueTexts(node, sourceCode) {
|
|
6542
5944
|
const texts = [];
|
|
6543
5945
|
for (const prop of node.properties) {
|
|
6544
|
-
if (prop.type !==
|
|
5946
|
+
if (prop.type !== AST_NODE_TYPES27.Property) {
|
|
6545
5947
|
return null;
|
|
6546
5948
|
}
|
|
6547
5949
|
if (prop.computed || prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6548
5950
|
return null;
|
|
6549
5951
|
}
|
|
6550
5952
|
const value = prop.value;
|
|
6551
|
-
if (value.type !==
|
|
5953
|
+
if (value.type !== AST_NODE_TYPES27.Literal || typeof value.value !== "string") {
|
|
6552
5954
|
return null;
|
|
6553
5955
|
}
|
|
6554
5956
|
const text = sourceCode.getText(value);
|
|
@@ -6564,7 +5966,7 @@ function resolvesToLocalEnum(node, scope) {
|
|
|
6564
5966
|
const variable = current.variables.find((v) => v.name === node.name);
|
|
6565
5967
|
if (variable !== void 0) {
|
|
6566
5968
|
return variable.defs.some(
|
|
6567
|
-
(def) => def.node.type ===
|
|
5969
|
+
(def) => def.node.type === AST_NODE_TYPES27.TSEnumDeclaration
|
|
6568
5970
|
);
|
|
6569
5971
|
}
|
|
6570
5972
|
current = current.upper;
|
|
@@ -6584,7 +5986,7 @@ function resolvesToImportedEnum(node, services) {
|
|
|
6584
5986
|
}
|
|
6585
5987
|
return (symbol.flags & ENUM_SYMBOL_FLAGS) !== 0;
|
|
6586
5988
|
}
|
|
6587
|
-
var no_zod_native_enum_default =
|
|
5989
|
+
var no_zod_native_enum_default = ESLintUtils39.RuleCreator(
|
|
6588
5990
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6589
5991
|
)({
|
|
6590
5992
|
name: "no-zod-native-enum",
|
|
@@ -6611,32 +6013,32 @@ var no_zod_native_enum_default = ESLintUtils44.RuleCreator(
|
|
|
6611
6013
|
}
|
|
6612
6014
|
let services;
|
|
6613
6015
|
try {
|
|
6614
|
-
services =
|
|
6016
|
+
services = ESLintUtils39.getParserServices(context);
|
|
6615
6017
|
} catch {
|
|
6616
6018
|
services = null;
|
|
6617
6019
|
}
|
|
6618
6020
|
const zodImportedNames = /* @__PURE__ */ new Map();
|
|
6619
6021
|
function isZodMemberCall(node, api) {
|
|
6620
6022
|
const callee = node.callee;
|
|
6621
|
-
if (callee.type ===
|
|
6023
|
+
if (callee.type === AST_NODE_TYPES27.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES27.Identifier) {
|
|
6622
6024
|
return callee.property.name === api;
|
|
6623
6025
|
}
|
|
6624
|
-
if (callee.type ===
|
|
6026
|
+
if (callee.type === AST_NODE_TYPES27.Identifier) {
|
|
6625
6027
|
return zodImportedNames.get(callee.name) === api;
|
|
6626
6028
|
}
|
|
6627
6029
|
return false;
|
|
6628
6030
|
}
|
|
6629
6031
|
function buildFix(node) {
|
|
6630
6032
|
const callee = node.callee;
|
|
6631
|
-
if (callee.type !==
|
|
6033
|
+
if (callee.type !== AST_NODE_TYPES27.MemberExpression || callee.property.type !== AST_NODE_TYPES27.Identifier) {
|
|
6632
6034
|
return null;
|
|
6633
6035
|
}
|
|
6634
6036
|
const arg = node.arguments[0];
|
|
6635
|
-
if (arg === void 0 || node.arguments.length !== 1 || arg.type ===
|
|
6037
|
+
if (arg === void 0 || node.arguments.length !== 1 || arg.type === AST_NODE_TYPES27.SpreadElement) {
|
|
6636
6038
|
return null;
|
|
6637
6039
|
}
|
|
6638
6040
|
const inner = unwrap3(arg);
|
|
6639
|
-
if (inner.type !==
|
|
6041
|
+
if (inner.type !== AST_NODE_TYPES27.ObjectExpression) {
|
|
6640
6042
|
return null;
|
|
6641
6043
|
}
|
|
6642
6044
|
const values = stringValueTexts(inner, sourceCode);
|
|
@@ -6656,7 +6058,7 @@ var no_zod_native_enum_default = ESLintUtils44.RuleCreator(
|
|
|
6656
6058
|
return;
|
|
6657
6059
|
}
|
|
6658
6060
|
for (const spec of node.specifiers) {
|
|
6659
|
-
if (spec.type ===
|
|
6061
|
+
if (spec.type === AST_NODE_TYPES27.ImportSpecifier && spec.imported.type === AST_NODE_TYPES27.Identifier) {
|
|
6660
6062
|
zodImportedNames.set(spec.local.name, spec.imported.name);
|
|
6661
6063
|
}
|
|
6662
6064
|
}
|
|
@@ -6675,7 +6077,7 @@ var no_zod_native_enum_default = ESLintUtils44.RuleCreator(
|
|
|
6675
6077
|
return;
|
|
6676
6078
|
}
|
|
6677
6079
|
const arg = node.arguments[0];
|
|
6678
|
-
if (arg === void 0 || arg.type !==
|
|
6080
|
+
if (arg === void 0 || arg.type !== AST_NODE_TYPES27.Identifier) {
|
|
6679
6081
|
return;
|
|
6680
6082
|
}
|
|
6681
6083
|
const isEnum = resolvesToLocalEnum(arg, sourceCode.getScope(arg)) || services !== null && resolvesToImportedEnum(arg, services);
|
|
@@ -6693,8 +6095,8 @@ var no_zod_native_enum_default = ESLintUtils44.RuleCreator(
|
|
|
6693
6095
|
|
|
6694
6096
|
// src/rules/prefer-module-level-constant.ts
|
|
6695
6097
|
import {
|
|
6696
|
-
ESLintUtils as
|
|
6697
|
-
AST_NODE_TYPES as
|
|
6098
|
+
ESLintUtils as ESLintUtils40,
|
|
6099
|
+
AST_NODE_TYPES as AST_NODE_TYPES28
|
|
6698
6100
|
} from "@typescript-eslint/utils";
|
|
6699
6101
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6700
6102
|
var MAX_LITERAL_DEPTH = 4;
|
|
@@ -6731,9 +6133,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6731
6133
|
"assign"
|
|
6732
6134
|
]);
|
|
6733
6135
|
var FUNCTION_TYPES4 = /* @__PURE__ */ new Set([
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6136
|
+
AST_NODE_TYPES28.FunctionDeclaration,
|
|
6137
|
+
AST_NODE_TYPES28.FunctionExpression,
|
|
6138
|
+
AST_NODE_TYPES28.ArrowFunctionExpression
|
|
6737
6139
|
]);
|
|
6738
6140
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6739
6141
|
function isIgnoredFile3(filename, sourceText) {
|
|
@@ -6746,13 +6148,13 @@ function isTestFile2(filename) {
|
|
|
6746
6148
|
return TEST_FILE_PATTERNS.some((re) => re.test(filename));
|
|
6747
6149
|
}
|
|
6748
6150
|
function unwrap4(node) {
|
|
6749
|
-
if (node.type ===
|
|
6151
|
+
if (node.type === AST_NODE_TYPES28.TSAsExpression || node.type === AST_NODE_TYPES28.TSSatisfiesExpression || node.type === AST_NODE_TYPES28.TSNonNullExpression) {
|
|
6750
6152
|
return unwrap4(node.expression);
|
|
6751
6153
|
}
|
|
6752
6154
|
return node;
|
|
6753
6155
|
}
|
|
6754
6156
|
function isRegexLiteral(node) {
|
|
6755
|
-
return node.type ===
|
|
6157
|
+
return node.type === AST_NODE_TYPES28.Literal && "regex" in node && node.regex !== void 0;
|
|
6756
6158
|
}
|
|
6757
6159
|
function isLiteralOnly(node, depth) {
|
|
6758
6160
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6760,29 +6162,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6760
6162
|
}
|
|
6761
6163
|
const inner = unwrap4(node);
|
|
6762
6164
|
switch (inner.type) {
|
|
6763
|
-
case
|
|
6165
|
+
case AST_NODE_TYPES28.Literal: {
|
|
6764
6166
|
return true;
|
|
6765
6167
|
}
|
|
6766
|
-
case
|
|
6168
|
+
case AST_NODE_TYPES28.TemplateLiteral: {
|
|
6767
6169
|
return inner.expressions.length === 0;
|
|
6768
6170
|
}
|
|
6769
|
-
case
|
|
6770
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
6171
|
+
case AST_NODE_TYPES28.UnaryExpression: {
|
|
6172
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES28.Literal && typeof inner.argument.value === "number";
|
|
6771
6173
|
}
|
|
6772
|
-
case
|
|
6174
|
+
case AST_NODE_TYPES28.ArrayExpression: {
|
|
6773
6175
|
return inner.elements.every(
|
|
6774
|
-
(el) => el !== null && el.type !==
|
|
6176
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES28.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6775
6177
|
);
|
|
6776
6178
|
}
|
|
6777
|
-
case
|
|
6179
|
+
case AST_NODE_TYPES28.ObjectExpression: {
|
|
6778
6180
|
return inner.properties.every((prop) => {
|
|
6779
|
-
if (prop.type !==
|
|
6181
|
+
if (prop.type !== AST_NODE_TYPES28.Property) {
|
|
6780
6182
|
return false;
|
|
6781
6183
|
}
|
|
6782
6184
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6783
6185
|
return false;
|
|
6784
6186
|
}
|
|
6785
|
-
if (prop.computed && prop.key.type !==
|
|
6187
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES28.Literal) {
|
|
6786
6188
|
return false;
|
|
6787
6189
|
}
|
|
6788
6190
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6795,7 +6197,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6795
6197
|
}
|
|
6796
6198
|
function unwrapObjectFreeze(node) {
|
|
6797
6199
|
const inner = unwrap4(node);
|
|
6798
|
-
if (inner.type ===
|
|
6200
|
+
if (inner.type === AST_NODE_TYPES28.CallExpression && inner.callee.type === AST_NODE_TYPES28.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES28.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES28.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES28.SpreadElement) {
|
|
6799
6201
|
return unwrap4(inner.arguments[0]);
|
|
6800
6202
|
}
|
|
6801
6203
|
return inner;
|
|
@@ -6811,19 +6213,19 @@ function classify(init, checkRegex) {
|
|
|
6811
6213
|
}
|
|
6812
6214
|
return { kind: "regex", size: 1 };
|
|
6813
6215
|
}
|
|
6814
|
-
if (node.type ===
|
|
6216
|
+
if (node.type === AST_NODE_TYPES28.ArrayExpression) {
|
|
6815
6217
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6816
6218
|
}
|
|
6817
|
-
if (node.type ===
|
|
6219
|
+
if (node.type === AST_NODE_TYPES28.ObjectExpression) {
|
|
6818
6220
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6819
6221
|
}
|
|
6820
|
-
if (node.type ===
|
|
6222
|
+
if (node.type === AST_NODE_TYPES28.NewExpression && node.callee.type === AST_NODE_TYPES28.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6821
6223
|
const arg = node.arguments[0];
|
|
6822
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
6224
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES28.SpreadElement) {
|
|
6823
6225
|
return null;
|
|
6824
6226
|
}
|
|
6825
6227
|
const entries = unwrap4(arg);
|
|
6826
|
-
if (entries.type !==
|
|
6228
|
+
if (entries.type !== AST_NODE_TYPES28.ArrayExpression) {
|
|
6827
6229
|
return null;
|
|
6828
6230
|
}
|
|
6829
6231
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6852,10 +6254,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6852
6254
|
);
|
|
6853
6255
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6854
6256
|
const callee = node.callee;
|
|
6855
|
-
if (callee.type ===
|
|
6257
|
+
if (callee.type === AST_NODE_TYPES28.Identifier && callee.name === "structuredClone") {
|
|
6856
6258
|
return true;
|
|
6857
6259
|
}
|
|
6858
|
-
if (callee.type !==
|
|
6260
|
+
if (callee.type !== AST_NODE_TYPES28.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES28.Identifier || callee.property.type !== AST_NODE_TYPES28.Identifier) {
|
|
6859
6261
|
return false;
|
|
6860
6262
|
}
|
|
6861
6263
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6869,43 +6271,43 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6869
6271
|
}
|
|
6870
6272
|
function isSafeRead(identifier) {
|
|
6871
6273
|
const parent = identifier.parent;
|
|
6872
|
-
if (parent.type ===
|
|
6274
|
+
if (parent.type === AST_NODE_TYPES28.MemberExpression) {
|
|
6873
6275
|
if (parent.object !== identifier) {
|
|
6874
6276
|
return true;
|
|
6875
6277
|
}
|
|
6876
6278
|
const grandparent = parent.parent;
|
|
6877
|
-
if (grandparent.type ===
|
|
6279
|
+
if (grandparent.type === AST_NODE_TYPES28.AssignmentExpression && grandparent.left === parent) {
|
|
6878
6280
|
return false;
|
|
6879
6281
|
}
|
|
6880
|
-
if (grandparent.type ===
|
|
6282
|
+
if (grandparent.type === AST_NODE_TYPES28.UpdateExpression) {
|
|
6881
6283
|
return false;
|
|
6882
6284
|
}
|
|
6883
|
-
if (grandparent.type ===
|
|
6285
|
+
if (grandparent.type === AST_NODE_TYPES28.UnaryExpression && grandparent.operator === "delete") {
|
|
6884
6286
|
return false;
|
|
6885
6287
|
}
|
|
6886
|
-
if (!parent.computed && parent.property.type ===
|
|
6288
|
+
if (!parent.computed && parent.property.type === AST_NODE_TYPES28.Identifier && MUTATING_METHODS.has(parent.property.name) && grandparent.type === AST_NODE_TYPES28.CallExpression && grandparent.callee === parent) {
|
|
6887
6289
|
return false;
|
|
6888
6290
|
}
|
|
6889
6291
|
return true;
|
|
6890
6292
|
}
|
|
6891
|
-
if (parent.type ===
|
|
6293
|
+
if (parent.type === AST_NODE_TYPES28.ForOfStatement && parent.right === identifier) {
|
|
6892
6294
|
return true;
|
|
6893
6295
|
}
|
|
6894
|
-
if (parent.type ===
|
|
6296
|
+
if (parent.type === AST_NODE_TYPES28.SpreadElement) {
|
|
6895
6297
|
return true;
|
|
6896
6298
|
}
|
|
6897
|
-
if (parent.type ===
|
|
6299
|
+
if (parent.type === AST_NODE_TYPES28.BinaryExpression) {
|
|
6898
6300
|
return true;
|
|
6899
6301
|
}
|
|
6900
|
-
if (parent.type ===
|
|
6302
|
+
if (parent.type === AST_NODE_TYPES28.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6901
6303
|
return true;
|
|
6902
6304
|
}
|
|
6903
|
-
if (parent.type ===
|
|
6305
|
+
if (parent.type === AST_NODE_TYPES28.UnaryExpression && parent.operator !== "delete") {
|
|
6904
6306
|
return true;
|
|
6905
6307
|
}
|
|
6906
6308
|
return false;
|
|
6907
6309
|
}
|
|
6908
|
-
var prefer_module_level_constant_default =
|
|
6310
|
+
var prefer_module_level_constant_default = ESLintUtils40.RuleCreator(
|
|
6909
6311
|
(name) => `https://github.com/sarj-ai/linting/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
6910
6312
|
)({
|
|
6911
6313
|
name: "prefer-module-level-constant",
|
|
@@ -6957,7 +6359,7 @@ var prefer_module_level_constant_default = ESLintUtils45.RuleCreator(
|
|
|
6957
6359
|
if (reference.isWrite()) {
|
|
6958
6360
|
return false;
|
|
6959
6361
|
}
|
|
6960
|
-
if (reference.identifier.type !==
|
|
6362
|
+
if (reference.identifier.type !== AST_NODE_TYPES28.Identifier) {
|
|
6961
6363
|
return false;
|
|
6962
6364
|
}
|
|
6963
6365
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6969,10 +6371,10 @@ var prefer_module_level_constant_default = ESLintUtils45.RuleCreator(
|
|
|
6969
6371
|
return {
|
|
6970
6372
|
VariableDeclarator(node) {
|
|
6971
6373
|
const declaration = node.parent;
|
|
6972
|
-
if (declaration.type !==
|
|
6374
|
+
if (declaration.type !== AST_NODE_TYPES28.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6973
6375
|
return;
|
|
6974
6376
|
}
|
|
6975
|
-
if (node.id.type !==
|
|
6377
|
+
if (node.id.type !== AST_NODE_TYPES28.Identifier || node.init === null) {
|
|
6976
6378
|
return;
|
|
6977
6379
|
}
|
|
6978
6380
|
if (enclosingFunction2(node) === null) {
|
|
@@ -6999,7 +6401,7 @@ var prefer_module_level_constant_default = ESLintUtils45.RuleCreator(
|
|
|
6999
6401
|
});
|
|
7000
6402
|
|
|
7001
6403
|
// src/rules/jsdoc-restates-signature.ts
|
|
7002
|
-
import { AST_NODE_TYPES as
|
|
6404
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES29, ESLintUtils as ESLintUtils41 } from "@typescript-eslint/utils";
|
|
7003
6405
|
var VALUE_TAGS = /* @__PURE__ */ new Set([
|
|
7004
6406
|
"alpha",
|
|
7005
6407
|
"author",
|
|
@@ -7082,30 +6484,30 @@ function declarationNames(node) {
|
|
|
7082
6484
|
switch (node.type) {
|
|
7083
6485
|
// `export function f()` — the JSDoc sits above the `export`, so the token
|
|
7084
6486
|
// after it resolves to the wrapper, not to the thing being documented.
|
|
7085
|
-
case
|
|
7086
|
-
case
|
|
6487
|
+
case AST_NODE_TYPES29.ExportNamedDeclaration:
|
|
6488
|
+
case AST_NODE_TYPES29.ExportDefaultDeclaration:
|
|
7087
6489
|
return node.declaration == null ? null : declarationNames(node.declaration);
|
|
7088
|
-
case
|
|
7089
|
-
case
|
|
6490
|
+
case AST_NODE_TYPES29.FunctionDeclaration:
|
|
6491
|
+
case AST_NODE_TYPES29.TSDeclareFunction:
|
|
7090
6492
|
return node.id === null ? null : { name: node.id.name, params: paramNames(node.params) };
|
|
7091
|
-
case
|
|
7092
|
-
case
|
|
7093
|
-
case
|
|
7094
|
-
case
|
|
6493
|
+
case AST_NODE_TYPES29.ClassDeclaration:
|
|
6494
|
+
case AST_NODE_TYPES29.TSInterfaceDeclaration:
|
|
6495
|
+
case AST_NODE_TYPES29.TSTypeAliasDeclaration:
|
|
6496
|
+
case AST_NODE_TYPES29.TSEnumDeclaration:
|
|
7095
6497
|
return node.id === null ? null : { name: node.id.name, params: [] };
|
|
7096
|
-
case
|
|
6498
|
+
case AST_NODE_TYPES29.VariableDeclaration: {
|
|
7097
6499
|
const declarator = node.declarations[0];
|
|
7098
|
-
if (declarator === void 0 || declarator.id.type !==
|
|
6500
|
+
if (declarator === void 0 || declarator.id.type !== AST_NODE_TYPES29.Identifier) return null;
|
|
7099
6501
|
const init = declarator.init;
|
|
7100
|
-
const params = init != null && (init.type ===
|
|
6502
|
+
const params = init != null && (init.type === AST_NODE_TYPES29.ArrowFunctionExpression || init.type === AST_NODE_TYPES29.FunctionExpression) ? paramNames(init.params) : [];
|
|
7101
6503
|
return { name: declarator.id.name, params };
|
|
7102
6504
|
}
|
|
7103
|
-
case
|
|
7104
|
-
case
|
|
7105
|
-
case
|
|
7106
|
-
case
|
|
7107
|
-
if (node.key.type !==
|
|
7108
|
-
const params = node.type ===
|
|
6505
|
+
case AST_NODE_TYPES29.MethodDefinition:
|
|
6506
|
+
case AST_NODE_TYPES29.PropertyDefinition:
|
|
6507
|
+
case AST_NODE_TYPES29.TSMethodSignature:
|
|
6508
|
+
case AST_NODE_TYPES29.TSPropertySignature: {
|
|
6509
|
+
if (node.key.type !== AST_NODE_TYPES29.Identifier) return null;
|
|
6510
|
+
const params = node.type === AST_NODE_TYPES29.MethodDefinition ? paramNames(node.value.params) : node.type === AST_NODE_TYPES29.TSMethodSignature ? paramNames(node.params) : [];
|
|
7109
6511
|
return { name: node.key.name, params };
|
|
7110
6512
|
}
|
|
7111
6513
|
default:
|
|
@@ -7115,9 +6517,9 @@ function declarationNames(node) {
|
|
|
7115
6517
|
function paramNames(params) {
|
|
7116
6518
|
const names = [];
|
|
7117
6519
|
for (const param of params) {
|
|
7118
|
-
const target = param.type ===
|
|
7119
|
-
if (target.type ===
|
|
7120
|
-
else if (target.type ===
|
|
6520
|
+
const target = param.type === AST_NODE_TYPES29.AssignmentPattern ? param.left : param;
|
|
6521
|
+
if (target.type === AST_NODE_TYPES29.Identifier) names.push(target.name);
|
|
6522
|
+
else if (target.type === AST_NODE_TYPES29.TSParameterProperty) continue;
|
|
7121
6523
|
}
|
|
7122
6524
|
return names;
|
|
7123
6525
|
}
|
|
@@ -7126,7 +6528,7 @@ function tokensOf(names) {
|
|
|
7126
6528
|
for (const name of names) for (const part of splitIdentifier(name)) tokens.add(part);
|
|
7127
6529
|
return tokens;
|
|
7128
6530
|
}
|
|
7129
|
-
var jsdoc_restates_signature_default =
|
|
6531
|
+
var jsdoc_restates_signature_default = ESLintUtils41.RuleCreator(
|
|
7130
6532
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7131
6533
|
)({
|
|
7132
6534
|
name: "jsdoc-restates-signature",
|
|
@@ -7162,7 +6564,7 @@ var jsdoc_restates_signature_default = ESLintUtils46.RuleCreator(
|
|
|
7162
6564
|
if (token === null || token.loc.start.line !== comment.loc.end.line + 1) continue;
|
|
7163
6565
|
let node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
|
7164
6566
|
let declaration = null;
|
|
7165
|
-
while (node != null && node.type !==
|
|
6567
|
+
while (node != null && node.type !== AST_NODE_TYPES29.Program) {
|
|
7166
6568
|
declaration = declarationNames(node);
|
|
7167
6569
|
if (declaration !== null) break;
|
|
7168
6570
|
node = node.parent ?? null;
|
|
@@ -7217,7 +6619,7 @@ var jsdoc_restates_signature_default = ESLintUtils46.RuleCreator(
|
|
|
7217
6619
|
});
|
|
7218
6620
|
|
|
7219
6621
|
// src/rules/no-restated-comment.ts
|
|
7220
|
-
import { AST_NODE_TYPES as
|
|
6622
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES30, ESLintUtils as ESLintUtils42 } from "@typescript-eslint/utils";
|
|
7221
6623
|
var MAX_WORDS = 8;
|
|
7222
6624
|
var MIN_CONTENT_TOKENS = 2;
|
|
7223
6625
|
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 +6643,7 @@ function headsSiblingRun(node) {
|
|
|
7241
6643
|
const next = index >= 0 ? body[index + 1] : void 0;
|
|
7242
6644
|
return next !== void 0 && next.type === node.type;
|
|
7243
6645
|
}
|
|
7244
|
-
var no_restated_comment_default =
|
|
6646
|
+
var no_restated_comment_default = ESLintUtils42.RuleCreator(
|
|
7245
6647
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7246
6648
|
)({
|
|
7247
6649
|
name: "no-restated-comment",
|
|
@@ -7269,7 +6671,7 @@ var no_restated_comment_default = ESLintUtils47.RuleCreator(
|
|
|
7269
6671
|
function labelsASiblingRun(comment) {
|
|
7270
6672
|
const token = sourceCode.getTokenAfter(comment, { includeComments: false });
|
|
7271
6673
|
if (token === null) return false;
|
|
7272
|
-
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !==
|
|
6674
|
+
for (let node = sourceCode.getNodeByRangeIndex(token.range[0]); node != null && node.type !== AST_NODE_TYPES30.Program; node = node.parent) {
|
|
7273
6675
|
if (headsSiblingRun(node)) return true;
|
|
7274
6676
|
}
|
|
7275
6677
|
return false;
|
|
@@ -7309,7 +6711,7 @@ var no_restated_comment_default = ESLintUtils47.RuleCreator(
|
|
|
7309
6711
|
});
|
|
7310
6712
|
|
|
7311
6713
|
// src/rules/trailing-value-narration.ts
|
|
7312
|
-
import { ESLintUtils as
|
|
6714
|
+
import { ESLintUtils as ESLintUtils43 } from "@typescript-eslint/utils";
|
|
7313
6715
|
var NUMBER_RE = /(?<![\w.])(\d+(?:\.\d+)?)(?![\w.])/g;
|
|
7314
6716
|
var WORD_RE3 = /[A-Za-z]+(?:'[a-z]+)?|\d+(?:\.\d+)?/g;
|
|
7315
6717
|
var UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
@@ -7393,7 +6795,7 @@ function narratesValue(body, code) {
|
|
|
7393
6795
|
(word) => STOPWORDS3.has(word) || UNIT_WORDS.has(word) || commentNumbers.has(word) || identifiers.has(word) || stems.has(stem(word))
|
|
7394
6796
|
);
|
|
7395
6797
|
}
|
|
7396
|
-
var trailing_value_narration_default =
|
|
6798
|
+
var trailing_value_narration_default = ESLintUtils43.RuleCreator(
|
|
7397
6799
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7398
6800
|
)({
|
|
7399
6801
|
name: "trailing-value-narration",
|
|
@@ -7434,7 +6836,7 @@ var trailing_value_narration_default = ESLintUtils48.RuleCreator(
|
|
|
7434
6836
|
});
|
|
7435
6837
|
|
|
7436
6838
|
// src/rules/no-tautological-expect.ts
|
|
7437
|
-
import { AST_NODE_TYPES as
|
|
6839
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES31, ESLintUtils as ESLintUtils44 } from "@typescript-eslint/utils";
|
|
7438
6840
|
var EQUALITY_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
7439
6841
|
var ZERO_ARG_MATCHERS = /* @__PURE__ */ new Set([
|
|
7440
6842
|
"toBeDefined",
|
|
@@ -7448,17 +6850,17 @@ var OPERAND_PREVIEW_CHARS = 40;
|
|
|
7448
6850
|
var NUMERIC_SIGNS = /* @__PURE__ */ new Set(["-", "+"]);
|
|
7449
6851
|
function isLiteral(node) {
|
|
7450
6852
|
switch (node.type) {
|
|
7451
|
-
case
|
|
6853
|
+
case AST_NODE_TYPES31.Literal:
|
|
7452
6854
|
return true;
|
|
7453
|
-
case
|
|
6855
|
+
case AST_NODE_TYPES31.TemplateLiteral:
|
|
7454
6856
|
return node.expressions.length === 0;
|
|
7455
|
-
case
|
|
6857
|
+
case AST_NODE_TYPES31.UnaryExpression:
|
|
7456
6858
|
return NUMERIC_SIGNS.has(node.operator) && isLiteral(node.argument);
|
|
7457
|
-
case
|
|
6859
|
+
case AST_NODE_TYPES31.ArrayExpression:
|
|
7458
6860
|
return node.elements.every((element) => element !== null && isLiteral(element));
|
|
7459
|
-
case
|
|
6861
|
+
case AST_NODE_TYPES31.ObjectExpression:
|
|
7460
6862
|
return node.properties.every(
|
|
7461
|
-
(property) => property.type ===
|
|
6863
|
+
(property) => property.type === AST_NODE_TYPES31.Property && !property.computed && isLiteral(property.value)
|
|
7462
6864
|
);
|
|
7463
6865
|
default:
|
|
7464
6866
|
return false;
|
|
@@ -7466,12 +6868,12 @@ function isLiteral(node) {
|
|
|
7466
6868
|
}
|
|
7467
6869
|
function expectOperand(callee) {
|
|
7468
6870
|
const receiver = callee.object;
|
|
7469
|
-
if (receiver.type !==
|
|
6871
|
+
if (receiver.type !== AST_NODE_TYPES31.CallExpression || receiver.callee.type !== AST_NODE_TYPES31.Identifier || receiver.callee.name !== "expect" || receiver.arguments.length !== 1) {
|
|
7470
6872
|
return null;
|
|
7471
6873
|
}
|
|
7472
6874
|
return receiver.arguments[0] ?? null;
|
|
7473
6875
|
}
|
|
7474
|
-
var no_tautological_expect_default =
|
|
6876
|
+
var no_tautological_expect_default = ESLintUtils44.RuleCreator(
|
|
7475
6877
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7476
6878
|
)({
|
|
7477
6879
|
name: "no-tautological-expect",
|
|
@@ -7498,10 +6900,10 @@ var no_tautological_expect_default = ESLintUtils49.RuleCreator(
|
|
|
7498
6900
|
return {
|
|
7499
6901
|
CallExpression(node) {
|
|
7500
6902
|
const callee = node.callee;
|
|
7501
|
-
if (callee.type !==
|
|
6903
|
+
if (callee.type !== AST_NODE_TYPES31.MemberExpression || callee.computed) {
|
|
7502
6904
|
return;
|
|
7503
6905
|
}
|
|
7504
|
-
if (callee.property.type !==
|
|
6906
|
+
if (callee.property.type !== AST_NODE_TYPES31.Identifier) {
|
|
7505
6907
|
return;
|
|
7506
6908
|
}
|
|
7507
6909
|
const matcher = callee.property.name;
|
|
@@ -7535,26 +6937,26 @@ var no_tautological_expect_default = ESLintUtils49.RuleCreator(
|
|
|
7535
6937
|
});
|
|
7536
6938
|
|
|
7537
6939
|
// src/rules/require-interface-for-injected-service.ts
|
|
7538
|
-
import { AST_NODE_TYPES as
|
|
6940
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES32, ESLintUtils as ESLintUtils45 } from "@typescript-eslint/utils";
|
|
7539
6941
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
7540
6942
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
7541
6943
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
7542
6944
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
7543
6945
|
var ROUTER_FACTORY_NAME = "Router";
|
|
7544
6946
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
7545
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
7546
|
-
var qualifiedName = (name) => name.type ===
|
|
6947
|
+
var isExportedClass = (node) => node.parent.type === AST_NODE_TYPES32.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES32.ExportDefaultDeclaration;
|
|
6948
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES32.Identifier ? name.name : name.type === AST_NODE_TYPES32.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
7547
6949
|
var typeReferenceName = (annotated) => {
|
|
7548
6950
|
let target = annotated;
|
|
7549
|
-
if (target.type ===
|
|
7550
|
-
if (target.type ===
|
|
7551
|
-
if (target.type !==
|
|
6951
|
+
if (target.type === AST_NODE_TYPES32.TSParameterProperty) target = target.parameter;
|
|
6952
|
+
if (target.type === AST_NODE_TYPES32.AssignmentPattern) target = target.left;
|
|
6953
|
+
if (target.type !== AST_NODE_TYPES32.Identifier) return null;
|
|
7552
6954
|
const annotation = target.typeAnnotation?.typeAnnotation;
|
|
7553
|
-
if (annotation === void 0 || annotation.type !==
|
|
6955
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES32.TSTypeReference) {
|
|
7554
6956
|
return null;
|
|
7555
6957
|
}
|
|
7556
6958
|
const { typeName } = annotation;
|
|
7557
|
-
const rightmost = typeName.type ===
|
|
6959
|
+
const rightmost = typeName.type === AST_NODE_TYPES32.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES32.TSQualifiedName ? typeName.right.name : null;
|
|
7558
6960
|
if (rightmost === null) return null;
|
|
7559
6961
|
return { name: target.name, typeName: rightmost, display: qualifiedName(typeName) };
|
|
7560
6962
|
};
|
|
@@ -7564,17 +6966,17 @@ var readConstructor = (ctor) => {
|
|
|
7564
6966
|
let constructedFields = 0;
|
|
7565
6967
|
if (body !== null && body !== void 0) {
|
|
7566
6968
|
for (const statement of body.body) {
|
|
7567
|
-
if (statement.type !==
|
|
6969
|
+
if (statement.type !== AST_NODE_TYPES32.ExpressionStatement) continue;
|
|
7568
6970
|
const expression = statement.expression;
|
|
7569
|
-
if (expression.type !==
|
|
6971
|
+
if (expression.type !== AST_NODE_TYPES32.AssignmentExpression || expression.operator !== "=" || expression.left.type !== AST_NODE_TYPES32.MemberExpression || expression.left.object.type !== AST_NODE_TYPES32.ThisExpression) {
|
|
7570
6972
|
continue;
|
|
7571
6973
|
}
|
|
7572
6974
|
const source = expression.right;
|
|
7573
|
-
if (source.type ===
|
|
6975
|
+
if (source.type === AST_NODE_TYPES32.NewExpression) {
|
|
7574
6976
|
constructedFields += 1;
|
|
7575
|
-
} else if (source.type ===
|
|
6977
|
+
} else if (source.type === AST_NODE_TYPES32.Identifier) {
|
|
7576
6978
|
storedFrom.add(source.name);
|
|
7577
|
-
} else if (source.type ===
|
|
6979
|
+
} else if (source.type === AST_NODE_TYPES32.MemberExpression && source.object.type === AST_NODE_TYPES32.Identifier) {
|
|
7578
6980
|
storedFrom.add(source.object.name);
|
|
7579
6981
|
}
|
|
7580
6982
|
}
|
|
@@ -7583,7 +6985,7 @@ var readConstructor = (ctor) => {
|
|
|
7583
6985
|
for (const parameter of ctor.value.params) {
|
|
7584
6986
|
const reference = typeReferenceName(parameter);
|
|
7585
6987
|
if (reference === null) continue;
|
|
7586
|
-
const stored = parameter.type ===
|
|
6988
|
+
const stored = parameter.type === AST_NODE_TYPES32.TSParameterProperty || storedFrom.has(reference.name);
|
|
7587
6989
|
if (!stored) continue;
|
|
7588
6990
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
7589
6991
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -7613,19 +7015,19 @@ var subtreeHas = (root, found) => {
|
|
|
7613
7015
|
return hit;
|
|
7614
7016
|
};
|
|
7615
7017
|
var isFrameworkWiring = (body) => subtreeHas(body, (node) => {
|
|
7616
|
-
if (node.type ===
|
|
7018
|
+
if (node.type === AST_NODE_TYPES32.CallExpression) {
|
|
7617
7019
|
const { callee } = node;
|
|
7618
|
-
if (callee.type ===
|
|
7619
|
-
return callee.type ===
|
|
7020
|
+
if (callee.type === AST_NODE_TYPES32.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
7021
|
+
return callee.type === AST_NODE_TYPES32.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES32.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
7620
7022
|
}
|
|
7621
|
-
return node.type ===
|
|
7023
|
+
return node.type === AST_NODE_TYPES32.TSTypeReference && node.typeName.type === AST_NODE_TYPES32.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
7622
7024
|
});
|
|
7623
7025
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
7624
7026
|
var fileInterfaceNames = (program) => {
|
|
7625
7027
|
const names = [];
|
|
7626
7028
|
for (const statement of program.body) {
|
|
7627
|
-
const declaration = statement.type ===
|
|
7628
|
-
if (declaration?.type ===
|
|
7029
|
+
const declaration = statement.type === AST_NODE_TYPES32.ExportNamedDeclaration ? statement.declaration : statement;
|
|
7030
|
+
if (declaration?.type === AST_NODE_TYPES32.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
7629
7031
|
}
|
|
7630
7032
|
return names;
|
|
7631
7033
|
};
|
|
@@ -7643,16 +7045,16 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
7643
7045
|
var publicMethodNames = (body) => {
|
|
7644
7046
|
const names = [];
|
|
7645
7047
|
for (const member of body.body) {
|
|
7646
|
-
if (member.type !==
|
|
7048
|
+
if (member.type !== AST_NODE_TYPES32.MethodDefinition) continue;
|
|
7647
7049
|
if (member.kind !== "method" || member.static) continue;
|
|
7648
7050
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
7649
|
-
if (member.key.type ===
|
|
7650
|
-
if (member.key.type ===
|
|
7051
|
+
if (member.key.type === AST_NODE_TYPES32.PrivateIdentifier) continue;
|
|
7052
|
+
if (member.key.type === AST_NODE_TYPES32.Identifier) names.push(member.key.name);
|
|
7651
7053
|
else names.push("\u2026");
|
|
7652
7054
|
}
|
|
7653
7055
|
return names;
|
|
7654
7056
|
};
|
|
7655
|
-
var require_interface_for_injected_service_default =
|
|
7057
|
+
var require_interface_for_injected_service_default = ESLintUtils45.RuleCreator(
|
|
7656
7058
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7657
7059
|
)({
|
|
7658
7060
|
name: "require-interface-for-injected-service",
|
|
@@ -7680,7 +7082,7 @@ var require_interface_for_injected_service_default = ESLintUtils50.RuleCreator(
|
|
|
7680
7082
|
if (node.implements.length > 0) return;
|
|
7681
7083
|
if (node.decorators.length > 0) return;
|
|
7682
7084
|
const ctor = node.body.body.find(
|
|
7683
|
-
(member) => member.type ===
|
|
7085
|
+
(member) => member.type === AST_NODE_TYPES32.MethodDefinition && member.kind === "constructor"
|
|
7684
7086
|
);
|
|
7685
7087
|
if (ctor === void 0) return;
|
|
7686
7088
|
const { collaborators, constructedFields } = readConstructor(ctor);
|
|
@@ -7705,26 +7107,26 @@ var require_interface_for_injected_service_default = ESLintUtils50.RuleCreator(
|
|
|
7705
7107
|
});
|
|
7706
7108
|
|
|
7707
7109
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7708
|
-
import { AST_NODE_TYPES as
|
|
7110
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES33, ESLintUtils as ESLintUtils46 } from "@typescript-eslint/utils";
|
|
7709
7111
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7710
7112
|
function propertyName(node) {
|
|
7711
7113
|
const key = node.key;
|
|
7712
|
-
if (key.type ===
|
|
7713
|
-
if (key.type ===
|
|
7114
|
+
if (key.type === AST_NODE_TYPES33.Identifier) return key.name;
|
|
7115
|
+
if (key.type === AST_NODE_TYPES33.Literal) return String(key.value);
|
|
7714
7116
|
return "collection";
|
|
7715
7117
|
}
|
|
7716
7118
|
function isArrayType(node) {
|
|
7717
|
-
if (node.type ===
|
|
7718
|
-
return node.type ===
|
|
7119
|
+
if (node.type === AST_NODE_TYPES33.TSArrayType) return true;
|
|
7120
|
+
return node.type === AST_NODE_TYPES33.TSTypeReference && node.typeName.type === AST_NODE_TYPES33.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7719
7121
|
}
|
|
7720
7122
|
function isNullishType(node) {
|
|
7721
|
-
return node.type ===
|
|
7123
|
+
return node.type === AST_NODE_TYPES33.TSNullKeyword || node.type === AST_NODE_TYPES33.TSUndefinedKeyword;
|
|
7722
7124
|
}
|
|
7723
7125
|
function isNullableArrayOnly(node) {
|
|
7724
7126
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
7725
7127
|
return values.length > 0 && values.length < node.types.length && values.every(isArrayType);
|
|
7726
7128
|
}
|
|
7727
|
-
var prefer_non_nullable_collection_default =
|
|
7129
|
+
var prefer_non_nullable_collection_default = ESLintUtils46.RuleCreator(
|
|
7728
7130
|
(name) => `https://github.com/sarj-ai/standards/tree/main/packages/typescript#${name}`
|
|
7729
7131
|
)({
|
|
7730
7132
|
name: "prefer-non-nullable-collection",
|
|
@@ -7747,7 +7149,7 @@ var prefer_non_nullable_collection_default = ESLintUtils51.RuleCreator(
|
|
|
7747
7149
|
function checkOptionalProperty(node) {
|
|
7748
7150
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7749
7151
|
if (annotation === void 0) return;
|
|
7750
|
-
if (annotation.type !==
|
|
7152
|
+
if (annotation.type !== AST_NODE_TYPES33.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7751
7153
|
return;
|
|
7752
7154
|
}
|
|
7753
7155
|
context.report({
|
|
@@ -7760,7 +7162,7 @@ var prefer_non_nullable_collection_default = ESLintUtils51.RuleCreator(
|
|
|
7760
7162
|
TSPropertySignature: checkOptionalProperty,
|
|
7761
7163
|
PropertyDefinition: checkOptionalProperty,
|
|
7762
7164
|
TSTypeAliasDeclaration(node) {
|
|
7763
|
-
if (node.typeAnnotation.type !==
|
|
7165
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES33.TSUnionType) return;
|
|
7764
7166
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7765
7167
|
context.report({
|
|
7766
7168
|
node,
|
|
@@ -7773,41 +7175,41 @@ var prefer_non_nullable_collection_default = ESLintUtils51.RuleCreator(
|
|
|
7773
7175
|
});
|
|
7774
7176
|
|
|
7775
7177
|
// src/rules/primary-export-file-name.ts
|
|
7776
|
-
import { AST_NODE_TYPES as
|
|
7777
|
-
var
|
|
7178
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES34, ESLintUtils as ESLintUtils47 } from "@typescript-eslint/utils";
|
|
7179
|
+
var CONVENTIONAL_BUCKET_EXPORTS = /* @__PURE__ */ new Set(["cn"]);
|
|
7778
7180
|
var GENERIC_ENTRYPOINTS = /* @__PURE__ */ new Set(["main", "run", "cli", "setup", "teardown", "execute"]);
|
|
7779
|
-
var
|
|
7181
|
+
var ACRONYM_OVERRIDES = [
|
|
7780
7182
|
[/OAuth/g, "Oauth"],
|
|
7781
7183
|
[/GraphQL/g, "Graphql"],
|
|
7782
7184
|
[/gRPC/g, "Grpc"]
|
|
7783
7185
|
];
|
|
7784
|
-
var
|
|
7785
|
-
var
|
|
7786
|
-
var
|
|
7787
|
-
var
|
|
7186
|
+
var CAMEL_BOUNDARY_RE = /(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g;
|
|
7187
|
+
var basename = (filename) => filename.split(/[/\\]/).pop() ?? filename;
|
|
7188
|
+
var stemOf = (base) => base.replace(/\.(test|spec|config|d|stories)\.[cm]?[jt]sx?$/i, "").replace(/\.[cm]?[jt]sx?$/i, "");
|
|
7189
|
+
var kebabCase = (name) => {
|
|
7788
7190
|
let normalized = name;
|
|
7789
|
-
for (const [pattern, replacement] of
|
|
7191
|
+
for (const [pattern, replacement] of ACRONYM_OVERRIDES) {
|
|
7790
7192
|
normalized = normalized.replace(pattern, replacement);
|
|
7791
7193
|
}
|
|
7792
|
-
return normalized.replace(
|
|
7194
|
+
return normalized.replace(CAMEL_BOUNDARY_RE, "-").toLowerCase();
|
|
7793
7195
|
};
|
|
7794
|
-
var isFunctionOrClass = (node) => node.type ===
|
|
7196
|
+
var isFunctionOrClass = (node) => node.type === AST_NODE_TYPES34.ArrowFunctionExpression || node.type === AST_NODE_TYPES34.FunctionExpression;
|
|
7795
7197
|
var findPrimaryExport = (body) => {
|
|
7796
7198
|
let exportCount = 0;
|
|
7797
7199
|
let primaryCandidate = null;
|
|
7798
7200
|
for (const statement of body) {
|
|
7799
|
-
if (statement.type ===
|
|
7201
|
+
if (statement.type === AST_NODE_TYPES34.ExportAllDeclaration) {
|
|
7800
7202
|
return null;
|
|
7801
7203
|
}
|
|
7802
|
-
if (statement.type ===
|
|
7204
|
+
if (statement.type === AST_NODE_TYPES34.ExportDefaultDeclaration) {
|
|
7803
7205
|
exportCount += 1;
|
|
7804
7206
|
const decl = statement.declaration;
|
|
7805
|
-
if ((decl.type ===
|
|
7207
|
+
if ((decl.type === AST_NODE_TYPES34.FunctionDeclaration || decl.type === AST_NODE_TYPES34.ClassDeclaration) && decl.id !== null) {
|
|
7806
7208
|
primaryCandidate = { name: decl.id.name, node: statement, isDefault: true };
|
|
7807
|
-
} else if (decl.type ===
|
|
7209
|
+
} else if (decl.type === AST_NODE_TYPES34.Identifier) {
|
|
7808
7210
|
primaryCandidate = { name: decl.name, node: statement, isDefault: true };
|
|
7809
7211
|
}
|
|
7810
|
-
} else if (statement.type ===
|
|
7212
|
+
} else if (statement.type === AST_NODE_TYPES34.ExportNamedDeclaration) {
|
|
7811
7213
|
if (statement.source !== null) {
|
|
7812
7214
|
return null;
|
|
7813
7215
|
}
|
|
@@ -7816,27 +7218,27 @@ var findPrimaryExport = (body) => {
|
|
|
7816
7218
|
exportCount += statement.specifiers.length;
|
|
7817
7219
|
if (statement.specifiers.length === 1 && primaryCandidate === null) {
|
|
7818
7220
|
const spec = statement.specifiers[0];
|
|
7819
|
-
if (spec && spec.exported.type ===
|
|
7221
|
+
if (spec && spec.exported.type === AST_NODE_TYPES34.Identifier) {
|
|
7820
7222
|
primaryCandidate = { name: spec.exported.name, node: statement, isDefault: false };
|
|
7821
7223
|
}
|
|
7822
7224
|
}
|
|
7823
|
-
} else if (decl.type ===
|
|
7225
|
+
} else if (decl.type === AST_NODE_TYPES34.FunctionDeclaration || decl.type === AST_NODE_TYPES34.ClassDeclaration) {
|
|
7824
7226
|
if (decl.id !== null) {
|
|
7825
7227
|
exportCount += 1;
|
|
7826
7228
|
if (primaryCandidate === null) {
|
|
7827
7229
|
primaryCandidate = { name: decl.id.name, node: statement, isDefault: false };
|
|
7828
7230
|
}
|
|
7829
7231
|
}
|
|
7830
|
-
} else if (decl.type ===
|
|
7232
|
+
} else if (decl.type === AST_NODE_TYPES34.VariableDeclaration) {
|
|
7831
7233
|
for (const declarator of decl.declarations) {
|
|
7832
|
-
if (declarator.id.type ===
|
|
7234
|
+
if (declarator.id.type === AST_NODE_TYPES34.Identifier) {
|
|
7833
7235
|
exportCount += 1;
|
|
7834
7236
|
if (primaryCandidate === null && declarator.init && isFunctionOrClass(declarator.init)) {
|
|
7835
7237
|
primaryCandidate = { name: declarator.id.name, node: statement, isDefault: false };
|
|
7836
7238
|
}
|
|
7837
7239
|
}
|
|
7838
7240
|
}
|
|
7839
|
-
} else if (decl.type ===
|
|
7241
|
+
} else if (decl.type === AST_NODE_TYPES34.TSTypeAliasDeclaration || decl.type === AST_NODE_TYPES34.TSInterfaceDeclaration) {
|
|
7840
7242
|
exportCount += 1;
|
|
7841
7243
|
if (primaryCandidate === null) {
|
|
7842
7244
|
primaryCandidate = { name: decl.id.name, node: statement, isDefault: false };
|
|
@@ -7849,7 +7251,7 @@ var findPrimaryExport = (body) => {
|
|
|
7849
7251
|
}
|
|
7850
7252
|
return { ...primaryCandidate, count: exportCount };
|
|
7851
7253
|
};
|
|
7852
|
-
var primary_export_file_name_default =
|
|
7254
|
+
var primary_export_file_name_default = ESLintUtils47.RuleCreator(
|
|
7853
7255
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7854
7256
|
)({
|
|
7855
7257
|
name: "primary-export-file-name",
|
|
@@ -7865,10 +7267,10 @@ var primary_export_file_name_default = ESLintUtils52.RuleCreator(
|
|
|
7865
7267
|
},
|
|
7866
7268
|
defaultOptions: [],
|
|
7867
7269
|
create(context) {
|
|
7868
|
-
const base =
|
|
7270
|
+
const base = basename(context.filename);
|
|
7869
7271
|
if (base.endsWith(".d.ts") || base.startsWith("index.") || base.startsWith("_")) return {};
|
|
7870
7272
|
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) return {};
|
|
7871
|
-
const stem3 =
|
|
7273
|
+
const stem3 = stemOf(base);
|
|
7872
7274
|
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
7275
|
return {};
|
|
7874
7276
|
}
|
|
@@ -7876,8 +7278,8 @@ var primary_export_file_name_default = ESLintUtils52.RuleCreator(
|
|
|
7876
7278
|
Program(node) {
|
|
7877
7279
|
const primary = findPrimaryExport(node.body);
|
|
7878
7280
|
if (primary === null) return;
|
|
7879
|
-
if (
|
|
7880
|
-
const expectedStem =
|
|
7281
|
+
if (CONVENTIONAL_BUCKET_EXPORTS.has(primary.name) || GENERIC_ENTRYPOINTS.has(primary.name)) return;
|
|
7282
|
+
const expectedStem = kebabCase(primary.name);
|
|
7881
7283
|
if (stem3 === expectedStem) return;
|
|
7882
7284
|
const ext = base.endsWith(".tsx") ? ".tsx" : ".ts";
|
|
7883
7285
|
context.report({
|
|
@@ -7891,7 +7293,7 @@ var primary_export_file_name_default = ESLintUtils52.RuleCreator(
|
|
|
7891
7293
|
});
|
|
7892
7294
|
|
|
7893
7295
|
// src/rules/no-implicit-attribute-access.ts
|
|
7894
|
-
import { AST_NODE_TYPES as
|
|
7296
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35, ESLintUtils as ESLintUtils48 } from "@typescript-eslint/utils";
|
|
7895
7297
|
var EXCLUDED_BASES = /* @__PURE__ */ new Set([
|
|
7896
7298
|
"environ",
|
|
7897
7299
|
"headers",
|
|
@@ -7907,15 +7309,15 @@ var EXCLUDED_BASES = /* @__PURE__ */ new Set([
|
|
|
7907
7309
|
"sessionStorage"
|
|
7908
7310
|
]);
|
|
7909
7311
|
function getBaseName(node) {
|
|
7910
|
-
if (node.type ===
|
|
7312
|
+
if (node.type === AST_NODE_TYPES35.Identifier) {
|
|
7911
7313
|
return node.name;
|
|
7912
7314
|
}
|
|
7913
|
-
if (node.type ===
|
|
7315
|
+
if (node.type === AST_NODE_TYPES35.MemberExpression && node.property.type === AST_NODE_TYPES35.Identifier) {
|
|
7914
7316
|
return node.property.name;
|
|
7915
7317
|
}
|
|
7916
7318
|
return null;
|
|
7917
7319
|
}
|
|
7918
|
-
var no_implicit_attribute_access_default =
|
|
7320
|
+
var no_implicit_attribute_access_default = ESLintUtils48.RuleCreator(
|
|
7919
7321
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
7920
7322
|
)({
|
|
7921
7323
|
name: "no-implicit-attribute-access",
|
|
@@ -7936,7 +7338,7 @@ var no_implicit_attribute_access_default = ESLintUtils53.RuleCreator(
|
|
|
7936
7338
|
if (!node.computed) {
|
|
7937
7339
|
return;
|
|
7938
7340
|
}
|
|
7939
|
-
if (node.property.type ===
|
|
7341
|
+
if (node.property.type === AST_NODE_TYPES35.Literal && typeof node.property.value === "string") {
|
|
7940
7342
|
const baseName = getBaseName(node.object);
|
|
7941
7343
|
if (!baseName || !EXCLUDED_BASES.has(baseName)) {
|
|
7942
7344
|
context.report({
|
|
@@ -7949,11 +7351,11 @@ var no_implicit_attribute_access_default = ESLintUtils53.RuleCreator(
|
|
|
7949
7351
|
},
|
|
7950
7352
|
CallExpression(node) {
|
|
7951
7353
|
const callee = node.callee;
|
|
7952
|
-
if (callee.type ===
|
|
7953
|
-
const method = callee.property.type ===
|
|
7354
|
+
if (callee.type === AST_NODE_TYPES35.MemberExpression) {
|
|
7355
|
+
const method = callee.property.type === AST_NODE_TYPES35.Identifier ? callee.property.name : null;
|
|
7954
7356
|
if (method === "get") {
|
|
7955
7357
|
const arg = node.arguments[0];
|
|
7956
|
-
if (arg && arg.type ===
|
|
7358
|
+
if (arg && arg.type === AST_NODE_TYPES35.Literal && typeof arg.value === "string") {
|
|
7957
7359
|
const baseName = getBaseName(callee.object);
|
|
7958
7360
|
if (!baseName || !EXCLUDED_BASES.has(baseName)) {
|
|
7959
7361
|
context.report({
|
|
@@ -7971,8 +7373,8 @@ var no_implicit_attribute_access_default = ESLintUtils53.RuleCreator(
|
|
|
7971
7373
|
});
|
|
7972
7374
|
|
|
7973
7375
|
// src/rules/strict-test-assertions.ts
|
|
7974
|
-
import { AST_NODE_TYPES as
|
|
7975
|
-
var strict_test_assertions_default =
|
|
7376
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36, ESLintUtils as ESLintUtils49 } from "@typescript-eslint/utils";
|
|
7377
|
+
var strict_test_assertions_default = ESLintUtils49.RuleCreator.withoutDocs({
|
|
7976
7378
|
meta: {
|
|
7977
7379
|
type: "suggestion",
|
|
7978
7380
|
docs: {
|
|
@@ -7990,9 +7392,9 @@ var strict_test_assertions_default = ESLintUtils54.RuleCreator.withoutDocs({
|
|
|
7990
7392
|
let currentObject = null;
|
|
7991
7393
|
let sequence = [];
|
|
7992
7394
|
function getExpectObject(expr) {
|
|
7993
|
-
if (expr.type ===
|
|
7395
|
+
if (expr.type === AST_NODE_TYPES36.CallExpression && expr.callee.type === AST_NODE_TYPES36.MemberExpression && expr.callee.object.type === AST_NODE_TYPES36.CallExpression && expr.callee.object.callee.type === AST_NODE_TYPES36.Identifier && expr.callee.object.callee.name === "expect" && expr.callee.object.arguments.length === 1) {
|
|
7994
7396
|
const arg = expr.callee.object.arguments.at(0);
|
|
7995
|
-
if (arg?.type ===
|
|
7397
|
+
if (arg?.type === AST_NODE_TYPES36.MemberExpression) {
|
|
7996
7398
|
return arg.object;
|
|
7997
7399
|
}
|
|
7998
7400
|
}
|
|
@@ -8008,12 +7410,12 @@ var strict_test_assertions_default = ESLintUtils54.RuleCreator.withoutDocs({
|
|
|
8008
7410
|
if (!currentObject) return null;
|
|
8009
7411
|
const objectText = context.sourceCode.getText(currentObject);
|
|
8010
7412
|
const props = sequence.map((stmt) => {
|
|
8011
|
-
if (stmt.expression.type !==
|
|
7413
|
+
if (stmt.expression.type !== AST_NODE_TYPES36.CallExpression || stmt.expression.callee.type !== AST_NODE_TYPES36.MemberExpression || stmt.expression.callee.object.type !== AST_NODE_TYPES36.CallExpression) {
|
|
8012
7414
|
return null;
|
|
8013
7415
|
}
|
|
8014
7416
|
const actual = stmt.expression.callee.object.arguments.at(0);
|
|
8015
7417
|
const expected = stmt.expression.arguments.at(0);
|
|
8016
|
-
if (actual?.type ===
|
|
7418
|
+
if (actual?.type === AST_NODE_TYPES36.MemberExpression && actual.property.type === AST_NODE_TYPES36.Identifier && expected) {
|
|
8017
7419
|
const propName2 = actual.property.name;
|
|
8018
7420
|
const valText = context.sourceCode.getText(expected);
|
|
8019
7421
|
return `${propName2}: ${valText}`;
|
|
@@ -8031,7 +7433,7 @@ var strict_test_assertions_default = ESLintUtils54.RuleCreator.withoutDocs({
|
|
|
8031
7433
|
}
|
|
8032
7434
|
}
|
|
8033
7435
|
for (const statement of body) {
|
|
8034
|
-
if (statement.type ===
|
|
7436
|
+
if (statement.type === AST_NODE_TYPES36.ExpressionStatement) {
|
|
8035
7437
|
const obj = getExpectObject(statement.expression);
|
|
8036
7438
|
if (obj && currentObject && context.sourceCode.getText(obj) === context.sourceCode.getText(currentObject)) {
|
|
8037
7439
|
sequence.push(statement);
|
|
@@ -8065,8 +7467,8 @@ var strict_test_assertions_default = ESLintUtils54.RuleCreator.withoutDocs({
|
|
|
8065
7467
|
});
|
|
8066
7468
|
|
|
8067
7469
|
// src/rules/no-async-callback-in-waitfor.ts
|
|
8068
|
-
import { AST_NODE_TYPES as
|
|
8069
|
-
var no_async_callback_in_waitfor_default =
|
|
7470
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37, ESLintUtils as ESLintUtils50 } from "@typescript-eslint/utils";
|
|
7471
|
+
var no_async_callback_in_waitfor_default = ESLintUtils50.RuleCreator(
|
|
8070
7472
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
8071
7473
|
)({
|
|
8072
7474
|
name: "no-async-callback-in-waitfor",
|
|
@@ -8087,9 +7489,9 @@ var no_async_callback_in_waitfor_default = ESLintUtils55.RuleCreator(
|
|
|
8087
7489
|
}
|
|
8088
7490
|
return {
|
|
8089
7491
|
CallExpression(node) {
|
|
8090
|
-
if (node.callee.type ===
|
|
7492
|
+
if (node.callee.type === AST_NODE_TYPES37.Identifier && node.callee.name === "waitFor") {
|
|
8091
7493
|
const callback = node.arguments[0];
|
|
8092
|
-
if (callback && (callback.type ===
|
|
7494
|
+
if (callback && (callback.type === AST_NODE_TYPES37.ArrowFunctionExpression || callback.type === AST_NODE_TYPES37.FunctionExpression) && callback.async) {
|
|
8093
7495
|
context.report({
|
|
8094
7496
|
node: callback,
|
|
8095
7497
|
messageId: "noAsyncCallbackInWaitFor"
|
|
@@ -8102,8 +7504,8 @@ var no_async_callback_in_waitfor_default = ESLintUtils55.RuleCreator(
|
|
|
8102
7504
|
});
|
|
8103
7505
|
|
|
8104
7506
|
// src/rules/prefer-setup-file-mocks.ts
|
|
8105
|
-
import { AST_NODE_TYPES as
|
|
8106
|
-
var prefer_setup_file_mocks_default =
|
|
7507
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38, ESLintUtils as ESLintUtils51 } from "@typescript-eslint/utils";
|
|
7508
|
+
var prefer_setup_file_mocks_default = ESLintUtils51.RuleCreator(
|
|
8107
7509
|
(name) => `https://github.com/sarj-ai/standards/blob/main/packages/typescript/src/rules/${name}.ts`
|
|
8108
7510
|
)({
|
|
8109
7511
|
name: "prefer-setup-file-mocks",
|
|
@@ -8124,7 +7526,7 @@ var prefer_setup_file_mocks_default = ESLintUtils56.RuleCreator(
|
|
|
8124
7526
|
}
|
|
8125
7527
|
return {
|
|
8126
7528
|
CallExpression(node) {
|
|
8127
|
-
if (node.callee.type ===
|
|
7529
|
+
if (node.callee.type === AST_NODE_TYPES38.MemberExpression && node.callee.object.type === AST_NODE_TYPES38.Identifier && (node.callee.object.name === "vi" || node.callee.object.name === "jest") && node.callee.property.type === AST_NODE_TYPES38.Identifier && node.callee.property.name === "mock") {
|
|
8128
7530
|
context.report({
|
|
8129
7531
|
node,
|
|
8130
7532
|
messageId: "preferSetupFileMocks"
|
|
@@ -8147,29 +7549,24 @@ var rules = {
|
|
|
8147
7549
|
"no-log-only-catch": no_log_only_catch_default,
|
|
8148
7550
|
"no-raw-env": no_raw_env_default,
|
|
8149
7551
|
"no-sentinel-return-on-catch": no_sentinel_return_on_catch_default,
|
|
8150
|
-
"no-sequential-await": no_sequential_await_default,
|
|
8151
7552
|
"no-string-concat-in-loop": no_string_concat_in_loop_default,
|
|
8152
7553
|
"no-unnecessary-use-client": no_unnecessary_use_client_default,
|
|
8153
7554
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
8154
7555
|
"prefer-schema-for-api-payload": prefer_schema_for_api_payload_default,
|
|
8155
7556
|
"prefer-semantic-colors": prefer_semantic_colors_default,
|
|
8156
7557
|
"prefer-server-actions": prefer_server_actions_default,
|
|
8157
|
-
"prefer-shadcn": prefer_shadcn_default,
|
|
8158
7558
|
"require-assert-never": require_assert_never_default,
|
|
8159
7559
|
"require-zod-form-validation": require_zod_form_validation_default,
|
|
8160
7560
|
"zod-naming-convention": zod_naming_convention_default,
|
|
8161
7561
|
"no-cors-wildcard-with-credentials": no_cors_wildcard_with_credentials_default,
|
|
8162
7562
|
"no-fat-try-blocks": no_fat_try_blocks_default,
|
|
8163
7563
|
"no-secret-in-log": no_secret_in_log_default,
|
|
8164
|
-
"no-unsafe-cast": no_unsafe_cast_default,
|
|
8165
7564
|
"no-unsafe-mock-casting": no_unsafe_mock_casting_default,
|
|
8166
7565
|
"prefer-string-literal-union": prefer_string_literal_union_default,
|
|
8167
7566
|
"prefer-zod-enum": prefer_zod_enum_default,
|
|
8168
|
-
"single-public-export": single_public_export_default,
|
|
8169
7567
|
"primary-export-file-name": primary_export_file_name_default,
|
|
8170
7568
|
"no-silent-promise-catch": no_silent_promise_catch_default,
|
|
8171
7569
|
"require-fetch-timeout": require_fetch_timeout_default,
|
|
8172
|
-
"require-schema-validate-search": require_schema_validate_search_default,
|
|
8173
7570
|
"no-offset-pagination": no_offset_pagination_default,
|
|
8174
7571
|
"no-positional-tuple-return": no_positional_tuple_return_default,
|
|
8175
7572
|
"no-repeated-string-literal": no_repeated_string_literal_default,
|
|
@@ -8197,7 +7594,7 @@ var rules = {
|
|
|
8197
7594
|
var plugin = {
|
|
8198
7595
|
meta: {
|
|
8199
7596
|
name: "@sarj/eslint-plugin",
|
|
8200
|
-
version: "
|
|
7597
|
+
version: "3.0.0"
|
|
8201
7598
|
},
|
|
8202
7599
|
rules,
|
|
8203
7600
|
configs: {
|
|
@@ -8214,7 +7611,6 @@ var plugin = {
|
|
|
8214
7611
|
"@sarj/no-unnecessary-use-client": "warn",
|
|
8215
7612
|
"@sarj/prefer-schema-for-api-payload": "warn",
|
|
8216
7613
|
// Distilled from sarj-audit skills — warn in recommended, error in strict.
|
|
8217
|
-
"@sarj/no-sequential-await": "warn",
|
|
8218
7614
|
"@sarj/no-sentinel-return-on-catch": "warn",
|
|
8219
7615
|
"@sarj/no-log-only-catch": "warn",
|
|
8220
7616
|
"@sarj/no-insecure-random-id": "warn",
|
|
@@ -8231,16 +7627,13 @@ var plugin = {
|
|
|
8231
7627
|
"@sarj/no-fat-try-blocks": "warn",
|
|
8232
7628
|
"@sarj/no-cors-wildcard-with-credentials": "warn",
|
|
8233
7629
|
"@sarj/no-secret-in-log": "warn",
|
|
8234
|
-
"@sarj/no-unsafe-cast": "warn",
|
|
8235
7630
|
"@sarj/no-unsafe-mock-casting": "warn",
|
|
8236
|
-
"@sarj/single-public-export": "warn",
|
|
8237
7631
|
"@sarj/primary-export-file-name": "warn",
|
|
8238
7632
|
"@sarj/prefer-string-literal-union": "warn",
|
|
8239
7633
|
"@sarj/prefer-zod-enum": "warn",
|
|
8240
7634
|
// Mined from 2y of PR review feedback + 5-repo code-smell audit (2026-07).
|
|
8241
7635
|
"@sarj/require-fetch-timeout": "warn",
|
|
8242
7636
|
"@sarj/no-silent-promise-catch": "warn",
|
|
8243
|
-
"@sarj/require-schema-validate-search": "warn",
|
|
8244
7637
|
// Second SARJ port wave — the TS/Python parity gap. Each targets a
|
|
8245
7638
|
// defect class seen in production Workers code: timing-leaky secret
|
|
8246
7639
|
// compares, non-idempotent store writes under queue redelivery,
|
|
@@ -8301,14 +7694,12 @@ var plugin = {
|
|
|
8301
7694
|
"@sarj/ban-loose-type-guards-in-tests": "error",
|
|
8302
7695
|
"@sarj/enforce-file-structure": "error",
|
|
8303
7696
|
"@sarj/no-raw-env": "error",
|
|
8304
|
-
"@sarj/prefer-shadcn": "error",
|
|
8305
7697
|
"@sarj/no-enum": "error",
|
|
8306
7698
|
"@sarj/no-client-side-data-fetching": "error",
|
|
8307
7699
|
"@sarj/prefer-server-actions": "error",
|
|
8308
7700
|
"@sarj/no-unnecessary-use-client": "error",
|
|
8309
7701
|
"@sarj/prefer-schema-for-api-payload": "error",
|
|
8310
7702
|
// Distilled from sarj-audit skills.
|
|
8311
|
-
"@sarj/no-sequential-await": "error",
|
|
8312
7703
|
"@sarj/no-sentinel-return-on-catch": "error",
|
|
8313
7704
|
"@sarj/no-log-only-catch": "error",
|
|
8314
7705
|
"@sarj/no-insecure-random-id": "error",
|
|
@@ -8326,9 +7717,7 @@ var plugin = {
|
|
|
8326
7717
|
"@sarj/no-fat-try-blocks": "error",
|
|
8327
7718
|
"@sarj/no-cors-wildcard-with-credentials": "error",
|
|
8328
7719
|
"@sarj/no-secret-in-log": "error",
|
|
8329
|
-
"@sarj/no-unsafe-cast": "error",
|
|
8330
7720
|
"@sarj/no-unsafe-mock-casting": "error",
|
|
8331
|
-
"@sarj/single-public-export": "error",
|
|
8332
7721
|
"@sarj/primary-export-file-name": "error",
|
|
8333
7722
|
// Promoted to error 2026-07-25 — strict means strict (user directive).
|
|
8334
7723
|
"@sarj/prefer-string-literal-union": "error",
|
|
@@ -8336,7 +7725,6 @@ var plugin = {
|
|
|
8336
7725
|
// Mined from 2y of PR review feedback + 5-repo code-smell audit (2026-07).
|
|
8337
7726
|
"@sarj/require-fetch-timeout": "error",
|
|
8338
7727
|
"@sarj/no-silent-promise-catch": "error",
|
|
8339
|
-
"@sarj/require-schema-validate-search": "error",
|
|
8340
7728
|
// Second SARJ port wave — the TS/Python parity gap.
|
|
8341
7729
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
8342
7730
|
"@sarj/store-insert-requires-on-conflict": "error",
|