diff --git a/extensions/vscode/src/actions/showAssociateGUID.ts b/extensions/vscode/src/actions/showAssociateGUID.ts index c0b93d135..7d89f9d74 100644 --- a/extensions/vscode/src/actions/showAssociateGUID.ts +++ b/extensions/vscode/src/actions/showAssociateGUID.ts @@ -8,7 +8,7 @@ import { Views } from "src/constants"; import { useApi } from "src/api"; export async function showAssociateGUID(state: PublisherState) { - let urlOrGuid = ""; + const urlOrGuid = ""; const result = await window.showInputBox({ title: "Enter the URL of the Existing Content Item on the Server", prompt: "Please provide the content's URL from Connect", diff --git a/extensions/vscode/src/api/client.ts b/extensions/vscode/src/api/client.ts index 05cdcbbe1..b13a6e8df 100644 --- a/extensions/vscode/src/api/client.ts +++ b/extensions/vscode/src/api/client.ts @@ -57,7 +57,7 @@ class PublishingClientApi { this.entrypoints = new EntryPoints(this.client); } - logDuration(response: AxiosResponse) { + logDuration(response: AxiosResponse) { const timestamp = response.config.ts; if (timestamp) { const request = response.request; diff --git a/extensions/vscode/src/api/types/error.ts b/extensions/vscode/src/api/types/error.ts index 33f6220a8..6a911ead8 100644 --- a/extensions/vscode/src/api/types/error.ts +++ b/extensions/vscode/src/api/types/error.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ // Copyright (C) 2023 by Posit Software, PBC. import { ErrorCode } from "../../utils/errorTypes"; diff --git a/extensions/vscode/src/api/types/events.ts b/extensions/vscode/src/api/types/events.ts index 8654c35e4..07a628037 100644 --- a/extensions/vscode/src/api/types/events.ts +++ b/extensions/vscode/src/api/types/events.ts @@ -622,10 +622,6 @@ export function isPublishCreateDeploymentStart( export interface PublishCreateDeploymentLog extends EventStreamMessage { type: "publish/createDeployment/log"; - data: { - // structured data not guaranteed, use selective or generic queries - // from data map - }; } export type OnPublishCreateDeploymentLogCallback = ( msg: PublishCreateDeploymentLog, @@ -683,10 +679,6 @@ export function isPublishUploadBundleStart( export interface PublishUploadBundleLog extends EventStreamMessage { type: "publish/uploadBundle/log"; - data: { - // structured data not guaranteed, use selective or generic queries - // from data map - }; } export type OnPublishUploadBundleLogCallback = ( msg: PublishUploadBundleLog, @@ -745,10 +737,6 @@ export function isPublishDeployBundleStart( export interface PublishDeployBundleLog extends EventStreamMessage { type: "publish/deployBundle/log"; - data: { - // structured data not guaranteed, use selective or generic queries - // from data map - }; } export type OnPublishDeployBundleLogCallback = ( msg: PublishDeployBundleLog, diff --git a/extensions/vscode/src/eventErrors.test.ts b/extensions/vscode/src/eventErrors.test.ts index db780c703..5dc85e9cb 100644 --- a/extensions/vscode/src/eventErrors.test.ts +++ b/extensions/vscode/src/eventErrors.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ // Copyright (C) 2024 by Posit Software, PBC. import { describe, expect, test } from "vitest"; diff --git a/extensions/vscode/src/events.ts b/extensions/vscode/src/events.ts index d09ce499e..0d09258e1 100644 --- a/extensions/vscode/src/events.ts +++ b/extensions/vscode/src/events.ts @@ -287,6 +287,7 @@ export class EventStream extends Readable implements Disposable { * @param object - The object to convert. * @returns The object with camel case keys. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any const convertKeysToCamelCase = (object: any): any => { if (typeof object !== "object" || object === null) { return object; @@ -297,9 +298,10 @@ const convertKeysToCamelCase = (object: any): any => { return object.map((item) => convertKeysToCamelCase(item)); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any const newObject: any = {}; for (const key in object) { - if (object.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(object, key)) { // Convert the key to camel case const newKey = key.charAt(0).toLowerCase() + key.slice(1); // Recursively convert keys for nested objects diff --git a/extensions/vscode/src/multiStepInputs/multiStepHelper.ts b/extensions/vscode/src/multiStepInputs/multiStepHelper.ts index 590ffcbb2..5e6a5ba50 100644 --- a/extensions/vscode/src/multiStepInputs/multiStepHelper.ts +++ b/extensions/vscode/src/multiStepInputs/multiStepHelper.ts @@ -184,6 +184,7 @@ export class MultiStepInput { if (item === QuickInputButtons.Back) { reject(InputFlowAction.back); } else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any resolve(item); } }), @@ -260,6 +261,7 @@ export class MultiStepInput { if (item === QuickInputButtons.Back) { reject(InputFlowAction.back); } else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any resolve(item); } }), diff --git a/extensions/vscode/src/multiStepInputs/newDeployment.ts b/extensions/vscode/src/multiStepInputs/newDeployment.ts index eb2c2608e..3842812b1 100644 --- a/extensions/vscode/src/multiStepInputs/newDeployment.ts +++ b/extensions/vscode/src/multiStepInputs/newDeployment.ts @@ -66,9 +66,9 @@ export async function newDeployment( let credentials: Credential[] = []; let credentialListItems: QuickPickItem[] = []; - let entryPointListItems: QuickPickItem[] = []; + const entryPointListItems: QuickPickItem[] = []; let inspectionResults: ConfigurationInspectionResult[] = []; - let contentRecordNames = new Map(); + const contentRecordNames = new Map(); let newConfig: Configuration | undefined; let newOrSelectedCredential: Credential | undefined; @@ -95,7 +95,7 @@ export async function newDeployment( newCredentials: NewCredentialAttrs; }; - let newDeploymentData: NewDeploymentData = { + const newDeploymentData: NewDeploymentData = { entrypoint: {}, newCredentials: {}, }; @@ -114,62 +114,58 @@ export async function newDeployment( return newCredentialForced() || newCredentialSelected(); }; - const getConfigurationInspectionQuickPicks = ( + const getConfigurationInspectionQuickPicks = async ( relEntryPoint: EntryPointPath, - ) => { - return new Promise( - async (resolve, reject) => { - const inspectionListItems: QuickPickItemWithInspectionResult[] = []; - - try { - const python = await getPythonInterpreterPath(); - const relEntryPointDir = path.dirname(relEntryPoint); - const relEntryPointFile = path.basename(relEntryPoint); - - const inspectResponse = await api.configurations.inspect( - relEntryPointDir, - python, - { - entrypoint: relEntryPointFile, - }, - ); - - inspectionResults = inspectResponse.data; - inspectionResults.forEach((result) => { - const config = result.configuration; - if (config.entrypoint) { - inspectionListItems.push({ - iconPath: new ThemeIcon("gear"), - label: config.type.toString(), - description: `(${contentTypeStrings[config.type]})`, - inspectionResult: result, - }); - } + ): Promise => { + const inspectionListItems: QuickPickItemWithInspectionResult[] = []; + + try { + const python = await getPythonInterpreterPath(); + const relEntryPointDir = path.dirname(relEntryPoint); + const relEntryPointFile = path.basename(relEntryPoint); + + const inspectResponse = await api.configurations.inspect( + relEntryPointDir, + python, + { + entrypoint: relEntryPointFile, + }, + ); + + inspectionResults = inspectResponse.data; + inspectionResults.forEach((result) => { + const config = result.configuration; + if (config.entrypoint) { + inspectionListItems.push({ + iconPath: new ThemeIcon("gear"), + label: config.type.toString(), + description: `(${contentTypeStrings[config.type]})`, + inspectionResult: result, }); - } catch (error: unknown) { - if (isAxiosErrorWithJson(error)) { - return reject(error); - } - const summary = getSummaryStringFromError( - "newDeployment, configurations.inspect", - error, - ); - window.showErrorMessage( - `Unable to continue with project inspection failure for ${entryPointFile}. ${summary}`, - ); - return reject(); } - if (!inspectionListItems.length) { - const msg = `Unable to continue with no project entrypoints found during inspection for ${entryPointFile}.`; - window.showErrorMessage(msg); - return reject(); - } - return resolve(inspectionListItems); - }, - ); + }); + } catch (error: unknown) { + if (isAxiosErrorWithJson(error)) { + throw error; + } + const summary = getSummaryStringFromError( + "newDeployment, configurations.inspect", + error, + ); + window.showErrorMessage( + `Unable to continue with project inspection failure for ${entryPointFile}. ${summary}`, + ); + throw error; + } + if (!inspectionListItems.length) { + const msg = `Unable to continue with no project entrypoints found during inspection for ${entryPointFile}.`; + window.showErrorMessage(msg); + throw new Error(msg); + } + return inspectionListItems; }; - const getCredentials = new Promise(async (resolve, reject) => { + const getCredentials = async (): Promise => { try { const response = await api.credentials.list(); credentials = response.data; @@ -190,12 +186,11 @@ export async function newDeployment( window.showErrorMessage( `Unable to continue with a failed API response. ${summary}`, ); - return reject(summary); + throw error; } - return resolve(); - }); + }; - const getEntrypoints = new Promise((resolve) => { + const getEntrypoints = () => { if (entryPointFile) { // we were passed in a specific entrypoint file. // while we don't need it, we'll still provide the results @@ -205,7 +200,7 @@ export async function newDeployment( iconPath: new ThemeIcon("file"), label: entryPointPath, }); - return resolve(); + return; } // build up a list of open files, relative to the opened workspace folder @@ -237,10 +232,10 @@ export async function newDeployment( label: browseForEntrypointLabel, detail: "Select a file as your entrypoint.", }); - return resolve(); - }); + return; + }; - const getContentRecords = new Promise(async (resolve, reject) => { + const getContentRecords = async () => { try { const response = await api.contentRecords.getAll( projectDir ? projectDir : ".", @@ -266,10 +261,9 @@ export async function newDeployment( window.showInformationMessage( `Unable to continue due to deployment error. ${summary}`, ); - return reject(); + throw error; } - return resolve(); - }); + }; // *************************************************************** // Order of all steps @@ -763,7 +757,11 @@ export async function newDeployment( "Initializing::newDeployment", viewId, async () => - await Promise.all([getCredentials, getEntrypoints, getContentRecords]), + await Promise.all([ + getCredentials(), + getEntrypoints(), + getContentRecords(), + ]), ); } catch { // errors have already been displayed by the underlying promises.. @@ -874,7 +872,7 @@ export async function newDeployment( FileAction.INCLUDE, newDeploymentData.entrypoint.inspectionResult.projectDir, ); - } catch (error: unknown) { + } catch (_error: unknown) { // continue on as it is not necessary to include .posit files for deployment console.debug( `Failed to add the configuration file '${configName}' to \`files\`.`, @@ -923,7 +921,7 @@ export async function newDeployment( FileAction.INCLUDE, newDeploymentData.entrypoint.inspectionResult.projectDir, ); - } catch (error: unknown) { + } catch (_error: unknown) { // continue on as it is not necessary to include .posit files for deployment console.debug( `Failed to add the content record file '${newContentRecord.deploymentName}' to \`files\`.`, diff --git a/extensions/vscode/src/multiStepInputs/selectNewOrExistingConfig.ts b/extensions/vscode/src/multiStepInputs/selectNewOrExistingConfig.ts index 97172d6bc..2997a10d9 100644 --- a/extensions/vscode/src/multiStepInputs/selectNewOrExistingConfig.ts +++ b/extensions/vscode/src/multiStepInputs/selectNewOrExistingConfig.ts @@ -54,7 +54,7 @@ export async function selectNewOrExistingConfig( let configFileListItems: QuickPickItem[] = []; let configurations: Configuration[] = []; - let entryPointListItems: QuickPickItemWithIndex[] = []; + const entryPointListItems: QuickPickItemWithIndex[] = []; let inspectionResults: ConfigurationInspectionResult[] = []; const createNewConfigurationLabel = "Create a New Configuration"; @@ -97,13 +97,13 @@ export async function selectNewOrExistingConfig( } } - const getConfigurations = new Promise(async (resolve, reject) => { + const getConfigurations = async () => { try { // get all configurations const response = await api.configurations.getAll( activeDeployment.projectDir, ); - let rawConfigs = response.data; + const rawConfigs = response.data; // remove the errors configurations = configurations.filter( (cfg): cfg is Configuration => !isConfigurationError(cfg), @@ -139,7 +139,7 @@ export async function selectNewOrExistingConfig( kind: QuickPickItemKind.Separator, }); } - let existingConfigFileListItems: QuickPickItem[] = []; + const existingConfigFileListItems: QuickPickItem[] = []; configurations.forEach((config) => { const { title, problem } = calculateTitle(activeDeployment, config); if (problem) { @@ -152,8 +152,8 @@ export async function selectNewOrExistingConfig( }); }); existingConfigFileListItems.sort((a: QuickPickItem, b: QuickPickItem) => { - var x = a.label.toLowerCase(); - var y = b.label.toLowerCase(); + const x = a.label.toLowerCase(); + const y = b.label.toLowerCase(); return x < y ? -1 : x > y ? 1 : 0; }); // add to end of our list items @@ -168,55 +168,51 @@ export async function selectNewOrExistingConfig( window.showInformationMessage( `Unable to continue with API Error: ${summary}`, ); - return reject(); + throw error; } - resolve(); - }); - - const getConfigurationInspections = new Promise( - async (resolve, reject) => { - try { - const python = await getPythonInterpreterPath(); - const inspectResponse = await api.configurations.inspect( - activeDeployment.projectDir, - python, - ); - inspectionResults = filterInspectionResultsToType( - inspectResponse.data, - effectiveContentTypeFilter, - ); - inspectionResults.forEach((result, i) => { - const config = result.configuration; - if (config.entrypoint) { - entryPointListItems.push({ - iconPath: new ThemeIcon("file"), - label: config.entrypoint, - description: `(${contentTypeStrings[config.type]})`, - detail: isRelativePathRoot(result.projectDir) - ? undefined - : `${result.projectDir}${path.sep}`, - index: i, - }); - } - }); - } catch (error: unknown) { - const summary = getSummaryStringFromError( - "selectNewOrExistingConfig, configurations.inspect", - error, - ); - window.showErrorMessage( - `Unable to continue with project inspection failure. ${summary}`, - ); - return reject(); - } - if (!entryPointListItems.length) { - const msg = `Unable to continue with no project entrypoints found during inspection`; - window.showErrorMessage(msg); - return reject(); - } - return resolve(); - }, - ); + }; + + const getConfigurationInspections = async () => { + try { + const python = await getPythonInterpreterPath(); + const inspectResponse = await api.configurations.inspect( + activeDeployment.projectDir, + python, + ); + inspectionResults = filterInspectionResultsToType( + inspectResponse.data, + effectiveContentTypeFilter, + ); + inspectionResults.forEach((result, i) => { + const config = result.configuration; + if (config.entrypoint) { + entryPointListItems.push({ + iconPath: new ThemeIcon("file"), + label: config.entrypoint, + description: `(${contentTypeStrings[config.type]})`, + detail: isRelativePathRoot(result.projectDir) + ? undefined + : `${result.projectDir}${path.sep}`, + index: i, + }); + } + }); + } catch (error: unknown) { + const summary = getSummaryStringFromError( + "selectNewOrExistingConfig, configurations.inspect", + error, + ); + window.showErrorMessage( + `Unable to continue with project inspection failure. ${summary}`, + ); + throw error; + } + if (!entryPointListItems.length) { + const msg = `Unable to continue with no project entrypoints found during inspection`; + window.showErrorMessage(msg); + throw new Error(msg); + } + }; // *************************************************************** // Order of all steps @@ -392,7 +388,7 @@ export async function selectNewOrExistingConfig( "Initializing::selectNewOrExistingConfig", viewId, async () => - await Promise.all([getConfigurations, getConfigurationInspections]), + await Promise.all([getConfigurations(), getConfigurationInspections()]), ); } catch { // errors have already been displayed by the underlying promises.. diff --git a/extensions/vscode/src/test/suite/extension.test.ts b/extensions/vscode/src/test/suite/extension.test.ts index b8c31d2e0..5d2ed2dfb 100644 --- a/extensions/vscode/src/test/suite/extension.test.ts +++ b/extensions/vscode/src/test/suite/extension.test.ts @@ -7,6 +7,7 @@ import { Extension, extensions } from "vscode"; suite("Extension Test Suite", () => { test("extension is registered", () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const extension: Extension = extensions.getExtension("posit.publisher")!; assert.ok(extension !== undefined); diff --git a/extensions/vscode/src/types/messages/conduit.ts b/extensions/vscode/src/types/messages/conduit.ts index cebf256ab..391bb6e3c 100644 --- a/extensions/vscode/src/types/messages/conduit.ts +++ b/extensions/vscode/src/types/messages/conduit.ts @@ -3,21 +3,15 @@ import { HostToWebviewMessage, HostToWebviewMessageType, - isHostToWebviewMessage, } from "./hostToWebviewMessages"; import { WebviewToHostMessage, WebviewToHostMessageType, - isWebviewToHostMessage, } from "./webviewToHostMessages"; export type MessageType = WebviewToHostMessageType | HostToWebviewMessageType; export type ConduitMessage = HostToWebviewMessage | WebviewToHostMessage; -export function isConduitMessage(msg: any): msg is ConduitMessage { - return isHostToWebviewMessage(msg) || isWebviewToHostMessage(msg); -} - export type WebviewToHostMessageCB = (msg: WebviewToHostMessage) => void; export type HostToWebviewMessageCB = (msg: HostToWebviewMessage) => void; diff --git a/extensions/vscode/src/types/messages/hostToWebviewMessages.ts b/extensions/vscode/src/types/messages/hostToWebviewMessages.ts index dafd264fd..90078d2f7 100644 --- a/extensions/vscode/src/types/messages/hostToWebviewMessages.ts +++ b/extensions/vscode/src/types/messages/hostToWebviewMessages.ts @@ -59,6 +59,7 @@ export type HostToWebviewMessage = | SetPathSeparatorMsg | UpdateServerEnvironmentMsg; +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function isHostToWebviewMessage(msg: any): msg is HostToWebviewMessage { return ( msg.kind === HostToWebviewMessageType.INITIALIZING_REQUEST_COMPLETE || diff --git a/extensions/vscode/src/types/messages/webviewToHostMessages.ts b/extensions/vscode/src/types/messages/webviewToHostMessages.ts index eab12f8f8..b83a064d5 100644 --- a/extensions/vscode/src/types/messages/webviewToHostMessages.ts +++ b/extensions/vscode/src/types/messages/webviewToHostMessages.ts @@ -64,6 +64,7 @@ export type WebviewToHostMessage = | ViewPublishingLog | ShowAssociateGUIDMsg; +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function isWebviewToHostMessage(msg: any): msg is WebviewToHostMessage { return ( msg.kind === WebviewToHostMessageType.DEPLOY || diff --git a/extensions/vscode/src/utils/config.ts b/extensions/vscode/src/utils/config.ts index bb7cfcd69..1691932de 100644 --- a/extensions/vscode/src/utils/config.ts +++ b/extensions/vscode/src/utils/config.ts @@ -15,7 +15,9 @@ export async function getPythonInterpreterPath(): Promise { "python.interpreterPath", { workspaceFolder: workspaceFolder }, ); - } catch {} + } catch { + // Ignore + } if (configuredPython === undefined) { return undefined; } @@ -30,7 +32,7 @@ export async function getPythonInterpreterPath(): Promise { "Scripts/python.exe", "Scripts/python3.exe", ]; - for (let name of names) { + for (const name of names) { const candidate = Uri.joinPath(pythonUri, name); if (await fileExists(candidate)) { python = candidate.fsPath; diff --git a/extensions/vscode/src/utils/errorEnhancer.ts b/extensions/vscode/src/utils/errorEnhancer.ts index e0482414d..5042d72a0 100644 --- a/extensions/vscode/src/utils/errorEnhancer.ts +++ b/extensions/vscode/src/utils/errorEnhancer.ts @@ -5,6 +5,7 @@ export enum ErrorMessageActionIds { } export function isErrorMessageActionId( + // eslint-disable-next-line @typescript-eslint/no-explicit-any searchValue: any, ): searchValue is ErrorMessageActionIds { return Object.values(ErrorMessageActionIds).includes(searchValue); diff --git a/extensions/vscode/src/utils/errorTypes.test.ts b/extensions/vscode/src/utils/errorTypes.test.ts index 15b8e629b..f810db18b 100644 --- a/extensions/vscode/src/utils/errorTypes.test.ts +++ b/extensions/vscode/src/utils/errorTypes.test.ts @@ -25,6 +25,7 @@ import { isErrPythonExecNotFoundError, } from "./errorTypes"; +// eslint-disable-next-line @typescript-eslint/no-explicit-any const mkAxiosJsonErr = (data: Record) => { return new AxiosError(undefined, undefined, undefined, undefined, { status: 0, diff --git a/extensions/vscode/src/utils/errorTypes.ts b/extensions/vscode/src/utils/errorTypes.ts index 1da43d1ee..5902eef56 100644 --- a/extensions/vscode/src/utils/errorTypes.ts +++ b/extensions/vscode/src/utils/errorTypes.ts @@ -53,7 +53,7 @@ export type ErrUnknown = MkErrorDataType< "unknown", { error: string; - data: Record; + data: Record; } >; export const isErrUnknown = mkErrorTypeGuard("unknown"); diff --git a/extensions/vscode/src/utils/errors.test.ts b/extensions/vscode/src/utils/errors.test.ts index d37b2bc3d..93985e57a 100644 --- a/extensions/vscode/src/utils/errors.test.ts +++ b/extensions/vscode/src/utils/errors.test.ts @@ -4,6 +4,7 @@ import { describe, expect, test } from "vitest"; import { AxiosError, AxiosHeaders } from "axios"; import { getSummaryStringFromError } from "./errors"; +// eslint-disable-next-line @typescript-eslint/no-explicit-any const mkAxiosJsonErr = (data: Record) => { return new AxiosError(undefined, undefined, undefined, undefined, { status: 0, diff --git a/extensions/vscode/src/utils/errors.ts b/extensions/vscode/src/utils/errors.ts index 5eb27bd09..c6615ee13 100644 --- a/extensions/vscode/src/utils/errors.ts +++ b/extensions/vscode/src/utils/errors.ts @@ -142,14 +142,7 @@ export const scrubErrorData = (data: Record | undefined) => { } // remove what we don't want to display // in this unknown list of attributes - const { - // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-shadow - file, - method, - status, - url, - ...remainingData - } = data; + const { file, method, status, url, ...remainingData } = data; if (Object.keys(remainingData).length === 0) { return undefined; diff --git a/extensions/vscode/src/utils/files.ts b/extensions/vscode/src/utils/files.ts index e9b791d87..63ff42f21 100644 --- a/extensions/vscode/src/utils/files.ts +++ b/extensions/vscode/src/utils/files.ts @@ -19,7 +19,7 @@ export async function fileExists(fileUri: Uri): Promise { try { await workspace.fs.stat(fileUri); return true; - } catch (e: unknown) { + } catch (_e: unknown) { return false; } } @@ -28,7 +28,7 @@ export async function isDir(fileUri: Uri): Promise { try { const info = await workspace.fs.stat(fileUri); return (info.type & FileType.Directory) !== 0; - } catch (e: unknown) { + } catch (_e: unknown) { return false; } } @@ -49,7 +49,7 @@ export function isValidFilename(filename: string): boolean { return false; } const forbidden = "/:*?\"<>|'\\"; - for (let c of filename) { + for (const c of filename) { if (forbidden.includes(c)) { return false; } @@ -175,8 +175,8 @@ export function pathSort(paths: string[], sep: string): string[] { } export function pathSorter(a: string[], b: string[]): number { - var l = Math.max(a.length, b.length); - for (var i = 0; i < l; i += 1) { + const l = Math.max(a.length, b.length); + for (let i = 0; i < l; i += 1) { if (!(i in a)) { return -1; } diff --git a/extensions/vscode/src/utils/variables.ts b/extensions/vscode/src/utils/variables.ts index a3ddc262d..d219a20dd 100644 --- a/extensions/vscode/src/utils/variables.ts +++ b/extensions/vscode/src/utils/variables.ts @@ -10,18 +10,18 @@ export function substituteVariables(s: string, recursive: boolean = false) { // Including it here because the NPM package is way // out of date and triggers npm audit messages. - let workspaces = workspace.workspaceFolders || []; - let workspaceFolder = workspace.workspaceFolders?.length + const workspaces = workspace.workspaceFolders || []; + const workspaceFolder = workspace.workspaceFolders?.length ? workspace.workspaceFolders[0] : null; - let activeFile = window.activeTextEditor?.document; - let absoluteFilePath = activeFile?.uri.fsPath || ""; + const activeFile = window.activeTextEditor?.document; + const absoluteFilePath = activeFile?.uri.fsPath || ""; s = s.replace(/\${workspaceFolder}/g, workspaceFolder?.uri.fsPath || ""); s = s.replace(/\${workspaceFolderBasename}/g, workspaceFolder?.name || ""); s = s.replace(/\${file}/g, absoluteFilePath); let activeWorkspace = workspaceFolder; let relativeFilePath = absoluteFilePath; - for (let workspace of workspaces) { + for (const workspace of workspaces) { if ( absoluteFilePath.replace(workspace.uri.fsPath, "") !== absoluteFilePath ) { @@ -32,7 +32,7 @@ export function substituteVariables(s: string, recursive: boolean = false) { break; } } - let parsedPath = path.parse(absoluteFilePath); + const parsedPath = path.parse(absoluteFilePath); s = s.replace(/\${fileWorkspaceFolder}/g, activeWorkspace?.uri.fsPath || ""); s = s.replace(/\${relativeFile}/g, relativeFilePath); s = s.replace( diff --git a/extensions/vscode/src/utils/webviewConduit.ts b/extensions/vscode/src/utils/webviewConduit.ts index 4b75716bc..547b5f9dc 100644 --- a/extensions/vscode/src/utils/webviewConduit.ts +++ b/extensions/vscode/src/utils/webviewConduit.ts @@ -16,6 +16,7 @@ export class WebviewConduit { constructor() {} + // eslint-disable-next-line @typescript-eslint/no-explicit-any private onRawMsgCB = (e: any) => { const obj = JSON.parse(e); // console.debug( diff --git a/extensions/vscode/src/views/deployProgress.ts b/extensions/vscode/src/views/deployProgress.ts index a37964aae..573dd5c02 100644 --- a/extensions/vscode/src/views/deployProgress.ts +++ b/extensions/vscode/src/views/deployProgress.ts @@ -12,7 +12,9 @@ export function deployProject(localID: string, stream: EventStream) { cancellable: true, }, (progress, token) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any let resolveCB: (reason?: any) => void; + // eslint-disable-next-line @typescript-eslint/no-explicit-any let rejectCB: (reason?: any) => void; const registrations: UnregisterCallback[] = []; const promise = new Promise((resolve, reject) => { @@ -420,7 +422,7 @@ export function deployProject(localID: string, stream: EventStream) { }); resolveCB("Success!"); - let visitOption = "View"; + const visitOption = "View"; const selection = await window.showInformationMessage( "Deployment was successful", visitOption, diff --git a/extensions/vscode/src/views/homeView.ts b/extensions/vscode/src/views/homeView.ts index fcbb14591..6d55a46f0 100644 --- a/extensions/vscode/src/views/homeView.ts +++ b/extensions/vscode/src/views/homeView.ts @@ -1203,7 +1203,7 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { } } - let credential = + const credential = this.state.findCredentialForContentRecord(contentRecord); const result = calculateTitle(contentRecord, config); @@ -1218,7 +1218,7 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { problem = true; } - let details = []; + const details = []; if (credential?.name) { details.push(credential.name); } else { @@ -1241,7 +1241,7 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { } const detail = details.join(" • "); - let lastMatch = + const lastMatch = lastContentRecordName === contentRecord.saveName && lastContentRecordProjectDir === contentRecord.projectDir && lastConfigName === configName; @@ -1262,8 +1262,8 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { }); existingDeploymentQuickPickList.sort( (a: QuickPickItem, b: QuickPickItem) => { - var x = a.label.toLowerCase(); - var y = b.label.toLowerCase(); + const x = a.label.toLowerCase(); + const y = b.label.toLowerCase(); return x < y ? -1 : x > y ? 1 : 0; }, ); @@ -1578,7 +1578,7 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { environment: response.data, }, }); - } catch (error: unknown) { + } catch (_error: unknown) { // No matter the error we clear the environment this.webviewConduit.sendMsg({ kind: HostToWebviewMessageType.UPDATE_SERVER_ENVIRONMENT, @@ -1621,8 +1621,8 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { // get the configs which are filtered for the entrypoint in that projectDir // determine a list of deployments that use those filtered configs - let contentRecordList: (ContentRecord | PreContentRecord)[] = []; - const getContentRecords = new Promise(async (resolve, reject) => { + const contentRecordList: (ContentRecord | PreContentRecord)[] = []; + const getContentRecords = async () => { try { const response = await api.contentRecords.getAll(entrypointDir, { recursive: false, @@ -1640,19 +1640,18 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { window.showInformationMessage( `Unable to continue due to deployment error. ${summary}`, ); - return reject(); + throw error; } - return resolve(); - }); + }; - let configMap = new Map(); - const getConfigurations = new Promise(async (resolve, reject) => { + const configMap = new Map(); + const getConfigurations = async () => { try { const response = await api.configurations.getAll(entrypointDir, { entrypoint: entrypointFile, recursive: false, }); - let rawConfigs = response.data; + const rawConfigs = response.data; rawConfigs.forEach((cfg) => { if (!isConfigurationError(cfg)) { configMap.set(cfg.configurationName, cfg); @@ -1666,17 +1665,16 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable { window.showErrorMessage( `Unable to continue with API Error: ${summary}`, ); - return reject(); + throw error; } - resolve(); - }); + }; try { await showProgress( "Initializing::handleFileInitiatedDeployment", Views.HomeView, async () => { - return await Promise.all([getContentRecords, getConfigurations]); + return await Promise.all([getContentRecords(), getConfigurations()]); }, ); } catch { diff --git a/extensions/vscode/src/views/logs.ts b/extensions/vscode/src/views/logs.ts index 633c0d3fc..3ed65f493 100644 --- a/extensions/vscode/src/views/logs.ts +++ b/extensions/vscode/src/views/logs.ts @@ -193,9 +193,9 @@ export class LogsTreeDataProvider implements TreeDataProvider { } }); - let showLogsOption = "View Log"; - let options = [showLogsOption]; - let enhancedError = findErrorMessageSplitOption(msg.data.message); + const showLogsOption = "View Log"; + const options = [showLogsOption]; + const enhancedError = findErrorMessageSplitOption(msg.data.message); if (enhancedError && enhancedError.buttonStr) { options.push(enhancedError.buttonStr); } diff --git a/extensions/vscode/src/watchers.ts b/extensions/vscode/src/watchers.ts index 48386f3a2..842347964 100644 --- a/extensions/vscode/src/watchers.ts +++ b/extensions/vscode/src/watchers.ts @@ -104,7 +104,7 @@ export class ContentRecordWatcherManager implements Disposable { } dispose() { - this.contentRecord?.dispose; + this.contentRecord?.dispose(); } }