News for hackers. Stuff that matters.
Re:Prettier $20k Bounty was Claimed by SamBam on Monday November 27, 2023 @12:42PM (#38435403)
It's not really an issue if you do a one-time Prettification commit, and then stick to Prettifying automatically thereafter. Then you won't ever see line-width changes mixed in with functional changes.

Isn't this an issue with every linter? At some point you're going to have to decide what to do with old code that doesn't match the new style rules.

Re:Prettier $20k Bounty was Claimed by lainga on Monday November 27, 2023 @12:52PM (#38435553)
Sure you will. Whoops, my regex got too long and now the diff is

    - filter: /\.(jimmy|jimbo|jeremiad)$/
    + filter:
    +     /\.(jimmy|jimbo|jeremiad|james)$/

. And it's not clear where the change is. GP's article has an example of that in a linked tweet.
Re:Prettier $20k Bounty was Claimed by Cthulhu_ on Monday November 27, 2023 @03:59PM (#38438196)
Is that down to the formatter - which you've configured to enforce a certain line length (https://prettier.io/docs/en/options.html#print-width) - or the diff visualiser that doesn't show a difference between whitespace and other changes?
Re:Prettier $20k Bounty was Claimed by francislavoie on Monday November 27, 2023 @06:59PM (#38440380)
It's impossible to turn off line length rules. You can only change the width, which means if you set it to a big number it will aggressively unwrap code you want to keep wrapped sensibly. Awful and unacceptable.
Re:Prettier $20k Bounty was Claimed by JasonSage on Monday November 27, 2023 @01:14PM (#38435890)
This is fine for a text diff, but I want my code review tool to show me something different. Separate problem, and the flaw here isn’t the diff, or the tool that produced the diff, rather the tool displaying it to me. Let me do whatever I want to my code and show me BOTH the visual (unimportant) and semantic differences.
Re:Prettier $20k Bounty was Claimed by nicky0 on Tuesday November 28, 2023 @04:02AM (#38443824)
Good point. Are there any code-semantics-aware diff tool out there though?
Re:Prettier $20k Bounty was Claimed by slackner on Tuesday November 28, 2023 @09:46AM (#38446281)
If you're looking for a VS Code extension or a GitHub app, check out https://semanticdiff.com/. I'm a co-founder of this project.

If you prefer a CLI tool, check out https://github.com/Wilfred/difftastic. It supports more languages, but doesn't recognize when code has been replaced by an equivalent version ("invariances"). So it will show some changes (e.g. replacing a character in a string with an escape sequence) even though they are technically equivalent.

Re:Prettier $20k Bounty was Claimed by richardwhiuk on Monday November 27, 2023 @12:50PM (#38435529)
> Then you won't ever see line-width changes mixed in with functional changes.

You will - every time you extend a line which now exceeds the limit.

Re:Prettier $20k Bounty was Claimed by twicetwice on Monday November 27, 2023 @12:55PM (#38435601)
Isn't this a natural consequence of having line length limits? This seems like a general problem, not a problem with Prettier.
Re:Prettier $20k Bounty was Claimed by richardwhiuk on Monday November 27, 2023 @01:01PM (#38435692)
Sure
Re:Prettier $20k Bounty was Claimed by francislavoie on Monday November 27, 2023 @07:00PM (#38440393)
It's an issue with prettier because it cannot be disabled.