Pro Yearly is on sale from $80 to $50! »

Clj-kondo: a linter for Clojure code that sparks joy @ ClojuTRE 2019

Clj-kondo: a linter for Clojure code that sparks joy @ ClojuTRE 2019

Clj-kondo is a linter for Clojure code that sparks joy. It analyzes your code without evaluating it and detects arity errors, redundant expressions, unused requires, missing test assertions and more. It provides fast editor feedback because it runs instantly as a native binary, not depending on a REPL in a JVM. In this talk we will see what it can do, how it is implemented and how it compares to other Clojure linters.

Bbb17eeeecd3d9d06f4db310ab630a12?s=128

Michiel Borkent

September 27, 2019
Tweet

Transcript

  1. Michiel Borkent @borkdude

  2. Word origins

  3. Clojure linters Linter Focus CLJS? Macroexpand? Execution Eastwood General No

    core + user JVM Kibit Idioms No No JVM Joker General Yes core Go native Cljfmt Formatting Yes n/a JVM How to ns How to ns Yes n/a Clojure JVM Clj-kondo General Yes core GraalVM native / JVM
  4. Clj-kondo origin story • I've been a happy joker user

    since 2017 • Wanted to add a feature: (defn foo [x] (def x 1)) • Joker is written in Go, can it be done in Clojure? • Tried with Clojure on GraalVM (native = fast startup like joker) • Success with rewrite-clj which is based on tools.reader • Writing more linting features was too much fun!
  5. Invalid code is still data

  6. None
  7. None
  8. Arity errors

  9. None
  10. None
  11. REPL state

  12. REPL state $ clj-kondo --lint src | grep "unresolved symbol

    c" src/dre/analytics/authors.clj:585:41: info: unresolved symbol c
  13. Unused let and fn bindings

  14. Unresolved symbols

  15. Redundant let + do

  16. Missing test assertion

  17. Style: don't refer :all

  18. Ns form cleanup

  19. Ns form cleanup

  20. Type checking

  21. Editor support

  22. .clj-kondo • .clj-kondo/config.edn • Shared configuration, intended for version control

    • .clj-kondo/.cache • Automatically updated when changing code in editor • Contains arity and other info about linted code • Allows linter to reason about multiple namespaces • Populate with lib info: clj-kondo --lint $(clj -Spath)
  23. Config from manifold.deferred Clj-kondo doesn't know how to lint this

    macro
  24. Config

  25. Analysis export

  26. Who uses clj-kondo? Github #438 Add your company to the

    list:
  27. Thank you https://github.com/borkdude/clj-kondo