From ae30a5e7426ad88ea69c544856c4727bd10a08df Mon Sep 17 00:00:00 2001 From: Scott O'Hara Date: Thu, 8 Aug 2019 15:54:49 +1000 Subject: [PATCH 1/2] fix(eslint-plugin): [promise-function-async] Allow async function getter/setter --- packages/eslint-plugin/src/rules/promise-function-async.ts | 4 ++++ .../tests/rules/promise-function-async.test.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/eslint-plugin/src/rules/promise-function-async.ts b/packages/eslint-plugin/src/rules/promise-function-async.ts index 48d63cf0f54..4a1ffc47161 100644 --- a/packages/eslint-plugin/src/rules/promise-function-async.ts +++ b/packages/eslint-plugin/src/rules/promise-function-async.ts @@ -102,6 +102,10 @@ export default util.createRule({ return; } + if (node.parent && node.parent.type === 'Property') { + return; + } + context.report({ messageId: 'missingAsync', node, diff --git a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts index 829bb9a091c..ed798ca18e2 100644 --- a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts +++ b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts @@ -63,6 +63,12 @@ const invalidAsyncModifiers = { }, set asyncGetter(p: Promise) { return p; + }, + get asyncGetterFunc() { + return async () => new Promise(); + }, + set asyncGetterFunc(p: () => Promise) { + return p; } } `, From 4985605f62e77b027f513d5cb050148a36b7f344 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 23 Aug 2019 08:14:55 -0700 Subject: [PATCH 2/2] fix: tighten check --- packages/eslint-plugin/src/rules/promise-function-async.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/promise-function-async.ts b/packages/eslint-plugin/src/rules/promise-function-async.ts index 4a1ffc47161..7426e31356a 100644 --- a/packages/eslint-plugin/src/rules/promise-function-async.ts +++ b/packages/eslint-plugin/src/rules/promise-function-async.ts @@ -102,7 +102,11 @@ export default util.createRule({ return; } - if (node.parent && node.parent.type === 'Property') { + if ( + node.parent && + node.parent.type === 'Property' && + (node.parent.kind === 'get' || node.parent.kind === 'set') + ) { return; }