clj-kondo

https://github.com/clj-kondo/clj-kondo
ep 2020-06-23T07:04:44.027100Z

question about future approaches to macros. does the addition of hooks mean that the https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#unrecognized-macros documented here: Clj-kondo only expands a selected set of macros from clojure.core and some popular community libraries will not be supported anymore in favor of us developing our own hooks? my question is if i want to contribute by updating or adding new built-in support for a macro, should i be exclusively developing hooks or will built-in support for libraries like compojure continue to be maintained?

borkdude 2020-06-23T07:34:47.028100Z

@epransky Macros that are already supported will remain supported. Macros that are very common can eventually move from hooks to built-in supported.

ep 2020-06-23T07:35:43.028400Z

thanks 🙂

borkdude 2020-06-23T07:36:29.028900Z

E.g. if someone figures out a hook for core.match, it can be moved inside clj-kondo

yuhan 2020-06-23T07:49:17.030200Z

Is there a limitation to why we can't write nodes as plain expressions instead of using the api syntax?

yuhan 2020-06-23T07:51:53.030800Z

like an inverse of the sexpr function

borkdude 2020-06-23T07:52:31.031100Z

@qythium Yes. I've explained it here: https://blog.michielborkent.nl/2020/06/21/clj-kondo-hooks/

yuhan 2020-06-23T07:55:12.031600Z

ah, I didn't understand that point the first time round. Thanks!

borkdude 2020-06-23T07:57:51.032400Z

Also this is more performant. Going from rewrite-clj -> sexpr -> hook -> sexpr -> rewrite-clj takes more operations than rewrite-clj -> hook -> rewrite-clj

borkdude 2020-06-23T07:58:22.032900Z

But loss of information is the main reason I abandoned the idea

lread 2020-06-23T12:08:08.036200Z

I wonder if hooks docs should link to your blog, it is very helpful. Either that or extracting a few key phrases from the blog to the hooks docs.

borkdude 2020-06-23T12:27:14.036400Z

PR welcome!

lread 2020-06-23T12:28:07.036700Z

Will do!

rschmukler 2020-06-23T18:45:31.039400Z

Hey! Does the new hooks API allow for allowing for different linting based off of clojure and clojurescript mode? I have a cljc macro for RPC that boils away the body on the cljs side (and instead does an RPC call) and behaves like a defn on the clj side. Since I'm conditionally requiring the clj libraries, lint-as clojure.core/defn doesn't work for me.

borkdude 2020-06-23T20:02:41.040300Z

@rschmukler Currently there is nothing to go by in the hook, but I could add a :lang key that will contain either :clj or :cljs if that's helpful

rschmukler 2020-06-23T21:08:48.041700Z

@borkdude that'd be wonderful! It might also be worth including a :lang-via which could indicate that the file is cljc. I'm not immediately sure that this is useful at all, so feel free to consider it and ignore it if you can't think of a use case!

borkdude 2020-06-23T21:09:50.042700Z

@rschmukler In clj-kondo itself I use a ctx map which has :base-lang :cljc and :lang :cljs for example

rschmukler 2020-06-23T21:10:02.043Z

That's perfect

rschmukler 2020-06-23T21:12:21.045800Z

Also, have you considered somehow allowing libraries to communicate with the hooks library directly? It'd be cool if downloading a library via clojars automatically gave me linting, similar to how typescript allows types to be packaged up in NPM modules.... ie. Could library authors somehow get you clj-kondo hooks for free without requiring you modify the config...

rschmukler 2020-06-23T21:12:35.046200Z

Not sure if it's a road you want to go down, but maybe worth thinking about

borkdude 2020-06-23T21:13:38.047200Z

I have thought about that: https://github.com/borkdude/clj-kondo/issues/559 For now I suggest library authors to post their configs here: https://github.com/borkdude/clj-kondo/tree/master/libraries Maybe eventually we can have some tool which can inspect the classpath and harvest these configs for you

rschmukler 2020-06-23T21:13:53.047700Z

Hmmmmm and now that I'm thinking about it - giving hooks access to the config could be useful then

rschmukler 2020-06-23T21:14:10.048200Z

ie. imagine if a library auto packages itself with hooks, maybe it has its own clj-kondo settings

rschmukler 2020-06-23T21:14:47.049Z

I'll check out the issues, thanks for the replies! Super excited for the hooks API, I think it could really be something special if the community widely adopts it

borkdude 2020-06-23T21:15:02.049200Z

Thank you

borkdude 2020-06-23T21:52:40.049700Z

@rschmukler Could you maybe add an issue about those extra keys, in case I forget

rschmukler 2020-06-23T22:06:54.049900Z

Will do!