wybe icon indicating copy to clipboard operation
wybe copied to clipboard

Use a linter to enforce code quality + formatting

Open neon64 opened this issue 2 years ago • 2 comments

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:

image

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.

neon64 avatar Apr 04 '22 08:04 neon64

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.

pschachte avatar Apr 05 '22 02:04 pschachte

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.

CaviarChen avatar Apr 05 '22 15:04 CaviarChen