Commit 685f17e
chore: re-enable the prefer-const ESLint rule (#250)
* chore: re-enable the prefer-const ESLint rule
prefer-const was disabled in src/eslint.config.mjs under a "TODO: re-enable" comment. Re-enabled with { destructuring: "all" } so it only flags a destructuring declaration when every binding can be const. Most violations were auto-fixed (let -> const); five declare-then-assign cases were merged by hand into a single const declaration. No behavior change — tsc and the tests for the touched modules pass.
* fix(McpHub): pass cancellationDisposable to cleanup() to avoid TDZ on sync cancellation
When CancellationToken.onCancellationRequested() registers a listener
on an already-cancelled token, VS Code fires the callback synchronously
inside the registration call — before the `const cancellationDisposable
= onCancellationRequested(...)` assignment completes. The old `let`-
predeclared shape was no-op-safe via optional chaining, but the
prefer-const consolidation in this PR put `cancellationDisposable`
into the temporal dead zone for the duration of the sync callback,
turning the already-cancelled path into a ReferenceError.
Restructured cleanup() to receive the disposable as a parameter
instead of capturing it from outer scope:
- cleanup signature now takes `disposable?: vscode.Disposable`
- non-callback call sites pass cancellationDisposable explicitly
- the cancellation callback calls cleanup() with no arg; VS Code's
CancellationToken cleans up its own listener after firing, so
disposing from inside the listener was already redundant
Keeps cancellationDisposable as a const, so prefer-const remains
satisfied. Includes a regression test that fires the cancellation
listener synchronously during registration and asserts the flow
resolves cleanly.
* fix(McpHub): register the oauth watcher before installing the cancellation callback
The previous TDZ fix made cancellationDisposable safe under
synchronous callback firing, but the _oauthWatchers.set(watcherKey, ...)
call after the onCancellationRequested(...) registration is still
racy. If the token is already cancelled at registration time and
the callback fires synchronously, cleanup() runs (which tries to
_oauthWatchers.delete the entry) before the entry has been added,
leaving an orphan watcher in the map after the flow has otherwise
torn itself down.
Moved the watcher registration above the onCancellationRequested
call so the entry exists in the map before the callback can fire.
A sync-firing cleanup() now finds and deletes it cleanly. Extended
the existing already-cancelled-token regression test to assert
_oauthWatchers is empty after the flow resolves.
* test: increasing coverage of touched files
* fix(vitest): addressing test flake on teardown
---------
Co-authored-by: 0xMink <260166390+0xMink@users.noreply.github.com>
Co-authored-by: Elliott de Launay <edelauna@gmail.com>
Co-authored-by: Elliott de Launay <edelaunay@wealthsimple.com>1 parent 44e7bee commit 685f17e
56 files changed
Lines changed: 490 additions & 204 deletions
File tree
- .changeset
- src
- api
- providers
- __tests__
- fetchers
- transform
- cache-strategy
- __tests__
- caching
- core
- auto-approval
- config
- __tests__
- context-tracking
- __tests__
- diff/strategies
- environment
- prompts/sections
- task
- tools
- webview
- integrations
- misc
- terminal
- workspace/__tests__
- services
- code-index
- __tests__
- embedders
- glob
- mcp
- __tests__
- ripgrep
- webview-ui
- src/components
- chat/__tests__
- common/__tests__
- settings/__tests__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
184 | 204 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
| 355 | + | |
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
| 401 | + | |
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| |||
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
594 | | - | |
595 | | - | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
596 | 599 | | |
597 | 600 | | |
598 | 601 | | |
| |||
934 | 937 | | |
935 | 938 | | |
936 | 939 | | |
937 | | - | |
| 940 | + | |
938 | 941 | | |
939 | 942 | | |
940 | 943 | | |
| |||
998 | 1001 | | |
999 | 1002 | | |
1000 | 1003 | | |
1001 | | - | |
| 1004 | + | |
1002 | 1005 | | |
1003 | 1006 | | |
1004 | 1007 | | |
| |||
1025 | 1028 | | |
1026 | 1029 | | |
1027 | 1030 | | |
1028 | | - | |
| 1031 | + | |
1029 | 1032 | | |
1030 | 1033 | | |
1031 | 1034 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
681 | | - | |
| 681 | + | |
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| |||
0 commit comments