1 ---
2 sidebar_label: "prefer-link-over-remote-link"
3 ---
4
5 export const metadata = {
6 title: `prefer-link-over-remote-link - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires you to use `Link` instead of `RemoteLink`, which is deprecated since Medusa v2.2.0.
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 anywhere in your project. It reports usages of the deprecated remote link, including:
20
21 - Resolving the `"remoteLink"` registration key.
22 - Using `ContainerRegistrationKeys.REMOTE_LINK`.
23 - Importing the `RemoteLink` or `IRemoteLink` types.
24
25 The following code is reported by the rule:
26
27 ```ts title="src/workflows/steps/create-link.ts"
28 import { RemoteLink } from "@medusajs/framework/types"
29
30 const link = container.resolve("remoteLink")
31 ```
32
33 Instead, use the `"link"` registration key and the `Link` type:
34
35 ```ts title="src/workflows/steps/create-link.ts"
36 import { Link } from "@medusajs/framework/types"
37
38 const link = container.resolve("link")
39 ```
40
41 You can also resolve the link using `ContainerRegistrationKeys.LINK`:
42
43 ```ts title="src/workflows/steps/create-link.ts"
44 import {
45 ContainerRegistrationKeys,
46 } from "@medusajs/framework/utils"
47
48 const link = container.resolve(
49 ContainerRegistrationKeys.LINK
50 )
51 ```
52
53 ## Why it's Important
54
55 `RemoteLink` is deprecated since Medusa v2.2.0 and may be removed in a future version. Using `Link` keeps your code aligned with the supported API.
56
57 Learn more in the [Module Links documentation](!docs!/learn/fundamentals/module-links).
58
59 ## Fixable
60
61 This rule is auto-fixable. Run the linter with the `--fix` option to apply the fix automatically.
62
63 ## Turn it Off
64
65 To turn off this rule, set it to `off` in your ESLint configuration:
66
67 ```ts title="eslint.config.ts"
68 import { defineConfig } from "eslint/config"
69 import medusa from "@medusajs/eslint-plugin"
70
71 export default defineConfig([
72 ...medusa.configs.recommended,
73 {
74 rules: {
75 "@medusajs/prefer-link-over-remote-link": "off",
76 },
77 },
78 ])
79 ```
80
81 Or disable it for a single line using an inline comment:
82
83 ```ts
84 // eslint-disable-next-line @medusajs/prefer-link-over-remote-link
85 const link = container.resolve("remoteLink")
86 ```