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); } `, ],