Settings

Theme

Speeding up Prettier locally using the new –cache CLI option

prettier.io

29 points by assadk 4 years ago · 7 comments

Reader

hooper 4 years ago

If your files are under version control, you already have a generic change detection mechanism that can give you a shorter list of changed files that need to be checked for formatting. For example, you can run code formatters in pre-commit hooks. Mercurial's "fix" extension rewrites commits using formatting fixes that can be focused on changed line ranges. Of course, the purpose of this --cache feature is still valid for other situations.

  • bobbylarrybobby 4 years ago

    In between commits, the `--cache` option is still helpful because it means you can avoid running prettier on a file whose contents have changed since the last commit but not since it was last saved.

    That said, formatters should be run in pre commit hooks anyway.

    • slavik81 4 years ago

      How do you decide what changes to restage? My experience has been that applying formatting in the pre-commit hook breaks `git add -p`.

justusw 4 years ago

Am I right to assume that Prettier runs single-threaded? I was never able to find an option to parallelize (and I assume it is paralellizable). Being able to speed up Prettier would improve my workflow by a lot.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection