Skip to content

Commit e9c4fe9

Browse files
authored
upgrades floating promises to explicit void (#18141)
1 parent 36088a1 commit e9c4fe9

36 files changed

+143
-130
lines changed

eslint.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default [
125125
],
126126
"deprecation/deprecation": "warn",
127127
"@typescript-eslint/no-floating-promises": [
128-
"warn",
128+
"error",
129129
{
130130
ignoreVoid: true,
131131
},

src/azure/msal/msalAzureAuth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export abstract class MsalAzureAuth {
272272

273273
public async loadTokenCache(): Promise<void> {
274274
let tokenCache = this.clientApplication.getTokenCache();
275-
tokenCache.getAllAccounts();
275+
void tokenCache.getAllAccounts();
276276
}
277277

278278
public async getAccountFromMsalCache(

src/azure/msal/msalAzureController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class MsalAzureController extends AzureController {
7474

7575
let azureAuth = await this.getAzureAuthInstance(authType!);
7676
await this.clearOldCacheIfExists();
77-
azureAuth.loadTokenCache();
77+
void azureAuth.loadTokenCache();
7878
}
7979

8080
public async clearTokenCache(): Promise<void> {

src/azure/simpleWebServer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class SimpleWebServer {
9393
clearTimeout(portTimeout);
9494
};
9595

96-
portPromise.finally(clearPortTimeout);
96+
void portPromise.finally(clearPortTimeout);
9797

9898
return portPromise;
9999
}

src/controllers/connectionManager.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,9 @@ export default class ConnectionManager {
16571657
} else {
16581658
await this._accountStore.pruneAccounts();
16591659
}
1660-
this.azureController.removeAccount(answers.account);
1660+
void this.azureController.removeAccount(
1661+
answers.account,
1662+
);
16611663
this.vscodeWrapper.showInformationMessage(
16621664
LocalizedConstants.accountRemovedSuccessfully,
16631665
);

src/controllers/executionPlanWebviewController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class ExecutionPlanWebviewController extends ReactWebviewPanelController<
5555
),
5656
},
5757
);
58-
this.initialize();
58+
void this.initialize();
5959
}
6060

