oxlint-plugin-arch 0.12.6 → 0.13.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/CHANGELOG.md +90 -0
- package/README.md +3 -3
- package/dist/index.js +396 -149
- package/dist/preset/preset-effect.d.ts +3 -0
- package/dist/preset/preset-recipes.d.ts +10 -0
- package/dist/preset/preset.constants.d.ts +17 -2
- package/dist/preset/preset.d.ts +11 -1
- package/dist/preset/preset.js +681 -221
- package/dist/preset/preset.utils.d.ts +5 -0
- package/dist/rules/code/code-delegate.d.ts +1 -0
- package/dist/rules/react/react-query-props.d.ts +1 -0
- package/dist/types/backend.types.d.ts +2 -3
- package/dist/types/code.types.d.ts +6 -0
- package/dist/types/files.types.d.ts +3 -2
- package/dist/types/preset.types.d.ts +26 -24
- package/dist/types/react.types.d.ts +4 -0
- package/dist/types/types.types.d.ts +4 -0
- package/dist/vendor/dillon-anti-slop/index.js +1 -1
- package/package.json +15 -1
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ function optionsPatternsTest(patterns, value) {
|
|
|
37
37
|
function optionsGlob(pattern) {
|
|
38
38
|
const negated = [];
|
|
39
39
|
const source = pattern.replaceAll(/!\(([^()]*)\)/g, (_, options) => {
|
|
40
|
-
negated.push(options.split("|").map((option) => option.replaceAll(/[.+^$()|[\]
|
|
40
|
+
negated.push(options.split("|").map((option) => option.replaceAll(/[.+^$()|[\]\\?{}]/g, "\\$&").replaceAll("*", "[^/]*")).join("|"));
|
|
41
41
|
return `\x02${negated.length - 1}\x03`;
|
|
42
42
|
}).replaceAll(/[.+^$()|[\]\\]/g, "\\$&").replaceAll("?", "[^/]").replaceAll("**/", "\x00").replaceAll("**", "\x01").replaceAll("*", "[^/]*").replaceAll("\x00", "(?:.*/)?").replaceAll("\x01", ".*").replaceAll(/\{([^}]*)\}/g, (_, options) => `(?:${options.split(",").join("|")})`);
|
|
43
43
|
return new RegExp(`^${negated.reduce((text, names, index) => text.replace(`\x02${index}\x03`, `(?!(?:${names})(?:/|$))[^/]*`), source)}$`);
|
|
@@ -283,16 +283,14 @@ var backendOrpcOutput = defineRule2({
|
|
|
283
283
|
type: "object",
|
|
284
284
|
additionalProperties: false,
|
|
285
285
|
properties: {
|
|
286
|
-
composers: { type: "array", items: { type: "string" } },
|
|
287
286
|
handler: { type: "string" },
|
|
288
287
|
output: { type: "string" }
|
|
289
|
-
}
|
|
290
|
-
required: ["composers"]
|
|
288
|
+
}
|
|
291
289
|
}
|
|
292
290
|
],
|
|
293
291
|
messages: {
|
|
294
292
|
missing: "oRPC procedures must declare .output() before .handler().",
|
|
295
|
-
invalid: "oRPC .output() must use a named schema or
|
|
293
|
+
invalid: "oRPC .output() must use a named schema or a plain function called with a named schema."
|
|
296
294
|
}
|
|
297
295
|
},
|
|
298
296
|
createOnce(context) {
|
|
@@ -301,7 +299,7 @@ var backendOrpcOutput = defineRule2({
|
|
|
301
299
|
if (node.callee.type !== "MemberExpression") {
|
|
302
300
|
return;
|
|
303
301
|
}
|
|
304
|
-
const {
|
|
302
|
+
const { handler: handlerMethod = "handler", output: outputMethod = "output" } = optionsFirst(context, {});
|
|
305
303
|
if (astMemberName(node.callee) !== handlerMethod) {
|
|
306
304
|
return;
|
|
307
305
|
}
|
|
@@ -311,7 +309,7 @@ var backendOrpcOutput = defineRule2({
|
|
|
311
309
|
return;
|
|
312
310
|
}
|
|
313
311
|
const schema = output.arguments.at(0);
|
|
314
|
-
const named = schema?.type === "Identifier" || schema?.type === "CallExpression" && schema.callee.type === "Identifier" &&
|
|
312
|
+
const named = schema?.type === "Identifier" || schema?.type === "CallExpression" && schema.callee.type === "Identifier" && schema.arguments[0]?.type === "Identifier";
|
|
315
313
|
if (!named) {
|
|
316
314
|
context.report({ node: output, messageId: "invalid" });
|
|
317
315
|
}
|
|
@@ -971,6 +969,12 @@ function boundariesResolveTarget(options, file, source) {
|
|
|
971
969
|
}
|
|
972
970
|
|
|
973
971
|
// src/rules/backend/backend-sql-like.ts
|
|
972
|
+
var backendSqlLikeDefaults = {
|
|
973
|
+
methods: ["like", "ilike"],
|
|
974
|
+
sanitizers: ["escapeLikeWildcards"],
|
|
975
|
+
bindings: true,
|
|
976
|
+
operators: ["where"]
|
|
977
|
+
};
|
|
974
978
|
var backendSqlLike = defineRule5({
|
|
975
979
|
meta: {
|
|
976
980
|
type: "problem",
|
|
@@ -983,17 +987,16 @@ var backendSqlLike = defineRule5({
|
|
|
983
987
|
sanitizers: { type: "array", items: { type: "string" } },
|
|
984
988
|
bindings: { type: "boolean" },
|
|
985
989
|
operators: { type: "array", items: { type: "string" } }
|
|
986
|
-
}
|
|
987
|
-
required: ["methods", "sanitizers"]
|
|
990
|
+
}
|
|
988
991
|
}
|
|
989
992
|
],
|
|
990
993
|
messages: { unescaped: ".{{method}}() values must use a configured sanitizer." }
|
|
991
994
|
},
|
|
992
995
|
createOnce(context) {
|
|
993
|
-
let options =
|
|
996
|
+
let options = backendSqlLikeDefaults;
|
|
994
997
|
const seen = new Set;
|
|
995
998
|
function sanitizedBinding(identifier, name) {
|
|
996
|
-
const variable = options.bindings
|
|
999
|
+
const variable = options.bindings ? boundariesDeclaredVariable(context.sourceCode.getScope(identifier), name) : null;
|
|
997
1000
|
const declarator = variable?.defs.length === 1 && variable.defs[0].type === "Variable" ? variable.defs[0].node : undefined;
|
|
998
1001
|
const statement = declarator?.parent?.parent;
|
|
999
1002
|
if (!variable || declarator?.type !== "VariableDeclarator" || seen.has(variable) || !(statement?.type === "Program" || statement?.type === "ExportNamedDeclaration" && statement.parent.type === "Program") || variable.references.some((reference) => reference.isWrite() && !reference.init)) {
|
|
@@ -1034,8 +1037,8 @@ var backendSqlLike = defineRule5({
|
|
|
1034
1037
|
if (node.callee.type !== "MemberExpression") {
|
|
1035
1038
|
return;
|
|
1036
1039
|
}
|
|
1037
|
-
options = optionsFirst(context);
|
|
1038
|
-
const { methods, operators: operatorMethods
|
|
1040
|
+
options = { ...backendSqlLikeDefaults, ...optionsFirst(context, {}) };
|
|
1041
|
+
const { methods, operators: operatorMethods } = options;
|
|
1039
1042
|
const method = astMemberName(node.callee);
|
|
1040
1043
|
if (!method) {
|
|
1041
1044
|
return;
|
|
@@ -2016,12 +2019,82 @@ var codeConstructor = defineRule13({
|
|
|
2016
2019
|
}
|
|
2017
2020
|
});
|
|
2018
2021
|
|
|
2022
|
+
// src/rules/code/code-delegate.ts
|
|
2023
|
+
import { defineRule as defineRule14 } from "@oxlint/plugins";
|
|
2024
|
+
var codeDelegate = defineRule14({
|
|
2025
|
+
meta: {
|
|
2026
|
+
type: "suggestion",
|
|
2027
|
+
schema: [
|
|
2028
|
+
{
|
|
2029
|
+
type: "object",
|
|
2030
|
+
additionalProperties: false,
|
|
2031
|
+
properties: {
|
|
2032
|
+
methods: { type: "array", items: { type: "string" } },
|
|
2033
|
+
reads: { type: "array", items: { type: "string" } },
|
|
2034
|
+
max: { type: "integer", minimum: 0 }
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
],
|
|
2038
|
+
messages: {
|
|
2039
|
+
statement: "A handler only delegates: read services, make one call, return. Move this to an action.",
|
|
2040
|
+
calls: "A handler's yielded or awaited calls are limited to {{max}}; move the rest into the action it calls.",
|
|
2041
|
+
ternary: "A handler does not branch; move the condition into the action it calls.",
|
|
2042
|
+
nested: "A handler holds no function; move it into the action it calls."
|
|
2043
|
+
}
|
|
2044
|
+
},
|
|
2045
|
+
createOnce(context) {
|
|
2046
|
+
return {
|
|
2047
|
+
CallExpression(node) {
|
|
2048
|
+
const { methods = ["handler", "effect"], reads = ["Effect.serviceOption"], max = 1 } = optionsFirst(context, {});
|
|
2049
|
+
if (!methods.includes(astCallName(node) ?? "")) {
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
const awaited = (value) => value?.type === "YieldExpression" || value?.type === "AwaitExpression";
|
|
2053
|
+
for (const handler of node.arguments.filter(astIsInlineFunction)) {
|
|
2054
|
+
let calls = 0;
|
|
2055
|
+
const scan = (value) => astSome(value, (child) => {
|
|
2056
|
+
if (child.type === "ConditionalExpression") {
|
|
2057
|
+
context.report({ node: child, messageId: "ternary" });
|
|
2058
|
+
}
|
|
2059
|
+
if (child.type === "FunctionDeclaration" || astIsInlineFunction(child)) {
|
|
2060
|
+
context.report({ node: child, messageId: "nested" });
|
|
2061
|
+
}
|
|
2062
|
+
const target = awaited(child) && "argument" in child ? child.argument : null;
|
|
2063
|
+
if (target?.type === "CallExpression" && !reads.includes(astDottedName(target.callee) ?? "")) {
|
|
2064
|
+
calls += 1;
|
|
2065
|
+
if (calls > max) {
|
|
2066
|
+
context.report({
|
|
2067
|
+
node: child,
|
|
2068
|
+
messageId: "calls",
|
|
2069
|
+
data: { max: String(max) }
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
return false;
|
|
2074
|
+
}, (child) => child.type !== "FunctionDeclaration" && !astIsInlineFunction(child));
|
|
2075
|
+
const { body } = handler;
|
|
2076
|
+
if (body && body.type !== "BlockStatement") {
|
|
2077
|
+
scan(body);
|
|
2078
|
+
}
|
|
2079
|
+
for (const statement of body?.type === "BlockStatement" ? body.body : []) {
|
|
2080
|
+
const allowed = statement.type === "ReturnStatement" || statement.type === "VariableDeclaration" && statement.declarations.every((declarator) => awaited(declarator.init)) || statement.type === "ExpressionStatement" && awaited(statement.expression) && "argument" in statement.expression && statement.expression.argument?.type === "CallExpression";
|
|
2081
|
+
if (!allowed) {
|
|
2082
|
+
context.report({ node: statement, messageId: "statement" });
|
|
2083
|
+
}
|
|
2084
|
+
scan(statement);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2090
|
+
});
|
|
2091
|
+
|
|
2019
2092
|
// src/rules/code/code-double-negation.ts
|
|
2020
2093
|
var codeDoubleNegation = astSelectorRule('UnaryExpression[operator="!"] > UnaryExpression[operator="!"]', "Use Boolean(value) or an explicit comparison.");
|
|
2021
2094
|
|
|
2022
2095
|
// src/rules/code/code-function-nesting.ts
|
|
2023
|
-
import { defineRule as
|
|
2024
|
-
var codeFunctionNesting =
|
|
2096
|
+
import { defineRule as defineRule15 } from "@oxlint/plugins";
|
|
2097
|
+
var codeFunctionNesting = defineRule15({
|
|
2025
2098
|
meta: {
|
|
2026
2099
|
type: "suggestion",
|
|
2027
2100
|
schema: [
|
|
@@ -2062,7 +2135,7 @@ var codeFunctionNesting = defineRule14({
|
|
|
2062
2135
|
});
|
|
2063
2136
|
|
|
2064
2137
|
// src/rules/code/code-inline.ts
|
|
2065
|
-
import { defineRule as
|
|
2138
|
+
import { defineRule as defineRule16 } from "@oxlint/plugins";
|
|
2066
2139
|
|
|
2067
2140
|
// src/utils/source.utils.ts
|
|
2068
2141
|
var sourceDirective = /^\s*(?:\/\s*<(?:reference\b|amd-[\w-]+\b)|@ts-(?:check|ignore|expect-error|nocheck)\b|(?:#|@)__(?:PURE|NO_SIDE_EFFECTS)__\b|@jsx(?:ImportSource|Runtime|Frag)?\b|@vite-ignore\b|(?:[#@]\s*)?sourceMappingURL=|(?:es|ox)lint-(?:disable|enable)|prettier-ignore|biome-ignore|[cv]8 ignore|istanbul ignore|webpack[A-Z])/;
|
|
@@ -2147,7 +2220,7 @@ var codeInlineEffects = new Set([
|
|
|
2147
2220
|
function codeInlineEffectBetween(program, start, end) {
|
|
2148
2221
|
return astSome(program, (node) => node.range[0] >= start && node.range[1] <= end && (codeInlineEffects.has(node.type) || node.type === "UnaryExpression" && node.operator === "delete"), (node) => node.range[1] > start && node.range[0] < end && !(node.range[0] >= start && (node.type === "FunctionDeclaration" || astIsInlineFunction(node))));
|
|
2149
2222
|
}
|
|
2150
|
-
var codeInline =
|
|
2223
|
+
var codeInline = defineRule16({
|
|
2151
2224
|
meta: {
|
|
2152
2225
|
type: "suggestion",
|
|
2153
2226
|
schema: [
|
|
@@ -2260,8 +2333,8 @@ var codeInline = defineRule15({
|
|
|
2260
2333
|
});
|
|
2261
2334
|
|
|
2262
2335
|
// src/rules/code/code-justified-call.ts
|
|
2263
|
-
import { defineRule as
|
|
2264
|
-
var codeJustifiedCall =
|
|
2336
|
+
import { defineRule as defineRule17 } from "@oxlint/plugins";
|
|
2337
|
+
var codeJustifiedCall = defineRule17({
|
|
2265
2338
|
meta: {
|
|
2266
2339
|
type: "problem",
|
|
2267
2340
|
schema: [
|
|
@@ -2315,8 +2388,8 @@ var codeJustifiedCall = defineRule16({
|
|
|
2315
2388
|
});
|
|
2316
2389
|
|
|
2317
2390
|
// src/rules/code/code-literal-in.ts
|
|
2318
|
-
import { defineRule as
|
|
2319
|
-
var codeLiteralIn =
|
|
2391
|
+
import { defineRule as defineRule18 } from "@oxlint/plugins";
|
|
2392
|
+
var codeLiteralIn = defineRule18({
|
|
2320
2393
|
meta: {
|
|
2321
2394
|
type: "suggestion",
|
|
2322
2395
|
schema: [
|
|
@@ -2357,7 +2430,7 @@ var codeLiteralIn = defineRule17({
|
|
|
2357
2430
|
});
|
|
2358
2431
|
|
|
2359
2432
|
// src/rules/code/code-mutable-state.ts
|
|
2360
|
-
import { defineRule as
|
|
2433
|
+
import { defineRule as defineRule19 } from "@oxlint/plugins";
|
|
2361
2434
|
var functionScopes = new Set([
|
|
2362
2435
|
"FunctionDeclaration",
|
|
2363
2436
|
"FunctionExpression",
|
|
@@ -2374,7 +2447,7 @@ function hasAncestor(node, test) {
|
|
|
2374
2447
|
}
|
|
2375
2448
|
return false;
|
|
2376
2449
|
}
|
|
2377
|
-
var codeMutableState =
|
|
2450
|
+
var codeMutableState = defineRule19({
|
|
2378
2451
|
meta: {
|
|
2379
2452
|
type: "problem",
|
|
2380
2453
|
schema: [
|
|
@@ -2432,7 +2505,7 @@ var codeMutableState = defineRule18({
|
|
|
2432
2505
|
});
|
|
2433
2506
|
|
|
2434
2507
|
// src/rules/code/code-object-params.ts
|
|
2435
|
-
import { defineRule as
|
|
2508
|
+
import { defineRule as defineRule20 } from "@oxlint/plugins";
|
|
2436
2509
|
function isObjectParam(node) {
|
|
2437
2510
|
if (node.type === "ObjectPattern") {
|
|
2438
2511
|
return true;
|
|
@@ -2446,7 +2519,7 @@ function isObjectParam(node) {
|
|
|
2446
2519
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
2447
2520
|
return !annotation || annotation.type === "TSTypeReference" || annotation.type === "TSTypeLiteral" || annotation.type === "TSIntersectionType";
|
|
2448
2521
|
}
|
|
2449
|
-
var codeObjectParams =
|
|
2522
|
+
var codeObjectParams = defineRule20({
|
|
2450
2523
|
meta: {
|
|
2451
2524
|
type: "problem",
|
|
2452
2525
|
schema: [
|
|
@@ -2495,8 +2568,8 @@ var codeObjectParams = defineRule19({
|
|
|
2495
2568
|
});
|
|
2496
2569
|
|
|
2497
2570
|
// src/rules/code/code-paired-call.ts
|
|
2498
|
-
import { defineRule as
|
|
2499
|
-
var codePairedCall =
|
|
2571
|
+
import { defineRule as defineRule21 } from "@oxlint/plugins";
|
|
2572
|
+
var codePairedCall = defineRule21({
|
|
2500
2573
|
meta: {
|
|
2501
2574
|
type: "problem",
|
|
2502
2575
|
schema: [
|
|
@@ -2563,7 +2636,7 @@ var codePairedCall = defineRule20({
|
|
|
2563
2636
|
});
|
|
2564
2637
|
|
|
2565
2638
|
// src/rules/code/code-promise-mutation.ts
|
|
2566
|
-
import { defineRule as
|
|
2639
|
+
import { defineRule as defineRule22 } from "@oxlint/plugins";
|
|
2567
2640
|
function mutationBinding(node) {
|
|
2568
2641
|
if (node.type === "Identifier") {
|
|
2569
2642
|
return node;
|
|
@@ -2592,7 +2665,7 @@ function mutationBindings(node) {
|
|
|
2592
2665
|
const binding = mutationBinding(node);
|
|
2593
2666
|
return binding ? [binding] : [];
|
|
2594
2667
|
}
|
|
2595
|
-
var codePromiseMutation =
|
|
2668
|
+
var codePromiseMutation = defineRule22({
|
|
2596
2669
|
meta: {
|
|
2597
2670
|
type: "problem",
|
|
2598
2671
|
schema: [
|
|
@@ -2685,8 +2758,8 @@ var codePromiseMutation = defineRule21({
|
|
|
2685
2758
|
var codeSwitch = astSelectorRule("SwitchStatement", "Avoid switch statements.");
|
|
2686
2759
|
|
|
2687
2760
|
// src/rules/code/code-traced.ts
|
|
2688
|
-
import { defineRule as
|
|
2689
|
-
var codeTraced =
|
|
2761
|
+
import { defineRule as defineRule23 } from "@oxlint/plugins";
|
|
2762
|
+
var codeTraced = defineRule23({
|
|
2690
2763
|
meta: {
|
|
2691
2764
|
type: "problem",
|
|
2692
2765
|
schema: [
|
|
@@ -2773,7 +2846,7 @@ var codeTraced = defineRule22({
|
|
|
2773
2846
|
});
|
|
2774
2847
|
|
|
2775
2848
|
// src/rules/code/code-trivial-functions.ts
|
|
2776
|
-
import { defineRule as
|
|
2849
|
+
import { defineRule as defineRule24 } from "@oxlint/plugins";
|
|
2777
2850
|
var codeTrivialFunctionsBanned = [
|
|
2778
2851
|
"isRecord",
|
|
2779
2852
|
"isPlainObject",
|
|
@@ -2903,7 +2976,35 @@ function guardStatement(node, state) {
|
|
|
2903
2976
|
return guardFallback(declaration.init);
|
|
2904
2977
|
});
|
|
2905
2978
|
}
|
|
2906
|
-
|
|
2979
|
+
function codeTrivialFunctionsDefaults(program) {
|
|
2980
|
+
const starts = [];
|
|
2981
|
+
const names = new Set;
|
|
2982
|
+
for (const statement of program.body) {
|
|
2983
|
+
const declaration = statement.type === "ExportDefaultDeclaration" ? statement.declaration : undefined;
|
|
2984
|
+
if (declaration?.type === "FunctionDeclaration" || declaration && astIsInlineFunction(declaration)) {
|
|
2985
|
+
starts.push(declaration.start);
|
|
2986
|
+
} else if (declaration?.type === "Identifier") {
|
|
2987
|
+
names.add(declaration.name);
|
|
2988
|
+
} else if (statement.type === "ExportNamedDeclaration" && !statement.source) {
|
|
2989
|
+
const specifier = statement.specifiers.find((item) => astModuleName(item.exported) === "default");
|
|
2990
|
+
if (specifier) {
|
|
2991
|
+
names.add(astModuleName(specifier.local));
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
for (const statement of program.body) {
|
|
2996
|
+
if (statement.type === "FunctionDeclaration" && statement.id && names.has(statement.id.name)) {
|
|
2997
|
+
starts.push(statement.start);
|
|
2998
|
+
}
|
|
2999
|
+
for (const declarator of statement.type === "VariableDeclaration" ? statement.declarations : []) {
|
|
3000
|
+
if (declarator.id.type === "Identifier" && names.has(declarator.id.name) && declarator.init && astIsInlineFunction(declarator.init)) {
|
|
3001
|
+
starts.push(declarator.init.start);
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
return starts;
|
|
3006
|
+
}
|
|
3007
|
+
var codeTrivialFunctions = defineRule24({
|
|
2907
3008
|
meta: {
|
|
2908
3009
|
type: "problem",
|
|
2909
3010
|
schema: [
|
|
@@ -2917,7 +3018,8 @@ var codeTrivialFunctions = defineRule23({
|
|
|
2917
3018
|
services: { type: "boolean" },
|
|
2918
3019
|
mode: { type: "string", enum: ["legacy", "precise"] },
|
|
2919
3020
|
deny: { type: "array", items: { type: "string" }, uniqueItems: true },
|
|
2920
|
-
guards: { type: "boolean" }
|
|
3021
|
+
guards: { type: "boolean" },
|
|
3022
|
+
defaults: { type: "boolean" }
|
|
2921
3023
|
}
|
|
2922
3024
|
}
|
|
2923
3025
|
],
|
|
@@ -2937,8 +3039,10 @@ var codeTrivialFunctions = defineRule23({
|
|
|
2937
3039
|
let checkServiceMethods = false;
|
|
2938
3040
|
const reported = new Set;
|
|
2939
3041
|
const checked = new Set;
|
|
3042
|
+
const defaults = new Set;
|
|
3043
|
+
let checkDefaults = true;
|
|
2940
3044
|
function checkHelper(node) {
|
|
2941
|
-
if (bannedNames.size === 0 && !checkGenericGuards || checked.has(node.start)) {
|
|
3045
|
+
if (bannedNames.size === 0 && !checkGenericGuards || checked.has(node.start) || defaults.has(node.start)) {
|
|
2942
3046
|
return;
|
|
2943
3047
|
}
|
|
2944
3048
|
checked.add(node.start);
|
|
@@ -3003,12 +3107,20 @@ var codeTrivialFunctions = defineRule23({
|
|
|
3003
3107
|
allowAsync = options.async ?? false;
|
|
3004
3108
|
reported.clear();
|
|
3005
3109
|
checked.clear();
|
|
3110
|
+
defaults.clear();
|
|
3111
|
+
checkDefaults = options.defaults ?? true;
|
|
3006
3112
|
},
|
|
3007
3113
|
FunctionDeclaration: checkHelper,
|
|
3008
3114
|
FunctionExpression: checkHelper,
|
|
3009
3115
|
ArrowFunctionExpression: checkHelper,
|
|
3010
3116
|
Program(program) {
|
|
3117
|
+
for (const start of checkDefaults ? [] : codeTrivialFunctionsDefaults(program)) {
|
|
3118
|
+
defaults.add(start);
|
|
3119
|
+
}
|
|
3011
3120
|
for (const { name, node } of exportsCheckedFunctions(program, true, checkServiceMethods, allowed)) {
|
|
3121
|
+
if (defaults.has(node.start)) {
|
|
3122
|
+
continue;
|
|
3123
|
+
}
|
|
3012
3124
|
checkHelper(node);
|
|
3013
3125
|
if (reported.has(node.start) || node.returnType?.typeAnnotation.type === "TSTypePredicate") {
|
|
3014
3126
|
continue;
|
|
@@ -3034,8 +3146,8 @@ var codeTrivialFunctions = defineRule23({
|
|
|
3034
3146
|
});
|
|
3035
3147
|
|
|
3036
3148
|
// src/rules/code/code-yield-argument.ts
|
|
3037
|
-
import { defineRule as
|
|
3038
|
-
var codeYieldArgument =
|
|
3149
|
+
import { defineRule as defineRule25 } from "@oxlint/plugins";
|
|
3150
|
+
var codeYieldArgument = defineRule25({
|
|
3039
3151
|
meta: {
|
|
3040
3152
|
type: "suggestion",
|
|
3041
3153
|
messages: {
|
|
@@ -3057,7 +3169,7 @@ var codeYieldArgument = defineRule24({
|
|
|
3057
3169
|
});
|
|
3058
3170
|
|
|
3059
3171
|
// src/rules/comments/comments-code.ts
|
|
3060
|
-
import { defineRule as
|
|
3172
|
+
import { defineRule as defineRule26 } from "@oxlint/plugins";
|
|
3061
3173
|
var commentsLineGap = /^[\t \r\n\u2028\u2029]*$/;
|
|
3062
3174
|
var commentsLineTerminator = /\r\n|[\n\r\u2028\u2029]/;
|
|
3063
3175
|
var commentsUnicodeTerminator = /[\u2028\u2029]/;
|
|
@@ -3108,7 +3220,7 @@ function commentsFollowsOpeningBrace(text, offset) {
|
|
|
3108
3220
|
}
|
|
3109
3221
|
return false;
|
|
3110
3222
|
}
|
|
3111
|
-
var commentsCode =
|
|
3223
|
+
var commentsCode = defineRule26({
|
|
3112
3224
|
meta: {
|
|
3113
3225
|
type: "suggestion",
|
|
3114
3226
|
fixable: "code",
|
|
@@ -3274,9 +3386,9 @@ var commentsCode = defineRule25({
|
|
|
3274
3386
|
});
|
|
3275
3387
|
|
|
3276
3388
|
// src/rules/comments/comments-directives.ts
|
|
3277
|
-
import { defineRule as
|
|
3389
|
+
import { defineRule as defineRule27 } from "@oxlint/plugins";
|
|
3278
3390
|
var directive = /^\s*(?:oxlint|eslint)-disable(?:-next-line|-line)?\b(.*)$/s;
|
|
3279
|
-
var commentsDirectives =
|
|
3391
|
+
var commentsDirectives = defineRule27({
|
|
3280
3392
|
meta: {
|
|
3281
3393
|
type: "problem",
|
|
3282
3394
|
schema: [],
|
|
@@ -3304,9 +3416,9 @@ var commentsDirectives = defineRule26({
|
|
|
3304
3416
|
});
|
|
3305
3417
|
|
|
3306
3418
|
// src/rules/copy/copy-dashes.ts
|
|
3307
|
-
import { defineRule as
|
|
3419
|
+
import { defineRule as defineRule28 } from "@oxlint/plugins";
|
|
3308
3420
|
var copyDashesMessage = "Use a comma, colon, period or parentheses instead.";
|
|
3309
|
-
var copyDashes =
|
|
3421
|
+
var copyDashes = defineRule28({
|
|
3310
3422
|
meta: {
|
|
3311
3423
|
type: "suggestion",
|
|
3312
3424
|
schema: [
|
|
@@ -3362,7 +3474,7 @@ var copyDashes = defineRule27({
|
|
|
3362
3474
|
});
|
|
3363
3475
|
|
|
3364
3476
|
// src/rules/effect/effect-layer-file.ts
|
|
3365
|
-
import { defineRule as
|
|
3477
|
+
import { defineRule as defineRule29 } from "@oxlint/plugins";
|
|
3366
3478
|
|
|
3367
3479
|
// src/utils/effect.utils.ts
|
|
3368
3480
|
var effectBuilders = ["Effect.gen", "Effect.fn", "Effect.fnUntraced"];
|
|
@@ -3404,7 +3516,7 @@ var effectLayerFileDefaultConstructors = [
|
|
|
3404
3516
|
"Layer.sync",
|
|
3405
3517
|
"Layer.unwrap"
|
|
3406
3518
|
];
|
|
3407
|
-
var effectLayerFile =
|
|
3519
|
+
var effectLayerFile = defineRule29({
|
|
3408
3520
|
meta: {
|
|
3409
3521
|
type: "problem",
|
|
3410
3522
|
schema: [
|
|
@@ -3567,7 +3679,7 @@ var effectLayerFile = defineRule28({
|
|
|
3567
3679
|
});
|
|
3568
3680
|
|
|
3569
3681
|
// src/rules/effect/effect-layers.ts
|
|
3570
|
-
import { defineRule as
|
|
3682
|
+
import { defineRule as defineRule30 } from "@oxlint/plugins";
|
|
3571
3683
|
var effectLayersDefaultMerge = ["Layer.mergeAll"];
|
|
3572
3684
|
var effectLayersDefaultProvide = ["Effect.provide", "Layer.provide", "Layer.provideMerge"];
|
|
3573
3685
|
var effectLayersDefaultMin = 2;
|
|
@@ -3579,7 +3691,7 @@ var effectLayersGroupSchema = {
|
|
|
3579
3691
|
min: { type: "integer", minimum: 1 }
|
|
3580
3692
|
}
|
|
3581
3693
|
};
|
|
3582
|
-
var effectLayers =
|
|
3694
|
+
var effectLayers = defineRule30({
|
|
3583
3695
|
meta: {
|
|
3584
3696
|
type: "layout",
|
|
3585
3697
|
fixable: "whitespace",
|
|
@@ -3661,11 +3773,11 @@ var effectLayers = defineRule29({
|
|
|
3661
3773
|
});
|
|
3662
3774
|
|
|
3663
3775
|
// src/rules/effect/effect-merge-pipe.ts
|
|
3664
|
-
import { defineRule as
|
|
3776
|
+
import { defineRule as defineRule31 } from "@oxlint/plugins";
|
|
3665
3777
|
var effectMergePipeDefaultMerge = ["Layer.mergeAll"];
|
|
3666
3778
|
var effectMergePipeDefaultPipe = ["pipe", "Function.pipe"];
|
|
3667
3779
|
var effectMergePipeDefaultMethods = ["pipe"];
|
|
3668
|
-
var effectMergePipe =
|
|
3780
|
+
var effectMergePipe = defineRule31({
|
|
3669
3781
|
meta: {
|
|
3670
3782
|
type: "layout",
|
|
3671
3783
|
schema: [
|
|
@@ -3710,7 +3822,7 @@ var effectMergePipe = defineRule30({
|
|
|
3710
3822
|
});
|
|
3711
3823
|
|
|
3712
3824
|
// src/rules/effect/effect-schema-first.ts
|
|
3713
|
-
import { defineRule as
|
|
3825
|
+
import { defineRule as defineRule32 } from "@oxlint/plugins";
|
|
3714
3826
|
var effectSchemaFirstDefaultRuntime = [
|
|
3715
3827
|
"Effect",
|
|
3716
3828
|
"Layer",
|
|
@@ -3772,7 +3884,7 @@ function effectSchemaFirstReference(node) {
|
|
|
3772
3884
|
}
|
|
3773
3885
|
return node.type === "TSInterfaceHeritage" ? astDottedName(node.expression) : undefined;
|
|
3774
3886
|
}
|
|
3775
|
-
var effectSchemaFirst =
|
|
3887
|
+
var effectSchemaFirst = defineRule32({
|
|
3776
3888
|
meta: {
|
|
3777
3889
|
type: "suggestion",
|
|
3778
3890
|
schema: [
|
|
@@ -3945,7 +4057,7 @@ var effectSchemaFirst = defineRule31({
|
|
|
3945
4057
|
});
|
|
3946
4058
|
|
|
3947
4059
|
// src/rules/effect/effect-values-first.ts
|
|
3948
|
-
import { defineRule as
|
|
4060
|
+
import { defineRule as defineRule33 } from "@oxlint/plugins";
|
|
3949
4061
|
var effectValuesFirstDefaultPinned = [
|
|
3950
4062
|
"^Layer\\.",
|
|
3951
4063
|
"^Context\\.",
|
|
@@ -3954,7 +4066,7 @@ var effectValuesFirstDefaultPinned = [
|
|
|
3954
4066
|
"(?:^|\\.)layer[^.]*$",
|
|
3955
4067
|
"^Schema\\.(?:asserts|decode\\w*|encode\\w*|is|isSchema|isSchemaError|resolveAnnotations)$"
|
|
3956
4068
|
];
|
|
3957
|
-
var effectValuesFirst =
|
|
4069
|
+
var effectValuesFirst = defineRule33({
|
|
3958
4070
|
meta: {
|
|
3959
4071
|
type: "suggestion",
|
|
3960
4072
|
schema: [
|
|
@@ -4037,7 +4149,7 @@ var effectValuesFirst = defineRule32({
|
|
|
4037
4149
|
});
|
|
4038
4150
|
|
|
4039
4151
|
// src/rules/files/files-components-only.ts
|
|
4040
|
-
import { defineRule as
|
|
4152
|
+
import { defineRule as defineRule34 } from "@oxlint/plugins";
|
|
4041
4153
|
|
|
4042
4154
|
// src/utils/react.utils.ts
|
|
4043
4155
|
function reactReturnsOutput(program, node) {
|
|
@@ -4109,7 +4221,7 @@ function reactIsComponent(program, candidate) {
|
|
|
4109
4221
|
function componentName(basename2) {
|
|
4110
4222
|
return basename2.replace(/\.(tsx?|jsx?)$/, "").replaceAll(/(?:^[-.]*|[-.]+)(.?)/g, (_, char) => char.toUpperCase());
|
|
4111
4223
|
}
|
|
4112
|
-
var filesComponentsOnly =
|
|
4224
|
+
var filesComponentsOnly = defineRule34({
|
|
4113
4225
|
meta: {
|
|
4114
4226
|
type: "problem",
|
|
4115
4227
|
schema: [
|
|
@@ -4197,7 +4309,7 @@ var filesComponentsOnly = defineRule33({
|
|
|
4197
4309
|
});
|
|
4198
4310
|
|
|
4199
4311
|
// src/rules/files/files-constants-only.ts
|
|
4200
|
-
import { defineRule as
|
|
4312
|
+
import { defineRule as defineRule35 } from "@oxlint/plugins";
|
|
4201
4313
|
function unwrap(expression) {
|
|
4202
4314
|
if (expression.type === "ParenthesizedExpression" || expression.type === "TSAsExpression" || expression.type === "TSSatisfiesExpression" || expression.type === "TSTypeAssertion" || expression.type === "TSNonNullExpression" || expression.type === "TSInstantiationExpression") {
|
|
4203
4315
|
return unwrap(expression.expression);
|
|
@@ -4252,7 +4364,7 @@ function collectBindings(program) {
|
|
|
4252
4364
|
}
|
|
4253
4365
|
return bindings;
|
|
4254
4366
|
}
|
|
4255
|
-
var filesConstantsOnly =
|
|
4367
|
+
var filesConstantsOnly = defineRule35({
|
|
4256
4368
|
meta: {
|
|
4257
4369
|
type: "problem",
|
|
4258
4370
|
schema: [
|
|
@@ -4351,7 +4463,7 @@ var filesConstantsOnly = defineRule34({
|
|
|
4351
4463
|
});
|
|
4352
4464
|
|
|
4353
4465
|
// src/rules/files/files-domain-constants.ts
|
|
4354
|
-
import { defineRule as
|
|
4466
|
+
import { defineRule as defineRule36 } from "@oxlint/plugins";
|
|
4355
4467
|
import { basename as basename2, dirname as dirname2 } from "node:path";
|
|
4356
4468
|
function isData(expression) {
|
|
4357
4469
|
const value = astUnwrap(expression);
|
|
@@ -4369,7 +4481,7 @@ function isData(expression) {
|
|
|
4369
4481
|
}
|
|
4370
4482
|
return value.type === "NewExpression" && value.callee.type === "Identifier" && ["Map", "Set"].includes(value.callee.name) && value.arguments[0]?.type === "ArrayExpression" && value.arguments[0].elements.length > 0;
|
|
4371
4483
|
}
|
|
4372
|
-
var filesDomainConstants =
|
|
4484
|
+
var filesDomainConstants = defineRule36({
|
|
4373
4485
|
meta: {
|
|
4374
4486
|
type: "problem",
|
|
4375
4487
|
schema: [
|
|
@@ -4434,11 +4546,12 @@ var filesDomainConstants = defineRule35({
|
|
|
4434
4546
|
});
|
|
4435
4547
|
|
|
4436
4548
|
// src/rules/files/files-exports.ts
|
|
4437
|
-
import { defineRule as
|
|
4549
|
+
import { defineRule as defineRule37 } from "@oxlint/plugins";
|
|
4550
|
+
import { posix as posix2 } from "node:path";
|
|
4438
4551
|
function escapeRegExp(value) {
|
|
4439
4552
|
return value.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4440
4553
|
}
|
|
4441
|
-
var filesExports =
|
|
4554
|
+
var filesExports = defineRule37({
|
|
4442
4555
|
meta: {
|
|
4443
4556
|
type: "problem",
|
|
4444
4557
|
schema: [
|
|
@@ -4448,7 +4561,8 @@ var filesExports = defineRule36({
|
|
|
4448
4561
|
properties: {
|
|
4449
4562
|
names: { type: "array", items: { type: "string" } },
|
|
4450
4563
|
patterns: { type: "array", items: { type: "string" } },
|
|
4451
|
-
stem: { type: "string", enum: [...namingStemModes] },
|
|
4564
|
+
stem: { type: "string", enum: [...namingStemModes, "folder"] },
|
|
4565
|
+
singularize: { type: "string", enum: ["none", "trailing-s"] },
|
|
4452
4566
|
roles: { type: "array", items: { type: "string" } },
|
|
4453
4567
|
separators: { type: "array", items: { type: "string" } },
|
|
4454
4568
|
types: { type: "boolean" },
|
|
@@ -4491,7 +4605,9 @@ var filesExports = defineRule36({
|
|
|
4491
4605
|
if (options.names === undefined && options.patterns === undefined) {
|
|
4492
4606
|
return;
|
|
4493
4607
|
}
|
|
4494
|
-
const
|
|
4608
|
+
const read = options.stem === "folder" ? namingBasename(posix2.dirname(context.filename.replaceAll("\\", "/"))) : namingFileStem(basename3, options.stem, options.roles, options.separators);
|
|
4609
|
+
const last = read.split(/[-_]+/).at(-1) ?? "";
|
|
4610
|
+
const domain = options.singularize === "trailing-s" && last.length > 1 && last.endsWith("s") ? read.slice(0, -1) : read;
|
|
4495
4611
|
const pascalDomain = namingPascalCase(domain);
|
|
4496
4612
|
const camelDomain = namingCamelCase(domain);
|
|
4497
4613
|
const allowed = (options.names ?? []).map((template) => template.replaceAll("{Domain}", pascalDomain).replaceAll("{domain}", camelDomain));
|
|
@@ -4519,12 +4635,12 @@ var filesExports = defineRule36({
|
|
|
4519
4635
|
});
|
|
4520
4636
|
|
|
4521
4637
|
// src/rules/files/files-externals.ts
|
|
4522
|
-
import { defineRule as
|
|
4638
|
+
import { defineRule as defineRule38 } from "@oxlint/plugins";
|
|
4523
4639
|
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
4524
4640
|
import { builtinModules as builtinModules2 } from "node:module";
|
|
4525
4641
|
import { dirname as dirname3, join as join2 } from "node:path";
|
|
4526
4642
|
var filesExternalsConfigs = "^(?:vite|next)\\.config\\.[cm]?[jt]s$";
|
|
4527
|
-
var filesExternals =
|
|
4643
|
+
var filesExternals = defineRule38({
|
|
4528
4644
|
meta: {
|
|
4529
4645
|
type: "problem",
|
|
4530
4646
|
schema: [
|
|
@@ -4617,7 +4733,7 @@ var filesExternals = defineRule37({
|
|
|
4617
4733
|
});
|
|
4618
4734
|
|
|
4619
4735
|
// src/rules/files/files-factory-keys.ts
|
|
4620
|
-
import { defineRule as
|
|
4736
|
+
import { defineRule as defineRule39 } from "@oxlint/plugins";
|
|
4621
4737
|
function returnedObject(expression) {
|
|
4622
4738
|
if (expression?.type === "TSAsExpression" || expression?.type === "TSSatisfiesExpression" || expression?.type === "TSTypeAssertion" || expression?.type === "TSNonNullExpression") {
|
|
4623
4739
|
return returnedObject(expression.expression);
|
|
@@ -4628,7 +4744,7 @@ function compileKeys(pattern, keys, requireKeys) {
|
|
|
4628
4744
|
const allowedList = keys.concat(requireKeys.filter((key) => !keys.includes(key)));
|
|
4629
4745
|
return { patterns: optionsPatternsWithEmpty(pattern), allowed: new Set(allowedList), allowedList, required: requireKeys };
|
|
4630
4746
|
}
|
|
4631
|
-
var filesFactoryKeys =
|
|
4747
|
+
var filesFactoryKeys = defineRule39({
|
|
4632
4748
|
meta: {
|
|
4633
4749
|
type: "problem",
|
|
4634
4750
|
schema: [
|
|
@@ -4746,8 +4862,8 @@ var filesFactoryKeys = defineRule38({
|
|
|
4746
4862
|
});
|
|
4747
4863
|
|
|
4748
4864
|
// src/rules/files/files-helpers.ts
|
|
4749
|
-
import { defineRule as
|
|
4750
|
-
var filesHelpers =
|
|
4865
|
+
import { defineRule as defineRule40 } from "@oxlint/plugins";
|
|
4866
|
+
var filesHelpers = defineRule40({
|
|
4751
4867
|
meta: {
|
|
4752
4868
|
type: "problem",
|
|
4753
4869
|
schema: [
|
|
@@ -4795,8 +4911,8 @@ var filesHelpers = defineRule39({
|
|
|
4795
4911
|
});
|
|
4796
4912
|
|
|
4797
4913
|
// src/rules/files/files-no-functions.ts
|
|
4798
|
-
import { defineRule as
|
|
4799
|
-
var filesNoFunctions =
|
|
4914
|
+
import { defineRule as defineRule41 } from "@oxlint/plugins";
|
|
4915
|
+
var filesNoFunctions = defineRule41({
|
|
4800
4916
|
meta: {
|
|
4801
4917
|
type: "problem",
|
|
4802
4918
|
schema: [
|
|
@@ -4850,8 +4966,8 @@ var filesNoFunctions = defineRule40({
|
|
|
4850
4966
|
});
|
|
4851
4967
|
|
|
4852
4968
|
// src/rules/files/files-restricted.ts
|
|
4853
|
-
import { defineRule as
|
|
4854
|
-
var filesRestricted =
|
|
4969
|
+
import { defineRule as defineRule42 } from "@oxlint/plugins";
|
|
4970
|
+
var filesRestricted = defineRule42({
|
|
4855
4971
|
meta: {
|
|
4856
4972
|
type: "problem",
|
|
4857
4973
|
schema: [
|
|
@@ -4883,7 +4999,7 @@ var filesRestricted = defineRule41({
|
|
|
4883
4999
|
});
|
|
4884
5000
|
|
|
4885
5001
|
// src/rules/files/files-route.ts
|
|
4886
|
-
import { defineRule as
|
|
5002
|
+
import { defineRule as defineRule43 } from "@oxlint/plugins";
|
|
4887
5003
|
function inspectAdapter(context, item, bannedHooks, banIntrinsicJsx) {
|
|
4888
5004
|
astVisit(item.node.body, [item.node], (node) => {
|
|
4889
5005
|
if (banIntrinsicJsx && node.type === "JSXOpeningElement" && node.name.type === "JSXIdentifier" && /^[a-z]/.test(node.name.name)) {
|
|
@@ -4903,7 +5019,7 @@ function inspectAdapter(context, item, bannedHooks, banIntrinsicJsx) {
|
|
|
4903
5019
|
}
|
|
4904
5020
|
});
|
|
4905
5021
|
}
|
|
4906
|
-
var filesRoute =
|
|
5022
|
+
var filesRoute = defineRule43({
|
|
4907
5023
|
meta: {
|
|
4908
5024
|
type: "problem",
|
|
4909
5025
|
schema: [
|
|
@@ -4973,7 +5089,7 @@ var filesRoute = defineRule42({
|
|
|
4973
5089
|
});
|
|
4974
5090
|
|
|
4975
5091
|
// src/rules/files/files-types-only.ts
|
|
4976
|
-
import { defineRule as
|
|
5092
|
+
import { defineRule as defineRule44 } from "@oxlint/plugins";
|
|
4977
5093
|
function runtimeImportLocalNames(statement) {
|
|
4978
5094
|
return statement.specifiers.flatMap((specifier) => specifier.type !== "ImportSpecifier" || specifier.importKind !== "type" ? [specifier.local.name] : []);
|
|
4979
5095
|
}
|
|
@@ -5142,7 +5258,7 @@ function runtimeKind(node) {
|
|
|
5142
5258
|
}
|
|
5143
5259
|
return node.type === "FunctionDeclaration" ? "function" : "variable";
|
|
5144
5260
|
}
|
|
5145
|
-
var filesTypesOnly =
|
|
5261
|
+
var filesTypesOnly = defineRule44({
|
|
5146
5262
|
meta: {
|
|
5147
5263
|
type: "problem",
|
|
5148
5264
|
schema: [
|
|
@@ -5250,8 +5366,8 @@ var filesTypesOnly = defineRule43({
|
|
|
5250
5366
|
});
|
|
5251
5367
|
|
|
5252
5368
|
// src/rules/layout/layout-arrow-body.ts
|
|
5253
|
-
import { defineRule as
|
|
5254
|
-
var layoutArrowBody =
|
|
5369
|
+
import { defineRule as defineRule45 } from "@oxlint/plugins";
|
|
5370
|
+
var layoutArrowBody = defineRule45({
|
|
5255
5371
|
meta: {
|
|
5256
5372
|
type: "layout",
|
|
5257
5373
|
fixable: "whitespace",
|
|
@@ -5303,12 +5419,12 @@ var layoutArrowBody = defineRule44({
|
|
|
5303
5419
|
});
|
|
5304
5420
|
|
|
5305
5421
|
// src/rules/layout/layout-call-arguments.ts
|
|
5306
|
-
import { defineRule as
|
|
5422
|
+
import { defineRule as defineRule46 } from "@oxlint/plugins";
|
|
5307
5423
|
function layoutCallArgumentsHuggable(node) {
|
|
5308
5424
|
return astIsInlineFunction(node) || node.type === "ObjectExpression" || node.type === "ArrayExpression" || astIsCall(node) && node.arguments.length === 1 && (node.callee.type !== "MemberExpression" || astIsOneLine(node.callee)) && node.arguments.every(layoutCallArgumentsHuggable);
|
|
5309
5425
|
}
|
|
5310
5426
|
var layoutCallArgumentsMax = { type: "integer", minimum: 1 };
|
|
5311
|
-
var layoutCallArguments =
|
|
5427
|
+
var layoutCallArguments = defineRule46({
|
|
5312
5428
|
meta: {
|
|
5313
5429
|
type: "layout",
|
|
5314
5430
|
fixable: "whitespace",
|
|
@@ -5490,12 +5606,12 @@ var layoutCallArguments = defineRule45({
|
|
|
5490
5606
|
});
|
|
5491
5607
|
|
|
5492
5608
|
// src/rules/layout/layout-call-array.ts
|
|
5493
|
-
import { defineRule as
|
|
5609
|
+
import { defineRule as defineRule47 } from "@oxlint/plugins";
|
|
5494
5610
|
var layoutCallArrayDefaultCallees = ["Promise.all", "Promise.allSettled"];
|
|
5495
5611
|
function layoutCallArrayRoot(node) {
|
|
5496
5612
|
return node.type === "MemberExpression" ? layoutCallArrayRoot(node.object) : node;
|
|
5497
5613
|
}
|
|
5498
|
-
var layoutCallArray =
|
|
5614
|
+
var layoutCallArray = defineRule47({
|
|
5499
5615
|
meta: {
|
|
5500
5616
|
type: "layout",
|
|
5501
5617
|
fixable: "whitespace",
|
|
@@ -5611,7 +5727,7 @@ var layoutCallArray = defineRule46({
|
|
|
5611
5727
|
});
|
|
5612
5728
|
|
|
5613
5729
|
// src/rules/layout/layout-call-depth.ts
|
|
5614
|
-
import { defineRule as
|
|
5730
|
+
import { defineRule as defineRule48 } from "@oxlint/plugins";
|
|
5615
5731
|
function layoutCallDepthOuter(node) {
|
|
5616
5732
|
const parent = node.parent;
|
|
5617
5733
|
if (!parent || parent.type === "ArrowFunctionExpression" || parent.type === "FunctionExpression" || parent.type.endsWith("Statement")) {
|
|
@@ -5619,7 +5735,7 @@ function layoutCallDepthOuter(node) {
|
|
|
5619
5735
|
}
|
|
5620
5736
|
return astIsCall(parent) && parent.arguments.some((argument) => argument === node) ? parent : layoutCallDepthOuter(parent);
|
|
5621
5737
|
}
|
|
5622
|
-
var layoutCallDepth =
|
|
5738
|
+
var layoutCallDepth = defineRule48({
|
|
5623
5739
|
meta: {
|
|
5624
5740
|
type: "layout",
|
|
5625
5741
|
schema: [
|
|
@@ -5658,8 +5774,8 @@ var layoutCallDepth = defineRule47({
|
|
|
5658
5774
|
});
|
|
5659
5775
|
|
|
5660
5776
|
// src/rules/layout/layout-chain.ts
|
|
5661
|
-
import { defineRule as
|
|
5662
|
-
var layoutChain =
|
|
5777
|
+
import { defineRule as defineRule49 } from "@oxlint/plugins";
|
|
5778
|
+
var layoutChain = defineRule49({
|
|
5663
5779
|
meta: {
|
|
5664
5780
|
type: "layout",
|
|
5665
5781
|
fixable: "whitespace",
|
|
@@ -5778,8 +5894,8 @@ var layoutChain = defineRule48({
|
|
|
5778
5894
|
});
|
|
5779
5895
|
|
|
5780
5896
|
// src/rules/layout/layout-items.ts
|
|
5781
|
-
import { defineRule as
|
|
5782
|
-
var layoutItems =
|
|
5897
|
+
import { defineRule as defineRule50 } from "@oxlint/plugins";
|
|
5898
|
+
var layoutItems = defineRule50({
|
|
5783
5899
|
meta: {
|
|
5784
5900
|
type: "layout",
|
|
5785
5901
|
fixable: "whitespace",
|
|
@@ -5834,8 +5950,8 @@ var layoutItems = defineRule49({
|
|
|
5834
5950
|
});
|
|
5835
5951
|
|
|
5836
5952
|
// src/rules/layout/layout-jsx-attributes.ts
|
|
5837
|
-
import { defineRule as
|
|
5838
|
-
var layoutJsxAttributes =
|
|
5953
|
+
import { defineRule as defineRule51 } from "@oxlint/plugins";
|
|
5954
|
+
var layoutJsxAttributes = defineRule51({
|
|
5839
5955
|
meta: {
|
|
5840
5956
|
type: "layout",
|
|
5841
5957
|
fixable: "whitespace",
|
|
@@ -5923,8 +6039,8 @@ var layoutJsxAttributes = defineRule50({
|
|
|
5923
6039
|
});
|
|
5924
6040
|
|
|
5925
6041
|
// src/rules/layout/layout-key-value.ts
|
|
5926
|
-
import { defineRule as
|
|
5927
|
-
var layoutKeyValue =
|
|
6042
|
+
import { defineRule as defineRule52 } from "@oxlint/plugins";
|
|
6043
|
+
var layoutKeyValue = defineRule52({
|
|
5928
6044
|
meta: {
|
|
5929
6045
|
type: "layout",
|
|
5930
6046
|
fixable: "whitespace",
|
|
@@ -5960,7 +6076,7 @@ var layoutKeyValue = defineRule51({
|
|
|
5960
6076
|
});
|
|
5961
6077
|
|
|
5962
6078
|
// src/rules/layout/layout-object.ts
|
|
5963
|
-
import { defineRule as
|
|
6079
|
+
import { defineRule as defineRule53 } from "@oxlint/plugins";
|
|
5964
6080
|
function layoutObjectIsWhitespace(text) {
|
|
5965
6081
|
return /^[\t\n\r\f ]*$/.test(text);
|
|
5966
6082
|
}
|
|
@@ -5968,7 +6084,7 @@ function layoutObjectIsFlat(property) {
|
|
|
5968
6084
|
const value = property.type === "SpreadElement" ? property.argument : property.value;
|
|
5969
6085
|
return astIsOneLine(property) && (property.type === "SpreadElement" || !property.method && property.kind === "init") && value.type !== "ObjectExpression" && value.type !== "ArrayExpression" && !astIsInlineFunction(value);
|
|
5970
6086
|
}
|
|
5971
|
-
var layoutObject =
|
|
6087
|
+
var layoutObject = defineRule53({
|
|
5972
6088
|
meta: {
|
|
5973
6089
|
type: "layout",
|
|
5974
6090
|
fixable: "whitespace",
|
|
@@ -6085,7 +6201,7 @@ var layoutObject = defineRule52({
|
|
|
6085
6201
|
});
|
|
6086
6202
|
|
|
6087
6203
|
// src/rules/layout/layout-padding.ts
|
|
6088
|
-
import { defineRule as
|
|
6204
|
+
import { defineRule as defineRule54 } from "@oxlint/plugins";
|
|
6089
6205
|
var layoutPaddingControl = new Set([
|
|
6090
6206
|
"IfStatement",
|
|
6091
6207
|
"ForStatement",
|
|
@@ -6114,7 +6230,7 @@ function layoutPaddingKind(node) {
|
|
|
6114
6230
|
function layoutPaddingIsMultilineVariable(node, kind) {
|
|
6115
6231
|
return kind === "variable" && node.loc.start.line !== node.loc.end.line;
|
|
6116
6232
|
}
|
|
6117
|
-
var layoutPadding =
|
|
6233
|
+
var layoutPadding = defineRule54({
|
|
6118
6234
|
meta: {
|
|
6119
6235
|
type: "layout",
|
|
6120
6236
|
fixable: "whitespace",
|
|
@@ -6203,8 +6319,8 @@ var layoutPadding = defineRule53({
|
|
|
6203
6319
|
});
|
|
6204
6320
|
|
|
6205
6321
|
// src/rules/layout/layout-pipe.ts
|
|
6206
|
-
import { defineRule as
|
|
6207
|
-
var layoutPipe =
|
|
6322
|
+
import { defineRule as defineRule55 } from "@oxlint/plugins";
|
|
6323
|
+
var layoutPipe = defineRule55({
|
|
6208
6324
|
meta: {
|
|
6209
6325
|
type: "layout",
|
|
6210
6326
|
messages: {
|
|
@@ -6235,7 +6351,7 @@ var layoutPipe = defineRule54({
|
|
|
6235
6351
|
});
|
|
6236
6352
|
|
|
6237
6353
|
// src/rules/layout/layout-ternary.ts
|
|
6238
|
-
import { defineRule as
|
|
6354
|
+
import { defineRule as defineRule56 } from "@oxlint/plugins";
|
|
6239
6355
|
function layoutTernaryLines(node) {
|
|
6240
6356
|
return node.loc.end.line - node.loc.start.line + 1;
|
|
6241
6357
|
}
|
|
@@ -6243,7 +6359,7 @@ function layoutTernaryBreak(between, operator, newline) {
|
|
|
6243
6359
|
const at = between.indexOf(operator);
|
|
6244
6360
|
return `${between.slice(0, at).trimEnd()}${newline}${operator} ${between.slice(at + 1).trimStart()}`;
|
|
6245
6361
|
}
|
|
6246
|
-
var layoutTernary =
|
|
6362
|
+
var layoutTernary = defineRule56({
|
|
6247
6363
|
meta: {
|
|
6248
6364
|
type: "layout",
|
|
6249
6365
|
fixable: "whitespace",
|
|
@@ -6359,9 +6475,9 @@ var layoutTernary = defineRule55({
|
|
|
6359
6475
|
});
|
|
6360
6476
|
|
|
6361
6477
|
// src/rules/naming/naming-declarations.ts
|
|
6362
|
-
import { defineRule as
|
|
6478
|
+
import { defineRule as defineRule57 } from "@oxlint/plugins";
|
|
6363
6479
|
var namingDeclarationsKinds = ["function", "const", "let", "var", "class", "type", "interface", "enum"];
|
|
6364
|
-
var namingDeclarations =
|
|
6480
|
+
var namingDeclarations = defineRule57({
|
|
6365
6481
|
meta: {
|
|
6366
6482
|
type: "problem",
|
|
6367
6483
|
schema: [
|
|
@@ -6438,7 +6554,7 @@ var namingDeclarations = defineRule56({
|
|
|
6438
6554
|
});
|
|
6439
6555
|
|
|
6440
6556
|
// src/rules/naming/naming-exports.ts
|
|
6441
|
-
import { defineRule as
|
|
6557
|
+
import { defineRule as defineRule58 } from "@oxlint/plugins";
|
|
6442
6558
|
var namingExportsScopeProperties = {
|
|
6443
6559
|
scope: { type: "string", enum: ["exports", "functions", "declarations"] },
|
|
6444
6560
|
types: { type: "boolean" },
|
|
@@ -6464,7 +6580,7 @@ function matchTemplate(basename3, template, placeholder = "[a-z0-9-]+") {
|
|
|
6464
6580
|
}
|
|
6465
6581
|
return new RegExp(`^${pattern}$`).exec(basename3)?.groups ?? null;
|
|
6466
6582
|
}
|
|
6467
|
-
var namingExports =
|
|
6583
|
+
var namingExports = defineRule58({
|
|
6468
6584
|
meta: {
|
|
6469
6585
|
type: "problem",
|
|
6470
6586
|
schema: {
|
|
@@ -6601,10 +6717,10 @@ var namingExports = defineRule57({
|
|
|
6601
6717
|
});
|
|
6602
6718
|
|
|
6603
6719
|
// src/rules/naming/naming-file.ts
|
|
6604
|
-
import { defineRule as
|
|
6720
|
+
import { defineRule as defineRule59 } from "@oxlint/plugins";
|
|
6605
6721
|
import { readdirSync as readdirSync2 } from "node:fs";
|
|
6606
6722
|
import { dirname as dirname4 } from "node:path";
|
|
6607
|
-
var namingFile =
|
|
6723
|
+
var namingFile = defineRule59({
|
|
6608
6724
|
meta: {
|
|
6609
6725
|
type: "problem",
|
|
6610
6726
|
schema: {
|
|
@@ -6674,9 +6790,9 @@ var namingFile = defineRule58({
|
|
|
6674
6790
|
});
|
|
6675
6791
|
|
|
6676
6792
|
// src/rules/naming/naming-folder.ts
|
|
6677
|
-
import { defineRule as
|
|
6678
|
-
import { posix as
|
|
6679
|
-
var namingFolder =
|
|
6793
|
+
import { defineRule as defineRule60 } from "@oxlint/plugins";
|
|
6794
|
+
import { posix as posix3 } from "node:path";
|
|
6795
|
+
var namingFolder = defineRule60({
|
|
6680
6796
|
meta: {
|
|
6681
6797
|
type: "problem",
|
|
6682
6798
|
schema: [
|
|
@@ -6699,7 +6815,7 @@ var namingFolder = defineRule59({
|
|
|
6699
6815
|
return {
|
|
6700
6816
|
Program(program) {
|
|
6701
6817
|
const { singularize = "trailing-s", separators = ["-"], after, prefixes: stripPrefixes = [] } = optionsFirst(context, {});
|
|
6702
|
-
const all =
|
|
6818
|
+
const all = posix3.dirname(context.filename.replaceAll("\\", "/")).split("/").filter((part) => part && part !== ".");
|
|
6703
6819
|
const parent = [all.at(-1) ?? ""];
|
|
6704
6820
|
let folders = after ? undefined : parent;
|
|
6705
6821
|
const marker = (after ?? "").split("/").filter(Boolean);
|
|
@@ -6750,9 +6866,9 @@ var reactDynamicClasses = astSelectorRule(':matches(JSXAttribute[name.name="clas
|
|
|
6750
6866
|
var reactEmptyEffect = astSelectorRule(':matches(CallExpression[callee.name=/^use(Layout)?Effect$/], CallExpression[callee.object.name="React"][callee.property.name=/^use(Layout)?Effect$/]) > :matches(ArrowFunctionExpression, FunctionExpression) > BlockStatement[body.length=0]', "Remove the empty effect.");
|
|
6751
6867
|
|
|
6752
6868
|
// src/rules/react/react-memo.ts
|
|
6753
|
-
import { defineRule as
|
|
6869
|
+
import { defineRule as defineRule61 } from "@oxlint/plugins";
|
|
6754
6870
|
var reactMemoNames = ["memo", "useMemo", "useCallback"];
|
|
6755
|
-
var reactMemo =
|
|
6871
|
+
var reactMemo = defineRule61({
|
|
6756
6872
|
meta: {
|
|
6757
6873
|
type: "problem",
|
|
6758
6874
|
schema: [],
|
|
@@ -6787,7 +6903,7 @@ var reactMemo = defineRule60({
|
|
|
6787
6903
|
});
|
|
6788
6904
|
|
|
6789
6905
|
// src/rules/react/react-props.ts
|
|
6790
|
-
import { defineRule as
|
|
6906
|
+
import { defineRule as defineRule62 } from "@oxlint/plugins";
|
|
6791
6907
|
function reactPropsTarget(node) {
|
|
6792
6908
|
if (node?.type === "FunctionDeclaration" || node?.type === "FunctionExpression" || node?.type === "ArrowFunctionExpression") {
|
|
6793
6909
|
return { fn: node };
|
|
@@ -6814,7 +6930,7 @@ function reactIsPassThrough(type) {
|
|
|
6814
6930
|
const argument = type.typeArguments?.params.length === 1 ? type.typeArguments.params[0] : undefined;
|
|
6815
6931
|
return name.type === "Identifier" && name.name === "ComponentProps" && (argument?.type === "TSTypeQuery" || argument?.type === "TSLiteralType" && argument.literal.type === "Literal" && typeof argument.literal.value === "string");
|
|
6816
6932
|
}
|
|
6817
|
-
var reactProps =
|
|
6933
|
+
var reactProps = defineRule62({
|
|
6818
6934
|
meta: {
|
|
6819
6935
|
type: "problem",
|
|
6820
6936
|
schema: [
|
|
@@ -6912,8 +7028,90 @@ var reactProps = defineRule61({
|
|
|
6912
7028
|
}
|
|
6913
7029
|
});
|
|
6914
7030
|
|
|
7031
|
+
// src/rules/react/react-query-props.ts
|
|
7032
|
+
import { defineRule as defineRule63 } from "@oxlint/plugins";
|
|
7033
|
+
var reactQueryProps = defineRule63({
|
|
7034
|
+
meta: {
|
|
7035
|
+
type: "problem",
|
|
7036
|
+
schema: [
|
|
7037
|
+
{
|
|
7038
|
+
type: "object",
|
|
7039
|
+
additionalProperties: false,
|
|
7040
|
+
properties: {
|
|
7041
|
+
hooks: { type: "array", items: { type: "string" } },
|
|
7042
|
+
functions: { type: "array", items: { type: "string" } }
|
|
7043
|
+
}
|
|
7044
|
+
}
|
|
7045
|
+
],
|
|
7046
|
+
messages: {
|
|
7047
|
+
options: "Build the {{hook}} options here from props; ready-made options hide where the data comes from.",
|
|
7048
|
+
source: "{{key}} must be a prop or call one; pass the data function in from the app."
|
|
7049
|
+
}
|
|
7050
|
+
},
|
|
7051
|
+
createOnce(context) {
|
|
7052
|
+
return {
|
|
7053
|
+
CallExpression(node) {
|
|
7054
|
+
const { hooks = ["useQuery", "useMutation", "useInfiniteQuery", "useSuspenseQuery"], functions = ["queryFn", "mutationFn"] } = optionsFirst(context, {});
|
|
7055
|
+
const hook = astCallName(node);
|
|
7056
|
+
let owner = node.parent;
|
|
7057
|
+
while (owner && owner.type !== "FunctionDeclaration" && !astIsInlineFunction(owner)) {
|
|
7058
|
+
owner = owner.parent;
|
|
7059
|
+
}
|
|
7060
|
+
if (!hook || !hooks.includes(hook) || !owner || owner.type !== "FunctionDeclaration" && !astIsInlineFunction(owner)) {
|
|
7061
|
+
return;
|
|
7062
|
+
}
|
|
7063
|
+
const component = owner;
|
|
7064
|
+
const first = component.params.at(0);
|
|
7065
|
+
const parameter = first?.type === "AssignmentPattern" ? first.left : first;
|
|
7066
|
+
const definition = (identifier) => boundariesDeclaredVariable(context.sourceCode.getScope(identifier), identifier.name)?.defs.at(0);
|
|
7067
|
+
const isProps = (value) => {
|
|
7068
|
+
const found = value?.type === "Identifier" ? definition(value) : undefined;
|
|
7069
|
+
return found?.type === "Parameter" && found.node === component && parameter?.type === "Identifier";
|
|
7070
|
+
};
|
|
7071
|
+
const isProp = (value) => {
|
|
7072
|
+
if (value.type === "MemberExpression") {
|
|
7073
|
+
return isProps(value.object);
|
|
7074
|
+
}
|
|
7075
|
+
const found = value.type === "Identifier" ? definition(value) : undefined;
|
|
7076
|
+
if (found?.type === "Parameter") {
|
|
7077
|
+
return found.node === component && parameter?.type === "ObjectPattern";
|
|
7078
|
+
}
|
|
7079
|
+
return found?.type === "Variable" && found.node.type === "VariableDeclarator" && found.node.id.type === "ObjectPattern" && isProps(found.node.init);
|
|
7080
|
+
};
|
|
7081
|
+
const options = node.arguments.at(0);
|
|
7082
|
+
if (options?.type !== "ObjectExpression" || options.properties.some((property) => property.type === "SpreadElement")) {
|
|
7083
|
+
context.report({
|
|
7084
|
+
node: options ?? node,
|
|
7085
|
+
messageId: "options",
|
|
7086
|
+
data: { hook }
|
|
7087
|
+
});
|
|
7088
|
+
return;
|
|
7089
|
+
}
|
|
7090
|
+
for (const property of options.properties) {
|
|
7091
|
+
if (property.type !== "Property") {
|
|
7092
|
+
continue;
|
|
7093
|
+
}
|
|
7094
|
+
const key = property.key.type === "Identifier" && !property.computed ? property.key.name : astStaticString(property.key);
|
|
7095
|
+
if (key === undefined || !functions.includes(key)) {
|
|
7096
|
+
continue;
|
|
7097
|
+
}
|
|
7098
|
+
const { value } = property;
|
|
7099
|
+
const calls = astIsInlineFunction(value) && astSome(value.body, (child) => child.type === "CallExpression" && isProp(child.callee));
|
|
7100
|
+
if (!isProp(value) && !calls) {
|
|
7101
|
+
context.report({
|
|
7102
|
+
node: value,
|
|
7103
|
+
messageId: "source",
|
|
7104
|
+
data: { key }
|
|
7105
|
+
});
|
|
7106
|
+
}
|
|
7107
|
+
}
|
|
7108
|
+
}
|
|
7109
|
+
};
|
|
7110
|
+
}
|
|
7111
|
+
});
|
|
7112
|
+
|
|
6915
7113
|
// src/rules/schemas/schemas-inline.ts
|
|
6916
|
-
import { defineRule as
|
|
7114
|
+
import { defineRule as defineRule64 } from "@oxlint/plugins";
|
|
6917
7115
|
|
|
6918
7116
|
// src/utils/schemas.utils.ts
|
|
6919
7117
|
var schemasElementOptionsSchema = {
|
|
@@ -6949,7 +7147,7 @@ function schemasIsAllowedElement(node, allowScalars, namespaces, structuralMetho
|
|
|
6949
7147
|
}
|
|
6950
7148
|
|
|
6951
7149
|
// src/rules/schemas/schemas-inline.ts
|
|
6952
|
-
var schemasInline =
|
|
7150
|
+
var schemasInline = defineRule64({
|
|
6953
7151
|
meta: {
|
|
6954
7152
|
type: "problem",
|
|
6955
7153
|
schema: [schemasElementOptionsSchema],
|
|
@@ -6998,11 +7196,11 @@ var schemasInline = defineRule62({
|
|
|
6998
7196
|
});
|
|
6999
7197
|
|
|
7000
7198
|
// src/rules/schemas/schemas-local.ts
|
|
7001
|
-
import { defineRule as
|
|
7199
|
+
import { defineRule as defineRule65 } from "@oxlint/plugins";
|
|
7002
7200
|
var schemasLocalImportMessage = "Do not import runtime schema constructors from {{source}}; import a named schema instead.";
|
|
7003
7201
|
var schemasLocalConstructionMessage = "Do not construct schemas locally; import a named schema instead.";
|
|
7004
7202
|
var schemasLocalCalls = ["config", "prettifyError", "treeifyError", "flattenError", "formatError"];
|
|
7005
|
-
var schemasLocal =
|
|
7203
|
+
var schemasLocal = defineRule65({
|
|
7006
7204
|
meta: {
|
|
7007
7205
|
type: "problem",
|
|
7008
7206
|
schema: [
|
|
@@ -7151,8 +7349,8 @@ var schemasLocal = defineRule63({
|
|
|
7151
7349
|
});
|
|
7152
7350
|
|
|
7153
7351
|
// src/rules/schemas/schemas-rederive.ts
|
|
7154
|
-
import { defineRule as
|
|
7155
|
-
var schemasRederive =
|
|
7352
|
+
import { defineRule as defineRule66 } from "@oxlint/plugins";
|
|
7353
|
+
var schemasRederive = defineRule66({
|
|
7156
7354
|
meta: {
|
|
7157
7355
|
type: "problem",
|
|
7158
7356
|
schema: [
|
|
@@ -7198,7 +7396,7 @@ var schemasRederive = defineRule64({
|
|
|
7198
7396
|
});
|
|
7199
7397
|
|
|
7200
7398
|
// src/rules/schemas/schemas-single-use.ts
|
|
7201
|
-
import { defineRule as
|
|
7399
|
+
import { defineRule as defineRule67 } from "@oxlint/plugins";
|
|
7202
7400
|
function isScalarSchema(node, namespaces, structuralMethods) {
|
|
7203
7401
|
if (node.type !== "CallExpression" || node.callee.type !== "MemberExpression") {
|
|
7204
7402
|
return false;
|
|
@@ -7212,7 +7410,7 @@ function isScalarSchema(node, namespaces, structuralMethods) {
|
|
|
7212
7410
|
}
|
|
7213
7411
|
return node.callee.object.type === "CallExpression" && isScalarSchema(node.callee.object, namespaces, structuralMethods);
|
|
7214
7412
|
}
|
|
7215
|
-
var schemasSingleUse =
|
|
7413
|
+
var schemasSingleUse = defineRule67({
|
|
7216
7414
|
meta: {
|
|
7217
7415
|
type: "suggestion",
|
|
7218
7416
|
schema: [schemasElementOptionsSchema],
|
|
@@ -7288,7 +7486,7 @@ var schemasSingleUse = defineRule65({
|
|
|
7288
7486
|
});
|
|
7289
7487
|
|
|
7290
7488
|
// src/rules/tests/tests-assertions.ts
|
|
7291
|
-
import { defineRule as
|
|
7489
|
+
import { defineRule as defineRule68 } from "@oxlint/plugins";
|
|
7292
7490
|
var testsAssertionsModifiers = new Set(["for", "each", "concurrent", "sequential", "only", "skip"]);
|
|
7293
7491
|
var testsAssertionsFunctions = [
|
|
7294
7492
|
"expect",
|
|
@@ -7478,7 +7676,7 @@ function isAssertedTest(registration, sourceCode, state) {
|
|
|
7478
7676
|
}
|
|
7479
7677
|
return rows.length > 0 && rows.every((row) => hasAssertion(callback, row.bindings, new Set, state));
|
|
7480
7678
|
}
|
|
7481
|
-
var testsAssertions =
|
|
7679
|
+
var testsAssertions = defineRule68({
|
|
7482
7680
|
meta: {
|
|
7483
7681
|
type: "problem",
|
|
7484
7682
|
schema: [
|
|
@@ -7604,8 +7802,8 @@ var testsAssertions = defineRule66({
|
|
|
7604
7802
|
});
|
|
7605
7803
|
|
|
7606
7804
|
// src/rules/tests/tests-concurrent-db.ts
|
|
7607
|
-
import { defineRule as
|
|
7608
|
-
var testsConcurrentDb =
|
|
7805
|
+
import { defineRule as defineRule69 } from "@oxlint/plugins";
|
|
7806
|
+
var testsConcurrentDb = defineRule69({
|
|
7609
7807
|
meta: {
|
|
7610
7808
|
type: "problem",
|
|
7611
7809
|
schema: [
|
|
@@ -7661,7 +7859,7 @@ var testsConcurrentDb = defineRule67({
|
|
|
7661
7859
|
});
|
|
7662
7860
|
|
|
7663
7861
|
// src/rules/tests/tests-modifiers.ts
|
|
7664
|
-
import { defineRule as
|
|
7862
|
+
import { defineRule as defineRule70 } from "@oxlint/plugins";
|
|
7665
7863
|
var testsModifiersNames = ["test", "it", "describe", "suite"];
|
|
7666
7864
|
var testsModifiersPackages = new Set(["vitest", "bun:test", "@playwright/test", "@jest/globals"]);
|
|
7667
7865
|
var testsModifiersBanned = ["only", "skip", "todo"];
|
|
@@ -7680,7 +7878,7 @@ function modifierName(node) {
|
|
|
7680
7878
|
const property = astMemberName(node);
|
|
7681
7879
|
return object && property ? `${object}.${property}` : undefined;
|
|
7682
7880
|
}
|
|
7683
|
-
var testsModifiers =
|
|
7881
|
+
var testsModifiers = defineRule70({
|
|
7684
7882
|
meta: {
|
|
7685
7883
|
type: "problem",
|
|
7686
7884
|
schema: [
|
|
@@ -7734,9 +7932,9 @@ var testsModifiers = defineRule68({
|
|
|
7734
7932
|
});
|
|
7735
7933
|
|
|
7736
7934
|
// src/rules/tests/tests-titles.ts
|
|
7737
|
-
import { defineRule as
|
|
7935
|
+
import { defineRule as defineRule71 } from "@oxlint/plugins";
|
|
7738
7936
|
var testsTitlesModifiers = ["only", "skip", "concurrent", "sequential", "todo", "each", "for"];
|
|
7739
|
-
var testsTitles =
|
|
7937
|
+
var testsTitles = defineRule71({
|
|
7740
7938
|
meta: {
|
|
7741
7939
|
type: "suggestion",
|
|
7742
7940
|
schema: [
|
|
@@ -7814,11 +8012,11 @@ var testsTitles = defineRule69({
|
|
|
7814
8012
|
});
|
|
7815
8013
|
|
|
7816
8014
|
// src/rules/types/types-declarations.ts
|
|
7817
|
-
import { defineRule as
|
|
8015
|
+
import { defineRule as defineRule72 } from "@oxlint/plugins";
|
|
7818
8016
|
function isValuePattern(source) {
|
|
7819
8017
|
return /^\^?=/.test(source);
|
|
7820
8018
|
}
|
|
7821
|
-
var typesDeclarations =
|
|
8019
|
+
var typesDeclarations = defineRule72({
|
|
7822
8020
|
meta: {
|
|
7823
8021
|
type: "problem",
|
|
7824
8022
|
schema: [
|
|
@@ -7826,7 +8024,8 @@ var typesDeclarations = defineRule70({
|
|
|
7826
8024
|
type: "object",
|
|
7827
8025
|
additionalProperties: false,
|
|
7828
8026
|
properties: {
|
|
7829
|
-
allow: optionsPatternSchema
|
|
8027
|
+
allow: optionsPatternSchema,
|
|
8028
|
+
modules: { type: "boolean" }
|
|
7830
8029
|
}
|
|
7831
8030
|
}
|
|
7832
8031
|
],
|
|
@@ -7837,8 +8036,14 @@ var typesDeclarations = defineRule70({
|
|
|
7837
8036
|
createOnce(context) {
|
|
7838
8037
|
let allowedNames = [];
|
|
7839
8038
|
let allowedValues = [];
|
|
8039
|
+
let allowModules = false;
|
|
7840
8040
|
function check(node) {
|
|
7841
|
-
|
|
8041
|
+
let ancestor = node.parent;
|
|
8042
|
+
while (allowModules && ancestor && ancestor.type !== "TSModuleDeclaration") {
|
|
8043
|
+
ancestor = ancestor.parent;
|
|
8044
|
+
}
|
|
8045
|
+
const ambient = ancestor?.type === "TSModuleDeclaration" && (ancestor.kind === "global" || ancestor.id.type === "Literal");
|
|
8046
|
+
if (allowModules && ambient || optionsPatternsTest(allowedNames, node.id.name) || node.type === "TSTypeAliasDeclaration" && allowedValues.length > 0 && optionsPatternsTest(allowedValues, `= ${context.sourceCode.getText(node.typeAnnotation)}`)) {
|
|
7842
8047
|
return;
|
|
7843
8048
|
}
|
|
7844
8049
|
context.report({
|
|
@@ -7849,7 +8054,8 @@ var typesDeclarations = defineRule70({
|
|
|
7849
8054
|
}
|
|
7850
8055
|
return {
|
|
7851
8056
|
before() {
|
|
7852
|
-
const { allow: allowPattern } = optionsFirst(context, {});
|
|
8057
|
+
const { allow: allowPattern, modules = false } = optionsFirst(context, {});
|
|
8058
|
+
allowModules = modules;
|
|
7853
8059
|
const sources = allowPattern === undefined ? [] : [allowPattern].flat();
|
|
7854
8060
|
allowedNames = optionsPatterns(sources.filter((source) => !isValuePattern(source)));
|
|
7855
8061
|
allowedValues = optionsPatterns(sources.filter(isValuePattern));
|
|
@@ -7861,8 +8067,8 @@ var typesDeclarations = defineRule70({
|
|
|
7861
8067
|
});
|
|
7862
8068
|
|
|
7863
8069
|
// src/rules/types/types-duplicate.ts
|
|
7864
|
-
import { defineRule as
|
|
7865
|
-
var typesDuplicate =
|
|
8070
|
+
import { defineRule as defineRule73 } from "@oxlint/plugins";
|
|
8071
|
+
var typesDuplicate = defineRule73({
|
|
7866
8072
|
meta: {
|
|
7867
8073
|
type: "suggestion",
|
|
7868
8074
|
schema: [
|
|
@@ -7926,7 +8132,7 @@ var typesDuplicate = defineRule71({
|
|
|
7926
8132
|
});
|
|
7927
8133
|
|
|
7928
8134
|
// src/rules/types/types-imported-alias.ts
|
|
7929
|
-
import { defineRule as
|
|
8135
|
+
import { defineRule as defineRule74 } from "@oxlint/plugins";
|
|
7930
8136
|
function importedAliasTarget(declaration, imports) {
|
|
7931
8137
|
if (declaration?.type !== "TSTypeAliasDeclaration") {
|
|
7932
8138
|
return;
|
|
@@ -7938,7 +8144,7 @@ function importedAliasTarget(declaration, imports) {
|
|
|
7938
8144
|
const { name } = type.typeName;
|
|
7939
8145
|
return imports.has(name) && !declaration.typeParameters?.params.some((parameter) => parameter.name.name === name) ? name : undefined;
|
|
7940
8146
|
}
|
|
7941
|
-
var typesImportedAlias =
|
|
8147
|
+
var typesImportedAlias = defineRule74({
|
|
7942
8148
|
meta: {
|
|
7943
8149
|
type: "problem",
|
|
7944
8150
|
schema: [],
|
|
@@ -8000,7 +8206,7 @@ var typesImportedAlias = defineRule72({
|
|
|
8000
8206
|
});
|
|
8001
8207
|
|
|
8002
8208
|
// src/rules/types/types-inline.ts
|
|
8003
|
-
import { defineRule as
|
|
8209
|
+
import { defineRule as defineRule75 } from "@oxlint/plugins";
|
|
8004
8210
|
function parameterAnnotation(parameter) {
|
|
8005
8211
|
if (parameter.type === "TSParameterProperty") {
|
|
8006
8212
|
return parameterAnnotation(parameter.parameter);
|
|
@@ -8010,7 +8216,7 @@ function parameterAnnotation(parameter) {
|
|
|
8010
8216
|
}
|
|
8011
8217
|
return parameter.typeAnnotation;
|
|
8012
8218
|
}
|
|
8013
|
-
var typesInline =
|
|
8219
|
+
var typesInline = defineRule75({
|
|
8014
8220
|
meta: {
|
|
8015
8221
|
type: "problem",
|
|
8016
8222
|
schema: [
|
|
@@ -8021,6 +8227,9 @@ var typesInline = defineRule73({
|
|
|
8021
8227
|
parameters: { type: "boolean" },
|
|
8022
8228
|
returns: { type: "boolean" },
|
|
8023
8229
|
functions: { type: "boolean" },
|
|
8230
|
+
variables: { type: "boolean" },
|
|
8231
|
+
assertions: { type: "boolean" },
|
|
8232
|
+
arguments: { type: "boolean" },
|
|
8024
8233
|
min: { type: "integer", minimum: 1 }
|
|
8025
8234
|
}
|
|
8026
8235
|
}
|
|
@@ -8033,6 +8242,9 @@ var typesInline = defineRule73({
|
|
|
8033
8242
|
let checkParameters = true;
|
|
8034
8243
|
let checkReturns = true;
|
|
8035
8244
|
let checkFunctionTypes = true;
|
|
8245
|
+
let checkVariables = false;
|
|
8246
|
+
let checkAssertions = false;
|
|
8247
|
+
let checkArguments = false;
|
|
8036
8248
|
let minMembers = 1;
|
|
8037
8249
|
function isInline(node) {
|
|
8038
8250
|
if (node.type === "TSTypeLiteral") {
|
|
@@ -8068,11 +8280,44 @@ var typesInline = defineRule73({
|
|
|
8068
8280
|
checkParameters = options.parameters ?? true;
|
|
8069
8281
|
checkReturns = options.returns ?? true;
|
|
8070
8282
|
checkFunctionTypes = options.functions ?? true;
|
|
8283
|
+
checkVariables = options.variables ?? false;
|
|
8284
|
+
checkAssertions = options.assertions ?? false;
|
|
8285
|
+
checkArguments = options.arguments ?? false;
|
|
8071
8286
|
minMembers = options.min ?? 1;
|
|
8072
|
-
if (!checkParameters && !checkReturns) {
|
|
8287
|
+
if (!checkParameters && !checkReturns && !checkVariables && !checkAssertions && !checkArguments) {
|
|
8073
8288
|
return false;
|
|
8074
8289
|
}
|
|
8075
8290
|
},
|
|
8291
|
+
VariableDeclarator(node) {
|
|
8292
|
+
if (checkVariables) {
|
|
8293
|
+
check(parameterAnnotation(node.id), "variable");
|
|
8294
|
+
}
|
|
8295
|
+
},
|
|
8296
|
+
PropertyDefinition(node) {
|
|
8297
|
+
if (checkVariables) {
|
|
8298
|
+
check(node.typeAnnotation, "variable");
|
|
8299
|
+
}
|
|
8300
|
+
},
|
|
8301
|
+
TSAsExpression(node) {
|
|
8302
|
+
if (checkAssertions) {
|
|
8303
|
+
check(node.typeAnnotation, "assertion");
|
|
8304
|
+
}
|
|
8305
|
+
},
|
|
8306
|
+
TSSatisfiesExpression(node) {
|
|
8307
|
+
if (checkAssertions) {
|
|
8308
|
+
check(node.typeAnnotation, "assertion");
|
|
8309
|
+
}
|
|
8310
|
+
},
|
|
8311
|
+
CallExpression(node) {
|
|
8312
|
+
if (checkArguments) {
|
|
8313
|
+
check(node.typeArguments, "type argument");
|
|
8314
|
+
}
|
|
8315
|
+
},
|
|
8316
|
+
NewExpression(node) {
|
|
8317
|
+
if (checkArguments) {
|
|
8318
|
+
check(node.typeArguments, "type argument");
|
|
8319
|
+
}
|
|
8320
|
+
},
|
|
8076
8321
|
FunctionDeclaration: checkFunction,
|
|
8077
8322
|
FunctionExpression: checkFunction,
|
|
8078
8323
|
ArrowFunctionExpression: checkFunction,
|
|
@@ -8086,8 +8331,8 @@ var typesInline = defineRule73({
|
|
|
8086
8331
|
var typesLocalAlias = astSelectorRule("TSTypeAliasDeclaration", "Local component/hook contracts use interfaces named for their owner. Derived or reusable aliases belong in domain types; do not substitute an empty interface.");
|
|
8087
8332
|
|
|
8088
8333
|
// src/rules/types/types-namespace-import.ts
|
|
8089
|
-
import { defineRule as
|
|
8090
|
-
var typesNamespaceImport =
|
|
8334
|
+
import { defineRule as defineRule76 } from "@oxlint/plugins";
|
|
8335
|
+
var typesNamespaceImport = defineRule76({
|
|
8091
8336
|
meta: {
|
|
8092
8337
|
type: "suggestion",
|
|
8093
8338
|
schema: [
|
|
@@ -8129,8 +8374,8 @@ var typesNamespaceImport = defineRule74({
|
|
|
8129
8374
|
});
|
|
8130
8375
|
|
|
8131
8376
|
// src/rules/types/types-service.ts
|
|
8132
|
-
import { defineRule as
|
|
8133
|
-
var typesService =
|
|
8377
|
+
import { defineRule as defineRule77 } from "@oxlint/plugins";
|
|
8378
|
+
var typesService = defineRule77({
|
|
8134
8379
|
meta: {
|
|
8135
8380
|
type: "problem",
|
|
8136
8381
|
schema: [
|
|
@@ -8180,12 +8425,12 @@ var typesService = defineRule75({
|
|
|
8180
8425
|
});
|
|
8181
8426
|
|
|
8182
8427
|
// src/rules/types/types-unknown.ts
|
|
8183
|
-
import { defineRule as
|
|
8428
|
+
import { defineRule as defineRule78 } from "@oxlint/plugins";
|
|
8184
8429
|
function isCatchName(node) {
|
|
8185
8430
|
const key = "key" in node && !(("computed" in node) && node.computed) ? node.key : undefined;
|
|
8186
8431
|
return key?.type === "Identifier" && key.name === "catch";
|
|
8187
8432
|
}
|
|
8188
|
-
var typesUnknown =
|
|
8433
|
+
var typesUnknown = defineRule78({
|
|
8189
8434
|
meta: { type: "problem", schema: [], messages: { forbidden: "Use an owned domain type rather than unknown." } },
|
|
8190
8435
|
createOnce(context) {
|
|
8191
8436
|
return {
|
|
@@ -8224,6 +8469,7 @@ var src_default = eslintCompatPlugin({
|
|
|
8224
8469
|
"boundaries-token-owner": boundariesTokenOwner,
|
|
8225
8470
|
"code-branch-once": codeBranchOnce,
|
|
8226
8471
|
"code-constructor": codeConstructor,
|
|
8472
|
+
"code-delegate": codeDelegate,
|
|
8227
8473
|
"code-double-negation": codeDoubleNegation,
|
|
8228
8474
|
"code-function-nesting": codeFunctionNesting,
|
|
8229
8475
|
"code-inline": codeInline,
|
|
@@ -8277,6 +8523,7 @@ var src_default = eslintCompatPlugin({
|
|
|
8277
8523
|
"react-empty-effect": reactEmptyEffect,
|
|
8278
8524
|
"react-memo": reactMemo,
|
|
8279
8525
|
"react-props": reactProps,
|
|
8526
|
+
"react-query-props": reactQueryProps,
|
|
8280
8527
|
"schemas-inline": schemasInline,
|
|
8281
8528
|
"schemas-local": schemasLocal,
|
|
8282
8529
|
"schemas-rederive": schemasRederive,
|