From e32bef6f6b74228c95e54a5cba1cde53d5e40623 Mon Sep 17 00:00:00 2001 From: Taeheon Kim Date: Sun, 13 Feb 2022 02:57:16 +0900 Subject: [PATCH] feat: add checking property definition for allowNames option (#4542) --- .../src/rules/explicit-module-boundary-types.ts | 3 ++- .../rules/explicit-module-boundary-types.test.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 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 30509bb660e..3f9f50086cc 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -232,7 +232,8 @@ export default util.createRule({ } else if ( 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.Property && node.method) || + node.type === AST_NODE_TYPES.PropertyDefinition ) { if ( node.key.type === AST_NODE_TYPES.Literal && 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 e511e29d682..fbed6829fef 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 @@ -390,11 +390,15 @@ export class Test { ['prop']() {} [\`prop\`]() {} [\`\${v}\`](): void {} + + foo = () => { + bar: 5; + }; } `, options: [ { - allowedNames: ['prop', 'method'], + allowedNames: ['prop', 'method', 'foo'], }, ], }, @@ -1187,6 +1191,7 @@ export class Test { return; } arrow = (): string => 'arrow'; + foo = () => 'bar'; } `, options: [ @@ -1202,6 +1207,13 @@ export class Test { column: 3, endColumn: 11, }, + { + messageId: 'missingReturnType', + line: 12, + endLine: 12, + column: 9, + endColumn: 14, + }, ], }, {