Skip to content

linter: eslint(no-useless-constructor) does not recognise argument processing #17469

@JoshVee

Description

@JoshVee

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?

{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": [
    "typescript"
  ],
  "categories": {
    "correctness": "off"
  },
  "rules": {
    "no-useless-constructor": "error"
  }
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions