r/webdev • u/fagnerbrack • 6d ago
Problem with concurrent linter fixes
https://jfmengels.net/concurrent-linter-fixes/1
u/ProfessionalNet5513 6d ago
this is why I dont let èslint --fix`run on a whole repo in one shot. the two fixes dont overlap textually so the linter applies both, àverage`gets deleted while something still calls it, and then the second pass decides `sum`can go too. now the diff has three unrelated changes and one of them doesnt compile. run it one file at a time and actually read the output, or spend the afternoon bisecting a commit that only touched a variable name. half these configs have fixable rules that fight each other and nobody notices until the build is green but the code is wrong
1
u/Separate_Newt_8657 6d ago
eslint --fix and its habit of silently breaking working code, and I still see people run it on the whole repo before committing
1
u/_Darkrei_ 6d ago
Interesting. It highlights something easy to overlook: two fixes can have non-overlapping edit ranges but still depend on each other semantically.
Applying one fix at a time and re-analyzing makes sense, even if it comes with a performance cost. I'd rather have a slightly slower linter than one that silently breaks my code.
1
u/Afnan_CH_Digital 6d ago
Hit this exact class of bug once with eslint --fix and a custom codemod both wired into the same pre-commit hook. Each read the file, each wrote its own version back, and the last write won, so half the fixes silently vanished. What worked for us: serialize the fixers (one at a time, re-lint between passes) and let CI only ever check, never fix. Fixes happen locally where a human can actually eyeball the diff.
1
u/Cultural_Pie_8068 6d ago
This is the exact reason i stopped trusting èslint --fix`on save. Two rules both "correct", ranges dont overlap so eslint happily slaps both in one pass, and now you got a call to àverage`sitting there after the other rule deleted àverage`. Great. And everytime you bring this up someone shows up with "just run the fix twice lol" like that isnt the whole problem, the tool shouldnt need me to babysit it in a loop, that's what a fixer is for. elm-review doing one fix per iteration and re-analyzing is the obvious boring correct way and yet eslint, biome, all of them just batch it because its faster and nobody wants to eat the perf cost of a parse per fix. which i get, i do, a big codebase with 40 autofix rules would crawl, but then at least give me a setting to opt into the slow safe mode instead of pretending the batch is fine. the fix range check is not a correctness check and it never was. i still run it though, im not going to sit there fixing import order by hand
1
u/lucaslamou 5d ago
ast mutations colliding across multiple autofix passes is the worst kind of bug because the linter exit code is zero so ci just lets it through. keeping autofix scoped to pre-commit on staged files only has saved our team so many headaches
1
u/Few-Incident-3536 5d ago
this makes me think fixers need a 'review me' tier: formatting and local syntax fixes can stay in --fix, while deletions or renames get surfaced as suggestions or run in a separate codemod step. that won't catch every semantic interaction, but it lowers the chance that cleanup silently removes something another fix just introduced.
3
u/nuttertools 6d ago
An article about problems caused by idiots tangentially related to linting through improper use of linting.
0/10 - Anyone who reads this becomes dumber.