Fork me on GitHub
#clj-kondo
<
2020-06-21
>
borkdude10:06:43

Example config for the Rum library: https://github.com/borkdude/clj-kondo/tree/master/libraries/rum cc @martinklepsch @robert-stuttaford

borkdude12:06:15

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!

dominicm14:06:57

Gonna give this a spin, today

dominicm16:06:15

How do I debug a hook? Like, check the output?

borkdude16:06:44

@dominicm Try (prn (api/sexpr node))

qythium19:06:07

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

borkdude19:06:47

@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

qythium23:06:35

Is this true even when different libraries both have their own .clj-kondo subdirectories?

qythium23:06:55

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

borkdude06:06:24

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

borkdude19:06:26

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

lee23:06:41

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!

qythium23:06:13

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.