Pretty Quick (evacuated from NSA/Microsoft Github)
Mario Pareja ea58162d4f feat: safer handling of partially staged files (with fix) (#33) | %!s(int64=6) %!d(string=hai) anos | |
---|---|---|
__mocks__ | %!s(int64=7) %!d(string=hai) anos | |
bin | %!s(int64=6) %!d(string=hai) anos | |
img | %!s(int64=7) %!d(string=hai) anos | |
src | %!s(int64=6) %!d(string=hai) anos | |
.babelrc | %!s(int64=7) %!d(string=hai) anos | |
.eslintrc.yml | %!s(int64=7) %!d(string=hai) anos | |
.gitignore | %!s(int64=7) %!d(string=hai) anos | |
.prettierignore | %!s(int64=7) %!d(string=hai) anos | |
.prettierrc.yml | %!s(int64=7) %!d(string=hai) anos | |
.travis.yml | %!s(int64=7) %!d(string=hai) anos | |
LICENSE | %!s(int64=7) %!d(string=hai) anos | |
README.md | %!s(int64=6) %!d(string=hai) anos | |
package.json | %!s(int64=6) %!d(string=hai) anos | |
yarn.lock | %!s(int64=7) %!d(string=hai) anos |
pretty-quick
Get Pretty Quick
Runs Prettier on your changed files.
Supported source control managers:
With yarn
:
yarn add --dev prettier pretty-quick
With npm
:
npm install --save-dev prettier pretty-quick
With yarn
:
yarn pretty-quick
With npx
: (No install required)
npx pretty-quick
With npm
:
"pretty-quick": "pretty-quick"
to the scripts section of package.json
.npm run pretty-quick
You can run pretty-quick
as a pre-commit hook using husky
.
For Mercurial have a look at
husky-hg
yarn add --dev husky
In package.json
's "scripts"
section, add:
"precommit": "pretty-quick --staged"
--staged
(only git)Pre-commit mode. Under this flag only staged files will be formatted, and they will be re-staged after formatting.
Partially staged files will not be re-staged after formatting and pretty-quick will exit with a non-zero exit code. The intent is to abort the git commit and allow the user to amend their selective staging to include formatting fixes.
--branch
When not in staged
pre-commit mode, use this flag to compare changes with the specified branch. Defaults to master
(git) / default
(hg) branch.
pretty-quick
will respect your .prettierrc
, .prettierignore
, and .editorconfig
files, so there's no additional setup required. Configuration files will be found by searching up the file system. .prettierignore
files are only found from the working directory that the command was executed from.