This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-16
Channels
- # announcements (9)
- # babashka (12)
- # beginners (60)
- # biff (2)
- # calva (4)
- # cider (4)
- # clj-commons (1)
- # clj-kondo (17)
- # clojure (2)
- # clojure-europe (17)
- # clojurescript (15)
- # emacs (18)
- # exercism (5)
- # fulcro (15)
- # holy-lambda (13)
- # joyride (1)
- # lambdaisland (2)
- # malli (1)
- # nbb (3)
- # off-topic (23)
- # polylith (6)
- # portal (59)
- # releases (1)
- # squint (1)
- # tools-deps (4)
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
https://clojurians.slack.com/archives/CPABC1H61/p1658985733025239?thread_ts=1658978704.619419&cid=CPABC1H61 (original question was regarding clojure-lsp but the situation is the same)
thanks, ill look into it
You may find https://github.com/clj-kondo/hooks-workshop-clojured-2022 helpful.
@U01JYUZRS4V what kind of macro? Do you have an example of its usage?
I'm asking since the syntax of your macro may make it easier or less easy to configure it for clj-kondo
;; 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"]))
this is the test case for the macro
it becomes a (defn app ...) that in turn use reagent with-let to setup subscriptions to firestore
as far as I understand, I should write a hook that rewrites the code into a (defn <name> [] (let [..
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
thanks everybody for your help - I finally solved it by rewriting my macro into a pure binding macro
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
or convention
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.
first, it doesn't recognize that my macro generates a defn and second it doesnt recognize let bindings