Skip to content

Commit

Permalink
fix(eslint-plugin): handle method overloading in semi (#4318)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjuan committed Dec 20, 2021
1 parent 04d1f3e commit 3b87b49
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/semi.ts
Expand Up @@ -53,11 +53,11 @@ export default util.createRule<Options, MessageIds>({
const nodesToCheck = [
AST_NODE_TYPES.PropertyDefinition,
AST_NODE_TYPES.TSAbstractPropertyDefinition,
AST_NODE_TYPES.TSAbstractMethodDefinition,
AST_NODE_TYPES.TSDeclareFunction,
AST_NODE_TYPES.TSExportAssignment,
AST_NODE_TYPES.TSImportEqualsDeclaration,
AST_NODE_TYPES.TSTypeAliasDeclaration,
AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
].reduce<TSESLint.RuleListener>((acc, node) => {
acc[node as string] = checkForSemicolon;
return acc;
Expand Down
39 changes: 39 additions & 0 deletions packages/eslint-plugin/tests/rules/semi.test.ts
Expand Up @@ -302,7 +302,46 @@ class PanCamera extends FreeCamera {
options: ['always', { omitLastInOneLineBlock: true }],
errors: [extraSemicolon],
},
{
code: `
class A {
method(): void
method(arg?: any): void {
}
}
`,
output: `
class A {
method(): void;
method(arg?: any): void {
}
}
`,
options: ['always'],
errors: [missingSemicolon],
},
{
code: `
class A {
method(): void;
method(arg?: any): void {
}
}
`,
output: `
class A {
method(): void
method(arg?: any): void {
}
}
`,
options: ['never'],
errors: [extraSemicolon],
},
{
code: `
import a from "a"
Expand Down

0 comments on commit 3b87b49

Please sign in to comment.