Our repo require fairly strict commit messages so the normal workflow is something like:
--no-verify flagfeat: My new featureThe issue is that during a rebase, the lint hook is running for each rebase step. The git rebase --continue etc command does not allow a --no-verify flag so each rebase step errors out due to lint-staged.
--no-verify flag.git rebase -i HEAD~2I'm a bit surprised it seems no one else has run into this. Am I thinking about this incorrectly? Or is everyone making all their WIP commits pass the linter each time?
I'm not sure if lint-staged can know it's being run in a rebase or if there are times where you do need it to run during a rebase. Possibly a way to enable/disable via a ENV flag?
馃毇馃挬 Lint-staged is design to run on precommit. In your case it seems you better be suited with a CI.
I think lint-staged should not run while rebasing. What if the linter (e.g. prettier) is upgraded during one of those commits? While rebasing, if it is stricter, it will fail on one of the older commits.
I think the scenario @benjamincharity describes is that, installing lint-staged as described in the README, it still gets called during an _interactive_ rebase.
EDIT: There's a possible workaround on the Husky side: https://github.com/typicode/husky/issues/447
EDIT 2: To clarify, that pre-commit is called only on certain git rebase commands (like reword or fixup)
lint-staged currently contains code to make it handle rebase cases and reverting of the commit state in case of errors. It would be possible to detect an ongoing rebase and instead skip running lint-staged. This would have to be a new cli option to not make it a breaking change, something like --no-rebase.
Most helpful comment
馃毇馃挬 Lint-staged is design to run on precommit. In your case it seems you better be suited with a CI.