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:
Instead, reference each module's linkable property:
You can also pass an object with a linkable property to set options such as isList:
src/links/product-post.ts1export 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:
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:
Or disable it for a single line using an inline comment: