From ed8c67ce7ede4530d55a1e550785a1fb9274abc3 Mon Sep 17 00:00:00 2001 From: Ramon Henrique Ornelas Date: Mon, 22 Aug 2016 19:19:43 -0300 Subject: [PATCH] chore(): tslint (#466) * fix src tslint gulp ionic * - fix errors tslint --- gulpfile.js | 4 ++- src/plugins/3dtouch.ts | 5 +-- src/plugins/background-geolocation.ts | 2 -- src/plugins/camera-preview.ts | 2 +- src/plugins/crop.ts | 2 +- src/plugins/emailcomposer.ts | 19 ++++++++-- src/plugins/file.ts | 4 --- src/plugins/googlemaps.ts | 51 +++++++++++++++++++-------- src/plugins/instagram.ts | 6 ++-- src/plugins/media.ts | 10 +++--- src/plugins/onesignal.ts | 2 +- src/plugins/plugin.ts | 4 +-- src/plugins/screenshot.ts | 2 +- src/plugins/twitter-connect.ts | 2 +- src/plugins/video-editor.ts | 2 +- src/plugins/video-player.ts | 2 +- 16 files changed, 76 insertions(+), 43 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 863d6db0..eaaf8e87 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -27,7 +27,9 @@ gulp.task("minify:dist", function(){ .pipe(gulp.dest('./dist')); }); -gulp.task('lint', tslint); +gulp.task('lint', function() { + tslint({src: 'src/**/*.ts'}); +}); gulp.task('plugin:create', function(){ if(flags.n && flags.n !== ''){ diff --git a/src/plugins/3dtouch.ts b/src/plugins/3dtouch.ts index bbbc9d22..0288a28d 100644 --- a/src/plugins/3dtouch.ts +++ b/src/plugins/3dtouch.ts @@ -106,8 +106,9 @@ export class ThreeDeeTouch { */ static onHomeIconPressed(): Observable { return new Observable(observer => { - if (window.ThreeDeeTouch && window.ThreeDeeTouch.onHomeIconPressed) window.ThreeDeeTouch.onHomeIconPressed = observer.next.bind(observer); - else { + if (window.ThreeDeeTouch && window.ThreeDeeTouch.onHomeIconPressed) { + window.ThreeDeeTouch.onHomeIconPressed = observer.next.bind(observer); + } else { observer.error('3dTouch plugin is not available.'); observer.complete(); } diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index dc452efd..bafbb896 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -1,6 +1,4 @@ import { Cordova, Plugin } from './plugin'; -import { Observable } from 'rxjs/Observable'; - declare var window; diff --git a/src/plugins/camera-preview.ts b/src/plugins/camera-preview.ts index 0c45db67..af0499f3 100644 --- a/src/plugins/camera-preview.ts +++ b/src/plugins/camera-preview.ts @@ -42,7 +42,7 @@ export class CameraPreview { @Cordova({ sync: true }) - static startCamera(rect: CameraPreviewRect, defaultCamera: string, tapEnabled: boolean, dragEnabled: boolean, toBack: boolean, alpha: number): void { + static startCamera(rect: CameraPreviewRect, defaultCamera: string, tapEnabled: boolean, dragEnabled: boolean, toBack: boolean, alpha: number): void { }; diff --git a/src/plugins/crop.ts b/src/plugins/crop.ts index 86dc9129..92f42d00 100644 --- a/src/plugins/crop.ts +++ b/src/plugins/crop.ts @@ -31,4 +31,4 @@ export class Crop { callbackOrder: 'reverse' }) static crop(pathToImage: string, options?: {quality: number}): Promise {return; } -} \ No newline at end of file +} diff --git a/src/plugins/emailcomposer.ts b/src/plugins/emailcomposer.ts index c1cdddd1..7701a523 100644 --- a/src/plugins/emailcomposer.ts +++ b/src/plugins/emailcomposer.ts @@ -59,8 +59,23 @@ export class EmailComposer { */ static isAvailable(app?: string): Promise { return new Promise((resolve, reject) => { - if (app) cordova.plugins.email.isAvailable(app, (isAvailable) => { if (isAvailable) resolve(); else reject(); }); - else cordova.plugins.email.isAvailable((isAvailable) => { if (isAvailable) resolve(); else reject(); }); + if (app) { + cordova.plugins.email.isAvailable(app, (isAvailable) => { + if (isAvailable) { + resolve(); + } else { + reject(); + } + }); + } else { + cordova.plugins.email.isAvailable((isAvailable) => { + if (isAvailable) { + resolve(); + } else { + reject(); + } + }); + } }); } diff --git a/src/plugins/file.ts b/src/plugins/file.ts index d03d752d..213d3315 100644 --- a/src/plugins/file.ts +++ b/src/plugins/file.ts @@ -676,10 +676,6 @@ export class File { } } - let cflags: Flags = { - create: true - }; - return File.resolveDirectoryUrl(path) .then((fse) => { return File.getFile(fse, fileName, opts); diff --git a/src/plugins/googlemaps.ts b/src/plugins/googlemaps.ts index 4b4f1530..a6faa97d 100644 --- a/src/plugins/googlemaps.ts +++ b/src/plugins/googlemaps.ts @@ -204,8 +204,11 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addMarker(options, (marker: any) => { - if (marker) resolve(new GoogleMapsMarker(marker)); - else reject(); + if (marker) { + resolve(new GoogleMapsMarker(marker)); + } else { + reject(); + } }); } ); @@ -215,8 +218,11 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addCircle(options, (circle: any) => { - if (circle) resolve(new GoogleMapsCircle(circle)); - else reject(); + if (circle) { + resolve(new GoogleMapsCircle(circle)); + } else { + reject(); + } }); } ); @@ -226,8 +232,11 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addPolygon(options, (polygon: any) => { - if (polygon) resolve(new GoogleMapsPolygon(polygon)); - else reject(); + if (polygon) { + resolve(new GoogleMapsPolygon(polygon)); + } else { + reject(); + } }); } ); @@ -237,8 +246,11 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addPolyline(options, (polyline: any) => { - if (polyline) resolve(new GoogleMapsPolyline(polyline)); - else reject(); + if (polyline) { + resolve(new GoogleMapsPolyline(polyline)); + } else { + reject(); + } }); } ); @@ -248,8 +260,11 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addTileOverlay(options, (tileOverlay: any) => { - if (tileOverlay) resolve(new GoogleMapsTileOverlay(tileOverlay)); - else reject(); + if (tileOverlay) { + resolve(new GoogleMapsTileOverlay(tileOverlay)); + } else { + reject(); + } }); } ); @@ -259,8 +274,11 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => { - if (groundOverlay) resolve(new GoogleMapsGroundOverlay(groundOverlay)); - else reject(); + if (groundOverlay) { + resolve(new GoogleMapsGroundOverlay(groundOverlay)); + } else { + reject(); + } }); } ); @@ -270,8 +288,11 @@ export class GoogleMap { return new Promise( (resolve, reject) => { this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => { - if (kmlOverlay) resolve(new GoogleMapsKmlOverlay(kmlOverlay)); - else reject(); + if (kmlOverlay) { + resolve(new GoogleMapsKmlOverlay(kmlOverlay)); + } else { + reject(); + } }); } ); @@ -1047,7 +1068,7 @@ export interface GeocoderResult { permises?: string; phone?: string; url?: string - }, + }; locale?: string; locality?: string; position?: { lat: number; lng: number }; diff --git a/src/plugins/instagram.ts b/src/plugins/instagram.ts index 7ad21515..743d979a 100644 --- a/src/plugins/instagram.ts +++ b/src/plugins/instagram.ts @@ -29,7 +29,7 @@ export class Instagram { @Cordova({ callbackStyle: 'node' }) - static isInstalled(): Promise {return;} + static isInstalled(): Promise { return; } /** * Share an image on Instagram @@ -42,7 +42,7 @@ export class Instagram { @Cordova({ callbackStyle: 'node' }) - static share(canvasIdOrDataUrl: string, caption?: string): Promise {return;} + static share(canvasIdOrDataUrl: string, caption?: string): Promise { return; } /** * Share a library asset or video @@ -52,6 +52,6 @@ export class Instagram { @Cordova({ callbackOrder: 'reverse' }) - static shareAsset(assetLocalIdentifier: string): Promise {return;} + static shareAsset(assetLocalIdentifier: string): Promise { return; } } diff --git a/src/plugins/media.ts b/src/plugins/media.ts index b9d91a14..cd939f08 100644 --- a/src/plugins/media.ts +++ b/src/plugins/media.ts @@ -4,7 +4,7 @@ import { Observable } from 'rxjs/Observable'; declare var Media: any; -export interface MediaError { +export interface MediaError { code: number; message: string; } @@ -83,12 +83,12 @@ export class MediaPlugin { static MEDIA_PAUSED: number = 3; static MEDIA_STOPPED: number = 4; - //error codes + // error codes static MEDIA_ERR_ABORTED: number = 1; - static MEDIA_ERR_NETWORK: number = 2; + static MEDIA_ERR_NETWORK: number = 2; static MEDIA_ERR_DECODE: number = 3; static MEDIA_ERR_NONE_SUPPORTED: number = 4; - + // Properties private _objectInstance: any; status: Observable; @@ -199,4 +199,4 @@ export class MediaPlugin { }) stop(): void { } -} \ No newline at end of file +} diff --git a/src/plugins/onesignal.ts b/src/plugins/onesignal.ts index 365fcbb2..cf6f1467 100644 --- a/src/plugins/onesignal.ts +++ b/src/plugins/onesignal.ts @@ -251,4 +251,4 @@ export class OneSignal { visualLevel: number }): void { } -} \ No newline at end of file +} diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index 3adc4eec..0ea2ae7f 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -62,9 +62,9 @@ function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Func // We don't want that the reject cb gets spliced into the position of an optional argument that has not been defined and thus causing non expected behaviour. if (opts.errorIndex > args.length) { - args[opts.errorIndex] = reject; //insert the reject fn at the correct specific index + args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index } else { - args.splice(opts.errorIndex, 0, reject); //otherwise just splice it into the array + args.splice(opts.errorIndex, 0, reject); // otherwise just splice it into the array } } else { // Otherwise, let's tack them on to the end of the argument list diff --git a/src/plugins/screenshot.ts b/src/plugins/screenshot.ts index e23e87f5..376d6aa2 100644 --- a/src/plugins/screenshot.ts +++ b/src/plugins/screenshot.ts @@ -1,4 +1,4 @@ -import { Cordova, Plugin } from './plugin'; +import { Plugin } from './plugin'; declare var navigator: any; diff --git a/src/plugins/twitter-connect.ts b/src/plugins/twitter-connect.ts index bfdc5928..f39c93b5 100644 --- a/src/plugins/twitter-connect.ts +++ b/src/plugins/twitter-connect.ts @@ -51,7 +51,7 @@ export class TwitterConnect { * @return {Promise} returns a promise that resolves if user profile is successfully retrieved and rejects if request fails */ @Cordova() - static showUser(): Promise {return; } + static showUser(): Promise {return; } } export interface TwitterConnectResponse { /** diff --git a/src/plugins/video-editor.ts b/src/plugins/video-editor.ts index 8b6c2b63..92e59d73 100644 --- a/src/plugins/video-editor.ts +++ b/src/plugins/video-editor.ts @@ -92,7 +92,7 @@ export interface CreateThumbnailOptions { export interface GetVideoInfoOptions { /** The path to the video on the device. */ - fileUri: string + fileUri: string; } diff --git a/src/plugins/video-player.ts b/src/plugins/video-player.ts index 33e8306e..a39ad981 100644 --- a/src/plugins/video-player.ts +++ b/src/plugins/video-player.ts @@ -59,4 +59,4 @@ export class VideoPlayer { */ @Cordova({ sync: true }) static close(): void { } -} \ No newline at end of file +}