This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-24
Channels
- # announcements (2)
- # aws (2)
- # babashka (1)
- # beginners (87)
- # boot (1)
- # calva (42)
- # clj-kondo (18)
- # cljdoc (5)
- # cljsjs (1)
- # cljsrn (1)
- # clojars (16)
- # clojure (222)
- # clojure-dev (30)
- # clojure-europe (17)
- # clojure-gamedev (2)
- # clojure-hungary (10)
- # clojure-italy (6)
- # clojure-nl (21)
- # clojure-spec (9)
- # clojure-uk (111)
- # clojuredesign-podcast (1)
- # clojurescript (99)
- # code-reviews (1)
- # conjure (18)
- # cursive (11)
- # datomic (22)
- # emacs (1)
- # events (3)
- # figwheel-main (3)
- # fulcro (14)
- # graalvm (41)
- # graphql (16)
- # helix (12)
- # juxt (1)
- # kaocha (56)
- # keechma (1)
- # meander (77)
- # observability (1)
- # off-topic (29)
- # pathom (3)
- # re-frame (4)
- # reagent (3)
- # reitit (1)
- # remote-jobs (3)
- # reveal (9)
- # shadow-cljs (45)
- # spacemacs (43)
- # sql (28)
- # tools-deps (14)
- # vim (1)
- # xtdb (26)
- # yada (1)
hi folks, just wanted to check something before submitting a bug. I'm using clj-kondo plugin version v2020.6.21 with visual studio code on MacOS Catalina. Whenever I :require
a namespace within my project without providing an alias (`:as`) the first occurrence of a loaded var in the current namespace will result in a "unresolved symbol" error. The subsequent occurrences of the same var won't show the error. Similarly, if the var indeed does not exist, only the first occurrence shows the error and not the subsequent ones. Below is a screenshot of the issue. In this case the some-fn-define-in-bar
is defined in the namespace bar
.
@jplfdsilva Kondo only reports the first use of an undeclared var. It doesn't "see" any vars when you use :refer :all
, I believe. You either need to use an alias or explicitly :refer
the vars by name -- using :refer :all
is poor practice.
You'll see there's a warning on :all
which will tell you not to do that 🙂
So, not a bug: expected behavior.
If it's any consolation, we use :refer :all
in a lot of our test files and I'm slowly changing that so clj-kondo
is happy 🙂
my use case is unit testing where I thought it would make sense to :`refer :all` vars
(we have 278 occurrences in 266 files -- and only two of those are not test files -- so it'll take us a while to "fix" them all)
I've started doing :as sut
for the "system under test" and that's actually quite nice because then I can easily tell what's being tested vs what is just a supporting function: everything being tested is sut/some-function
.
For test files that are short and only refer to a couple of functions from the test namespace, I :refer
them by name. And I also :refer
by name the vars from clojure.test
and expectations.clojure.test
.
@jplfdsilva clj-kondo can resolve the :refer :all
-ed vars, but then you need to lint that namespace first.