Created
September 13, 2018 10:58
-
-
Save vahanNasibyan/d0753d3826ee7756b635212e201b0519 to your computer and use it in GitHub Desktop.
Setting up eslint and tests running before each commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Setting up eslint and tests running before each commit. | |
1. `npm install --save-dev husky` | |
2. `npm install --save-dev lint-staged` | |
4. Add husky config to run lint-staged script before every commit | |
``` | |
"husky": { | |
"hooks": { | |
"pre-commit": "lint-staged" | |
} | |
}, | |
``` | |
5. Add lint staged config to run eslint and tests for modified files | |
```"lint-staged": { | |
"linters": { | |
"*.{js,scss}": [ | |
"eslint --fix", | |
"npm run test:unit", | |
"git add" | |
] | |
} | |
}, | |
``` | |
6. Add `test:unit` command in scripts section | |
``` | |
"test:unit": "jest --coverage", | |
``` | |
#After this you can modify your code and do your stuff. | |
#This will notify you about problems with eslint in modified files and test cases. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment