How do you lint purescript?

I am new to Purescript and I am trying to set up tools to help me code. Is there any linter for Purescript? It will be awesome for something like ESLint for Purescript(or maybe rules for Purescript in ESLint), but unfortunately I cannot find any. What linter is the community using?

1 Like

Think about it differently, why do you need linter ? what it does for you ? and try to find equivalent. What we use for “linting” and validating is the compiler. and there is purescript-ide for your code editor which helps to find where are the issues and helps to write purescript. https://github.com/purescript-emacs/psc-ide-emacs or https://github.com/nwolverson/vscode-ide-purescript

so if you use ide + compiler, you can see type errors in code. This can be futher accompanied by repl where you can try and inspect stuff.

And to help you with searching for a function there is ?hole which you can put instead of function you want to use and it will suggest what you can use. (the const of it is that it usually doesn’t suggest infix version of the function)

and if you still want linting to force certain cody style, I think this will be supported later but I am not aware of any linter for purescript.

2 Likes

I’d second this - many of the kinds of things that you need a linter for in other languages are caught by the compiler / type-system in PureScript. It really is a total change of perspective.

One way that i like to think of, and explain, how it works in effect is to encourage the novice to learn how to use the type system to express all the kinds of “memo to self” comments and notes that you’d have in another language “memo to self - remember that the list of widgets could be empty” or “TODO: is this field validated here, need to check”.

Then, the compiler actually takes that information seriously and constrains your program in those ways, which for me at least often results in headslap moments where i realize that i have different views of my program in different places and the compiler is like your pair programming buddy who points this out. At compile time.

Oh, and a lot of other lint-y functionality (uninitialized variable type stuff) is caught by the compiler too.

The compiler’s “partial function” check is particularly powerful, too, check it out!

2 Likes

I use

3 Likes

the purescript ide for vscode has a linter builtin. It will, for example, warn you about unused imports

@bjornkihlberg that’s misleading; VSCode’s PureScript IDE gets all its warnings and errors from the PureScript compiler (indirectly I think). All these warnings will be generated even if you use purs directly.

1 Like

You’re right. I got the impression he wanted to get going with an IDE experience. I should’ve phrased it in those terms.

1 Like

Compiler plus formatter takes big chunk of the work from the linter but there’s still some room for having one. hlint is a good example of that.

7 Likes