I have a macro that should be linted as anonymous function (fn [params] body). I tried to add this {:clj-kondo/lint-as 'clojure.core/fn} to macro's attr-map as described here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#inline-macro-configuration, but I'm unable to make it work. The linter still highlights unrecognized symbol in the params vector. Is there a standard linter for fn? Am I configuring it wrong? Any help would be appreciated! Thank you.
Can you try moving the config to config.edn?
Here it does work: Are you sure you are using a recent version?
Hm... interesting. I typed your macro fn** example, and it lints it properly, but mine still returns an error. Can something within the macro itself affect it? Or how it macro expands?
Oh, looks like macro name has something to do with it... I renamed the above macro to state-map** and it started to show error again.
What is your clj-kondo version
I use it through Calva and my assumption that it's part of it's clojure-lsp integration. Is there a way to see the version through repl?
Try linting on the command line so at least we know what we’re working with
Ok, here is the clj-kondo version: "clj-kondo-version": "2024.08.01" calva currently uses. Is this sufficient? Or should I try on the latest one?
Perhaps in that version there was something with the two stars which was a feature slated for 1.12 which later changed. Upgrade Clojure-LSP and it should work
I tried to lint with clj-kondo's latest version using console and it still shows the same error:
sshvets@Sergeys-MacBook-Pro growthtools % clj-kondo --lint "src"
<cut>
src/cljc/sshvets/hull/state_map.cljc:217:29: error: Unresolved symbol: init-count
src/cljc/sshvets/hull/state_map.cljc:217:42: warning: unused binding x
src/cljc/sshvets/hull/state_map.cljc:217:42: error: Unresolved symbol: x
<cut>
linting took 67ms, errors: 2, warnings: 9
sshvets@Sergeys-MacBook-Pro growthtools % clj-kondo --version
clj-kondo v2024.09.27If I rename my macro to fn** from state-map it starts to lint properly.
Can you make an issue with repro? I’ll have a look
On the console you need to first lint the macro again and then the source using it
Else clj-kondo will still have the faulty config caused by the old version
by lint again you mean to run clj-kondo --lint?
You need to lint the source of the macro first
Yes
Oh. The issue is due to the file being cljc. It lints clj version correctly, but if I use a code without #?(:clj) it shows an error.
Inline config makes this more complicated
Make a repro on Github then we’ll talk further
It was my bad. I haven't required macros in ClojureScript. After fixing that issue and reliniting from console it worked. Clearing calva's clj-kondo cache made it work in the editor. Thank you for your time and help!
No problem, glad it’s solved!