1 ---
2 sidebar_label: "ui-route-config-via-define-route-config"
3 ---
4
5 export const metadata = {
6 title: `ui-route-config-via-define-route-config - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires a UI route `config` export to be initialized with `defineRouteConfig`.
12
13 ## Severity
14
15 `warn`. This rule is enabled in the [recommended](../../page.mdx#recommended) preset.
16
17 ## What it Targets
18
19 This rule targets `page.tsx` files in your project's `src/admin/routes` directory. It reports a `config` export that isn't initialized with `defineRouteConfig` from `@medusajs/admin-sdk`.
20
21 The following code is reported by the rule:
22
23 ```tsx title="src/admin/routes/custom/page.tsx"
24 const CustomPage = () => <>Custom</>
25
26 export const config = {
27 label: "Custom",
28 }
29
30 export default CustomPage
31 ```
32
33 Instead, initialize `config` with `defineRouteConfig`:
34
35 ```tsx title="src/admin/routes/custom/page.tsx"
36 import { defineRouteConfig } from "@medusajs/admin-sdk"
37
38 const CustomPage = () => <>Custom</>
39
40 export const config = defineRouteConfig({
41 label: "Custom",
42 })
43
44 export default CustomPage
45 ```
46
47 ## Why it's Important
48
49 The `defineRouteConfig` helper provides the expected type and structure for a route's sidebar configuration, so Medusa can register the route correctly.
50
51 Learn more in the [UI Routes documentation](!docs!/learn/fundamentals/admin/ui-routes).
52
53 ## Fixable
54
55 This rule isn't auto-fixable.
56
57 ## Turn it Off
58
59 To turn off this rule, set it to `off` in your ESLint configuration:
60
61 ```ts title="eslint.config.ts"
62 import { defineConfig } from "eslint/config"
63 import medusa from "@medusajs/eslint-plugin"
64
65 export default defineConfig([
66 ...medusa.configs.recommended,
67 {
68 rules: {
69 "@medusajs/ui-route-config-via-define-route-config": "off",
70 },
71 },
72 ])
73 ```
74
75 Or disable it for a single line using an inline comment:
76
77 ```tsx
78 // eslint-disable-next-line @medusajs/ui-route-config-via-define-route-config
79 export const config = {
80 ```