widget-zone-must-be-string-literal - ESLint plugin rules

This rule requires the zone property in defineWidgetConfig to be a string literal or an array of string literals.

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 zone property whose value isn't a string literal, an array of string literals, or a template literal without expressions.

The following code is reported by the rule:

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

Instead, use a string literal:

src/admin/widgets/product-widget.tsx
1import { defineWidgetConfig } from "@medusajs/admin-sdk"2
3export const config = defineWidgetConfig({4  zone: "product.details",5})

Why it's Important#

Medusa statically analyzes widget files to determine the zones a widget is injected into. A dynamic zone value can't be resolved at build time, so the widget may not render in the expected location.

Learn more in the Admin Development Constraints documentation.

Fixable#

This rule is auto-fixable. Run the linter with the --fix option to apply the fix automatically.

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