Skip to content

Commit 666f78e

Browse files
authored
enable and fix no-unused-vars and no-async-promise-executor (#17070)
* dev: set --no-bail for lint task * lint: enable no-async-promise-executor lint and fix them * lint: enable no-unused-vars with allowing _ prefix * lint: fix semi
1 parent cf89c4e commit 666f78e

File tree

144 files changed

+326
-356
lines changed

Some content is hidden

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

144 files changed

+326
-356
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"migrateandstart": "pnpm migrate && pnpm start",
4040
"watch": "pnpm dev",
4141
"dev": "node scripts/dev.mjs",
42-
"lint": "pnpm -r lint",
42+
"lint": "pnpm --no-bail -r lint",
4343
"cy:open": "pnpm cypress open --config-file=cypress.config.ts",
4444
"cy:run": "pnpm cypress run",
4545
"e2e": "pnpm start-server-and-test start:test http://localhost:61812 cy:run",

packages/backend/assets/misc/bios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ window.onload = async () => {
99
const account = JSON.parse(localStorage.getItem('account'));
1010
const i = account.token;
1111

12-
const api = (endpoint, data = {}) => {
12+
const _api = (endpoint, data = {}) => {
1313
const promise = new Promise((resolve, reject) => {
1414
// Append a credential
1515
if (i) data.i = i;

packages/backend/eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default [
2525
},
2626
},
2727
rules: {
28-
'@typescript-eslint/no-unused-vars': 'off',
2928
'import/order': ['warn', {
3029
groups: [
3130
'builtin',

packages/backend/scripts/check_connect.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,22 @@ async function connectToPostgres() {
1616
}
1717

1818
async function connectToRedis(redisOptions) {
19-
return await new Promise(async (resolve, reject) => {
20-
const redis = new Redis({
19+
let redis;
20+
try {
21+
redis = new Redis({
2122
...redisOptions,
2223
lazyConnect: true,
2324
reconnectOnError: false,
2425
showFriendlyErrorStack: true,
2526
});
26-
redis.on('error', e => reject(e));
2727

28-
try {
29-
await redis.connect();
30-
resolve();
31-
} catch (e) {
32-
reject(e);
33-
} finally {
34-
redis.disconnect(false);
35-
}
36-
});
28+
await Promise.race([
29+
new Promise((_, reject) => redis.on('error', e => reject(e))),
30+
redis.connect(),
31+
]);
32+
} finally {
33+
redis.disconnect(false);
34+
}
3735
}
3836

3937
// If not all of these are defined, the default one gets reused.

packages/backend/src/boot/master.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function masterMain() {
5858
//await connectDb();
5959
if (config.pidFile) fs.writeFileSync(config.pidFile, process.pid.toString());
6060
} catch (e) {
61-
bootLogger.error('Fatal error occurred during initialization', null, true);
61+
bootLogger.error('Fatal error occurred during initialization: ' + e, null, true);
6262
process.exit(1);
6363
}
6464

packages/backend/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export function loadConfig(): Config {
352352
function tryCreateUrl(url: string) {
353353
try {
354354
return new URL(url);
355-
} catch (e) {
355+
} catch (_) {
356356
throw new Error(`url="${url}" is not a valid URL.`);
357357
}
358358
}

packages/backend/src/core/AccountMoveService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class AccountMoveService {
7575
*/
7676
@bindThis
7777
public async moveFromLocal(src: MiLocalUser, dst: MiLocalUser | MiRemoteUser): Promise<unknown> {
78-
const srcUri = this.userEntityService.getUserUri(src);
78+
const _srcUri = this.userEntityService.getUserUri(src);
7979
const dstUri = this.userEntityService.getUserUri(dst);
8080

8181
// add movedToUri to indicate that the user has moved

packages/backend/src/core/AnnouncementService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export class AnnouncementService {
205205
announcementId: announcementId,
206206
userId: user.id,
207207
});
208-
} catch (e) {
208+
} catch (_) {
209209
return;
210210
}
211211

packages/backend/src/core/AvatarDecorationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class AvatarDecorationService implements OnApplicationShutdown {
3939
const obj = JSON.parse(data);
4040

4141
if (obj.channel === 'internal') {
42-
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
42+
const { type, body: _ } = obj.message as GlobalEvents['internal']['payload'];
4343
switch (type) {
4444
case 'avatarDecorationCreated':
4545
case 'avatarDecorationUpdated':

packages/backend/src/core/EmailService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ export class EmailService {
366366
valid: true,
367367
reason: null,
368368
};
369-
} catch (error) {
369+
} catch (_) {
370370
return {
371371
valid: false,
372372
reason: 'network',

0 commit comments

Comments
 (0)