Fork me on GitHub
#clj-kondo
<
2022-10-16
>
Fredrik Andersson14:10:55

however, now I have created my own macro - how do I make clj-kondo lint that correctly? I have two linter errors coming from my macro

Fredrik Andersson14:10:23

thanks, ill look into it

borkdude15:10:34

@U01JYUZRS4V what kind of macro? Do you have an example of its usage?

borkdude15:10:45

I'm asking since the syntax of your macro may make it easier or less easy to configure it for clj-kondo

Fredrik Andersson17:10:03

;; define component that depends on resolvers (sub/defcomp app [user-id] [boot [:firebase firebase-config] individual [:firestore [:individual user-id]]] (case (:state @boot) :starting [:div "booting"] :unauthenticated [:div "unauthenticated"] :authenticated (layout/app {:logo [:div.bg-green-100 "Logo"] :user [:div.bg-blue-100 "User"] :navigation [:div.bg-yellow-100 [:div "lalalala"]] :content-top [:div.bg-red-100 "Content top"] :menu [:div.bg-purple-100 "Hamburger"] :content [:div.bg-pink-100 [:div "lalalala"]]}) [:div "Error"]))

Fredrik Andersson17:10:22

this is the test case for the macro

Fredrik Andersson17:10:10

it becomes a (defn app ...) that in turn use reagent with-let to setup subscriptions to firestore

Fredrik Andersson17:10:37

as far as I understand, I should write a hook that rewrites the code into a (defn <name> [] (let [..

Fredrik Andersson17:10:11

ahh, now I see that everything would be easier if I just let the macro be a new (let bindings instead of the whole function

Fredrik Andersson18:10:37

thanks everybody for your help - I finally solved it by rewriting my macro into a pure binding macro

borkdude18:10:31

makes sense

Fredrik Andersson18:10:42

yes, I realize now that I was trying to do too much in my macro and that it wouldn't be according to general consensus

borkdude18:10:31

With clj-kondo in general it works best if your new macros align with some existing macro so you can use :lint-as but if not, there's always other ways to do stuff: either by suppressing warnings, or writing hooks.

Fredrik Andersson14:10:39

first, it doesn't recognize that my macro generates a defn and second it doesnt recognize let bindings