Skip to content

Commit 4210d8a

Browse files
authored
Merge pull request #546 from NativeScript/hdeshev/lint
Linting
2 parents 2ae5b3b + a19fdc1 commit 4210d8a

Some content is hidden

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

52 files changed

+868
-617
lines changed

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ install:
3535
- tns error-reporting disable
3636
- cd nativescript-angular
3737
- npm install
38+
- npm run tslint
3839
- cd ../tests
3940
- npm install
4041
- tns platform add android

Diff for: nativescript-angular/.npmignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
tsconfig.json
99
global.d.ts
1010
.npmignore
11-
gulpfile.js
11+
gulpfile.js
12+
tslint.json

Diff for: nativescript-angular/animation-driver.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { AnimationPlayer } from "@angular/core";
22
import { AnimationStyles, AnimationKeyframe } from "./private_import_core";
3-
import { NativeScriptAnimationPlayer } from './animation-player';
3+
import { NativeScriptAnimationPlayer } from "./animation-player";
44
import { View } from "ui/core/view";
5-
import { getPropertyByCssName } from 'ui/styling/style-property';
5+
import { getPropertyByCssName } from "ui/styling/style-property";
66

77
export abstract class AnimationDriver {
88
abstract animate(
@@ -16,7 +16,14 @@ export class NativeScriptAnimationDriver implements AnimationDriver {
1616
return (<View>element).style._getValue(getPropertyByCssName(prop));
1717
}
1818

19-
animate(element: any, startingStyles: AnimationStyles, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string): AnimationPlayer {
19+
animate(
20+
element: any,
21+
_startingStyles: AnimationStyles,
22+
keyframes: AnimationKeyframe[],
23+
duration: number,
24+
delay: number,
25+
easing: string
26+
): AnimationPlayer {
2027
return new NativeScriptAnimationPlayer(element, keyframes, duration, delay, easing);
2128
}
2229
}

Diff for: nativescript-angular/animation-player.ts

+59-27
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { AnimationPlayer } from "@angular/core";
22
import { AnimationKeyframe } from "./private_import_core";
3-
import { KeyframeAnimation, KeyframeAnimationInfo, KeyframeInfo, KeyframeDeclaration } from 'ui/animation/keyframe-animation';
3+
import {
4+
KeyframeAnimation,
5+
KeyframeAnimationInfo,
6+
KeyframeInfo,
7+
KeyframeDeclaration
8+
} from "ui/animation/keyframe-animation";
49
import { View } from "ui/core/view";
510
import { AnimationCurve } from "ui/enums";
6-
import { ValueSource } from 'ui/core/dependency-observable';
11+
import { ValueSource } from "ui/core/dependency-observable";
712
import { isString } from "utils/types";
8-
import * as styleProperty from 'ui/styling/style-property';
13+
import * as styleProperty from "ui/styling/style-property";
914

1015
export class NativeScriptAnimationPlayer implements AnimationPlayer {
1116

@@ -18,7 +23,13 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
1823
private animation: KeyframeAnimation;
1924
private target: View;
2025

21-
constructor(element: Node, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string) {
26+
constructor(
27+
element: Node,
28+
keyframes: AnimationKeyframe[],
29+
duration: number,
30+
delay: number,
31+
easing: string
32+
) {
2233

2334
this.parentPlayer = null;
2435

@@ -36,7 +47,9 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
3647
keyframeAnimationInfo.duration = duration;
3748
keyframeAnimationInfo.delay = delay;
3849
keyframeAnimationInfo.iterations = 1;
39-
keyframeAnimationInfo.curve = easing ? NativeScriptAnimationPlayer.animationTimingFunctionConverter(easing) : AnimationCurve.ease;
50+
keyframeAnimationInfo.curve = easing ?
51+
NativeScriptAnimationPlayer.animationTimingFunctionConverter(easing) :
52+
AnimationCurve.ease;
4053
keyframeAnimationInfo.keyframes = new Array<KeyframeInfo>();
4154
keyframeAnimationInfo.isForwards = true;
4255

@@ -53,16 +66,16 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
5366
value = property.valueConverter(<string>value);
5467
}
5568
keyframeInfo.declarations.push({ property: property.name, value: value });
56-
}
57-
else if (typeof value === "string" && substyle === "transform") {
69+
} else if (typeof value === "string" && substyle === "transform") {
5870
NativeScriptAnimationPlayer.parseTransform(<string>value, keyframeInfo);
5971
}
6072
}
6173
}
6274
keyframeAnimationInfo.keyframes.push(keyframeInfo);
6375
}
6476

65-
this.animation = KeyframeAnimation.keyframeAnimationFromInfo(keyframeAnimationInfo, ValueSource.VisualState);
77+
this.animation = KeyframeAnimation.keyframeAnimationFromInfo(
78+
keyframeAnimationInfo, ValueSource.VisualState);
6679
}
6780

