Example config for the Rum library: https://github.com/borkdude/clj-kondo/tree/master/libraries/rum cc @martinklepsch @robert-stuttaford
clj-kondo v2020.06.21 introduces a new hooks API which allows writing code to support custom macros https://github.com/borkdude/clj-kondo/releases/tag/v2020.06.21 This work was sponsored by Clojurists Together as part of their Summer of Bugs program. Thanks!
Gonna give this a spin, today
How do I debug a hook? Like, check the output?
@dominicm Try (prn (api/sexpr node))
Blogged about the new feature here: https://blog.michielborkent.nl/2020/06/21/clj-kondo-hooks/
@dominicm https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#tips-and-tricks
The new hooks API looks interesting! One thing that wasn't clear to me from reading the documentation was whether clj-kondo treats the auxillary files in .clj-kondo as regular namespaces? Eg. If I write my library and put its macroexpand definitons in .clj-kondo/foo.clj
, does that conflict with another library's definitions in the same foo
ns?
Wondering why this isn't namespaced the conventional way with the library name: https://github.com/borkdude/clj-kondo/blob/master/.clj-kondo/macroexpand/one_of.clj
@qythium clj-kondo doesn't execute any other files than those in .clj-kondo
and since there can only be one .clj-kondo/foo.clj
file at the same time, there isn't any conflict
and you can load that file using (require 'foo)
or refer to it from the config as foo/foo
(assuming it has a function foo
). having said that, it's a good habit to use at least two segments in a namespace
Thanks for the new linting power @borkdude! I’ll see if I can get it working on rewrite-cljc’s internal import-vars-with-mods
macro!
Is this true even when different libraries both have their own .clj-kondo subdirectories?
Sorry, maybe I'm misunderstanding the mechanism for 3rd-party libraries to provide hooks - do they all have to be added via PR to the clj-kondo repo? And curated such that libraries/***/.clj-kondo/hooks/common-name.clj
does not conflict
Also, where does one find the actual API for clj-kondo.hooks-api
? I couldn't find such a namespace defined in the clj-kondo repo, only usages of it.