I think I'm close to a release now
Latest example for re-frame/dispatch hook:
Now write some docs
@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?
@wilkerlucio I consider that a different feature: https://github.com/borkdude/clj-kondo/issues/559
:clj-kondo/config
is just ordinary clj-kondo config
@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.
@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
@borkdude I figured as much.
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
I consider that something for later
Either way, the example should cope with vars.
How does apply play with hooks?
The :analyze-call
hook only gets called when the function is in function position, not as an argument to apply
Note that this is mostly for expanding unrecognized macros
The rest is more or less a bonus
Here are some docs: https://github.com/borkdude/clj-kondo/blob/macros-sci/doc/config.md#hooks
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.
@dominicm you're right, the example fails with (dispatch x ...)
or (dispatch (some-fn-producing-a-vector))
, so I'll probably just remove it
well, the example is still useful when: 1) the users passes a vector with a keyword, but the keyword is unqualified
although you get limited feedback, still useful, like with many other cases where static analysis can only get you so far
@borkdude Yeah. You just need to be careful about what you lint, I think carefully applied power matters here.
Updated: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#custom-lint-warnings
So this is merged to master now
Btw you can also specify the types for dispatch
as :vector
but that doesn't say anything about the contents of the vector
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