Fork me on GitHub

Oh… being the king of typos, I should really try this one out!


This is great, and I’m not saying this just because I was one of the people who requested this. The not-so-great part is that this is one of those “why did I miss this obvious bug” things 😅


@U8SFC8HLP I don't even ask that question anymore! simple_smile Just glad that clj-kondo, my ever-patient review buddy, helps me out. Thanks for requesting this feature.


When I have a line like this

(js/console.log "foo")
I get the following warning
Unresolved var: js/console.log
Is there any way to configure clj-kondo to handle these cases? I'm also curious if this syntax has a name that I would be able to google for.


The js namespace is only provided by ClojureScript. So you need to either use a *.cljs file or use a`*.cljc` file with a cljs reader conditional.

;; if cljc file

(js/console.log "foo")          ;; unresolved

#?(:cljs (js/console.log "foo"))  ;; => "foo"


If I understand you correctly I don't think the js namespace is my problem. I am in a cljs file and the following lints fine

(.log js/console "foo")
I haven't changed my .clj-kondo/config.edn very much except to add a few :list-as rules, so I'm not sure what I might have mis-configured for this to lint properly
(js/console.log "foo")


(.log js/console "foo") and (js/console.log "foo") should both be fine. You'll probably need to provide more info for help.


(js/console.log "foo") is fine with clj-kondo, I do that all the time, but not when you're in a .clj or .cljc file


@U03NXD9TGBD If you can post a repro with your problem (a full complete .cljwhatever file) then I'll be able to take a look. This shouldn't happen in .cljs file


Sorry it took me a while to get back to you! I've been using clj-kondo only from vscode/vim so I wanted to make sure I installed the latest version and ran it directly. TLDR: I deleted .clj-kondo/.cache in my project and it seems to be working now? I don't get a warning for something like

(js/not.a.fn "foo)
but I could see how that might make sense. Is this the desired behaviour? Other symbols do give the warning, such as (foo 'bar) I installed on Ubuntu via the installation script Then I created a file src/test.cljs
(ns test)$ clj-kondo --lint src/test.cljs 
src/test.cljs:3:2: warning: Unresolved var: js/console.log
linting took 9ms, errors: 0, warnings: 1

(js/console.log "foo")
Running the linter produced the warning
$ clj-kondo --lint src/test.cljs 
src/test.cljs:3:2: warning: Unresolved var: js/console.log
linting took 9ms, errors: 0, warnings: 1
However, if I ran the same command outside of my project it did not produce the warning. This led me to believe it was a problem with my project, so I cleared the cache. Sorry I didn't have the foresight to save the cache before I deleted so I guess there is no way to debug now... :face_palm:

Anders Eknert20:09:32

I’m seeing this too, with or without cache

Anders Eknert20:09:36

(ns main
  #?(:cljs (:require [cljs.nodejs :as node])))

(def ^:dynamic *env*
  #?(:clj (System/getenv)
     :cljs (if (= *target* "nodejs")
             (into {} (map #(vector % (aget node/process.env %)) (.keys js/Object node/process.env)))

(defn env-var [name]
  (get *env* name))

(defn -main []
  (println (env-var "USER")))

Anders Eknert20:09:51

clj-kondo --lint main.cljc
main.cljc:7:45: warning: Unresolved var: node/process.env

Anders Eknert20:09:06

code compiles/runs fine though


@U03AU2X8TD5 This is a different issue. In a .cljc file clj-kondo also lints the file as if it's a clj file. And in clj you can't write node/process.env


ah wait, this is in a :cljs branch


Try (.-env node/process)


Btw, in Node you can also just write it like:


👍 1

but this seems like a genuine bug, so issue welcome

Anders Eknert21:09:43

> Try (.-env node/process) yes. that works.. I was just saying that I too have had problems with the construct reported above

Anders Eknert21:09:23

cool, I’ll file one before bedtime then 🙂


Wrote my first hook today! Debugged it via the REPL per the docs. Thank you @borkdude for a great, extensible tool (and great docs!) gratitude

🎉 5
clj-kondo 2

Thanks for sharing, it's always nice to get feedback like this