Closed danskarda closed 1 year ago
Is it bug in clj-kondo?
No, this is intentional.
Thanks for the report. I consider this a duplicate of https://github.com/clj-kondo/clj-kondo/issues/1196 Please upvote the issue there.
Thank you for fast response.
I have not seen #1196. To include source platform(s) in (any) reported cljc issue is better and covers more scenarios. I should have think about that :)
Is your feature request related to a problem? Please describe. Some functions are defined only in clojure.core or cljs.core. For example
clojure.core/requiring-resolve
orcljs.core/clj->js
.clj-kondo correctly reports
unresolved symbol: requiring-resolve
in CLJC file because it is undefined for ClojurScript.However this warning was very puzzling to me, because I forgot I am in CLJC file. CIDER was able to auto-complete the symbol, showed me its definition and arity in status line and I was able to jump to its definition. So was it defined or not? One tool says yes, another tool says no. Is it bug in clj-kondo? :thinking:
I tried to find the root-cause and searched clj-kondo source files. Then I tried to replicate the issue with minimal source file. Suddenly requiring-resolve was defined. Huh? Only then I realized my file was .cljC so even though NOW I use Clojure REPL and symbol IS defined, it is really NOT defined in ClojureScript context.
Describe the solution you'd like When resolving symbols in CLJC files, check if they are defined at least for one dialect in its core library. For example if you use
cljs.core/clj->js
warn:unresolved symbol: clj->js is defined in cljs.core, not in clojure.core
This can safe some confusion and head-scratching :)
Describe alternatives you've considered Solution might get tricky as .CLJC files could be used for other Clojure dialects like ClojureDart, babashka or ClojErl with different set of build-in functions and macros in clojure.core.