6881
init(): void {
@@ -98,7 +111,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
98111
this._onStart();
99112
this.animation.play(this.target)
100113
.then(() => { this._onFinish(); })
101-
.catch((e) => { });
114+
.catch((_e) => { });
102115
}
103116
}
104117

@@ -126,7 +139,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
126139
this._onFinish();
127140
}
128141

129-
setPosition(p: any): void {
142+
setPosition(_p: any): void {
130143
throw new Error("AnimationPlayer.setPosition method is not supported!");
131144
}
132145

@@ -159,8 +172,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
159172
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[1]),
160173
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[2]),
161174
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[3]));
162-
}
163-
else {
175+
} else {
164176
throw new Error("Invalid value for animation: " + value);
165177
}
166178
}
@@ -178,16 +190,14 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
178190
let operations = {};
179191
operations[value] = value;
180192
return operations;
181-
}
182-
else if (isString(value)) {
193+
} else if (isString(value)) {
183194
let operations = {};
184195
let operator = "";
185196
let pos = 0;
186197
while (pos < value.length) {
187198
if (value[pos] === " " || value[pos] === ",") {
188199
pos++;
189-
}
190-
else if (value[pos] === "(") {
200+
} else if (value[pos] === "(") {
191201
let start = pos + 1;
192202
while (pos < value.length && value[pos] !== ")") {
193203
pos++;
@@ -196,14 +206,12 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
196206
operations[operator] = operand.trim();
197207
operator = "";
198208
pos++;
199-
}
200-
else {
209+
} else {
201210
operator += value[pos++];
202211
}
203212
}
204213
return operations;
205-
}
206-
else {
214+
} else {
207215
return undefined;
208216
}
209217
}
@@ -215,29 +223,50 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
215223
for (let transform in newTransform) {
216224
switch (transform) {
217225
case "scaleX":
218-
animationInfo.declarations.push({ property: "scale", value: { x: parseFloat(newTransform[transform]), y: 1 } });
226+
animationInfo.declarations.push({
227+
property: "scale",
228+
value: { x: parseFloat(newTransform[transform]), y: 1 }
229+
});
219230
break;
220231
case "scaleY":
221-
animationInfo.declarations.push({ property: "scale", value: { x: 1, y: parseFloat(newTransform[transform]) } });
232+
animationInfo.declarations.push({
233+
property: "scale",
234+
value: { x: 1, y: parseFloat(newTransform[transform]) }
235+
});
222236
break;
223237
case "scale":
224238
case "scale3d":
225239
values = newTransform[transform].split(",");
226240
if (values.length === 2 || values.length === 3) {
227-
animationInfo.declarations.push({ property: "scale", value: { x: parseFloat(values[0]), y: parseFloat(values[1]) } });
241+
animationInfo.declarations.push({
242+
property: "scale",
243+
value: { x: parseFloat(values[0]), y: parseFloat(values[1]) }
244+
});
228245
}
229246
break;
230247
case "translateX":
231-
animationInfo.declarations.push({ property: "translate", value: { x: parseFloat(newTransform[transform]), y: 0 } });
248+
animationInfo.declarations.push({
249+
property: "translate",
250+
value: { x: parseFloat(newTransform[transform]), y: 0 }
251+
});
232252
break;
233253
case "translateY":
234-
animationInfo.declarations.push({ property: "translate", value: { x: 0, y: parseFloat(newTransform[transform]) } });
254+
animationInfo.declarations.push({
255+
property: "translate",
256+
value: { x: 0, y: parseFloat(newTransform[transform]) }
257+
});
235258
break;
236259
case "translate":
237260
case "translate3d":
238261
values = newTransform[transform].split(",");
239262
if (values.length === 2 || values.length === 3) {
240-
animationInfo.declarations.push({ property: "translate", value: { x: parseFloat(values[0]), y: parseFloat(values[1]) } });
263+
animationInfo.declarations.push({
264+
property: "translate",
265+
value: {
266+
x: parseFloat(values[0]),
267+
y: parseFloat(values[1])
268+
}
269+
});
241270
}
242271
break;
243272
case "rotate":
@@ -250,9 +279,12 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
250279
break;
251280
case "none":
252281
animationInfo.declarations.push({ property: "scale", value: { x: 1, y: 1 } });
253-
animationInfo.declarations.push({ property: "translate", value: { x: 0, y: 0 } });
282+
animationInfo.declarations.push(
283+
{ property: "translate", value: { x: 0, y: 0 } });
254284
animationInfo.declarations.push({ property: "rotate", value: 0 });
255285
break;
286+
default:
287+
throw new Error("Unsupported transform: " + transform);
256288
}
257289
}
258290
return array;

0 commit comments

Comments
 (0)