2

我正在使用 husky 和 ​​lint-staged 使用此配置在我的 sass 文件上运行“stylelint --fix”

"husky": {
    "hooks": {
        "pre-commit": "lint-staged",
        "post-commit": "git update-index --again"
    }
},
"lint-staged": {
    "resources/sass/*.scss": [
        "stylelint --fix",
        "git add"
    ]
}

和 PhpStorm 阻止我的提交告诉我:

Commit failed with error, 0 file committed, 4 files failed to commit: test lintstaged husky > pre-commit (node v12.18.4) ⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index. [STARTED] Preparing... [SUCCESS] Preparing... [STARTED] Running tasks... [STARTED] Running tasks for resources/sass/*.scss [STARTED] stylelint --fix [FAILED] stylelint --fix [FAILED] [FAILED] stylelint --fix [FAILED] [SUCCESS] Running tasks... [STARTED] Applying modifications... [SKIPPED] Skipped because of errors from tasks. [STARTED] Reverting to original state because of errors... [SUCCESS] Reverting to original state because of errors... [STARTED] Cleaning up... [SUCCESS] Cleaning up... ✖ stylelint --fix: resources/sass/_custom.scss 614:1 ✖ Unexpected duplicate selector "body", first used at line 116 no-duplicate-selectors 974:11 ✖ Unexpected unknown type selector "readonly" selector-type-no-unknown 988:1 ✖ Unexpected duplicate selector "body", first used at line 116 no-duplicate-selectors 1313:1 ✖ Unexpected duplicate selector ".btn.clear", first used at line 418 no-duplicate-selectors husky > pre-commit hook failed (add --no-verify to bypass)

我在文档上读到使用命令“--no-verify”它会跳过“stylelint --fix”,但我想运行“stylelint --fix”来修复stylelint可以修复的错误并跳过防止犯罪。

换句话说,我想修复可以自动修复的错误并提交,即使有来自 stylelint 的警告。

有可能这样做吗?

4

0 回答 0