Skip to content

Commit bf32e8d

Browse files
authored
chore: 更新eslint 9并修复大量代码风格错误 (#1343)
1 parent cd8efd3 commit bf32e8d

File tree

217 files changed

+2100
-1737
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+2100
-1737
lines changed

.eslintignore

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

.eslintrc.js

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

.github/workflows/test-build-publish.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
- name: Install dependencies
4646
run: pnpm i --frozen-lockfile
4747

48+
- name: Prepare dev libs and code
49+
run: pnpm prepareDev
50+
4851
- name: Lint code
4952
run: pnpm lint
5053

@@ -60,10 +63,6 @@ jobs:
6063
if: vars.RUN_TESTS == 'true'
6164
run: docker ps
6265

63-
- name: Prepare dev libs and code
64-
if: vars.RUN_TESTS == 'true' || vars.RUN_RELEASE == 'true'
65-
run: pnpm prepareDev
66-
6766
- name: Wait for ports
6867
if: vars.RUN_TESTS == 'true'
6968
uses: ifaxity/wait-on-action@v1.2.1

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"cSpell.words": [
1010
"trpc"
1111
],
12+
"jest.runMode": "on-demand",
1213
"editor.codeActionsOnSave": {
1314
"source.fixAll.eslint": "explicit"
1415
},

apps/ai/.eslintignore

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

apps/ai/.eslintrc.json

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

apps/ai/eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require("../../eslint.config");
2+
const react = require("@ddadaal/eslint-config/react");
3+
4+
module.export = {
5+
...base,
6+
...react,
7+
};

apps/ai/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"build:ts": "rimraf build && tsc -p tsconfig.server.json && tsc-alias -p tsconfig.server.json",
2323
"orm": "dotenv -e env/.env.dev -- npx mikro-orm",
2424
"ormCreate": "dotenv -e env/.env.dev -- npx mikro-orm migration:create",
25-
"ormUp": "dotenv -e env/.env.dev -- npx mikro-orm migration:up"
25+
"ormUp": "dotenv -e env/.env.dev -- npx mikro-orm migration:up",
26+
"lint": "eslint ."
2627
},
2728
"mikro-orm": {
2829
"useTsNode": true,

apps/audit-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"build": "rimraf build && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
1010
"serve": "node build/index.js",
1111
"test": "jest",
12-
"orm": "dotenv -e env/.env.dev -- npx mikro-orm"
12+
"orm": "dotenv -e env/.env.dev -- npx mikro-orm",
13+
"lint": "eslint -c ../../eslint.config.js ."
1314
},
1415
"files": [
1516
"scripts",

apps/audit-server/src/entities/OperationLog.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,37 @@ export enum OperationResult {
2525
export class OperationLog {
2626

2727
@PrimaryKey()
28-
id!: number;
28+
id!: number;
2929

3030
@Property()
31-
operatorUserId!: string;
31+
operatorUserId!: string;
3232

3333
@Property()
34-
operatorIp!: string;
34+
operatorIp!: string;
3535

3636
@Property({ columnType: DATETIME_TYPE, defaultRaw: CURRENT_TIMESTAMP })
37-
operationTime?: Date;
37+
operationTime?: Date;
3838

3939
@Enum({ items: () => OperationResult, comment: Object.values(OperationResult).join(", ") })
40-
operationResult: OperationResult;
40+
operationResult: OperationResult;
4141

4242
@Property({ type: "json", nullable: true })
43-
metaData?: OperationEvent & { targetAccountName?: string };
43+
metaData?: OperationEvent & { targetAccountName?: string };
4444

4545
// 用户自定义操作类型
4646
@Index({ name: "custom_event" })
4747
@Property({ nullable: true })
48-
customEventType?: string;
48+
customEventType?: string;
4949

5050
constructor(init: {
51-
operationLogId?: number;
52-
operatorUserId: string;
53-
operatorIp: string;
54-
operationTime?: Date;
55-
operationResult: OperationResult;
56-
metaData: OperationEvent & { targetAccountName?: string };
57-
customEventType?: string;
58-
}) {
51+
operationLogId?: number;
52+
operatorUserId: string;
53+
operatorIp: string;
54+
operationTime?: Date;
55+
operationResult: OperationResult;
56+
metaData: OperationEvent & { targetAccountName?: string };
57+
customEventType?: string;
58+
}) {
5959
if (init.operationLogId) {
6060
this.id = init.operationLogId;
6161
}

apps/audit-server/src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ async function main() {
2727

2828
switch (command) {
2929

30-
case "migrationUp":
31-
await migrationUp(server.ext.orm);
32-
break;
33-
default:
34-
logger.error("Unexpected task name %s", command);
35-
process.exit(1);
30+
case "migrationUp":
31+
await migrationUp(server.ext.orm);
32+
break;
33+
default:
34+
logger.error("Unexpected task name %s", command);
35+
process.exit(1);
3636
}
3737

3838
process.exit(0);
@@ -41,4 +41,4 @@ async function main() {
4141
await server.start();
4242
}
4343

44-
main();
44+
void main();
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1-
import { Migration } from '@mikro-orm/migrations';
1+
/**
2+
* Copyright (c) 2022 Peking University and Peking University Institute for Computing and Digital Economy
3+
* SCOW is licensed under Mulan PSL v2.
4+
* You can use this software according to the terms and conditions of the Mulan PSL v2.
5+
* You may obtain a copy of Mulan PSL v2 at:
6+
* http://license.coscl.org.cn/MulanPSL2
7+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8+
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9+
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10+
* See the Mulan PSL v2 for more details.
11+
*/
12+
13+
/* eslint-disable @stylistic/max-len */
14+
15+
import { Migration } from "@mikro-orm/migrations";
216

317
export class Migration20230817054947 extends Migration {
418

519
async up(): Promise<void> {
6-
this.addSql('create table `operation_log` (`id` int unsigned not null auto_increment primary key, `operator_user_id` varchar(255) not null, `operator_ip` varchar(255) not null, `operation_time` DATETIME(6) not null default current_timestamp(6), `operation_result` enum(\'UNKNOWN\', \'SUCCESS\', \'FAIL\') not null comment \'UNKNOWN, SUCCESS, FAIL\', `meta_data` json null) default character set utf8mb4 engine = InnoDB;');
20+
this.addSql("create table `operation_log` (`id` int unsigned not null auto_increment primary key, `operator_user_id` varchar(255) not null, `operator_ip` varchar(255) not null, `operation_time` DATETIME(6) not null default current_timestamp(6), `operation_result` enum('UNKNOWN', 'SUCCESS', 'FAIL') not null comment 'UNKNOWN, SUCCESS, FAIL', `meta_data` json null) default character set utf8mb4 engine = InnoDB;");
721
}
822

923
async down(): Promise<void> {
10-
this.addSql('drop table if exists `operation_log`;');
24+
this.addSql("drop table if exists `operation_log`;");
1125
}
1226

1327
}

apps/audit-server/src/migrations/Migration20240218000000.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/**
2+
* Copyright (c) 2022 Peking University and Peking University Institute for Computing and Digital Economy
3+
* SCOW is licensed under Mulan PSL v2.
4+
* You can use this software according to the terms and conditions of the Mulan PSL v2.
5+
* You may obtain a copy of Mulan PSL v2 at:
6+
* http://license.coscl.org.cn/MulanPSL2
7+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8+
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9+
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10+
* See the Mulan PSL v2 for more details.
11+
*/
12+
13+
/* eslint-disable @stylistic/max-len */
14+
115
import { Migration } from "@mikro-orm/migrations";
216

317
export class Migration20240129000000 extends Migration {
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1-
import { Migration } from '@mikro-orm/migrations';
1+
/**
2+
* Copyright (c) 2022 Peking University and Peking University Institute for Computing and Digital Economy
3+
* SCOW is licensed under Mulan PSL v2.
4+
* You can use this software according to the terms and conditions of the Mulan PSL v2.
5+
* You may obtain a copy of Mulan PSL v2 at:
6+
* http://license.coscl.org.cn/MulanPSL2
7+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8+
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9+
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10+
* See the Mulan PSL v2 for more details.
11+
*/
12+
13+
/* eslint-disable @stylistic/max-len */
14+
15+
import { Migration } from "@mikro-orm/migrations";
216

317
export class Migration20240313015230 extends Migration {
418

519
async up(): Promise<void> {
6-
this.addSql('alter table `operation_log` add `custom_event_type` varchar(255) null;');
7-
this.addSql('alter table `operation_log` modify `operation_time` DATETIME(6) not null default current_timestamp(6), modify `operation_result` enum(\'UNKNOWN\', \'SUCCESS\', \'FAIL\') not null comment \'UNKNOWN, SUCCESS, FAIL\';');
8-
this.addSql('alter table `operation_log` add index `custom_event`(`custom_event_type`);');
20+
this.addSql("alter table `operation_log` add `custom_event_type` varchar(255) null;");
21+
this.addSql("alter table `operation_log` modify `operation_time` DATETIME(6) not null default current_timestamp(6), modify `operation_result` enum('UNKNOWN', 'SUCCESS', 'FAIL') not null comment 'UNKNOWN, SUCCESS, FAIL';");
22+
this.addSql("alter table `operation_log` add index `custom_event`(`custom_event_type`);");
923
}
1024

1125
async down(): Promise<void> {
12-
this.addSql('alter table `operation_log` drop index `custom_event`;');
13-
this.addSql('alter table `operation_log` drop column `custom_event_type`;');
26+
this.addSql("alter table `operation_log` drop index `custom_event`;");
27+
this.addSql("alter table `operation_log` drop column `custom_event_type`;");
1428

15-
this.addSql('alter table `operation_log` modify `operation_time` DATETIME(6) not null default current_timestamp(0), modify `operation_result` enum(\'UNKNOWN\', \'SUCCESS\', \'FAIL\') not null comment \'UNKNOWN, SUCCESS, FAIL\';');
29+
this.addSql("alter table `operation_log` modify `operation_time` DATETIME(6) not null default current_timestamp(0), modify `operation_result` enum('UNKNOWN', 'SUCCESS', 'FAIL') not null comment 'UNKNOWN, SUCCESS, FAIL';");
1630
}
1731

1832
}

apps/audit-server/src/services/operationLog.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,18 @@ export const operationLogServiceServer = plugin((server) => {
123123
data.push(row);
124124
writeTotal += 1;
125125
if (data.length === 200 || writeTotal === addAccountNamesRecords.length) {
126-
await new Promise(async (resolve) => {
127-
await writeAsync({ operationLogs: data });
128-
// 清空暂存
129-
data = [];
130-
resolve("done");
126+
await new Promise((resolve) => {
127+
void writeAsync({ operationLogs: data }).then(() => {
128+
// 清空暂存
129+
data = [];
130+
resolve("done");
131+
});
131132
}).catch((e) => {
132-
throw <ServiceError>{
133+
throw {
133134
code: status.INTERNAL,
134135
message: "Error when exporting file",
135136
details: e?.message,
136-
};
137+
} as ServiceError;
137138
});
138139
}
139140
}
@@ -144,7 +145,7 @@ export const operationLogServiceServer = plugin((server) => {
144145
getCustomEventTypes: async ({ em }) => {
145146

146147
const qb = em.createQueryBuilder(OperationLog, "o");
147-
qb
148+
void qb
148149
.select([
149150
raw("DISTINCT o.custom_event_type as customType"),
150151
raw("JSON_UNQUOTE(JSON_EXTRACT(meta_data, '$.customEvent.name')) AS name"),

apps/audit-server/src/services/statistic.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const statisticServiceServer = plugin((server) => {
2929
checkTimeZone(timeZone);
3030

3131
const qb = em.createQueryBuilder(OperationLog, "o");
32-
qb
32+
void qb
3333
.select([
3434
raw("DATE(CONVERT_TZ(o.operation_time, 'UTC', ?)) as date", [timeZone]),
3535
raw("COUNT(DISTINCT o.operator_user_id) as userCount"),
@@ -39,7 +39,7 @@ export const statisticServiceServer = plugin((server) => {
3939
.groupBy(raw("date"))
4040
.orderBy({ [raw("date")]: QueryOrder.DESC });
4141

42-
const records: {date: string, userCount: number}[] = await qb.execute();
42+
const records: { date: string, userCount: number }[] = await qb.execute();
4343

4444
return [{
4545
results: records.map((record) => ({
@@ -72,15 +72,15 @@ export const statisticServiceServer = plugin((server) => {
7272
];
7373

7474
const qb = em.createQueryBuilder(OperationLog, "o");
75-
qb
75+
void qb
7676
.select([raw("JSON_EXTRACT(meta_data, '$.$case') as operationType"), raw("COUNT(*) as count")])
7777
.where({ operationTime: { $gte: startTime } })
7878
.andWhere({ operationTime: { $lte: endTime } })
7979
.andWhere({ [raw("JSON_EXTRACT(meta_data, '$.$case')")]: { $in: portalOperationType } })
8080
.groupBy(raw("operationType"))
8181
.orderBy({ [raw("count")]: QueryOrder.DESC });
8282

83-
const results: {operationType: string, count: number}[] = await qb.execute();
83+
const results: { operationType: string, count: number }[] = await qb.execute();
8484

8585
return [{
8686
results,
@@ -133,15 +133,15 @@ export const statisticServiceServer = plugin((server) => {
133133
];
134134

135135
const qb = em.createQueryBuilder(OperationLog, "o");
136-
qb
136+
void qb
137137
.select([raw("JSON_EXTRACT(meta_data, '$.$case') as operationType"), raw("COUNT(*) as count")])
138138
.where({ operationTime: { $gte: startTime } })
139139
.andWhere({ operationTime: { $lte: endTime } })
140140
.andWhere({ [raw("JSON_EXTRACT(meta_data, '$.$case')")]: { $in: misOperationType } })
141141
.groupBy(raw("operationType"))
142142
.orderBy({ [raw("count")]: QueryOrder.DESC });
143143

144-
const results: {operationType: string, count: number}[] = await qb.execute();
144+
const results: { operationType: string, count: number }[] = await qb.execute();
145145

146146
return [{
147147
results,

0 commit comments

Comments
 (0)