6161
private async initialize() {

src/controllers/mainController.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export default class MainController implements vscode.Disposable {
141141
* Disposes the controller
142142
*/
143143
dispose(): void {
144-
this.deactivate();
144+
void this.deactivate();
145145
}
146146

147147
/**
@@ -177,16 +177,16 @@ export default class MainController implements vscode.Disposable {
177177
// register VS Code commands
178178
this.registerCommand(Constants.cmdConnect);
179179
this._event.on(Constants.cmdConnect, () => {
180-
this.runAndLogErrors(this.onNewConnection());
180+
void this.runAndLogErrors(this.onNewConnection());
181181
});
182182
this.registerCommand(Constants.cmdDisconnect);
183183
this._event.on(Constants.cmdDisconnect, () => {
184-
this.runAndLogErrors(this.onDisconnect());
184+
void this.runAndLogErrors(this.onDisconnect());
185185
});
186186
this.registerCommand(Constants.cmdRunQuery);
187187
this._event.on(Constants.cmdRunQuery, () => {
188-
UserSurvey.getInstance().promptUserForNPSFeedback();
189-
this.onRunQuery();
188+
void UserSurvey.getInstance().promptUserForNPSFeedback();
189+
void this.onRunQuery();
190190
});
191191
this.registerCommand(Constants.cmdManageConnectionProfiles);
192192
this._event.on(Constants.cmdManageConnectionProfiles, async () => {
@@ -198,19 +198,19 @@ export default class MainController implements vscode.Disposable {
198198
});
199199
this.registerCommand(Constants.cmdRunCurrentStatement);
200200
this._event.on(Constants.cmdRunCurrentStatement, () => {
201-
this.onRunCurrentStatement();
201+
void this.onRunCurrentStatement();
202202
});
203203
this.registerCommand(Constants.cmdChangeDatabase);
204204
this._event.on(Constants.cmdChangeDatabase, () => {
205-
this.runAndLogErrors(this.onChooseDatabase());
205+
void this.runAndLogErrors(this.onChooseDatabase());
206206
});
207207
this.registerCommand(Constants.cmdChooseDatabase);
208208
this._event.on(Constants.cmdChooseDatabase, () => {
209-
this.runAndLogErrors(this.onChooseDatabase());
209+
void this.runAndLogErrors(this.onChooseDatabase());
210210
});
211211
this.registerCommand(Constants.cmdChooseLanguageFlavor);
212212
this._event.on(Constants.cmdChooseLanguageFlavor, () => {
213-
this.runAndLogErrors(this.onChooseLanguageFlavor());
213+
void this.runAndLogErrors(this.onChooseLanguageFlavor());
214214
});
215215
this.registerCommand(Constants.cmdLaunchUserFeedback);
216216
this._event.on(Constants.cmdLaunchUserFeedback, async () => {
@@ -536,7 +536,7 @@ export default class MainController implements vscode.Disposable {
536536

537537
// Shows first time notifications on extension installation or update
538538
// This call is intentionally not awaited to avoid blocking extension activation
539-
this.showFirstLaunchPrompts();
539+
void this.showFirstLaunchPrompts();
540540

541541
// Handle case where SQL file is the 1st opened document
542542
const activeTextEditor = this._vscodeWrapper.activeTextEditor;
@@ -1269,7 +1269,7 @@ export default class MainController implements vscode.Disposable {
12691269
if (this.canRunCommand() && this.validateTextDocumentHasFocus()) {
12701270
const fileUri = this._vscodeWrapper.activeTextEditorUri;
12711271
if (fileUri && this._vscodeWrapper.isEditingSqlFile) {
1272-
this._connectionMgr.onChooseLanguageFlavor();
1272+
void this._connectionMgr.onChooseLanguageFlavor();
12731273
} else {
12741274
this._vscodeWrapper.showWarningMessage(
12751275
LocalizedConstants.msgOpenSqlFile,
@@ -1997,7 +1997,7 @@ export default class MainController implements vscode.Disposable {
19971997
(await this._objectExplorerProvider.getChildren()).forEach(
19981998
(n: TreeNodeInfo) => {
19991999
try {
2000-
this._objectExplorerProvider.refreshNode(n);
2000+
void this._objectExplorerProvider.refreshNode(n);
20012001
} catch (e) {
20022002
errorFoundWhileRefreshing = true;
20032003
this._connectionMgr.client.logger.error(e);
@@ -2079,11 +2079,11 @@ export default class MainController implements vscode.Disposable {
20792079
}
20802080

20812081
public removeAadAccount(prompter: IPrompter): void {
2082-
this.connectionManager.removeAccount(prompter);
2082+
void this.connectionManager.removeAccount(prompter);
20832083
}
20842084

20852085
public addAadAccount(): void {
2086-
this.connectionManager.addAccount();
2086+
void this.connectionManager.addAccount();
20872087
}
20882088

20892089
public onClearAzureTokenCache(): void {

src/controllers/queryRunner.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ export default class QueryRunner {
515515
this._vscodeWrapper.showErrorMessage(
516516
"Something went wrong getting more rows: " + error.message,
517517
);
518-
Promise.reject(error);
518+
void Promise.reject(error);
519519
}
520520
}
521521

@@ -536,7 +536,7 @@ export default class QueryRunner {
536536
this._vscodeWrapper.showErrorMessage(
537537
"Failed disposing query: " + error.message,
538538
);
539-
Promise.reject(error);
539+
void Promise.reject(error);
540540
}
541541
}
542542

src/languageservice/serviceclient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ export default class SqlToolsServiceClient {
453453
serverOptions,
454454
clientOptions,
455455
);
456-
client.onReady().then(() => {
456+
void client.onReady().then(() => {
457457
client.onNotification(
458458
LanguageServiceContracts.StatusChangedNotification.type,
459459
this.handleLanguageServiceStatusNotification(),

src/models/sqlOutputContentProvider.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class SqlOutputContentProvider {
123123
selection: Interfaces.ISlickRange[],
124124
includeHeaders?: boolean,
125125
): void {
126-
this._queryResultsMap
126+
void this._queryResultsMap
127127
.get(uri)
128128
.queryRunner.copyResults(
129129
selection,
@@ -137,7 +137,7 @@ export class SqlOutputContentProvider {
137137
uri: string,
138138
selection: ISelectionData,
139139
): void {
140-
this._queryResultsMap
140+
void this._queryResultsMap
141141
.get(uri)
142142
.queryRunner.setEditorSelection(selection);
143143
}
@@ -617,7 +617,7 @@ export class SqlOutputContentProvider {
617617
this.cancelQuery(queryRunnerState.queryRunner);
618618
} else {
619619
// We need to explicitly dispose the query
620-
queryRunnerState.queryRunner.dispose();
620+
void queryRunnerState.queryRunner.dispose();
621621
}
622622
} else {
623623
queryRunnerState.timeout = this.setRunnerDeletionTimeout(uri);

src/objectExplorer/objectExplorerService.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ export class ObjectExplorerService {
222222
errorNumber ===
223223
Constants.errorSSLCertificateValidationFailed
224224
) {
225-
self._connectionManager.showInstructionTextAsWarning(
225+
void self._connectionManager.showInstructionTextAsWarning(
226226
self._currentNode.connectionInfo,
227227
async (updatedProfile) => {
228-
self.reconnectProfile(
228+
void self.reconnectProfile(
229229
self._currentNode,
230230
updatedProfile,
231231
);
@@ -251,7 +251,7 @@ export class ObjectExplorerService {
251251
self._currentNode.connectionInfo
252252
);
253253
self.updateNode(self._currentNode);
254-
self._connectionManager.connectionUI.handleFirewallError(
254+
void self._connectionManager.connectionUI.handleFirewallError(
255255
nodeUri,
256256
profile,
257257
handleFirewallResult.ipAddress,
@@ -273,7 +273,7 @@ export class ObjectExplorerService {
273273
await this.refreshAccount(account, profile);
274274
// Do not await when performing reconnect to allow
275275
// OE node to expand after connection is established.
276-
this.reconnectProfile(self._currentNode, profile);
276+
void this.reconnectProfile(self._currentNode, profile);
277277
} else {
278278
self._connectionManager.vscodeWrapper.showErrorMessage(
279279
error,
@@ -311,7 +311,7 @@ export class ObjectExplorerService {
311311
profile,
312312
)
313313
) {
314-
this.refreshNode(node);
314+
void this.refreshNode(node);
315315
}
316316
} else {
317317
this._connectionManager.vscodeWrapper.showErrorMessage(
@@ -765,7 +765,10 @@ export class ObjectExplorerService {
765765
(!azureController.isSqlAuthProviderEnabled() ||
766766
needsRefresh)
767767
) {
768-
this.refreshAccount(account, connectionCredentials);
768+
void this.refreshAccount(
769+
account,
770+
connectionCredentials,
771+
);
769772
}
770773
}
771774
}

src/protocol.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class MessageProxy implements Disposable {
153153
deferred.resolve(message.response);
154154
}
155155
} else {
156-
Promise.resolve(
156+
void Promise.resolve(
157157
this.handler[message.method].apply(
158158
this.handler,
159159
message.passArguments,

src/queryResult/queryResultWebViewController.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export class QueryResultWebviewController extends ReactWebviewViewController<
2424
resultPaneTab: qr.QueryResultPaneTabs.Messages,
2525
},
2626
});
27-
this.initialize();
27+
28+
void this.initialize();
2829
}
2930

3031
private async initialize() {

src/reactviews/common/rpc.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class WebviewRpc<Reducers> {
8383
method: MethodName,
8484
payload?: Reducers[MethodName],
8585
) {
86-
this.call("action", { type: method, payload });
86+
void this.call("action", { type: method, payload });
8787
}
8888

8989
public subscribe(method: string, callback: (params: unknown) => void) {
@@ -94,10 +94,10 @@ export class WebviewRpc<Reducers> {
9494
}
9595

9696
public sendActionEvent(event: WebviewTelemetryActionEvent) {
97-
this.call("sendActionEvent", event);
97+
void this.call("sendActionEvent", event);
9898
}
9999

100100
public sendErrorEvent(event: WebviewTelemetryErrorEvent) {
101-
this.call("sendErrorEvent", event);
101+
void this.call("sendErrorEvent", event);
102102
}
103103
}

src/reactviews/common/vscodeWebviewProvider.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ export function VscodeWebviewProvider<State, Reducers>({
115115
setLocalization(true);
116116
}
117117

118-
getTheme();
119-
getState();
120-
loadStats();
121-
getLocalization();
118+
void getTheme();
119+
void getState();
120+
void loadStats();
121+
void getLocalization();
122122
}, []);
123123

124124
extensionRpc.subscribe("onDidChangeTheme", (params) => {

src/reactviews/pages/ExecutionPlan/properties.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ export const PropertiesPane: React.FC<PropertiesPaneProps> = ({
455455
}
456456
onChange={(e) => {
457457
setInputValue(e.target.value);
458-
handleFilter(e.target.value);
458+
void handleFilter(e.target.value);
459459
}}
460460
/>
461461
</Toolbar>

src/reactviews/pages/QueryResult/commandBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const CommandBar = (props: CommandBarProps) => {
4545
const classes = useStyles();
4646

4747
const saveResults = (buttonLabel: string) => {
48-
webViewState.extensionRpc.call("saveResults", {
48+
void webViewState.extensionRpc.call("saveResults", {
4949
uri: props.uri,
5050
batchId: props.resultSetSummary?.batchId,
5151
resultId: props.resultSetSummary?.id,

src/reactviews/pages/QueryResult/table/hybridDataProvider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ export class HybridDataProvider<T extends Slick.SlickData>
108108

109109
public async filter(columns: FilterableColumn<T>[]) {
110110
await this.initializeCacheIfNeeded();
111-
this.provider.filter(columns);
111+
void this.provider.filter(columns);
112112
}
113113

114114
public async sort(options: Slick.OnSortEventArgs<T>) {
115115
await this.initializeCacheIfNeeded();
116-
this.provider.sort(options);
116+
void this.provider.sort(options);
117117
}
118118

119119
private get thresholdReached(): boolean {

src/reactviews/pages/QueryResult/table/plugins/headerFilter.plugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ export class HeaderFilter<T extends Slick.SlickData> {
165165
"click",
166166
"#sort-ascending",
167167
(_e: JQuery.ClickEvent) => {
168-
this.handleMenuItemClick("sort-asc", this.columnDef);
168+
void this.handleMenuItemClick("sort-asc", this.columnDef);
169169
closePopup($popup);
170170
},
171171
);
172172
jQuery(document).on(
173173
"click",
174174
"#sort-descending",
175175
(_e: JQuery.ClickEvent) => {
176-
this.handleMenuItemClick("sort-desc", this.columnDef);
176+
void this.handleMenuItemClick("sort-desc", this.columnDef);
177177
closePopup($popup);
178178
},
179179
);

src/tableDesigner/tableDesignerWebviewController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class TableDesignerWebviewController extends ReactWebviewPanelController<
6060
),
6161
},
6262
);
63-
this.initialize();
63+
void this.initialize();
6464
}
6565

6666
private async initialize() {

test/unit/adapter.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ suite("Code Adapter Tests", () => {
7171
});
7272

7373
test("promptSingle and promptCallback should call prompt", () => {
74-
adapter.promptSingle(testQuestion);
74+
void adapter.promptSingle(testQuestion);
7575
adapter.promptCallback([testQuestion], () => true);
7676
// Error case
77-
adapter.prompt([{ type: "test", message: "test", name: "test" }]);
77+
void adapter.prompt([{ type: "test", message: "test", name: "test" }]);
7878
});
7979

8080
test("prompting a checkbox question should call fixQuestion", () => {
@@ -84,9 +84,9 @@ suite("Code Adapter Tests", () => {
8484
name: "test_checkbox",
8585
choices: [{ name: "test_choice", value: "test_choice" }],
8686
};
87-
adapter.promptSingle(formattedQuestion);
87+
void adapter.promptSingle(formattedQuestion);
8888
let question: any = Object.assign({}, formattedQuestion);
8989
question.choices[0] = "test";
90-
adapter.promptSingle(question);
90+
void adapter.promptSingle(question);
9191
});
9292
});

0 commit comments

Comments
 (0)