Getting started with linters

clojurescript
clojure

#1

I’ve never used Linters before but now find myself managing teams of [student] developers learning Clojure, and this seems like a great way to maintain code quality (and get my own code etiquette in gear, too). What are some recommendations for Clojure linting software and linting setups?

Some notes:

  • I use emacs but give my teams the option of using emacs or Cursive. A linter that operates outside of the code editor would hence make sense (unless you experts tell me it doesn’t).
  • Our projects include Clojure and Clojurescript.

So, where should I start and what should I consider for setting up style rules (if necessary)?


#2

I have used clj-fmt with whatever defaults it comes with for purely formatting issues, and Eastwood for other things. No complaints so far. I’d like to integrate joker for on the fly results.


#3

I recommend Joker: https://twitter.com/borkdude/status/1047135083998732288


#4

I use Joker as a plugin for Emacs (Spacemacs clojure-lint layer) that continually checks my Clojure code. Joker gives me fast feedback in Emacs without being obtrusive or distracting.

Joker can give a few false positives, especially around macros, however it is easy to define those in a .joker ignore file. For example:

{:known-macros [rum.core/defc
                rum.core/defcc
                rum.core/defcs]}

I also use Eastwood, a leiningen plugin, as a check before I commit code. Eastwood does a full evaluation of your code and is arguably more correct about the code than Joker.

You can use squiggly-clojure to continually run Eastwood linting. This will repeatedly reload your code in the repl, so you should ensure your code is happy with that.

Thank you.


#5

Joker is what I’ll probably use myself, and Eastwood sounds great in general. My team is using a combination of IntelliJ and Emacs, so it’s good to have options. Anyone know of IntelliJ/Cursive linting solutions like Joker?


#6

IntelliJ IDEs have their own internal parsing/checking engines, and Cursive makes a decent job of exploiting it to detect errors, unused variables/aliases. That said it seems it detects less things than Joker (not sure since I couldn’t find a list of all Joker lints).

I never used Joker or Eastwood, so I don’t know how to integrate them with Cursive.