Skip to content

Instantly share code, notes, and snippets.

@vahanNasibyan
Created September 13, 2018 10:58
Show Gist options
  • Save vahanNasibyan/d0753d3826ee7756b635212e201b0519 to your computer and use it in GitHub Desktop.
Save vahanNasibyan/d0753d3826ee7756b635212e201b0519 to your computer and use it in GitHub Desktop.
Setting up eslint and tests running before each commit.
##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