1 ---
2 sidebar_label: "widget-must-have-default-export"
3 ---
4
5 export const metadata = {
6 title: `widget-must-have-default-export - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires widget files to default-export the widget component.
12
13 ## Severity
14
15 `error`. This rule is enabled in the [recommended](../../page.mdx#recommended) preset.
16
17 ## What it Targets
18
19 This rule targets files in your project's `src/admin/widgets` directory. It reports a widget file that doesn't have a default export.
20
21 The following code is reported by the rule:
22
23 ```tsx title="src/admin/widgets/product-widget.tsx"
24 import { defineWidgetConfig } from "@medusajs/admin-sdk"
25
26 const MyWidget = () => null
27
28 export const config = defineWidgetConfig({
29 zone: "product.details",
30 })
31
32 export { MyWidget }
33 ```
34
35 Instead, default-export the widget component:
36
37 ```tsx title="src/admin/widgets/product-widget.tsx"
38 import { defineWidgetConfig } from "@medusajs/admin-sdk"
39
40 const MyWidget = () => null
41
42 export const config = defineWidgetConfig({
43 zone: "product.details",
44 })
45
46 export default MyWidget
47 ```
48
49 ## Why it's Important
50
51 Medusa renders the default export of a widget file in the configured zones. Without a default export, the widget has no component to render.
52
53 Learn more in the [Admin Widgets documentation](!docs!/learn/fundamentals/admin/widgets).
54
55 ## Fixable
56
57 This rule isn't auto-fixable.