Fork me on GitHub
#clj-kondo
<
2020-06-20
>
borkdude11:06:42

I think I'm close to a release now

borkdude11:06:13

Latest example for re-frame/dispatch hook:

borkdude11:06:09

Now write some docs

wilkerlucio12:06:12

@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?

borkdude13:06:05

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

borkdude13:06:44

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

dominicm13:06:57

@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.

borkdude13:06:16

@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

dominicm13:06:47

@borkdude I figured as much.

borkdude13:06:14

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

borkdude13:06:42

I consider that something for later

dominicm13:06:52

Either way, the example should cope with vars.

dominicm13:06:09

How does apply play with hooks?

borkdude13:06:52

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

borkdude13:06:27

Note that this is mostly for expanding unrecognized macros

borkdude13:06:33

The rest is more or less a bonus

borkdude14:06:45

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.

borkdude16:06:21

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

borkdude16:06:26

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

borkdude16:06:00

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

dominicm16:06:23

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

borkdude16:06:08

So this is merged to master now

borkdude16:06:51

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

borkdude16:06:20

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