|
1
|
--- |
|
2
|
sidebar_label: "scheduled-job-config-required" |
|
3
|
--- |
|
4
|
|
|
5
|
export const metadata = { |
|
6
|
title: `scheduled-job-config-required - ESLint plugin rules`, |
|
7
|
} |
|
8
|
|
|
9
|
# {metadata.title} |
|
10
|
|
|
11
|
This rule requires scheduled job files to export a `config` object with `name` and `schedule` properties. |
|
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/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. |
|
20
|
|
|
21
|
The following code is reported by the rule: |
|
22
|
|
|
23
|
```ts title="src/jobs/sync-products.ts" |
|
24
|
export default async function () {} |
|
25
|
|
|
26
|
export const config = {} |
|
27
|
``` |
|
28
|
|
|
29
|
Instead, export a `config` object with `name` and `schedule`: |
|
30
|
|
|
31
|
```ts title="src/jobs/sync-products.ts" |
|
32
|
export default async function () {} |
|
33
|
|
|
34
|
export const config = { |
|
35
|
name: "sync-products", |
|
36
|
schedule: "0 0 * * *", |
|
37
|
} |
|
38
|
``` |
|
39
|
|
|
40
|
## Why it's Important |
|
41
|
|
|
42
|
The `name` uniquely identifies the job, and the `schedule` tells Medusa when to run it. Without both, Medusa can't register the job. |
|
43
|
|
|
44
|
Learn more in the [Scheduled Jobs documentation](!docs!/learn/fundamentals/scheduled-jobs). |
|
45
|
|
|
46
|
## Fixable |
|
47
|
|
|
48
|
This rule isn't auto-fixable. |