diff --git a/eslint/babel-eslint-plugin/rules/arrow-parens.js b/eslint/babel-eslint-plugin/rules/arrow-parens.js index b3ee3a7652..8e7c9456be 100644 --- a/eslint/babel-eslint-plugin/rules/arrow-parens.js +++ b/eslint/babel-eslint-plugin/rules/arrow-parens.js @@ -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"] } -]; \ No newline at end of file +]; diff --git a/eslint/babel-eslint-plugin/tests/arrow-parens.js b/eslint/babel-eslint-plugin/tests/arrow-parens.js index 74a03f62c5..3616fa7022 100644 --- a/eslint/babel-eslint-plugin/tests/arrow-parens.js +++ b/eslint/babel-eslint-plugin/tests/arrow-parens.js @@ -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 -}); \ No newline at end of file +});