New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
husky/lint-staged compatibility #1127
Comments
Hello, It depends which tool you want to make leading I suppose. I don't know the tool lint-staged, but there might be 2 options:
You could indeed make grumphp leading as well and add a custom bash script. I don't know why the command does not return an exit code of |
Thanks for your response!
Whichever one will allow me to run both Prettier and GrumPHP 🙂 feels like either approach is close really - I can "almost" run Prettier as a GrumPHP npm task, and I can "almost" run GrumPHP via
This would be great. Is there any reason GrumPHP currently can't be given paths to run on?
Great idea, thanks. Sadly this doesn't work though as
I'm pretty sure Prettier CLI does return an exit code of parameters:
tasks:
npm_script:
script: "echo 'Hello World'; exit 0" Which leads me to think npm script tasks aren't working in GrumPHP at all. |
You are basically running:
Which I dont think is supported.
when the package.json contains: {
"scripts": {
"prettier": "prettier --check"
}
} Next, you need to configure grumphp to execute a nmp run task: grumphp:
tasks:
prettier:
script: "prettier"
triggered_by: [js, jsx, coffee, ts, less, sass, scss]
working_directory: "./"
is_run_task: true
silent: false
metadata:
task: npm_script If you just want to run a bash command, you need the shell task. |
Ah I see, that makes sense thanks. However in my testing even that is not working 😅
(same with and without Prettier check errors) Besides, even if I was able to run Prettier through GrumPHP, it might simplify e.g. CI but it doesn't solve the GrumPHP pre-commit hook not running. My current lint-staged setup runs all staged files through Prettier on commit. It would be nice to be able to include GrumPHP in that list for The alternative of removing husky/lint-staged and relying on GrumPHP for commit hooks isn't as appealing. Doesn't look like I would be able to e.g. run only all staged files though Prettier. I think I'd need to run a full |
2.5.0
I use husky and lint-staged in my WordPress plugin to e.g. run Prettier to format my PHP code on commit.
I've added GrumPHP via Composer to handle PHP-related linting tasks. Since GrumPHP also looks to "sniff your commits" I assumed GrumPHP would run on the staged files during commit, but this does not seem to happen - only the husky hooks run.
Is there any way you know of to work around this issue, or have you considered native compatibility with husky/lint-staged?
I did try running GrumPHP through lint-staged like I do Prettier:
.lintstagedrc.json
But it appears you can't pass an argument to the GrumPHP
run
command, in this case the path(s) of the staged files.Another option I considered was running Prettier through GrumPHP using npm_script:
grumphp.yml
But the check never seems to complete with
✔
. Any ideas?My configuration
Steps to reproduce:
The text was updated successfully, but these errors were encountered: