Back to Medusa

{metadata.title}

www/apps/resources/app/lint/rules/scheduled-job-name-unique/page.mdx

2.17.01.4 KB
Original Source

import { Note } from "docs-ui"

export const metadata = { title: scheduled-job-name-unique - ESLint plugin rules, }

{metadata.title}

This rule requires a scheduled job's config.name to be unique across all scheduled jobs in the project.

Severity

error. This rule is enabled in the strict preset.

By default, Medusa projects use the recommended preset, which doesn't enable this rule. To use it, switch to the strict preset.

What it Targets

This rule targets files in your project's src/jobs directory. It reports a config.name that's already used by another scheduled job file.

The following code is reported by the rule when another job already uses the name sync-products:

ts
export default async function () {}

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

Instead, give the job a unique name:

ts
export default async function () {}

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

Why it's Important

Medusa identifies each scheduled job by its name. Two jobs sharing a name conflict with each other, so only one is registered.

Learn more in the Scheduled Jobs documentation.

Fixable

This rule isn't auto-fixable.