Skip to content

Commit 10b2f3d

Browse files
committed
removed unneeded ts directives
1 parent ad708aa commit 10b2f3d

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/ModuleResolver.ts

+23-25
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export type PrettierNodeModule = typeof prettier;
3636
const origFsStatSync = fs.statSync;
3737
const fsStatSyncWorkaround = (
3838
path: fs.PathLike,
39-
options: fs.StatSyncOptions,
39+
options: fs.StatSyncOptions
4040
) => {
4141
if (
4242
options?.throwIfNoEntry === true ||
@@ -136,10 +136,8 @@ export class ModuleResolver implements ModuleResolverInterface {
136136
typeof prettierPkgJson === "object" &&
137137
prettierPkgJson !== null &&
138138
"version" in prettierPkgJson &&
139-
// @ts-expect-error checked
140139
typeof prettierPkgJson.version === "string"
141140
) {
142-
// @ts-expect-error checked
143141
version = prettierPkgJson.version;
144142
}
145143

@@ -155,15 +153,15 @@ export class ModuleResolver implements ModuleResolverInterface {
155153
* @param fileName The path of the file to use as the starting point. If none provided, the bundled prettier will be used.
156154
*/
157155
public async getPrettierInstance(
158-
fileName: string,
156+
fileName: string
159157
): Promise<PrettierNodeModule | PrettierInstance | undefined> {
160158
if (!workspace.isTrusted) {
161159
this.loggingService.logDebug(UNTRUSTED_WORKSPACE_USING_BUNDLED_PRETTIER);
162160
return prettier;
163161
}
164162

165163
const { prettierPath, resolveGlobalModules } = getConfig(
166-
Uri.file(fileName),
164+
Uri.file(fileName)
167165
);
168166

169167
// Look for local module
@@ -188,7 +186,7 @@ export class ModuleResolver implements ModuleResolverInterface {
188186
this.loggingService.logInfo(
189187
`Attempted to determine module path from ${
190188
modulePath || moduleDirectory || "package.json"
191-
}`,
189+
}`
192190
);
193191
this.loggingService.logError(FAILED_TO_LOAD_MODULE_MESSAGE, error);
194192

@@ -211,7 +209,7 @@ export class ModuleResolver implements ModuleResolverInterface {
211209
if (resolvedGlobalPackageManagerPath) {
212210
const globalModulePath = path.join(
213211
resolvedGlobalPackageManagerPath,
214-
"prettier",
212+
"prettier"
215213
);
216214
if (fs.existsSync(globalModulePath)) {
217215
modulePath = globalModulePath;
@@ -246,7 +244,7 @@ export class ModuleResolver implements ModuleResolverInterface {
246244
this.loggingService.logInfo(
247245
`Attempted to load Prettier module from ${
248246
modulePath || "package.json"
249-
}`,
247+
}`
250248
);
251249
this.loggingService.logError(FAILED_TO_LOAD_MODULE_MESSAGE, error);
252250

@@ -268,7 +266,7 @@ export class ModuleResolver implements ModuleResolverInterface {
268266

269267
if (!isValidVersion) {
270268
this.loggingService.logInfo(
271-
`Attempted to load Prettier module from ${modulePath}`,
269+
`Attempted to load Prettier module from ${modulePath}`
272270
);
273271
this.loggingService.logError(OUTDATED_PRETTIER_VERSION_MESSAGE);
274272
return undefined;
@@ -284,7 +282,7 @@ export class ModuleResolver implements ModuleResolverInterface {
284282

285283
public async getResolvedIgnorePath(
286284
fileName: string,
287-
ignorePath: string,
285+
ignorePath: string
288286
): Promise<string | undefined> {
289287
const cacheKey = `${fileName}:${ignorePath}`;
290288
// cache resolvedIgnorePath because resolving it checks the file system
@@ -314,7 +312,7 @@ export class ModuleResolver implements ModuleResolverInterface {
314312
// https://stackoverflow.com/questions/17699599/node-js-check-if-file-exists#comment121041700_57708635
315313
await fs.promises.stat(p).then(
316314
() => true,
317-
() => false,
315+
() => false
318316
)
319317
) {
320318
resolvedIgnorePath = p;
@@ -331,7 +329,7 @@ export class ModuleResolver implements ModuleResolverInterface {
331329

332330
private adjustFileNameForPrettierVersion3_1_1(
333331
prettierInstance: { version: string | null },
334-
fileName: string,
332+
fileName: string
335333
) {
336334
if (!prettierInstance.version) {
337335
return fileName;
@@ -350,12 +348,12 @@ export class ModuleResolver implements ModuleResolverInterface {
350348
resolveConfigFile(filePath?: string): Promise<string | null>;
351349
resolveConfig(
352350
fileName: string,
353-
options?: prettier.ResolveConfigOptions,
351+
options?: prettier.ResolveConfigOptions
354352
): Promise<PrettierOptions | null>;
355353
},
356354
uri: Uri,
357355
fileName: string,
358-
vscodeConfig: PrettierVSCodeConfig,
356+
vscodeConfig: PrettierVSCodeConfig
359357
): Promise<"error" | "disabled" | PrettierOptions | null> {
360358
const isVirtual = uri.scheme !== "file" && uri.scheme !== "vscode-userdata";
361359

@@ -366,14 +364,14 @@ export class ModuleResolver implements ModuleResolverInterface {
366364
(await prettierInstance.resolveConfigFile(
367365
this.adjustFileNameForPrettierVersion3_1_1(
368366
prettierInstance,
369-
fileName,
370-
),
367+
fileName
368+
)
371369
)) ?? undefined;
372370
}
373371
} catch (error) {
374372
this.loggingService.logError(
375373
`Error resolving prettier configuration for ${fileName}`,
376-
error,
374+
error
377375
);
378376
return "error";
379377
}
@@ -395,15 +393,15 @@ export class ModuleResolver implements ModuleResolverInterface {
395393
} catch (error) {
396394
this.loggingService.logError(
397395
"Invalid prettier configuration file detected.",
398-
error,
396+
error
399397
);
400398
this.loggingService.logError(INVALID_PRETTIER_CONFIG);
401399

402400
return "error";
403401
}
404402
if (resolveConfigOptions.config) {
405403
this.loggingService.logInfo(
406-
`Using config file at ${resolveConfigOptions.config}`,
404+
`Using config file at ${resolveConfigOptions.config}`
407405
);
408406
}
409407

@@ -418,7 +416,7 @@ export class ModuleResolver implements ModuleResolverInterface {
418416
vscodeConfig.requireConfig
419417
) {
420418
this.loggingService.logInfo(
421-
"Require config set to true and no config present. Skipping file.",
419+
"Require config set to true and no config present. Skipping file."
422420
);
423421
return "disabled";
424422
}
@@ -428,7 +426,7 @@ export class ModuleResolver implements ModuleResolverInterface {
428426

429427
public async getResolvedConfig(
430428
{ fileName, uri }: TextDocument,
431-
vscodeConfig: PrettierVSCodeConfig,
429+
vscodeConfig: PrettierVSCodeConfig
432430
): Promise<"error" | "disabled" | PrettierOptions | null> {
433431
const prettierInstance: typeof prettier | PrettierInstance =
434432
(await this.getPrettierInstance(fileName)) || prettier;
@@ -437,7 +435,7 @@ export class ModuleResolver implements ModuleResolverInterface {
437435
prettierInstance,
438436
uri,
439437
fileName,
440-
vscodeConfig,
438+
vscodeConfig
441439
);
442440

443441
return resolvedConfig;
@@ -500,7 +498,7 @@ export class ModuleResolver implements ModuleResolverInterface {
500498
let packageJson;
501499
try {
502500
packageJson = JSON.parse(
503-
fs.readFileSync(path.join(dir, "package.json"), "utf8"),
501+
fs.readFileSync(path.join(dir, "package.json"), "utf8")
504502
);
505503
} catch (e) {
506504
// 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 {
520518
return findUp.stop;
521519
}
522520
},
523-
{ cwd: finalPath, type: "directory" },
521+
{ cwd: finalPath, type: "directory" }
524522
);
525523

526524
if (packageJsonResDir) {
@@ -540,7 +538,7 @@ export class ModuleResolver implements ModuleResolverInterface {
540538
return findUp.stop;
541539
}
542540
},
543-
{ cwd: finalPath, type: "directory" },
541+
{ cwd: finalPath, type: "directory" }
544542
);
545543

546544
if (nodeModulesResDir) {

0 commit comments

Comments
 (0)