service-constructor-must-call-super - ESLint plugin rules

This rule requires that a service extending MedusaService(...) with a constructor calls super(...arguments).

Severity#

error. This rule is enabled in the recommended preset.

What it Targets#

This rule targets service files in your project's src/modules directory. It reports a constructor on a class that extends MedusaService(...) when the constructor doesn't call super(...arguments).

The following code is reported by the rule:

src/modules/blog/service.ts
1import { MedusaService } from "@medusajs/framework/utils"2
3class BlogModuleService extends MedusaService({}) {4  constructor() {}5}

Instead, call super(...arguments) in the constructor:

src/modules/blog/service.ts
1import { MedusaService } from "@medusajs/framework/utils"2
3class BlogModuleService extends MedusaService({}) {4  constructor() {5    super(...arguments)6  }7}

Why it's Important#

The MedusaService factory sets up the service's data-management methods and dependencies in its constructor. If you don't call super(...arguments), that setup never runs and the service fails at runtime.

Learn more in the Service Factory 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
⇧↵