@tanstack/eslint-plugin-router 1.161.5 → 1.161.6
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/cjs/index.cjs +22 -27
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/rules/create-route-property-order/constants.cjs +23 -36
- package/dist/cjs/rules/create-route-property-order/constants.cjs.map +1 -1
- package/dist/cjs/rules/create-route-property-order/create-route-property-order.rule.cjs +68 -98
- package/dist/cjs/rules/create-route-property-order/create-route-property-order.rule.cjs.map +1 -1
- package/dist/cjs/rules/create-route-property-order/create-route-property-order.utils.cjs +33 -44
- package/dist/cjs/rules/create-route-property-order/create-route-property-order.utils.cjs.map +1 -1
- package/dist/cjs/rules/route-param-names/constants.cjs +24 -9
- package/dist/cjs/rules/route-param-names/constants.cjs.map +1 -1
- package/dist/cjs/rules/route-param-names/route-param-names.rule.cjs +75 -95
- package/dist/cjs/rules/route-param-names/route-param-names.rule.cjs.map +1 -1
- package/dist/cjs/rules/route-param-names/route-param-names.utils.cjs +65 -54
- package/dist/cjs/rules/route-param-names/route-param-names.utils.cjs.map +1 -1
- package/dist/cjs/rules.cjs +9 -8
- package/dist/cjs/rules.cjs.map +1 -1
- package/dist/cjs/utils/detect-router-imports.cjs +35 -51
- package/dist/cjs/utils/detect-router-imports.cjs.map +1 -1
- package/dist/cjs/utils/get-docs-url.cjs +5 -4
- package/dist/cjs/utils/get-docs-url.cjs.map +1 -1
- package/dist/esm/index.js +23 -28
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/rules/create-route-property-order/constants.js +22 -37
- package/dist/esm/rules/create-route-property-order/constants.js.map +1 -1
- package/dist/esm/rules/create-route-property-order/create-route-property-order.rule.js +65 -96
- package/dist/esm/rules/create-route-property-order/create-route-property-order.rule.js.map +1 -1
- package/dist/esm/rules/create-route-property-order/create-route-property-order.utils.js +34 -46
- package/dist/esm/rules/create-route-property-order/create-route-property-order.utils.js.map +1 -1
- package/dist/esm/rules/route-param-names/constants.js +25 -12
- package/dist/esm/rules/route-param-names/constants.js.map +1 -1
- package/dist/esm/rules/route-param-names/route-param-names.rule.js +73 -94
- package/dist/esm/rules/route-param-names/route-param-names.rule.js.map +1 -1
- package/dist/esm/rules/route-param-names/route-param-names.utils.js +65 -54
- package/dist/esm/rules/route-param-names/route-param-names.utils.js.map +1 -1
- package/dist/esm/rules.js +10 -9
- package/dist/esm/rules.js.map +1 -1
- package/dist/esm/utils/detect-router-imports.js +35 -51
- package/dist/esm/utils/detect-router-imports.js.map +1 -1
- package/dist/esm/utils/get-docs-url.js +6 -5
- package/dist/esm/utils/get-docs-url.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,40 +1,25 @@
|
|
|
1
1
|
import { getCheckedProperties } from "./create-route-property-order.utils.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
[
|
|
21
|
-
["loader"],
|
|
22
|
-
[
|
|
23
|
-
"onEnter",
|
|
24
|
-
"onStay",
|
|
25
|
-
"onLeave",
|
|
26
|
-
"head",
|
|
27
|
-
"scripts",
|
|
28
|
-
"headers",
|
|
29
|
-
"remountDeps"
|
|
30
|
-
]
|
|
31
|
-
]
|
|
2
|
+
//#region src/rules/create-route-property-order/constants.ts
|
|
3
|
+
var createRouteFunctionsIndirect = ["createFileRoute", "createRootRouteWithContext"];
|
|
4
|
+
var createRouteFunctions = [...["createRootRoute", "createRoute"], ...createRouteFunctionsIndirect];
|
|
5
|
+
var sortRules = [
|
|
6
|
+
[["params", "validateSearch"], ["search"]],
|
|
7
|
+
[["search"], ["loaderDeps", "ssr"]],
|
|
8
|
+
[["loaderDeps"], ["context"]],
|
|
9
|
+
[["context"], ["beforeLoad"]],
|
|
10
|
+
[["beforeLoad"], ["loader"]],
|
|
11
|
+
[["loader"], [
|
|
12
|
+
"onEnter",
|
|
13
|
+
"onStay",
|
|
14
|
+
"onLeave",
|
|
15
|
+
"head",
|
|
16
|
+
"scripts",
|
|
17
|
+
"headers",
|
|
18
|
+
"remountDeps"
|
|
19
|
+
]]
|
|
32
20
|
];
|
|
33
21
|
getCheckedProperties(sortRules);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
sortRules
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=constants.js.map
|
|
22
|
+
//#endregion
|
|
23
|
+
export { createRouteFunctions, createRouteFunctionsIndirect, sortRules };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/rules/create-route-property-order/constants.ts"],"sourcesContent":["import { getCheckedProperties } from './create-route-property-order.utils'\n\nexport const createRouteFunctionsIndirect = [\n 'createFileRoute',\n 'createRootRouteWithContext',\n] as const\nexport const createRouteFunctionsDirect = [\n 'createRootRoute',\n 'createRoute',\n] as const\n\nexport const createRouteFunctions = [\n ...createRouteFunctionsDirect,\n ...createRouteFunctionsIndirect,\n] as const\n\nexport type CreateRouteFunction = (typeof createRouteFunctions)[number]\n\nexport const sortRules = [\n [['params', 'validateSearch'], ['search']],\n [['search'], ['loaderDeps', 'ssr']],\n [['loaderDeps'], ['context']],\n [['context'], ['beforeLoad']],\n [['beforeLoad'], ['loader']],\n [\n ['loader'],\n [\n 'onEnter',\n 'onStay',\n 'onLeave',\n 'head',\n 'scripts',\n 'headers',\n 'remountDeps',\n ],\n ],\n] as const\n\nexport type CheckedProperties = (typeof sortRules)[number][number][number]\nexport const checkedProperties = getCheckedProperties(sortRules)\n"],"
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../../src/rules/create-route-property-order/constants.ts"],"sourcesContent":["import { getCheckedProperties } from './create-route-property-order.utils'\n\nexport const createRouteFunctionsIndirect = [\n 'createFileRoute',\n 'createRootRouteWithContext',\n] as const\nexport const createRouteFunctionsDirect = [\n 'createRootRoute',\n 'createRoute',\n] as const\n\nexport const createRouteFunctions = [\n ...createRouteFunctionsDirect,\n ...createRouteFunctionsIndirect,\n] as const\n\nexport type CreateRouteFunction = (typeof createRouteFunctions)[number]\n\nexport const sortRules = [\n [['params', 'validateSearch'], ['search']],\n [['search'], ['loaderDeps', 'ssr']],\n [['loaderDeps'], ['context']],\n [['context'], ['beforeLoad']],\n [['beforeLoad'], ['loader']],\n [\n ['loader'],\n [\n 'onEnter',\n 'onStay',\n 'onLeave',\n 'head',\n 'scripts',\n 'headers',\n 'remountDeps',\n ],\n ],\n] as const\n\nexport type CheckedProperties = (typeof sortRules)[number][number][number]\nexport const checkedProperties = getCheckedProperties(sortRules)\n"],"mappings":";;AAEA,IAAa,+BAA+B,CAC1C,mBACA,6BACD;AAMD,IAAa,uBAAuB,CAClC,GANwC,CACxC,mBACA,cACD,EAIC,GAAG,6BACJ;AAID,IAAa,YAAY;CACvB,CAAC,CAAC,UAAU,iBAAiB,EAAE,CAAC,SAAS,CAAC;CAC1C,CAAC,CAAC,SAAS,EAAE,CAAC,cAAc,MAAM,CAAC;CACnC,CAAC,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC;CAC7B,CAAC,CAAC,UAAU,EAAE,CAAC,aAAa,CAAC;CAC7B,CAAC,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC;CAC5B,CACE,CAAC,SAAS,EACV;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;CACF;AAGgC,qBAAqB,UAAU"}
|
|
@@ -1,103 +1,72 @@
|
|
|
1
|
-
import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
2
1
|
import { getDocsUrl } from "../../utils/get-docs-url.js";
|
|
3
2
|
import { detectTanstackRouterImports } from "../../utils/detect-router-imports.js";
|
|
4
3
|
import { sortDataByOrder } from "./create-route-property-order.utils.js";
|
|
5
4
|
import { createRouteFunctions, createRouteFunctionsIndirect, sortRules } from "./constants.js";
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
6
|
+
//#region src/rules/create-route-property-order/create-route-property-order.rule.ts
|
|
7
|
+
var createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
8
|
+
var createRouteFunctionSet = new Set(createRouteFunctions);
|
|
8
9
|
function isCreateRouteFunction(node) {
|
|
9
|
-
|
|
10
|
+
return createRouteFunctionSet.has(node);
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (sortedProperties === null) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
context.report({
|
|
71
|
-
node: argument,
|
|
72
|
-
data: { function: node.callee.name },
|
|
73
|
-
messageId: "invalidOrder",
|
|
74
|
-
fix(fixer) {
|
|
75
|
-
const sourceCode = context.sourceCode;
|
|
76
|
-
const text = sortedProperties.reduce(
|
|
77
|
-
(sourceText, specifier, index) => {
|
|
78
|
-
let text2 = "";
|
|
79
|
-
if (index < allProperties.length - 1) {
|
|
80
|
-
text2 = sourceCode.getText().slice(
|
|
81
|
-
allProperties[index].range[1],
|
|
82
|
-
allProperties[index + 1].range[0]
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return sourceText + sourceCode.getText(specifier.property) + text2;
|
|
86
|
-
},
|
|
87
|
-
""
|
|
88
|
-
);
|
|
89
|
-
return fixer.replaceTextRange(
|
|
90
|
-
[allProperties[0].range[0], allProperties.at(-1).range[1]],
|
|
91
|
-
text
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
})
|
|
12
|
+
var name = "create-route-property-order";
|
|
13
|
+
var rule = createRule({
|
|
14
|
+
name,
|
|
15
|
+
meta: {
|
|
16
|
+
type: "problem",
|
|
17
|
+
docs: {
|
|
18
|
+
description: "Ensure correct order of inference sensitive properties for createRoute functions",
|
|
19
|
+
recommended: "error"
|
|
20
|
+
},
|
|
21
|
+
messages: { invalidOrder: "Invalid order of properties for `{{function}}`." },
|
|
22
|
+
schema: [],
|
|
23
|
+
hasSuggestions: true,
|
|
24
|
+
fixable: "code"
|
|
25
|
+
},
|
|
26
|
+
defaultOptions: [],
|
|
27
|
+
create: detectTanstackRouterImports((context) => {
|
|
28
|
+
return { CallExpression(node) {
|
|
29
|
+
if (node.callee.type !== AST_NODE_TYPES.Identifier) return;
|
|
30
|
+
const createRouteFunction = node.callee.name;
|
|
31
|
+
if (!isCreateRouteFunction(createRouteFunction)) return;
|
|
32
|
+
let args = node.arguments;
|
|
33
|
+
if (createRouteFunctionsIndirect.includes(createRouteFunction)) if (node.parent.type === AST_NODE_TYPES.CallExpression) args = node.parent.arguments;
|
|
34
|
+
else return;
|
|
35
|
+
const argument = args[0];
|
|
36
|
+
if (argument === void 0 || argument.type !== "ObjectExpression") return;
|
|
37
|
+
const allProperties = argument.properties;
|
|
38
|
+
if (allProperties.length < 2) return;
|
|
39
|
+
const sortedProperties = sortDataByOrder(allProperties.flatMap((p) => {
|
|
40
|
+
if (p.type === AST_NODE_TYPES.Property && p.key.type === AST_NODE_TYPES.Identifier) return {
|
|
41
|
+
name: p.key.name,
|
|
42
|
+
property: p
|
|
43
|
+
};
|
|
44
|
+
else if (p.type === AST_NODE_TYPES.SpreadElement) if (p.argument.type === AST_NODE_TYPES.Identifier) return {
|
|
45
|
+
name: p.argument.name,
|
|
46
|
+
property: p
|
|
47
|
+
};
|
|
48
|
+
else throw new Error("Unsupported spread element");
|
|
49
|
+
return [];
|
|
50
|
+
}), sortRules, "name");
|
|
51
|
+
if (sortedProperties === null) return;
|
|
52
|
+
context.report({
|
|
53
|
+
node: argument,
|
|
54
|
+
data: { function: node.callee.name },
|
|
55
|
+
messageId: "invalidOrder",
|
|
56
|
+
fix(fixer) {
|
|
57
|
+
const sourceCode = context.sourceCode;
|
|
58
|
+
const text = sortedProperties.reduce((sourceText, specifier, index) => {
|
|
59
|
+
let text = "";
|
|
60
|
+
if (index < allProperties.length - 1) text = sourceCode.getText().slice(allProperties[index].range[1], allProperties[index + 1].range[0]);
|
|
61
|
+
return sourceText + sourceCode.getText(specifier.property) + text;
|
|
62
|
+
}, "");
|
|
63
|
+
return fixer.replaceTextRange([allProperties[0].range[0], allProperties.at(-1).range[1]], text);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
} };
|
|
67
|
+
})
|
|
98
68
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
//# sourceMappingURL=create-route-property-order.rule.js.map
|
|
69
|
+
//#endregion
|
|
70
|
+
export { name, rule };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=create-route-property-order.rule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-route-property-order.rule.js","sources":["../../../../src/rules/create-route-property-order/create-route-property-order.rule.ts"],"sourcesContent":["import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils'\n\nimport { getDocsUrl } from '../../utils/get-docs-url'\nimport { detectTanstackRouterImports } from '../../utils/detect-router-imports'\nimport { sortDataByOrder } from './create-route-property-order.utils'\nimport {\n createRouteFunctions,\n createRouteFunctionsIndirect,\n sortRules,\n} from './constants'\nimport type { CreateRouteFunction } from './constants'\nimport type { ExtraRuleDocs } from '../../types'\n\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl)\n\nconst createRouteFunctionSet = new Set(createRouteFunctions)\nfunction isCreateRouteFunction(node: any): node is CreateRouteFunction {\n return createRouteFunctionSet.has(node)\n}\n\nexport const name = 'create-route-property-order'\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Ensure correct order of inference sensitive properties for createRoute functions',\n recommended: 'error',\n },\n messages: {\n invalidOrder: 'Invalid order of properties for `{{function}}`.',\n },\n schema: [],\n hasSuggestions: true,\n fixable: 'code',\n },\n defaultOptions: [],\n\n create: detectTanstackRouterImports((context) => {\n return {\n CallExpression(node) {\n if (node.callee.type !== AST_NODE_TYPES.Identifier) {\n return\n }\n const createRouteFunction = node.callee.name\n if (!isCreateRouteFunction(createRouteFunction)) {\n return\n }\n let args = node.arguments\n if (createRouteFunctionsIndirect.includes(createRouteFunction as any)) {\n if (node.parent.type === AST_NODE_TYPES.CallExpression) {\n args = node.parent.arguments\n } else {\n return\n }\n }\n\n const argument = args[0]\n if (argument === undefined || argument.type !== 'ObjectExpression') {\n return\n }\n\n const allProperties = argument.properties\n // no need to sort if there is at max 1 property\n if (allProperties.length < 2) {\n return\n }\n\n const properties = allProperties.flatMap((p) => {\n if (\n p.type === AST_NODE_TYPES.Property &&\n p.key.type === AST_NODE_TYPES.Identifier\n ) {\n return { name: p.key.name, property: p }\n } else if (p.type === AST_NODE_TYPES.SpreadElement) {\n if (p.argument.type === AST_NODE_TYPES.Identifier) {\n return { name: p.argument.name, property: p }\n } else {\n throw new Error('Unsupported spread element')\n }\n }\n return []\n })\n\n const sortedProperties = sortDataByOrder(properties, sortRules, 'name')\n if (sortedProperties === null) {\n return\n }\n context.report({\n node: argument,\n data: { function: node.callee.name },\n messageId: 'invalidOrder',\n fix(fixer) {\n const sourceCode = context.sourceCode\n\n const text = sortedProperties.reduce(\n (sourceText, specifier, index) => {\n let text = ''\n if (index < allProperties.length - 1) {\n text = sourceCode\n .getText()\n .slice(\n allProperties[index]!.range[1],\n allProperties[index + 1]!.range[0],\n )\n }\n return (\n sourceText + sourceCode.getText(specifier.property) + text\n )\n },\n '',\n )\n return fixer.replaceTextRange(\n [allProperties[0]!.range[0], allProperties.at(-1)!.range[1]],\n text,\n )\n },\n })\n },\n }\n }),\n})\n"],"
|
|
1
|
+
{"version":3,"file":"create-route-property-order.rule.js","names":[],"sources":["../../../../src/rules/create-route-property-order/create-route-property-order.rule.ts"],"sourcesContent":["import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils'\n\nimport { getDocsUrl } from '../../utils/get-docs-url'\nimport { detectTanstackRouterImports } from '../../utils/detect-router-imports'\nimport { sortDataByOrder } from './create-route-property-order.utils'\nimport {\n createRouteFunctions,\n createRouteFunctionsIndirect,\n sortRules,\n} from './constants'\nimport type { CreateRouteFunction } from './constants'\nimport type { ExtraRuleDocs } from '../../types'\n\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl)\n\nconst createRouteFunctionSet = new Set(createRouteFunctions)\nfunction isCreateRouteFunction(node: any): node is CreateRouteFunction {\n return createRouteFunctionSet.has(node)\n}\n\nexport const name = 'create-route-property-order'\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Ensure correct order of inference sensitive properties for createRoute functions',\n recommended: 'error',\n },\n messages: {\n invalidOrder: 'Invalid order of properties for `{{function}}`.',\n },\n schema: [],\n hasSuggestions: true,\n fixable: 'code',\n },\n defaultOptions: [],\n\n create: detectTanstackRouterImports((context) => {\n return {\n CallExpression(node) {\n if (node.callee.type !== AST_NODE_TYPES.Identifier) {\n return\n }\n const createRouteFunction = node.callee.name\n if (!isCreateRouteFunction(createRouteFunction)) {\n return\n }\n let args = node.arguments\n if (createRouteFunctionsIndirect.includes(createRouteFunction as any)) {\n if (node.parent.type === AST_NODE_TYPES.CallExpression) {\n args = node.parent.arguments\n } else {\n return\n }\n }\n\n const argument = args[0]\n if (argument === undefined || argument.type !== 'ObjectExpression') {\n return\n }\n\n const allProperties = argument.properties\n // no need to sort if there is at max 1 property\n if (allProperties.length < 2) {\n return\n }\n\n const properties = allProperties.flatMap((p) => {\n if (\n p.type === AST_NODE_TYPES.Property &&\n p.key.type === AST_NODE_TYPES.Identifier\n ) {\n return { name: p.key.name, property: p }\n } else if (p.type === AST_NODE_TYPES.SpreadElement) {\n if (p.argument.type === AST_NODE_TYPES.Identifier) {\n return { name: p.argument.name, property: p }\n } else {\n throw new Error('Unsupported spread element')\n }\n }\n return []\n })\n\n const sortedProperties = sortDataByOrder(properties, sortRules, 'name')\n if (sortedProperties === null) {\n return\n }\n context.report({\n node: argument,\n data: { function: node.callee.name },\n messageId: 'invalidOrder',\n fix(fixer) {\n const sourceCode = context.sourceCode\n\n const text = sortedProperties.reduce(\n (sourceText, specifier, index) => {\n let text = ''\n if (index < allProperties.length - 1) {\n text = sourceCode\n .getText()\n .slice(\n allProperties[index]!.range[1],\n allProperties[index + 1]!.range[0],\n )\n }\n return (\n sourceText + sourceCode.getText(specifier.property) + text\n )\n },\n '',\n )\n return fixer.replaceTextRange(\n [allProperties[0]!.range[0], allProperties.at(-1)!.range[1]],\n text,\n )\n },\n })\n },\n }\n }),\n})\n"],"mappings":";;;;;;AAaA,IAAM,aAAa,YAAY,YAA2B,WAAW;AAErE,IAAM,yBAAyB,IAAI,IAAI,qBAAqB;AAC5D,SAAS,sBAAsB,MAAwC;AACrE,QAAO,uBAAuB,IAAI,KAAK;;AAGzC,IAAa,OAAO;AAEpB,IAAa,OAAO,WAAW;CAC7B;CACA,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aACE;GACF,aAAa;GACd;EACD,UAAU,EACR,cAAc,mDACf;EACD,QAAQ,EAAE;EACV,gBAAgB;EAChB,SAAS;EACV;CACD,gBAAgB,EAAE;CAElB,QAAQ,6BAA6B,YAAY;AAC/C,SAAO,EACL,eAAe,MAAM;AACnB,OAAI,KAAK,OAAO,SAAS,eAAe,WACtC;GAEF,MAAM,sBAAsB,KAAK,OAAO;AACxC,OAAI,CAAC,sBAAsB,oBAAoB,CAC7C;GAEF,IAAI,OAAO,KAAK;AAChB,OAAI,6BAA6B,SAAS,oBAA2B,CACnE,KAAI,KAAK,OAAO,SAAS,eAAe,eACtC,QAAO,KAAK,OAAO;OAEnB;GAIJ,MAAM,WAAW,KAAK;AACtB,OAAI,aAAa,KAAA,KAAa,SAAS,SAAS,mBAC9C;GAGF,MAAM,gBAAgB,SAAS;AAE/B,OAAI,cAAc,SAAS,EACzB;GAmBF,MAAM,mBAAmB,gBAhBN,cAAc,SAAS,MAAM;AAC9C,QACE,EAAE,SAAS,eAAe,YAC1B,EAAE,IAAI,SAAS,eAAe,WAE9B,QAAO;KAAE,MAAM,EAAE,IAAI;KAAM,UAAU;KAAG;aAC/B,EAAE,SAAS,eAAe,cACnC,KAAI,EAAE,SAAS,SAAS,eAAe,WACrC,QAAO;KAAE,MAAM,EAAE,SAAS;KAAM,UAAU;KAAG;QAE7C,OAAM,IAAI,MAAM,6BAA6B;AAGjD,WAAO,EAAE;KACT,EAEmD,WAAW,OAAO;AACvE,OAAI,qBAAqB,KACvB;AAEF,WAAQ,OAAO;IACb,MAAM;IACN,MAAM,EAAE,UAAU,KAAK,OAAO,MAAM;IACpC,WAAW;IACX,IAAI,OAAO;KACT,MAAM,aAAa,QAAQ;KAE3B,MAAM,OAAO,iBAAiB,QAC3B,YAAY,WAAW,UAAU;MAChC,IAAI,OAAO;AACX,UAAI,QAAQ,cAAc,SAAS,EACjC,QAAO,WACJ,SAAS,CACT,MACC,cAAc,OAAQ,MAAM,IAC5B,cAAc,QAAQ,GAAI,MAAM,GACjC;AAEL,aACE,aAAa,WAAW,QAAQ,UAAU,SAAS,GAAG;QAG1D,GACD;AACD,YAAO,MAAM,iBACX,CAAC,cAAc,GAAI,MAAM,IAAI,cAAc,GAAG,GAAG,CAAE,MAAM,GAAG,EAC5D,KACD;;IAEJ,CAAC;KAEL;GACD;CACH,CAAC"}
|
|
@@ -1,50 +1,38 @@
|
|
|
1
|
+
//#region src/rules/create-route-property-order/create-route-property-order.utils.ts
|
|
1
2
|
function sortDataByOrder(data, orderRules, key) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const sortedItem = inOrderIterator.next().value;
|
|
31
|
-
if (sortedItem[key] !== item[key]) {
|
|
32
|
-
wasResorted = true;
|
|
33
|
-
}
|
|
34
|
-
return sortedItem;
|
|
35
|
-
}
|
|
36
|
-
return item;
|
|
37
|
-
});
|
|
38
|
-
if (!wasResorted) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
3
|
+
const getSubsetIndex = (item, subsets) => {
|
|
4
|
+
for (let i = 0; i < subsets.length; i++) if (subsets[i]?.includes(item)) return i;
|
|
5
|
+
return null;
|
|
6
|
+
};
|
|
7
|
+
const orderSets = orderRules.reduce((sets, [A, B]) => [
|
|
8
|
+
...sets,
|
|
9
|
+
A,
|
|
10
|
+
B
|
|
11
|
+
], []);
|
|
12
|
+
const inOrderArray = data.filter((item) => getSubsetIndex(item[key], orderSets) !== null);
|
|
13
|
+
let wasResorted = false;
|
|
14
|
+
const inOrderIterator = inOrderArray.sort((a, b) => {
|
|
15
|
+
const aKey = a[key], bKey = b[key];
|
|
16
|
+
const aSubsetIndex = getSubsetIndex(aKey, orderSets);
|
|
17
|
+
const bSubsetIndex = getSubsetIndex(bKey, orderSets);
|
|
18
|
+
if (aSubsetIndex !== null && bSubsetIndex !== null && aSubsetIndex !== bSubsetIndex) return aSubsetIndex - bSubsetIndex;
|
|
19
|
+
return 0;
|
|
20
|
+
}).values();
|
|
21
|
+
const result = data.map((item) => {
|
|
22
|
+
if (getSubsetIndex(item[key], orderSets) !== null) {
|
|
23
|
+
const sortedItem = inOrderIterator.next().value;
|
|
24
|
+
if (sortedItem[key] !== item[key]) wasResorted = true;
|
|
25
|
+
return sortedItem;
|
|
26
|
+
}
|
|
27
|
+
return item;
|
|
28
|
+
});
|
|
29
|
+
if (!wasResorted) return null;
|
|
30
|
+
return result;
|
|
42
31
|
}
|
|
43
32
|
function getCheckedProperties(orderRules) {
|
|
44
|
-
|
|
33
|
+
return [...new Set(orderRules.flat(2))];
|
|
45
34
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=create-route-property-order.utils.js.map
|
|
35
|
+
//#endregion
|
|
36
|
+
export { getCheckedProperties, sortDataByOrder };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=create-route-property-order.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-route-property-order.utils.js","sources":["../../../../src/rules/create-route-property-order/create-route-property-order.utils.ts"],"sourcesContent":["export function sortDataByOrder<T, TKey extends keyof T>(\n data: Array<T> | ReadonlyArray<T>,\n orderRules: ReadonlyArray<\n Readonly<[ReadonlyArray<T[TKey]>, ReadonlyArray<T[TKey]>]>\n >,\n key: TKey,\n): Array<T> | null {\n const getSubsetIndex = (\n item: T[TKey],\n subsets: ReadonlyArray<ReadonlyArray<T[TKey]> | Array<T[TKey]>>,\n ): number | null => {\n for (let i = 0; i < subsets.length; i++) {\n if (subsets[i]?.includes(item)) {\n return i\n }\n }\n return null\n }\n\n const orderSets = orderRules.reduce(\n (sets, [A, B]) => [...sets, A, B],\n [] as Array<ReadonlyArray<T[TKey]> | Array<T[TKey]>>,\n )\n\n const inOrderArray = data.filter(\n (item) => getSubsetIndex(item[key], orderSets) !== null,\n )\n\n let wasResorted = false as boolean\n\n // Sort by the relative order defined by the rules\n const sortedArray = inOrderArray.sort((a, b) => {\n const aKey = a[key],\n bKey = b[key]\n const aSubsetIndex = getSubsetIndex(aKey, orderSets)\n const bSubsetIndex = getSubsetIndex(bKey, orderSets)\n\n // If both items belong to different subsets, sort by their subset order\n if (\n aSubsetIndex !== null &&\n bSubsetIndex !== null &&\n aSubsetIndex !== bSubsetIndex\n ) {\n return aSubsetIndex - bSubsetIndex\n }\n\n // If both items belong to the same subset or neither is in the subset, keep their relative order\n return 0\n })\n\n const inOrderIterator = sortedArray.values()\n const result = data.map((item) => {\n if (getSubsetIndex(item[key], orderSets) !== null) {\n const sortedItem = inOrderIterator.next().value!\n if (sortedItem[key] !== item[key]) {\n wasResorted = true\n }\n return sortedItem\n }\n return item\n })\n\n if (!wasResorted) {\n return null\n }\n return result\n}\n\nexport function getCheckedProperties<T>(\n orderRules: ReadonlyArray<ReadonlyArray<ReadonlyArray<T>>>,\n): ReadonlyArray<T> {\n return [...new Set<T>(orderRules.flat(2))]\n}\n"],"
|
|
1
|
+
{"version":3,"file":"create-route-property-order.utils.js","names":[],"sources":["../../../../src/rules/create-route-property-order/create-route-property-order.utils.ts"],"sourcesContent":["export function sortDataByOrder<T, TKey extends keyof T>(\n data: Array<T> | ReadonlyArray<T>,\n orderRules: ReadonlyArray<\n Readonly<[ReadonlyArray<T[TKey]>, ReadonlyArray<T[TKey]>]>\n >,\n key: TKey,\n): Array<T> | null {\n const getSubsetIndex = (\n item: T[TKey],\n subsets: ReadonlyArray<ReadonlyArray<T[TKey]> | Array<T[TKey]>>,\n ): number | null => {\n for (let i = 0; i < subsets.length; i++) {\n if (subsets[i]?.includes(item)) {\n return i\n }\n }\n return null\n }\n\n const orderSets = orderRules.reduce(\n (sets, [A, B]) => [...sets, A, B],\n [] as Array<ReadonlyArray<T[TKey]> | Array<T[TKey]>>,\n )\n\n const inOrderArray = data.filter(\n (item) => getSubsetIndex(item[key], orderSets) !== null,\n )\n\n let wasResorted = false as boolean\n\n // Sort by the relative order defined by the rules\n const sortedArray = inOrderArray.sort((a, b) => {\n const aKey = a[key],\n bKey = b[key]\n const aSubsetIndex = getSubsetIndex(aKey, orderSets)\n const bSubsetIndex = getSubsetIndex(bKey, orderSets)\n\n // If both items belong to different subsets, sort by their subset order\n if (\n aSubsetIndex !== null &&\n bSubsetIndex !== null &&\n aSubsetIndex !== bSubsetIndex\n ) {\n return aSubsetIndex - bSubsetIndex\n }\n\n // If both items belong to the same subset or neither is in the subset, keep their relative order\n return 0\n })\n\n const inOrderIterator = sortedArray.values()\n const result = data.map((item) => {\n if (getSubsetIndex(item[key], orderSets) !== null) {\n const sortedItem = inOrderIterator.next().value!\n if (sortedItem[key] !== item[key]) {\n wasResorted = true\n }\n return sortedItem\n }\n return item\n })\n\n if (!wasResorted) {\n return null\n }\n return result\n}\n\nexport function getCheckedProperties<T>(\n orderRules: ReadonlyArray<ReadonlyArray<ReadonlyArray<T>>>,\n): ReadonlyArray<T> {\n return [...new Set<T>(orderRules.flat(2))]\n}\n"],"mappings":";AAAA,SAAgB,gBACd,MACA,YAGA,KACiB;CACjB,MAAM,kBACJ,MACA,YACkB;AAClB,OAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAClC,KAAI,QAAQ,IAAI,SAAS,KAAK,CAC5B,QAAO;AAGX,SAAO;;CAGT,MAAM,YAAY,WAAW,QAC1B,MAAM,CAAC,GAAG,OAAO;EAAC,GAAG;EAAM;EAAG;EAAE,EACjC,EAAE,CACH;CAED,MAAM,eAAe,KAAK,QACvB,SAAS,eAAe,KAAK,MAAM,UAAU,KAAK,KACpD;CAED,IAAI,cAAc;CAsBlB,MAAM,kBAnBc,aAAa,MAAM,GAAG,MAAM;EAC9C,MAAM,OAAO,EAAE,MACb,OAAO,EAAE;EACX,MAAM,eAAe,eAAe,MAAM,UAAU;EACpD,MAAM,eAAe,eAAe,MAAM,UAAU;AAGpD,MACE,iBAAiB,QACjB,iBAAiB,QACjB,iBAAiB,aAEjB,QAAO,eAAe;AAIxB,SAAO;GACP,CAEkC,QAAQ;CAC5C,MAAM,SAAS,KAAK,KAAK,SAAS;AAChC,MAAI,eAAe,KAAK,MAAM,UAAU,KAAK,MAAM;GACjD,MAAM,aAAa,gBAAgB,MAAM,CAAC;AAC1C,OAAI,WAAW,SAAS,KAAK,KAC3B,eAAc;AAEhB,UAAO;;AAET,SAAO;GACP;AAEF,KAAI,CAAC,YACH,QAAO;AAET,QAAO;;AAGT,SAAgB,qBACd,YACkB;AAClB,QAAO,CAAC,GAAG,IAAI,IAAO,WAAW,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/rules/route-param-names/constants.ts
|
|
2
|
+
/**
|
|
3
|
+
* Functions where the path is passed as the first argument (string literal)
|
|
4
|
+
* e.g., createFileRoute('/path/$param')(...)
|
|
5
|
+
*/
|
|
6
|
+
var pathAsFirstArgFunctions = [
|
|
7
|
+
"createFileRoute",
|
|
8
|
+
"createLazyFileRoute",
|
|
9
|
+
"createLazyRoute"
|
|
5
10
|
];
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Functions where the path is a property in the options object
|
|
13
|
+
* e.g., createRoute({ path: '/path/$param' })
|
|
14
|
+
*/
|
|
15
|
+
var pathAsPropertyFunctions = ["createRoute"];
|
|
16
|
+
[...pathAsFirstArgFunctions, ...pathAsPropertyFunctions];
|
|
17
|
+
/**
|
|
18
|
+
* Regex for valid JavaScript identifier (param name)
|
|
19
|
+
* Must start with letter, underscore, or dollar sign
|
|
20
|
+
* Can contain letters, numbers, underscores, or dollar signs
|
|
21
|
+
*/
|
|
22
|
+
var VALID_PARAM_NAME_REGEX = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { VALID_PARAM_NAME_REGEX, pathAsFirstArgFunctions, pathAsPropertyFunctions };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/rules/route-param-names/constants.ts"],"sourcesContent":["/**\n * Functions where the path is passed as the first argument (string literal)\n * e.g., createFileRoute('/path/$param')(...)\n */\nexport const pathAsFirstArgFunctions = [\n 'createFileRoute',\n 'createLazyFileRoute',\n 'createLazyRoute',\n] as const\n\nexport type PathAsFirstArgFunction = (typeof pathAsFirstArgFunctions)[number]\n\n/**\n * Functions where the path is a property in the options object\n * e.g., createRoute({ path: '/path/$param' })\n */\nexport const pathAsPropertyFunctions = ['createRoute'] as const\n\nexport type PathAsPropertyFunction = (typeof pathAsPropertyFunctions)[number]\n\n/**\n * All route functions that need param name validation\n */\nexport const allRouteFunctions = [\n ...pathAsFirstArgFunctions,\n ...pathAsPropertyFunctions,\n] as const\n\nexport type RouteFunction = (typeof allRouteFunctions)[number]\n\n/**\n * Regex for valid JavaScript identifier (param name)\n * Must start with letter, underscore, or dollar sign\n * Can contain letters, numbers, underscores, or dollar signs\n */\nexport const VALID_PARAM_NAME_REGEX = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/\n"],"
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../../src/rules/route-param-names/constants.ts"],"sourcesContent":["/**\n * Functions where the path is passed as the first argument (string literal)\n * e.g., createFileRoute('/path/$param')(...)\n */\nexport const pathAsFirstArgFunctions = [\n 'createFileRoute',\n 'createLazyFileRoute',\n 'createLazyRoute',\n] as const\n\nexport type PathAsFirstArgFunction = (typeof pathAsFirstArgFunctions)[number]\n\n/**\n * Functions where the path is a property in the options object\n * e.g., createRoute({ path: '/path/$param' })\n */\nexport const pathAsPropertyFunctions = ['createRoute'] as const\n\nexport type PathAsPropertyFunction = (typeof pathAsPropertyFunctions)[number]\n\n/**\n * All route functions that need param name validation\n */\nexport const allRouteFunctions = [\n ...pathAsFirstArgFunctions,\n ...pathAsPropertyFunctions,\n] as const\n\nexport type RouteFunction = (typeof allRouteFunctions)[number]\n\n/**\n * Regex for valid JavaScript identifier (param name)\n * Must start with letter, underscore, or dollar sign\n * Can contain letters, numbers, underscores, or dollar signs\n */\nexport const VALID_PARAM_NAME_REGEX = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/\n"],"mappings":";;;;;AAIA,IAAa,0BAA0B;CACrC;CACA;CACA;CACD;;;;;AAQD,IAAa,0BAA0B,CAAC,cAAc;AAOrB,CAC/B,GAAG,yBACH,GAAG,wBACJ;;;;;;AASD,IAAa,yBAAyB"}
|
|
@@ -1,98 +1,77 @@
|
|
|
1
|
-
import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
2
1
|
import { getDocsUrl } from "../../utils/get-docs-url.js";
|
|
3
2
|
import { detectTanstackRouterImports } from "../../utils/detect-router-imports.js";
|
|
4
|
-
import { getInvalidParams } from "./route-param-names.utils.js";
|
|
5
3
|
import { pathAsFirstArgFunctions, pathAsPropertyFunctions } from "./constants.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const funcName = innerCall.callee.name;
|
|
76
|
-
if (!helpers.isTanstackRouterImport(innerCall.callee)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (pathAsFirstArgSet.has(funcName)) {
|
|
80
|
-
const pathArg = innerCall.arguments[0];
|
|
81
|
-
if (pathArg) {
|
|
82
|
-
const pathValue = getStringLiteralValue(pathArg);
|
|
83
|
-
if (pathValue) {
|
|
84
|
-
reportInvalidParams(pathArg, pathValue);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
})
|
|
4
|
+
import { getInvalidParams } from "./route-param-names.utils.js";
|
|
5
|
+
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
6
|
+
//#region src/rules/route-param-names/route-param-names.rule.ts
|
|
7
|
+
var createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
8
|
+
var pathAsFirstArgSet = new Set(pathAsFirstArgFunctions);
|
|
9
|
+
var pathAsPropertySet = new Set(pathAsPropertyFunctions);
|
|
10
|
+
var name = "route-param-names";
|
|
11
|
+
var rule = createRule({
|
|
12
|
+
name,
|
|
13
|
+
meta: {
|
|
14
|
+
type: "problem",
|
|
15
|
+
docs: {
|
|
16
|
+
description: "Ensure route param names are valid JavaScript identifiers",
|
|
17
|
+
recommended: "error"
|
|
18
|
+
},
|
|
19
|
+
messages: { invalidParamName: "Invalid param name \"{{paramName}}\" in route path. Param names must be valid JavaScript identifiers (match /[a-zA-Z_$][a-zA-Z0-9_$]*/)." },
|
|
20
|
+
schema: []
|
|
21
|
+
},
|
|
22
|
+
defaultOptions: [],
|
|
23
|
+
create: detectTanstackRouterImports((context, _, helpers) => {
|
|
24
|
+
function reportInvalidParams(node, path) {
|
|
25
|
+
const invalidParams = getInvalidParams(path);
|
|
26
|
+
for (const param of invalidParams) context.report({
|
|
27
|
+
node,
|
|
28
|
+
messageId: "invalidParamName",
|
|
29
|
+
data: { paramName: param.paramName }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function getStringLiteralValue(node) {
|
|
33
|
+
if (node.type === AST_NODE_TYPES.Literal && typeof node.value === "string") return node.value;
|
|
34
|
+
if (node.type === AST_NODE_TYPES.TemplateLiteral && node.quasis.length === 1) {
|
|
35
|
+
const cooked = node.quasis[0]?.value.cooked;
|
|
36
|
+
if (cooked != null) return cooked;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return { CallExpression(node) {
|
|
41
|
+
if (node.callee.type === AST_NODE_TYPES.Identifier) {
|
|
42
|
+
const funcName = node.callee.name;
|
|
43
|
+
if (!helpers.isTanstackRouterImport(node.callee)) return;
|
|
44
|
+
if (pathAsPropertySet.has(funcName)) {
|
|
45
|
+
const arg = node.arguments[0];
|
|
46
|
+
if (arg?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
47
|
+
for (const prop of arg.properties) if (prop.type === AST_NODE_TYPES.Property) {
|
|
48
|
+
if (prop.key.type === AST_NODE_TYPES.Identifier && prop.key.name === "path" || prop.key.type === AST_NODE_TYPES.Literal && prop.key.value === "path") {
|
|
49
|
+
const pathValue = getStringLiteralValue(prop.value);
|
|
50
|
+
if (pathValue) reportInvalidParams(prop.value, pathValue);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (node.callee.type === AST_NODE_TYPES.CallExpression) {
|
|
58
|
+
const innerCall = node.callee;
|
|
59
|
+
if (innerCall.callee.type === AST_NODE_TYPES.Identifier) {
|
|
60
|
+
const funcName = innerCall.callee.name;
|
|
61
|
+
if (!helpers.isTanstackRouterImport(innerCall.callee)) return;
|
|
62
|
+
if (pathAsFirstArgSet.has(funcName)) {
|
|
63
|
+
const pathArg = innerCall.arguments[0];
|
|
64
|
+
if (pathArg) {
|
|
65
|
+
const pathValue = getStringLiteralValue(pathArg);
|
|
66
|
+
if (pathValue) reportInvalidParams(pathArg, pathValue);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} };
|
|
72
|
+
})
|
|
93
73
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
//# sourceMappingURL=route-param-names.rule.js.map
|
|
74
|
+
//#endregion
|
|
75
|
+
export { name, rule };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=route-param-names.rule.js.map
|