

If your editor does not support Prettier, you can instead run Prettier with a file watcher. See Editor Integration for how to set up your editor. When a line has gotten so long while coding that it won’t fit your screen, just hit a key and watch it magically be wrapped into multiple lines! Or when you paste some code and the indentation gets all messed up, let Prettier fix it up for you without leaving your editor. Set up your editorįormatting from the command line is a good way to get started, but you get the most from Prettier by running it from your editor, either via a keyboard shortcut or automatically whenever you save a file. prettier -write and prettier -check are the most common ways to run Prettier. check is like -write, but only checks that files are already formatted, rather than overwriting them. This avoids merge conflicts and other collaboration issues! npx prettier -check.

If you have a CI setup, run the following as part of it to make sure that everyone runs Prettier. Or use a glob like prettier -write "app/**/*.test.js" to format all tests in a directory (see fast-glob for supported glob syntax). You may run prettier -write app/ to format a certain directory, or prettier -write app/components/Button.js to format a certain file.

is great for formatting everything, but for a big project it might take a little while. We’ll leave off the yarn part for brevity throughout the rest of this file! What is yarn doing at the start? yarn prettier runs the locally installed version of Prettier.
