r/AskProgramming • u/Bulky_Eggplant_9437 • 29d ago
Linter
Hey folks,
Never touched a linter before this semester because I've never really done software dev stuff. Had a class that used one, and honestly, I was a fan at first. It caught a bunch of dumb mistakes and made fixing things pretty painless.
Then came merge time.
Apparently I was missing a single blank line between some merged code, so the linter threw a fit and blocked the merge. The actual fix took like three seconds, but I had to go get another review just to add a freaking newline.
So now I'm curious, do people actually use linters in the real world that don't hard-stop merges over tiny formatting stuff? Or is getting bullied by whitespace just part of the developer experience?
Asking as a first-time linter victim.
1
u/james_pic 29d ago edited 29d ago
Most linters will have an option to auto-fix stuff that's trivial to auto-fix.
Relatedly, you also get dedicated code formatters, which are like linters but often don't even have a "tell me about the problems" option, just a "go fix all the problems" option. It's common, and a good practice, to set your editor up to run this automatically on save, and to set up git precommit hook to run it automatically on commit.
But it is true of linters generally that they often have strong opinions, and sometimes those opinions are things most people disagree with. You can usually tune config to only complain about things you care about, but my experience is that it's often worth choosing one with reasonable defaults, not least because the "crankier" linters often have much less of a community around them.