no-duplicate-step-id-in-workflow - ESLint plugin rules

This rule disallows invoking the same step more than once in a createWorkflow constructor without renaming the subsequent calls with .config({ name }).

Severity#

error. This rule is enabled in the recommended preset.

What it Targets#

This rule targets files in your project's src/workflows directory. It reports a step invoked more than once in a workflow's constructor when the duplicates aren't renamed.

The following code is reported by the rule:

src/workflows/example.ts
1import {2  createWorkflow,3  WorkflowResponse,4} from "@medusajs/framework/workflows-sdk"5
6createWorkflow("hello", () => {7  const products = useQueryGraphStep({8    // ...9  })10  const customers = useQueryGraphStep({11    // ...12  })13
14  return new WorkflowResponse({ products, customers })15})

Instead, rename the subsequent calls with .config({ name }):

src/workflows/example.ts
1import {2  createWorkflow,3  WorkflowResponse,4} from "@medusajs/framework/workflows-sdk"5
6createWorkflow("hello", () => {7  const products = useQueryGraphStep({8    // ...9  })10  const customers = useQueryGraphStep({11    // ...12  }).config({13    name: "fetch-customers",14  })15
16  return new WorkflowResponse({ products, customers })17})

Why it's Important#

Steps registered with the same ID throw an error at runtime. Giving each step a unique ID ensures the workflow runs correctly.

Learn more in the Multiple Step Usages in Workflows documentation.

Fixable#

This rule is auto-fixable. Run the linter with the --fix option to apply the fix automatically.

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