classMemberDuplicates
Reports duplicate class member names that will be overwritten.
✅ This rule is included in the ts untyped preset.
Duplicate class members are legal in JavaScript, but only the last definition is used. This can lead to confusion and bugs, especially when maintaining the code.
Examples
Section titled “Examples”class Foo { bar() {} bar() {}}class Foo { get bar() { return 1; } get bar() { return 2; }}class Foo { bar = 1; bar = 2;}class Foo { bar() {} baz() {}}class Foo { get bar() { return 1; } set bar(value) {}}class Foo { bar() {} static bar() {}}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”This rule should generally always be enabled. There is no valid use case for duplicate class member names.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.