File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -5,33 +5,29 @@ import * as Lint from "tslint";
5
5
* Curly statement newlines rule.
6
6
*/
7
7
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" ;
10
9
11
10
/**
12
11
* Apply the rule.
13
12
*/
14
13
public apply ( sourceFile : ts . SourceFile ) : Lint . RuleFailure [ ] {
15
14
return this . applyWithWalker ( new CurlyStatementNewlinesWalker ( sourceFile , this . getOptions ( ) ) ) ;
16
15
}
17
-
18
16
}
19
17
20
18
/**
21
19
* Curly statement newlines walker.
22
20
*/
23
21
class CurlyStatementNewlinesWalker extends Lint . RuleWalker {
24
-
25
22
/**
26
23
* Visit if statements.
27
24
*/
28
25
public visitIfStatement ( node : ts . IfStatement ) : void {
29
- const splitLength = node . getFullText ( ) . split ( "\n" ) . length ;
26
+ const splitLength = node . getFullText ( ) . trim ( ) . split ( "\n" ) . length ;
30
27
if ( splitLength <= 2 ) {
31
28
this . addFailureAt ( node . getStart ( ) , node . getWidth ( ) , Rule . FAILURE_STRING ) ;
32
29
}
33
30
34
31
super . visitIfStatement ( node ) ;
35
32
}
36
-
37
33
}
You can’t perform that action at this time.
0 commit comments