1 ---
2 sidebar_label: "zod-import-source"
3 ---
4
5 export const metadata = {
6 title: `zod-import-source - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires importing Zod from `@medusajs/framework/zod` (Medusa v2.13+), not the bare `zod` package.
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 all files in your backend customizations. It reports imports and re-exports whose source is the bare `zod` package.
20
21 The following code is reported by the rule:
22
23 ```ts title="src/api/example.ts"
24 // non-compliant
25 import { z } from "zod"
26 ```
27
28 Instead, import from the Medusa Framework entry point:
29
30 ```ts title="src/api/example.ts"
31 // compliant
32 import { z } from "@medusajs/framework/zod"
33 ```
34
35 ## Why it's Important
36
37 Importing Zod from `@medusajs/framework/zod` ensures you use the same Zod version Medusa relies on, avoiding version mismatches and duplicate copies in your project.
38
39 Learn more in the [API route validation documentation](!docs!/learn/fundamentals/api-routes/validation).
40
41 ## Fixable
42
43 This rule is auto-fixable. Run the linter with the `--fix` option to apply the fix automatically.
44
45 ## Turn it Off
46
47 To turn off this rule, set it to `off` in your ESLint configuration:
48
49 ```ts title="eslint.config.ts"
50 import { defineConfig } from "eslint/config"
51 import medusa from "@medusajs/eslint-plugin"
52
53 export default defineConfig([
54 ...medusa.configs.recommended,
55 {
56 rules: {
57 "@medusajs/zod-import-source": "off",
58 },
59 },
60 ])
61 ```
62
63 Or disable it for a single line using an inline comment:
64
65 ```ts
66 // eslint-disable-next-line @medusajs/zod-import-source
67 import { z } from "zod"
68 ```