Skip to content

Commit 4b48d66

Browse files
Merge pull request #6122 from uinstinct/no-misused-promises
chore: add no-misused-promises eslint rule
2 parents aee901f + 4b4e3e4 commit 4b48d66

File tree

9 files changed

+87
-77
lines changed

9 files changed

+87
-77
lines changed

.eslintrc.shared.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@typescript-eslint/naming-convention": "off",
1111
"@typescript-eslint/no-floating-promises": "warn",
1212
"@typescript-eslint/semi": "warn",
13+
"@typescript-eslint/no-misused-promises": "error",
1314
"curly": "warn",
1415
"eqeqeq": "warn",
1516
"no-throw-literal": "warn",

core/autocomplete/context/root-path-context/test/testUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function testRootPathContext(
4040
// @ts-ignore
4141
.spyOn(service, "getSnippets")
4242
// @ts-ignore
43-
.mockImplementation(async (_filepath, _endPosition) => {
43+
.mockImplementation((_filePath, _endPosition) => {
4444
return [];
4545
});
4646

core/config/ProfileLifecycleManager.ts

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -87,38 +87,40 @@ export class ProfileLifecycleManager {
8787
}
8888

8989
// Set pending config promise
90-
this.pendingConfigPromise = new Promise(async (resolve, reject) => {
91-
let result: ConfigResult<ContinueConfig>;
92-
// This try catch is expected to catch high-level errors that aren't block-specific
93-
// Like invalid json, invalid yaml, file read errors, etc.
94-
// NOT block-specific loading errors
95-
try {
96-
result = await this.profileLoader.doLoadConfig();
97-
} catch (e) {
98-
const message =
99-
e instanceof Error
100-
? `${e.message}\n${e.stack ? e.stack : ""}`
101-
: "Error loading config";
102-
result = {
103-
errors: [
104-
{
105-
fatal: true,
106-
message,
107-
},
108-
],
109-
config: undefined,
110-
configLoadInterrupted: true,
111-
};
112-
}
113-
114-
if (result.config) {
115-
// Add registered context providers
116-
result.config.contextProviders = (
117-
result.config.contextProviders ?? []
118-
).concat(additionalContextProviders);
119-
}
120-
121-
resolve(result);
90+
this.pendingConfigPromise = new Promise((resolve) => {
91+
void (async () => {
92+
let result: ConfigResult<ContinueConfig>;
93+
// This try catch is expected to catch high-level errors that aren't block-specific
94+
// Like invalid json, invalid yaml, file read errors, etc.
95+
// NOT block-specific loading errors
96+
try {
97+
result = await this.profileLoader.doLoadConfig();
98+
} catch (e) {
99+
const message =
100+
e instanceof Error
101+
? `${e.message}\n${e.stack ? e.stack : ""}`
102+
: "Error loading config";
103+
result = {
104+
errors: [
105+
{
106+
fatal: true,
107+
message,
108+
},
109+
],
110+
config: undefined,
111+
configLoadInterrupted: true,
112+
};
113+
}
114+
115+
if (result.config) {
116+
// Add registered context providers
117+
result.config.contextProviders = (
118+
result.config.contextProviders ?? []
119+
).concat(additionalContextProviders);
120+
}
121+
122+
resolve(result);
123+
})();
122124
});
123125

124126
// Wait for the config promise to resolve

core/core.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ export class Core {
145145
this.messenger,
146146
);
147147

148-
MCPManagerSingleton.getInstance().onConnectionsRefreshed = async () => {
149-
await this.configHandler.reloadConfig();
148+
MCPManagerSingleton.getInstance().onConnectionsRefreshed = () => {
149+
void this.configHandler.reloadConfig();
150150
};
151151

152152
this.codeBaseIndexer = new CodebaseIndexer(
@@ -156,24 +156,26 @@ export class Core {
156156
this.globalContext.get("indexingPaused"),
157157
);
158158

159-
this.configHandler.onConfigUpdate(async (result) => {
160-
const serializedResult = await this.configHandler.getSerializedConfig();
161-
this.messenger.send("configUpdate", {
162-
result: serializedResult,
163-
profileId:
164-
this.configHandler.currentProfile?.profileDescription.id || null,
165-
organizations: this.configHandler.getSerializedOrgs(),
166-
selectedOrgId: this.configHandler.currentOrg.id,
167-
});
168-
169-
// update additional submenu context providers registered via VSCode API
170-
const additionalProviders =
171-
this.configHandler.getAdditionalSubmenuContextProviders();
172-
if (additionalProviders.length > 0) {
173-
this.messenger.send("refreshSubmenuItems", {
174-
providers: additionalProviders,
159+
this.configHandler.onConfigUpdate((result) => {
160+
void (async () => {
161+
const serializedResult = await this.configHandler.getSerializedConfig();
162+
this.messenger.send("configUpdate", {
163+
result: serializedResult,
164+
profileId:
165+
this.configHandler.currentProfile?.profileDescription.id || null,
166+
organizations: this.configHandler.getSerializedOrgs(),
167+
selectedOrgId: this.configHandler.currentOrg.id,
175168
});
176-
}
169+
170+
// update additional submenu context providers registered via VSCode API
171+
const additionalProviders =
172+
this.configHandler.getAdditionalSubmenuContextProviders();
173+
if (additionalProviders.length > 0) {
174+
this.messenger.send("refreshSubmenuItems", {
175+
providers: additionalProviders,
176+
});
177+
}
178+
})();
177179
});
178180

179181
// Dev Data Logger

core/indexing/LanceDbIndex.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export class LanceDbIndex implements CodebaseIndex {
9797
contents TEXT NOT NULL
9898
)`);
9999

100-
await new Promise((resolve) =>
101-
migrate(
100+
await new Promise((resolve) => {
101+
void migrate(
102102
"lancedb_sqlite_artifact_id_column",
103103
async () => {
104104
try {
@@ -118,8 +118,8 @@ export class LanceDbIndex implements CodebaseIndex {
118118
}
119119
},
120120
() => resolve(undefined),
121-
),
122-
);
121+
);
122+
});
123123
}
124124

125125
private async computeRows(items: PathAndCacheKey[]): Promise<LanceDbRow[]> {

core/indexing/chunk/chunk.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,23 @@ export async function* chunkDocument({
5050
maxChunkSize,
5151
)) {
5252
chunkPromises.push(
53-
new Promise(async (resolve) => {
54-
if ((await countTokensAsync(chunkWithoutId.content)) > maxChunkSize) {
55-
// console.debug(
56-
// `Chunk with more than ${maxChunkSize} tokens constructed: `,
57-
// filepath,
58-
// countTokens(chunkWithoutId.content),
59-
// );
60-
return resolve(undefined);
61-
}
62-
resolve({
63-
...chunkWithoutId,
64-
digest,
65-
index,
66-
filepath,
67-
});
53+
new Promise((resolve) => {
54+
void (async () => {
55+
if ((await countTokensAsync(chunkWithoutId.content)) > maxChunkSize) {
56+
// console.debug(
57+
// `Chunk with more than ${maxChunkSize} tokens constructed: `,
58+
// filepath,
59+
// countTokens(chunkWithoutId.content),
60+
// );
61+
return resolve(undefined);
62+
}
63+
resolve({
64+
...chunkWithoutId,
65+
digest,
66+
index,
67+
filepath,
68+
});
69+
})();
6870
}),
6971
);
7072
index++;

core/indexing/docs/DocsService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ export default class DocsService {
186186
private async init(configHandler: ConfigHandler) {
187187
const result = await configHandler.loadConfig();
188188
await this.handleConfigUpdate(result);
189-
configHandler.onConfigUpdate(this.handleConfigUpdate.bind(this));
189+
configHandler.onConfigUpdate(
190+
this.handleConfigUpdate.bind(this) as (arg: any) => void,
191+
);
190192
}
191193

192194
readonly statuses: Map<string, IndexingStatus> = new Map();

core/indexing/docs/migrations.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { editConfigFile, migrate } from "../../util/paths.js";
66
import DocsService, { SqliteDocsRow } from "./DocsService.js";
77

88
export async function runLanceMigrations(table: Table) {
9-
await new Promise((resolve) =>
10-
migrate(
9+
await new Promise((resolve) => {
10+
void migrate(
1111
"rename_baseurl_column_for_lance_docs",
1212
async () => {
1313
try {
@@ -21,8 +21,8 @@ export async function runLanceMigrations(table: Table) {
2121
}
2222
},
2323
() => resolve(undefined),
24-
),
25-
);
24+
);
25+
});
2626
}
2727

2828
export async function runSqliteMigrations(db: Database) {

extensions/vscode/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"extends": ["../../.eslintrc.shared.json"],
77
"rules": {
88
"@typescript-eslint/naming-convention": "off",
9-
"@typescript-eslint/no-floating-promises": "warn"
9+
"@typescript-eslint/no-floating-promises": "warn",
10+
"@typescript-eslint/no-misused-promises": "warn"
1011
}
1112
}

0 commit comments

Comments
 (0)