1 ---
2 sidebar_label: "link-create-keys-modules-enum"
3 ---
4
5 export const metadata = {
6 title: `link-create-keys-modules-enum - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires you to use `Modules` enum members instead of bare string keys in link calls and remote-link workflow steps.
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 files in your project's `src/workflows` directory. It reports bare string keys that match a `Modules` enum value in:
20
21 - `link.create`, `link.dismiss`, `link.delete`, and `link.restore` calls.
22 - Remote-link workflow steps such as `createRemoteLinkStep` and `dismissRemoteLinkStep`.
23
24 The following code is reported by the rule:
25
26 ```ts title="src/workflows/steps/link.ts"
27 await link.create({
28 product: { product_id: "1" },
29 })
30 ```
31
32 Instead, use the matching `Modules` enum member as a computed key:
33
34 ```ts title="src/workflows/steps/link.ts"
35 import { Modules } from "@medusajs/framework/utils"
36
37 await link.create({
38 [Modules.PRODUCT]: { product_id: "1" },
39 })
40 ```
41
42 ## Why it's Important
43
44 The `Modules` enum gives you a single source of truth for module keys. Using it avoids typos in string keys and keeps your links consistent with Medusa's module names.
45
46 Learn more in the [Module Links documentation](!docs!/learn/fundamentals/module-links).
47
48 ## Fixable
49
50 This rule is auto-fixable. Run the linter with the `--fix` option to apply the fix automatically.
51
52 ## Turn it Off
53
54 To turn off this rule, set it to `off` in your ESLint configuration:
55
56 ```ts title="eslint.config.ts"
57 import { defineConfig } from "eslint/config"
58 import medusa from "@medusajs/eslint-plugin"
59
60 export default defineConfig([
61 ...medusa.configs.recommended,
62 {
63 rules: {
64 "@medusajs/link-create-keys-modules-enum": "off",
65 },
66 },
67 ])
68 ```
69
70 Or disable it for a single line using an inline comment:
71
72 ```ts
73 // eslint-disable-next-line @medusajs/link-create-keys-modules-enum
74 await link.create({ product: { product_id: "1" } })
75 ```