Skip to content

Commit

Permalink
do not handle whitespace in comma-delimited binary expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinr committed Aug 1, 2013
1 parent d5205bb commit e6bd303
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
11 changes: 7 additions & 4 deletions bin/tslint-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27323,11 +27323,14 @@ var Lint;
};

WhitespaceWalker.prototype.visitBinaryExpression = function (node) {
var position = this.positionAfter(node.left);
this.checkForLeadingSpace(position, node.left.trailingTrivia());
var operator = node.operatorToken;
if (operator.kind() !== TypeScript.SyntaxKind.CommaToken) {
var position = this.positionAfter(node.left);
this.checkForLeadingSpace(position, node.left.trailingTrivia());

position += node.operatorToken.fullWidth();
this.checkForLeadingSpace(position, node.operatorToken.trailingTrivia());
position += operator.fullWidth();
this.checkForLeadingSpace(position, operator.trailingTrivia());
}

_super.prototype.visitBinaryExpression.call(this, node);
};
Expand Down
11 changes: 7 additions & 4 deletions lib/tslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -27323,11 +27323,14 @@ var Lint;
};

WhitespaceWalker.prototype.visitBinaryExpression = function (node) {
var position = this.positionAfter(node.left);
this.checkForLeadingSpace(position, node.left.trailingTrivia());
var operator = node.operatorToken;
if (operator.kind() !== TypeScript.SyntaxKind.CommaToken) {
var position = this.positionAfter(node.left);
this.checkForLeadingSpace(position, node.left.trailingTrivia());

position += node.operatorToken.fullWidth();
this.checkForLeadingSpace(position, node.operatorToken.trailingTrivia());
position += operator.fullWidth();
this.checkForLeadingSpace(position, operator.trailingTrivia());
}

_super.prototype.visitBinaryExpression.call(this, node);
};
Expand Down
13 changes: 8 additions & 5 deletions src/rules/whitespaceRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ module Lint.Rules {
}
}

// check for spaces between the operator symbol
// check for spaces between the operator symbol (except in the case of comma statements)
public visitBinaryExpression(node: TypeScript.BinaryExpressionSyntax): void {
var position = this.positionAfter(node.left);
this.checkForLeadingSpace(position, node.left.trailingTrivia());
var operator = node.operatorToken;
if(operator.kind() !== TypeScript.SyntaxKind.CommaToken) {
var position = this.positionAfter(node.left);
this.checkForLeadingSpace(position, node.left.trailingTrivia());

position += node.operatorToken.fullWidth();
this.checkForLeadingSpace(position, node.operatorToken.trailingTrivia());
position += operator.fullWidth();
this.checkForLeadingSpace(position, operator.trailingTrivia());
}

super.visitBinaryExpression(node);
}
Expand Down

0 comments on commit e6bd303

Please sign in to comment.