From 24e4f2b155df410f0325c3c97bb332f49657ddae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Malek?= Date: Tue, 29 Aug 2023 12:44:11 +0200 Subject: [PATCH] feat: pass print options to block codemod --- .../colors-to-css-vars/color-in-JSX-multi-import.output.tsx | 2 +- .../color-in-JSX-single-import.output.tsx | 4 ++-- src/codemods/block-to-width-100.ts | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/codemods/__testfixtures__/colors-to-css-vars/color-in-JSX-multi-import.output.tsx b/src/codemods/__testfixtures__/colors-to-css-vars/color-in-JSX-multi-import.output.tsx index f57ac1ae4..147508193 100644 --- a/src/codemods/__testfixtures__/colors-to-css-vars/color-in-JSX-multi-import.output.tsx +++ b/src/codemods/__testfixtures__/colors-to-css-vars/color-in-JSX-multi-import.output.tsx @@ -1,5 +1,5 @@ import { CloseIcon } from '@freenow/wave'; export const CloseIconWrapper = () => ( - + ); diff --git a/src/codemods/__testfixtures__/colors-to-css-vars/color-in-JSX-single-import.output.tsx b/src/codemods/__testfixtures__/colors-to-css-vars/color-in-JSX-single-import.output.tsx index 357f19c13..b66b7cc48 100644 --- a/src/codemods/__testfixtures__/colors-to-css-vars/color-in-JSX-single-import.output.tsx +++ b/src/codemods/__testfixtures__/colors-to-css-vars/color-in-JSX-single-import.output.tsx @@ -1,7 +1,7 @@ export const GhostIcon = () => ( - - + + ); diff --git a/src/codemods/block-to-width-100.ts b/src/codemods/block-to-width-100.ts index 2e10cda87..68d921cda 100644 --- a/src/codemods/block-to-width-100.ts +++ b/src/codemods/block-to-width-100.ts @@ -1,8 +1,10 @@ import { API, FileInfo } from 'jscodeshift'; +import { Options } from 'recast'; -module.exports = (file: FileInfo, api: API) => { +module.exports = (file: FileInfo, api: API, options: Options) => { const j = api.jscodeshift; const ast = j(file.source); + const printOptions = options ?? { quote: 'single' }; const localButtonNames = []; @@ -53,5 +55,5 @@ module.exports = (file: FileInfo, api: API) => { }); }); - return ast.toSource({ quote: 'single' }); + return ast.toSource(printOptions); };