Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

prefer-function-over-method should ignore abstract methods #2307

Merged
merged 2 commits into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rules/preferFunctionOverMethodRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class PreferFunctionOverMethodWalker extends Lint.RuleWalker {
}

private shouldWarnForModifiers(node: ts.MethodDeclaration): boolean {
if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) {
if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword, ts.SyntaxKind.AbstractKeyword)) {
return false;
}
// TODO: Also return false if it's marked "override" (https://github.com/palantir/tslint/pull/2037)
Expand Down
4 changes: 4 additions & 0 deletions test/rules/prefer-function-over-method/default/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class C {
~~~~~~~~~~~~~~~~~ [0]
}

abstract class C2 {
abstract abstract(): void;
}

const o = {
x() {}
}
Expand Down