Skip to content

Commit afd7aac

Browse files
committed
chore: bump eslint to 9
1 parent 753b49e commit afd7aac

22 files changed

+1626
-1595
lines changed

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 65 deletions
This file was deleted.

eslint.config.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import antfu from '@antfu/eslint-config';
2+
import type { Linter } from 'eslint';
3+
import prettierConfig from 'eslint-config-prettier';
4+
5+
export default antfu(
6+
{
7+
typescript: {
8+
overrides: {
9+
'ts/ban-ts-comment': 'off',
10+
'ts/no-use-before-define': 'off',
11+
'ts/no-wrapper-object-types': 'off',
12+
'ts/member-ordering': 'warn',
13+
'ts/explicit-member-accessibility': ['warn', { accessibility: 'no-public' }],
14+
'ts/consistent-type-imports': [
15+
'warn',
16+
{
17+
prefer: 'type-imports',
18+
disallowTypeAnnotations: false,
19+
fixStyle: 'separate-type-imports',
20+
},
21+
],
22+
},
23+
},
24+
jsonc: false,
25+
yaml: false,
26+
markdown: false,
27+
ignores: ['/dist', '/test', '**/*.js'],
28+
},
29+
prettierConfig as Linter.Config,
30+
{
31+
rules: {
32+
'unicorn/new-for-builtins': 'off',
33+
'node/prefer-global/buffer': 'off',
34+
'antfu/curly': 'off',
35+
'antfu/consistent-list-newline': 'off',
36+
'style/semi': 'off',
37+
'style/member-delimiter-style': 'off',
38+
'style/arrow-parens': ['warn', 'as-needed'],
39+
'style/brace-style': ['warn', '1tbs'],
40+
'style/indent': 'off',
41+
'style/operator-linebreak': 'off',
42+
'style/quote-props': 'off',
43+
'antfu/if-newline': 'off',
44+
'antfu/top-level-function': 'off',
45+
'no-console': 'off',
46+
'no-cond-assign': 'off',
47+
'no-useless-return': 'warn',
48+
'symbol-description': 'off',
49+
'unused-imports/no-unused-vars': 'warn',
50+
'perfectionist/sort-imports': [
51+
'warn',
52+
{
53+
ignoreCase: false,
54+
newlinesBetween: 'never',
55+
internalPattern: ['^#.*'],
56+
groups: [
57+
['side-effect-style', 'side-effect'],
58+
'builtin',
59+
'external',
60+
'internal',
61+
'parent',
62+
'sibling',
63+
'index',
64+
'object',
65+
],
66+
},
67+
],
68+
},
69+
},
70+
);

package.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
},
2626
"./class/*": {
2727
"types": "./dist/class/*.d.ts",
28-
"require": "./dist/class/*.js"
28+
"default": "./dist/class/*.js"
2929
},
3030
"./utils/*": {
3131
"types": "./dist/utils/*.d.ts",
32-
"require": "./dist/utils/*.js"
32+
"default": "./dist/utils/*.js"
3333
},
3434
"./*": {
3535
"types": "./dist/*.d.ts",
36-
"require": "./dist/*.js"
36+
"default": "./dist/*.js"
3737
}
3838
},
3939
"author": "神代綺凛 <i@loli.best>",
@@ -47,31 +47,27 @@
4747
],
4848
"scripts": {
4949
"build": "rimraf dist && tsc",
50+
"lint": "eslint . --ext .ts",
5051
"lint:fix": "eslint . --ext .ts --fix",
5152
"postversion": "tpv"
5253
},
5354
"dependencies": {
5455
"@arkntools/unity-js-tools": "^3.2.0",
5556
"aes-js": "^3.1.2",
56-
"es-toolkit": "^1.39.6",
57+
"es-toolkit": "^1.39.7",
5758
"jimp": "^0.22.12",
5859
"jszip": "^3.10.1"
5960
},
6061
"optionalDependencies": {
6162
"node-web-audio-api": "^1.0.4"
6263
},
6364
"devDependencies": {
65+
"@antfu/eslint-config": "^4.17.0",
6466
"@tsuk1ko/postversion": "^1.0.2",
6567
"@types/aes-js": "^3.1.4",
66-
"@typescript-eslint/eslint-plugin": "^7.18.0",
67-
"@typescript-eslint/parser": "^7.18.0",
68-
"eslint": "^8.57.1",
69-
"eslint-config-love": "^47.0.0",
70-
"eslint-config-prettier": "^9.1.0",
71-
"eslint-import-resolver-typescript": "^3.10.1",
72-
"eslint-plugin-import": "^2.32.0",
73-
"eslint-plugin-n": "^17.21.0",
74-
"eslint-plugin-promise": "^6.6.0",
68+
"eslint": "^9.31.0",
69+
"eslint-config-prettier": "^10.1.8",
70+
"jiti": "^2.4.2",
7571
"lint-staged": "^16.1.2",
7672
"prettier": "^3.6.2",
7773
"rimraf": "^6.0.1",

src/bundle.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,19 @@ export interface BundleLoadOptions {
8989
}
9090

9191
export class Bundle {
92-
public readonly header: BundleHeader;
93-
public readonly nodes: StorageNode[] = [];
94-
public readonly files: ArrayBuffer[] = [];
95-
public readonly objectMap = new Map<bigint, AssetObject>();
96-
public readonly objects: AssetObject[];
97-
public readonly textureMixCache = new Map<string, Jimp>();
98-
// eslint-disable-next-line @typescript-eslint/ban-types
99-
public readonly containerMap?: Map<bigint, String>;
92+
readonly header: BundleHeader;
93+
readonly nodes: StorageNode[] = [];
94+
readonly files: ArrayBuffer[] = [];
95+
readonly objectMap = new Map<bigint, AssetObject>();
96+
readonly objects: AssetObject[];
97+
readonly textureMixCache = new Map<string, Jimp>();
98+
readonly containerMap?: Map<bigint, String>;
10099
private readonly blockInfos: StorageBlock[] = [];
101100
private unityCN?: UnityCN;
102101

103-
static async load(data: Buffer | ArrayBuffer | Uint8Array, options?: BundleLoadOptions) {
104-
const r = new ArrayBufferReader(await unzipIfNeed(ensureArrayBuffer(data)));
105-
return new Bundle(r, options);
106-
}
107-
108-
getContainer(pathId: bigint): string | undefined {
109-
return this.containerMap?.get(pathId)?.toString();
110-
}
111-
112102
private constructor(
113103
r: ArrayBufferReader,
114-
public readonly options?: BundleLoadOptions,
104+
readonly options?: BundleLoadOptions,
115105
) {
116106
const signature = r.readStringUntilZero();
117107
const version = r.readUInt32BE();
@@ -172,6 +162,15 @@ export class Bundle {
172162
}
173163
}
174164

165+
static async load(data: Buffer | ArrayBuffer | Uint8Array, options?: BundleLoadOptions) {
166+
const r = new ArrayBufferReader(await unzipIfNeed(ensureArrayBuffer(data)));
167+
return new Bundle(r, options);
168+
}
169+
170+
getContainer(pathId: bigint): string | undefined {
171+
return this.containerMap?.get(pathId)?.toString();
172+
}
173+
175174
private readHeader(r: ArrayBufferReader) {
176175
const { header } = this;
177176

src/classes/assetBundle.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import { AssetType } from './types';
77
export class AssetBundle extends AssetBase {
88
readonly type = AssetType.AssetBundle;
99
readonly preloadTable: PPtr[] = [];
10-
// eslint-disable-next-line @typescript-eslint/ban-types
1110
readonly containers: Array<PairData<String, AssetInfo>> = [];
12-
// eslint-disable-next-line @typescript-eslint/ban-types
1311
readonly containerMap = new Map<bigint, String>();
1412

1513
constructor(info: ObjectInfo, r: ArrayBufferReader) {

src/classes/base.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ const getNodes = (nodes: TypeTreeNode[], index: number): TypeTreeNode[] => {
5555
};
5656

5757
export abstract class AssetBase {
58-
abstract readonly type: AssetType;
5958
readonly name: string = '';
59+
abstract readonly type: AssetType;
6060

6161
constructor(
6262
protected readonly __info: ObjectInfo,
@@ -83,11 +83,6 @@ export abstract class AssetBase {
8383
return AssetType[this.type] || 'unknown';
8484
}
8585

86-
protected readName(r: ArrayBufferReader) {
87-
// @ts-expect-error
88-
this.name = r.readAlignedString();
89-
}
90-
9186
dump(): Record<string, any> {
9287
try {
9388
return dumpObject(this);
@@ -119,6 +114,11 @@ export abstract class AssetBase {
119114
return result.Base ?? result;
120115
}
121116

117+
protected readName(r: ArrayBufferReader) {
118+
// @ts-expect-error
119+
this.name = r.readAlignedString();
120+
}
121+
122122
private getTypeTreeValue(nodes: TypeTreeNode[], r: ArrayBufferReader, ctx: { index: number }) {
123123
const node = nodes[ctx.index];
124124
let align = (node.metaFlag & 0x4000) !== 0;

src/classes/mesh.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { maxBy } from 'es-toolkit';
22
import type { Vector3 } from '../types';
33
import { ArrayBufferReader } from '../utils/reader';
4-
import {
5-
VertexChannelFormat,
6-
VertexFormat,
7-
VertexFormat2017,
8-
type GfxPrimitiveType,
9-
} from './types';
4+
import { VertexChannelFormat, VertexFormat, VertexFormat2017 } from './types';
5+
import type { GfxPrimitiveType } from './types';
106

117
export class SubMesh {
128
readonly firstByte: number;

src/classes/monoBehaviour.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class MonoBehaviour extends AssetBase {
109109
try {
110110
this.sprites = typeTree._sprites.map(({ name, guid, atlas, rect, rotate }) => {
111111
const atlasInfo = atlases[atlas];
112-
if (!atlasInfo) throw new Error();
112+
if (!atlasInfo) throw new Error('atlasInfo not found');
113113
return new AtlasSprite(name, guid, atlasInfo, rect, rotate);
114114
});
115115
} catch {}

src/classes/pptr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class PPtr<T extends AssetObject = AssetObject> {
2020
this.fileId = r;
2121
this.pathId = pathId;
2222
} else {
23-
throw new Error('PPtr invalid arguments');
23+
throw new TypeError('PPtr invalid arguments');
2424
}
2525
}
2626

0 commit comments

Comments
 (0)