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 eaa7b8baf0b4..c8a627e7aca5 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -270,7 +270,8 @@ export default createRule({ node.type === AST_NODE_TYPES.MethodDefinition || node.type === AST_NODE_TYPES.TSAbstractMethodDefinition || (node.type === AST_NODE_TYPES.Property && node.method) || - node.type === AST_NODE_TYPES.PropertyDefinition + node.type === AST_NODE_TYPES.PropertyDefinition || + node.type === AST_NODE_TYPES.AccessorProperty ) { return isStaticMemberAccessOfValue( node, @@ -369,6 +370,7 @@ export default createRule({ return; case AST_NODE_TYPES.PropertyDefinition: + case AST_NODE_TYPES.AccessorProperty: case AST_NODE_TYPES.MethodDefinition: case AST_NODE_TYPES.TSAbstractMethodDefinition: if ( diff --git a/packages/eslint-plugin/src/util/misc.ts b/packages/eslint-plugin/src/util/misc.ts index 6313740bf0d0..b24758fd426a 100644 --- a/packages/eslint-plugin/src/util/misc.ts +++ b/packages/eslint-plugin/src/util/misc.ts @@ -239,6 +239,7 @@ export function isParenlessArrowFunction( } export type NodeWithKey = + | TSESTree.AccessorProperty | TSESTree.MemberExpression | TSESTree.MethodDefinition | TSESTree.Property 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 45deb7d1124f..1bd477f206ce 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 @@ -601,6 +601,15 @@ export default { Foo }; }, { code: ` +export class Foo { + accessor bar = (): void => { + return; + }; +} + `, + }, + { + code: ` export function foo(): (n: number) => string { return n => String(n); } @@ -1670,6 +1679,52 @@ class Foo { return arg; }; } +export default Foo; + `, + errors: [ + { + line: 3, + messageId: 'missingReturnType', + }, + { + data: { + name: 'arg', + }, + line: 3, + messageId: 'missingArgType', + }, + ], + }, + { + code: ` +class Foo { + accessor bool = arg => { + return arg; + }; +} +export default Foo; + `, + errors: [ + { + data: { + name: 'arg', + }, + line: 3, + messageId: 'missingArgType', + }, + { + line: 3, + messageId: 'missingReturnType', + }, + ], + }, + { + code: ` +class Foo { + accessor bool = function (arg) { + return arg; + }; +} export default Foo; `, errors: [