This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-16
Channels
- # announcements (2)
- # asami (124)
- # babashka (30)
- # babashka-sci-dev (73)
- # beginners (40)
- # biff (1)
- # calva (39)
- # clj-kondo (54)
- # clj-otel (1)
- # cljdoc (59)
- # cljs-dev (8)
- # clojars (2)
- # clojure (96)
- # clojure-austin (16)
- # clojure-boston (6)
- # clojure-europe (51)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojure-russia (60)
- # clojure-uk (4)
- # clojurescript (34)
- # community-development (6)
- # cursive (2)
- # datahike (10)
- # datascript (18)
- # emacs (109)
- # etaoin (1)
- # events (3)
- # figwheel-main (41)
- # fulcro (13)
- # helix (4)
- # introduce-yourself (5)
- # jobs (1)
- # leiningen (5)
- # lsp (8)
- # malli (6)
- # meander (7)
- # nrepl (6)
- # off-topic (60)
- # pathom (29)
- # polylith (8)
- # re-frame (5)
- # reitit (1)
- # releases (1)
- # remote-jobs (1)
- # rewrite-clj (33)
- # sci (3)
- # shadow-cljs (3)
- # xtdb (82)
For
:unused-private-var
{:exclude [user]}}
cljkondo errs with:
Expected fully qualified symbol, got: user {:type :clj-kondo/config}
That is not how it works. It expects fully qualified var names there for which you want to suppress the usage warning.
(ns foo)
(defn- foo [])
(ns bar (:require [foo]))
(foo/foo) ;; warning
:exclude [foo/foo]
Some use cases, the user.clj
namespace, and also the public vars in bb task.clj
files.
If you want to suppress warnings inside of the namespace you can do two things:
(ns foo {:clj-kondo/config '{:linters {:unused-private-var {:level :off}}})
or:
:config-in-ns {user {:linters ...}}

Is it valid for unused-public-var.
? Not working on my side
:config-in-ns
{task.deps {:linters {:clojure-lsp/unused-public-var
{:level :off}}}}
since I already get the number of usages on my screen, I find the "unused" bit a bit redundant
You can see the config for that one here: https://clojure-lsp.io/settings/#custom-clj-kondo-linters
It works for clj-kondo's own linters, but I don't think clojure-lsp looks at that config
Maybe @UKFSJSM38 could fix that
in case of clj-kondo's own linters this is automatic, but for "external" linters they have to implement this themselves
Oh, I think we need to fix on clojure-lsp to check config-in-ns indeed, will create a issue about that
@U04V15CAJ I think we would need to re-write lot of clj-kondo logic already has to check the ns and things like that, do you see any function we could expose on clj-kondo to make that easier for clojure-lsp?
@UKFSJSM38 For unused-public-var you'd only have to merge the config in :config-in-ns
for the namespace the unused public var occurred in
Im trying to use a lib that defines some functions dynamically using macros like
(defmacro log
"Log an event and optional data structure at the supplied severity level
using a logger that implements the Logger protocol."
([logger level event] (log-form logger level event nil &form))
([logger level event data] (log-form logger level event data &form)))
(doseq [level '(report fatal error warn info debug)]
(eval
`(defmacro ~level
~(format "Log an event with %s logging level. See [[log]]." level)
(~'[logger event]
(log-form ~'logger ~(keyword level) ~'event nil ~'&form))
(~'[logger event data]
(log-form ~'logger ~(keyword level) ~'event ~'data ~'&form)))))
and of course clj-kondo is complaining.. is there a way of telling it on the config that these functions actually are defined?given that I know that this will generate fns named [report fatal error warn info debug]
cant I “declare” them somehow on cfg file?
@U3QUAHZJ6 You can even just write
(declare report fata error warn info debug)
in your clojure code and clj-kondo will get it :)you can exclude warnings for all unresolved vars from namespace foo
using:
{:linters {:unresolved-var {:exclude [foo]}}}
or exclude a selection of unresolved vars using qualified symbols:
{:linters {:unresolved-var {:exclude [foo/x]}}}
While that works, I was wondering if it would be possible to create a linter or some config that says "wherever this macro is called, these n symbols will be defined" (provide list of symbols)
Yes, that is possible, using hooks, but those vars aren't created through a macro, but rather a global doseq
Has anyone tried linting with a cljs 1.11.X project? On a .cljs file with latest clj-kondo, I see update-keys
and parse-long
reported as unresolved symbols
@cldwalker if you lint your cljs dependency then (in theory) it should work
Not sure I understand the suggestion. The invocation I'm using is clj-kondo --lint /path/to/cljs/file
. Should I be adding the cljs version as a dep?
I tried the following as an alias but still get same error:
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "2022.04.25"}
org.clojure/clojurescript {:mvn/version "1.11.54"}}
:main-opts ["-m" "clj-kondo.main"]}
What I mean is, you should lint your dependencies with:
clj-kondo --lint $(clojure -Spath) --dependencies --parallel
Ah. I guess my clj-kondo uses have been basic. I see I missed docs in https://github.com/clj-kondo/clj-kondo/blob/master/README.md#project-setup. Thanks for the help!
@cldwalker Could you post an issue as a reminder to update the built-in cljs cache?