Fork me on GitHub
#clj-kondo
<
2021-02-03
>
pithyless05:02:46

has someone posted a linter for the else->> macro? It's a mind-bending piece of code and I would happily replace better-cond if it means clj-kondo can better lint my code 🙂 https://gist.github.com/borkdude/93efc3f5978a2ed545553a47caaf7aa8

borkdude07:02:30

@pithyless I think it’s not hard to write a hook for this

pithyless07:02:45

yeah, I figured a hook for this is easier to write, than for parsing better-cond; I was just hoping someone had already done it ;]

pithyless07:02:18

if no one has, I guess I'll take a stab at it later

flowthing13:02:20

I'm trying out the new "unresolved var" linter. I'm wondering why it doesn't always work. Repro:

(require '[clojure.tools.namespace.repl :as t.n.r])
(t.n.r/nope)

(require '[clojure.set :as set])
(set/onion)
It reports set/onion, but not t.n.r/nope.

borkdude13:02:29

@flowthing the reason (probably) is, is that clojure.tools.namespace hasn't been analyzed/linted, but clj-kondo knows about a few built-in libraries like clojure.set already

flowthing13:02:20

Aha. Is that something I can fix by configuring clj-kondo?

borkdude13:02:06

to lint this library, make a .clj-kondo dir in your project root and then lint everything using clj-kondo --no-warnings --parallel --lint <classpath> where <classpath> is some build-tool specific thing like $(clojure -Spath)

flowthing13:02:30

Thanks! I'll give that a try. Guess I should RTFM. 🙂

borkdude13:02:46

If you use clojure-lsp then it will do this for you, I think

borkdude13:02:54

any time you open a project

flowthing13:02:06

OK — I don't use it at the moment, though, but good to know.

flowthing13:02:08

Yeah, your suggestion fixed the issue -- many thanks!

flowthing13:02:30

(Also for clj-kondo itself — it's absolutely fantastic.)

niwinz21:02:24

Hi! I have an issue that after some time of digging on it, did not found a solution. I have a macro that "reexports" some vars, so the code looks like (d/export somens/somesymthatpointstovar) , now clj-kondo raises the warning about unresolved var when using anything that is exported using this macro. I tried to use it like lint-as with clojure.core/declare and it does not have any effect (indeed because the warning is not caused by the macro export ; is cause by the use of the results of this macro. There are any hint on how to fix it?

borkdude22:02:37

@niwinz There are multiple ways to solve this. 1) You can configure the :unresolved-var linter to turn off warnings for this namespace. See docs here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#unresolved-var. 2) You can write a hook to make clj-kondo understand your macro. See https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md.

niwinz22:02:13

hmm i was not aware about hooks for this case, thanks for the hint

niwinz23:02:54

@borkdude thanks, that worked