How to make Prettier to ignore a certain tag or block of code in JSX/TSX

42 Views Asked by At

enter image description here

I use prettier for my React + Next.js project, I like it a lot but for the React interface it usually uses SVGs, whose parameters are irrelevant because is usually just a copy-paste from an external library or web. I would like prettier to ignore the SVG formatting so that it stays on a single line and have a much cleaner code as it takes up a lot and is irrelevant.

Like this:

enter image description here

I have thought about creating a file where to put all the code of the SVGs and export them as components, but I would prefer just to be able to use them in literal form

1

There are 1 best solutions below

0
ByteVictor On

One option I found is using brackets to place a comment like this:

enter image description here

It would be nice if someone knows if it's possible to just add a certain tag, in this case to the Prettier config and skip adding {/* prettier-ignore */} every time.