From 88cad7120b124ed63f7b4776c60daf4957c487a6 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Wed, 10 Jan 2018 14:50:25 -0500 Subject: [PATCH] style(components): fix lint errors --- .../animation-controller/animator.tsx | 98 +++++++++---------- .../animation-controller/constants.ts | 4 +- .../animation-controller/transition-end.ts | 2 +- .../core/src/components/fab-list/fab-list.tsx | 2 +- .../core/src/components/gesture/gesture.tsx | 6 +- packages/core/src/components/nav/nav.tsx | 2 +- .../src/components/split-pane/split-pane.tsx | 4 +- packages/core/src/global/platform-configs.ts | 4 +- packages/core/src/utils/helpers.ts | 8 +- 9 files changed, 65 insertions(+), 65 deletions(-) diff --git a/packages/core/src/components/animation-controller/animator.tsx b/packages/core/src/components/animation-controller/animator.tsx index d8bca94352..cd3e532ae6 100644 --- a/packages/core/src/components/animation-controller/animator.tsx +++ b/packages/core/src/components/animation-controller/animator.tsx @@ -141,7 +141,7 @@ export class Animator { * Add the "to" value for a specific property. */ to(prop: string, val: any, clearProperyAfterTransition?: boolean): Animator { - let fx = this._addProp('to', prop, val); + const fx = this._addProp('to', prop, val); if (clearProperyAfterTransition) { // if this effect is a transform then clear the transform effect @@ -178,7 +178,7 @@ export class Animator { if (!fxProp) { // first time we've see this EffectProperty - let shouldTrans = (TRANSFORM_PROPS[prop] === 1); + const shouldTrans = (TRANSFORM_PROPS[prop] === 1); fxProp = { effectName: prop, trans: shouldTrans, @@ -190,7 +190,7 @@ export class Animator { } // add from/to EffectState to the EffectProperty - let fxState: EffectState = { + const fxState: EffectState = { val: val, num: null, effectUnit: '', @@ -198,8 +198,8 @@ export class Animator { fxProp[state] = fxState; if (typeof val === 'string' && val.indexOf(' ') < 0) { - let r = val.match(CSS_VALUE_REGEX); - let num = parseFloat(r[1]); + const r = val.match(CSS_VALUE_REGEX); + const num = parseFloat(r[1]); if (!isNaN(num)) { fxState.num = num; @@ -313,7 +313,7 @@ export class Animator { * Play the animation. */ play(opts?: PlayOptions) { - let self = this; + const self = this; // If the animation was already invalidated (it did finish), do nothing if (self._destroyed) { @@ -349,7 +349,7 @@ export class Animator { syncPlay() { // If the animation was already invalidated (it did finish), do nothing if (!this._destroyed) { - let opts = { duration: 0 }; + const opts = { duration: 0 }; this._isAsync = false; this._clearAsync(); this._playInit(opts); @@ -371,7 +371,7 @@ export class Animator { this.hasCompleted = false; this._hasDur = (this.getDuration(opts) > DURATION_MIN); - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { // ******** DOM WRITE **************** children[i]._playInit(opts); @@ -394,7 +394,7 @@ export class Animator { * ROOT ANIMATION */ _playDomInspect(opts: PlayOptions) { - let self = this; + const self = this; // fire off all the "before" function that have DOM READS in them // elements will be in the DOM, however visibily hidden // so we can read their dimensions if need be @@ -405,7 +405,7 @@ export class Animator { // for the root animation only // set the async TRANSITION END event // and run onFinishes when the transition ends - let dur = self.getDuration(opts); + const dur = self.getDuration(opts); if (self._isAsync) { self._asyncEnd(dur, true); } @@ -427,7 +427,7 @@ export class Animator { * RECURSION */ _playProgress(opts: PlayOptions) { - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { // ******** DOM WRITE **************** children[i]._playProgress(opts); @@ -460,7 +460,7 @@ export class Animator { */ _playToStep(stepValue: number) { if (!this._destroyed) { - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { // ******** DOM WRITE **************** children[i]._playToStep(stepValue); @@ -482,7 +482,7 @@ export class Animator { * ROOT ANIMATION */ _asyncEnd(dur: number, shouldComplete: boolean) { - let self = this; + const self = this; function onTransitionEnd() { // congrats! a successful transition completed! @@ -527,7 +527,7 @@ export class Animator { * RECURSION */ _playEnd(stepValue?: number) { - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { // ******** DOM WRITE **************** children[i]._playEnd(stepValue); @@ -563,7 +563,7 @@ export class Animator { return true; } - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { if (children[i]._hasDuration(opts)) { return true; @@ -581,7 +581,7 @@ export class Animator { return true; } - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { if (children[i]._hasDomReads()) { return true; @@ -620,8 +620,8 @@ export class Animator { _progress(stepValue: number) { // bread 'n butter let val: any; - let effects = this._fxProperties; - let nuElements = this._elementTotal; + const effects = this._fxProperties; + const nuElements = this._elementTotal; if (!effects || !nuElements || this._destroyed) { return; @@ -634,16 +634,16 @@ export class Animator { let i = 0; let j = 0; let finalTransform = ''; - let elements = this._elements; + const elements = this._elements; let fx: EffectProperty; for (i = 0; i < effects.length; i++) { fx = effects[i]; if (fx.from && fx.to) { - let fromNum = fx.from.num; - let toNum = fx.to.num; - let tweenEffect = (fromNum !== toNum); + const fromNum = fx.from.num; + const toNum = fx.to.num; + const tweenEffect = (fromNum !== toNum); if (tweenEffect) { this._hasTweenEffect = true; @@ -660,7 +660,7 @@ export class Animator { } else if (tweenEffect) { // EVERYTHING IN BETWEEN let valNum = (((toNum - fromNum) * stepValue) + fromNum); - let unit = fx.to.effectUnit; + const unit = fx.to.effectUnit; if (unit === 'px') { valNum = Math.round(valNum); } @@ -668,7 +668,7 @@ export class Animator { } if (val !== null) { - let prop = fx.effectName; + const prop = fx.effectName; if (fx.trans) { finalTransform += prop + '(' + val + ') '; @@ -706,12 +706,12 @@ export class Animator { } // set the TRANSITION properties inline on the element - let elements = this._elements; - let easing = (forcedLinearEasing ? 'linear' : this.getEasing()); - let durString = dur + 'ms'; - let cssTransform = CSS_PROP.transitionProp; - let cssTransitionDuration = CSS_PROP.transitionDurationProp; - let cssTransitionTimingFn = CSS_PROP.transitionTimingFnProp; + const elements = this._elements; + const easing = (forcedLinearEasing ? 'linear' : this.getEasing()); + const durString = dur + 'ms'; + const cssTransform = CSS_PROP.transitionProp; + const cssTransitionDuration = CSS_PROP.transitionDurationProp; + const cssTransitionTimingFn = CSS_PROP.transitionTimingFnProp; let eleStyle: any; for (let i = 0; i < this._elementTotal; i++) { @@ -761,7 +761,7 @@ export class Animator { */ _setBeforeStyles() { let i: number, j: number; - let children = this._childAnimations; + const children = this._childAnimations; for (i = 0; i < this._childAnimationTotal; i++) { children[i]._setBeforeStyles(); } @@ -771,8 +771,8 @@ export class Animator { if (this._isReverse) { return; } - let addClasses = this._beforeAddClasses; - let removeClasses = this._beforeRemoveClasses; + const addClasses = this._beforeAddClasses; + const removeClasses = this._beforeRemoveClasses; let elm: HTMLElement; let elementClassList: DOMTokenList; @@ -812,7 +812,7 @@ export class Animator { * RECURSION */ _fireBeforeReadFunc() { - let children = this._childAnimations; + const children = this._childAnimations; let i = 0; for (i = 0; i < this._childAnimationTotal; i++) { @@ -820,7 +820,7 @@ export class Animator { children[i]._fireBeforeReadFunc(); } - let readFunctions = this._readCallbacks; + const readFunctions = this._readCallbacks; if (readFunctions) { for (i = 0; i < readFunctions.length; i++) { // ******** DOM READ **************** @@ -834,7 +834,7 @@ export class Animator { * RECURSION */ _fireBeforeWriteFunc() { - let children = this._childAnimations; + const children = this._childAnimations; let i = 0; for (i = 0; i < this._childAnimationTotal; i++) { @@ -842,7 +842,7 @@ export class Animator { children[i]._fireBeforeWriteFunc(); } - let writeFunctions = this._writeCallbacks; + const writeFunctions = this._writeCallbacks; if (this._writeCallbacks) { for (i = 0; i < writeFunctions.length; i++) { // ******** DOM WRITE **************** @@ -858,7 +858,7 @@ export class Animator { let i: number, j: number; let elm: HTMLElement; let elementClassList: DOMTokenList; - let elements = this._elements; + const elements = this._elements; let prop: string; for (i = 0; i < this._elementTotal; i++) { @@ -933,13 +933,13 @@ export class Animator { _willChange(addWillChange: boolean) { let i = 0; let wc: string[]; - let effects = this._fxProperties; + const effects = this._fxProperties; let willChange: string; if (addWillChange && effects) { wc = []; for (i = 0; i < effects.length; i++) { - let propWC = effects[i].wc; + const propWC = effects[i].wc; if (propWC === 'webkitTransform') { wc.push('transform', '-webkit-transform'); @@ -978,7 +978,7 @@ export class Animator { * RECURSION */ _progressStart() { - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { // ******** DOM WRITE **************** children[i]._progressStart(); @@ -999,7 +999,7 @@ export class Animator { // only update if the last update was more than 16ms ago stepValue = Math.min(1, Math.max(0, stepValue)); - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { // ******** DOM WRITE **************** children[i].progressStep(stepValue); @@ -1013,7 +1013,7 @@ export class Animator { * End the progress animation. */ progressEnd(shouldComplete: boolean, currentStepValue: number, dur: number) { - let self = this; + const self = this; if (dur === undefined) { dur = -1; } @@ -1023,9 +1023,9 @@ export class Animator { // flip the step value: 0 becomes 1, 1 becomes 0 currentStepValue = ((currentStepValue * -1) + 1); } - let stepValue = shouldComplete ? 1 : 0; + const stepValue = shouldComplete ? 1 : 0; - let diff = Math.abs(currentStepValue - stepValue); + const diff = Math.abs(currentStepValue - stepValue); if (diff < 0.05) { dur = 0; } else if (dur < 0) { @@ -1058,7 +1058,7 @@ export class Animator { * RECURSION */ _progressEnd(shouldComplete: boolean, stepValue: number, dur: number, isAsync: boolean) { - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { // ******** DOM WRITE **************** children[i]._progressEnd(shouldComplete, stepValue, dur, isAsync); @@ -1108,7 +1108,7 @@ export class Animator { * RECURSION */ _didFinishAll(hasCompleted: boolean, finishAsyncAnimations: boolean, finishNoDurationAnimations: boolean) { - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { children[i]._didFinishAll(hasCompleted, finishAsyncAnimations, finishNoDurationAnimations); } @@ -1149,7 +1149,7 @@ export class Animator { if (shouldReverse === undefined) { shouldReverse = true; } - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { children[i].reverse(shouldReverse); } @@ -1163,7 +1163,7 @@ export class Animator { destroy() { this._destroyed = true; - let children = this._childAnimations; + const children = this._childAnimations; for (let i = 0; i < this._childAnimationTotal; i++) { children[i].destroy(); } diff --git a/packages/core/src/components/animation-controller/constants.ts b/packages/core/src/components/animation-controller/constants.ts index 3101b0e425..f9e4dfee55 100644 --- a/packages/core/src/components/animation-controller/constants.ts +++ b/packages/core/src/components/animation-controller/constants.ts @@ -1,6 +1,6 @@ export let CSS_PROP = function(docEle: HTMLElement) { - let css: { + const css: { transformProp?: string; transitionProp?: string; transitionDurationProp?: string; @@ -28,7 +28,7 @@ export let CSS_PROP = function(docEle: HTMLElement) { } // The only prefix we care about is webkit for transitions. - let prefix = css.transitionProp.indexOf('webkit') > -1 ? '-webkit-' : ''; + const prefix = css.transitionProp.indexOf('webkit') > -1 ? '-webkit-' : ''; // transition duration css.transitionDurationProp = prefix + 'transition-duration'; diff --git a/packages/core/src/components/animation-controller/transition-end.ts b/packages/core/src/components/animation-controller/transition-end.ts index f7c3d71daa..49df59db4d 100644 --- a/packages/core/src/components/animation-controller/transition-end.ts +++ b/packages/core/src/components/animation-controller/transition-end.ts @@ -3,7 +3,7 @@ export function transitionEnd(elm: HTMLElement, callback: {(ev?: TransitionEvent): void}) { let unRegTrans: Function; let unRegWKTrans: Function; - let opts: any = { passive: true }; + const opts: any = { passive: true }; function unregister() { unRegWKTrans && unRegWKTrans(); diff --git a/packages/core/src/components/fab-list/fab-list.tsx b/packages/core/src/components/fab-list/fab-list.tsx index d30eacdb1d..5ef2fd9b70 100644 --- a/packages/core/src/components/fab-list/fab-list.tsx +++ b/packages/core/src/components/fab-list/fab-list.tsx @@ -15,7 +15,7 @@ export class FabList { const fabs = this.el.querySelectorAll('ion-fab-button'); // if showing the fabs add a timeout, else show immediately - let timeout = activated ? 30 : 0; + const timeout = activated ? 30 : 0; for (let i = 0; i < fabs.length; i++) { const fab = fabs[i]; setTimeout(() => fab.show = activated, i * timeout); diff --git a/packages/core/src/components/gesture/gesture.tsx b/packages/core/src/components/gesture/gesture.tsx index dd0e24ed77..564a42e6ef 100644 --- a/packages/core/src/components/gesture/gesture.tsx +++ b/packages/core/src/components/gesture/gesture.tsx @@ -277,9 +277,9 @@ export class Gesture { if (startPos > 1) { // compute relative movement between these two points - let frequency = 1 / (positions[startPos] - timestamp); - let movedY = positions[startPos - 1] - currentY; - let movedX = positions[startPos - 2] - currentX; + const frequency = 1 / (positions[startPos] - timestamp); + const movedY = positions[startPos - 1] - currentY; + const movedX = positions[startPos - 2] - currentX; // based on XXms compute the movement to apply for each render step // velocity = space/time = s*(1/t) = s*frequency diff --git a/packages/core/src/components/nav/nav.tsx b/packages/core/src/components/nav/nav.tsx index 2a0d4432ad..d1cf150877 100644 --- a/packages/core/src/components/nav/nav.tsx +++ b/packages/core/src/components/nav/nav.tsx @@ -1017,7 +1017,7 @@ export function getEnteringView(ti: TransitionInstruction, nav: Nav, leavingView return ti.insertViews[ti.insertViews.length - 1]; } if (isDef(ti.removeStart)) { - let removeEnd = ti.removeStart + ti.removeCount; + const removeEnd = ti.removeStart + ti.removeCount; for (let i = nav.views.length - 1; i >= 0; i--) { if ((i < ti.removeStart || i >= removeEnd) && nav.views[i] !== leavingView) { return nav.views[i]; diff --git a/packages/core/src/components/split-pane/split-pane.tsx b/packages/core/src/components/split-pane/split-pane.tsx index 4a572c3170..1633246813 100644 --- a/packages/core/src/components/split-pane/split-pane.tsx +++ b/packages/core/src/components/split-pane/split-pane.tsx @@ -67,8 +67,8 @@ export class SplitPane { const nu = this.el.childElementCount; let foundMain = false; for (let i = 0; i < nu; i++) { - let child = children[i] as HTMLElement; - let isMain = child.hasAttribute('main'); + const child = children[i] as HTMLElement; + const isMain = child.hasAttribute('main'); if (isMain) { if (foundMain) { console.warn('split pane can not have more than one main node'); diff --git a/packages/core/src/global/platform-configs.ts b/packages/core/src/global/platform-configs.ts index 59185716fc..584ae05138 100644 --- a/packages/core/src/global/platform-configs.ts +++ b/packages/core/src/global/platform-configs.ts @@ -85,8 +85,8 @@ export function isPlatformMatch(url: string, userAgent: string, platformName: st export function queryParam(url: string, key: string) { key = key.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); - let regex = new RegExp('[\\?&]' + key + '=([^&#]*)'); - let results = regex.exec(url); + const regex = new RegExp('[\\?&]' + key + '=([^&#]*)'); + const results = regex.exec(url); return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null; } diff --git a/packages/core/src/utils/helpers.ts b/packages/core/src/utils/helpers.ts index bfdf851cf1..cc2e285549 100644 --- a/packages/core/src/utils/helpers.ts +++ b/packages/core/src/utils/helpers.ts @@ -59,7 +59,7 @@ export function pointerCoordX(ev: any): number { // get X coordinates for either a mouse click // or a touch depending on the given event if (ev) { - let changedTouches = ev.changedTouches; + const changedTouches = ev.changedTouches; if (changedTouches && changedTouches.length > 0) { return changedTouches[0].clientX; } @@ -76,9 +76,9 @@ export function updateDetail(ev: any, detail: any) { let x = 0; let y = 0; if (ev) { - let changedTouches = ev.changedTouches; + const changedTouches = ev.changedTouches; if (changedTouches && changedTouches.length > 0) { - let touch = changedTouches[0]; + const touch = changedTouches[0]; x = touch.clientX; y = touch.clientY; } else if (ev.pageX !== undefined) { @@ -94,7 +94,7 @@ export function pointerCoordY(ev: any): number { // get Y coordinates for either a mouse click // or a touch depending on the given event if (ev) { - let changedTouches = ev.changedTouches; + const changedTouches = ev.changedTouches; if (changedTouches && changedTouches.length > 0) { return changedTouches[0].clientY; }