Skip to content

no-dupe-class-members

Reports a class member whose name is already used by another member of the class: two methods, two fields, a field and a method, two getters. A getter with its setter may share a name, and so may a static and an instance member.

When two members have one name, the later one silently replaces the earlier, so the first body is dead code. It is usually a copy-paste mistake where the second member was meant to have another name.

To fix, rename one of them or delete the one that is not used.

Reported
...
class A { a() {} a() {} static b() {} b() {} get c() { return 1; } set c(v) {} d = 1; d = 2; ["e"]() {} e() {} }
js:
lint:
rules:
no-dupe-class-members: error # off, warn, error (default)

Enabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line no-dupe-class-members in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint no-dupe-class-members full