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,
};