maybe @delaguardo ^?
I already reserve few hours this weekend for that)
๐ โค๏ธ
This is an example of rewriting a slingshot/try+ call to something clj-kondo understands using the new "hooks" functionality: https://github.com/borkdude/clj-kondo/blob/macros-sci/corpus/.clj-kondo/macroexpand/try_plus.clj
(cc @martinklepsch)
it's not the easiest macro example, but it shows that it's possible to do it. this is an easier one which is syntactically isomorphic to the jdbc with-transaction macro: https://github.com/borkdude/clj-kondo/blob/macros-sci/corpus/.clj-kondo/macroexpand/weird_macro.clj
@martinklepsch so this is a newer version of a hook that can teach clj-kondo about rum defc: https://github.com/borkdude/clj-kondo/blob/81e3e8a66beaf07c011546ff89b7d7358cd00644/corpus/macroexpand.clj#L74-L111
Note, the string in the config is only for demo, it may also be a filepath relative to the .clj-kondo directory
Here's a mac binary: https://9926-176829714-gh.circle-artifacts.com/0/release/clj-kondo-2020.06.13-SNAPSHOT-macos-amd64.zip
I might still rename the naming of {:hooks {rum/defc ...}}
since this gets invoked during analysis of a call only. so maybe {:hooks {:analyze-call {rum/defc ...}}}
might be better for future extension
and then we could potentially add more and more hooks
but that's a minor detail.
downloaded this binary and added the config to the ns form of a file but it seems to behave as before
Iโm pretty sure the right clj-kondo
binary is used
clj-kondo v2020.06.13-SNAPSHOT
can you give me that same file?
works for me
can you try running clj-kondo --lint rum.clj
?
it should output:
$ clj-kondo --lint /tmp/rum.clj
/tmp/rum.clj:35:1: error: quux/with-mixin is called with 4 args but expects 1
/tmp/rum.clj:35:13: error: unresolved symbol a
/tmp/rum.clj:37:1: warning: redefined var #'quux/with-mixin
figured it out by trying to trim down my file
the :hooks
key should use the fully qualified macro name
{:clj-kondo/config '{:hooks {rum.core/defc "
before the key was just rum/defc
but these macros live in rum.core
yeah sorry, that was just for my own tests ๐ I actually don't use rum so I didn't bother to look what the real ns name was ๐
very very cool though, seems to work great!
thanks for testing
my pleasure, very excited to get this into our CI ๐
so how many variations of this defc macro are there, only one?
rum/defcs I see, is that syntactically the same as defc?
if so, then adding a lint-as rule for this should work (it doesn't right now, but it can be made so)
done: https://github.com/borkdude/clj-kondo/blob/macros-sci/corpus/macroexpand.clj#L74-L120 should now work with this binary: https://9930-176829714-gh.circle-artifacts.com/0/release/clj-kondo-2020.06.13-SNAPSHOT-macos-amd64.zip (cc @robert-stuttaford)
thereโs also defcc but I think itโs also the same
they basically add extra arguments to the function
so as long as the argvec is parsed correctly this should be fine
ok then lint-as can also be used for that one, nice
@delaguardo Seems someone worked on including clj-kondo into super-linter: https://github.com/github/super-linter/pull/197
That's even better) now I have free two hours on weekend)
:hugging_face: