logoalt Hacker News

ttul • today at 9:03 PM • 2 replies • view on HN

I've noticed the line breaks issue. It's easily fixed with a formatter like prettier and, frankly, that kind of quality-of-life thing is best handled deterministically anyway.


Replies

LukaD • today at 10:16 PM

I haven't used prettier much but this is what the prettier docs say about empty lines.

> It turns out that empty lines are very hard to automatically generate. The approach that Prettier takes is to preserve empty lines the way they were in the original source code. There are two additional rules: > > - Prettier collapses multiple blank lines into a single blank line. > - Empty lines at the start and end of blocks (and whole files) are removed. (Files always end with a single newline, though.)

The last time I used astra it wrote a lot of rust code where it would insert almost no empty lines at all. Not before functions, structs, impl blocks, etc., and not inside functions to group statements. Similar to prettier, rustfmt doesn't really insert empty lines.

Edit: hmm maybe I misunderstood your and the parent's comment. Are you talking about missing regular newlines after statements, i.e. multiple statements on one line?

rsfern • today at 9:31 PM

Doesn’t this mess up the context though? I use ruff and my agents get confused if I edit and run ruff out of band. How do people deal with that? I’m always having to remind agents to re-read files because they’ve changed