Skip to content

Commit cbb6165

Browse files
Small refactorings.
1 parent 15d689c commit cbb6165

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: scripts/tslint/preferConstRule.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ class PreferConstWalker extends Lint.RuleWalker {
8585

8686
visitBinaryExpression(node: ts.BinaryExpression) {
8787
if (isAssignmentOperator(node.operatorToken.kind)) {
88-
this.visitLHSExpressions(node.left);
88+
this.visitLeftHandSideExpression(node.left);
8989
}
9090
super.visitBinaryExpression(node);
9191
}
9292

93-
private visitLHSExpressions(node: ts.Expression) {
93+
private visitLeftHandSideExpression(node: ts.Expression) {
9494
while (node.kind === ts.SyntaxKind.ParenthesizedExpression) {
9595
node = (node as ts.ParenthesizedExpression).expression;
9696
}
@@ -112,7 +112,7 @@ class PreferConstWalker extends Lint.RuleWalker {
112112
this.markAssignment((element as ts.ShorthandPropertyAssignment).name);
113113
}
114114
else if (kind === ts.SyntaxKind.PropertyAssignment) {
115-
this.visitLHSExpressions((element as ts.PropertyAssignment).initializer);
115+
this.visitLeftHandSideExpression((element as ts.PropertyAssignment).initializer);
116116
}
117117
else {
118118
// Should we throw an exception?
@@ -122,7 +122,7 @@ class PreferConstWalker extends Lint.RuleWalker {
122122
else if (node.kind === ts.SyntaxKind.ArrayLiteralExpression) {
123123
const pattern = node as ts.ArrayLiteralExpression;
124124
for (const element of pattern.elements) {
125-
this.visitLHSExpressions(element);
125+
this.visitLeftHandSideExpression(element);
126126
}
127127
}
128128
}
@@ -150,7 +150,7 @@ class PreferConstWalker extends Lint.RuleWalker {
150150

151151
private visitAnyUnaryExpression(node: ts.PrefixUnaryExpression | ts.PostfixUnaryExpression) {
152152
if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator === ts.SyntaxKind.MinusMinusToken) {
153-
this.visitLHSExpressions(node.operand);
153+
this.visitLeftHandSideExpression(node.operand);
154154
}
155155
}
156156

@@ -216,12 +216,12 @@ class PreferConstWalker extends Lint.RuleWalker {
216216
}
217217
}
218218

219-
private collectNameIdentifiers(value: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.Map<DeclarationUsages>) {
219+
private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.Map<DeclarationUsages>) {
220220
if (node.kind === ts.SyntaxKind.Identifier) {
221-
table[(node as ts.Identifier).text] = {declaration: value, usages: 0};
221+
table[(node as ts.Identifier).text] = { declaration, usages: 0 };
222222
}
223223
else {
224-
this.collectBindingPatternIdentifiers(value, node as ts.BindingPattern, table);
224+
this.collectBindingPatternIdentifiers(declaration, node as ts.BindingPattern, table);
225225
}
226226
}
227227

0 commit comments

Comments
 (0)