jinxdash / prettier-plugin-rust

Prettier Rust is an opinionated code formatter that autocorrects bad syntax.
MIT License
178 stars 7 forks source link

inconsistency in EOF (end of file newline) #21

Closed kevinvalk closed 1 year ago

kevinvalk commented 1 year ago

Input code

fn eof() {}
\n

Output code

fn eof() {}
\ No newline at end of file

Additional context

It seems that this plugin does always add an EOF (end of file newline). Specifically for functions it does not do that. If you have a file with just a comment // test it does make it into // test\n.

That said, in the following piece of code rust prettier does NOT add a newline.

fn eof() {}
// comment
ZerdoX-x commented 1 year ago

For me it even removes the empty line. I am happy that running prettier --check doesn't throw errors about missing EOF newline in .rs files :)