link-uses-linkable-properties - ESLint plugin rules

This rule requires arguments to defineLink to be of the form Module.linkable.<dataModel> or an object with a linkable: Module.linkable.<dataModel> property.

Severity#

warn. This rule is enabled in the recommended preset.

What it Targets#

This rule targets files in your project's src/links directory. It reports defineLink arguments that don't reference a module's linkable property.

The following code is reported by the rule:

src/links/product-post.ts
1import { defineLink } from "@medusajs/framework/utils"2import ProductModule from "@medusajs/medusa/product"3
4export default defineLink(ProductModule, {5  foo: "bar",6})

Instead, reference each module's linkable property:

src/links/product-post.ts
1import { defineLink } from "@medusajs/framework/utils"2import ProductModule from "@medusajs/medusa/product"3import BlogModule from "../modules/blog"4
5export default defineLink(6  ProductModule.linkable.product,7  BlogModule.linkable.post8)

You can also pass an object with a linkable property to set options such as isList:

src/links/product-post.ts
1export default defineLink(2  ProductModule.linkable.product,3  { linkable: BlogModule.linkable.post, isList: true }4)

When linking to a data model by its id (for example, linking to draft orders via OrderModule.linkable.order.id), the .id suffix on the linkable property is also valid:

src/links/vendor-draft-order.ts
1import { defineLink } from "@medusajs/framework/utils"2import MarketplaceModule from "../modules/marketplace"3import OrderModule from "@medusajs/medusa/order"4
5export default defineLink(6  MarketplaceModule.linkable.vendor,7  { linkable: OrderModule.linkable.order.id, isList: true }8)

Why it's Important#

A module's linkable property exposes the data models that can participate in a link. Referencing it ensures Medusa can resolve the linked records correctly at runtime.

Learn more in the Module Links documentation.

Fixable#

This rule isn't auto-fixable.

Turn it Off#

To turn off this rule, set it to off in your ESLint configuration:

eslint.config.ts
1import { defineConfig } from "eslint/config"2import medusa from "@medusajs/eslint-plugin"3
4export default defineConfig([5  ...medusa.configs.recommended,6  {7    rules: {8      "@medusajs/link-uses-linkable-properties": "off",9    },10  },11])

Or disable it for a single line using an inline comment:

Code
1// eslint-disable-next-line @medusajs/link-uses-linkable-properties2export default defineLink(ProductModule, { foo: "bar" })
Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