Run TSLint against staged git files only !
Used as git hook, it will run fast by not running on all of your project files !
TSLint will be depreciated in a near future to move to ESLint !
Lint-staged gives you the same feature and more for ESLint and Prettier.
npm install --save-dev tslint-staged
TSLint-Staged configuration holds directly in your package.json
:
{
...,
"tslintStaged": {
"tslintConfig": "tslint.json",
"include": [ "**/*.ts" ],
"exclude": []
},
...
}
tslint_config
specify the path of your own tslint.json
configuration file.
include
and exclude
allow you to filter analysed files. TSLint-Staged uses micromatch for matching files. You can use wild cards as *
, **
and more !
You can now run TSLint-Staged :
npm run tslint-staged
Use it as a hook with Husky
The most usefull way to use TSLint-staged is to use it as a pre-commit/pre-push hook !
{
...,
"husky": {
"hooks": {
"pre-commit": "tslint-staged"
}
},
...
}