clj-kondo

sergey.shvets 2024-11-08T05:22:32.445359Z

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.

borkdude 2024-11-08T07:35:30.850269Z

Can you try moving the config to config.edn?

borkdude 2024-11-08T09:55:28.763529Z

Here it does work: Are you sure you are using a recent version?

sergey.shvets 2024-11-08T15:56:36.108419Z

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?

sergey.shvets 2024-11-08T16:28:51.521369Z

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.

borkdude 2024-11-08T16:48:06.195349Z

What is your clj-kondo version

sergey.shvets 2024-11-08T17:00:05.363869Z

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?

borkdude 2024-11-08T17:03:39.273229Z

Try linting on the command line so at least we know what we’re working with

sergey.shvets 2024-11-08T17:12:01.560619Z

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?

borkdude 2024-11-08T17:19:13.989509Z

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

sergey.shvets 2024-11-08T17:25:44.250539Z

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.27

sergey.shvets 2024-11-08T17:26:47.005779Z

If I rename my macro to fn** from state-map it starts to lint properly.

borkdude 2024-11-08T17:28:59.572399Z

Can you make an issue with repro? I’ll have a look

borkdude 2024-11-08T17:29:29.354509Z

On the console you need to first lint the macro again and then the source using it

borkdude 2024-11-08T17:29:56.924559Z

Else clj-kondo will still have the faulty config caused by the old version

sergey.shvets 2024-11-08T17:31:06.682159Z

by lint again you mean to run clj-kondo --lint?

borkdude 2024-11-08T17:33:10.756789Z

You need to lint the source of the macro first

borkdude 2024-11-08T17:33:14.265639Z

Yes

sergey.shvets 2024-11-08T17:33:14.987789Z

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.

borkdude 2024-11-08T17:33:33.830019Z

Inline config makes this more complicated

borkdude 2024-11-08T17:34:03.171629Z

Make a repro on Github then we’ll talk further

sergey.shvets 2024-11-08T18:05:12.122319Z

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!

👍 1
borkdude 2024-11-08T18:12:09.153909Z

No problem, glad it’s solved!

🙏 1