Skip to content

Commit

Permalink
feat: add checking property definition for allowNames option (#4542)
Browse files Browse the repository at this point in the history
  • Loading branch information
lonyele committed Feb 12, 2022
1 parent 9d029a9 commit e32bef6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Expand Up @@ -232,7 +232,8 @@ export default util.createRule<Options, MessageIds>({
} 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 &&
Expand Down
Expand Up @@ -390,11 +390,15 @@ export class Test {
['prop']() {}
[\`prop\`]() {}
[\`\${v}\`](): void {}
foo = () => {
bar: 5;
};
}
`,
options: [
{
allowedNames: ['prop', 'method'],
allowedNames: ['prop', 'method', 'foo'],
},
],
},
Expand Down Expand Up @@ -1187,6 +1191,7 @@ export class Test {
return;
}
arrow = (): string => 'arrow';
foo = () => 'bar';
}
`,
options: [
Expand All @@ -1202,6 +1207,13 @@ export class Test {
column: 3,
endColumn: 11,
},
{
messageId: 'missingReturnType',
line: 12,
endLine: 12,
column: 9,
endColumn: 14,
},
],
},
{
Expand Down

0 comments on commit e32bef6

Please sign in to comment.