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

Make semi-colon rule laxer with bound-method properties #1081

Merged
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
6 changes: 5 additions & 1 deletion src/rules/semicolonRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ class SemicolonWalker extends Lint.RuleWalker {
}

public visitPropertyDeclaration(node: ts.PropertyDeclaration) {
this.checkSemicolonAt(node);
const initializer = node.initializer;
/* ALWAYS === "enabled" for this rule. */
if (this.hasOption(OPTION_NEVER) || !(initializer && initializer.kind === ts.SyntaxKind.ArrowFunction)) {
this.checkSemicolonAt(node);
}
super.visitPropertyDeclaration(node);
}

Expand Down
4 changes: 4 additions & 0 deletions test/rules/semicolon/always/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class MyClass {
private index : number
~nil [missing semicolon]
private email : string;

public initializedProperty = 6
~nil [missing semicolon]
public initializedMethodProperty = () => { return "hi"; }
}

interface ITest {
Expand Down
3 changes: 3 additions & 0 deletions test/rules/semicolon/enabled/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class MyClass {
private index : number
~nil [missing semicolon]
private email : string;
public initializedProperty = 6
~nil [missing semicolon]
public initializedMethodProperty = () => { return "hi"; }
}

interface ITest {
Expand Down
4 changes: 4 additions & 0 deletions test/rules/semicolon/never/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class MyClass {
private index : number;
~ [unnecessary semicolon]
private email : string
public initializedProperty = 6
public initializedMethodProperty = () => { return "hi" };
~ [unnecessary semicolon]

}

interface ITest {
Expand Down