noDuplicateClassMembers
このコンテンツはまだ日本語訳がありません。
Diagnostic Category: lint/suspicious/noDuplicateClassMembers
Since: v1.0.0
Sources:
- Same as:
no-dupe-class-members
- Same as:
@typescript-eslint/no-dupe-class-members
Disallow duplicate class members.
If there are declarations of the same name among class members, the last declaration overwrites other declarations silently. It can cause unexpected behaviours.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:3:3 lint/suspicious/noDuplicateClassMembers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Duplicate class member name “bar”
1 │ class Foo {
2 │ bar() { }
> 3 │ bar() { }
│ ^^^^^^^^^
4 │ }
5 │
code-block.js:3:3 lint/suspicious/noDuplicateClassMembers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Duplicate class member name “bar”
1 │ class Foo {
2 │ bar() { }
> 3 │ get bar() { }
│ ^^^^^^^^^^^^^
4 │ }
5 │
code-block.js:3:3 lint/suspicious/noDuplicateClassMembers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Duplicate class member name “bar”
1 │ class Foo {
2 │ bar;
> 3 │ bar() { }
│ ^^^^^^^^^
4 │ }
5 │
code-block.js:3:3 lint/suspicious/noDuplicateClassMembers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Duplicate class member name “bar”
1 │ class Foo {
2 │ static bar() { }
> 3 │ static bar() { }
│ ^^^^^^^^^^^^^^^^
4 │ }
5 │