Skip to content

Commit 643a223

Browse files
gavinbarronbradzacher
authored andcommitted
fix(eslint-plugin): explicit-function-return-type: ensure class arrow methods are validated (typescript-eslint#377)
Fixes typescript-eslint#348
1 parent 6f5c0fa commit 643a223

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/eslint-plugin/src/rules/explicit-function-return-type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export default util.createRule<Options, MessageIds>({
114114
): void {
115115
if (
116116
options.allowExpressions &&
117+
node.type !== AST_NODE_TYPES.ArrowFunctionExpression &&
117118
node.parent &&
118119
node.parent.type !== AST_NODE_TYPES.VariableDeclarator &&
119120
node.parent.type !== AST_NODE_TYPES.MethodDefinition

packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Test {
4141
method(): void {
4242
return;
4343
}
44+
arrow = (): string => 'arrow';
4445
}
4546
`,
4647
},
@@ -171,6 +172,7 @@ class Test {
171172
method() {
172173
return;
173174
}
175+
arrow = () => 'arrow';
174176
}
175177
`,
176178
errors: [
@@ -184,6 +186,11 @@ class Test {
184186
line: 8,
185187
column: 9,
186188
},
189+
{
190+
messageId: 'missingReturnType',
191+
line: 11,
192+
column: 11,
193+
},
187194
],
188195
},
189196
{

0 commit comments

Comments
 (0)
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