i searched for taoensso/carmine and saw that due to no exported clj-kondo config, better to just exclude unresolved-var . but given that there's a https://github.com/taoensso/carmine/blob/97cefd0aaf7f4bae56257634ea5423801a7a1ca6/resources/carmine-commands.edn file that shows everything it autogenerates, i could conceivably just parse and build those for clj-kondo. is it possible to "intern" vars into clj-kondo's understanding of a given namespace, which would then be used in analysis?
I guess you could generate a hook from that EDN file that does what the macro does to define some vars
even if it would just do a bunch of declares
huh, interseting idea
any ideas how i'd write that? i'm trying to use :macroexpand but struggling
what have you tried so far? I'm suggesting to actually generate the macroexpand hook file using some script outside of kondo which can read the .edn file and spits out the hook file which clj-kondo can then use
oh i see, i was trying to generate it from within the hooks file
so build a file that has a bunch of (defn foo [{:keys [node]}] ...) lines, and then have a config file that says {:hooks {:analyze-call {carmine/foo hooks.carmine/foo ...}}}?
yes
cool, thanks for the idea, i went about it totally wrong lol
it could also be a :macroexpand-hook
doesn't matter, as long as you generate a bunch of declare ...
assuming that carmine uses some kind of macro to define those
yes, it does
hmm i can't seem to make this work
i have a hook file in .clj-kondo/hooks/taoensso/carmine/commands.clj:
(ns hooks.taoensso.carmine.commands
(:require
[clj-kondo.hooks-api :as api]))
(def commands '("foo" ...))
(defn make-declare [token]
(api/list-node [(api/token-node 'declare) (api/token-node token)]))
(defn defcommands
[{:keys [_node]}]
(prn _node)
(let [declares (mapv make-declare commands)
new-node (api/list-node
(list*
(api/token-node 'do)
declares))]
{:node new-node}))
and then in config.edn, i have
{:hooks {:analyze-call {taoensso.carmine.commands/defcommands hooks.taoensso.carmine.commands/defcommands}}}
and then i run
$ clj-kondo --lint src/[REDACTED]/queue.clj --debug
[clj-kondo] Auto-loading config path: imports/rewrite-clj/rewrite-clj
[clj-kondo] Auto-loading config path: imports/taoensso/encore
[clj-kondo] Auto-loading config path: imports/nubank/matcher-combinators
[clj-kondo] Auto-loading config path: imports/babashka/sci
[clj-kondo] Auto-loading config path: imports/babashka/fs
[clj-kondo] Linting file: src/[REDACTED]/queue.clj
linting took 32ms, errors: 0, warnings: 0
hmm jk, it is working? nothing is printed, but the calls aren't flagged as wrong
You should lint carmines source to activate the hook?
ah okay
i still don't get why it doesn't print, but it does seem to work now. thanks for the help
oh, it prints when i lint the dependencies, not when i lint my own code. that makes sense