Skip to content

Commit b60ce40

Browse files
committed
fix(lint): enable tslint and codelyzer (fixes #309)
1 parent 232b8ae commit b60ce40

File tree

65 files changed

+1429
-1324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1429
-1324
lines changed

components/accordion/accordion-group.component.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import {Component, OnInit, OnDestroy, Input, HostBinding, Inject} from 'angular2/core';
1+
import {
2+
Component, OnInit, OnDestroy, Input, HostBinding, Inject
3+
} from 'angular2/core';
24
import {NgClass} from 'angular2/common';
3-
45
import {Collapse} from '../collapse';
56
import {Accordion} from './accordion.component';
67

8+
/* tslint:disable:component-selector-name */
79
@Component({
810
selector: 'accordion-group, accordion-panel',
911
directives: [Collapse, NgClass],
@@ -31,7 +33,8 @@ export class AccordionPanel implements OnInit, OnDestroy {
3133
@Input() public isDisabled:boolean;
3234

3335
@HostBinding('class.panel-open')
34-
@Input() public get isOpen():boolean {
36+
@Input()
37+
public get isOpen():boolean {
3538
return this._isOpen;
3639
}
3740

@@ -43,20 +46,22 @@ export class AccordionPanel implements OnInit, OnDestroy {
4346
}
4447

4548
private _isOpen:boolean;
49+
private accordion:Accordion;
4650

47-
constructor(@Inject(Accordion) private accordion:Accordion) {
51+
public constructor(@Inject(Accordion) accordion:Accordion) {
52+
this.accordion = accordion;
4853
}
4954

50-
ngOnInit() {
55+
public ngOnInit():any {
5156
this.panelClass = this.panelClass || 'panel-default';
5257
this.accordion.addGroup(this);
5358
}
5459

55-
ngOnDestroy() {
60+
public ngOnDestroy():any {
5661
this.accordion.removeGroup(this);
5762
}
5863

59-
public toggleOpen(event:MouseEvent) {
64+
public toggleOpen(event:MouseEvent):any {
6065
event.preventDefault();
6166
if (!this.isDisabled) {
6267
this.isOpen = !this.isOpen;

components/accordion/accordion.component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {Component, Input, HostBinding} from 'angular2/core';
2-
32
import {AccordionPanel} from './accordion-group.component';
43

54
// todo: support template url
@@ -10,15 +9,17 @@ import {AccordionPanel} from './accordion-group.component';
109
export class Accordion {
1110
@Input() public closeOthers:boolean;
1211

12+
/* tslint:disable:no-unused-variable */
1313
@HostBinding('class.panel-group')
14-
private addClass = true;
14+
private addClass:boolean = true;
15+
/* tslint:enable:no-unused-variable */
1516

16-
constructor() {
17+
public constructor() {
1718
}
1819

1920
private groups:Array<AccordionPanel> = [];
2021

21-
public closeOtherPanels(openGroup:AccordionPanel) {
22+
public closeOtherPanels(openGroup:AccordionPanel):void {
2223
if (!this.closeOthers) {
2324
return;
2425
}
@@ -30,11 +31,11 @@ export class Accordion {
3031
});
3132
}
3233

33-
public addGroup(group:AccordionPanel) {
34+
public addGroup(group:AccordionPanel):void {
3435
this.groups.push(group);
3536
}
3637

37-
public removeGroup(group:AccordionPanel) {
38+
public removeGroup(group:AccordionPanel):void {
3839
let index = this.groups.indexOf(group);
3940
if (index !== -1) {
4041
this.groups.splice(index, 1);
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
it,
3-
inject,
4-
injectAsync,
5-
beforeEachProviders,
6-
TestComponentBuilder
7-
} from 'angular2/testing';
8-
1+
import {it, inject, beforeEachProviders} from 'angular2/testing';
92
import {Alert} from './alert.component';
103

114
describe('Alert', () => {
@@ -14,6 +7,7 @@ describe('Alert', () => {
147
]);
158

169
it('should have default type', inject([Alert], (alert:Alert) => {
17-
expect(alert.type).toEqual('warning');
10+
expect(alert.type)
11+
.toEqual('warning');
1812
}));
1913
});

components/alert/alert.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component, OnInit, Input, Output, EventEmitter } from 'angular2/core';
2-
import { NgIf, NgClass } from 'angular2/common';
1+
import {Component, OnInit, Input, Output, EventEmitter} from 'angular2/core';
2+
import {NgIf, NgClass} from 'angular2/common';
33

44
const ALERT_TEMPLATE = `
55
<div class="alert" role="alert" [ngClass]="classes" *ngIf="!closed">
@@ -27,9 +27,9 @@ export class Alert implements OnInit {
2727
private closed:boolean;
2828
private classes:Array<string> = [];
2929

30-
constructor() {}
30+
public constructor() {}
3131

32-
ngOnInit() {
32+
public ngOnInit():any {
3333
this.classes[0] = `alert-${this.type}`;
3434
if (this.dismissible) {
3535
this.classes[1] = 'alert-dismissible';
@@ -43,7 +43,7 @@ export class Alert implements OnInit {
4343
}
4444

4545
// todo: mouse event + touch + pointer
46-
onClose() {
46+
public onClose():void {
4747
this.closed = true;
4848
this.close.emit(this);
4949
}

components/buttons.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ import {ButtonRadio} from './buttons/button-radio.component';
33

44
export {ButtonCheckbox} from './buttons/button-checkbox.component';
55
export {ButtonRadio} from './buttons/button-radio.component';
6-
export const BUTTON_DIRECTIVES = [ButtonCheckbox, ButtonRadio];
6+
export const BUTTON_DIRECTIVES:Array<any> = [ButtonCheckbox, ButtonRadio];

components/buttons/button-checkbox.component.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,62 @@
1-
import { Directive, OnInit, Input, HostBinding, HostListener,
2-
Self, Renderer, ElementRef } from 'angular2/core';
3-
import { ControlValueAccessor, NgModel } from 'angular2/common';
1+
import {
2+
Directive, OnInit, Input, HostBinding, HostListener, Self
3+
} from 'angular2/core';
4+
import {ControlValueAccessor, NgModel} from 'angular2/common';
45

5-
@Directive({ selector: '[btnCheckbox][ngModel]' })
6+
@Directive({selector: '[btnCheckbox][ngModel]'})
67
export class ButtonCheckbox implements ControlValueAccessor, OnInit {
7-
@Input() private btnCheckboxTrue:any;
8-
@Input() private btnCheckboxFalse:any;
8+
public cd:NgModel;
9+
@Input() public btnCheckboxTrue:any;
910

11+
@Input() public btnCheckboxFalse:any;
1012
@HostBinding('class.active')
11-
private state:boolean = false;
13+
public state:boolean = false;
14+
15+
private value:any;
1216

1317
// view -> model
1418
@HostListener('click')
15-
private onClick() {
19+
public onClick():void {
1620
this.toggle(!this.state);
1721
this.cd.viewToModelUpdate(this.value);
1822
}
1923

20-
private value:any;
21-
22-
constructor(@Self() public cd:NgModel) {
24+
public constructor(@Self() cd:NgModel) {
25+
this.cd = cd;
2326
// hack !
2427
cd.valueAccessor = this;
2528
}
2629

27-
public ngOnInit() {
30+
public ngOnInit():any {
2831
this.toggle(this.trueValue === this.value);
2932
}
3033

31-
private get trueValue() {
32-
return typeof this.btnCheckboxTrue !== 'undefined' ? this.btnCheckboxTrue : true;
34+
private get trueValue():boolean {
35+
return typeof this.btnCheckboxTrue !== 'undefined'
36+
? this.btnCheckboxTrue
37+
: true;
3338
}
3439

35-
private get falseValue() {
36-
return typeof this.btnCheckboxFalse !== 'undefined' ? this.btnCheckboxFalse : false;
40+
private get falseValue():boolean {
41+
return typeof this.btnCheckboxFalse !== 'undefined'
42+
? this.btnCheckboxFalse
43+
: false;
3744
}
3845

39-
private toggle(state:boolean) {
46+
public toggle(state:boolean):void {
4047
this.state = state;
4148
this.value = this.state ? this.trueValue : this.falseValue;
4249
}
4350

4451
// ControlValueAccessor
4552
// model -> view
46-
public writeValue(value:any) {
53+
public writeValue(value:any):void {
4754
this.state = this.trueValue === value;
4855
this.value = value;
4956
}
5057

51-
protected onChange = (_:any) => {};
52-
protected onTouched = () => {};
58+
protected onChange:any = () => {};
59+
protected onTouched:any = () => {};
5360

5461
public registerOnChange(fn:(_:any) => {}):void {
5562
this.onChange = fn;

components/buttons/button-radio.component.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
1-
import { Directive, OnInit, Input, HostBinding, HostListener,
2-
Self, ElementRef } from 'angular2/core';
3-
import { ControlValueAccessor, NgModel } from 'angular2/common';
1+
import {
2+
Directive, OnInit, Input, HostBinding, HostListener, Self, ElementRef
3+
} from 'angular2/core';
4+
import {ControlValueAccessor, NgModel} from 'angular2/common';
45

5-
@Directive({ selector: '[btnRadio][ngModel]' })
6+
@Directive({selector: '[btnRadio][ngModel]'})
67
export class ButtonRadio implements ControlValueAccessor, OnInit {
8+
public cd:NgModel;
9+
public el:ElementRef;
10+
711
@Input() private btnRadio:string;
812
@Input() private uncheckable:boolean;
913

1014
@HostBinding('class.active')
11-
private get isActive() {
15+
public get isActive():boolean {
1216
return this.btnRadio === this.value;
1317
}
1418

1519
@HostListener('click')
16-
private onClick() {
20+
public onClick():void {
1721
if (this.uncheckable && this.btnRadio === this.value) {
18-
return this.cd.viewToModelUpdate(null);
22+
return this.cd.viewToModelUpdate(void 0);
1923
}
2024

2125
this.cd.viewToModelUpdate(this.btnRadio);
2226
}
2327

24-
constructor(@Self() public cd:NgModel, public el:ElementRef) {
28+
public constructor(@Self() cd:NgModel, el:ElementRef) {
2529
// hack!
30+
this.cd = cd;
31+
this.el = el;
2632
cd.valueAccessor = this;
2733
}
2834

29-
public ngOnInit() {
35+
public ngOnInit():void {
3036
this.uncheckable = typeof this.uncheckable !== 'undefined';
3137
}
3238

3339
// hack view model!
34-
protected get value() {
40+
protected get value():any {
3541
return this.cd.viewModel;
3642
}
3743

38-
protected set value(value) {
44+
protected set value(value:any) {
3945
this.cd.viewModel = value;
4046
}
4147

4248
// ControlValueAccessor
4349
// model -> view
44-
public writeValue(value:any) {
50+
public writeValue(value:any):void {
4551
this.value = value;
4652
}
4753

48-
public onChange = (_:any) => {};
49-
public onTouched = () => {};
54+
public onChange:any = () => {};
55+
public onTouched:any = () => {};
5056

5157
public registerOnChange(fn:(_:any) => {}):void {
5258
this.onChange = fn;

0 commit comments

Comments
 (0)