diff --git a/cocos/tween/actions/action-interval.ts b/cocos/tween/actions/action-interval.ts index c1a6b1fe93d..767cee3f4da 100644 --- a/cocos/tween/actions/action-interval.ts +++ b/cocos/tween/actions/action-interval.ts @@ -51,6 +51,7 @@ export class ActionInterval extends FiniteTimeAction { protected MAX_VALUE = 2; protected _elapsed = 0; protected _firstTick = false; + // eslint-disable-next-line @typescript-eslint/ban-types protected _easeList: Function[] = []; protected _speed = 1; protected _repeatForever = false; @@ -59,7 +60,7 @@ export class ActionInterval extends FiniteTimeAction { constructor (d?: number) { super(); - if (d !== undefined && !isNaN(d)) { + if (d !== undefined && !Number.isNaN(d)) { this.initWithDuration(d); } } @@ -128,6 +129,7 @@ export class ActionInterval extends FiniteTimeAction { easing (easeObj: any): ActionInterval { if (this._easeList) this._easeList.length = 0; else this._easeList = []; + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument for (let i = 0; i < arguments.length; i++) this._easeList.push(arguments[i]); return this; } @@ -256,7 +258,7 @@ export class ActionInterval extends FiniteTimeAction { */ repeat (times: number): ActionInterval { times = Math.round(times); - if (isNaN(times) || times < 1) { + if (Number.isNaN(times) || times < 1) { logID(1014); return this; } @@ -289,7 +291,7 @@ export class Sequence extends ActionInterval { const sequence = new Sequence(); sequence.initWithTwoActions(actionOne, actionTwo); return sequence; - } + }; private _actions: ActionInterval[] = []; private _split = 0; @@ -323,6 +325,7 @@ export class Sequence extends ActionInterval { for (let i = 1; i < last; i++) { if (paramArray[i]) { action1 = prev; + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument prev = Sequence._actionOneTwo(action1, paramArray[i]); } } @@ -346,6 +349,7 @@ export class Sequence extends ActionInterval { durationOne *= actionOne._repeatMethod ? actionOne._timesForRepeat : 1; durationTwo *= actionTwo._repeatMethod ? actionTwo._timesForRepeat : 1; const d = durationOne + durationTwo; + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.initWithDuration(d); this._actions[0] = actionOne; @@ -355,6 +359,7 @@ export class Sequence extends ActionInterval { clone (): any { const action = new Sequence(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this._cloneDecoration(action as any); action.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone()); return action as any; @@ -411,6 +416,7 @@ export class Sequence extends ActionInterval { } } + // eslint-disable-next-line prefer-const actionFound = locActions[found]; // Last action found and it is done. if (locLast === found && actionFound.isDone()) return; @@ -454,8 +460,9 @@ export class Sequence extends ActionInterval { export function sequence (/* Multiple Arguments */tempArray: any): ActionInterval { const paramArray = (tempArray instanceof Array) ? tempArray : arguments; if (paramArray.length === 1) { - errorID(1019); - return null as any; + // errorID(1019); + // return null as any; + return paramArray[0] as ActionInterval; } const last = paramArray.length - 1; if ((last >= 0) && (paramArray[last] == null)) logID(1015); @@ -465,11 +472,13 @@ export function sequence (/* Multiple Arguments */tempArray: any): ActionInterva result = paramArray[0]; for (let i = 1; i <= last; i++) { if (paramArray[i]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument result = Sequence._actionOneTwo(result, paramArray[i]); } } } + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return result; } @@ -493,6 +502,7 @@ export class Repeat extends ActionInterval { constructor (action?: any, times?: any) { super(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument times !== undefined && this.initWithAction(action, times); } @@ -666,7 +676,7 @@ export class RepeatForever extends ActionInterval { step (dt: any): void { const locInnerAction = this._innerAction!; - locInnerAction.step(dt); + locInnerAction.step(dt as number); if (locInnerAction.isDone()) { // var diff = locInnerAction.getElapsed() - locInnerAction._duration; locInnerAction.startWithTarget(this.target); @@ -731,7 +741,7 @@ export class Spawn extends ActionInterval { const pSpawn = new Spawn(); pSpawn.initWithTwoActions(action1, action2); return pSpawn; - } + }; private _one: ActionInterval | null = null; private _two: ActionInterval | null = null; @@ -775,13 +785,15 @@ export class Spawn extends ActionInterval { const d1 = action1._duration; const d2 = action2._duration; - if (this.initWithDuration(Math.max(d1, d2))) { + if (this.initWithDuration(Math.max(d1 as number, d2 as number))) { this._one = action1; this._two = action2; if (d1 > d2) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this._two = Sequence._actionOneTwo(action2, delayTime(d1 - d2)); } else if (d1 < d2) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this._one = Sequence._actionOneTwo(action1, delayTime(d2 - d1)); } @@ -811,8 +823,8 @@ export class Spawn extends ActionInterval { update (dt: any): void { dt = this._computeEaseTime(dt); - if (this._one) this._one.update(dt); - if (this._two) this._two.update(dt); + if (this._one) this._one.update(dt as number); + if (this._two) this._two.update(dt as number); } reverse (): any { @@ -839,6 +851,7 @@ export function spawn (/* Multiple Arguments */tempArray: any): FiniteTimeAction const paramArray = (tempArray instanceof Array) ? tempArray : arguments; if (paramArray.length === 1) { errorID(1020); + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return null as any; } if ((paramArray.length > 0) && (paramArray[paramArray.length - 1] == null)) logID(1015); @@ -847,7 +860,7 @@ export function spawn (/* Multiple Arguments */tempArray: any): FiniteTimeAction for (let i = 1; i < paramArray.length; i++) { if (paramArray[i] != null) prev = Spawn._actionOneTwo(prev, paramArray[i]); } - return prev; + return prev as FiniteTimeAction; } /* Delays the action a certain amount of seconds @@ -855,6 +868,7 @@ export function spawn (/* Multiple Arguments */tempArray: any): FiniteTimeAction * @extends ActionInterval */ class DelayTime extends ActionInterval { + // eslint-disable-next-line @typescript-eslint/no-empty-function update (dt: any): void { } reverse (): any { @@ -905,6 +919,7 @@ export class ReverseTime extends ActionInterval { constructor (action?: any) { super(); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument action && this.initWithAction(action); }