Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Prettier Whitespaces in React Typescript

I use prettier for formatting my code. How can I configure prettier to add a space depending on curly braces in react code?

Current code:

<AdminPanel
    theme={myTheme}
    dataProvider={dataProvider}
    authProvider={authProvider}
    history={history}
/>

Expected result:

<AdminPanel
    theme={ myTheme }
    dataProvider={ dataProvider }
    authProvider={ authProvider }
    history={ history }
/>
like image 272
Mark Uivari Avatar asked Dec 04 '19 18:12

Mark Uivari


1 Answers

The option bracket-spacing is what you are looking for: bracketSpacing: true.

https://prettier.io/docs/en/options.html#bracket-spacing

like image 188
Michael Wallace Avatar answered Oct 23 '22 02:10

Michael Wallace