eslint/no-constructor-return Pedantic
What it does
Disallow returning value from constructor
Why is this bad?
In JavaScript, returning a value in the constructor of a class may be a mistake. Forbidding this pattern prevents mistakes resulting from unfamiliarity with the language or a copy-paste error.
Example
Examples of incorrect code for this rule:
rust
class C {
constructor() { return 42; }
}
Examples of correct code for this rule:
rust
class C {
constructor() { this.value = 42; }
}
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny no-constructor-return
json
{
"rules": {
"no-constructor-return": "error"
}
}