Skip to content

Commit

Permalink
Fix eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Nov 23, 2024
1 parent 2c3b3dc commit defc71d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/extension-api-utils/extensionHost.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import * as vscode from "vscode";

declare const globalThis: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
};

export interface HostWebviewPanel extends vscode.Disposable {
readonly webview: vscode.Webview;
readonly visible: boolean;
reveal(viewColumn?: vscode.ViewColumn, preserveFocus?: boolean): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readonly onDidChangeViewState: vscode.Event<any>;
readonly onDidDispose: vscode.Event<void>;
}
Expand Down Expand Up @@ -53,6 +55,7 @@ export async function getPositronPreferredRuntime(
return await pst.runtime.getPreferredRuntime(languageId);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getPositronAPI(): undefined | any {
if (typeof globalThis?.acquirePositronApi !== "function") {
return;
Expand Down
1 change: 0 additions & 1 deletion src/extension-api-utils/getRemoteSafeUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable curly */
/* eslint-disable @typescript-eslint/naming-convention */
// From https://github.com/rstudio/shinyuieditor/blob/392659a0d936e4e38ac99660e89b0327db45b3a9/inst/vscode-extension/src/extension-api-utils/getRemoteSafeUrl.ts

Expand Down
4 changes: 2 additions & 2 deletions src/extension-api-utils/runShellCommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable curly */
/* eslint-disable @typescript-eslint/naming-convention */
// From https://github.com/rstudio/shinyuieditor/blob/392659a0d936e4e38ac99660e89b0327db45b3a9/inst/vscode-extension/src/extension-api-utils/runShellCommand.ts

Expand Down Expand Up @@ -50,10 +49,12 @@ export async function runShellCommand({
cleanup();
resolve({ status: "success", ...output });
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function onStdout(d: any) {
logger(`stdout: ${d.toString()}`);
output.stdout.push(d.toString());
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function onStderr(d: any) {
logger(`stderr: ${d.toString()}`);
output.stderr.push(d.toString());
Expand Down Expand Up @@ -90,7 +91,6 @@ export async function runShellCommand({
function makeLogger(verbose: boolean, prefix: string) {
return (msg: string) => {
if (verbose) {
// eslint-disable-next-line no-console
console.log(prefix + msg);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export function activate(context: vscode.ExtensionContext) {
shinyliveCreateFromExplorer
),
vscode.window.registerUriHandler({
handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
handlePositShinyUri(uri);
async handleUri(uri: vscode.Uri): Promise<void> {
await handlePositShinyUri(uri);
},
})
);
Expand Down
8 changes: 4 additions & 4 deletions src/net-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as http from "http";
import type { AddressInfo } from "net";
import * as net from "net";
import { AddressInfo } from "net";
import * as vscode from "vscode";
import { getExtensionHostPreview } from "./extension-api-utils/extensionHost";
import { getRemoteSafeUrl } from "./extension-api-utils/getRemoteSafeUrl";
Expand Down Expand Up @@ -138,7 +138,7 @@ export async function openBrowserWhenReady(
return;
}

let previewUrl = await getRemoteSafeUrl(port);
const previewUrl = await getRemoteSafeUrl(port);
await openBrowser(previewUrl);
}

Expand All @@ -162,7 +162,7 @@ export async function openBrowser(url: string): Promise<void> {
vscode.env.openExternal(vscode.Uri.parse(url));
return;
}
// @ts-ignore-next-line
// @ts-expect-error Fallthrough case in switch
case "internal": {
const hostPreview = getExtensionHostPreview();
if (hostPreview) {
Expand Down Expand Up @@ -200,7 +200,7 @@ export async function suggestPort(): Promise<number> {
if (!UNSAFE_PORTS.includes(port)) {
return port;
}
} while (true);
} while (true); // eslint-disable-line no-constant-condition
}

async function closeServer(server: http.Server): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function pyRunApp(): Promise<void> {

// Clear out the browser. Without this it can be a little confusing as to
// whether the app is trying to load or not.
openBrowser("about:blank");
await openBrowser("about:blank");
// If we start too quickly, openBrowserWhenReady may detect the old Shiny
// process (in the process of shutting down), not the new one. Give it a
// second. It's a shame to wait an extra second, but it's only when the Play
Expand Down Expand Up @@ -185,7 +185,7 @@ export async function rRunApp(): Promise<void> {

// Clear out the browser. Without this it can be a little confusing as to
// whether the app is trying to load or not.
openBrowser("about:blank");
await openBrowser("about:blank");
// If we start too quickly, openBrowserWhenReady may detect the old Shiny
// process (in the process of shutting down), not the new one. Give it a
// second. It's a shame to wait an extra second, but it's only when the Play
Expand Down
3 changes: 2 additions & 1 deletion src/shinylive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ async function askUserForOutputFile(
* selected directory, or `undefined` if the user canceled the selection.
*/
async function askUserForOutputDirectory(): Promise<vscode.Uri | undefined> {
let defaultUri = lastUsedDir || vscode.workspace.workspaceFolders?.[0].uri;
const defaultUri = lastUsedDir || vscode.workspace.workspaceFolders?.[0].uri;

const uri = await vscode.window.showSaveDialog({
defaultUri: defaultUri,
Expand Down Expand Up @@ -664,6 +664,7 @@ async function askUserToConfirmOverwrite(filePath: vscode.Uri) {

async function pathExists(file: vscode.Uri): Promise<boolean> {
try {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
typeof (await vscode.workspace.fs.stat(file)).type !== "undefined";
return true;
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ async function main() {
}
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
main();

0 comments on commit defc71d

Please sign in to comment.