Fork me on GitHub
#clj-kondo
<
2022-08-09
>
jumar07:08:37

I'm noob when it comes to configuring clj-kondo and I'm playing with guardrails: https://github.com/fulcrologic/guardrails#quick-start Emacs complains about <defn macro and its syntax so I'd like to fix it. I noticed guardrails has clj-kondo config: https://github.com/fulcrologic/guardrails/tree/develop/.clj-kondo ... which links to https://github.com/fulcrologic/guardrails/tree/develop/src/clj-kondo/clj-kondo.exports/com.fulcrologic/guardrails How can I make it work when using guardrails as a library?

jumar07:08:27

Hmm, it finishes very quickly giving me this:

clj-kondo --lint "<classpath>" --dependencies --parallel --copy-configs
No configs copied.

jumar07:08:43

Ah, sorry, I didn't read very far...

jumar07:08:19

clj-kondo --lint $(clojure -Spath) --dependencies --parallel --copy-configs
this looks better

jumar07:08:00

But it didn't help much. Do I need to restart emacs once this is done? (I just killed the buffer and opened it again)

borkdude07:08:42

Can you check what is in your .clj-kondo folder now?

jumar07:08:25

Hmm, there's nothing like that in the project root

borkdude07:08:15

You first have to create the .clj-kondo directory manually

jumar07:08:35

Ouch, why clj-kondo --lint ... doesn't do that automatically?

borkdude07:08:17

because else your project would be littered with .clj-kondo directories

borkdude07:08:27

.clj-kondo is used to detect the project root

jumar08:08:19

Hmm, I can imagine the use case for it but cannot you just make people run this command in the project root anyway? (Instead of making them to run the command in the project root) Or you have a use case to run it only in subfolder(s)?

borkdude08:08:55

the clj-kondo binary is also used from emacs and flycheck doesn't execute it from a project root, the cwd is the file you're editing, so unfortunately no

jumar08:08:20

Ok, got it. Thanks for the help. I hope I can make it work now 🙂

borkdude08:08:09

keep me posted ;)

jumar08:08:47

Looks good now, thanks again!

🎉 1
Noah Bogart13:08:57

In a couple places, I have functions like (def get-body (comp :body http/get)). clj-kondo treats these symbols as normal symbols instead of functions. What's the best way to make clj-kondo treat this as the function http/get? (same arg list, etc)

Joshua Suskalo14:08:19

I think you could add it to :lint-as although I'm not entirely sure.

Noah Bogart14:08:37

oh that's a good point

Noah Bogart14:08:09

i wish i could attach :lint-as and other data directly to the var so i didn't have to worry about them getting out of sync because someone forgot lol

Joshua Suskalo14:08:20

Yeah, understandable.

borkdude14:08:26

The best way would be to write functions using defn and avoid comp :)

Noah Bogart14:08:32

haha Yeah, I agree, but my boss is... persnickety about some stuff, so I'm hoping to just make my own life a little easier

borkdude14:08:21

haha, I know, some people go a bit overboard with comp and partial

eval202015:08:12

It’s the end of the day, I might be totally overseeing something obvious, but I can’t find what’s wrong here:

$ clj-kondo --lint malli_select.clj | grep Unparsable
malli_select.clj:0:0: error: Can't parse malli_select.clj, Unparsable namespace form
~/projects/garden/malli/schema_select (master *)
$ head malli_select.clj
(ns malli-select
  (:require [clojure.test :as test :refer [deftest is testing are]]
            [malli.core :as m]
            [malli.generator :as mg]
            [malli.util :as mu]))
$ clj -M -m malli-select
Works!
Nuking the requires doesn’t fix it. Renaming file and namespace to foo doesn’t fix it…

borkdude15:08:31

@eval2020 Did you try the smallest repro possible?

eval202015:08:57

emptying the file and copying the exact ns-form does not yield the error.

borkdude16:08:40

Do you have more require forms in the namespace?

eval202016:08:18

Ah, some (require '[]) in a comment-block

👍 1
eval202016:08:50

good to know - thanks

borkdude16:08:21

clj-kondo could do a better job of not crashing on that though. issue welcome

eval202016:08:20

right - or point to the offending line maybe…

borkdude17:08:00

yes, that's what it should do