Skip to content

Commit 1633f12

Browse files
sis0k0hdeshev
authored andcommitted
refactor: lint test apps
1 parent f9ad6a5 commit 1633f12

Some content is hidden

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

64 files changed

+771
-436
lines changed

Diff for: nativescript-angular/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
"devDependencies": {
4343
"@angular/animations": "4.0.0-rc.5",
4444
"@angular/compiler-cli": "4.0.0-rc.5",
45-
"codelyzer": "~2.0.0",
45+
"codelyzer": "~3.0.0-beta.4",
4646
"tns-core-modules": "internal-preview",
47-
"tslint": "~4.4.0",
47+
"tslint": "~4.5.0",
4848
"typescript": "~2.2.1",
4949
"zone.js": "^0.8.2"
5050
},

Diff for: nativescript-angular/renderer.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ import { View } from "tns-core-modules/ui/core/view";
1010
import { addCss } from "tns-core-modules/application";
1111
import { topmost } from "tns-core-modules/ui/frame";
1212

13-
import { APP_ROOT_VIEW, DEVICE } from "./platform-providers";
13+
import { APP_ROOT_VIEW, DEVICE, getRootPage } from "./platform-providers";
1414
import { isBlank } from "./lang-facade";
1515
import { ViewUtil } from "./view-util";
1616
import { NgView } from "./element-registry";
1717
import { rendererLog as traceLog } from "./trace";
18-
import { escapeRegexSymbols } from "tns-core-modules/utils/utils";
19-
import { Device } from "tns-core-modules/platform";
20-
import { getRootPage } from "./platform-providers";
2118

2219
// CONTENT_ATTR not exported from NativeScript_renderer - we need it for styles application.
2320
const COMPONENT_REGEX = /%COMP%/g;

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function makeExampleModule(componentType) {
6868
ExampleModule,
6969
];
7070
if (componentType.routes) {
71-
imports.push(NativeScriptRouterModule.forRoot(componentType.routes))
71+
imports.push(NativeScriptRouterModule.forRoot(componentType.routes));
7272
}
7373
let exports: any[] = [];
7474
if (componentType.exports) {
@@ -133,11 +133,11 @@ const customPageFactoryProvider = {
133133
// animations
134134
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationStatesTest));
135135
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationNgClassTest));
136-
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationKeyframesTest));
137-
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
136+
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationKeyframesTest));
137+
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
138138

139-
//Livesync test
140-
var cachedUrl: string;
139+
// Livesync test
140+
let cachedUrl: string;
141141
onBeforeLivesync.subscribe((moduleRef) => {
142142
console.log("------- onBeforeLivesync");
143143
if (moduleRef) {
@@ -156,5 +156,5 @@ onAfterLivesync.subscribe((moduleRef) => {
156156
}
157157
});
158158

159-
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
159+
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
160160
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

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
import {Component, trigger, style, animate, state, transition, keyframes } from '@angular/core';
1+
import {Component, trigger, style, animate, state, transition, keyframes } 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('active', style({ transform: 'translateX(0)', opacity: 1 })),
12-
state('inactive', style({ transform: 'translateX(0)', opacity: 0.2 })),
13-
transition('inactive => active', [
10+
trigger("state", [
11+
state("active", style({ transform: "translateX(0)", opacity: 1 })),
12+
state("inactive", style({ transform: "translateX(0)", opacity: 0.2 })),
13+
transition("inactive => active", [
1414
animate(300, keyframes([
15-
style({opacity: 0.2, transform: 'translateX(-100),translateY(100)', offset: 0}),
16-
style({opacity: 1, transform: 'translateX(15)', offset: 0.3}),
17-
style({opacity: 1, transform: 'translateX(0)', offset: 1.0})
15+
style({opacity: 0.2, transform: "translateX(-100),translateY(100)", offset: 0}),
16+
style({opacity: 1, transform: "translateX(15)", offset: 0.3}),
17+
style({opacity: 1, transform: "translateX(0)", offset: 1.0})
1818
]))
1919
]),
20-
transition('active => inactive', [
20+
transition("active => inactive", [
2121
animate(300, keyframes([
22-
style({opacity: 1, transform: 'translateX(0)', offset: 0}),
23-
style({opacity: 1, transform: 'translateX(-15)', offset: 0.7}),
24-
style({opacity: 0.2, transform: 'translateX(100)', offset: 1.0})
22+
style({opacity: 1, transform: "translateX(0)", offset: 0}),
23+
style({opacity: 1, transform: "translateX(-15)", offset: 0.7}),
24+
style({opacity: 0.2, transform: "translateX(100)", offset: 1.0})
2525
]))
2626
])
2727
])
2828
]
2929
})
3030
export class AnimationKeyframesTest {
31-
31+
3232
isOn = false;
3333

3434
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)