我正在为我的新项目使用NestJs。
我正在使用此命令添加所有文件。 git add .
当我在添加所有文件后提交时,赫斯基会阻止提交并向我显示此错误。
[文件路径]/.spec.ts' 不包含在项目中。
husky > pre-commit hook 失败(添加 --no-verify 绕过)
我隐式添加了该文件,但它仍然向我抛出该错误。
我的 tsconfig.json 文件
{
"compilerOptions": {
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"allowJs": true,
"outDir": "./dist",
"baseUrl": "./src",
"lib": ["dom", "es2018", "esnext"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
这就是我在 package.json 文件中添加 husky 命令的方式
"scripts": {
"lint": "tslint -p tsconfig.json -c tslint.json",
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "git push origin HEAD"
}
},
"lint-staged": {
"*.ts": [
"tslint -p tsconfig.json -c tslint.json",
"git add"
]
},