Skip to content

Commit f526c9d

Browse files
devversionmmalerba
authored andcommitted
build(tslint): disallow var keyword (#3625)
* Disallows the var-keyboard in the source files. `var` mostly causes issues with variables, and can be safely replaced with `let`.
1 parent 6b6b392 commit f526c9d

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

src/examples/example-data.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ export class ExampleData {
2828
}
2929
this.selectorName = this.indexFilename = `${example}-example`;
3030

31-
var exampleName = example.replace(/(?:^\w|\b\w)/g, function(letter) {
32-
return letter.toUpperCase();
33-
});
31+
let exampleName = example.replace(/(?:^\w|\b\w)/g, letter => letter.toUpperCase());
3432

3533
if (EXAMPLE_COMPONENTS[example].title) {
3634
this.description = EXAMPLE_COMPONENTS[example].title;

src/lib/button-toggle/button-toggle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const MD_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR: any = {
3636
multi: true
3737
};
3838

39-
var _uniqueIdCounter = 0;
39+
let _uniqueIdCounter = 0;
4040

4141
/** Change event object emitted by MdButtonToggle. */
4242
export class MdButtonToggleChange {

src/lib/checkbox/checkbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export class MdCheckbox implements ControlValueAccessor, AfterViewInit, OnDestro
402402

403403
private _getAnimationClassForCheckStateTransition(
404404
oldState: TransitionCheckState, newState: TransitionCheckState): string {
405-
var animSuffix: string;
405+
let animSuffix: string;
406406

407407
switch (oldState) {
408408
case TransitionCheckState.Init:

src/lib/radio/radio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const MD_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any = {
3939
multi: true
4040
};
4141

42-
var _uniqueIdCounter = 0;
42+
let _uniqueIdCounter = 0;
4343

4444
/** Change event object emitted by MdRadio and MdRadioGroup. */
4545
export class MdRadioChange {

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"no-shadowed-variable": true,
2626
"no-unused-expression": true,
2727
"no-unused-var": [true, {"ignore-pattern": "^(_.*)$"}],
28+
"no-var-keyword": true,
2829
"no-debugger": true,
2930
"one-line": [
3031
true,

0 commit comments

Comments
 (0)