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 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added allow-empty-catch option to no-empty (#2886)
- Loading branch information
Showing
5 changed files
with
102 additions
and
7 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
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
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,5 @@ | ||
{ | ||
"rules": { | ||
"no-empty": [true, "allow-empty-catch"] | ||
} | ||
} |
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,70 @@ | ||
if (x === 1) {} | ||
~~ [block is empty] | ||
if (x === 2) { | ||
~ | ||
|
||
~nil | ||
|
||
~nil | ||
} | ||
~ [block is empty] | ||
|
||
function testFunction() { | ||
~ | ||
|
||
~nil | ||
} | ||
~ [block is empty] | ||
|
||
for (var x = 0; x < 1; ++x) { } | ||
~~~ [block is empty] | ||
|
||
// empty blocks with comments should be legal | ||
for (var y = 0; y < 1; ++y) { | ||
// empty here | ||
} | ||
{ // empty block allowed | ||
} | ||
{ | ||
/* this block is also empty, but allowed to be */ | ||
} | ||
|
||
class testClass { | ||
constructor(private allowed: any, private alsoAllowed: any) { | ||
} | ||
} | ||
|
||
class testClass2 { | ||
constructor(protected allowed: any) { | ||
} | ||
} | ||
|
||
class testClass3 { | ||
constructor(notAllowed: any) { | ||
~ | ||
} | ||
~~~~~ [block is empty] | ||
} | ||
|
||
class testClass4 { | ||
constructor(readonly allowed: any) { | ||
} | ||
} | ||
|
||
class PrivateClassConstructor { | ||
private constructor() {} | ||
} | ||
|
||
class ProtectedClassConstructor { | ||
protected constructor() {} | ||
} | ||
|
||
class PublicClassConstructor { | ||
public constructor() {} | ||
~~ [block is empty] | ||
} | ||
|
||
try { | ||
throw new Error(); | ||
} catch (error) {} | ||
~~ [block is empty] |
File renamed without changes.