mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
Enable no-floating-promises for data-workspace (#16958)
This commit is contained in:
13
extensions/data-workspace/.eslintrc.json
Normal file
13
extensions/data-workspace/.eslintrc.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
"project": "./extensions/data-workspace/tsconfig.json"
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/no-floating-promises": [
|
||||
"error",
|
||||
{
|
||||
"ignoreVoid": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export class DataWorkspaceExtension implements IExtension {
|
||||
}
|
||||
|
||||
showProjectsView(): void {
|
||||
vscode.commands.executeCommand('dataworkspace.views.main.focus');
|
||||
void vscode.commands.executeCommand('dataworkspace.views.main.focus');
|
||||
}
|
||||
|
||||
get defaultProjectSaveLocation(): vscode.Uri | undefined {
|
||||
|
||||
@@ -16,7 +16,7 @@ import { TelemetryReporter } from './telemetry';
|
||||
export class WorkspaceTreeDataProvider implements vscode.TreeDataProvider<WorkspaceTreeItem>{
|
||||
constructor(private _workspaceService: IWorkspaceService) {
|
||||
this._workspaceService.onDidWorkspaceProjectsChange(() => {
|
||||
this.refresh();
|
||||
return this.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export class WorkspaceTreeDataProvider implements vscode.TreeDataProvider<Worksp
|
||||
}
|
||||
|
||||
if (errorCount > 0) {
|
||||
vscode.window.showErrorMessage(ProjectsFailedToLoad);
|
||||
void vscode.window.showErrorMessage(ProjectsFailedToLoad);
|
||||
}
|
||||
|
||||
TelemetryReporter.sendMetricsEvent(typeMetric, 'OpenWorkspaceProjectTypes');
|
||||
@@ -89,7 +89,7 @@ export class WorkspaceTreeDataProvider implements vscode.TreeDataProvider<Worksp
|
||||
'OpenWorkspaceProjectsHandled');
|
||||
|
||||
if (unknownProjects.length > 0) {
|
||||
vscode.window.showErrorMessage(UnknownProjectsError(unknownProjects));
|
||||
void vscode.window.showErrorMessage(UnknownProjectsError(unknownProjects));
|
||||
}
|
||||
|
||||
return treeItems;
|
||||
|
||||
@@ -96,7 +96,7 @@ export class NewProjectDialog extends DialogBase {
|
||||
.withAdditionalProperties({ projectFileExtension: this.model.projectFileExtension, projectTemplateId: this.model.projectTypeId, error: err?.message ? err.message : err })
|
||||
.send();
|
||||
|
||||
vscode.window.showErrorMessage(err?.message ? err.message : err);
|
||||
void vscode.window.showErrorMessage(err?.message ? err.message : err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ export class NewProjectDialog extends DialogBase {
|
||||
|
||||
this.register(projectNameTextBox.onTextChanged(() => {
|
||||
this.model.name = projectNameTextBox.value!;
|
||||
projectNameTextBox.updateProperty('title', projectNameTextBox.value);
|
||||
return projectNameTextBox.updateProperty('title', projectNameTextBox.value);
|
||||
}));
|
||||
|
||||
const locationTextBox = view.modelBuilder.inputBox().withProps({
|
||||
@@ -175,7 +175,7 @@ export class NewProjectDialog extends DialogBase {
|
||||
|
||||
this.register(locationTextBox.onTextChanged(() => {
|
||||
this.model.location = locationTextBox.value!;
|
||||
locationTextBox.updateProperty('title', locationTextBox.value);
|
||||
return locationTextBox.updateProperty('title', locationTextBox.value);
|
||||
}));
|
||||
|
||||
const browseFolderButton = view.modelBuilder.button().withProps({
|
||||
|
||||
@@ -93,7 +93,7 @@ export class OpenExistingDialog extends DialogBase {
|
||||
await addProjectsPromise;
|
||||
}
|
||||
catch (err) {
|
||||
vscode.window.showErrorMessage(err?.message ? err.message : err);
|
||||
void vscode.window.showErrorMessage(err?.message ? err.message : err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export class OpenExistingDialog extends DialogBase {
|
||||
}).component();
|
||||
|
||||
this.register(gitRepoTextBox.onTextChanged(() => {
|
||||
gitRepoTextBox.updateProperty('title', this.localClonePathTextBox!.value!);
|
||||
return gitRepoTextBox.updateProperty('title', this.localClonePathTextBox!.value!);
|
||||
}));
|
||||
|
||||
this.gitRepoTextBoxComponent = {
|
||||
@@ -158,7 +158,7 @@ export class OpenExistingDialog extends DialogBase {
|
||||
}).component();
|
||||
|
||||
this.register(this.localClonePathTextBox.onTextChanged(() => {
|
||||
this.localClonePathTextBox!.updateProperty('title', this.localClonePathTextBox!.value!);
|
||||
return this.localClonePathTextBox!.updateProperty('title', this.localClonePathTextBox!.value!);
|
||||
}));
|
||||
|
||||
const localClonePathBrowseFolderButton = view.modelBuilder.button().withProps({
|
||||
@@ -181,7 +181,7 @@ export class OpenExistingDialog extends DialogBase {
|
||||
|
||||
const selectedFolder = folderUris[0].fsPath;
|
||||
this.localClonePathTextBox!.value = selectedFolder;
|
||||
this.localClonePathTextBox!.updateProperty('title', this.localClonePathTextBox!.value);
|
||||
void this.localClonePathTextBox!.updateProperty('title', this.localClonePathTextBox!.value);
|
||||
}));
|
||||
|
||||
this.localClonePathComponent = {
|
||||
@@ -198,7 +198,7 @@ export class OpenExistingDialog extends DialogBase {
|
||||
}).component();
|
||||
|
||||
this.register(this.filePathTextBox.onTextChanged(() => {
|
||||
this.filePathTextBox!.updateProperty('title', this.filePathTextBox!.value!);
|
||||
return this.filePathTextBox!.updateProperty('title', this.filePathTextBox!.value!);
|
||||
}));
|
||||
|
||||
const localProjectBrowseFolderButton = view.modelBuilder.button().withProps({
|
||||
@@ -210,7 +210,7 @@ export class OpenExistingDialog extends DialogBase {
|
||||
this.register(localProjectBrowseFolderButton.onDidClick(() => this.onBrowseButtonClick()));
|
||||
|
||||
const flexContainer = this.createHorizontalContainer(view, [this.filePathTextBox, localProjectBrowseFolderButton]);
|
||||
flexContainer.updateCssStyles({ 'margin-top': '-10px' });
|
||||
void flexContainer.updateCssStyles({ 'margin-top': '-10px' });
|
||||
this.filePathAndButtonComponent = {
|
||||
component: flexContainer
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ import { createNewProjectWithQuickpick } from './dialogs/newProjectQuickpick';
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext): Promise<IExtension> {
|
||||
const azdataApi = getAzdataApi();
|
||||
vscode.commands.executeCommand('setContext', 'azdataAvailable', !!azdataApi);
|
||||
void vscode.commands.executeCommand('setContext', 'azdataAvailable', !!azdataApi);
|
||||
const workspaceService = new WorkspaceService();
|
||||
|
||||
const workspaceTreeDataProvider = new WorkspaceTreeDataProvider(workspaceService);
|
||||
@@ -59,7 +59,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IExten
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('dataworkspace.close', () => {
|
||||
vscode.commands.executeCommand('workbench.action.closeFolder');
|
||||
return vscode.commands.executeCommand('workbench.action.closeFolder');
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('projects.manageProject', async (treeItem: WorkspaceTreeItem) => {
|
||||
@@ -73,7 +73,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IExten
|
||||
}
|
||||
|
||||
function setProjectProviderContextValue(workspaceService: IWorkspaceService): void {
|
||||
vscode.commands.executeCommand('setContext', 'isProjectProviderAvailable', workspaceService.isProjectProviderAvailable);
|
||||
void vscode.commands.executeCommand('setContext', 'isProjectProviderAvailable', workspaceService.isProjectProviderAvailable);
|
||||
}
|
||||
|
||||
export function deactivate(): void {
|
||||
|
||||
@@ -23,7 +23,7 @@ export class WorkspaceService implements IWorkspaceService {
|
||||
private openedProjects: vscode.Uri[] | undefined = undefined;
|
||||
|
||||
constructor() {
|
||||
this.getProjectsInWorkspace(undefined, true);
|
||||
this.getProjectsInWorkspace(undefined, true).catch(err => console.error('Error initializing projects in workspace ', err));
|
||||
}
|
||||
|
||||
get isProjectProviderAvailable(): boolean {
|
||||
@@ -81,7 +81,7 @@ export class WorkspaceService implements IWorkspaceService {
|
||||
for (const projectFile of projectFiles) {
|
||||
if (previousProjects.includes(projectFile.path)) {
|
||||
projectsAlreadyOpen.push(projectFile.fsPath);
|
||||
vscode.window.showInformationMessage(constants.ProjectAlreadyOpened(projectFile.fsPath));
|
||||
void vscode.window.showInformationMessage(constants.ProjectAlreadyOpened(projectFile.fsPath));
|
||||
}
|
||||
else {
|
||||
newProjectAdded = true;
|
||||
@@ -206,7 +206,7 @@ export class WorkspaceService implements IWorkspaceService {
|
||||
|
||||
try {
|
||||
// show git output channel
|
||||
vscode.commands.executeCommand('git.showOutput');
|
||||
void vscode.commands.executeCommand('git.showOutput');
|
||||
const repositoryPath = await vscode.window.withProgress(
|
||||
opts,
|
||||
(progress, token) => gitApi.clone(url!, { parentPath: localClonePath!, progress, recursive: true }, token)
|
||||
@@ -214,9 +214,9 @@ export class WorkspaceService implements IWorkspaceService {
|
||||
|
||||
// get all the project files in the cloned repo and add them to workspace
|
||||
const repoProjects = (await this.getAllProjectsInFolder(vscode.Uri.file(repositoryPath)));
|
||||
this.addProjectsToWorkspace(repoProjects);
|
||||
await this.addProjectsToWorkspace(repoProjects);
|
||||
} catch (e) {
|
||||
vscode.window.showErrorMessage(constants.gitCloneError);
|
||||
void vscode.window.showErrorMessage(constants.gitCloneError);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ suite('workspaceTreeDataProvider Tests', function (): void {
|
||||
should.strictEqual(treeDataChangeHandler.calledOnce, true);
|
||||
});
|
||||
|
||||
test('test getTreeItem()', () => {
|
||||
test('test getTreeItem()', async function (): Promise<void> {
|
||||
const getTreeItemStub = sinon.stub();
|
||||
treeProvider.getTreeItem(({
|
||||
await treeProvider.getTreeItem(({
|
||||
treeDataProvider: ({
|
||||
getTreeItem: (arg: WorkspaceTreeItem) => {
|
||||
return getTreeItemStub(arg);
|
||||
|
||||
Reference in New Issue
Block a user