Skip to content

Commit

Permalink
fix(eslint-plugin): [efrt] allowExpressions - check functions in clas…
Browse files Browse the repository at this point in the history
…s field properties (#952)
  • Loading branch information
a-tarasyuk authored and bradzacher committed Sep 7, 2019
1 parent e011e90 commit f1059d8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
Expand Up @@ -335,7 +335,8 @@ export default util.createRule<Options, MessageIds>({
options.allowExpressions &&
node.parent.type !== AST_NODE_TYPES.VariableDeclarator &&
node.parent.type !== AST_NODE_TYPES.MethodDefinition &&
node.parent.type !== AST_NODE_TYPES.ExportDefaultDeclaration
node.parent.type !== AST_NODE_TYPES.ExportDefaultDeclaration &&
node.parent.type !== AST_NODE_TYPES.ClassProperty
) {
return;
}
Expand Down
Expand Up @@ -516,6 +516,57 @@ function test() {
},
],
},
{
filename: 'test.ts',
code: `
class Foo {
public a = () => {};
public b = function () {};
public c = function test() {};
static d = () => {};
static e = function () {};
}
`,
options: [{ allowExpressions: true }],
errors: [
{
messageId: 'missingReturnType',
line: 3,
endLine: 3,
column: 14,
endColumn: 19,
},
{
messageId: 'missingReturnType',
line: 4,
endLine: 4,
column: 14,
endColumn: 25,
},
{
messageId: 'missingReturnType',
line: 5,
endLine: 5,
column: 14,
endColumn: 29,
},
{
messageId: 'missingReturnType',
line: 7,
endLine: 7,
column: 14,
endColumn: 19,
},
{
messageId: 'missingReturnType',
line: 8,
endLine: 8,
column: 14,
endColumn: 25,
},
],
},
{
filename: 'test.ts',
code: "var arrowFn = () => 'test';",
Expand Down

0 comments on commit f1059d8

Please sign in to comment.