SimenB / stylint

Improve your Stylus code with Stylint
https://simenb.github.io/stylint/
GNU General Public License v2.0
348 stars 62 forks source link

Rule to ensure files end with a newline #419

Open brianhelba opened 6 years ago

brianhelba commented 6 years ago

Text files on Unix-like systems should generally end with a newline. It would be helpful to have a rule, trailingNewline (or some similar name), which required that all files had a LF (or perhaps the platform-specific equivalent) as their final character.

ESLint has this rule as eol-last.

brianhelba commented 6 years ago

I've looked into submitting a PR for this myself, but I'm stuck on the fact that all lines are split and re-formed by the parser before being passed to any rules. Furthermore, the origLine that's passed to each rule is lacking a trailing newline.

This probably isn't that bad, since a normal rule which is run on every single line is probably inefficient (since we only need to run it on the last line of the file). It would be simpler to have a rule which gets run on the entire file, but I'm not sure where that should be called from. Perhaps we could add another special case call (like the one for commentSpace)? Could we add this to parse.js?

Feedback would be appreciated before I start coding this.

brianhelba commented 6 years ago

Ping @SimenB .