tolitius / mount

managing Clojure and ClojureScript app state since (reset)
Eclipse Public License 1.0
1.22k stars 88 forks source link

Please add config for clj-kondo to understand defstate #128

Closed holyjak closed 5 months ago

holyjak commented 1 year ago

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.

rajcspsg commented 1 year ago

The emacs-lsp is also giving error like this

zain83986667 commented 1 year ago

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.

imrekoszo commented 1 year ago

This last comment appears to be made by a bot.

Samy-33 commented 1 year ago

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.

Sleepful commented 9 months ago

+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