Skip to content

Commit aed76bc

Browse files
authored
Merge pull request yannbf#42 from yannbf/feature/add-lint
feat(lint): Add tslint + Refactor
2 parents 29e5a6a + 8fd48db commit aed76bc

File tree

150 files changed

+1881
-1836
lines changed

Some content is hidden

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

150 files changed

+1881
-1836
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@
3535
"moment": "^2.15.2",
3636
"rxjs": "5.4.0",
3737
"sw-toolbox": "3.6.0",
38+
"tslint-config-airbnb": "^5.2.1",
3839
"zone.js": "^0.8.12"
3940
},
4041
"devDependencies": {
41-
"@ionic/app-scripts": "2.0.1",
42+
"@ionic/app-scripts": "2.0.2",
4243
"@ionic/cli-plugin-cordova": "1.4.1",
4344
"@ionic/cli-plugin-ionic-angular": "1.3.2",
4445
"typescript": "~2.3.4"

src/app/app.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ export class MyApp {
3737
{ icon: 'camera', active: false },
3838
{ icon: 'beer', active: false },
3939
{ icon: 'power', active: false },
40-
]
40+
];
4141

4242
this.pages = [
4343
{ title: 'Home', component: 'HomePage', active: true, icon: 'home' },
44-
{ title: 'Ionic Official Components', component: 'IonicOfficialComponentsPage', active: false, icon: 'ionic' },
44+
{ title: 'Ionic Official Components',
45+
component: 'IonicOfficialComponentsPage', active: false, icon: 'ionic' },
4546
{ title: 'Ionic Native Features', component: 'IonicNativePage', active: false, icon: 'ionic' },
4647
{ title: 'Login', component: 'LoginListPage', active: false, icon: 'archive' },
4748
{ title: 'Lists', component: 'ListPage', active: false, icon: 'body' },

src/app/app.global.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
import { Injectable } from '@angular/core';
22
@Injectable()
33
export class AppState {
4-
_state = {}
5-
constructor() {
6-
}
7-
// already return a clone of the current state
8-
get state() {
9-
return this._state = this._clone(this._state);
10-
}
11-
// never allow mutation
12-
set state(value) {
13-
throw new Error('do not mutate the `.state` directly');
14-
}
15-
get(prop?: any) {
16-
// use our state getter for the clone
17-
const state = this.state;
18-
return state.hasOwnProperty(prop) ? state[prop] : state;
19-
}
20-
set(prop: string, value: any) {
21-
// internally mutate our state
22-
return this._state[prop] = value;
23-
}
24-
_clone(object) {
25-
// simple object clone
26-
return JSON.parse(JSON.stringify(object));
27-
}
28-
}
4+
_state = {};
5+
6+
// already return a clone of the current state
7+
get state() {
8+
return this._state = this.clone(this._state);
9+
}
10+
11+
// never allow mutation
12+
set state(value) {
13+
throw new Error('do not mutate the `.state` directly');
14+
}
15+
16+
get(prop?: any) {
17+
// use our state getter for the clone
18+
const state = this.state;
19+
return state.hasOwnProperty(prop) ? state[prop] : state;
20+
}
21+
22+
set(prop: string, value: any) {
23+
// internally mutate our state
24+
return this._state[prop] = value;
25+
}
26+
27+
private clone(object) {
28+
// simple object clone
29+
return JSON.parse(JSON.stringify(object));
30+
}
31+
}

src/app/app.imports.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,44 @@ import { SwingModule } from 'angular2-swing';
3939
import { BrowserModule } from '@angular/platform-browser';
4040
import { HttpModule } from '@angular/http';
4141

42-
export const Modules = [
43-
SwingModule,
44-
BrowserModule,
45-
HttpModule,
46-
]
42+
export const MODULES = [
43+
SwingModule,
44+
BrowserModule,
45+
HttpModule,
46+
];
4747

48-
export const Pipes = [
49-
TemperaturePipe, MomentPipe, OrderByPipe, CapitalizePipe, ShortenStringPipe
50-
]
48+
export const PIPES = [
49+
TemperaturePipe, MomentPipe, OrderByPipe, CapitalizePipe, ShortenStringPipe
50+
];
5151

