Skip to content

eslint/no-dupe-class-members Correctness ​

✅ This rule is turned on by default.

What it does ​

Disallow duplicate class members

Why is this bad? ​

If there are declarations of the same name in class members, the last declaration overwrites other declarations silently. It can cause unexpected behaviors.

Example ​

javascript
class A {
  foo() {
    console.log("foo");
  }
  foo = 123;
}
let a = new A();
a.foo(); // Uncaught TypeError: a.foo is not a function

How to use ​

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-dupe-class-members
json
{
  "rules": {
    "no-dupe-class-members": "error"
  }
}

References ​

Released under the MIT License.