Merge pull request babel/eslint-plugin-babel#44 from ssorallen/arrow-type-annotations
Add type annotations to arrow-parens "as-needed"
This commit is contained in:
parent
d58dc7bd1d
commit
7a2ecd2516
@ -24,7 +24,9 @@ module.exports = function(context) {
|
||||
if (node.async) token = context.getTokenAfter(token);
|
||||
|
||||
// as-needed: x => x
|
||||
if (asNeeded && node.params.length === 1 && node.params[0].type === "Identifier") {
|
||||
if (asNeeded && node.params.length === 1
|
||||
&& node.params[0].type === "Identifier"
|
||||
&& node.params[0].typeAnnotation === undefined) {
|
||||
if (token.type === "Punctuator" && token.value === "(") {
|
||||
context.report(node, asNeededMessage);
|
||||
}
|
||||
@ -50,4 +52,4 @@ module.exports.schema = [
|
||||
{
|
||||
"enum": ["always", "as-needed"]
|
||||
}
|
||||
];
|
||||
];
|
||||
|
||||
@ -46,6 +46,7 @@ var valid = [
|
||||
{ code: "(a = 10) => {}", options: ["as-needed"], ecmaFeatures: { arrowFunctions: true, destructuring: true, defaultParams: true } },
|
||||
{ code: "(...a) => a[0]", options: ["as-needed"], ecmaFeatures: { arrowFunctions: true, restParams: true } },
|
||||
{ code: "(a, b) => {}", options: ["as-needed"], ecmaFeatures: { arrowFunctions: true } },
|
||||
ok("(a: string) => a", ["as-needed"]),
|
||||
|
||||
// async
|
||||
ok("async () => {}"),
|
||||
@ -174,4 +175,4 @@ var invalid = [
|
||||
ruleTester.run("arrow-parens", rule, {
|
||||
valid: valid,
|
||||
invalid: invalid
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user