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
Question: if multiple globs match do the scripts run in a reliable order? #916
Comments
Hello, you can try using the |
Perfect, that should work great. Apologies for not noticing that option earlier. Thank you for the quick response! |
That said, maybe it would be more efficient to not use that setting, and split your globs like in the first example. The inner jobs always run in order, and as long as there are no overlaps, the prettier should run last. "lint-staged": {
"*.(js|jsx)": [
"eslint --fix",
"prettier --write"
],
"*.scss": [
"stylelint --fix --max-warnings 0",
"prettier --write"
],
"*.!(js|jsx|scss)": [
"prettier --write"
]
}, |
Ah that's a great point, I didn't realize exclusion was possible in globs, but this is exactly what I need. Thanks again 👍 |
I tested this and found out that the exclusion pattern ExamplesI only used Staged files with its contents:
This did not work
"lint-staged": {
"*.!(css|js)": [
"prettier --check"
]
} Output after
This worked
"lint-staged": {
"!(*.css|*.js)": [
"prettier --check"
]
} Output after
All @iiroj Could you please confirm that? I also suggest adding this example to the README. I have spent some time searching for this here, in the micromatch repo, and with Google, have but not found anything clear. I think it might be useful for others with the same or similar case. |
Thanks @germanfrelo, feel free to open a PR for updating the README! |
Here is the PR #1405. |
I can't find clear documentation about this use case so I wanted to clarify:
My use case: I want to run
eslint
on js files, stylelint onscss
files, andprettier
on all files, but only after linting has finished.So do I need to do something like this to ensure prettier runs last and on all files:
Or can I rely on the later matches running after the prior matches' scripts are finished and do this:
Thank you for your help!
The text was updated successfully, but these errors were encountered: