ah good point, I would was thinking more of used but undefined
like a (s/keys :req-un [::where])
that does not have corresponding (s/def ::where map?)
Hey there, trying to read the docs on unresolved-symbol but the link seems to be dead. https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#unrecognized-macros
Is there an updated page with that info?
Can make a PR to fix it
@jayzawrotny The link should probably go here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md
Thanks, will create a pr for that momentarily. So if I am understanding it right in my ~/.clj-kondo/config.edn I can put the following?
{ :linters {:unresolved-symbol {my-app.utils/current-file [ns-resolve]}}}
Oops I see my mistake, forgot the exclude part
Thanks for the upcoming PR! Yes, that's right
:linters
{:unused-import
{:exclude [(my-app.utils [dbg!])]}}
Is there something similar for unused-import? Got a cljs file importing a cljc macro.unused-import is for classes
My apologies
I see the unused-referred-var now, that makes sense sorry about that!
Can you provide an example? It's unlikely that you will need a config for a referred thing that you actually are using
No worries
(ns my-app.utils
(:require-macros
[my-app.utils :refer [dbg!]])
(:require
[cljs.analyzer]))
Is this .cljs
file?
Correct
Ah you want the dgb!
macro available, yes this makes a lot of sense for the config. I do something similar with timbre
Cool, looks like the example is for that too
I seem to be running into trouble with the unresolved-symbol exclusion though:
@jayzawrotny If that is a .cljc
file then you should use reader conditionals
e.g. *file*
is not a thing in CLJS
{:lint-as {kitchen-async.promise/-> clojure.core/->
kitchen-async.promise/let clojure.core/let}
:skip-comments true
:linters
{:unresolved-symbol {:exclude [(my-app.utils/current-file [ns-resolve])
(my-app.utils/dbg! [*file*])]}
:unused-referred-var {:exclude {my-app.utils [dbg!]}}}}
I recall having trouble with that using reader conditionals but I’ll try again
why have it as a .cljc
file at all if it only contains clojure code?
My understanding was that macros have to be in cljc to be used within cljs?
Though I suppose for this branch I can remove the conditional
no that's not the case, you can put your macros in .clj
Well it’s intended to work in both clj and cljs
The current-file function runs in cljs
yes, but macros are always executed in clojure
Ok, I can change it to clj then.
Your current-file
function runs during macro-expansion in the JVM
(unless you use self-hosted clojurescript, but even then you can use .clj
for macros)
Clj-kondo assumes code in .cljc
files to be valid for both Clojure and ClojureScript outside conditionals. E.g. future
is unresolved for ClojureScript, hence you write #?(:clj (future :foo) :cljs :foo)
https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#gotcha-4-clj-macros
The key point: > First of all - ClojureScript macros are written in Clojure and run during the ClojureScript compilation on the JVM.
He is not suggesting you need .cljc
, he only writes that you cannot use reader conditionals to achieve a certain goal
Oh!
I think that’s where I got stuck. Thanks very much!
Lints clean now too 🎉
btw do you have a sponsorship thing setup for one-off payments? I kind of have an unwritten rule where if I am wasting maintainers time and it turns out to be on me for not understanding or reading the docs: I donate.
haha, don't worry
I insist! At least a cup of coffee or a beer. Venmo? Paypal?
If you want to buy me a cup of coffee: https://ko-fi.com/borkdude
Thanks a lot. I'll be thinking of your beautiful CGI scripts during my coffee tomorrow ;)
Excellent!