@tanstack/eslint-plugin-router 1.161.4 → 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.
Files changed (41) hide show
  1. package/dist/cjs/index.cjs +22 -27
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/rules/create-route-property-order/constants.cjs +23 -36
  4. package/dist/cjs/rules/create-route-property-order/constants.cjs.map +1 -1
  5. package/dist/cjs/rules/create-route-property-order/create-route-property-order.rule.cjs +68 -98
  6. package/dist/cjs/rules/create-route-property-order/create-route-property-order.rule.cjs.map +1 -1
  7. package/dist/cjs/rules/create-route-property-order/create-route-property-order.utils.cjs +33 -44
  8. package/dist/cjs/rules/create-route-property-order/create-route-property-order.utils.cjs.map +1 -1
  9. package/dist/cjs/rules/route-param-names/constants.cjs +24 -9
  10. package/dist/cjs/rules/route-param-names/constants.cjs.map +1 -1
  11. package/dist/cjs/rules/route-param-names/route-param-names.rule.cjs +75 -95
  12. package/dist/cjs/rules/route-param-names/route-param-names.rule.cjs.map +1 -1
  13. package/dist/cjs/rules/route-param-names/route-param-names.utils.cjs +65 -54
  14. package/dist/cjs/rules/route-param-names/route-param-names.utils.cjs.map +1 -1
  15. package/dist/cjs/rules.cjs +9 -8
  16. package/dist/cjs/rules.cjs.map +1 -1
  17. package/dist/cjs/utils/detect-router-imports.cjs +35 -51
  18. package/dist/cjs/utils/detect-router-imports.cjs.map +1 -1
  19. package/dist/cjs/utils/get-docs-url.cjs +5 -4
  20. package/dist/cjs/utils/get-docs-url.cjs.map +1 -1
  21. package/dist/esm/index.js +23 -28
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/rules/create-route-property-order/constants.js +22 -37
  24. package/dist/esm/rules/create-route-property-order/constants.js.map +1 -1
  25. package/dist/esm/rules/create-route-property-order/create-route-property-order.rule.js +65 -96
  26. package/dist/esm/rules/create-route-property-order/create-route-property-order.rule.js.map +1 -1
  27. package/dist/esm/rules/create-route-property-order/create-route-property-order.utils.js +34 -46
  28. package/dist/esm/rules/create-route-property-order/create-route-property-order.utils.js.map +1 -1
  29. package/dist/esm/rules/route-param-names/constants.js +25 -12
  30. package/dist/esm/rules/route-param-names/constants.js.map +1 -1
  31. package/dist/esm/rules/route-param-names/route-param-names.rule.js +73 -94
  32. package/dist/esm/rules/route-param-names/route-param-names.rule.js.map +1 -1
  33. package/dist/esm/rules/route-param-names/route-param-names.utils.js +65 -54
  34. package/dist/esm/rules/route-param-names/route-param-names.utils.js.map +1 -1
  35. package/dist/esm/rules.js +10 -9
  36. package/dist/esm/rules.js.map +1 -1
  37. package/dist/esm/utils/detect-router-imports.js +35 -51
  38. package/dist/esm/utils/detect-router-imports.js.map +1 -1
  39. package/dist/esm/utils/get-docs-url.js +6 -5
  40. package/dist/esm/utils/get-docs-url.js.map +1 -1
  41. package/package.json +1 -1
