-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add no-mixed rule * Update the correct README * Remove unused var
- Loading branch information
Showing
7 changed files
with
98 additions
and
0 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,8 @@ | ||
### `no-mixed` | ||
|
||
Warns against "mixed" type annotations. | ||
These types are not strict enough and could often be made more specific. | ||
|
||
The following patterns are considered problems: | ||
|
||
<!-- assertions noMixed --> |
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,17 @@ | ||
const schema = []; | ||
|
||
const create = (context) => { | ||
return { | ||
MixedTypeAnnotation (node) { | ||
context.report({ | ||
message: 'Unexpected use of mixed type', | ||
node | ||
}); | ||
} | ||
}; | ||
}; | ||
|
||
export default { | ||
create, | ||
schema | ||
}; |
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,66 @@ | ||
export default { | ||
invalid: [ | ||
{ | ||
code: 'function foo(thing): mixed {}', | ||
errors: [{ | ||
message: 'Unexpected use of mixed type' | ||
}] | ||
}, | ||
{ | ||
code: 'function foo(thing): Promise<mixed> {}', | ||
errors: [{ | ||
message: 'Unexpected use of mixed type' | ||
}] | ||
}, | ||
{ | ||
code: 'function foo(thing): Promise<Promise<mixed>> {}', | ||
errors: [{ | ||
message: 'Unexpected use of mixed type' | ||
}] | ||
} | ||
], | ||
valid: [ | ||
{ | ||
code: 'function foo(thing): string {}' | ||
}, | ||
{ | ||
code: 'function foo(thing): Promise<string> {}' | ||
}, | ||
{ | ||
code: 'function foo(thing): Promise<Promise<string>> {}' | ||
}, | ||
{ | ||
code: '(foo?: string) => {}' | ||
}, | ||
{ | ||
code: '(foo: ?string) => {}' | ||
}, | ||
{ | ||
code: '(foo: { a: string }) => {}' | ||
}, | ||
{ | ||
code: '(foo: { a: ?string }) => {}' | ||
}, | ||
{ | ||
code: '(foo: string[]) => {}' | ||
}, | ||
{ | ||
code: 'type Foo = string' | ||
}, | ||
{ | ||
code: 'type Foo = { a: string }' | ||
}, | ||
{ | ||
code: 'type Foo = { (a: string): string }' | ||
}, | ||
{ | ||
code: 'function foo(thing: string) {}' | ||
}, | ||
{ | ||
code: 'var foo: string' | ||
}, | ||
{ | ||
code: 'class Foo { props: string }' | ||
} | ||
] | ||
}; |
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