This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-11
Channels
- # adventofcode (42)
- # asami (13)
- # babashka (40)
- # beginners (25)
- # calva (39)
- # cider (18)
- # circleci (6)
- # cljs-dev (3)
- # clojure (39)
- # clojure-europe (16)
- # clojure-norway (9)
- # clojure-uk (2)
- # clojurescript (42)
- # datalevin (4)
- # datomic (23)
- # fulcro (33)
- # jobs (1)
- # malli (26)
- # minecraft (1)
- # off-topic (88)
- # pedestal (3)
- # polylith (8)
- # re-frame (6)
- # remote-jobs (2)
- # shadow-cljs (20)
- # tools-deps (12)
- # xtdb (5)
Is there a way with clj-refactor
to prevent the clean-ns
function from running when moving a form to another namespace? Or more concretely is there way to prevent it from deleting unused exports in a namespace? I am using potemkin/import-vars
in one ns, so the unused requires aren't really unused.
we have a trick for this at work. in the require you have [some-ns :as alias]
and in the code do (comment alias/keep-me)
@diego.vid.eco I recommend removing it from the ns
form and using (require ...)
right below it.
ns
is only sugar over require
/`load` so there's no difference. There's a good chance other tools will also understand this pattern (clj-kondo does!)
thanks @vemv!
clj-kondo (and clojure-lsp) won't warn/touch unused requires when they have 1) no alias and 2) no refers
if they don't have 1 and 2 then it is assumed the namespace was required for side effects
yeah that's a difference relative to refactor-nrepl, which doesn't infer things from ns
libspecs
In a way I like require
, it seems very explicit/unmistakable
not really. in the REPL yes, but in a file, perhaps only the first top level require, but not all over the place. don't also quote me on that
The top level requires might make some reloading code not function correctly. Both tools namespace and possibly require :reload-all
honestly I consider it a flaw that it doesn't try analyzing the whole source other than the ns
form
code in the wild not only can have top-level requires, but also conditional ones, which warrant a more advanced parsing
Btw, an idiomatic solution for clj-refactor is setting https://github.com/clojure-emacs/clj-refactor.el/blob/363b95c5d2855abc93ac011e9adc778cf7a773e5/clj-refactor.el#L265-L273 in your dir-locals