Skip to content

Commit

Permalink
fix some eslint error (#15590)
Browse files Browse the repository at this point in the history
* fix some eslint error

* change to string
  • Loading branch information
minggo authored Jul 10, 2023
1 parent 92fcc44 commit e361440
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 18 deletions.
8 changes: 4 additions & 4 deletions cocos/2d/assembler/label/font-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export class LetterAtlas {
}

public getLetterDefinitionForChar (char: string, labelInfo: ILabelInfo): any {
const hash = char.charCodeAt(0) + labelInfo.hash;
const hash = char.charCodeAt(0).toString() + labelInfo.hash;
let letter = this.fontDefDictionary.letterDefinitions[hash];
if (!letter) {
const temp = new LetterTexture(char, labelInfo);
Expand Down Expand Up @@ -445,13 +445,13 @@ export const shareLabelInfo: IShareLabelInfo = {
fontScale: 1,
};

export function computeHash (labelInfo): string {
export function computeHash (labelInfo: IShareLabelInfo): string {
const hashData = '';
const color = labelInfo.color.toHEX();
let out = '';
if (labelInfo.isOutlined && labelInfo.margin > 0) {
out = out + labelInfo.margin + labelInfo.out.toHEX();
out = out + labelInfo.margin.toString() + labelInfo.out.toHEX();
}

return hashData + labelInfo.fontSize + labelInfo.fontFamily + color + out;
return hashData + labelInfo.fontSize.toString() + labelInfo.fontFamily + color + out;
}
1 change: 1 addition & 0 deletions cocos/2d/assets/sprite-atlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class SpriteAtlas extends Asset {
spriteFrames: frames,
};
}
return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/framework/mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ export class MeshRenderer extends ModelRenderer {
/**
* @engineInternal
*/
public isUseGPUScene () {
public isUseGPUScene (): boolean {
const sceneData = cclegacy.director.root.pipeline.pipelineSceneData;
if (!sceneData || !sceneData.isGPUDrivenEnabled()) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions cocos/animation/animation-clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ class RootMotionEvaluation {
}

function relativeTransform (out: Mat4, from: Mat4, to: Mat4): void {
Mat4.invert(out, from);
Mat4.invert(out, from);
Mat4.multiply(out, to, out);
}

Expand Down Expand Up @@ -1533,7 +1533,7 @@ class EventEvaluator {
}
}

public reset () {
public reset (): void {
this._lastFrameIndex = -1;
this._lastIterations = 0.0;
this._lastDirection = 0;
Expand Down
2 changes: 1 addition & 1 deletion cocos/animation/marionette/motion/animation-blend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class AnimationBlendPort implements MotionPort {
return this._host.__evaluatePort(this, progress, context);
}

public reenter () {
public reenter (): void {
const { childPorts } = this;
const nChildPorts = childPorts.length;
for (let iChild = 0; iChild < nChildPorts; ++iChild) {
Expand Down
4 changes: 2 additions & 2 deletions cocos/animation/marionette/motion/clip-motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class ClipMotionEval implements MotionEval {
}
}

public reenter () {
public reenter (): void {
this._frameEventEval?.reset();
}

Expand Down Expand Up @@ -216,7 +216,7 @@ class ClipMotionPort implements MotionPort {
return this._eval[evaluatePortTag](progress, context);
}

public reenter () {
public reenter (): void {
this._eval.reenter();
}

Expand Down
4 changes: 2 additions & 2 deletions cocos/audio/audio-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { AudioPlayer, OneShotAudio } from 'pal/audio';
import { js } from '../core';
import { error, js } from '../core';

type ManagedAudio = AudioPlayer | OneShotAudio;
interface AudioInfo<T> {
Expand Down Expand Up @@ -97,7 +97,7 @@ export class AudioManager {
});
}
if (audioInfoToDiscard) {
audioInfoToDiscard.audio.stop();
audioInfoToDiscard.audio.stop()?.catch((err) => { error(err); });
this.removePlaying(audioInfoToDiscard.audio);
}
}
Expand Down
12 changes: 8 additions & 4 deletions cocos/core/data/utils/compact-value-type-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import { ccclass, serializable } from 'cc.decorator';
import { Vec3, Quat, Vec4, Vec2, Mat4 } from '../../math';
import { error } from '../../platform';

export enum StorageUnit {
Uint8, Uint16, Uint32,
Expand Down Expand Up @@ -110,9 +111,9 @@ export class CompactValueTypeArray {
*/
public static compress (values: any[], elementType: ElementType, unit: StorageUnit, arrayBuffer: ArrayBuffer, byteOffset: number, presumedByteOffset: number): CompactValueTypeArray {

Check warning on line 112 in cocos/core/data/utils/compact-value-type-array.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 186. Maximum allowed is 150
const elementTraits = getElementTraits(elementType);
const storageConstructor = getStorageConstructor(unit);
const StorageConstructor = getStorageConstructor(unit);
const unitCount = elementTraits.requiredUnits * values.length;
const storage = new storageConstructor(arrayBuffer, byteOffset, unitCount);
const storage = new StorageConstructor(arrayBuffer, byteOffset, unitCount);
for (let i = 0; i < values.length; ++i) {
elementTraits.compress(storage, i, values[i]);
}
Expand All @@ -132,8 +133,8 @@ export class CompactValueTypeArray {
public decompress<T> (arrayBuffer: ArrayBuffer): T[] {
const { storageUnit, elementType } = extractStorageUnitElementType(this._unitElement);
const elementTraits = getElementTraits(elementType);
const storageConstructor = getStorageConstructor(storageUnit);
const storage = new storageConstructor(arrayBuffer, this._byteOffset, this._unitCount);
const StorageConstructor = getStorageConstructor(storageUnit);
const storage = new StorageConstructor(arrayBuffer, this._byteOffset, this._unitCount);
const result = new Array<T>(this._length);
for (let i = 0; i < this._length; ++i) {
result[i] = elementTraits.decompress(storage, i);
Expand Down Expand Up @@ -164,6 +165,9 @@ function getStorageConstructor (unit: StorageUnit): TypedArrayConstructor {
return Float32Array;
case StorageUnit.Float64:
return Float64Array;
default:
error('Unknown uint type. Return Uint8Array.');
return Uint8Array;
}
}

Expand Down
2 changes: 1 addition & 1 deletion cocos/core/data/utils/extends-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { errorID } from '../../platform/debug';
* const ApplePen = extendsEnum(Apple, Pen);
* ```
*/
export function extendsEnum (): {};
export function extendsEnum (): {}

export function extendsEnum<E0> (e0: E0): E0;

Expand Down
6 changes: 5 additions & 1 deletion cocos/core/data/utils/preprocess-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ function parseType (val, type, className, propName): void {
if (type.length > 0) {
val.type = type = type[0];
} else {
return errorID(5508, className, propName);
errorID(5508, className, propName);
return;
}
}
if (typeof type === 'function') {
Expand Down Expand Up @@ -132,6 +133,8 @@ function parseType (val, type, className, propName): void {
case null:
warnID(5511, className, propName);
break;
default:
break;
}
}

Expand All @@ -153,6 +156,7 @@ function getBaseClassWherePropertyDefined_DEV (propName, cls): any {
}
return res;
}
return null;
}

function _wrapOptions (isGetset: boolean, _default, type?: Function | Function[] | PrimitiveType<any>): {
Expand Down

0 comments on commit e361440

Please sign in to comment.