Skip to content

Instantly share code, notes, and snippets.

@gustavoalbuquerquebr
Last active June 3, 2020 02:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavoalbuquerquebr/3138869d498629a782244f6b197f15e5 to your computer and use it in GitHub Desktop.
Save gustavoalbuquerquebr/3138869d498629a782244f6b197f15e5 to your computer and use it in GitHub Desktop.
#prettier #cheatsheet #cli

PRETTIER CHEATSHEET

install: npm i prettier --save-dev --save-exact
NOTE: "We recommend pinning an exact version of prettier in your package.json as we introduce stylistic changes in patch releases".

options can be configured in the cli or .prettierrc file

rules: https://prettier.io/docs/en/options.html

basic usage: npx prettier --write <filename...>

to watch, install the package onchange npm i onchange --save-dev and execute: npx onchange <file path> -- npx prettier --write {{changed}}

npm scripts: run once: prettier --write *.js, keep watching: onchange *.js -- prettier --write {{changed}}

ignore:

/* prettier-ignore */ let x       = "test";
/* prettier-ignore */ let sadçj   = "x";
/* prettier-ignore */ let sadçjfç = "x";
/* prettier-ignore */ let dfsja   = "y";

// prettier-ignore
let z = {
  a   : 1,
  bbbb: 2,
  cc  : 3,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment