Back to Medusa

{metadata.title}

www/apps/resources/app/lint/rules/subscriber-config-export-required/page.mdx

2.17.01.2 KB
Original Source

export const metadata = { title: subscriber-config-export-required - ESLint plugin rules, }

{metadata.title}

This rule requires subscriber files to export a config object with at least an event property.

Severity

error. This rule is enabled in the recommended preset.

What it Targets

This rule targets files in your project's src/subscribers directory. It reports a subscriber file that's missing the named config export, or whose config object doesn't declare an event property.

The following code is reported by the rule:

ts
export default async function () {}

Instead, export a config object with an event property:

ts
export default async function () {}

export const config = {
  event: "order.placed",
}

Why it's Important

The config export tells Medusa which event(s) the subscriber listens to. Without an event property, Medusa can't register the subscriber for any event.

Learn more in the Subscribers documentation.

Fixable

This rule isn't auto-fixable.