Open brandondurham opened 5 years ago
Hi @brandondurham! Thanks for the detailed issue report, that's helpful π So I got your setup working I think, you can see it here.
If you remove --no-verify
from your commit
script, it works like expected. I'm not sure what commitizen or husky does with --no-verify
, but it seems that the hook commit-msg
is skipped with that.
Try this commit script instead "commit": "lint-staged && git-cz"
, that gives me this output:
β― yarn commit
yarn run v1.17.3
$ lint-staged && git-cz
No staged files match any of provided globs.
husky > pre-commit (node v12.7.0)
No staged files match any of provided globs.
husky > commit-msg (node v12.7.0)
β§ input: another faulty commit
β subject may not be empty [subject-empty]
β type may not be empty [type-empty]
β found 2 problems, 0 warnings
β Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
husky > commit-msg hook failed (add --no-verify to bypass)
Done in 8.89s.
Hope it helps!
Im quite sure husky is picking up the --no-verify
flag, which skips the commit-msg
hook π
Ah yes. The --no-verify
is in place because otherwise instead of things running in this order:
lint-staged
commitizen
commitlint
β¦ you get this:
lint-staged
commitizen
lint-staged
commitlint
Example:
Ah ok, so basically --no-verify
ignores the hook you are binding commitlint to. Is there another way to ease up lint-staged
?
Looks like i have similar issue
Expected Behavior
When using
yarn commit
the expected result is to runlint-staged
to lint all js and css files; thengit-cz
to generate a commit message; and finallycommitlint
to ensure that the scope and subject fields are formatted correctly.Current Behavior
Both
lint-staged
andgit-cz
run correctly and in the correct order, butcommitlint
is never triggered.Affected packages
Steps to Reproduce (for bugs)
"commit": "lint-staged && git-cz --no-verify",
as a script in package.json.In your
.lintstagedrc
file, add the following config:In your
.huskyrc
file, add the following config:Finally, in your
.commitlintrc.js
file, add the following config items:commitlint.config.js
```js module.exports = { extends: ['@commitlint/config-conventional'], rules: { 'header-case': [2, 'always', 'lower-case'], 'scope-case': [2, 'always', 'lower-case'], 'subject-case': [2, 'always', 'lower-case'], } } ```Context
My absolute goal is to run
lint-staged
, thengit-cz
, thencommitlint
any time you runyarn commit
.Your Environment
My project was started with
create-react-app
and has not been ejected. Iβve not even added any components yet β Iβm just trying to get a solid, baseline codebase to start building on. Getting all of these tools to work well together has been tricky.@commitlint/cli
@commitlint/config-conventional
git --version
node --version
commitizen
cz-conventional-changelog
cz-customizable
husky