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 886
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] Introduce new typedef rule option (variable-declara…
…tion-ignore-function) (#4769) * Introduce new typedef rule option (variable-declaration-ignore-function) Ignores typedef requirement for vars for arrow and non arrow functions. Fixes: #2654 * Fix linting issues * Include ignore typedef for member var declaration * Fix linter issue * Process PR comments, remove comments from test + add test cases
- Loading branch information
1 parent
8056e63
commit 1d5d624
Showing
3 changed files
with
79 additions
and
13 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
23 changes: 23 additions & 0 deletions
23
test/rules/typedef/variable-declaration-ignore-function/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,23 @@ | ||
var foo = function(): void {}; | ||
let foo = function(): void {}; | ||
const foo = function(): void {}; | ||
|
||
var foo = (): void => {}; | ||
let foo = (): void => {}; | ||
const foo = (): void => {}; | ||
|
||
class Foo { | ||
foo = (): void => {}; | ||
foo = function(): void {}; | ||
} | ||
|
||
const foo: () => void = (): void => {}; | ||
const foo: () => void = function(): void {}; | ||
|
||
var noTypeDef = 'Should still fail'; | ||
~~~~~~~~~ [expected variable-declaration: 'noTypeDef' to have a typedef] | ||
|
||
class NoTypeDef { | ||
public noTypeDef = 'Should still fail'; | ||
~~~~~~~~~ [expected member-variable-declaration: 'noTypeDef' to have a typedef] | ||
} |
10 changes: 10 additions & 0 deletions
10
test/rules/typedef/variable-declaration-ignore-function/tslint.json
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,10 @@ | ||
{ | ||
"rules": { | ||
"typedef": [ | ||
true, | ||
"variable-declaration", | ||
"member-variable-declaration", | ||
"variable-declaration-ignore-function" | ||
] | ||
} | ||
} |