Skip to content

Commit 17dc763

Browse files
committed
chore: enforce no-floating-promises in activate/
First slice of a ratchet that re-enables @typescript-eslint/no-floating-promises directory by directory. The rule and type-aware linting are scoped to activate/** via a files-block in eslint.config.mjs, so pnpm lint (eslint --max-warnings=0) stays green; later PRs widen the scope. registerCommands.ts had 7 un-awaited postMessageToWebview calls: the 5 in synchronous command handlers are marked void (intentional fire-and-forget); the 2 in async handlers are awaited — one sits inside a try/catch, so awaiting routes a rejected post into the existing error handling.
1 parent b40461d commit 17dc763

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/activate/registerCommands.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
103103

104104
TelemetryService.instance.captureTitleButtonClicked("settings")
105105

106-
visibleProvider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
106+
void visibleProvider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
107107
// Also explicitly post the visibility message to trigger scroll reliably
108-
visibleProvider.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
108+
void visibleProvider.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
109109
},
110110
historyButtonClicked: () => {
111111
const visibleProvider = getVisibleProviderOrLog(outputChannel)
@@ -116,12 +116,12 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
116116

117117
TelemetryService.instance.captureTitleButtonClicked("history")
118118

119-
visibleProvider.postMessageToWebview({ type: "action", action: "historyButtonClicked" })
119+
void visibleProvider.postMessageToWebview({ type: "action", action: "historyButtonClicked" })
120120
},
121121
marketplaceButtonClicked: () => {
122122
const visibleProvider = getVisibleProviderOrLog(outputChannel)
123123
if (!visibleProvider) return
124-
visibleProvider.postMessageToWebview({ type: "action", action: "marketplaceButtonClicked" })
124+
void visibleProvider.postMessageToWebview({ type: "action", action: "marketplaceButtonClicked" })
125125
},
126126
newTask: handleNewTask,
127127
setCustomStoragePath: async () => {
@@ -150,7 +150,7 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
150150

151151
// Send focus input message only for sidebar panels
152152
if (sidebarPanel && getPanel() === sidebarPanel) {
153-
provider.postMessageToWebview({ type: "action", action: "focusInput" })
153+
await provider.postMessageToWebview({ type: "action", action: "focusInput" })
154154
}
155155
} catch (error) {
156156
outputChannel.appendLine(`Error focusing input: ${error}`)
@@ -170,7 +170,7 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
170170
return
171171
}
172172

173-
visibleProvider.postMessageToWebview({ type: "acceptInput" })
173+
void visibleProvider.postMessageToWebview({ type: "acceptInput" })
174174
},
175175
toggleAutoApprove: async () => {
176176
const visibleProvider = getVisibleProviderOrLog(outputChannel)
@@ -179,7 +179,7 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
179179
return
180180
}
181181

182-
visibleProvider.postMessageToWebview({
182+
await visibleProvider.postMessageToWebview({
183183
type: "action",
184184
action: "toggleAutoApprove",
185185
})

src/eslint.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ export default [
2929
"no-undef": "off",
3030
},
3131
},
32+
{
33+
// Ratchet: enforce no-floating-promises directory by directory. Each
34+
// directory is added here once its floating promises are resolved.
35+
files: ["activate/**/*.ts"],
36+
languageOptions: {
37+
parserOptions: {
38+
project: true,
39+
tsconfigRootDir: import.meta.dirname,
40+
},
41+
},
42+
rules: {
43+
"@typescript-eslint/no-floating-promises": "error",
44+
},
45+
},
3246
{
3347
ignores: ["webview-ui", "out"],
3448
},

0 commit comments

Comments
 (0)