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:
Jason Quense 2016-01-21 20:20:23 -05:00
parent d58dc7bd1d
commit 7a2ecd2516
2 changed files with 6 additions and 3 deletions

View File

@ -24,7 +24,9 @@ module.exports = function(context) {
if (node.async) token = context.getTokenAfter(token); if (node.async) token = context.getTokenAfter(token);
// as-needed: x => x // 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 === "(") { if (token.type === "Punctuator" && token.value === "(") {
context.report(node, asNeededMessage); context.report(node, asNeededMessage);
} }

View File

@ -46,6 +46,7 @@ var valid = [
{ code: "(a = 10) => {}", options: ["as-needed"], ecmaFeatures: { arrowFunctions: true, destructuring: true, defaultParams: true } }, { 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) => a[0]", options: ["as-needed"], ecmaFeatures: { arrowFunctions: true, restParams: true } },
{ code: "(a, b) => {}", options: ["as-needed"], ecmaFeatures: { arrowFunctions: true } }, { code: "(a, b) => {}", options: ["as-needed"], ecmaFeatures: { arrowFunctions: true } },
ok("(a: string) => a", ["as-needed"]),
// async // async
ok("async () => {}"), ok("async () => {}"),