diff --git a/angular/src/app-initialize.ts b/angular/src/app-initialize.ts index 6a34ae7cd8..75637323ff 100644 --- a/angular/src/app-initialize.ts +++ b/angular/src/app-initialize.ts @@ -5,7 +5,7 @@ import { Config } from './providers/config'; import { IonicWindow } from './types/interfaces'; import { raf } from './util/util'; -export function appInitialize(config: Config, doc: Document, zone: NgZone) { +export const appInitialize = (config: Config, doc: Document, zone: NgZone) => { return (): any => { const win: IonicWindow | undefined = doc.defaultView as any; if (win) { @@ -36,4 +36,4 @@ export function appInitialize(config: Config, doc: Document, zone: NgZone) { }); } }; -} +}; diff --git a/angular/src/directives/control-value-accessors/value-accessor.ts b/angular/src/directives/control-value-accessors/value-accessor.ts index 527d57bf03..b70b7b9499 100644 --- a/angular/src/directives/control-value-accessors/value-accessor.ts +++ b/angular/src/directives/control-value-accessors/value-accessor.ts @@ -72,7 +72,7 @@ const getClasses = (element: HTMLElement) => { return classes; }; -function setClasses(element: HTMLElement, classes: string[]) { +const setClasses = (element: HTMLElement, classes: string[]) => { const classList = element.classList; classList.remove( @@ -84,8 +84,8 @@ function setClasses(element: HTMLElement, classes: string[]) { 'ion-pristine' ); classList.add(...classes); -} +}; -function startsWith(input: string, search: string): boolean { +const startsWith = (input: string, search: string): boolean => { return input.substr(0, search.length) === search; -} +}; diff --git a/angular/src/directives/virtual-scroll/virtual-scroll.ts b/angular/src/directives/virtual-scroll/virtual-scroll.ts index 22bf8a2026..f0f235dde1 100644 --- a/angular/src/directives/virtual-scroll/virtual-scroll.ts +++ b/angular/src/directives/virtual-scroll/virtual-scroll.ts @@ -206,7 +206,7 @@ export class IonVirtualScroll { } } -function getElement(view: EmbeddedViewRef): HTMLElement { +const getElement = (view: EmbeddedViewRef): HTMLElement => { const rootNodes = view.rootNodes; for (let i = 0; i < rootNodes.length; i++) { if (rootNodes[i].nodeType === 1) { @@ -214,7 +214,7 @@ function getElement(view: EmbeddedViewRef): HTMLElement { } } throw new Error('virtual element was not created'); -} +}; proxyInputs(IonVirtualScroll, [ 'approxItemHeight', diff --git a/angular/src/providers/angular-delegate.ts b/angular/src/providers/angular-delegate.ts index 301823e91a..5f0912d10b 100644 --- a/angular/src/providers/angular-delegate.ts +++ b/angular/src/providers/angular-delegate.ts @@ -65,7 +65,7 @@ export class AngularFrameworkDelegate implements FrameworkDelegate { } } -export function attachView( +export const attachView = ( zone: NgZone, resolver: ComponentFactoryResolver, injector: Injector, @@ -74,7 +74,7 @@ export function attachView( elRefMap: WeakMap, elEventsMap: WeakMap void>, container: any, component: any, params: any, cssClasses: string[] | undefined -) { +) => { const factory = resolver.resolveComponentFactory(component); const childInjector = Injector.create({ providers: getProviders(params), @@ -104,7 +104,7 @@ export function attachView( elRefMap.set(hostElement, componentRef); elEventsMap.set(hostElement, unbindEvents); return hostElement; -} +}; const LIFECYCLES = [ LIFECYCLE_WILL_ENTER, @@ -114,7 +114,7 @@ const LIFECYCLES = [ LIFECYCLE_WILL_UNLOAD ]; -export function bindLifecycleEvents(zone: NgZone, instance: any, element: HTMLElement) { +export const bindLifecycleEvents = (zone: NgZone, instance: any, element: HTMLElement) => { return zone.run(() => { const unregisters = LIFECYCLES .filter(eventName => typeof instance[eventName] === 'function') @@ -125,11 +125,11 @@ export function bindLifecycleEvents(zone: NgZone, instance: any, element: HTMLEl }); return () => unregisters.forEach(fn => fn()); }); -} +}; const NavParamsToken = new InjectionToken('NavParamsToken'); -function getProviders(params: {[key: string]: any}) { +const getProviders = (params: {[key: string]: any}) => { return [ { provide: NavParamsToken, useValue: params @@ -138,8 +138,8 @@ function getProviders(params: {[key: string]: any}) { provide: NavParams, useFactory: provideNavParamsInjectable, deps: [NavParamsToken] } ]; -} +}; -function provideNavParamsInjectable(params: {[key: string]: any}) { +const provideNavParamsInjectable = (params: {[key: string]: any}) => { return new NavParams(params); -} +}; diff --git a/angular/src/providers/config.ts b/angular/src/providers/config.ts index 48e9b95c3d..fa41a40fbb 100644 --- a/angular/src/providers/config.ts +++ b/angular/src/providers/config.ts @@ -42,7 +42,7 @@ export class Config { export const ConfigToken = new InjectionToken('USERCONFIG'); -function getConfig(): CoreConfig | null { +const getConfig = (): CoreConfig | null => { if (typeof (window as any) !== 'undefined') { const Ionic = (window as IonicWindow).Ionic; if (Ionic && Ionic.config) { @@ -50,4 +50,4 @@ function getConfig(): CoreConfig | null { } } return null; -} +}; diff --git a/angular/src/providers/dom-controller.ts b/angular/src/providers/dom-controller.ts index 09b00b7bb7..a73678f631 100644 --- a/angular/src/providers/dom-controller.ts +++ b/angular/src/providers/dom-controller.ts @@ -22,7 +22,7 @@ export class DomController { } } -function getQueue() { +const getQueue = () => { const win = typeof (window as any) !== 'undefined' ? window : null as any; if (win != null) { @@ -41,6 +41,6 @@ function getQueue() { read: (cb: any) => cb(), write: (cb: any) => cb() }; -} +}; export type RafCallback = (timeStamp?: number) => void; diff --git a/angular/src/providers/nav-controller.ts b/angular/src/providers/nav-controller.ts index cd3d467ea2..da2458cc76 100644 --- a/angular/src/providers/nav-controller.ts +++ b/angular/src/providers/nav-controller.ts @@ -213,7 +213,7 @@ export class NavController { } } -function getAnimation(direction: RouterDirection, animated: boolean | undefined, animationDirection: 'forward' | 'back' | undefined): NavDirection | undefined { +const getAnimation = (direction: RouterDirection, animated: boolean | undefined, animationDirection: 'forward' | 'back' | undefined): NavDirection | undefined => { if (animated === false) { return undefined; } @@ -226,7 +226,7 @@ function getAnimation(direction: RouterDirection, animated: boolean | undefined, return 'forward'; } return undefined; -} +}; const DEFAULT_DIRECTION = 'auto'; const DEFAULT_ANIMATED = undefined; diff --git a/angular/tslint.json b/angular/tslint.json index 973d007101..909ec200f5 100644 --- a/angular/tslint.json +++ b/angular/tslint.json @@ -18,7 +18,7 @@ "no-floating-promises": false, "no-invalid-template-strings": true, "ban-export-const-enum": true, - + "only-arrow-functions": true, "prefer-for-of": false } }