Must be configured on top level directory of a project when having a multi-package project (e.g. frontend + backend).
npm install --save-dev husky lint-staged
Add npm script "lint-staged" to package.json
"scripts": {
"lint-staged": "lint-staged"
}
Add husky and lint-staged config to package.json
"husky": {
"hooks": {
"pre-commit": "npm run lint-staged"
}
},
"lint-staged": {
"*.ts": [
"tslint -c tslint.json -p tsconfig.json",
"git add"
]
}
Please adjust paths to tslint.json and tsconfig.json!
To make the hook stop when tslint finds a fault, change default severity for tslint in tslint.json:
"defaultSeverity": "error"
defaultSeverity "warning" will not stop the commit process!