From bdae116442c937bcda63c5adc43cc437bb0d566d Mon Sep 17 00:00:00 2001 From: William Swanson Date: Thu, 15 Aug 2019 14:04:46 -0700 Subject: [PATCH] fix: loosen explicit-function-return-type This fixes #110. --- src/fixture.ts | 10 ++++++++++ src/index.test.ts | 4 +++- src/index.ts | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/fixture.ts b/src/fixture.ts index 2f8bb24a..7e60ccf4 100644 --- a/src/fixture.ts +++ b/src/fixture.ts @@ -24,3 +24,13 @@ export interface Boo { b_oo: null } * ESLint should ignore this `no-undef` violation because that rule is turned off for TypeScript. */ // console.log(undef) + +/** + * https://github.com/standard/eslint-config-standard-with-typescript/issues/110 + */ +// Inline callbacks don't need return types: +setTimeout(() => {}, 1) + +// The return type is clear from the left side of the assignment: +const double: ((n: number) => number) = n => n * 2 +;[1, 2].map(double) diff --git a/src/index.test.ts b/src/index.test.ts index 28c6d26d..5b643763 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -21,7 +21,9 @@ test('export', (t): void => { '@typescript-eslint/array-type': ['error', 'array-simple'], '@typescript-eslint/camelcase': ['error', { properties: 'never' }], '@typescript-eslint/explicit-function-return-type': ['error', { - allowHigherOrderFunctions: true + allowExpressions: true, + allowHigherOrderFunctions: true, + allowTypedFunctionExpressions: true }], '@typescript-eslint/indent': ['error', 2, { SwitchCase: 1, diff --git a/src/index.ts b/src/index.ts index aae2d2b0..e89846aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,7 +42,9 @@ export = { '@typescript-eslint/adjacent-overload-signatures': 'error', '@typescript-eslint/array-type': ['error', 'array-simple'], '@typescript-eslint/explicit-function-return-type': ['error', { - allowHigherOrderFunctions: true + allowExpressions: true, + allowHigherOrderFunctions: true, + allowTypedFunctionExpressions: true }], '@typescript-eslint/member-delimiter-style': [ 'error',