Skip to content

Commit dc08df5

Browse files
committedFeb 5, 2019
Fix curly statement newlines rule when prefixed with newlines
·
v4.100.31.31.0-20
1 parent 70ad911 commit dc08df5

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed
 

‎rules/src/curlyStatementNewlinesRule.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,29 @@ import * as Lint from "tslint";
55
* Curly statement newlines rule.
66
*/
77
export class Rule extends Lint.Rules.AbstractRule {
8-
9-
public static FAILURE_STRING = "curly statements must separate with newlines";
8+
public static FAILURE_STRING = "Curly statements must separate with newlines";
109

1110
/**
1211
* Apply the rule.
1312
*/
1413
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
1514
return this.applyWithWalker(new CurlyStatementNewlinesWalker(sourceFile, this.getOptions()));
1615
}
17-
1816
}
1917

2018
/**
2119
* Curly statement newlines walker.
2220
*/
2321
class CurlyStatementNewlinesWalker extends Lint.RuleWalker {
24-
2522
/**
2623
* Visit if statements.
2724
*/
2825
public visitIfStatement(node: ts.IfStatement): void {
29-
const splitLength = node.getFullText().split("\n").length;
26+
const splitLength = node.getFullText().trim().split("\n").length;
3027
if (splitLength <= 2) {
3128
this.addFailureAt(node.getStart(), node.getWidth(), Rule.FAILURE_STRING);
3229
}
3330

3431
super.visitIfStatement(node);
3532
}
36-
3733
}

0 commit comments

Comments
 (0)
Please sign in to comment.