Thanks to evolutionxbox, so far couple of solutions were found.
Ignoring Files or Folders
To exclude files from formatting, add entries to a .prettierignore
file in the project root
or set the --ignore-path
CLI option. .prettierignore
uses gitignore syntax.
/app/src/scripts/example.js
/app/src/folder/
Ignore based on extension
To exclude files based on extesntion you can add entries to a .prettierignore
file as well
*.html.erb
Ignore lines
JavaScript
A JavaScript comment of // prettier-ignore
will exclude the next node in the abstract syntax tree from formatting.
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
// prettier-ignore
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
will be transformed to:
matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);
// prettier-ignore
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)
JSX
<div>
{/* prettier-ignore */}
<span ugly format='' />
</div>
more: https://prettier.io/docs/en/ignore.html
Using an extension
We can use an extension to toggle formatting like prettier on the specific page when you need it.
Formatting Toggle
https://marketplace.visualstudio.com/items?itemName=tombonnike.vscode-status-bar-format-toggle