@@ -63,8 +63,8 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker {
6363 this . messageIndex = undefined ;
6464 this . keyIndex = undefined ;
6565 this . usedKeys = Object . create ( null ) ;
66- let options : any [ ] = this . getOptions ( ) ;
67- let first : UnexternalizedStringsOptions = options && options . length > 0 ? options [ 0 ] : null ;
66+ const options : any [ ] = this . getOptions ( ) ;
67+ const first : UnexternalizedStringsOptions = options && options . length > 0 ? options [ 0 ] : null ;
6868 if ( first ) {
6969 if ( Array . isArray ( first . signatures ) ) {
7070 first . signatures . forEach ( ( signature : string ) => this . signatures [ signature ] = true ) ;
@@ -84,7 +84,7 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker {
8484 protected visitSourceFile ( node : ts . SourceFile ) : void {
8585 super . visitSourceFile ( node ) ;
8686 Object . keys ( this . usedKeys ) . forEach ( key => {
87- let occurrences = this . usedKeys [ key ] ;
87+ const occurrences = this . usedKeys [ key ] ;
8888 if ( occurrences . length > 1 ) {
8989 occurrences . forEach ( occurrence => {
9090 this . addFailure ( ( this . createFailure ( occurrence . key . getStart ( ) , occurrence . key . getWidth ( ) , `Duplicate key ${ occurrence . key . getText ( ) } with different message value.` ) ) ) ;
@@ -99,9 +99,9 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker {
9999 }
100100
101101 private checkStringLiteral ( node : ts . StringLiteral ) : void {
102- let text = node . getText ( ) ;
103- let doubleQuoted = text . length >= 2 && text [ 0 ] === NoUnexternalizedStringsRuleWalker . DOUBLE_QUOTE && text [ text . length - 1 ] === NoUnexternalizedStringsRuleWalker . DOUBLE_QUOTE ;
104- let info = this . findDescribingParent ( node ) ;
102+ const text = node . getText ( ) ;
103+ const doubleQuoted = text . length >= 2 && text [ 0 ] === NoUnexternalizedStringsRuleWalker . DOUBLE_QUOTE && text [ text . length - 1 ] === NoUnexternalizedStringsRuleWalker . DOUBLE_QUOTE ;
104+ const info = this . findDescribingParent ( node ) ;
105105 // Ignore strings in import and export nodes.
106106 if ( info && info . isImport && doubleQuoted ) {
107107 const fix = [
@@ -115,8 +115,8 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker {
115115 ) ;
116116 return ;
117117 }
118- let callInfo = info ? info . callInfo : null ;
119- let functionName = callInfo ? callInfo . callExpression . expression . getText ( ) : null ;
118+ const callInfo = info ? info . callInfo : null ;
119+ const functionName = callInfo ? callInfo . callExpression . expression . getText ( ) : null ;
120120 if ( functionName && this . ignores [ functionName ] ) {
121121 return ;
122122 }
@@ -134,19 +134,19 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker {
134134 return ;
135135 }
136136 // We have a string that is a direct argument into the localize call.
137- let keyArg : ts . Expression | null = callInfo && callInfo . argIndex === this . keyIndex
137+ const keyArg : ts . Expression | null = callInfo && callInfo . argIndex === this . keyIndex
138138 ? callInfo . callExpression . arguments [ this . keyIndex ]
139139 : null ;
140140 if ( keyArg ) {
141141 if ( isStringLiteral ( keyArg ) ) {
142142 this . recordKey ( keyArg , this . messageIndex && callInfo ? callInfo . callExpression . arguments [ this . messageIndex ] : undefined ) ;
143143 } else if ( isObjectLiteral ( keyArg ) ) {
144144 for ( let i = 0 ; i < keyArg . properties . length ; i ++ ) {
145- let property = keyArg . properties [ i ] ;
145+ const property = keyArg . properties [ i ] ;
146146 if ( isPropertyAssignment ( property ) ) {
147- let name = property . name . getText ( ) ;
147+ const name = property . name . getText ( ) ;
148148 if ( name === 'key' ) {
149- let initializer = property . initializer ;
149+ const initializer = property . initializer ;
150150 if ( isStringLiteral ( initializer ) ) {
151151 this . recordKey ( initializer , this . messageIndex && callInfo ? callInfo . callExpression . arguments [ this . messageIndex ] : undefined ) ;
152152 }
@@ -168,7 +168,7 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker {
168168 }
169169
170170 private recordKey ( keyNode : ts . StringLiteral , messageNode : ts . Node | undefined ) {
171- let text = keyNode . getText ( ) ;
171+ const text = keyNode . getText ( ) ;
172172 // We have an empty key
173173 if ( text . match ( / ( [ ' " ] ) * \1/ ) ) {
174174 if ( messageNode ) {
@@ -194,9 +194,9 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker {
194194 private findDescribingParent ( node : ts . Node ) : { callInfo ?: { callExpression : ts . CallExpression , argIndex : number } , isImport ?: boolean ; } | null {
195195 let parent : ts . Node ;
196196 while ( ( parent = node . parent ) ) {
197- let kind = parent . kind ;
197+ const kind = parent . kind ;
198198 if ( kind === ts . SyntaxKind . CallExpression ) {
199- let callExpression = parent as ts . CallExpression ;
199+ const callExpression = parent as ts . CallExpression ;
200200 return { callInfo : { callExpression : callExpression , argIndex : callExpression . arguments . indexOf ( < any > node ) } } ;
201201 } else if ( kind === ts . SyntaxKind . ImportEqualsDeclaration || kind === ts . SyntaxKind . ImportDeclaration || kind === ts . SyntaxKind . ExportDeclaration ) {
202202 return { isImport : true } ;
0 commit comments