Lint files before commit
Ya so after a long long time I am back :)
So most of the time, we have an issue that why our friends commit files with errors like
- linting is not done .
- without proper indentation.
- and bla bla bla.
So for this we can set-up some hooks in git so when someone works on any files and tries to commit then first he needs to resolve all errors after that he can commit by this, code quality is also improved.
Requirement :
so for this we need to install 2 packages in our dev dependencies.
- husky (npm install husky –save-dev)
- lint-staged (npm install lint-staged –save-dev)
Setup :
So in our package.json file, we need to setup like below Here I am taking two configurations for Tslint
and for Eslint
.
As most of the time, we are working in angular.js and react.js ;). I am assuming that my all files in the src
folder.
for TSlint
so for this we need to install additionally tslint
package as it mention below in devDependencies
for ESlint
so for this we need to install additionally eslint
package as it mention below in devDependencies
Please give your comments and suggestion below.
Thanks .