forked from palantir/tslint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added allow-generics option to invalid-void rule (palantir#4839)
- Loading branch information
Showing
9 changed files
with
177 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
type Generic<T> = [T]; | ||
type GenericVoid = Generic<void>; | ||
~~~~ [0] | ||
|
||
function takeVoid(thing: void) { } | ||
~~~~ [0] | ||
|
||
let voidPromise: Promise<void> = new Promise<void>(() => {}); | ||
~~~~ [0] | ||
~~~~ [0] | ||
|
||
let voidMap: Map<string, void> = new Map<string, void>(); | ||
~~~~ [0] | ||
~~~~ [0] | ||
|
||
[0]: void is only valid as a return type |
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,7 @@ | ||
{ | ||
"rules": { | ||
"invalid-void": [true, { | ||
"allow-generics": false | ||
}] | ||
} | ||
} |
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,11 @@ | ||
type Generic<T> = [T]; | ||
type GenericVoid = Generic<void>; | ||
|
||
function takeVoid(thing: void) { } | ||
~~~~ [0] | ||
|
||
let voidPromise: Promise<void> = new Promise<void>(() => {}); | ||
|
||
let voidMap: Map<string, void> = new Map<string, void>(); | ||
|
||
[0]: void is only valid as a return type or generic type variable |
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,7 @@ | ||
{ | ||
"rules": { | ||
"invalid-void": [true, { | ||
"allow-generics": true | ||
}] | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/rules/invalid-void/allow-generics/whitelist/test.ts.lint
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,12 @@ | ||
type Allowed<T> = [T]; | ||
type AllowedVoid = Allowed<void>; | ||
|
||
type Banned<T> = [T]; | ||
type BannedVoid = Banned<void>; | ||
~~~~ [Generic % ('Banned')] | ||
|
||
function takeVoid(thing: void) { } | ||
~~~~ [0] | ||
|
||
[0]: void is only valid as a return type or generic type variable | ||
[Generic]: %s may not have void as a type variable |
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,7 @@ | ||
{ | ||
"rules": { | ||
"invalid-void": [true, { | ||
"allow-generics": ["Allowed"] | ||
}] | ||
} | ||
} |
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
File renamed without changes.