From cf7010b6da2515045ce23d35e2bf17f4aefa3647 Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 1 Feb 2019 01:38:41 +0100 Subject: [PATCH 1/2] test(eslint-plugin): add test case for eslint arrow-parens --- .../tests/lib/eslint-rules/arrow-parens.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js diff --git a/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js b/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js new file mode 100644 index 000000000000..8e5b96808afc --- /dev/null +++ b/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js @@ -0,0 +1,44 @@ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require('eslint/lib/rules/arrow-parens'), + RuleTester = require('eslint').RuleTester; + +const ruleTester = new RuleTester({ + parser: '@typescript-eslint/parser' +}); + +ruleTester.run('arrow-parens', rule, { + valid: [ + // https://github.com/typescript-eslint/typescript-eslint/issues/14 + 'const foo = (t) => {};', + 'const foo = (t) => {};', + 'const foo = (t: T) => {};', + 'const foo = ((t: T) => {});', + 'const foo = function (t: T) {};', + { + code: 'const foo = t => {};', + options: ["as-needed"] + }, + { + code: 'const foo = (t) => {};', + options: ["as-needed"] + }, + { + code: 'const foo = (t: T) => {};', + options: ["as-needed"] + }, + { + code: 'const foo = (t: T) => {};', + options: ["as-needed"] + }, + { + code: 'const foo = (t: T) => ({});', + options: ["as-needed", { requireForBlockBody: true }] + } + ], + invalid: [] +}); From e0ba177c2b36cf9e5cf72e5d67f1ccdcbe7e5de2 Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 1 Feb 2019 01:42:12 +0100 Subject: [PATCH 2/2] test(eslint-plugin): fix linting issue --- .../tests/lib/eslint-rules/arrow-parens.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js b/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js index 8e5b96808afc..e8a77ca2013d 100644 --- a/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js +++ b/packages/eslint-plugin/tests/lib/eslint-rules/arrow-parens.js @@ -21,23 +21,23 @@ ruleTester.run('arrow-parens', rule, { 'const foo = function (t: T) {};', { code: 'const foo = t => {};', - options: ["as-needed"] + options: ['as-needed'] }, { code: 'const foo = (t) => {};', - options: ["as-needed"] + options: ['as-needed'] }, { code: 'const foo = (t: T) => {};', - options: ["as-needed"] + options: ['as-needed'] }, { code: 'const foo = (t: T) => {};', - options: ["as-needed"] + options: ['as-needed'] }, { code: 'const foo = (t: T) => ({});', - options: ["as-needed", { requireForBlockBody: true }] + options: ['as-needed', { requireForBlockBody: true }] } ], invalid: []