1 ---
2 sidebar_label: "service-constructor-must-call-super"
3 ---
4
5 export const metadata = {
6 title: `service-constructor-must-call-super - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires that a service extending `MedusaService(...)` with a constructor calls `super(...arguments)`.
12
13 ## Severity
14
15 `error`. This rule is enabled in the [recommended](../../page.mdx#recommended) preset.
16
17 ## What it Targets
18
19 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)`.
20
21 The following code is reported by the rule:
22
23 ```ts title="src/modules/blog/service.ts"
24 import { MedusaService } from "@medusajs/framework/utils"
25
26 class BlogModuleService extends MedusaService({}) {
27 constructor() {}
28 }
29 ```
30
31 Instead, call `super(...arguments)` in the constructor:
32
33 ```ts title="src/modules/blog/service.ts"
34 import { MedusaService } from "@medusajs/framework/utils"
35
36 class BlogModuleService extends MedusaService({}) {
37 constructor() {
38 super(...arguments)
39 }
40 }
41 ```
42
43 ## Why it's Important
44
45 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.
46
47 Learn more in the [Service Factory documentation](!docs!/learn/fundamentals/modules/service-factory).
48
49 ## Fixable
50
51 This rule is auto-fixable. Run the linter with the `--fix` option to apply the fix automatically.