52-
export const Providers = [
53-
AlertService,
54-
ToastService,
55-
AppState,
56-
CameraProvider,
57-
NativeGoogleMapsProvider,
52+
export const PROVIDERS = [
53+
AlertService,
54+
ToastService,
55+
AppState,
56+
CameraProvider,
57+
NativeGoogleMapsProvider,
5858

5959
// Ionic native specific providers
60-
BarcodeScanner,
61-
Camera,
62-
Diagnostic,
63-
Geolocation,
64-
CardIO,
65-
StatusBar,
66-
SplashScreen,
67-
GoogleMaps,
68-
]
60+
BarcodeScanner,
61+
Camera,
62+
Diagnostic,
63+
Geolocation,
64+
CardIO,
65+
StatusBar,
66+
SplashScreen,
67+
GoogleMaps,
68+
];
6969

70-
export const Components = [
71-
FlashCardComponent,
72-
TimerProgress,
73-
Timer,
74-
ExpandableHeader,
75-
Autosize
76-
]
70+
export const COMPONENTS = [
71+
FlashCardComponent,
72+
TimerProgress,
73+
Timer,
74+
ExpandableHeader,
75+
Autosize
76+
];
7777

78-
export const Directives = [
79-
SlidingDrawer,
80-
Timer,
81-
Autosize,
82-
]
78+
export const DIRECTIVES = [
79+
SlidingDrawer,
80+
Timer,
81+
Autosize,
82+
];

src/app/app.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ import { NgModule, ErrorHandler } from '@angular/core';
33
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
44
import { MyApp } from './app.component';
55

6-
import { Modules, Providers } from './app.imports';
6+
import { MODULES, PROVIDERS } from './app.imports';
77

88
@NgModule({
99
declarations: [
1010
// App Core
1111
MyApp,
1212
],
1313
imports: [
14-
Modules,
14+
MODULES,
1515
IonicModule.forRoot(MyApp),
1616
SharedModule,
1717
],
1818
bootstrap: [IonicApp],
1919
entryComponents: [
2020
MyApp,
2121
],
22-
providers: [Providers, { provide: ErrorHandler, useClass: IonicErrorHandler }]
22+
providers: [PROVIDERS, { provide: ErrorHandler, useClass: IonicErrorHandler }]
2323
})
2424
export class AppModule { }

src/app/shared.module.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { Components, Directives, Pipes } from './app.imports';
1+
import { COMPONENTS, DIRECTIVES, PIPES } from './app.imports';
22
import { NgModule } from '@angular/core';
33
import { IonicModule } from 'ionic-angular';
44

55
@NgModule({
6-
declarations: [
7-
Pipes,
8-
Directives,
9-
Components
10-
],
11-
imports: [
12-
IonicModule,
13-
],
14-
exports: [
15-
Pipes,
16-
Components
17-
]
6+
declarations: [
7+
PIPES,
8+
DIRECTIVES,
9+
COMPONENTS
10+
],
11+
imports: [
12+
IonicModule,
13+
],
14+
exports: [
15+
PIPES,
16+
COMPONENTS
17+
]
1818
})
1919

20-
export class SharedModule { }
20+
export class SharedModule { }

src/components/autosize/autosize.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ElementRef, HostListener, Directive, OnInit} from '@angular/core';
1+
import { ElementRef, HostListener, Directive, OnInit } from '@angular/core';
22

33
@Directive({
44
selector: 'ion-textarea[autosize]'
@@ -18,9 +18,9 @@ export class Autosize implements OnInit {
1818
}
1919

2020
adjust():void {
21-
let textArea = this.element.nativeElement.getElementsByTagName('textarea')[0];
21+
const textArea = this.element.nativeElement.getElementsByTagName('textarea')[0];
2222
textArea.style.overflow = 'hidden';
2323
textArea.style.height = 'auto';
24-
textArea.style.height = textArea.scrollHeight + "px";
24+
textArea.style.height = textArea.scrollHeight + 'px';
2525
}
26-
}
26+
}

0 commit comments

Comments
 (0)