-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/lints): add
no-dupe-class-members
rule
- Loading branch information
1 parent
de09c55
commit b9315a6
Showing
9 changed files
with
762 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
crates/swc/tests/errors/lints/no-dupe-class-members/es6/.swcrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"jsc": { | ||
"target": "EsNext", | ||
"lints": { | ||
"noDupeClassMembers": ["error"] | ||
} | ||
} | ||
} |
202 changes: 202 additions & 0 deletions
202
crates/swc/tests/errors/lints/no-dupe-class-members/es6/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
() => { | ||
class A { | ||
foo() {} | ||
foo() {} | ||
} | ||
}; | ||
|
||
() => { | ||
!class A { foo() {} foo() {} }; | ||
}; | ||
|
||
() => { | ||
class A { 'foo'() {} 'foo'() {} } | ||
}; | ||
|
||
() => { | ||
class A { 10() {} 1e1() {} } | ||
}; | ||
|
||
() => { | ||
class A { ['foo']() {} ['foo']() {} } | ||
}; | ||
|
||
|
||
() => { | ||
class A { static ['foo']() {} static foo() {} } | ||
}; | ||
|
||
|
||
() => { | ||
class A { | ||
set foo(value) {} | ||
set ['foo'](val) {} | ||
} | ||
} | ||
|
||
() => { | ||
class A { ''() {} ['']() {} } | ||
}; | ||
|
||
() => { | ||
class A { [`foo`]() {} [`foo`]() {} } | ||
}; | ||
|
||
() => { | ||
class A { static get [`foo`]() {} static get ['foo']() {} } | ||
} | ||
|
||
() => { | ||
class A { foo() {} [`foo`]() {} } | ||
} | ||
|
||
() => { | ||
class A { get [`foo`]() {} 'foo'() {} } | ||
} | ||
|
||
() => { | ||
class A { static 'foo'() {} static [`foo`]() {} } | ||
} | ||
|
||
() => { | ||
class A { ['constructor']() {} ['constructor']() {} } | ||
} | ||
|
||
() => { | ||
class A { [123]() {} [123]() {} } | ||
} | ||
|
||
() => { | ||
class A { [0x10]() {} 16() {} } | ||
} | ||
|
||
() => { | ||
class A { [123.00]() {} [`123`]() {} } | ||
}; | ||
|
||
() => { | ||
class A { [null]() {} 'null'() {} } | ||
} | ||
|
||
() => { | ||
class A { foo() {} foo() {} foo() {} } | ||
} | ||
|
||
() => { | ||
class A { static foo() {} static foo() {} } | ||
} | ||
|
||
() => { | ||
class A { foo() {} get foo() {} } | ||
} | ||
|
||
() => { | ||
class A { set foo(value) {} foo() {} } | ||
} | ||
|
||
() => { | ||
class A { foo; foo; } | ||
} | ||
|
||
() => { | ||
class A { #priv() {} #priv() {} } | ||
} | ||
|
||
() => { | ||
class A { #priv; #priv() {} } | ||
} | ||
|
||
// Valid | ||
|
||
() => { | ||
class A { foo() {} bar() {} } | ||
} | ||
|
||
() => { | ||
class A { static foo() {} foo() {} } | ||
} | ||
|
||
() => { | ||
class A { get foo() {} set foo(value) {} } | ||
} | ||
|
||
() => { | ||
class A { static foo() {} get foo() {} set foo(value) {} } | ||
} | ||
|
||
() => { | ||
class A { foo() { } } | ||
class B { foo() { } } | ||
} | ||
|
||
() => { | ||
class A { [foo]() {} foo() {} } | ||
} | ||
|
||
() => { | ||
class A { 'foo'() {} 'bar'() {} baz() {} } | ||
} | ||
|
||
() => { | ||
class A { *'foo'() {} *'bar'() {} *baz() {} } | ||
} | ||
|
||
() => { | ||
class A { get 'foo'() {} get 'bar'() {} get baz() {} } | ||
} | ||
|
||
() => { | ||
class A { 1() {} 2() {} } | ||
} | ||
|
||
() => { | ||
class A { ['foo']() {} ['bar']() {} } | ||
} | ||
|
||
() => { | ||
class A { [`foo`]() {} [`bar`]() {} } | ||
} | ||
|
||
() => { | ||
class A { [12]() {} [123]() {} } | ||
} | ||
|
||
() => { | ||
class A { [1.0]() {} ['1.0']() {} } | ||
} | ||
|
||
() => { | ||
class A { [0x1]() {} [`0x1`]() {} } | ||
} | ||
|
||
() => { | ||
class A { [null]() {} ['']() {} } | ||
} | ||
|
||
() => { | ||
class A { get ['foo']() {} set ['foo'](value) {} } | ||
} | ||
|
||
() => { | ||
class A { ['foo']() {} static ['foo']() {} } | ||
} | ||
|
||
() => { | ||
class A { ['constructor']() {} constructor() {} } | ||
} | ||
|
||
() => { | ||
class A { 'constructor'() {} [`constructor`]() {} } | ||
} | ||
|
||
() => { | ||
class A { foo; static foo; } | ||
} | ||
|
||
() => { | ||
class A { foo; #foo; } | ||
} | ||
|
||
() => { | ||
class A { '#foo'; #foo; } | ||
} |
Oops, something went wrong.