Skip to content

Commit bd633c8

Browse files
author
Andy Hanson
committed
Lint all servicesSources
1 parent 7173fa8 commit bd633c8

15 files changed

Lines changed: 349 additions & 361 deletions

Jakefile.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -962,24 +962,13 @@ function lintFileAsync(options, path, cb) {
962962
});
963963
}
964964

965-
var servicesLintTargets = [
966-
"navigateTo.ts",
967-
"navigationBar.ts",
968-
"outliningElementsCollector.ts",
969-
"patternMatcher.ts",
970-
"services.ts",
971-
"shims.ts",
972-
"jsTyping.ts"
973-
].map(function (s) {
974-
return path.join(servicesDirectory, s);
975-
});
976965
var lintTargets = compilerSources
977966
.concat(harnessSources)
978967
// Other harness sources
979968
.concat(["instrumenter.ts"].map(function(f) { return path.join(harnessDirectory, f) }))
980969
.concat(serverCoreSources)
981970
.concat(tslintRulesFiles)
982-
.concat(servicesLintTargets);
971+
.concat(servicesSources);
983972

984973

985974
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");

scripts/tslint/noIncrementDecrementRule.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,15 @@ class IncrementDecrementWalker extends Lint.RuleWalker {
2828
}
2929

3030
visitIncrementDecrement(node: ts.UnaryExpression) {
31-
if (node.parent && (node.parent.kind === ts.SyntaxKind.ExpressionStatement ||
32-
node.parent.kind === ts.SyntaxKind.ForStatement)) {
31+
if (node.parent && (
32+
// Can be a statement
33+
node.parent.kind === ts.SyntaxKind.ExpressionStatement ||
34+
// Can be directly in a for-statement
35+
node.parent.kind === ts.SyntaxKind.ForStatement ||
36+
// Can be in a comma operator in a for statement (`for (let a = 0, b = 10; a < b; a++, b--)`)
37+
node.parent.kind === ts.SyntaxKind.BinaryExpression &&
38+
(<ts.BinaryExpression>node.parent).operatorToken.kind === ts.SyntaxKind.CommaToken &&
39+
node.parent.parent.kind === ts.SyntaxKind.ForStatement)) {
3340
return;
3441
}
3542
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.POSTFIX_FAILURE_STRING));

src/services/breakpoints.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace ts.BreakpointResolver {
1515
}
1616

1717
let tokenAtLocation = getTokenAtPosition(sourceFile, position);
18-
let lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
18+
const lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
1919
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) {
2020
// Get previous token if the token is returned starts on new line
2121
// eg: let x =10; |--- cursor is here
@@ -216,7 +216,7 @@ namespace ts.BreakpointResolver {
216216
return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile));
217217

218218
case SyntaxKind.CommaToken:
219-
return spanInPreviousNode(node)
219+
return spanInPreviousNode(node);
220220

