@@ -36,7 +36,7 @@ export type PrettierNodeModule = typeof prettier;
36
36
const origFsStatSync = fs . statSync ;
37
37
const fsStatSyncWorkaround = (
38
38
path : fs . PathLike ,
39
- options : fs . StatSyncOptions ,
39
+ options : fs . StatSyncOptions
40
40
) => {
41
41
if (
42
42
options ?. throwIfNoEntry === true ||
@@ -136,10 +136,8 @@ export class ModuleResolver implements ModuleResolverInterface {
136
136
typeof prettierPkgJson === "object" &&
137
137
prettierPkgJson !== null &&
138
138
"version" in prettierPkgJson &&
139
- // @ts -expect-error checked
140
139
typeof prettierPkgJson . version === "string"
141
140
) {
142
- // @ts -expect-error checked
143
141
version = prettierPkgJson . version ;
144
142
}
145
143
@@ -155,15 +153,15 @@ export class ModuleResolver implements ModuleResolverInterface {
155
153
* @param fileName The path of the file to use as the starting point. If none provided, the bundled prettier will be used.
156
154
*/
157
155
public async getPrettierInstance (
158
- fileName : string ,
156
+ fileName : string
159
157
) : Promise < PrettierNodeModule | PrettierInstance | undefined > {
160
158
if ( ! workspace . isTrusted ) {
161
159
this . loggingService . logDebug ( UNTRUSTED_WORKSPACE_USING_BUNDLED_PRETTIER ) ;
162
160
return prettier ;
163
161
}
164
162
165
163
const { prettierPath, resolveGlobalModules } = getConfig (
166
- Uri . file ( fileName ) ,
164
+ Uri . file ( fileName )
167
165
) ;
168
166
169
167
// Look for local module
@@ -188,7 +186,7 @@ export class ModuleResolver implements ModuleResolverInterface {
188
186
this . loggingService . logInfo (
189
187
`Attempted to determine module path from ${
190
188
modulePath || moduleDirectory || "package.json"
191
- } `,
189
+ } `
192
190
) ;
193
191
this . loggingService . logError ( FAILED_TO_LOAD_MODULE_MESSAGE , error ) ;
194
192
@@ -211,7 +209,7 @@ export class ModuleResolver implements ModuleResolverInterface {
211
209
if ( resolvedGlobalPackageManagerPath ) {
212
210
const globalModulePath = path . join (
213
211
resolvedGlobalPackageManagerPath ,
214
- "prettier" ,
212
+ "prettier"
215
213
) ;
216
214
if ( fs . existsSync ( globalModulePath ) ) {
217
215
modulePath = globalModulePath ;
@@ -246,7 +244,7 @@ export class ModuleResolver implements ModuleResolverInterface {
246
244
this . loggingService . logInfo (
247
245
`Attempted to load Prettier module from ${
248
246
modulePath || "package.json"
249
- } `,
247
+ } `
250
248
) ;
251
249
this . loggingService . logError ( FAILED_TO_LOAD_MODULE_MESSAGE , error ) ;
252
250
@@ -268,7 +266,7 @@ export class ModuleResolver implements ModuleResolverInterface {
268
266
269
267
if ( ! isValidVersion ) {
270
268
this . loggingService . logInfo (
271
- `Attempted to load Prettier module from ${ modulePath } ` ,
269
+ `Attempted to load Prettier module from ${ modulePath } `
272
270
) ;
273
271
this . loggingService . logError ( OUTDATED_PRETTIER_VERSION_MESSAGE ) ;
274
272
return undefined ;
@@ -284,7 +282,7 @@ export class ModuleResolver implements ModuleResolverInterface {
284
282
285
283
public async getResolvedIgnorePath (
286
284
fileName : string ,
287
- ignorePath : string ,
285
+ ignorePath : string
288
286
) : Promise < string | undefined > {
289
287
const cacheKey = `${ fileName } :${ ignorePath } ` ;
290
288
// cache resolvedIgnorePath because resolving it checks the file system
@@ -314,7 +312,7 @@ export class ModuleResolver implements ModuleResolverInterface {
314
312
// https://stackoverflow.com/questions/17699599/node-js-check-if-file-exists#comment121041700_57708635
315
313
await fs . promises . stat ( p ) . then (
316
314
( ) => true ,
317
- ( ) => false ,
315
+ ( ) => false
318
316
)
319
317
) {
320
318
resolvedIgnorePath = p ;
@@ -331,7 +329,7 @@ export class ModuleResolver implements ModuleResolverInterface {
331
329
332
330
private adjustFileNameForPrettierVersion3_1_1 (
333
331
prettierInstance : { version : string | null } ,
334
- fileName : string ,
332
+ fileName : string
335
333
) {
336
334
if ( ! prettierInstance . version ) {
337
335
return fileName ;
@@ -350,12 +348,12 @@ export class ModuleResolver implements ModuleResolverInterface {
350
348
resolveConfigFile ( filePath ?: string ) : Promise < string | null > ;
351
349
resolveConfig (
352
350
fileName : string ,
353
- options ?: prettier . ResolveConfigOptions ,
351
+ options ?: prettier . ResolveConfigOptions
354
352
) : Promise < PrettierOptions | null > ;
355
353
} ,
356
354
uri : Uri ,
357
355
fileName : string ,
358
- vscodeConfig : PrettierVSCodeConfig ,
356
+ vscodeConfig : PrettierVSCodeConfig
359
357
) : Promise < "error" | "disabled" | PrettierOptions | null > {
360
358
const isVirtual = uri . scheme !== "file" && uri . scheme !== "vscode-userdata" ;
361
359
@@ -366,14 +364,14 @@ export class ModuleResolver implements ModuleResolverInterface {
366
364
( await prettierInstance . resolveConfigFile (
367
365
this . adjustFileNameForPrettierVersion3_1_1 (
368
366
prettierInstance ,
369
- fileName ,
370
- ) ,
367
+ fileName
368
+ )
371
369
) ) ?? undefined ;
372
370
}
373
371
} catch ( error ) {
374
372
this . loggingService . logError (
375
373
`Error resolving prettier configuration for ${ fileName } ` ,
376
- error ,
374
+ error
377
375
) ;
378
376
return "error" ;
379
377
}
@@ -395,15 +393,15 @@ export class ModuleResolver implements ModuleResolverInterface {
395
393
} catch ( error ) {
396
394
this . loggingService . logError (
397
395
"Invalid prettier configuration file detected." ,
398
- error ,
396
+ error
399
397
) ;
400
398
this . loggingService . logError ( INVALID_PRETTIER_CONFIG ) ;
401
399
402
400
return "error" ;
403
401
}
404
402
if ( resolveConfigOptions . config ) {
405
403
this . loggingService . logInfo (
406
- `Using config file at ${ resolveConfigOptions . config } ` ,
404
+ `Using config file at ${ resolveConfigOptions . config } `
407
405
) ;
408
406
}
409
407
@@ -418,7 +416,7 @@ export class ModuleResolver implements ModuleResolverInterface {
418
416
vscodeConfig . requireConfig
419
417
) {
420
418
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."
422
420
) ;
423
421
return "disabled" ;
424
422
}
@@ -428,7 +426,7 @@ export class ModuleResolver implements ModuleResolverInterface {
428
426
429
427
public async getResolvedConfig (
430
428
{ fileName, uri } : TextDocument ,
431
- vscodeConfig : PrettierVSCodeConfig ,
429
+ vscodeConfig : PrettierVSCodeConfig
432
430
) : Promise < "error" | "disabled" | PrettierOptions | null > {
433
431
const prettierInstance : typeof prettier | PrettierInstance =
434
432
( await this . getPrettierInstance ( fileName ) ) || prettier ;
@@ -437,7 +435,7 @@ export class ModuleResolver implements ModuleResolverInterface {
437
435
prettierInstance ,
438
436
uri ,
439
437
fileName ,
440
- vscodeConfig ,
438
+ vscodeConfig
441
439
) ;
442
440
443
441
return resolvedConfig ;
@@ -500,7 +498,7 @@ export class ModuleResolver implements ModuleResolverInterface {
500
498
let packageJson ;
501
499
try {
502
500
packageJson = JSON . parse (
503
- fs . readFileSync ( path . join ( dir , "package.json" ) , "utf8" ) ,
501
+ fs . readFileSync ( path . join ( dir , "package.json" ) , "utf8" )
504
502
) ;
505
503
} catch ( e ) {
506
504
// 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 {
520
518
return findUp . stop ;
521
519
}
522
520
} ,
523
- { cwd : finalPath , type : "directory" } ,
521
+ { cwd : finalPath , type : "directory" }
524
522
) ;
525
523
526
524
if ( packageJsonResDir ) {
@@ -540,7 +538,7 @@ export class ModuleResolver implements ModuleResolverInterface {
540
538
return findUp . stop ;
541
539
}
542
540
} ,
543
- { cwd : finalPath , type : "directory" } ,
541
+ { cwd : finalPath , type : "directory" }
544
542
) ;
545
543
546
544
if ( nodeModulesResDir ) {
0 commit comments