Skip to content

Commit

Permalink
fix(lint): enable tslint and codelyzer (fixes valor-software#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin committed Apr 3, 2016
1 parent 232b8ae commit b60ce40
Show file tree
Hide file tree
Showing 65 changed files with 1,429 additions and 1,324 deletions.
19 changes: 12 additions & 7 deletions components/accordion/accordion-group.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {Component, OnInit, OnDestroy, Input, HostBinding, Inject} from 'angular2/core';
import {
Component, OnInit, OnDestroy, Input, HostBinding, Inject
} from 'angular2/core';
import {NgClass} from 'angular2/common';

import {Collapse} from '../collapse';
import {Accordion} from './accordion.component';

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

@HostBinding('class.panel-open')
@Input() public get isOpen():boolean {
@Input()
public get isOpen():boolean {
return this._isOpen;
}

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

private _isOpen:boolean;
private accordion:Accordion;

constructor(@Inject(Accordion) private accordion:Accordion) {
public constructor(@Inject(Accordion) accordion:Accordion) {
this.accordion = accordion;
}

ngOnInit() {
public ngOnInit():any {
this.panelClass = this.panelClass || 'panel-default';
this.accordion.addGroup(this);
}

ngOnDestroy() {
public ngOnDestroy():any {
this.accordion.removeGroup(this);
}

public toggleOpen(event:MouseEvent) {
public toggleOpen(event:MouseEvent):any {
event.preventDefault();
if (!this.isDisabled) {
this.isOpen = !this.isOpen;
Expand Down
13 changes: 7 additions & 6 deletions components/accordion/accordion.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Component, Input, HostBinding} from 'angular2/core';

import {AccordionPanel} from './accordion-group.component';

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

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

constructor() {
public constructor() {
}

private groups:Array<AccordionPanel> = [];

public closeOtherPanels(openGroup:AccordionPanel) {
public closeOtherPanels(openGroup:AccordionPanel):void {
if (!this.closeOthers) {
return;
}
Expand All @@ -30,11 +31,11 @@ export class Accordion {
});
}

public addGroup(group:AccordionPanel) {
public addGroup(group:AccordionPanel):void {
this.groups.push(group);
}

public removeGroup(group:AccordionPanel) {
public removeGroup(group:AccordionPanel):void {
let index = this.groups.indexOf(group);
if (index !== -1) {
this.groups.splice(index, 1);
Expand Down
12 changes: 3 additions & 9 deletions components/alert/alert.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
it,
inject,
injectAsync,
beforeEachProviders,
TestComponentBuilder
} from 'angular2/testing';

import {it, inject, beforeEachProviders} from 'angular2/testing';
import {Alert} from './alert.component';

describe('Alert', () => {
Expand All @@ -14,6 +7,7 @@ describe('Alert', () => {
]);

it('should have default type', inject([Alert], (alert:Alert) => {
expect(alert.type).toEqual('warning');
expect(alert.type)
.toEqual('warning');
}));
});
10 changes: 5 additions & 5 deletions components/alert/alert.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, Input, Output, EventEmitter } from 'angular2/core';
import { NgIf, NgClass } from 'angular2/common';
import {Component, OnInit, Input, Output, EventEmitter} from 'angular2/core';
import {NgIf, NgClass} from 'angular2/common';

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

constructor() {}
public constructor() {}

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

// todo: mouse event + touch + pointer
onClose() {
public onClose():void {
this.closed = true;
this.close.emit(this);
}
Expand Down
2 changes: 1 addition & 1 deletion components/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import {ButtonRadio} from './buttons/button-radio.component';

export {ButtonCheckbox} from './buttons/button-checkbox.component';
export {ButtonRadio} from './buttons/button-radio.component';
export const BUTTON_DIRECTIVES = [ButtonCheckbox, ButtonRadio];
export const BUTTON_DIRECTIVES:Array<any> = [ButtonCheckbox, ButtonRadio];
47 changes: 27 additions & 20 deletions components/buttons/button-checkbox.component.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,62 @@
import { Directive, OnInit, Input, HostBinding, HostListener,
Self, Renderer, ElementRef } from 'angular2/core';
import { ControlValueAccessor, NgModel } from 'angular2/common';
import {
Directive, OnInit, Input, HostBinding, HostListener, Self
} from 'angular2/core';
import {ControlValueAccessor, NgModel} from 'angular2/common';

@Directive({ selector: '[btnCheckbox][ngModel]' })
@Directive({selector: '[btnCheckbox][ngModel]'})
export class ButtonCheckbox implements ControlValueAccessor, OnInit {
@Input() private btnCheckboxTrue:any;
@Input() private btnCheckboxFalse:any;
public cd:NgModel;
@Input() public btnCheckboxTrue:any;

@Input() public btnCheckboxFalse:any;
@HostBinding('class.active')
private state:boolean = false;
public state:boolean = false;

private value:any;

// view -> model
@HostListener('click')
private onClick() {
public onClick():void {
this.toggle(!this.state);
this.cd.viewToModelUpdate(this.value);
}

private value:any;

constructor(@Self() public cd:NgModel) {
public constructor(@Self() cd:NgModel) {
this.cd = cd;
// hack !
cd.valueAccessor = this;
}

public ngOnInit() {
public ngOnInit():any {
this.toggle(this.trueValue === this.value);
}

private get trueValue() {
return typeof this.btnCheckboxTrue !== 'undefined' ? this.btnCheckboxTrue : true;
private get trueValue():boolean {
return typeof this.btnCheckboxTrue !== 'undefined'
? this.btnCheckboxTrue
: true;
}

private get falseValue() {
return typeof this.btnCheckboxFalse !== 'undefined' ? this.btnCheckboxFalse : false;
private get falseValue():boolean {
return typeof this.btnCheckboxFalse !== 'undefined'
? this.btnCheckboxFalse
: false;
}

private toggle(state:boolean) {
public toggle(state:boolean):void {
this.state = state;
this.value = this.state ? this.trueValue : this.falseValue;
}

// ControlValueAccessor
// model -> view
public writeValue(value:any) {
public writeValue(value:any):void {
this.state = this.trueValue === value;
this.value = value;
}

protected onChange = (_:any) => {};
protected onTouched = () => {};
protected onChange:any = () => {};
protected onTouched:any = () => {};

public registerOnChange(fn:(_:any) => {}):void {
this.onChange = fn;
Expand Down
34 changes: 20 additions & 14 deletions components/buttons/button-radio.component.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,58 @@
import { Directive, OnInit, Input, HostBinding, HostListener,
Self, ElementRef } from 'angular2/core';
import { ControlValueAccessor, NgModel } from 'angular2/common';
import {
Directive, OnInit, Input, HostBinding, HostListener, Self, ElementRef
} from 'angular2/core';
import {ControlValueAccessor, NgModel} from 'angular2/common';

@Directive({ selector: '[btnRadio][ngModel]' })
@Directive({selector: '[btnRadio][ngModel]'})
export class ButtonRadio implements ControlValueAccessor, OnInit {
public cd:NgModel;
public el:ElementRef;

@Input() private btnRadio:string;
@Input() private uncheckable:boolean;

@HostBinding('class.active')
private get isActive() {
public get isActive():boolean {
return this.btnRadio === this.value;
}

@HostListener('click')
private onClick() {
public onClick():void {
if (this.uncheckable && this.btnRadio === this.value) {
return this.cd.viewToModelUpdate(null);
return this.cd.viewToModelUpdate(void 0);
}

this.cd.viewToModelUpdate(this.btnRadio);
}

constructor(@Self() public cd:NgModel, public el:ElementRef) {
public constructor(@Self() cd:NgModel, el:ElementRef) {
// hack!
this.cd = cd;
this.el = el;
cd.valueAccessor = this;
}

public ngOnInit() {
public ngOnInit():void {
this.uncheckable = typeof this.uncheckable !== 'undefined';
}

// hack view model!
protected get value() {
protected get value():any {
return this.cd.viewModel;
}

protected set value(value) {
protected set value(value:any) {
this.cd.viewModel = value;
}

// ControlValueAccessor
// model -> view
public writeValue(value:any) {
public writeValue(value:any):void {
this.value = value;
}

public onChange = (_:any) => {};
public onTouched = () => {};
public onChange:any = () => {};
public onTouched:any = () => {};

public registerOnChange(fn:(_:any) => {}):void {
this.onChange = fn;
Expand Down
Loading

0 comments on commit b60ce40

Please sign in to comment.