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
Avoid empty commits? #588
Comments
What did create this empty commit? 🚫💩 lint-staged doesn't create commits and works as you described below: if the resulting diff is empty when there will be no-op for the commit after |
I had this in my config: |
It’s definitely not the issue with 🚫💩 lint-staged since it doesn’t do commit for you. |
@borekb Were you able to figure out a way around this? I've only run into this with a toy example, but I'd like to avoid any situation where the auto-fixed code will produce an empty commit. FWIW, here's a condensed version of my use case {
"linters": {
"*.{json,md,scss}": ["prettier --write", "git add"],
"*.{ts,tsx}": ["tslint --fix", "prettier --write", "git add"]
}
} .foo {
color: #fff;
} If I change |
@jcfranco In the end, we don't use |
@borekb Thanks for sharing! We'll try |
This is the same problem when auto-fixed the code |
If you're testing the By doing so, the "changes" of the commit would be fixed when running That's the reason to have another step after running the tasks - check if it's a valid commit. |
Not sure what the issue is, but lint-staged by default prevents empty git commits (just like git itself). This can be allowed with |
thanks |
I had the same problem. This happened to me when I tried the "lint-staged": {
"**/*.{js,jsx}": [
"yarn eslint --fix",
"prettier --write"
]
} And
Try missing some linting errors and making a modification, such as a |
hi, is there any solution to this problem without making empty git commits? If we just add spaces or change a bracket position and run lint-staged and prettier, the files are not formatted and no file gets added to git repo |
Maybe it's an edge case but I tested lint-staged on an example where I just mis-formatted a file to see if calling
eslint --fix
would do the right thing. It did – the formatting error was corrected – but it also created an empty commit. This is a different behavior compared to a scenario where I would runeslint --fix
manually and then attempted to commit – Git would just tell me "no changes added to commit".The text was updated successfully, but these errors were encountered: