Skip to content

Instantly share code, notes, and snippets.

@Skylarity
Last active August 8, 2018 19:28
Show Gist options
  • Save Skylarity/bf90efb382884bc285fbd7c454e53121 to your computer and use it in GitHub Desktop.
Save Skylarity/bf90efb382884bc285fbd7c454e53121 to your computer and use it in GitHub Desktop.
How to use Prettier

General

  • Prettier

  • Make sure there is a .prettierrc file in the project root

VS Code

  • Install the Vetur extension
  • Make sure that these settings are in your user settings:
{
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "files.trimTrailingWhitespace": true,
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true,
    "vetur.format.defaultFormatter.html": "js-beautify-html"
}

Atom

  • Install the prettier-atom extension (and all of its dependencies)
  • Within Atom's settings:
    • "Tab Length" should be "4"
  • Within prettier-atom's settings:
    • "Format Files on Save" should be checked
    • "Only format if a Prettier config is found" should be checked

Sublime

  • Install Package Control (if you haven't already)
  • Install prettier globally (npm i -g prettier)
  • Install the JsPrettier extension
  • Within your JsPrettier user settings:
{
	"auto_format_on_save": true,
	"auto_format_on_save_requires_prettier_config": true,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment