|
1
|
--- |
|
2
|
sidebar_label: "step-id-kebab-case" |
|
3
|
--- |
|
4
|
|
|
5
|
export const metadata = { |
|
6
|
title: `step-id-kebab-case - ESLint plugin rules`, |
|
7
|
} |
|
8
|
|
|
9
|
# {metadata.title} |
|
10
|
|
|
11
|
This rule requires a step's ID, the first argument of `createStep`, to be a kebab-case string that matches the enclosing variable name or filename. |
|
12
|
|
|
13
|
## Severity |
|
14
|
|
|
15
|
`warn`. 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/workflows` directory. It reports a `createStep` ID that isn't kebab-case or doesn't match the enclosing variable name or filename, with a trailing `Step` segment stripped. |
|
20
|
|
|
21
|
The following code is reported by the rule: |
|
22
|
|
|
23
|
```ts title="src/workflows/example.ts" |
|
24
|
import { createStep } from "@medusajs/framework/workflows-sdk" |
|
25
|
|
|
26
|
export const fetchCustomersStep = createStep( |
|
27
|
"fetchCustomers", |
|
28
|
() => {} |
|
29
|
) |
|
30
|
``` |
|
31
|
|
|
32
|
Instead, use a kebab-case ID that matches the variable name: |
|
33
|
|
|
34
|
```ts title="src/workflows/example.ts" |
|
35
|
import { createStep } from "@medusajs/framework/workflows-sdk" |
|
36
|
|
|
37
|
export const fetchCustomersStep = createStep( |
|
38
|
"fetch-customers", |
|
39
|
() => {} |
|
40
|
) |
|
41
|
``` |
|
42
|
|
|
43
|
## Why it's Important |
|
44
|
|
|
45
|
Using a consistent, kebab-case ID that matches the step's variable name or filename makes steps easier to identify in logs and traces. |
|
46
|
|
|
47
|
Learn more in the [Workflows documentation](!docs!/learn/fundamentals/workflows). |
|
48
|
|
|
49
|
## Fixable |
|
50
|
|
|
51
|
This rule is auto-fixable. Run the linter with the `--fix` option to apply the fix automatically. |
|
52
|
|
|
53
|
## Turn it Off |
|
54
|
|
|
55
|
To turn off this rule, set it to `off` in your ESLint configuration: |
|
56
|
|
|
57
|
```ts title="eslint.config.ts" |
|
58
|
import { defineConfig } from "eslint/config" |
|
59
|
import medusa from "@medusajs/eslint-plugin" |
|
60
|
|
|
61
|
export default defineConfig([ |
|
62
|
...medusa.configs.recommended, |
|
63
|
{ |
|
64
|
rules: { |
|
65
|
"@medusajs/step-id-kebab-case": "off", |
|
66
|
}, |
|
67
|
}, |
|
68
|
]) |
|
69
|
``` |
|
70
|
|
|
71
|
Or disable it for a single line using an inline comment: |
|
72
|
|
|
73
|
```ts |
|
74
|
// eslint-disable-next-line @medusajs/step-id-kebab-case |
|
75
|
export const fetchCustomersStep = createStep() |
|
76
|
``` |