221221
case SyntaxKind.OpenBraceToken:
222222
return spanInOpenBraceToken(node);
@@ -259,13 +259,13 @@ namespace ts.BreakpointResolver {
259259
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node)) {
260260
return spanInArrayLiteralOrObjectLiteralDestructuringPattern(<DestructuringPattern>node);
261261
}
262-
262+
263263
// Set breakpoint on identifier element of destructuring pattern
264264
// a or ...c or d: x from
265265
// [a, b, ...c] or { a, b } or { d: x } from destructuring pattern
266266
if ((node.kind === SyntaxKind.Identifier ||
267-
node.kind == SyntaxKind.SpreadElementExpression ||
268-
node.kind === SyntaxKind.PropertyAssignment ||
267+
node.kind == SyntaxKind.SpreadElementExpression ||
268+
node.kind === SyntaxKind.PropertyAssignment ||
269269
node.kind === SyntaxKind.ShorthandPropertyAssignment) &&
270270
isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
271271
return textSpan(node);
@@ -325,14 +325,14 @@ namespace ts.BreakpointResolver {
325325
break;
326326
}
327327
}
328-
328+
329329
// If this is name of property assignment, set breakpoint in the initializer
330330
if (node.parent.kind === SyntaxKind.PropertyAssignment &&
331-
(<PropertyDeclaration>node.parent).name === node &&
331+
(<PropertyDeclaration>node.parent).name === node &&
332332
!isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) {
333333
return spanInNode((<PropertyDeclaration>node.parent).initializer);
334334
}
335-
335+
336336
// Breakpoint in type assertion goes to its operand
337337
if (node.parent.kind === SyntaxKind.TypeAssertionExpression && (<TypeAssertion>node.parent).type === node) {
338338
return spanInNextNode((<TypeAssertion>node.parent).type);
@@ -370,7 +370,7 @@ namespace ts.BreakpointResolver {
370370
}
371371

372372
function textSpanFromVariableDeclaration(variableDeclaration: VariableDeclaration): TextSpan {
373-
let declarations = variableDeclaration.parent.declarations;
373+
const declarations = variableDeclaration.parent.declarations;
374374
if (declarations && declarations[0] === variableDeclaration) {
375375
// First declaration - include let keyword
376376
return textSpan(findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration);
@@ -386,7 +386,7 @@ namespace ts.BreakpointResolver {
386386
if (variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
387387
return spanInNode(variableDeclaration.parent.parent);
388388
}
389-
389+
390390
// If this is a destructuring pattern, set breakpoint in binding pattern
391391
if (isBindingPattern(variableDeclaration.name)) {
392392
return spanInBindingPattern(<BindingPattern>variableDeclaration.name);
@@ -400,7 +400,7 @@ namespace ts.BreakpointResolver {
400400
return textSpanFromVariableDeclaration(variableDeclaration);
401401
}
402402

403-
let declarations = variableDeclaration.parent.declarations;
403+
const declarations = variableDeclaration.parent.declarations;
404404
if (declarations && declarations[0] !== variableDeclaration) {
405405
// If we cannot set breakpoint on this declaration, set it on previous one
406406
// Because the variable declaration may be binding pattern and
@@ -425,8 +425,8 @@ namespace ts.BreakpointResolver {
425425
return textSpan(parameter);
426426
}
427427
else {
428-
let functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
429-
let indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
428+
const functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
429+
const indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
430430
if (indexOfParameter) {
431431
// Not a first parameter, go to previous parameter
432432
return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]);
@@ -459,7 +459,7 @@ namespace ts.BreakpointResolver {
459459
}
460460

461461
function spanInFunctionBlock(block: Block): TextSpan {
462-
let nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
462+
const nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
463463
if (canFunctionHaveSpanInWholeDeclaration(<FunctionLikeDeclaration>block.parent)) {
464464
return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock);
465465
}
@@ -493,7 +493,7 @@ namespace ts.BreakpointResolver {
493493
function spanInInitializerOfForLike(forLikeStatement: ForStatement | ForOfStatement | ForInStatement): TextSpan {
494494
if (forLikeStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
495495
// Declaration list - set breakpoint in first declaration
496-
let variableDeclarationList = <VariableDeclarationList>forLikeStatement.initializer;
496+
const variableDeclarationList = <VariableDeclarationList>forLikeStatement.initializer;
497497
if (variableDeclarationList.declarations.length > 0) {
498498
return spanInNode(variableDeclarationList.declarations[0]);
499499
}
@@ -519,7 +519,7 @@ namespace ts.BreakpointResolver {
519519

520520
function spanInBindingPattern(bindingPattern: BindingPattern): TextSpan {
521521
// Set breakpoint in first binding element
522-
let firstBindingElement = forEach(bindingPattern.elements,
522+
const firstBindingElement = forEach(bindingPattern.elements,
523523
element => element.kind !== SyntaxKind.OmittedExpression ? element : undefined);
524524

525525
if (firstBindingElement) {
@@ -616,7 +616,7 @@ namespace ts.BreakpointResolver {
616616
default:
617617
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
618618
// Breakpoint in last binding element or binding pattern if it contains no elements
619-
let objectLiteral = <ObjectLiteralExpression>node.parent;
619+
const objectLiteral = <ObjectLiteralExpression>node.parent;
620620
return textSpan(lastOrUndefined(objectLiteral.properties) || objectLiteral);
621621
}
622622
return spanInNode(node.parent);
@@ -633,7 +633,7 @@ namespace ts.BreakpointResolver {
633633
default:
634634
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
635635
// Breakpoint in last binding element or binding pattern if it contains no elements
636-
let arrayLiteral = <ArrayLiteralExpression>node.parent;
636+
const arrayLiteral = <ArrayLiteralExpression>node.parent;
637637
return textSpan(lastOrUndefined(arrayLiteral.elements) || arrayLiteral);
638638
}
639639

@@ -686,7 +686,7 @@ namespace ts.BreakpointResolver {
686686
function spanInColonToken(node: Node): TextSpan {
687687
// Is this : specifying return annotation of the function declaration
688688
if (isFunctionLike(node.parent) ||
689-
node.parent.kind === SyntaxKind.PropertyAssignment ||
689+
node.parent.kind === SyntaxKind.PropertyAssignment ||
690690
node.parent.kind === SyntaxKind.Parameter) {
691691
return spanInPreviousNode(node);
692692
}

0 commit comments

Comments
 (0)