@@ -1,98 +1,78 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils = require("@typescript-eslint/utils");
4
- const getDocsUrl = require("../../utils/get-docs-url.cjs");
5
- const detectRouterImports = require("../../utils/detect-router-imports.cjs");
6
- const routeParamNames_utils = require("./route-param-names.utils.cjs");
7
- const constants = require("./constants.cjs");
8
- const createRule = utils.ESLintUtils.RuleCreator(getDocsUrl.getDocsUrl);
9
- const pathAsFirstArgSet = new Set(constants.pathAsFirstArgFunctions);
10
- const pathAsPropertySet = new Set(constants.pathAsPropertyFunctions);
11
- const name = "route-param-names";
12
- const rule = createRule({
13
- name,
14
- meta: {
15
- type: "problem",
16
- docs: {
17
- description: "Ensure route param names are valid JavaScript identifiers",
18
- recommended: "error"
19
- },
20
- messages: {
21
- invalidParamName: 'Invalid param name "{{paramName}}" in route path. Param names must be valid JavaScript identifiers (match /[a-zA-Z_$][a-zA-Z0-9_$]*/).'
22
- },
23
- schema: []
24
- },
25
- defaultOptions: [],
26
- create: detectRouterImports.detectTanstackRouterImports((context, _, helpers) => {
27
- function reportInvalidParams(node, path) {
28
- const invalidParams = routeParamNames_utils.getInvalidParams(path);
29
- for (const param of invalidParams) {
30
- context.report({
31
- node,
32
- messageId: "invalidParamName",
33
- data: { paramName: param.paramName }
34
- });
35
- }
36
- }
37
- function getStringLiteralValue(node) {
38
- if (node.type === utils.AST_NODE_TYPES.Literal && typeof node.value === "string") {
39
- return node.value;
40
- }
41
- if (node.type === utils.AST_NODE_TYPES.TemplateLiteral && node.quasis.length === 1) {
42
- const cooked = node.quasis[0]?.value.cooked;
43
- if (cooked != null) {
44
- return cooked;
45
- }
46
- }
47
- return null;
48
- }
49
- return {
50
- CallExpression(node) {
51
- if (node.callee.type === utils.AST_NODE_TYPES.Identifier) {
52
- const funcName = node.callee.name;
53
- if (!helpers.isTanstackRouterImport(node.callee)) {
54
- return;
55
- }
56
- if (pathAsPropertySet.has(funcName)) {
57
- const arg = node.arguments[0];
58
- if (arg?.type === utils.AST_NODE_TYPES.ObjectExpression) {
59
- for (const prop of arg.properties) {
60
- if (prop.type === utils.AST_NODE_TYPES.Property) {
61
- const isPathKey = prop.key.type === utils.AST_NODE_TYPES.Identifier && prop.key.name === "path" || prop.key.type === utils.AST_NODE_TYPES.Literal && prop.key.value === "path";
62
- if (isPathKey) {
63
- const pathValue = getStringLiteralValue(prop.value);
64
- if (pathValue) {
65
- reportInvalidParams(prop.value, pathValue);
66
- }
67
- }
68
- }
69
- }
70
- }
71
- return;
72
- }
73
- }
74
- if (node.callee.type === utils.AST_NODE_TYPES.CallExpression) {
75
- const innerCall = node.callee;
76
- if (innerCall.callee.type === utils.AST_NODE_TYPES.Identifier) {
77
- const funcName = innerCall.callee.name;
78
- if (!helpers.isTanstackRouterImport(innerCall.callee)) {
79
- return;
80
- }
81
- if (pathAsFirstArgSet.has(funcName)) {
82
- const pathArg = innerCall.arguments[0];
83
- if (pathArg) {
84
- const pathValue = getStringLiteralValue(pathArg);
85
- if (pathValue) {
86
- reportInvalidParams(pathArg, pathValue);
87
- }
88
- }
89
- }
90
- }
91
- }
92
- }
93
- };
94
- })
1
+ const require_get_docs_url = require("../../utils/get-docs-url.cjs");
2
+ const require_detect_router_imports = require("../../utils/detect-router-imports.cjs");
3
+ const require_constants = require("./constants.cjs");
4
+ const require_route_param_names_utils = require("./route-param-names.utils.cjs");
5
+ let _typescript_eslint_utils = require("@typescript-eslint/utils");
6
+ //#region src/rules/route-param-names/route-param-names.rule.ts
7
+ var createRule = _typescript_eslint_utils.ESLintUtils.RuleCreator(require_get_docs_url.getDocsUrl);
8
+ var pathAsFirstArgSet = new Set(require_constants.pathAsFirstArgFunctions);
9
+ var pathAsPropertySet = new Set(require_constants.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: require_detect_router_imports.detectTanstackRouterImports((context, _, helpers) => {
24
+ function reportInvalidParams(node, path) {
25
+ const invalidParams = require_route_param_names_utils.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 === _typescript_eslint_utils.AST_NODE_TYPES.Literal && typeof node.value === "string") return node.value;
34
+ if (node.type === _typescript_eslint_utils.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 === _typescript_eslint_utils.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 === _typescript_eslint_utils.AST_NODE_TYPES.ObjectExpression) {
47
+ for (const prop of arg.properties) if (prop.type === _typescript_eslint_utils.AST_NODE_TYPES.Property) {
48
+ if (prop.key.type === _typescript_eslint_utils.AST_NODE_TYPES.Identifier && prop.key.name === "path" || prop.key.type === _typescript_eslint_utils.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 === _typescript_eslint_utils.AST_NODE_TYPES.CallExpression) {
58
+ const innerCall = node.callee;
59
+ if (innerCall.callee.type === _typescript_eslint_utils.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
+ })
95
73
  });
74
+ //#endregion
96
75
  exports.name = name;
97
76
  exports.rule = rule;
98
- //# sourceMappingURL=route-param-names.rule.cjs.map
77
+
78
+ //# sourceMappingURL=route-param-names.rule.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"route-param-names.rule.cjs","sources":["../../../../src/rules/route-param-names/route-param-names.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 { getInvalidParams } from './route-param-names.utils'\nimport { pathAsFirstArgFunctions, pathAsPropertyFunctions } from './constants'\nimport type { TSESTree } from '@typescript-eslint/utils'\nimport type { ExtraRuleDocs } from '../../types'\n\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl)\n\nconst pathAsFirstArgSet = new Set<string>(pathAsFirstArgFunctions)\nconst pathAsPropertySet = new Set<string>(pathAsPropertyFunctions)\n\nexport const name = 'route-param-names'\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Ensure route param names are valid JavaScript identifiers',\n recommended: 'error',\n },\n messages: {\n invalidParamName:\n 'Invalid param name \"{{paramName}}\" in route path. Param names must be valid JavaScript identifiers (match /[a-zA-Z_$][a-zA-Z0-9_$]*/).',\n },\n schema: [],\n },\n defaultOptions: [],\n\n create: detectTanstackRouterImports((context, _, helpers) => {\n function reportInvalidParams(node: TSESTree.Node, path: string) {\n const invalidParams = getInvalidParams(path)\n\n for (const param of invalidParams) {\n context.report({\n node,\n messageId: 'invalidParamName',\n data: { paramName: param.paramName },\n })\n }\n }\n\n function getStringLiteralValue(node: TSESTree.Node): string | null {\n if (\n node.type === AST_NODE_TYPES.Literal &&\n typeof node.value === 'string'\n ) {\n return node.value\n }\n if (\n node.type === AST_NODE_TYPES.TemplateLiteral &&\n node.quasis.length === 1\n ) {\n const cooked = node.quasis[0]?.value.cooked\n if (cooked != null) {\n return cooked\n }\n }\n return null\n }\n\n return {\n CallExpression(node) {\n // Handle direct function call: createRoute({ path: '...' })\n if (node.callee.type === AST_NODE_TYPES.Identifier) {\n const funcName = node.callee.name\n\n // Skip if not imported from TanStack Router\n if (!helpers.isTanstackRouterImport(node.callee)) {\n return\n }\n\n // Case: createRoute({ path: '/path/$param' }) or createRoute({ 'path': '/path/$param' })\n if (pathAsPropertySet.has(funcName)) {\n const arg = node.arguments[0]\n if (arg?.type === AST_NODE_TYPES.ObjectExpression) {\n for (const prop of arg.properties) {\n if (prop.type === AST_NODE_TYPES.Property) {\n const isPathKey =\n (prop.key.type === AST_NODE_TYPES.Identifier &&\n prop.key.name === 'path') ||\n (prop.key.type === AST_NODE_TYPES.Literal &&\n prop.key.value === 'path')\n if (isPathKey) {\n const pathValue = getStringLiteralValue(prop.value)\n if (pathValue) {\n reportInvalidParams(prop.value, pathValue)\n }\n }\n }\n }\n }\n return\n }\n }\n\n // Handle curried function call: createFileRoute('/path')({ ... })\n if (node.callee.type === AST_NODE_TYPES.CallExpression) {\n const innerCall = node.callee\n\n if (innerCall.callee.type === AST_NODE_TYPES.Identifier) {\n const funcName = innerCall.callee.name\n\n // Skip if not imported from TanStack Router\n if (!helpers.isTanstackRouterImport(innerCall.callee)) {\n return\n }\n\n // Case: createFileRoute('/path/$param')(...) or similar\n if (pathAsFirstArgSet.has(funcName)) {\n const pathArg = innerCall.arguments[0]\n if (pathArg) {\n const pathValue = getStringLiteralValue(pathArg)\n if (pathValue) {\n reportInvalidParams(pathArg, pathValue)\n }\n }\n }\n }\n }\n },\n }\n }),\n})\n"],"names":["ESLintUtils","getDocsUrl","pathAsFirstArgFunctions","pathAsPropertyFunctions","detectTanstackRouterImports","getInvalidParams","AST_NODE_TYPES"],"mappings":";;;;;;;AASA,MAAM,aAAaA,MAAAA,YAAY,YAA2BC,qBAAU;AAEpE,MAAM,oBAAoB,IAAI,IAAYC,iCAAuB;AACjE,MAAM,oBAAoB,IAAI,IAAYC,iCAAuB;AAE1D,MAAM,OAAO;AAEb,MAAM,OAAO,WAAW;AAAA,EAC7B;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,aAAa;AAAA,MACb,aAAa;AAAA,IAAA;AAAA,IAEf,UAAU;AAAA,MACR,kBACE;AAAA,IAAA;AAAA,IAEJ,QAAQ,CAAA;AAAA,EAAC;AAAA,EAEX,gBAAgB,CAAA;AAAA,EAEhB,QAAQC,oBAAAA,4BAA4B,CAAC,SAAS,GAAG,YAAY;AAC3D,aAAS,oBAAoB,MAAqB,MAAc;AAC9D,YAAM,gBAAgBC,sBAAAA,iBAAiB,IAAI;AAE3C,iBAAW,SAAS,eAAe;AAC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;AAEvB,cAAI,UAAU,OAAO,SAASA,MAAAA,eAAe,YAAY;AACvD,kBAAM,WAAW,UAAU,OAAO;AAGlC,gBAAI,CAAC,QAAQ,uBAAuB,UAAU,MAAM,GAAG;AACrD;AAAA,YACF;AAGA,gBAAI,kBAAkB,IAAI,QAAQ,GAAG;AACnC,oBAAM,UAAU,UAAU,UAAU,CAAC;AACrC,kBAAI,SAAS;AACX,sBAAM,YAAY,sBAAsB,OAAO;AAC/C,oBAAI,WAAW;AACb,sCAAoB,SAAS,SAAS;AAAA,gBACxC;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ,CAAC;AACH,CAAC;;;"}
1
+ {"version":3,"file":"route-param-names.rule.cjs","names":[],"sources":["../../../../src/rules/route-param-names/route-param-names.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 { getInvalidParams } from './route-param-names.utils'\nimport { pathAsFirstArgFunctions, pathAsPropertyFunctions } from './constants'\nimport type { TSESTree } from '@typescript-eslint/utils'\nimport type { ExtraRuleDocs } from '../../types'\n\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl)\n\nconst pathAsFirstArgSet = new Set<string>(pathAsFirstArgFunctions)\nconst pathAsPropertySet = new Set<string>(pathAsPropertyFunctions)\n\nexport const name = 'route-param-names'\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Ensure route param names are valid JavaScript identifiers',\n recommended: 'error',\n },\n messages: {\n invalidParamName:\n 'Invalid param name \"{{paramName}}\" in route path. Param names must be valid JavaScript identifiers (match /[a-zA-Z_$][a-zA-Z0-9_$]*/).',\n },\n schema: [],\n },\n defaultOptions: [],\n\n create: detectTanstackRouterImports((context, _, helpers) => {\n function reportInvalidParams(node: TSESTree.Node, path: string) {\n const invalidParams = getInvalidParams(path)\n\n for (const param of invalidParams) {\n context.report({\n node,\n messageId: 'invalidParamName',\n data: { paramName: param.paramName },\n })\n }\n }\n\n function getStringLiteralValue(node: TSESTree.Node): string | null {\n if (\n node.type === AST_NODE_TYPES.Literal &&\n typeof node.value === 'string'\n ) {\n return node.value\n }\n if (\n node.type === AST_NODE_TYPES.TemplateLiteral &&\n node.quasis.length === 1\n ) {\n const cooked = node.quasis[0]?.value.cooked\n if (cooked != null) {\n return cooked\n }\n }\n return null\n }\n\n return {\n CallExpression(node) {\n // Handle direct function call: createRoute({ path: '...' })\n if (node.callee.type === AST_NODE_TYPES.Identifier) {\n const funcName = node.callee.name\n\n // Skip if not imported from TanStack Router\n if (!helpers.isTanstackRouterImport(node.callee)) {\n return\n }\n\n // Case: createRoute({ path: '/path/$param' }) or createRoute({ 'path': '/path/$param' })\n if (pathAsPropertySet.has(funcName)) {\n const arg = node.arguments[0]\n if (arg?.type === AST_NODE_TYPES.ObjectExpression) {\n for (const prop of arg.properties) {\n if (prop.type === AST_NODE_TYPES.Property) {\n const isPathKey =\n (prop.key.type === AST_NODE_TYPES.Identifier &&\n prop.key.name === 'path') ||\n (prop.key.type === AST_NODE_TYPES.Literal &&\n prop.key.value === 'path')\n if (isPathKey) {\n const pathValue = getStringLiteralValue(prop.value)\n if (pathValue) {\n reportInvalidParams(prop.value, pathValue)\n }\n }\n }\n }\n }\n return\n }\n }\n\n // Handle curried function call: createFileRoute('/path')({ ... })\n if (node.callee.type === AST_NODE_TYPES.CallExpression) {\n const innerCall = node.callee\n\n if (innerCall.callee.type === AST_NODE_TYPES.Identifier) {\n const funcName = innerCall.callee.name\n\n // Skip if not imported from TanStack Router\n if (!helpers.isTanstackRouterImport(innerCall.callee)) {\n return\n }\n\n // Case: createFileRoute('/path/$param')(...) or similar\n if (pathAsFirstArgSet.has(funcName)) {\n const pathArg = innerCall.arguments[0]\n if (pathArg) {\n const pathValue = getStringLiteralValue(pathArg)\n if (p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AA,eAAe;WAE5B,KAAK,IAAI,SAAS,yBAAA,eAAe,cAChC,KAAK,IAAI,SAAS,UACnB,KAAK,IAAI,SAAS,yBAAA,eAAe,WAChC,KAAK,IAAI,UAAU,QACR;QACb,MAAM,YAAY,sBAAsB,KAAK,MAAM;AACnD,YAAI,UACF,qBAAoB,KAAK,OAAO,UAAU;;;;AAMpD;;;AAKJ,OAAI,KAAK,OAAO,SAAS,yBAAA,eAAe,gBAAgB;IACtD,MAAM,YAAY,KAAK;AAEvB,QAAI,UAAU,OAAO,SAAS,yBAAA,eAAe,YAAY;KACvD,MAAM,WAAW,UAAU,OAAO;AAGlC,SAAI,CAAC,QAAQ,uBAAuB,UAAU,OAAO,CACnD;AAIF,SAAI,kBAAkB,IAAI,SAAS,EAAE;MACnC,MAAM,UAAU,UAAU,UAAU;AACpC,UAAI,SAAS;OACX,MAAM,YAAY,sBAAsB,QAAQ;AAChD,WAAI,UACF,qBAAoB,SAAS,UAAU;;;;;KAOpD;GACD;CACH,CAAC"}
@@ -1,61 +1,72 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const constants = require("./constants.cjs");
1
+ const require_constants = require("./constants.cjs");
2
+ //#region src/rules/route-param-names/route-param-names.utils.ts
3
+ /**
4
+ * Extracts param names from a route path segment.
5
+ *
6
+ * Handles these patterns:
7
+ * - $paramName -> extract "paramName"
8
+ * - {$paramName} -> extract "paramName"
9
+ * - prefix{$paramName}suffix -> extract "paramName"
10
+ * - {-$paramName} -> extract "paramName" (optional)
11
+ * - prefix{-$paramName}suffix -> extract "paramName" (optional)
12
+ * - $ or {$} -> wildcard, skip validation
13
+ */
4
14
  function extractParamsFromSegment(segment) {
5
- const params = [];
6
- if (!segment || !segment.includes("$")) {
7
- return params;
8
- }
9
- if (segment === "$" || segment === "{$}") {
10
- return params;
11
- }
12
- if (segment.startsWith("$") && !segment.includes("{")) {
13
- const paramName = segment.slice(1);
14
- if (paramName) {
15
- params.push({
16
- fullParam: segment,
17
- paramName,
18
- isOptional: false,
19
- isValid: constants.VALID_PARAM_NAME_REGEX.test(paramName)
20
- });
21
- }
22
- return params;
23
- }
24
- const bracePattern = /\{(-?\$)([^}]*)\}/g;
25
- let match;
26
- while ((match = bracePattern.exec(segment)) !== null) {
27
- const prefix = match[1];
28
- const paramName = match[2];
29
- if (!paramName) {
30
- continue;
31
- }
32
- const isOptional = prefix === "-$";
33
- params.push({
34
- fullParam: `${prefix}${paramName}`,
35
- paramName,
36
- isOptional,
37
- isValid: constants.VALID_PARAM_NAME_REGEX.test(paramName)
38
- });
39
- }
40
- return params;
15
+ const params = [];
16
+ if (!segment || !segment.includes("$")) return params;
17
+ if (segment === "$" || segment === "{$}") return params;
18
+ if (segment.startsWith("$") && !segment.includes("{")) {
19
+ const paramName = segment.slice(1);
20
+ if (paramName) params.push({
21
+ fullParam: segment,
22
+ paramName,
23
+ isOptional: false,
24
+ isValid: require_constants.VALID_PARAM_NAME_REGEX.test(paramName)
25
+ });
26
+ return params;
27
+ }
28
+ const bracePattern = /\{(-?\$)([^}]*)\}/g;
29
+ let match;
30
+ while ((match = bracePattern.exec(segment)) !== null) {
31
+ const prefix = match[1];
32
+ const paramName = match[2];
33
+ if (!paramName) continue;
34
+ const isOptional = prefix === "-$";
35
+ params.push({
36
+ fullParam: `${prefix}${paramName}`,
37
+ paramName,
38
+ isOptional,
39
+ isValid: require_constants.VALID_PARAM_NAME_REGEX.test(paramName)
40
+ });
41
+ }
42
+ return params;
41
43
  }
44
+ /**
45
+ * Extracts all params from a route path.
46
+ *
47
+ * @param path - The route path (e.g., "/users/$userId/posts/$postId")
48
+ * @returns Array of extracted params with validation info
49
+ */
42
50
  function extractParamsFromPath(path) {
43
- if (!path || !path.includes("$")) {
44
- return [];
45
- }
46
- const segments = path.split("/");
47
- const allParams = [];
48
- for (const segment of segments) {
49
- const params = extractParamsFromSegment(segment);
50
- allParams.push(...params);
51
- }
52
- return allParams;
51
+ if (!path || !path.includes("$")) return [];
52
+ const segments = path.split("/");
53
+ const allParams = [];
54
+ for (const segment of segments) {
55
+ const params = extractParamsFromSegment(segment);
56
+ allParams.push(...params);
57
+ }
58
+ return allParams;
53
59
  }
60
+ /**
61
+ * Gets all invalid params from a route path.
62
+ *
63
+ * @param path - The route path
64
+ * @returns Array of invalid param info
65
+ */
54
66
  function getInvalidParams(path) {
55
- const params = extractParamsFromPath(path);
56
- return params.filter((p) => !p.isValid);
67
+ return extractParamsFromPath(path).filter((p) => !p.isValid);
57
68
  }
58
- exports.extractParamsFromPath = extractParamsFromPath;
59
- exports.extractParamsFromSegment = extractParamsFromSegment;
69
+ //#endregion
60
70
  exports.getInvalidParams = getInvalidParams;
61
- //# sourceMappingURL=route-param-names.utils.cjs.map
71
+
72
+ //# sourceMappingURL=route-param-names.utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"route-param-names.utils.cjs","sources":["../../../../src/rules/route-param-names/route-param-names.utils.ts"],"sourcesContent":["import { VALID_PARAM_NAME_REGEX } from './constants'\n\nexport interface ExtractedParam {\n /** The full param string including $ prefix (e.g., \"$userId\", \"-$optional\") */\n fullParam: string\n /** The param name without $ prefix (e.g., \"userId\", \"optional\") */\n paramName: string\n /** Whether this is an optional param (prefixed with -$) */\n isOptional: boolean\n /** Whether this param name is valid */\n isValid: boolean\n}\n\n/**\n * Extracts param names from a route path segment.\n *\n * Handles these patterns:\n * - $paramName -> extract \"paramName\"\n * - {$paramName} -> extract \"paramName\"\n * - prefix{$paramName}suffix -> extract \"paramName\"\n * - {-$paramName} -> extract \"paramName\" (optional)\n * - prefix{-$paramName}suffix -> extract \"paramName\" (optional)\n * - $ or {$} -> wildcard, skip validation\n */\nexport function extractParamsFromSegment(\n segment: string,\n): Array<ExtractedParam> {\n const params: Array<ExtractedParam> = []\n\n // Skip empty segments\n if (!segment || !segment.includes('$')) {\n return params\n }\n\n // Check for wildcard ($ alone or {$})\n if (segment === '$' || segment === '{$}') {\n return params // Wildcard, no param name to validate\n }\n\n // Pattern 1: Simple $paramName (entire segment starts with $)\n if (segment.startsWith('$') && !segment.includes('{')) {\n const paramName = segment.slice(1)\n if (paramName) {\n params.push({\n fullParam: segment,\n paramName,\n isOptional: false,\n isValid: VALID_PARAM_NAME_REGEX.test(paramName),\n })\n }\n return params\n }\n\n // Pattern 2: Braces pattern {$paramName} or {-$paramName} with optional prefix/suffix\n // Match patterns like: prefix{$param}suffix, {$param}, {-$param}\n const bracePattern = /\\{(-?\\$)([^}]*)\\}/g\n let match\n\n while ((match = bracePattern.exec(segment)) !== null) {\n const prefix = match[1] // \"$\" or \"-$\"\n const paramName = match[2] // The param name after $ or -$\n\n if (!paramName) {\n // This is a wildcard {$} or {-$}, skip\n continue\n }\n\n const isOptional = prefix === '-$'\n\n params.push({\n fullParam: `${prefix}${paramName}`,\n paramName,\n isOptional,\n isValid: VALID_PARAM_NAME_REGEX.test(paramName),\n })\n }\n\n return params\n}\n\n/**\n * Extracts all params from a route path.\n *\n * @param path - The route path (e.g., \"/users/$userId/posts/$postId\")\n * @returns Array of extracted params with validation info\n */\nexport function extractParamsFromPath(path: string): Array<ExtractedParam> {\n if (!path || !path.includes('$')) {\n return []\n }\n\n const segments = path.split('/')\n const allParams: Array<ExtractedParam> = []\n\n for (const segment of segments) {\n const params = extractParamsFromSegment(segment)\n allParams.push(...params)\n }\n\n return allParams\n}\n\n/**\n * Validates a single param name.\n *\n * @param paramName - The param name to validate (without $ prefix)\n * @returns Whether the param name is valid\n */\nexport function isValidParamName(paramName: string): boolean {\n return VALID_PARAM_NAME_REGEX.test(paramName)\n}\n\n/**\n * Gets all invalid params from a route path.\n *\n * @param path - The route path\n * @returns Array of invalid param info\n */\nexport function getInvalidParams(path: string): Array<ExtractedParam> {\n const params = extractParamsFromPath(path)\n return params.filter((p) => !p.isValid)\n}\n"],"names":["VALID_PARAM_NAME_REGEX"],"mappings":";;;AAwBO,SAAS,yBACd,SACuB;AACvB,QAAM,SAAgC,CAAA;AAGtC,MAAI,CAAC,WAAW,C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","names":[],"sources":["../../../../src/rules/route-param-names/route-param-names.utils.ts"],"sourcesContent":["import { VALID_PARAM_NAME_REGEX } from './constants'\n\nexport interface ExtractedParam {\n /** The full param string including $ prefix (e.g., \"$userId\", \"-$optional\") */\n fullParam: string\n /** The param name without $ prefix (e.g., \"userId\", \"optional\") */\n paramName: string\n /** Whether this is an optional param (prefixed with -$) */\n isOptional: boolean\n /** Whether this param name is valid */\n isValid: boolean\n}\n\n/**\n * Extracts param names from a route path segment.\n *\n * Handles these patterns:\n * - $paramName -> extract \"paramName\"\n * - {$paramName} -> extract \"paramName\"\n * - prefix{$paramName}suffix -> extract \"paramName\"\n * - {-$paramName} -> extract \"paramName\" (optional)\n * - prefix{-$paramName}suffix -> extract \"paramName\" (optional)\n * - $ or {$} -> wildcard, skip validation\n */\nexport function extractParamsFromSegment(\n segment: string,\n): Array<ExtractedParam> {\n const params: Array<ExtractedParam> = []\n\n // Skip empty segments\n if (!segment || !segment.includes('$')) {\n return params\n }\n\n // Check for wildcard ($ alone or {$})\n if (segment === '$' || segment === '{$}') {\n return params // Wildcard, no param name to validate\n }\n\n // Pattern 1: Simple $paramName (entire segment starts with $)\n if (segment.startsWith('$') && !segment.includes('{')) {\n const paramName = segment.slice(1)\n if (paramName) {\n params.push({\n fullParam: segment,\n paramName,\n isOptional: false,\n isValid: VALID_PARAM_NAME_REGEX.test(paramName),\n })\n }\n return params\n }\n\n // Pattern 2: Braces pattern {$paramName} or {-$paramName} with optional prefix/suffix\n // Match patterns like: prefix{$param}suffix, {$param}, {-$param}\n const bracePattern = /\\{(-?\\$)([^}]*)\\}/g\n let match\n\n while ((match = bracePattern.exec(segment)) !== null) {\n const prefix = match[1] // \"$\" or \"-$\"\n const paramName = match[2] // The param name after $ or -$\n\n if (!paramName) {\n // This is a wildcard {$} or {-$}, skip\n continue\n }\n\n const isOptional = prefix === '-$'\n\n params.push({\n fullParam: `${prefix}${paramName}`,\n paramName,\n isOptional,\n isValid: VALID_PARAM_NAME_REGEX.test(paramName),\n })\n }\n\n return params\n}\n\n/**\n * Extracts all params from a route path.\n *\n * @param path - The route path (e.g., \"/users/$userId/posts/$postId\")\n * @returns Array of extracted params with validation info\n */\nexport function extractParamsFromPath(path: string): Array<ExtractedParam> {\n if (!path || !path.includes('$')) {\n return []\n }\n\n const segments = path.split('/')\n const allParams: Array<ExtractedParam> = []\n\n for (const segment of segments) {\n const params = extractParamsFromSegment(segment)\n allParams.push(...params)\n }\n\n return allParams\n}\n\n/**\n * Validates a single param name.\n *\n * @param paramName - The param name to validate (without $ prefix)\n * @returns Whether the param name is valid\n */\nexport function isValidParamName(paramName: string): boolean {\n return VALID_PARAM_NAME_REGEX.test(paramName)\n}\n\n/**\n * Gets all invalid params from a route path.\n *\n * @param path - The route path\n * @returns Array of invalid param info\n */\nexport function getInvalidParams(path: string): Array<ExtractedParam> {\n const params = extractParamsFromPath(path)\n return params.filter((p) => !p.isValid)\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,SAAgB,yBACd,SACuB;CACvB,MAAM,SAAgC,EAAE;AAGxC,KAAI,CAAC,WAAW,CAAC,QAAQ,SAAS,IAAI,CACpC,QAAO;AAIT,KAAI,YAAY,OAAO,YAAY,MACjC,QAAO;AAIT,KAAI,QAAQ,WAAW,IAAI,IAAI,CAAC,QAAQ,SAAS,IAAI,EAAE;EACrD,MAAM,YAAY,QAAQ,MAAM,EAAE;AAClC,MAAI,UACF,QAAO,KAAK;GACV,WAAW;GACX;GACA,YAAY;GACZ,SAAS,kBAAA,uBAAuB,KAAK,UAAU;GAChD,CAAC;AAEJ,SAAO;;CAKT,MAAM,eAAe;CACrB,IAAI;AAEJ,SAAQ,QAAQ,aAAa,KAAK,QAAQ,MAAM,MAAM;EACpD,MAAM,SAAS,MAAM;EACrB,MAAM,YAAY,MAAM;AAExB,MAAI,CAAC,UAEH;EAGF,MAAM,aAAa,WAAW;AAE9B,SAAO,KAAK;GACV,WAAW,GAAG,SAAS;GACvB;GACA;GACA,SAAS,kBAAA,uBAAuB,KAAK,UAAU;GAChD,CAAC;;AAGJ,QAAO;;;;;;;;AAST,SAAgB,sBAAsB,MAAqC;AACzE,KAAI,CAAC,QAAQ,CAAC,KAAK,SAAS,IAAI,CAC9B,QAAO,EAAE;CAGX,MAAM,WAAW,KAAK,MAAM,IAAI;CAChC,MAAM,YAAmC,EAAE;AAE3C,MAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,SAAS,yBAAyB,QAAQ;AAChD,YAAU,KAAK,GAAG,OAAO;;AAG3B,QAAO;;;;;;;;AAmBT,SAAgB,iBAAiB,MAAqC;AAEpE,QADe,sBAAsB,KAAK,CAC5B,QAAQ,MAAM,CAAC,EAAE,QAAQ"}
@@ -1,10 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const createRoutePropertyOrder_rule = require("./rules/create-route-property-order/create-route-property-order.rule.cjs");
4
- const routeParamNames_rule = require("./rules/route-param-names/route-param-names.rule.cjs");
5
- const rules = {
6
- [createRoutePropertyOrder_rule.name]: createRoutePropertyOrder_rule.rule,
7
- [routeParamNames_rule.name]: routeParamNames_rule.rule
1
+ const require_create_route_property_order_rule = require("./rules/create-route-property-order/create-route-property-order.rule.cjs");
2
+ const require_route_param_names_rule = require("./rules/route-param-names/route-param-names.rule.cjs");
3
+ //#region src/rules.ts
4
+ var rules = {
5
+ [require_create_route_property_order_rule.name]: require_create_route_property_order_rule.rule,
6
+ [require_route_param_names_rule.name]: require_route_param_names_rule.rule
8
7
  };
8
+ //#endregion
9
9
  exports.rules = rules;
10
- //# sourceMappingURL=rules.cjs.map
10
+
11
+ //# sourceMappingURL=rules.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rules.cjs","sources":["../../src/rules.ts"],"sourcesContent":["import * as createRoutePropertyOrder from './rules/create-route-property-order/create-route-property-order.rule'\nimport * as routeParamNames from './rules/route-param-names/route-param-names.rule'\nimport type { ESLintUtils } from '@typescript-eslint/utils'\nimport type { ExtraRuleDocs } from './types'\n\nexport const rules: Record<\n string,\n ESLintUtils.RuleModule<\n string,\n ReadonlyArray<unknown>,\n ExtraRuleDocs,\n ESLintUtils.RuleListener\n >\n> = {\n [createRoutePropertyOrder.name]: createRoutePropertyOrder.rule,\n [routeParamNames.name]: routeParamNames.rule,\n}\n"],"names":["createRoutePropertyOrder.name","createRoutePropertyOrder.rule","routeParamNames.name","routeParamNames.rule"],"mappings":";;;;AAKO,MAAM,QAQT;AAAA,EACF,CAACA,8BAAAA,IAA6B,GAAGC,8BAAAA;AAAAA,EACjC,CAACC,yBAAoB,GAAGC,qBAAAA;AAC1B;;"}
1
+ {"version":3,"file":"rules.cjs","names":[],"sources":["../../src/rules.ts"],"sourcesContent":["import * as createRoutePropertyOrder from './rules/create-route-property-order/create-route-property-order.rule'\nimport * as routeParamNames from './rules/route-param-names/route-param-names.rule'\nimport type { ESLintUtils } from '@typescript-eslint/utils'\nimport type { ExtraRuleDocs } from './types'\n\nexport const rules: Record<\n string,\n ESLintUtils.RuleModule<\n string,\n ReadonlyArray<unknown>,\n ExtraRuleDocs,\n ESLintUtils.RuleListener\n >\n> = {\n [createRoutePropertyOrder.name]: createRoutePropertyOrder.rule,\n [routeParamNames.name]: routeParamNames.rule,\n}\n"],"mappings":";;;AAKA,IAAa,QAQT;;;CAGH"}
@@ -1,54 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils = require("@typescript-eslint/utils");
1
+ let _typescript_eslint_utils = require("@typescript-eslint/utils");
2
+ //#region src/utils/detect-router-imports.ts
4
3
  function detectTanstackRouterImports(create) {
5
- return (context, optionsWithDefault) => {
6
- const tanstackRouterImportSpecifiers = [];
7
- const helpers = {
8
- isSpecificTanstackRouterImport(node, source) {
9
- return !!tanstackRouterImportSpecifiers.find((specifier) => {
10
- if (specifier.type === utils.TSESTree.AST_NODE_TYPES.ImportSpecifier && specifier.parent.type === utils.TSESTree.AST_NODE_TYPES.ImportDeclaration && specifier.parent.source.value === source) {
11
- return node.name === specifier.local.name;
12
- }
13
- return false;
14
- });
15
- },
16
- isTanstackRouterImport(node) {
17
- return !!tanstackRouterImportSpecifiers.find((specifier) => {
18
- if (specifier.type === utils.TSESTree.AST_NODE_TYPES.ImportSpecifier) {
19
- return node.name === specifier.local.name;
20
- }
21
- return false;
22
- });
23
- }
24
- };
25
- const detectionInstructions = {
26
- ImportDeclaration(node) {
27
- if (node.specifiers.length > 0 && // `importKind` is parser-dependent and can be undefined (eg. Espree)
28
- node.importKind !== "type" && node.source.value.startsWith("@tanstack/") && node.source.value.endsWith("-router")) {
29
- tanstackRouterImportSpecifiers.push(...node.specifiers);
30
- }
31
- }
32
- };
33
- const ruleInstructions = create(context, optionsWithDefault, helpers);
34
- const enhancedRuleInstructions = {};
35
- const allKeys = new Set(
36
- Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions))
37
- );
38
- allKeys.forEach((instruction) => {
39
- enhancedRuleInstructions[instruction] = (node) => {
40
- if (instruction in detectionInstructions) {
41
- detectionInstructions[instruction]?.(node);
42
- }
43
- const ruleFunction = ruleInstructions[instruction];
44
- if (ruleFunction !== void 0) {
45
- return ruleFunction(node);
46
- }
47
- return void 0;
48
- };
49
- });
50
- return enhancedRuleInstructions;
51
- };
4
+ return (context, optionsWithDefault) => {
5
+ const tanstackRouterImportSpecifiers = [];
6
+ const helpers = {
7
+ isSpecificTanstackRouterImport(node, source) {
8
+ return !!tanstackRouterImportSpecifiers.find((specifier) => {
9
+ if (specifier.type === _typescript_eslint_utils.TSESTree.AST_NODE_TYPES.ImportSpecifier && specifier.parent.type === _typescript_eslint_utils.TSESTree.AST_NODE_TYPES.ImportDeclaration && specifier.parent.source.value === source) return node.name === specifier.local.name;
10
+ return false;
11
+ });
12
+ },
13
+ isTanstackRouterImport(node) {
14
+ return !!tanstackRouterImportSpecifiers.find((specifier) => {
15
+ if (specifier.type === _typescript_eslint_utils.TSESTree.AST_NODE_TYPES.ImportSpecifier) return node.name === specifier.local.name;
16
+ return false;
17
+ });
18
+ }
19
+ };
20
+ const detectionInstructions = { ImportDeclaration(node) {
21
+ if (node.specifiers.length > 0 && node.importKind !== "type" && node.source.value.startsWith("@tanstack/") && node.source.value.endsWith("-router")) tanstackRouterImportSpecifiers.push(...node.specifiers);
22
+ } };
23
+ const ruleInstructions = create(context, optionsWithDefault, helpers);
24
+ const enhancedRuleInstructions = {};
25
+ new Set(Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions))).forEach((instruction) => {
26
+ enhancedRuleInstructions[instruction] = (node) => {
27
+ if (instruction in detectionInstructions) detectionInstructions[instruction]?.(node);
28
+ const ruleFunction = ruleInstructions[instruction];
29
+ if (ruleFunction !== void 0) return ruleFunction(node);
30
+ };
31
+ });
32
+ return enhancedRuleInstructions;
33
+ };
52
34
  }
35
+ //#endregion
53
36
  exports.detectTanstackRouterImports = detectTanstackRouterImports;
54
- //# sourceMappingURL=detect-router-imports.cjs.map
37
+
38
+ //# sourceMappingURL=detect-router-imports.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"detect-router-imports.cjs","sources":["../../../src/utils/detect-router-imports.ts"],"sourcesContent":["import { TSESTree } from '@typescript-eslint/utils'\nimport type { ESLintUtils, TSESLint } from '@typescript-eslint/utils'\n\ntype Create = Parameters<\n ReturnType<typeof ESLintUtils.RuleCreator>\n>[0]['create']\n\ntype Context = Parameters<Create>[0]\ntype Options = Parameters<Create>[1]\ntype Helpers = {\n isSpecificTanstackRouterImport: (\n node: TSESTree.Identifier,\n source: string,\n ) => boolean\n isTanstackRouterImport: (node: TSESTree.Identifier) => boolean\n}\n\ntype EnhancedCreate = (\n context: Context,\n options: Options,\n helpers: Helpers,\n) => ReturnType<Create>\n\nexport function detectTanstackRouterImports(create: EnhancedCreate): Create {\n return (context, optionsWithDefault) => {\n const tanstackRouterImportSpecifiers: Array<TSESTree.ImportClause> = []\n\n const helpers: Helpers = {\n isSpecificTanstackRouterImport(node, source) {\n return !!tanstackRouterImportSpecifiers.find((specifier) => {\n if (\n specifier.type === TSESTree.AST_NODE_TYPES.ImportSpecifier &&\n specifier.parent.type ===\n TSESTree.AST_NODE_TYPES.ImportDeclaration &&\n specifier.parent.source.value === source\n ) {\n return node.name === specifier.local.name\n }\n\n return false\n })\n },\n isTanstackRouterImport(node) {\n return !!tanstackRouterImportSpecifiers.find((specifier) => {\n if (specifier.type === TSESTree.AST_NODE_TYPES.ImportSpecifier) {\n return node.name === specifier.local.name\n }\n\n return false\n })\n },\n }\n\n const detectionInstructions: TSESLint.RuleListener = {\n ImportDeclaration(node) {\n if (\n node.specifiers.length > 0 &&\n // `importKind` is parser-dependent and can be undefined (eg. Espree)\n node.importKind !== 'type' &&\n node.source.value.startsWith('@tanstack/') &&\n node.source.value.endsWith('-router')\n ) {\n tanstackRouterImportSpecifiers.push(...node.specifiers)\n }\n },\n }\n\n // Call original rule definition\n const ruleInstructions = create(context, optionsWithDefault, helpers)\n const enhancedRuleInstructions: TSESLint.RuleListener = {}\n\n const allKeys = new Set(\n Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions)),\n )\n\n // Iterate over ALL instructions keys so we can override original rule instructions\n // to prevent their execution if conditions to report errors are not met.\n allKeys.forEach((instruction) => {\n enhancedRuleInstructions[instruction] = (node) => {\n if (instruction in detectionInstructions) {\n detectionInstructions[instruction]?.(node)\n }\n\n const ruleFunction = ruleInstructions[instruction]\n if (ruleFunction !== undefined) {\n return ruleFunction(node)\n }\n\n return undefined\n }\n })\n\n return enhancedRuleInstructions\n }\n}\n"],"names":["TSESTree"],"mappings":";;;AAuBO,SAAS,4BAA4B,QAAgC;AAC1E,SAAO,CAAC,SAAS,uBAAuB;AACtC,UAAM,iCAA+D,CAAA;AAErE,UAAM,UAAmB;AAAA,MACvB,+BAA+B,MAAM,QAAQ;AAC3C,eAAO,CAAC,CAAC,+BAA+B,KAAK,CAAC,cAAc;AAC1D,cACE,UAAU,SAASA,MAAAA,SAAS,eAAe,mBAC3C,UAAU,OAAO,SACfA,MAAAA,SAAS,eAAe,qBAC1B,UAAU,OAAO,OAAO,UAAU,QAClC;AACA,mBAAO,KAAK,SAAS,UAAU,MAAM;AAAA,UACvC;AAEA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,MACA,uBAAuB,MAAM;AAC3B,eAAO,CAAC,CAAC,+BAA+B,KAAK,CAAC,cAAc;AAC1D,cAAI,UAAU,SAASA,eAAS,eAAe,iBAAiB;AAC9D,mBAAO,KAAK,SAAS,UAAU,MAAM;AAAA,UACvC;AAEA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IAAA;AAGF,UAAM,wBAA+C;AAAA,MACnD,kBAAkB,MAAM;AACtB,YACE,KAAK,WAAW,SAAS;AAAA,QAEzB,KAAK,eAAe,UACpB,KAAK,OAAO,MAAM,WAAW,YAAY,KACzC,KAAK,OAAO,MAAM,SAAS,SAAS,GACpC;AACA,yCAA+B,KAAK,GAAG,KAAK,UAAU;AAAA,QACxD;AAAA,MACF;AAAA,IAAA;AAIF,UAAM,mBAAmB,OAAO,SAAS,oBAAoB,OAAO;AACpE,UAAM,2BAAkD,CAAA;AAExD,UAAM,UAAU,IAAI;AAAA,MAClB,OAAO,KAAK,qBAAqB,EAAE,OAAO,OAAO,KAAK,gBAAgB,CAAC;AAAA,IAAA;AAKzE,YAAQ,QAAQ,CAAC,gBAAgB;AAC/B,+BAAyB,WAAW,IAAI,CAAC,SAAS;AAChD,YAAI,eAAe,uBAAuB;AACxC,gCAAsB,WAAW,IAAI,IAAI;AAAA,QAC3C;AAEA,cAAM,eAAe,iBAAiB,WAAW;AACjD,YAAI,iBAAiB,QAAW;AAC9B,iBAAO,aAAa,IAAI;AAAA,QAC1B;AAEA,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;;"}
1
+ {"version":3,"file":"detect-router-imports.cjs","names":[],"sources":["../../../src/utils/detect-router-imports.ts"],"sourcesContent":["import { TSESTree } from '@typescript-eslint/utils'\nimport type { ESLintUtils, TSESLint } from '@typescript-eslint/utils'\n\ntype Create = Parameters<\n ReturnType<typeof ESLintUtils.RuleCreator>\n>[0]['create']\n\ntype Context = Parameters<Create>[0]\ntype Options = Parameters<Create>[1]\ntype Helpers = {\n isSpecificTanstackRouterImport: (\n node: TSESTree.Identifier,\n source: string,\n ) => boolean\n isTanstackRouterImport: (node: TSESTree.Identifier) => boolean\n}\n\ntype EnhancedCreate = (\n context: Context,\n options: Options,\n helpers: Helpers,\n) => ReturnType<Create>\n\nexport function detectTanstackRouterImports(create: EnhancedCreate): Create {\n return (context, optionsWithDefault) => {\n const tanstackRouterImportSpecifiers: Array<TSESTree.ImportClause> = []\n\n const helpers: Helpers = {\n isSpecificTanstackRouterImport(node, source) {\n return !!tanstackRouterImportSpecifiers.find((specifier) => {\n if (\n specifier.type === TSESTree.AST_NODE_TYPES.ImportSpecifier &&\n specifier.parent.type ===\n TSESTree.AST_NODE_TYPES.ImportDeclaration &&\n specifier.parent.source.value === source\n ) {\n return node.name === specifier.local.name\n }\n\n return false\n })\n },\n isTanstackRouterImport(node) {\n return !!tanstackRouterImportSpecifiers.find((specifier) => {\n if (specifier.type === TSESTree.AST_NODE_TYPES.ImportSpecifier) {\n return node.name === specifier.local.name\n }\n\n return false\n })\n },\n }\n\n const detectionInstructions: TSESLint.RuleListener = {\n ImportDeclaration(node) {\n if (\n node.specifiers.length > 0 &&\n // `importKind` is parser-dependent and can be undefined (eg. Espree)\n node.importKind !== 'type' &&\n node.source.value.startsWith('@tanstack/') &&\n node.source.value.endsWith('-router')\n ) {\n tanstackRouterImportSpecifiers.push(...node.specifiers)\n }\n },\n }\n\n // Call original rule definition\n const ruleInstructions = create(context, optionsWithDefault, helpers)\n const enhancedRuleInstructions: TSESLint.RuleListener = {}\n\n const allKeys = new Set(\n Object.keys(detectionInstructions).concat(Object.keys(ruleInstructions)),\n )\n\n // Iterate over ALL instructions keys so we can override original rule instructions\n // to prevent their execution if conditions to report errors are not met.\n allKeys.forEach((instruction) => {\n enhancedRuleInstructions[instruction] = (node) => {\n if (instruction in detectionInstructions) {\n detectionInstructions[instruction]?.(node)\n }\n\n const ruleFunction = ruleInstructions[instruction]\n if (ruleFunction !== undefined) {\n return ruleFunction(node)\n }\n\n return undefined\n }\n })\n\n return enhancedRuleInstructions\n }\n}\n"],"mappings":";;AAuBA,SAAgB,4BAA4B,QAAgC;AAC1E,SAAQ,SAAS,uBAAuB;EACtC,MAAM,iCAA+D,EAAE;EAEvE,MAAM,UAAmB;GACvB,+BAA+B,MAAM,QAAQ;AAC3C,WAAO,CAAC,CAAC,+BAA+B,MAAM,cAAc;AAC1D,SACE,UAAU,SAAS,yBAAA,SAAS,eAAe,mBAC3C,UAAU,OAAO,SACf,yBAAA,SAAS,eAAe,qBAC1B,UAAU,OAAO,OAAO,UAAU,OAElC,QAAO,KAAK,SAAS,UAAU,MAAM;AAGvC,YAAO;MACP;;GAEJ,uBAAuB,MAAM;AAC3B,WAAO,CAAC,CAAC,+BAA+B,MAAM,cAAc;AAC1D,SAAI,UAAU,SAAS,yBAAA,SAAS,eAAe,gBAC7C,QAAO,KAAK,SAAS,UAAU,MAAM;AAGvC,YAAO;MACP;;GAEL;EAED,MAAM,wBAA+C,EACnD,kBAAkB,MAAM;AACtB,OACE,KAAK,WAAW,SAAS,KAEzB,KAAK,eAAe,UACpB,KAAK,OAAO,MAAM,WAAW,aAAa,IAC1C,KAAK,OAAO,MAAM,SAAS,UAAU,CAErC,gCAA+B,KAAK,GAAG,KAAK,WAAW;KAG5D;EAGD,MAAM,mBAAmB,OAAO,SAAS,oBAAoB,QAAQ;EACrE,MAAM,2BAAkD,EAAE;AAE1C,MAAI,IAClB,OAAO,KAAK,sBAAsB,CAAC,OAAO,OAAO,KAAK,iBAAiB,CAAC,CACzE,CAIO,SAAS,gBAAgB;AAC/B,4BAAyB,gBAAgB,SAAS;AAChD,QAAI,eAAe,sBACjB,uBAAsB,eAAe,KAAK;IAG5C,MAAM,eAAe,iBAAiB;AACtC,QAAI,iBAAiB,KAAA,EACnB,QAAO,aAAa,KAAK;;IAK7B;AAEF,SAAO"}
@@ -1,5 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const getDocsUrl = (ruleName) => `https://tanstack.com/router/latest/docs/eslint/${ruleName}`;
1
+ //#region src/utils/get-docs-url.ts
2
+ var getDocsUrl = (ruleName) => `https://tanstack.com/router/latest/docs/eslint/${ruleName}`;
3
+ //#endregion
4
4
  exports.getDocsUrl = getDocsUrl;
5
- //# sourceMappingURL=get-docs-url.cjs.map
5
+
6
+ //# sourceMappingURL=get-docs-url.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-docs-url.cjs","sources":["../../../src/utils/get-docs-url.ts"],"sourcesContent":["export const getDocsUrl = (ruleName: string): string =>\n `https://tanstack.com/router/latest/docs/eslint/${ruleName}`\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa,CAAC,aACzB,kDAAkD,QAAQ;;"}
1
+ {"version":3,"file":"get-docs-url.cjs","names":[],"sources":["../../../src/utils/get-docs-url.ts"],"sourcesContent":["export const getDocsUrl = (ruleName: string): string =>\n `https://tanstack.com/router/latest/docs/eslint/${ruleName}`\n"],"mappings":";AAAA,IAAa,cAAc,aACzB,kDAAkD"}
package/dist/esm/index.js CHANGED
@@ -1,32 +1,27 @@
1
1
  import { rules } from "./rules.js";
2
- const plugin = {
3
- meta: {
4
- name: "@tanstack/eslint-plugin-router"
5
- },
6
- configs: {},
7
- rules
2
+ //#region src/index.ts
3
+ var plugin = {
4
+ meta: { name: "@tanstack/eslint-plugin-router" },
5
+ configs: {},
6
+ rules
8
7
  };
9
8
  Object.assign(plugin.configs, {
10
- recommended: {
11
- plugins: ["@tanstack/eslint-plugin-router"],
12
- rules: {
13
- "@tanstack/router/create-route-property-order": "warn",
14
- "@tanstack/router/route-param-names": "error"
15
- }
16
- },
17
- "flat/recommended": [
18
- {
19
- plugins: {
20
- "@tanstack/router": plugin
21
- },
22
- rules: {
23
- "@tanstack/router/create-route-property-order": "warn",
24
- "@tanstack/router/route-param-names": "error"
25
- }
26
- }
27
- ]
9
+ recommended: {
10
+ plugins: ["@tanstack/eslint-plugin-router"],
11
+ rules: {
12
+ "@tanstack/router/create-route-property-order": "warn",
13
+ "@tanstack/router/route-param-names": "error"
14
+ }
15
+ },
16
+ "flat/recommended": [{
17
+ plugins: { "@tanstack/router": plugin },
18
+ rules: {
19
+ "@tanstack/router/create-route-property-order": "warn",
20
+ "@tanstack/router/route-param-names": "error"
21
+ }
22
+ }]
28
23
  });
29
- export {
30
- plugin as default
31
- };
32
- //# sourceMappingURL=index.js.map
24
+ //#endregion
25
+ export { plugin as default };
26
+
27
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { rules } from './rules'\nimport type { ESLint, Linter } from 'eslint'\nimport type { RuleModule } from '@typescript-eslint/utils/ts-eslint'\n\ntype RuleKey = keyof typeof rules\n\ninterface Plugin extends Omit<ESLint.Plugin, 'rules'> {\n rules: Record<RuleKey, RuleModule<any, any, any>>\n configs: {\n recommended: ESLint.ConfigData\n 'flat/recommended': Array<Linter.FlatConfig>\n }\n}\n\nconst plugin: Plugin = {\n meta: {\n name: '@tanstack/eslint-plugin-router',\n },\n configs: {} as Plugin['configs'],\n rules,\n}\n\n// Assign configs here so we can reference `plugin`\nObject.assign(plugin.configs, {\n recommended: {\n plugins: ['@tanstack/eslint-plugin-router'],\n rules: {\n '@tanstack/router/create-route-property-order': 'warn',\n '@tanstack/router/route-param-names': 'error',\n },\n },\n 'flat/recommended': [\n {\n plugins: {\n '@tanstack/router': plugin,\n },\n rules: {\n '@tanstack/router/create-route-property-order': 'warn',\n '@tanstack/router/route-param-names': 'error',\n },\n },\n ],\n})\n\nexport default plugin\n"],"names":[],"mappings":";AAcA,MAAM,SAAiB;AAAA,EACrB,MAAM;AAAA,IACJ,MAAM;AAAA,EAAA;AAAA,EAER,SAAS,CAAA;AAAA,EACT;AACF;AAGA,OAAO,OAAO,OAAO,SAAS;AAAA,EAC5B,aAAa;AAAA,IACX,SAAS,CAAC,gCAAgC;AAAA,IAC1C,OAAO;AAAA,MACL,gDAAgD;AAAA,MAChD,sCAAsC;AAAA,IAAA;AAAA,EACxC;AAAA,EAEF,oBAAoB;AAAA,IAClB;AAAA,MACE,SAAS;AAAA,QACP,oBAAoB;AAAA,MAAA;AAAA,MAEtB,OAAO;AAAA,QACL,gDAAgD;AAAA,QAChD,sCAAsC;AAAA,MAAA;AAAA,IACxC;AAAA,EACF;AAEJ,CAAC;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { rules } from './rules'\nimport type { ESLint, Linter } from 'eslint'\nimport type { RuleModule } from '@typescript-eslint/utils/ts-eslint'\n\ntype RuleKey = keyof typeof rules\n\ninterface Plugin extends Omit<ESLint.Plugin, 'rules'> {\n rules: Record<RuleKey, RuleModule<any, any, any>>\n configs: {\n recommended: ESLint.ConfigData\n 'flat/recommended': Array<Linter.FlatConfig>\n }\n}\n\nconst plugin: Plugin = {\n meta: {\n name: '@tanstack/eslint-plugin-router',\n },\n configs: {} as Plugin['configs'],\n rules,\n}\n\n// Assign configs here so we can reference `plugin`\nObject.assign(plugin.configs, {\n recommended: {\n plugins: ['@tanstack/eslint-plugin-router'],\n rules: {\n '@tanstack/router/create-route-property-order': 'warn',\n '@tanstack/router/route-param-names': 'error',\n },\n },\n 'flat/recommended': [\n {\n plugins: {\n '@tanstack/router': plugin,\n },\n rules: {\n '@tanstack/router/create-route-property-order': 'warn',\n '@tanstack/router/route-param-names': 'error',\n },\n },\n ],\n})\n\nexport default plugin\n"],"mappings":";;AAcA,IAAM,SAAiB;CACrB,MAAM,EACJ,MAAM,kCACP;CACD,SAAS,EAAE;CACX;CACD;AAGD,OAAO,OAAO,OAAO,SAAS;CAC5B,aAAa;EACX,SAAS,CAAC,iCAAiC;EAC3C,OAAO;GACL,gDAAgD;GAChD,sCAAsC;GACvC;EACF;CACD,oBAAoB,CAClB;EACE,SAAS,EACP,oBAAoB,QACrB;EACD,OAAO;GACL,gDAAgD;GAChD,sCAAsC;GACvC;EACF,CACF;CACF,CAAC"}