mount icon indicating copy to clipboard operation
mount copied to clipboard

Please add config for clj-kondo to understand defstate

Open holyjak opened this issue 2 years ago • 5 comments

Hello! Clj-kondo is more and more popular, and e.g. VS Code + Calva use it by default. As is, it will complain about any defstate <name> that the name is an unknown symbol. It is as simple to fix as

;; clj-kondo config.edn
{:lint-as {mount.core/defstate clojure.core/def}}

however it would be much nicer if Mount came with the config so that it can be added to kondo automatically (in the case of Calva) or simply manually with kondo's config import.

It is as simple as providing src/clj-kondo.exports/mount/mount/config.edn with that configuration.

holyjak avatar Dec 24 '22 23:12 holyjak

The emacs-lsp is also giving error like this

rajcspsg avatar Jan 26 '23 22:01 rajcspsg

To help clj-kondo understand defstate in your Clojure code, you can add the following configuration to your deps.edn file:

ruby Copy code {:aliases {:lint {:extra-deps {vlaaad/clj-kondo {:mvn/version "RELEASE"}} :main-opts ["-c" "clj-kondo.config/your-config.edn"]}}} And in your your-config.edn file, you can add the following:

ruby Copy code {:lint-as {:defstate :special-form} :vars {:defstate {:lint-as :dynamic-var}}} This configuration tells clj-kondo to recognize defstate as a special form instead of a regular function, and also to lint it as a dynamic variable instead of a regular variable.

Note that you may need to adjust the configuration to match your specific use case, and that this configuration assumes you are using clj-kondo version RELEASE.

zain83986667 avatar Apr 07 '23 06:04 zain83986667

This last comment appears to be made by a bot.

imrekoszo avatar Apr 28 '23 14:04 imrekoszo

Maybe one of us could raise a PR for this feature? I have no idea how to do that. Will be back when I get more info.

Samy-33 avatar May 30 '23 18:05 Samy-33

+1 I am getting a diagnostic from my LSP that says:

(defstate xt-node
  :start (start-xtdb!)
  :stop (.close xt-node))

Unresolved symbol: xt-node

Sleepful avatar Nov 17 '23 21:11 Sleepful