Skip to content

Commit d1510d8

Browse files
committed
refactor: enable @typescript-eslint/no-floating-promises check
1 parent d73d07b commit d1510d8

31 files changed

+71
-63
lines changed

.eslintrc.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"parser": "@typescript-eslint/parser",
44
"parserOptions": {
55
"ecmaVersion": 6,
6-
"sourceType": "module"
6+
"sourceType": "module",
7+
"project": ["./tsconfig.json", "./ui/tsconfig.json"]
78
},
89
"plugins": ["@typescript-eslint"],
910
"extends": "eslint:recommended",
@@ -15,7 +16,8 @@
1516
"no-throw-literal": "warn",
1617
"semi": "warn",
1718
"require-await": "warn",
18-
"no-undef": "off"
19+
"no-undef": "off",
20+
"@typescript-eslint/no-floating-promises": "warn"
1921
},
20-
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
22+
"ignorePatterns": ["out", "dist", "src/test/**", "**/*.d.ts"]
2123
}

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@
1212
"typescript.tsc.autoDetect": "off",
1313
"editor.formatOnSave": true,
1414
"cSpell.words": ["ASPNETCORE", "fluentui", "randomstring", "tailwindcss"],
15-
"json.format.enable": false
15+
"json.format.enable": false,
16+
"eslint.alwaysShowStatus": true,
17+
"eslint.lintTask.enable": true,
18+
"eslint.run": "onType",
19+
"eslint.debug": false,
20+
"eslint.format.enable": true
1621
}

src/commands/login.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { accountService } from '../services/account.service';
22

33
export const login = () => {
4-
accountService.login();
4+
return accountService.login();
55
};
66

77
export const logout = () => {
8-
accountService.logout();
8+
return accountService.logout();
99
};
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import vscode from 'vscode';
22

33
export const openMyAccountSettings = () => {
4-
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://account.cnblogs.com/settings/account'));
4+
return vscode.commands.executeCommand(
5+
'vscode.open',
6+
vscode.Uri.parse('https://account.cnblogs.com/settings/account')
7+
);
58
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import vscode from 'vscode';
22

33
export const openMyWebBlogConsole = () => {
4-
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://i.cnblogs.com'));
4+
return vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://i.cnblogs.com'));
55
};

src/commands/open-my-blog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import vscode from 'vscode';
44
export const openMyBlog = () => {
55
const userBlogUrl = accountService.curUser?.website;
66
if (userBlogUrl) {
7-
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(userBlogUrl));
7+
return vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(userBlogUrl));
88
}
99
};

src/commands/open-my-home-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export const openMyHomePage = () => {
88
}
99
const userHomePageUrl = `https://home.cnblogs.com/u/${accountId}`;
1010
if (userHomePageUrl) {
11-
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(userHomePageUrl));
11+
void vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(userHomePageUrl));
1212
}
1313
};

src/commands/open-post-in-blog-admin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export const openPostInBlogAdmin = (item: Post | Uri) => {
99

1010
const postId = item instanceof Post ? item.id : PostFileMapManager.getPostId(item.fsPath) ?? -1;
1111

12-
commands.executeCommand('vscode.open', Uri.parse(`https://i.cnblogs.com/posts/edit;postId=${postId}`));
12+
void commands.executeCommand('vscode.open', Uri.parse(`https://i.cnblogs.com/posts/edit;postId=${postId}`));
1313
};

src/commands/pdf/export-pdf.command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const retrieveChromiumPath = async (): Promise<string | undefined> => {
124124
}
125125

126126
if (path && path !== Settings.chromiumPath) {
127-
Settings.setChromiumPath(path);
127+
await Settings.setChromiumPath(path);
128128
}
129129

130130
return path;
@@ -178,7 +178,7 @@ const mapToPostEditDto = async (posts: Post[]) =>
178178

179179
const reportErrors = (errors: string[] | undefined) => {
180180
if (errors && errors.length > 0) {
181-
window.showErrorMessage('导出pdf时遇到错误', { modal: true, detail: errors.join('\n') } as MessageOptions);
181+
void window.showErrorMessage('导出pdf时遇到错误', { modal: true, detail: errors.join('\n') } as MessageOptions);
182182
}
183183
};
184184

src/commands/post-category/new-post-category.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const newPostCategory = async () => {
1111
if (!input) {
1212
return;
1313
}
14-
window.withProgress(
14+
await window.withProgress(
1515
{
1616
title: '正在新建博文分类',
1717
location: ProgressLocation.Notification,
@@ -25,13 +25,13 @@ export const newPostCategory = async () => {
2525
p.report({
2626
increment: 90,
2727
});
28-
await refreshPostCategoriesList();
28+
refreshPostCategoriesList();
2929
const newCategory = (await postCategoryService.fetchCategories()).find(x => x.title === input.title);
3030
if (newCategory) {
3131
await extensionViews.postCategoriesList?.reveal(newCategory);
3232
}
3333
} catch (err) {
34-
window.showErrorMessage('新建博文分类时遇到了错误', {
34+
void window.showErrorMessage('新建博文分类时遇到了错误', {
3535
modal: true,
3636
detail: `服务器反回了错误\n${err instanceof Error ? err.message : JSON.stringify(err)}`,
3737
} as MessageOptions);

0 commit comments

Comments
 (0)