Skip to content

Commit c7837ed

Browse files
committed
refactor: lint test apps
1 parent 150c1ce commit c7837ed

Some content is hidden

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

62 files changed

+788
-446
lines changed

Diff for: ng-sample/app/app.ts

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
//import "globals";
2-
// import "./modules";
3-
//global.registerModule("./main-page", function () { return require("./main-page"); });
1+
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
2+
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
3+
import { NativeScriptAnimationsModule } from "nativescript-angular/animations";
44

5-
//import * as profiling from "./profiling";
6-
//profiling.start("application-start");
7-
8-
// "nativescript-angular/application" import should be first in order to load some required settings (like globals and reflect-metadata)
9-
import { NativeScriptModule, platformNativeScriptDynamic } from "nativescript-angular/platform";
105
import { onAfterLivesync, onBeforeLivesync } from "nativescript-angular/platform-common";
116
import { NgModule } from "@angular/core";
127
import { Router } from "@angular/router";
@@ -69,9 +64,9 @@ import { AnimationStatesTest } from "./examples/animation/animation-states-test"
6964
class ExampleModule { }
7065

7166
function makeExampleModule(componentType) {
72-
let imports: any[] = [ExampleModule];
67+
let imports: any[] = [ExampleModule, NativeScriptAnimationsModule];
7368
if (componentType.routes) {
74-
imports.push(NativeScriptRouterModule.forRoot(componentType.routes))
69+
imports.push(NativeScriptRouterModule.forRoot(componentType.routes));
7570
}
7671
let exports: any[] = [];
7772
if (componentType.exports) {
@@ -111,7 +106,7 @@ const customPageFactoryProvider = {
111106
}
112107
};
113108

114-
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(RendererTest));
109+
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(RendererTest));
115110
// platformNativeScriptDynamic(undefined, [customPageFactoryProvider]).bootstrapModule(makeExampleModule(RendererTest));
116111
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(TabViewTest));
117112
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(Benchmark));
@@ -135,10 +130,10 @@ platformNativeScriptDynamic().bootstrapModule(makeExampleModule(RendererTest));
135130
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationStatesTest));
136131
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationNgClassTest));
137132
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationKeyframesTest));
138-
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
133+
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
139134

