Fork me on GitHub

Example config for the Rum library: cc @martinklepsch @robert-stuttaford


clj-kondo v2020.06.21 introduces a new hooks API which allows writing code to support custom macros 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))


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:


@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


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


At this time libraries don’t export config. Users have to add it manually


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!


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.