I did a threading macro for Promises in ClojureScript to make a Promise (.then p fn)
chain look like the normal threading operator macro. clj-kondo started giving arity warnings on the functions that are going to be “threaded”, and was wondering if there is a way to hint at the arity fix:
e.g.
(=> promise/resolve({})
(assoc :a 1))
and it would give the arity warning on assoc
equivalent, when the macro rewrites it to be:
(promise/then (promise/resolve {}) (fn [x] (assoc x : a)))
so it does get the correct arity when the ClojureScript is compiled and run, as it gives the expected results when doing testswas wondering if there are any hints for the pre-compiled macro form in ClojureScript, or annotations on the macro
since the standard threading operators don’t give those warning
thanks!
(where promise/then
and promise/resolve
are function wrappers for (.then p some-fn)
to make it safer to call)
@steven.proctor You can write a custom hook for this macro or just turn off arity warnings in that macro. https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md
Love your podcast btw!
Thanks, and thanks!!!
I have never configured clj-kondo before, so a question on general practice: the macro is in a promise library, it is possible to setup the clj-kondo config with that project so that all projects that use the macro get the config, or does that need to be configured in each project that uses it?
@steven.proctor That is possible. That mechanism is explained here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration
is that for the config.edn, the hooks definition, or both?
both
@borkdude thanks!!! I think the lint-as
config works, since I was basing it off the ->
operator, it looks like I can just lint it as that operator
ah great :)