Fork me on GitHub
#clj-kondo
<
2020-09-25
>
Kevin17: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

Kevin18: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}}

Kevin20: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

Matthew Downey17:01:14

Hey @U04V15CAJ - not to dig up ancient history but I wanted to check if the idea is still to keep indentation out of scope for clj-kondo. If so I'm thinking of using babashka + rewrite-clj to check for compliance with https://tonsky.me/blog/clojurefmt/ since it seems like an easy one to start with 🙂. My interest in this feature is mostly that while my editor does what I want it to, I want to be able to have a style guide for a project and not put myself in the position of bugging others to change little things in PRs or whatever (clj-kondo has been great for this already!).

borkdude19:01:12

Does this relate with the comment in #CPABC1H61 about formatting and style/indent etc?

borkdude19:01:36

since lsp has formatting abilities and clj-kondo doesn't it might be good to join that conversation there

Matthew Downey19:01:22

Oh no, total coincidence, hadn't seen it

Matthew Downey19:01:28

But yeah makes perfect sense, will investigate doing this with cljfmt

Noah Bogart20: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)

Noah Bogart20: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

Noah Bogart21:09:42

others is referenced on line 265

borkdude21:09:01

Can you boil this down to a small repro?

Noah Bogart21:09:15

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

Kevin22:09:23

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