From a53f8c6ff37aa47b3fc1b729e359d81ea079ff75 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Fri, 21 Aug 2020 23:15:59 +0300 Subject: [PATCH] fix(eslint-plugin): [explicit-module-boundary-types] ignore all bodyless setters (#2413) --- .../src/rules/explicit-module-boundary-types.ts | 7 ++++--- .../tests/rules/explicit-module-boundary-types.test.ts | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index fc2dd4e63c4..5671e36dbdd 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -427,10 +427,11 @@ export default util.createRule({ const isConstructor = node.parent?.type === AST_NODE_TYPES.MethodDefinition && node.parent.kind === 'constructor'; - const isAbstractSetAccessor = - node.parent?.type === AST_NODE_TYPES.TSAbstractMethodDefinition && + const isSetAccessor = + (node.parent?.type === AST_NODE_TYPES.TSAbstractMethodDefinition || + node.parent?.type === AST_NODE_TYPES.MethodDefinition) && node.parent.kind === 'set'; - if (!isConstructor && !isAbstractSetAccessor && !node.returnType) { + if (!isConstructor && !isSetAccessor && !node.returnType) { context.report({ node, messageId: 'missingReturnType', diff --git a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts index 32ae93592b4..c79cc34a314 100644 --- a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts @@ -649,6 +649,11 @@ export const buz: Buz = () => n => String(n); ` export abstract class Foo { abstract set value(element: T); +} + `, + ` +export declare class Foo { + set time(seconds: number); } `, ],