@borkdude finally got around to set up the Rum hook but there’s something to still figure out, with defcs
and defcc
there’s an implicit first argument. Since that is not passed at callsites, clj-kondo will say the function is called with the wrong arity. Would be happy to try to adapt the hook to support that. Do you think that’d require custom hooks or can it be made to work with the same lint-as
approach?
@martinklepsch If the arities are different, then the hooks probably need to be slightly different as well. I wasn't aware of that detail, sorry. I know @robert-stuttaford is also using the hook. Hasn't he ran into this yet? Maybe he doesn't use defcs
?
A PR fixing the reference config is welcome from either of you
PR welcome for the reference config
@borkdude I think I’m close. Ttrying to construct a modified argvec using this (api/vector-node (rest a))
but somehow not quite doing what I expect:
INPUT <vector: [state r]>
OUTPUT <vector: [[:format-string "[%s]"][:wrap-length 2][:seq-fn #object[clojure.core$vec 0x3ac6c820 "clojure.core$vec@104a1
ea78"]][:children (<token: state> <token: r>)]]>
WANTED <vector: [r]>
Also worth noting, printing the args vector node seems to omit spaces so the <vector: [state r]>
above is actually printed as <vector: [stater]>
@martinklepsch what is a?
<vector: [state r]>
you probably need (rest (:children a))
See the hooks docs, they explain this
https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#hooks
I found out about vector-node
reading this but don’t know much about rewrite-clj so missed the :children
bit
anyways, this seems to work
np
now the issue however is that the first arg isn’t known inside the function
:thinking_face:
you can fix this by introducing an artificial let binding with that name, bound to e.g. nil
for the implicit arg right
(let [state nil] ... body ...)
take a look at the hook for slingshot, it also uses this approach I think
cool, will do!
yes, we also have this, just haven't gotten round to doing the good opensource citizen thing and writing it up 😞
@martinklepsch Any luck with that?
got sidetracked by some other stuff after realizing that it’s not just a static token but could also have different names or be a destructuring form
in that case you should use the first element of the binding vector and then put that in the artificial let binding
(defn foo [stuff ...] body)
=> (defn foo [...] (let [stuff nil] body))