Skip to content

Commit

Permalink
feat(es/lints): add no-dupe-class-members rule
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturAralin committed Mar 9, 2024
1 parent de09c55 commit b9315a6
Show file tree
Hide file tree
Showing 9 changed files with 762 additions and 0 deletions.
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 crates/swc/tests/errors/lints/no-dupe-class-members/es6/input.js
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; }
}
Loading

0 comments on commit b9315a6

Please sign in to comment.