简体   繁体   中英

Pre-commit hook is not working | Husky and Lintstaged

I'm trying to use typescript pre-commit Husky hooks with LintStaged, but when I do a commit, the pre-commit script is not running, I just receive the common git response after commits. git 提交响应

.huskyrc.json

{
"hooks": {
    "pre-commit": "lint-staged"
}

}

.lintstagedrc.json

{
"*.ts": [
    "eslint 'src/**' --fix",
    "npm run test:staged"
]

}

My file structure

文件结构图片

What am I doing wrong?

The another way of doing it is adding the scripts to the package.json file.

// package.json

"husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
},
"lint-staged": {
    "*.ts": [
      "eslint 'src/**' --fix",
      "npm run test:staged"
    ],
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM