This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-03
Channels
- # announcements (17)
- # asami (17)
- # babashka (20)
- # beginners (110)
- # calva (1)
- # cherry (3)
- # cider (1)
- # clj-kondo (21)
- # clj-on-windows (1)
- # cljsrn (5)
- # clojure (142)
- # clojure-austin (1)
- # clojure-europe (72)
- # clojure-france (28)
- # clojure-hungary (2)
- # clojure-nl (2)
- # clojure-norway (38)
- # clojure-poland (2)
- # clojure-uk (3)
- # clojurescript (4)
- # cursive (33)
- # data-science (3)
- # datahike (5)
- # datomic (1)
- # emacs (27)
- # events (3)
- # fulcro (15)
- # graalvm (4)
- # gratitude (2)
- # honeysql (7)
- # humbleui (8)
- # introduce-yourself (11)
- # jobs-discuss (9)
- # lambdaisland (3)
- # lsp (18)
- # malli (62)
- # music (1)
- # nbb (3)
- # off-topic (10)
- # pathom (3)
- # pedestal (6)
- # polylith (5)
- # re-frame (7)
- # releases (2)
- # shadow-cljs (33)
- # sql (1)
- # test-check (23)
- # vim (20)
- # xtdb (9)
would it be technically possible for clj-kondo
to detect if ^{:some-metadata "foo}
was being applied to an unsuitable form?
for example I was looking at some reagent code such as ^{:key id} (if foo? [:div] [:span])
, which according to my very limited understanding of metadata is incorrect
it's not incorrect as in, the clojure reader will fail, but the metadata is discarded since if
doesn't do anything with it. you should use with-meta
here
indeed. But it seems like it's a relatively common mistake to make, I think I've seen it a couple of times because it's easy to assume it applies to the resulting value at runtime (like with-meta
). Sure would be nice to notice problems like that without looking at the react warnings in the js/console 😉
but I have no idea is it possible to reliably detect when the metadata is being ignored
in general it's not really something you can detect that is "wrong" since the macro (or special form) might do something with this metadata
@arturdumchev Currently there's not such a helper
I will check on weekends if there is a good solution to add one and maybe come up with the pr
My case: macro gets a map as a param. I have to get nodes from this map to use with-meta
further
can you describe your use case further? example call of the macro for example? why do you need to read from the map?
The codebase I am working now has a lot of macro like:
(macro-that-will-creat-several-functions
{:get-function "name-of-the-get-fn"
:set-funtion "name-of-the-set-fn"
:this-will-be-used-so-I-need-to-tell-clj-kondo-that-this-value-is-used pool-that-will-be-used-inside})
I have a library with some common operations for rewrite-clj nodes here https://github.com/borkdude/rewrite-edn/blob/80f246139b1a43b6f2cbab329521d060ee7c1b7b/src/borkdude/rewrite_edn/impl.cljc#L118