From c2bdcbe99654f162ff1083589a581e0c30a6d265 Mon Sep 17 00:00:00 2001 From: Prathik Shetty Date: Sat, 6 May 2017 20:29:23 +0530 Subject: [PATCH] Include pre-commit plugin (#1493) * Update README.md * Update README.md * Update README.md * Update README.md --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ae4b634b4..9450c578b 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,9 @@ In the future we will have better support for formatting whole projects. #### Pre-commit hook for changed files -[lint-staged](https://github.com/okonet/lint-staged) can re-format your files that are marked as "staged" via `git add` before you commit. +You can use this with a pre-commit tool. This can re-format your files that are marked as "staged" via `git add` before you commit. + +##### 1. [lint-staged](https://github.com/okonet/lint-staged) Install it along with [husky](https://github.com/typicode/husky): @@ -184,6 +186,25 @@ and add this config to your `package.json`: See https://github.com/okonet/lint-staged#configuration for more details about how you can configure lint-staged. + +##### 2. [pre-commit](https://github.com/pre-commit/pre-commit) + +Just copy the following config in your pre-commit config yaml file + +```yaml + + - repo: https://github.com/awebdeveloper/pre-commit-prettier + sha: '' # Use the sha or tag you want to point at + hooks: + - id: prettier + additional_dependencies: ['prettier@1.1.0'] + + ``` + +Find more info from [here](https://github.com/awebdeveloper/pre-commit-prettier) + +##### 3. bash script + Alternately you can just save this script as `.git/hooks/pre-commit` and give it execute permission: ```bash