www/apps/resources/app/lint/rules/no-workflow-call-without-container/page.mdx
import { Note } from "docs-ui"
export const metadata = {
title: no-workflow-call-without-container - ESLint plugin rules,
}
This rule requires a workflow to be invoked with the Medusa container, as in workflow(container).run({ input }).
warn. 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.
This rule targets workflow execution calls anywhere in your project. It reports invoking a workflow with no arguments or accessing its .run method directly, without passing the container.
The following code is reported by the rule:
import { myWorkflow } from "../../../workflows/my-workflow"
async function handler() {
await myWorkflow().run({ input: {} })
}
Instead, pass the container when invoking the workflow:
import { myWorkflow } from "../../../workflows/my-workflow"
async function handler(container) {
await myWorkflow(container).run({ input: {} })
}
A workflow resolves its steps' dependencies from the Medusa container. Invoking the workflow without the container, or calling .run directly, bypasses container resolution and the workflow fails to execute correctly.
Learn more in the Workflows documentation.
This rule isn't auto-fixable.
To turn off this rule, set it to off in your ESLint configuration:
import { defineConfig } from "eslint/config"
import medusa from "@medusajs/eslint-plugin"
export default defineConfig([
...medusa.configs.strict,
{
rules: {
"@medusajs/no-workflow-call-without-container": "off",
},
},
])
Or disable it for a single line using an inline comment:
// eslint-disable-next-line @medusajs/no-workflow-call-without-container
await myWorkflow().run({ input: {} })