This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-06
Channels
- # announcements (5)
- # asami (4)
- # babashka (27)
- # beginners (1)
- # calva (4)
- # cider (64)
- # clj-kondo (7)
- # clojure (7)
- # clojure-brasil (3)
- # clojure-europe (41)
- # clojure-france (2)
- # clojure-norway (101)
- # clojure-uk (5)
- # clojurescript (19)
- # cursive (3)
- # datahike (15)
- # datomic (15)
- # events (2)
- # honeysql (11)
- # hyperfiddle (27)
- # introduce-yourself (2)
- # jobs-rus (1)
- # leiningen (8)
- # london-clojurians (1)
- # lsp (175)
- # off-topic (52)
- # overtone (10)
- # portal (15)
- # re-frame (7)
- # reagent (1)
- # releases (1)
- # remote-jobs (2)
- # shadow-cljs (15)
- # sql (5)
I have a codebase with 2500 namespaces and 400 custom macros and running clj-kondo for it currently generates 700 errors and 400 warnings. My goals it make clj-kondo stop producing any false positives for this codebase and I estimate that I might need to create hooks or lint-as
rules for each of these macros. I’m wondering if there are any good shortcuts or supporting libraries or tools that make creating these hooks or lint-as rules easier?
One random idea that I have is that hook generation code might often be created with something similar to syntax quoting - which helps generates hooks that simply rewrite the existing code into something that clj-kondo can understand. I’m wondering if somebody had a similar idea. In my vision a defmacro
definition may include such a thing in its attrmap to introduce a replacement code for a hook. Something like this: (defmacro x {:clj-kondo/rewrite '(let [a {} b c] body)} [a b c & body] …)
. Thoughts?
Hey @UHS6PHL31 - it's an interesting idea, but right now you can almost achieve the same with
{:hooks {:macroexpand ...}}
The inline notation will imo lead to confusions, e.g. people will try to write things that refer to code outside of the form using syntax-quote perhaps.Thank you very much for your reply. This is quite interesting. I overlooked this initially. I’ve read the description in https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md#macroexpand and I’m puzzled by a few things: 1. It might be a bit confusing to have the same-named macro in the same-named namespace with potentially the same content only distinguishable by a path. Why does it need to be exactly the same (namespace and macro naming)? 2. The doc claims that locations info will be lost in some cases. Where can I find more detailed info about such cases and potential explanations about why the locations will be lost (or more importantly, how to use it so that no locations will be lost?) 3. How complex can be a macro in configuration, can it use syntax quotes, etc? What would determine whether a macro can be used as is for its config macroexpand macro? Maybe such macros can be configured to macroexpand automatically or by flagging them with some attr-map value? I guess I will have to try to see how #2 and #3 work. #1 seems to prevent macros from being reused - for example I have a number of macros defined in different namespaces that each can be potentially configured with the same macroexpand macro. Would it be possible to share a single implementation in such case?
:macroexpand
is a killer feature. Why isn’t it on by default for any arbitrary macro?
Thanks for pointing me to it.