Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit f3205f5

Browse files
Foxandxsswardbell
authored andcommitted
chore: first sweep on linting the codebase
closes #1616
1 parent 7e52648 commit f3205f5

File tree

239 files changed

+701
-688
lines changed

Some content is hidden

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

239 files changed

+701
-688
lines changed

gulpfile.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,15 @@ gulp.task('_zip-examples', function() {
636636
// Linting
637637

638638
gulp.task('lint', function() {
639-
return gulp.src(['./public/docs/_examples/style-guide/ts/**/*.ts', '!./public/docs/_examples/style-guide/ts/**/*.avoid.ts'])
639+
return gulp.src([
640+
'./public/docs/_examples/**/*.ts',
641+
'!./public/docs/_examples/**/ts-snippets/*.ts',
642+
'!./public/docs/_examples/style-guide/ts/**/*.avoid.ts',
643+
'!./public/docs/_examples/**/node_modules/**/*',
644+
'!./public/docs/_examples/_protractor/**/*',
645+
'!./public/docs/_examples/**/typings/**/*',
646+
'!./public/docs/_examples/**/typings-ng1/**/*'
647+
])
640648
.pipe(tslint({
641649
rulesDirectory: ['node_modules/codelyzer'],
642650
configuration: require('./tslint.json')

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"browser-sync": "^2.9.3",
3232
"canonical-path": "0.0.2",
3333
"cross-spawn": "^4.0.0",
34-
"codelyzer": "0.0.20",
34+
"codelyzer": "0.0.22",
3535
"del": "^2.2.0",
3636
"dgeni": "^0.4.0",
3737
"dgeni-packages": "^0.13.0",

public/docs/_examples/architecture/ts/app/backend.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const HEROES = [
1313
export class BackendService {
1414
constructor(private logger: Logger) {}
1515

16-
getAll(type:Type) : PromiseLike<any[]>{
16+
getAll(type: Type): PromiseLike<any[]> {
1717
if (type === Hero) {
1818
// TODO get from the database
1919
return Promise.resolve<Hero[]>(HEROES);

public/docs/_examples/architecture/ts/app/hero-detail.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input} from '@angular/core';
1+
import { Component, Input } from '@angular/core';
22

33
import { Hero } from './hero';
44

public/docs/_examples/architecture/ts/app/sales-tax.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class SalesTaxComponent {
3535
constructor(private salesTaxService: SalesTaxService) { }
3636
// #enddocregion ctor
3737

38-
getTax(value:string | number){
38+
getTax(value: string | number) {
3939
return this.salesTaxService.getVAT(value);
4040
}
4141
}

public/docs/_examples/architecture/ts/app/sales-tax.service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// #docregion
2-
import { Inject, Injectable } from '@angular/core';
2+
import { Inject, Injectable } from '@angular/core';
33

44
import { TaxRateService } from './tax-rate.service';
55

66
// #docregion class
77
@Injectable()
88
export class SalesTaxService {
99
constructor(private rateService: TaxRateService) { }
10-
getVAT(value:string | number){
11-
let amount:number;
12-
if (typeof value === "string"){
10+
getVAT(value: string | number) {
11+
let amount: number;
12+
if (typeof value === 'string') {
1313
amount = parseFloat(value);
1414
} else {
1515
amount = value;

public/docs/_examples/architecture/ts/app/tax-rate.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { Injectable } from '@angular/core';
44
// #docregion class
55
@Injectable()
66
export class TaxRateService {
7-
getRate(rateName:string){return 0.10;} // always 10% everywhere
7+
getRate(rateName: string) {return 0.10; } // always 10% everywhere
88
}
99
// #enddocregion class

public/docs/_examples/attribute-directives/ts/app/app.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ import { HighlightDirective } from './highlight.directive';
1111

1212
export class AppComponent { }
1313

14-
// #enddocregion
14+
// #enddocregion

public/docs/_examples/attribute-directives/ts/app/highlight.directive.2.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import { Directive, ElementRef, Input } from '@angular/core';
1414
export class HighlightDirective {
1515

1616
// #docregion ctor
17-
private el:HTMLElement;
17+
private el: HTMLElement;
1818
constructor(el: ElementRef) { this.el = el.nativeElement; }
1919
// #enddocregion ctor
2020

2121
// #docregion mouse-methods
22-
onMouseEnter() { this.highlight("yellow"); }
22+
onMouseEnter() { this.highlight('yellow'); }
2323
onMouseLeave() { this.highlight(null); }
2424

2525
private highlight(color: string) {

public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import { Directive, ElementRef, Input } from '@angular/core';
1313
export class HighlightDirective {
1414
private _defaultColor = 'red';
1515
private el: HTMLElement;
16-
16+
1717
constructor(el: ElementRef) { this.el = el.nativeElement; }
1818
// #enddocregion class-1
1919

2020
// #docregion defaultColor
21-
@Input() set defaultColor(colorName:string){
21+
@Input() set defaultColor(colorName: string){
2222
this._defaultColor = colorName || this._defaultColor;
2323
}
2424
// #enddocregion defaultColor
@@ -33,7 +33,7 @@ export class HighlightDirective {
3333
// #enddocregion mouse-enter
3434
onMouseLeave() { this.highlight(null); }
3535

36-
private highlight(color:string) {
36+
private highlight(color: string) {
3737
this.el.style.backgroundColor = color;
3838
}
3939
}

public/docs/_examples/cb-a1-a2-quick-reference/e2e-spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('Angular 1 to 2 Quick Reference Tests', function () {
8585

8686
posterButton.click().then(function () {
8787
testImagesAreDisplayed(isDisplayed);
88-
})
88+
});
8989
}
9090

9191
function getMovieRows() {
@@ -107,7 +107,7 @@ describe('Angular 1 to 2 Quick Reference Tests', function () {
107107
} else {
108108
expect(favoriteHeroLabel.isDisplayed()).toBe(false);
109109
}
110-
})
111-
})
110+
});
111+
});
112112
}
113113
});

public/docs/_examples/cb-a1-a2-quick-reference/ts/app/movie-list.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { StringSafeDatePipe } from './date.pipe';
1111
// #docregion component
1212
@Component({
1313
selector: 'movie-list',
14-
templateUrl:'app/movie-list.component.html',
14+
templateUrl: 'app/movie-list.component.html',
1515
// #enddocregion component
1616
// #docregion style-url
1717
styleUrls: ['app/movie-list.component.css'],

public/docs/_examples/cb-component-communication/e2e-spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ describe('Component Communication Cookbook Tests', function () {
2020
for (let i = 0; i < _heroNames.length; i++) {
2121
let childTitle = heroes.get(i).element(by.tagName('h3')).getText();
2222
let childDetail = heroes.get(i).element(by.tagName('p')).getText();
23-
expect(childTitle).toEqual(_heroNames[i] + ' says:')
24-
expect(childDetail).toContain(_masterName)
23+
expect(childTitle).toEqual(_heroNames[i] + ' says:');
24+
expect(childDetail).toContain(_masterName);
2525
}
2626
});
2727
// ...
@@ -38,7 +38,7 @@ describe('Component Communication Cookbook Tests', function () {
3838
let hero = parent.all(by.tagName('name-child')).get(_nonEmptyNameIndex);
3939

4040
let displayName = hero.element(by.tagName('h3')).getText();
41-
expect(displayName).toEqual(_nonEmptyName)
41+
expect(displayName).toEqual(_nonEmptyName);
4242
});
4343

4444
it('should replace empty name with default name', function () {
@@ -48,7 +48,7 @@ describe('Component Communication Cookbook Tests', function () {
4848
let hero = parent.all(by.tagName('name-child')).get(_emptyNameIndex);
4949

5050
let displayName = hero.element(by.tagName('h3')).getText();
51-
expect(displayName).toEqual(_defaultName)
51+
expect(displayName).toEqual(_defaultName);
5252
});
5353
// ...
5454
// #enddocregion parent-to-child-setter
@@ -83,7 +83,7 @@ describe('Component Communication Cookbook Tests', function () {
8383
expect(actual.label).toBe(labelAfter2Minor);
8484
expect(actual.count).toBe(3);
8585
expect(actual.logs.get(2).getText()).toBe(logAfter2Minor);
86-
})
86+
});
8787
});
8888
});
8989

@@ -155,11 +155,11 @@ describe('Component Communication Cookbook Tests', function () {
155155
// Can't run timer tests in protractor because
156156
// interaction w/ zones causes all tests to freeze & timeout.
157157
xdescribe('Parent calls child via local var', function() {
158-
countDownTimerTests('countdown-parent-lv')
158+
countDownTimerTests('countdown-parent-lv');
159159
});
160160

161161
xdescribe('Parent calls ViewChild', function() {
162-
countDownTimerTests('countdown-parent-vc')
162+
countDownTimerTests('countdown-parent-vc');
163163
});
164164

165165
function countDownTimerTests(parentTag: string) {

public/docs/_examples/cb-component-communication/ts/app/app.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let directives: any[] = [
1919
// Include Countdown examples
2020
// unless in e2e tests which they break.
2121
if (!/e2e/.test(location.search)) {
22-
console.log('adding countdown timer examples')
22+
console.log('adding countdown timer examples');
2323
directives.push(CountdownLocalVarParentComponent);
2424
directives.push(CountdownViewChildParentComponent);
2525
}

public/docs/_examples/cb-component-communication/ts/app/astronaut.component.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ import { Subscription } from 'rxjs/Subscription';
1717
</p>
1818
`
1919
})
20-
export class AstronautComponent implements OnDestroy{
20+
export class AstronautComponent implements OnDestroy {
2121
@Input() astronaut: string;
22-
mission = "<no mission announced>";
22+
mission = '<no mission announced>';
2323
confirmed = false;
2424
announced = false;
25-
subscription:Subscription;
25+
subscription: Subscription;
2626

2727
constructor(private missionService: MissionService) {
2828
this.subscription = missionService.missionAnnounced$.subscribe(
2929
mission => {
3030
this.mission = mission;
3131
this.announced = true;
3232
this.confirmed = false;
33-
})
33+
});
3434
}
3535

3636
confirm() {
3737
this.confirmed = true;
3838
this.missionService.confirmMission(this.astronaut);
3939
}
4040

41-
ngOnDestroy(){
41+
ngOnDestroy() {
4242
// prevent memory leak when component destroyed
4343
this.subscription.unsubscribe();
4444
}
4545
}
46-
// #enddocregion
46+
// #enddocregion

public/docs/_examples/cb-component-communication/ts/app/countdown-parent.component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CountdownTimerComponent } from './countdown-timer.component';
1111
//// Local variable, #timer, version
1212
// #docregion lv
1313
@Component({
14-
selector:'countdown-parent-lv',
14+
selector: 'countdown-parent-lv',
1515
template: `
1616
<h3>Countdown to Liftoff (via local variable)</h3>
1717
<button (click)="timer.start()">Start</button>
@@ -28,7 +28,7 @@ export class CountdownLocalVarParentComponent { }
2828
//// View Child version
2929
// #docregion vc
3030
@Component({
31-
selector:'countdown-parent-vc',
31+
selector: 'countdown-parent-vc',
3232
template: `
3333
<h3>Countdown to Liftoff (via ViewChild)</h3>
3434
<button (click)="start()">Start</button>
@@ -42,18 +42,18 @@ export class CountdownLocalVarParentComponent { }
4242
export class CountdownViewChildParentComponent implements AfterViewInit {
4343

4444
@ViewChild(CountdownTimerComponent)
45-
private timerComponent:CountdownTimerComponent;
45+
private timerComponent: CountdownTimerComponent;
4646

4747
seconds() { return 0; }
4848

4949
ngAfterViewInit() {
5050
// Redefine `seconds()` to get from the `CountdownTimerComponent.seconds` ...
5151
// but wait a tick first to avoid one-time devMode
5252
// unidirectional-data-flow-violation error
53-
setTimeout(() => this.seconds = () => this.timerComponent.seconds, 0)
53+
setTimeout(() => this.seconds = () => this.timerComponent.seconds, 0);
5454
}
5555

56-
start(){ this.timerComponent.start(); }
56+
start() { this.timerComponent.start(); }
5757
stop() { this.timerComponent.stop(); }
5858
}
5959
// #enddocregion vc

public/docs/_examples/cb-component-communication/ts/app/countdown-timer.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class CountdownTimerComponent implements OnInit, OnDestroy {
1111
message = '';
1212
seconds = 11;
1313

14-
clearTimer() {clearInterval(this.intervalId);}
14+
clearTimer() { clearInterval(this.intervalId); }
1515

1616
ngOnInit() { this.start(); }
1717
ngOnDestroy() { this.clearTimer(); }

public/docs/_examples/cb-component-communication/ts/app/hero.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export const HEROES = [
66
{name: 'Mr. IQ'},
77
{name: 'Magneta'},
88
{name: 'Bombasto'}
9-
];
9+
];

public/docs/_examples/cb-component-communication/ts/app/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import { bootstrap } from '@angular/platform-browser-dynamic';
22

33
import { AppComponent } from './app.component';
44

5-
bootstrap(AppComponent);
5+
bootstrap(AppComponent);

public/docs/_examples/cb-component-communication/ts/app/mission.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion
2-
import { Injectable } from '@angular/core'
2+
import { Injectable } from '@angular/core';
33
import { Subject } from 'rxjs/Subject';
44

55
@Injectable()
@@ -15,7 +15,7 @@ export class MissionService {
1515

1616
// Service message commands
1717
announceMission(mission: string) {
18-
this.missionAnnouncedSource.next(mission)
18+
this.missionAnnouncedSource.next(mission);
1919
}
2020

2121
confirmMission(astronaut: string) {

public/docs/_examples/cb-component-communication/ts/app/missioncontrol.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { MissionService } from './mission.service';
2121
providers: [MissionService]
2222
})
2323
export class MissionControlComponent {
24-
astronauts = ['Lovell', 'Swigert', 'Haise']
24+
astronauts = ['Lovell', 'Swigert', 'Haise'];
2525
history: string[] = [];
2626
missions = ['Fly to the moon!',
2727
'Fly to mars!',
@@ -32,7 +32,7 @@ export class MissionControlComponent {
3232
missionService.missionConfirmed$.subscribe(
3333
astronaut => {
3434
this.history.push(`${astronaut} confirmed the mission`);
35-
})
35+
});
3636
}
3737

3838
announce() {

public/docs/_examples/cb-component-communication/ts/app/version-child.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class VersionChildComponent implements OnChanges {
1717
@Input() minor: number;
1818
changeLog: string[] = [];
1919

20-
ngOnChanges(changes: {[propKey:string]: SimpleChange}){
20+
ngOnChanges(changes: {[propKey: string]: SimpleChange}) {
2121
let log: string[] = [];
2222
for (let propName in changes) {
2323
let changedProp = changes[propName];

public/docs/_examples/cb-component-communication/ts/app/voter.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export class VoterComponent {
1414
@Output() onVoted = new EventEmitter<boolean>();
1515
voted = false;
1616

17-
vote(agreed:boolean){
17+
vote(agreed: boolean) {
1818
this.onVoted.emit(agreed);
1919
this.voted = true;
2020
}
2121
}
22-
// #enddocregion
22+
// #enddocregion

public/docs/_examples/cb-component-communication/ts/app/votetaker.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { VoterComponent } from './voter.component';
1818
export class VoteTakerComponent {
1919
agreed = 0;
2020
disagreed = 0;
21-
voters = ['Mr. IQ', 'Ms. Universe', 'Bombasto']
21+
voters = ['Mr. IQ', 'Ms. Universe', 'Bombasto'];
2222

2323
onVoted(agreed: boolean) {
2424
agreed ? this.agreed++ : this.disagreed++;

public/docs/_examples/cb-component-relative-paths/e2e-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Cookbook: component-relative paths', function () {
1212
title: element( by.tagName( 'h1' )),
1313
absComp: element( by.css( 'absolute-path div' ) ),
1414
relComp: element( by.css( 'relative-path div' ) )
15-
}
15+
};
1616
}
1717

1818
let page: Page;

public/docs/_examples/cb-component-relative-paths/ts/app/app.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// #docregion
22
import { Component } from '@angular/core';
33

4-
import { SomeAbsoluteComponent, SomeRelativeComponent} from './some.component';
4+
import { SomeAbsoluteComponent, SomeRelativeComponent } from './some.component';
55

66
@Component({
77
selector: 'my-app',

0 commit comments

Comments
 (0)