-
-
Notifications
You must be signed in to change notification settings - Fork 880
Closed
Copy link
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
1.36.0
What command did you run?
oxlint -c .oxlintrc.json
What does your .oxlintrc.json config file look like?
What happened?
The eslint(no-useless-constructor) rule does not correctly detect how the arguments are being processed.
For example, when implementing a ClassDecorator where the constructor arguments are being modified, oxlint --fix will remove the constructor implementation entirely.
Example
In the following example @UseMetrics() decorator is modifying the constructor arguments but is incorrectly being identified as a useless constructor:
× eslint(no-useless-constructor): Redundant super call in constructor
╭─[src/use-metrics.decorator.ts:25:11]
24 │ class extends target {
25 │ constructor(...args: any[]) {
· ─────┬─────
· ╰── This constructor is unnecessary,
26 │ super(...args.map((v, idx) => (idx === metricsIndex && isMetrics(v) ? v.child(name) : v)));
· ─────────────────────────────────────────────┬────────────────────────────────────────────
· ╰── because it only passes arguments through to the superclass
27 │ }
╰────
help: Subclasses automatically use the constructor of their superclass, making this redundant.
Remove this constructor or add code to it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
{ "$schema": "./node_modules/oxlint/configuration_schema.json", "plugins": [ "typescript" ], "categories": { "correctness": "off" }, "rules": { "no-useless-constructor": "error" } }