This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-11
Channels
- # announcements (16)
- # aws (17)
- # babashka (25)
- # beginners (60)
- # calva (40)
- # cider (3)
- # clara (4)
- # clj-kondo (24)
- # clojure (16)
- # clojure-austin (3)
- # clojure-dev (23)
- # clojure-europe (33)
- # clojure-nl (2)
- # clojure-norway (7)
- # clojure-uk (4)
- # clojurescript (39)
- # clr (108)
- # conjure (10)
- # cursive (12)
- # datalevin (7)
- # editors (2)
- # events (1)
- # fulcro (24)
- # graalvm (3)
- # introduce-yourself (8)
- # london-clojurians (2)
- # malli (18)
- # meander (6)
- # missionary (10)
- # nbb (16)
- # off-topic (19)
- # polylith (1)
- # portal (4)
- # rdf (1)
- # reitit (4)
- # remote-jobs (3)
- # shadow-cljs (10)
- # xtdb (12)
I wonder if clj-kondo should report (:require [my-namespace :as-alias mns])
as unused if the alias isn't used anywhere - there is no harm in this unused namespace since it doesn't really load the namespace?
The reason I'm bringing this up is because in clerk, the following situation arises:
(:require [nextjournal.clerk.viewer :as-alias v])
'(fn [x] (v/html [:div x]))
The alias isn't really used, but clj-kondo exports analysis about the quoted symbol v/html
along with information about what namespace might be targeted with it, so clojure-lsp can navigate to nextjournal.clerk.viewer/html
when you navigate to that symbol.
The already supported way of doing this is using syntax-quote, but writing functions in syntax-quote isn't always that convenient / nice to read?
But from the perspective of clj-kondo, the alias v
isn't really used since it only occurs in a quote. Hence you will get an unused namespace warning. 🧵> there is no harm in this unused namespace since it doesn't really load the namespace? > Wow. Really? So what happens when/if the quoted expression gets evaluated later? Does the namespace get loaded late as part of that evaluation?
I think the :as-alias
is a syntactic sugar for writing:
(alias 'v (create-ns 'nextjournal.clerk.viewer))
which clj-kondo never warned about, so with that reasoning, it might make sense to not warnI agree it's unused, but This will make clojure-lsp remove that require when cleaning the ns, making that navigation of the symbol probably not work right?
but clojure-lsp still removes the namespace in that case... why, clj-kondo didn't report it?
I'll remove the warning for as-aliased namespace and if desired, I can make an option later to re-enable this
What's the latest thought on reporting about unused aliases using :as-alias
? I use :as-alias
a lot and often have leftover aliases after refactoring that I forget to remove.
Is there a place I should write a feature request?
GH issue?
Please upvote this issue: https://github.com/clj-kondo/clj-kondo/issues/1332
Done, thank you!
Also voted!
What's the latest thought on reporting about unused aliases using :as-alias
? I use :as-alias
a lot and often have leftover aliases after refactoring that I forget to remove.