clj-kondo

https://github.com/clj-kondo/clj-kondo
pithyless 2021-02-03T05:47:46.082800Z

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

borkdude 2021-02-03T07:49:30.083500Z

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

pithyless 2021-02-03T07:50:45.084300Z

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 ;]

pithyless 2021-02-03T07:51:18.085Z

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

flowthing 2021-02-03T13:28:20.086300Z

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.

borkdude 2021-02-03T13:29:29.087Z

@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

flowthing 2021-02-03T13:30:20.087800Z

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

borkdude 2021-02-03T13:31:06.088700Z

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)

flowthing 2021-02-03T13:31:30.089Z

Thanks! I'll give that a try. Guess I should RTFM. πŸ™‚

borkdude 2021-02-03T13:31:46.089300Z

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

borkdude 2021-02-03T13:31:54.089600Z

any time you open a project

flowthing 2021-02-03T13:32:06.089900Z

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

flowthing 2021-02-03T13:33:08.090300Z

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

flowthing 2021-02-03T13:33:30.090600Z

(Also for clj-kondo itself β€” it's absolutely fantastic.)

borkdude 2021-02-03T13:33:49.090800Z

πŸŽ‰

niwinz 2021-02-03T21:58:24.096Z

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?

niwinz 2021-02-03T21:58:31.096200Z

Thanks!

borkdude 2021-02-03T22:00:37.097500Z

@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.

niwinz 2021-02-03T22:02:13.098700Z

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

niwinz 2021-02-03T23:15:54.099Z

@borkdude thanks, that worked