From ad708aa2298dfc3f54fe4b56bb41801058a685d1 Mon Sep 17 00:00:00 2001 From: Nathan Totten Date: Wed, 14 Aug 2024 08:04:40 -0400 Subject: [PATCH 1/2] Upgraded typescript --- package.json | 2 +- yarn.lock | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 730736b42..bd3e00c3f 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "sinon": "^17.0.1", "tmp": "^0.2.3", "ts-loader": "^9.5.1", - "typescript": "^4.6.3", + "typescript": "^5.5.4", "util": "^0.12.4", "vsce": "^2.15.0", "vscode-nls-dev": "^4.0.4", diff --git a/yarn.lock b/yarn.lock index b1de81cfb..bc5456f2e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4010,11 +4010,16 @@ typed-rest-client@^1.8.4: tunnel "0.0.6" underscore "^1.12.1" -typescript@^4.5.4, typescript@^4.6.3: +typescript@^4.5.4: version "4.7.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== +typescript@^5.5.4: + version "5.5.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== + uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" From 10b2f3dbcd24fa29d522abf53fb2325a01923e50 Mon Sep 17 00:00:00 2001 From: Nathan Totten Date: Wed, 14 Aug 2024 08:08:30 -0400 Subject: [PATCH 2/2] removed unneeded ts directives --- src/ModuleResolver.ts | 48 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/ModuleResolver.ts b/src/ModuleResolver.ts index 7b89bf528..60f286673 100644 --- a/src/ModuleResolver.ts +++ b/src/ModuleResolver.ts @@ -36,7 +36,7 @@ export type PrettierNodeModule = typeof prettier; const origFsStatSync = fs.statSync; const fsStatSyncWorkaround = ( path: fs.PathLike, - options: fs.StatSyncOptions, + options: fs.StatSyncOptions ) => { if ( options?.throwIfNoEntry === true || @@ -136,10 +136,8 @@ export class ModuleResolver implements ModuleResolverInterface { typeof prettierPkgJson === "object" && prettierPkgJson !== null && "version" in prettierPkgJson && - // @ts-expect-error checked typeof prettierPkgJson.version === "string" ) { - // @ts-expect-error checked version = prettierPkgJson.version; } @@ -155,7 +153,7 @@ export class ModuleResolver implements ModuleResolverInterface { * @param fileName The path of the file to use as the starting point. If none provided, the bundled prettier will be used. */ public async getPrettierInstance( - fileName: string, + fileName: string ): Promise { if (!workspace.isTrusted) { this.loggingService.logDebug(UNTRUSTED_WORKSPACE_USING_BUNDLED_PRETTIER); @@ -163,7 +161,7 @@ export class ModuleResolver implements ModuleResolverInterface { } const { prettierPath, resolveGlobalModules } = getConfig( - Uri.file(fileName), + Uri.file(fileName) ); // Look for local module @@ -188,7 +186,7 @@ export class ModuleResolver implements ModuleResolverInterface { this.loggingService.logInfo( `Attempted to determine module path from ${ modulePath || moduleDirectory || "package.json" - }`, + }` ); this.loggingService.logError(FAILED_TO_LOAD_MODULE_MESSAGE, error); @@ -211,7 +209,7 @@ export class ModuleResolver implements ModuleResolverInterface { if (resolvedGlobalPackageManagerPath) { const globalModulePath = path.join( resolvedGlobalPackageManagerPath, - "prettier", + "prettier" ); if (fs.existsSync(globalModulePath)) { modulePath = globalModulePath; @@ -246,7 +244,7 @@ export class ModuleResolver implements ModuleResolverInterface { this.loggingService.logInfo( `Attempted to load Prettier module from ${ modulePath || "package.json" - }`, + }` ); this.loggingService.logError(FAILED_TO_LOAD_MODULE_MESSAGE, error); @@ -268,7 +266,7 @@ export class ModuleResolver implements ModuleResolverInterface { if (!isValidVersion) { this.loggingService.logInfo( - `Attempted to load Prettier module from ${modulePath}`, + `Attempted to load Prettier module from ${modulePath}` ); this.loggingService.logError(OUTDATED_PRETTIER_VERSION_MESSAGE); return undefined; @@ -284,7 +282,7 @@ export class ModuleResolver implements ModuleResolverInterface { public async getResolvedIgnorePath( fileName: string, - ignorePath: string, + ignorePath: string ): Promise { const cacheKey = `${fileName}:${ignorePath}`; // cache resolvedIgnorePath because resolving it checks the file system @@ -314,7 +312,7 @@ export class ModuleResolver implements ModuleResolverInterface { // https://stackoverflow.com/questions/17699599/node-js-check-if-file-exists#comment121041700_57708635 await fs.promises.stat(p).then( () => true, - () => false, + () => false ) ) { resolvedIgnorePath = p; @@ -331,7 +329,7 @@ export class ModuleResolver implements ModuleResolverInterface { private adjustFileNameForPrettierVersion3_1_1( prettierInstance: { version: string | null }, - fileName: string, + fileName: string ) { if (!prettierInstance.version) { return fileName; @@ -350,12 +348,12 @@ export class ModuleResolver implements ModuleResolverInterface { resolveConfigFile(filePath?: string): Promise; resolveConfig( fileName: string, - options?: prettier.ResolveConfigOptions, + options?: prettier.ResolveConfigOptions ): Promise; }, uri: Uri, fileName: string, - vscodeConfig: PrettierVSCodeConfig, + vscodeConfig: PrettierVSCodeConfig ): Promise<"error" | "disabled" | PrettierOptions | null> { const isVirtual = uri.scheme !== "file" && uri.scheme !== "vscode-userdata"; @@ -366,14 +364,14 @@ export class ModuleResolver implements ModuleResolverInterface { (await prettierInstance.resolveConfigFile( this.adjustFileNameForPrettierVersion3_1_1( prettierInstance, - fileName, - ), + fileName + ) )) ?? undefined; } } catch (error) { this.loggingService.logError( `Error resolving prettier configuration for ${fileName}`, - error, + error ); return "error"; } @@ -395,7 +393,7 @@ export class ModuleResolver implements ModuleResolverInterface { } catch (error) { this.loggingService.logError( "Invalid prettier configuration file detected.", - error, + error ); this.loggingService.logError(INVALID_PRETTIER_CONFIG); @@ -403,7 +401,7 @@ export class ModuleResolver implements ModuleResolverInterface { } if (resolveConfigOptions.config) { this.loggingService.logInfo( - `Using config file at ${resolveConfigOptions.config}`, + `Using config file at ${resolveConfigOptions.config}` ); } @@ -418,7 +416,7 @@ export class ModuleResolver implements ModuleResolverInterface { vscodeConfig.requireConfig ) { this.loggingService.logInfo( - "Require config set to true and no config present. Skipping file.", + "Require config set to true and no config present. Skipping file." ); return "disabled"; } @@ -428,7 +426,7 @@ export class ModuleResolver implements ModuleResolverInterface { public async getResolvedConfig( { fileName, uri }: TextDocument, - vscodeConfig: PrettierVSCodeConfig, + vscodeConfig: PrettierVSCodeConfig ): Promise<"error" | "disabled" | PrettierOptions | null> { const prettierInstance: typeof prettier | PrettierInstance = (await this.getPrettierInstance(fileName)) || prettier; @@ -437,7 +435,7 @@ export class ModuleResolver implements ModuleResolverInterface { prettierInstance, uri, fileName, - vscodeConfig, + vscodeConfig ); return resolvedConfig; @@ -500,7 +498,7 @@ export class ModuleResolver implements ModuleResolverInterface { let packageJson; try { packageJson = JSON.parse( - fs.readFileSync(path.join(dir, "package.json"), "utf8"), + fs.readFileSync(path.join(dir, "package.json"), "utf8") ); } catch (e) { // Swallow, if we can't read it we don't want to resolve based on it @@ -520,7 +518,7 @@ export class ModuleResolver implements ModuleResolverInterface { return findUp.stop; } }, - { cwd: finalPath, type: "directory" }, + { cwd: finalPath, type: "directory" } ); if (packageJsonResDir) { @@ -540,7 +538,7 @@ export class ModuleResolver implements ModuleResolverInterface { return findUp.stop; } }, - { cwd: finalPath, type: "directory" }, + { cwd: finalPath, type: "directory" } ); if (nodeModulesResDir) {