From f180528f066a78fa1ddf3a33cb59c9cfc184ba8c Mon Sep 17 00:00:00 2001 From: lonyele Date: Sat, 12 Feb 2022 19:19:02 +0900 Subject: [PATCH] feat: add checking property definition for allowNames option --- .../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 30509bb660ed..3f9f50086ccf 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 e511e29d682b..fbed6829fefc 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, + }, ], }, { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy