Fork me on GitHub
#clj-kondo
<
2020-09-25
>
kevin2642817:09:37

eslint has a way to pass --fix which will auto fix errors that don't require programmer intervention. Is there a way to do this with clj-kondo?

borkdude17:09:20

no, clj-kondo won't touch your code

borkdude18:09:18

there are various tool that can, but they are mostly tied to editors, e.g. clj-refactor, clojure-lsp, etc

borkdude18:09:48

this is a tool that cut out unused vars: https://github.com/borkdude/carve

kevin2642818:09:12

how would I configure linters when I'm using this library https://github.com/plumatic/plumbing . I want to use the :lint-as option instead of excluding it like this:

{:linters
  {:unresolved-symbol
    {:exclude [(plumbing.core/fnk)]}}}

borkdude19:09:02

@kevin26428 I think this works:

(ns foo
  {:clj-kondo/config '{:lint-as {plumbing.core/fnk clojure.core/fn}}}
  (:require [plumbing.core :refer (fnk sum)]))

(def stats-graph
  "A graph specifying the same computation as 'stats'"
  {:n  (fnk [xs]   (count xs))
   :m  (fnk [xs n] (/ (sum identity xs) n))
   :m2 (fnk [xs n] (/ (sum #(* % %) xs) n))
   :v  (fnk [m m2] (- m2 (* m m)))})

borkdude19:09:04

so {:lint-as {plumbing.core/fnk clojure.core/fn}}

kevin2642820:09:28

I didn't see any mention of white space or indentation space checks in clj-kondo, is this configurable?

borkdude20:09:53

clj-kondo ignores all whitespace - I think there might be other tools concerned with formatting / indentation

borkdude20:09:08

I think it could do that, but personally I haven't really found this an issue worthwhile to work on, since formatting in the editors I use is pretty much automatic

nbtheduke20:09:42

i have a macro called wait-for that does a lot (too much probably). i have it listed in the :invalid-arity {:skip-args vector. because of this, i have an "unused binding" warning. if I remove the wait-for from the :skip-args vector, the "unused binding" warning goes away (as it should, because the binding is used inside the wait-for call)

nbtheduke20:09:19

any ideas why this might be happening?

borkdude20:09:16

@nbtheduke Do you have a repro for me to look at?

borkdude21:09:19

@nbtheduke E.g.:

(ns foo)

(defmacro wait-for [& _body])

(defn foo [x]
  (wait-for (inc x 1 2 3)))
$ clj-kondo --lint /tmp/foo.clj --config '{:linters {:invalid-arity {:skip-args [foo/wait-for]}}}'
linting took 11ms, errors: 0, warnings: 0

borkdude21:09:32

I don't see x being unused

nbtheduke21:09:42

others is referenced on line 265

borkdude21:09:01

Can you boil this down to a small repro?

nbtheduke21:09:15

lol I'll see what I can do. this repo is a mess

kevin2642822:09:23

how do i exclude/handle things like tags #db/fn