140-
//Livesync test
141-
var cachedUrl: string;
135+
// Livesync test
136+
let cachedUrl: string;
142137
onBeforeLivesync.subscribe((moduleRef) => {
143138
console.log("------- onBeforeLivesync");
144139
if (moduleRef) {
@@ -157,5 +152,5 @@ onAfterLivesync.subscribe((moduleRef) => {
157152
}
158153
});
159154

160-
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
155+
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
161156
console.log("APP RESTART");

Diff for: ng-sample/app/examples/action-bar/action-bar-test.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component } from '@angular/core';
2-
import { Page} from "ui/page";
1+
import { Component } from "@angular/core";
2+
import { Page } from "ui/page";
33

44
@Component({
55
selector: "first",
@@ -29,7 +29,6 @@ class FirstComponent {
2929
@Component({
3030
selector: "nested-component",
3131
template: `
32-
3332
<ActionBarExtension>
3433
<ActionItem *ngIf="show" (tap)="onTap()">
3534
<Button text="CUSTOM"></Button>
@@ -70,7 +69,7 @@ class SecondComponent {
7069
}
7170

7271
@Component({
73-
selector: 'action-bar-test',
72+
selector: "action-bar-test",
7473
template: `
7574
<GridLayout>
7675
<page-router-outlet></page-router-outlet>
@@ -79,14 +78,12 @@ class SecondComponent {
7978
})
8079
export class ActionBarTest {
8180
static routes = [
82-
{ path: '', component: FirstComponent },
83-
{ path: 'second', component: SecondComponent },
84-
]
81+
{ path: "", component: FirstComponent },
82+
{ path: "second", component: SecondComponent },
83+
];
8584

8685
static entries = [
8786
FirstComponent,
8887
SecondComponent,
89-
]
88+
];
9089
}
91-
92-

Diff for: ng-sample/app/examples/animation/animation-enter-leave-test.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
import {Component, trigger, style, animate, state, transition } from '@angular/core';
1+
import {Component, trigger, style, animate, state, transition } from "@angular/core";
22

33
@Component({
4-
selector: 'animation-enter-leave',
5-
templateUrl: './examples/animation/animation-enter-leave-test.html',
6-
styleUrls: [ './examples/animation/animation-enter-leave-test.css' ],
4+
selector: "animation-enter-leave",
5+
templateUrl: "./examples/animation/animation-enter-leave-test.html",
6+
styleUrls: [ "./examples/animation/animation-enter-leave-test.css" ],
77
animations: [
8-
trigger('state', [
9-
state('in', style({ 'background-color': 'red', 'opacity': 1 })),
10-
state('void', style({ 'background-color': 'white', 'opacity': 0 })),
11-
transition('void => *', [ animate('600ms ease-out') ]),
12-
transition('* => void', [ animate('600ms ease-out')])
8+
trigger("state", [
9+
state("in", style({ "background-color": "red", "opacity": 1 })),
10+
state("void", style({ "background-color": "white", "opacity": 0 })),
11+
transition("void => *", [ animate("600ms ease-out") ]),
12+
transition("* => void", [ animate("600ms ease-out")])
1313
])
1414
]
1515
})
1616
export class AnimationEnterLeaveTest {
17-
17+
1818
public items: Array<string>;
1919

2020
constructor() {
2121
this.items = [];
22-
for (var i = 0; i < 3; i++) {
22+
for (let i = 0; i < 3; i++) {
2323
this.items.push("Item " + i);
2424
}
2525
}
26-
26+
2727
onAddTap() {
2828
this.items.push("Item " + (this.items.length + 1));
2929
}
30-
30+
3131
onRemoveAllTap() {
3232
this.items = [];
3333
}
34-
34+
3535
onItemTap(event) {
36-
var index = this.items.indexOf(event.object.text);
36+
let index = this.items.indexOf(event.object.text);
3737
this.items.splice(index, 1);
3838
}
3939
}

Diff for: ng-sample/app/examples/animation/animation-keyframes-test.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
import { Component } from '@angular/core';
2-
import { trigger, style, animate, state, transition, keyframes } from '@angular/animations';
1+
import { Component } from "@angular/core";
2+
import { trigger, style, animate, state, transition, keyframes } from "@angular/animations";
33

44
@Component({
5-
selector: 'animation-states',
5+
selector: "animation-states",
66
template: `
77
<StackLayout>
88
<Button text="Touch me!" [@state]=" isOn ? 'active' : 'inactive' " (tap)="onTap()"></Button>
99
</StackLayout>`,
1010
animations: [
11-
trigger('state', [
12-
state('active', style({ opacity: 1 })),
13-
state('inactive', style({ opacity: 0.2 })),
14-
transition('inactive => active', [
11+
trigger("state", [
12+
state("active", style({ opacity: 1 })),
13+
state("inactive", style({ opacity: 0.2 })),
14+
transition("inactive => active", [
1515
animate(300, keyframes([
16-
style({opacity: 0.2, transform: 'translateX(-100)', offset: 0}),
17-
style({opacity: 1, transform: 'translateX(15)', offset: 0.3}),
18-
style({opacity: 1, transform: 'translateX(0)', offset: 1.0})
16+
style({opacity: 0.2, transform: "translateX(-100),translateY(100)", offset: 0}),
17+
style({opacity: 1, transform: "translateX(15)", offset: 0.3}),
18+
style({opacity: 1, transform: "translateX(0)", offset: 1.0})
1919
]))
2020
]),
21-
transition('active => inactive', [
21+
transition("active => inactive", [
2222
animate(300, keyframes([
23-
style({opacity: 1, transform: 'translateX(0)', offset: 0}),
24-
style({opacity: 1, transform: 'translateX(-15)', offset: 0.7}),
25-
style({opacity: 0.2, transform: 'translateX(100)', offset: 1.0})
23+
style({opacity: 1, transform: "translateX(0)", offset: 0}),
24+
style({opacity: 1, transform: "translateX(-15)", offset: 0.7}),
25+
style({opacity: 0.2, transform: "translateX(100)", offset: 1.0})
2626
]))
2727
])
2828
])
2929
]
3030
})
3131
export class AnimationKeyframesTest {
32-
32+
3333
isOn = false;
3434

3535
onTap() {

Diff for: ng-sample/app/examples/animation/animation-ngclass-test.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ export class AnimationNgClassTest {
1313

1414
onTap() {
1515
this.isOn = !this.isOn;
16-
if (this.isOn) {
17-
this.text = "Toggled";
18-
}
19-
else {
20-
this.text = "Normal";
21-
}
16+
this.text = this.isOn ? "Toggled" : "Normal";
2217
}
2318
}

Diff for: ng-sample/app/examples/animation/animation-states-test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import {Component, trigger, style, animate, state, transition } from '@angular/core';
1+
import {Component, trigger, style, animate, state, transition } from "@angular/core";
22

33
@Component({
4-
selector: 'animation-states',
4+
selector: "animation-states",
55
template: `
66
<StackLayout>
77
<Button text="Touch me!" [@state]=" isOn ? 'active' : 'inactive' " (tap)="onTap()"></Button>
88
</StackLayout>`,
99
animations: [
10-
trigger('state', [
11-
state('inactive', style({ 'background-color': 'red' })),
12-
state('active', style({ 'background-color': 'green' })),
13-
transition('inactive => active', [ animate('600ms ease-out') ]),
14-
transition('active => inactive', [ animate('600ms ease-out') ]),
10+
trigger("state", [
11+
state("inactive", style({ "background-color": "red" })),
12+
state("active", style({ "background-color": "green" })),
13+
transition("inactive => active", [ animate("600ms ease-out") ]),
14+
transition("active => inactive", [ animate("600ms ease-out") ]),
1515
])
1616
]
1717
})
1818
export class AnimationStatesTest {
19-
19+
2020
isOn = false;
2121

2222
onTap() {

Diff for: ng-sample/app/examples/http/http-test.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import {Component} from '@angular/core';
2-
import {Http} from '@angular/http';
3-
import 'rxjs/add/operator/map';
1+
import {Component} from "@angular/core";
2+
import {Http} from "@angular/http";
3+
import "rxjs/add/operator/map";
44

55
/* IMPORTANT
6-
In order to test out the full image example, to fix the App Transport Security error in iOS 9, you will need to follow this after adding the iOS platform:
6+
In order to test out the full image example,
7+
to fix the App Transport Security error in iOS 9,
8+
you will need to follow this after adding the iOS platform:
79
810
https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativescript/
911
*/
1012

1113
@Component({
12-
selector: 'http-test',
14+
selector: "http-test",
1315
template: `
1416
<StackLayout horizontalAlignment="center">
1517
<Button text="Load Local File with Http" (tap)='loadLocal()' cssClass="btn-primary"></Button>
@@ -28,12 +30,12 @@ export class HttpTest {
2830
public title: string;
2931
public description: string;
3032

31-
constructor(private http: Http) {
32-
33+
constructor(private http: Http) {
34+
3335
}
34-
36+
3537
public loadLocal() {
36-
this.http.get('~/examples/http/data.json').map(res => res.json()).subscribe((response: any) => {
38+
this.http.get("~/examples/http/data.json").map(res => res.json()).subscribe((response: any) => {
3739
let user = response.results[0];
3840
this.title = user.title;
3941
this.description = user.description;

Diff for: ng-sample/app/examples/image/image-test.ts

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import {Component} from '@angular/core';
1+
import { Component } from "@angular/core";
22

33
/* IMPORTANT
4-
In order to test out the full image example, to fix the App Transport Security error in iOS 9, you will need to follow this after adding the iOS platform:
4+
In order to test out the full image example,
5+
to fix the App Transport Security error in iOS 9,
6+
you will need to follow this after adding the iOS platform:
57
68
https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativescript/
79
*/
810

911
@Component({
10-
selector: 'image-test',
12+
selector: "image-test",
1113
template: `
1214
<StackLayout horizontalAlignment="center">
1315
<Image [src]="currentImage" width="300" height="300"></Image>
@@ -22,19 +24,19 @@ https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativ
2224
`
2325
})
2426
export class ImageTest {
25-
27+
2628
public currentImage: string;
2729
private images: Array<string> = [
28-
'res://300x300.jpg',
29-
'~/examples/image/img/Default.png',
30-
'http://www.codeproject.com/KB/mobile/883465/NativeScript.png'
30+
"res://300x300.jpg",
31+
"~/examples/image/img/Default.png",
32+
"http://www.codeproject.com/KB/mobile/883465/NativeScript.png"
3133
];
3234
private cnt: number = 0;
3335

34-
constructor() {
36+
constructor() {
3537
this.currentImage = this.images[this.cnt];
3638
}
37-
39+
3840
changeImage(direction: number) {
3941
if (direction > 0) {
4042
this.cnt++;
@@ -50,12 +52,12 @@ export class ImageTest {
5052
}
5153
this.currentImage = this.images[this.cnt];
5254
}
53-
55+
5456
addImage(e: any, name: string): void {
55-
if (name.indexOf('http') === -1) {
57+
if (name.indexOf("http") === -1) {
5658
alert(`Must be a valid url to an image starting with 'http'!`);
5759
} else {
58-
this.images.push(name);
60+
this.images.push(name);
5961
this.currentImage = this.images[this.images.length - 1];
6062
}
6163
}

Diff for: ng-sample/app/examples/list/data.service.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@angular/core';
1+
import { Injectable } from "@angular/core";
22
import { BehaviorSubject } from "rxjs/BehaviorSubject";
33

44
export class DataItem {
@@ -10,13 +10,13 @@ export class DataService {
1010
private _intervalId;
1111
private _counter = 0;
1212
private _currentItems: Array<DataItem>;
13-
13+
1414
public items$: BehaviorSubject<Array<DataItem>>;
1515

1616
constructor() {
1717
this._currentItems = [];
18-
for (var i = 0; i < 3; i++) {
19-
this.appendItem()
18+
for (let i = 0; i < 3; i++) {
19+
this.appendItem();
2020
}
2121

2222
this.items$ = new BehaviorSubject(this._currentItems);
@@ -51,4 +51,5 @@ export class DataService {
5151
this._currentItems.push(new DataItem(this._counter, "data item " + this._counter));
5252
this._counter++;
5353
}
54-
}
54+
}
55+

0 commit comments

Comments
 (0)