This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[new-rule-option] check-super-calls option for unnecessary-constructo…
…r rule (#4813)
- Loading branch information
1 parent
7659cd9
commit b6c8b0c
Showing
8 changed files
with
678 additions
and
78 deletions.
There are no files selected for viewing
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
147 changes: 147 additions & 0 deletions
147
test/rules/unnecessary-constructor/check-super-calls/test.ts.fix
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,147 @@ | ||
export class ExportedClass { | ||
} | ||
|
||
class PublicConstructor { | ||
} | ||
|
||
class ProtectedConstructor { | ||
protected constructor() { } | ||
} | ||
|
||
class PrivateConstructor { | ||
private constructor() { } | ||
} | ||
|
||
class SameLine { } | ||
|
||
class WithPrecedingMember { | ||
public member: string; | ||
} | ||
|
||
class WithFollowingMethod { | ||
public method() {} | ||
} | ||
|
||
const classExpression = class { | ||
} | ||
|
||
class ContainsContents { | ||
constructor() { | ||
console.log("Hello!"); | ||
} | ||
} | ||
|
||
class CallsSuper extends PublicConstructor { | ||
} | ||
|
||
class ContainsParameter { | ||
} | ||
|
||
class PrivateContainsParameter { | ||
private constructor(x: number) { } | ||
} | ||
|
||
class ProtectedContainsParameter { | ||
protected constructor(x: number) { } | ||
} | ||
|
||
class ContainsParameterDeclaration { | ||
constructor(public x: number) { } | ||
} | ||
|
||
class ContainsParameterAndParameterDeclaration { | ||
constructor(x: number, public y: number) { } | ||
} | ||
|
||
class ConstructorOverload { | ||
} | ||
|
||
interface IConstructorSignature { | ||
new(): {}; | ||
} | ||
|
||
class DecoratedParameters { | ||
constructor(@Optional x: number) {} | ||
} | ||
|
||
class X { | ||
constructor(private param1: number, param2: number) {} | ||
} | ||
|
||
export class Y extends X { | ||
constructor(param1: number) { | ||
super(param1, 2); | ||
} | ||
} | ||
|
||
class Base { | ||
constructor(public param: number) {} | ||
} | ||
|
||
class Super extends Base { | ||
public param: number; | ||
constructor(param1: number) { | ||
super(param1); | ||
this.param = param1; | ||
} | ||
} | ||
|
||
class Super extends Base { | ||
} | ||
|
||
class Super extends Base { | ||
constructor(param1: number, public param2: number) { | ||
super(param1); | ||
} | ||
} | ||
|
||
class Super extends Base { | ||
} | ||
|
||
class Super extends Base { | ||
constructor(param1: number) { | ||
super(param1 + 1); | ||
} | ||
} | ||
|
||
class Super extends Base { | ||
constructor() { | ||
super(1); | ||
} | ||
} | ||
|
||
class Super extends Base { | ||
constructor(param1: number) { | ||
super(1); | ||
} | ||
} | ||
|
||
const test = (param: number) => number; | ||
|
||
class Super extends Base { | ||
constructor(param1: number) { | ||
super(test(param1)); | ||
} | ||
} | ||
|
||
class Base2 { | ||
constructor(public param1: number, param2: number) {} | ||
} | ||
|
||
class Super extends Base2 { | ||
constructor(param1: number, param2: number) { | ||
super(test(param2), param1); | ||
} | ||
} | ||
|
||
class Super extends Base2 { | ||
} | ||
|
||
class Super extends Base { | ||
public param1: number; | ||
constructor(public param2: number) { | ||
super(param2); | ||
this.param1 = param2; | ||
} | ||
} | ||
|
Oops, something went wrong.