wybe
wybe copied to clipboard
Use a linter to enforce code quality + formatting
would have made #271 redundant
One linter I currently have enabled in VS Code is hlint. It's not concerned with formatting, but instead produces some simplifications/suggestions like this one:
I believe hlint itself has no plans to deal with whitespace, so a separate tool would be needed if desired.
We could add a chosen linter and/or formatter to .github/workflows so that linting needs to pass in order to get the green tick.
I don't know what's involved in creating a pre-commit test on github, but something as simple as egrep ' $' src/*.hs
finds all lines ending with spaces in Haskell code.
I find that hlint makes a fair number of suggestions I don't agree with, though some are quite helpful. Perhaps with a suitable limited set of tests, it would be appropriate to use that as part of pre-commit checking, too.
linter+prettier sounds great, I've been wanting this for a long time (but I'm too lazy and didn't actually do it). For prettier, how about https://github.com/haskell/stylish-haskell?
I personally prefer consistency over how good coding styles are, but opting out some of the rules is always an option.