no-console-log-in-workflow - ESLint plugin rules
This rule disallows console.log and other console.* calls directly inside a createWorkflow constructor or a when().then() callback.
Severity#
warn. This rule is enabled in the recommended preset.
What it Targets#
This rule targets files in your project's src/workflows directory. It reports console.* calls placed directly in a workflow's constructor or in a when().then() callback.
The following code is reported by the rule:
Instead, move logging into a createStep callback:
1import {2 createWorkflow,3 createStep,4 WorkflowResponse,5} from "@medusajs/framework/workflows-sdk"6 7const logStep = createStep("log", (input) => {8 console.log("execution-time")9})10 11createWorkflow("my-workflow", (input) => {12 logStep(input)13 14 return new WorkflowResponse(input)15})
Why it's Important#
A workflow's constructor and callbacks run at definition time, not execution time. So, a call there only logs when the workflow is registered, not on each execution. Move logging into a callback so it runs every time the workflow executes.
Learn more in the Debugging Workflows documentation.
Fixable#
This rule isn't auto-fixable.
Turn it Off#
To turn off this rule, set it to off in your ESLint configuration:
Or disable it for a single line using an inline comment: