clj-kondo

https://github.com/clj-kondo/clj-kondo
borkdude 2020-06-20T11:05:42.451300Z

I think I'm close to a release now

borkdude 2020-06-20T11:06:13.451800Z

Latest example for re-frame/dispatch hook:

borkdude 2020-06-20T11:09:09.452400Z

Now write some docs

wilkerlucio 2020-06-20T12:31:12.453500Z

@borkdude nice, this :clj-kondo/config will also support regular clj-kondo config? I wonder if as a library author I can already say things like "this custom macro is just like defn", will that be possible using this ns config?

borkdude 2020-06-20T13:19:05.453900Z

@wilkerlucio I consider that a different feature: https://github.com/borkdude/clj-kondo/issues/559

borkdude 2020-06-20T13:19:44.454600Z

:clj-kondo/config is just ordinary clj-kondo config

dominicm 2020-06-20T13:28:57.456200Z

@borkdude does your example assume literals? Could it be updated to cancel early or use type inference when it isn't a literal? I think it's critical that the examples are comprehensive.

borkdude 2020-06-20T13:31:16.457Z

@dominicm yes, you get the source node as the user writes it. arguments don't get evaluated before you see the source node, that's not how static analysis works

dominicm 2020-06-20T13:31:47.457500Z

@borkdude I figured as much.

borkdude 2020-06-20T13:32:14.458Z

type inference: could be possible, but then I'd need to pass more into the hook function, something like :bindings where a binding can have a tag

borkdude 2020-06-20T13:32:42.458600Z

I consider that something for later

dominicm 2020-06-20T13:32:52.459100Z

Either way, the example should cope with vars.

dominicm 2020-06-20T13:33:09.459500Z

How does apply play with hooks?

borkdude 2020-06-20T13:33:52.460200Z

The :analyze-call hook only gets called when the function is in function position, not as an argument to apply

borkdude 2020-06-20T13:34:27.460500Z

Note that this is mostly for expanding unrecognized macros

borkdude 2020-06-20T13:34:33.460700Z

The rest is more or less a bonus

borkdude 2020-06-20T13:56:56.460900Z

Here are some docs: https://github.com/borkdude/clj-kondo/blob/macros-sci/doc/config.md#hooks

borkdude 2020-06-20T14:07:45.461900Z

I want to add more examples of other libraries. In fact I want to make documentation sections for library-specific configs. But this should explain how it works.

borkdude 2020-06-20T16:12:21.463900Z

@dominicm you're right, the example fails with (dispatch x ...) or (dispatch (some-fn-producing-a-vector)), so I'll probably just remove it

borkdude 2020-06-20T16:14:26.464600Z

well, the example is still useful when: 1) the users passes a vector with a keyword, but the keyword is unqualified

borkdude 2020-06-20T16:15:00.465100Z

although you get limited feedback, still useful, like with many other cases where static analysis can only get you so far

dominicm 2020-06-20T16:21:23.465700Z

@borkdude Yeah. You just need to be careful about what you lint, I think carefully applied power matters here.

borkdude 2020-06-20T16:26:08.466500Z

So this is merged to master now

borkdude 2020-06-20T16:31:51.467Z

Btw you can also specify the types for dispatch as :vector but that doesn't say anything about the contents of the vector

borkdude 2020-06-20T16:33:20.468Z

Btw, anyone's open source project is using clj-kondo and you want to share the config, do it here: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#example-configurations