widget-must-export-config - ESLint plugin rules

This rule requires widget files to export a named config initialized with defineWidgetConfig.

Severity#

error. This rule is enabled in the recommended preset.

What it Targets#

This rule targets files in your project's src/admin/widgets directory. It reports a widget file that's missing a named config export, or whose config export isn't initialized with defineWidgetConfig.

The following code is reported by the rule:

src/admin/widgets/product-widget.tsx
1const MyWidget = () => <>Widget</>2
3export default MyWidget

Instead, export a config initialized with defineWidgetConfig:

src/admin/widgets/product-widget.tsx
1import { defineWidgetConfig } from "@medusajs/admin-sdk"2
3const MyWidget = () => <>Widget</>4
5export const config = defineWidgetConfig({6  zone: "product.details",7})8
9export default MyWidget

Why it's Important#

The config export tells Medusa which zones a widget is injected into. Without it, Medusa can't register the widget in the admin dashboard.

Learn more in the Admin Widgets documentation.

Fixable#

This rule isn't auto-fixable.

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
⇧↵