From 9d1ed8ee141a29d3c46e280bd7441b9c2f687edc Mon Sep 17 00:00:00 2001 From: Mikael Brevik Date: Thu, 6 Jan 2022 11:06:15 +0100 Subject: [PATCH 1/2] fix(cli): pass in parser to prettier format to avoid deprecation warning --- packages/cli/src/dirCommand.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/dirCommand.ts b/packages/cli/src/dirCommand.ts index 74f1e82b..32da6a5e 100644 --- a/packages/cli/src/dirCommand.ts +++ b/packages/cli/src/dirCommand.ts @@ -3,7 +3,7 @@ import { promises as fs } from 'fs' import * as path from 'path' import { grey, white } from 'chalk' import { loadConfig, Config } from '@svgr/core' -import { format, resolveConfig } from 'prettier' +import { format, resolveConfig, getFileInfo } from 'prettier' import { convertFile, transformFilename, @@ -100,7 +100,9 @@ export const dirCommand: SvgrCommand = async ( const prettierRcConfig = opts.runtimeConfig ? await resolveConfig(filepath, { editorconfig: true }) : {} + const prettierFileInfo = await getFileInfo(filepath) return format(fileContent, { + parser: prettierFileInfo.inferredParser, ...prettierRcConfig, ...opts.prettierConfig, }) From 9f93734ebc1e67c4ea6a3b449887dca0be4f4b9e Mon Sep 17 00:00:00 2001 From: Mikael Brevik Date: Mon, 10 Jan 2022 08:55:46 +0100 Subject: [PATCH 2/2] refactor: use filepath instead of fileinfo --- packages/cli/src/dirCommand.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/dirCommand.ts b/packages/cli/src/dirCommand.ts index 32da6a5e..44098791 100644 --- a/packages/cli/src/dirCommand.ts +++ b/packages/cli/src/dirCommand.ts @@ -3,7 +3,7 @@ import { promises as fs } from 'fs' import * as path from 'path' import { grey, white } from 'chalk' import { loadConfig, Config } from '@svgr/core' -import { format, resolveConfig, getFileInfo } from 'prettier' +import { format, resolveConfig } from 'prettier' import { convertFile, transformFilename, @@ -100,9 +100,8 @@ export const dirCommand: SvgrCommand = async ( const prettierRcConfig = opts.runtimeConfig ? await resolveConfig(filepath, { editorconfig: true }) : {} - const prettierFileInfo = await getFileInfo(filepath) return format(fileContent, { - parser: prettierFileInfo.inferredParser, + filepath, ...prettierRcConfig, ...opts.prettierConfig, })