Work with lint-staged, run tsc on staged files and output the result of staged-only files.
⚠️ ONLY TESTED ON TYPESCRIPT 5
Setup
-
Install lint-staged, follow the instructions.
-
Install tslint, use:
npm i -D @hong97/tslint
-
In package.json, add tslint to *.ts
, *.tsx
files.
"lint-staged": {
"*.{ts,tsx}": [
"tslint"
]
},
-
Use Husky or other methods to set up your git 'pre-commit' hooks.
-
Now, TypeScript will be checked at commit staged.
Configuration
Create a file named tslintconfig.js
in your root directory:
module.exports = {
alwaysInclude: [
],
ignore: [
],
};
You can also set up a callback hook in config file:
module.exports = {
onFinish: (result) => {
}
};
The callback will be invoked after tslint finish running and the results will be passed through.