Back to Medusa

{metadata.title}

www/apps/resources/app/lint/rules/scheduled-job-config-required/page.mdx

2.17.01.2 KB
Original Source

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

{metadata.title}

This rule requires scheduled job files to export a config object with name and schedule properties.

Severity

error. This rule is enabled in the recommended preset.

What it Targets

This rule targets files in your project's src/jobs directory. It reports a scheduled job file that's missing the named config export, or whose config object doesn't declare both a name and a schedule property.

The following code is reported by the rule:

ts
export default async function () {}

export const config = {}

Instead, export a config object with name and schedule:

ts
export default async function () {}

export const config = {
  name: "sync-products",
  schedule: "0 0 * * *",
}

Why it's Important

The name uniquely identifies the job, and the schedule tells Medusa when to run it. Without both, Medusa can't register the job.

Learn more in the Scheduled Jobs documentation.

Fixable

This rule isn't auto-fixable.