Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tslint rules for #3994 #4458

Merged
merged 6 commits into from
Sep 18, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Feedback from PR, remove unused identifiers
  • Loading branch information
weswigham committed Sep 17, 2015
commit 2793bc2acda93a6d84cf1db19eab98d37a7b8271
14 changes: 6 additions & 8 deletions scripts/tslint/nextLineRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class NextLineWalker extends Lint.RuleWalker {
const elseKeyword = getFirstChildOfKind(node, ts.SyntaxKind.ElseKeyword);
if (this.hasOption(OPTION_ELSE) && !!elseKeyword) {
const thenStatementEndLoc = sourceFile.getLineAndCharacterOfPosition(thenStatement.getEnd());
const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart());
const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart(sourceFile));
if (thenStatementEndLoc.line !== (elseKeywordLoc.line - 1)) {
const failure = this.createFailure(elseKeyword.getStart(), elseKeyword.getWidth(), Rule.ELSE_FAILURE_STRING);
const failure = this.createFailure(elseKeyword.getStart(sourceFile), elseKeyword.getWidth(sourceFile), Rule.ELSE_FAILURE_STRING);
this.addFailure(failure);
}
}
Expand All @@ -40,17 +40,15 @@ class NextLineWalker extends Lint.RuleWalker {
const catchClause = node.catchClause;

// "visit" try block
const tryKeyword = node.getChildAt(0);
const tryBlock = node.tryBlock;
const tryOpeningBrace = tryBlock.getChildAt(0);

if (this.hasOption(OPTION_CATCH) && !!catchClause) {
const tryClosingBrace = node.tryBlock.getChildAt(node.tryBlock.getChildCount() - 1);
const catchKeyword = catchClause.getChildAt(0);
const tryClosingBrace = tryBlock.getLastToken(sourceFile);
const catchKeyword = catchClause.getFirstToken(sourceFile);
const tryClosingBraceLoc = sourceFile.getLineAndCharacterOfPosition(tryClosingBrace.getEnd());
const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart());
const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart(sourceFile));
if (tryClosingBraceLoc.line !== (catchKeywordLoc.line - 1)) {
const failure = this.createFailure(catchKeyword.getStart(), catchKeyword.getWidth(), Rule.CATCH_FAILURE_STRING);
const failure = this.createFailure(catchKeyword.getStart(sourceFile), catchKeyword.getWidth(sourceFile), Rule.CATCH_FAILURE_STRING);
this.addFailure(failure);
}
}
Expand Down
10 changes: 8 additions & 2 deletions scripts/tslint/noInferrableTypesRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ class InferrableTypeWalker extends Lint.RuleWalker {
}
break;
case ts.SyntaxKind.StringKeyword:
if (e.initializer.kind === ts.SyntaxKind.StringLiteral || e.initializer.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral) {
failure = 'string';
switch (e.initializer.kind) {
case ts.SyntaxKind.StringLiteral:
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
case ts.SyntaxKind.TemplateExpression:
failure = 'string';
break;
default:
break;
}
break;
}
Expand Down