@@ -5,6 +5,8 @@ import * as ts from "typescript";
55export class Rule extends Lint . Rules . AbstractRule {
66 public static LEADING_FAILURE_STRING = "No leading whitespace found on single-line object literal." ;
77 public static TRAILING_FAILURE_STRING = "No trailing whitespace found on single-line object literal." ;
8+ public static LEADING_EXCESS_FAILURE_STRING = "Excess leading whitespace found on single-line object literal." ;
9+ public static TRAILING_EXCESS_FAILURE_STRING = "Excess trailing whitespace found on single-line object literal." ;
810
911 public apply ( sourceFile : ts . SourceFile ) : Lint . RuleFailure [ ] {
1012 return this . applyWithWalker ( new ObjectLiteralSpaceWalker ( sourceFile , this . getOptions ( ) ) ) ;
@@ -21,10 +23,18 @@ class ObjectLiteralSpaceWalker extends Lint.RuleWalker {
2123 const failure = this . createFailure ( node . pos , node . getWidth ( ) , Rule . LEADING_FAILURE_STRING ) ;
2224 this . addFailure ( failure ) ;
2325 }
26+ if ( text . charAt ( 2 ) === " " ) {
27+ const failure = this . createFailure ( node . pos + 2 , 1 , Rule . LEADING_EXCESS_FAILURE_STRING ) ;
28+ this . addFailure ( failure ) ;
29+ }
2430 if ( text . charAt ( text . length - 2 ) !== " " ) {
2531 const failure = this . createFailure ( node . pos , node . getWidth ( ) , Rule . TRAILING_FAILURE_STRING ) ;
2632 this . addFailure ( failure ) ;
2733 }
34+ if ( text . charAt ( text . length - 3 ) === " " ) {
35+ const failure = this . createFailure ( node . pos + node . getWidth ( ) - 3 , 1 , Rule . TRAILING_EXCESS_FAILURE_STRING ) ;
36+ this . addFailure ( failure ) ;
37+ }
2838 }
2939 }
3040 super . visitNode ( node ) ;
0 commit comments