Skip to content

Commit 2793bc2

Browse files
committed
Feedback from PR, remove unused identifiers
1 parent 0d88d8d commit 2793bc2

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

scripts/tslint/nextLineRule.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class NextLineWalker extends Lint.RuleWalker {
2424
const elseKeyword = getFirstChildOfKind(node, ts.SyntaxKind.ElseKeyword);
2525
if (this.hasOption(OPTION_ELSE) && !!elseKeyword) {
2626
const thenStatementEndLoc = sourceFile.getLineAndCharacterOfPosition(thenStatement.getEnd());
27-
const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart());
27+
const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart(sourceFile));
2828
if (thenStatementEndLoc.line !== (elseKeywordLoc.line - 1)) {
29-
const failure = this.createFailure(elseKeyword.getStart(), elseKeyword.getWidth(), Rule.ELSE_FAILURE_STRING);
29+
const failure = this.createFailure(elseKeyword.getStart(sourceFile), elseKeyword.getWidth(sourceFile), Rule.ELSE_FAILURE_STRING);
3030
this.addFailure(failure);
3131
}
3232
}
@@ -40,17 +40,15 @@ class NextLineWalker extends Lint.RuleWalker {
4040
const catchClause = node.catchClause;
4141

4242
// "visit" try block
43-
const tryKeyword = node.getChildAt(0);
4443
const tryBlock = node.tryBlock;
45-
const tryOpeningBrace = tryBlock.getChildAt(0);
4644

4745
if (this.hasOption(OPTION_CATCH) && !!catchClause) {
48-
const tryClosingBrace = node.tryBlock.getChildAt(node.tryBlock.getChildCount() - 1);
49-
const catchKeyword = catchClause.getChildAt(0);
46+
const tryClosingBrace = tryBlock.getLastToken(sourceFile);
47+
const catchKeyword = catchClause.getFirstToken(sourceFile);
5048
const tryClosingBraceLoc = sourceFile.getLineAndCharacterOfPosition(tryClosingBrace.getEnd());
51-
const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart());
49+
const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart(sourceFile));
5250
if (tryClosingBraceLoc.line !== (catchKeywordLoc.line - 1)) {
53-
const failure = this.createFailure(catchKeyword.getStart(), catchKeyword.getWidth(), Rule.CATCH_FAILURE_STRING);
51+
const failure = this.createFailure(catchKeyword.getStart(sourceFile), catchKeyword.getWidth(sourceFile), Rule.CATCH_FAILURE_STRING);
5452
this.addFailure(failure);
5553
}
5654
}

scripts/tslint/noInferrableTypesRule.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ class InferrableTypeWalker extends Lint.RuleWalker {
2727
}
2828
break;
2929
case ts.SyntaxKind.StringKeyword:
30-
if (e.initializer.kind === ts.SyntaxKind.StringLiteral || e.initializer.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral) {
31-
failure = 'string';
30+
switch (e.initializer.kind) {
31+
case ts.SyntaxKind.StringLiteral:
32+
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
33+
case ts.SyntaxKind.TemplateExpression:
34+
failure = 'string';
35+
break;
36+
default:
37+
break;
3238
}
3339
break;
3440
}

0 commit comments

Comments
 (0)