This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-10
Channels
- # babashka (17)
- # beginners (57)
- # calva (19)
- # cider (1)
- # clj-kondo (21)
- # clojure (36)
- # clojure-austin (15)
- # clojure-australia (1)
- # clojure-china (1)
- # clojure-europe (35)
- # clojure-filipino (1)
- # clojure-hk (1)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (2)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-sg (1)
- # clojure-spec (6)
- # clojure-taiwan (1)
- # clojure-uk (3)
- # clojurescript (7)
- # clr (9)
- # community-development (5)
- # cursive (14)
- # datalevin (1)
- # emacs (5)
- # events (5)
- # exercism (2)
- # figwheel-main (2)
- # fulcro (6)
- # funcool (3)
- # introduce-yourself (2)
- # joyride (7)
- # leiningen (4)
- # london-clojurians (9)
- # malli (3)
- # membrane (1)
- # missionary (54)
- # music (1)
- # nbb (2)
- # pathom (5)
- # pedestal (55)
- # rdf (13)
- # re-frame (10)
- # reitit (3)
- # shadow-cljs (17)
- # vim (58)
- # web-security (12)
Hello! What is the recommended way of dealing with libs that generate their fns from some data / other ns, such as https://github.com/expez/superstring/blob/master/src/superstring/core.clj#L35-L36 ?
It seems that defalias
is similar to def
so you can use:
{:lint-as {foobar/defalias clojure.core/def}}
it seems that (alias-ns clojure.string)
is the same as (:require [clojure.string :refer :all])
- why invent a new syntax for this
ah yeah, I see, they are creating vars in their namespace to re-export clojure.string
there's not much that you can do about this in clj-kondo, except that you can :exclude some vars in the unresolved var linter
Thank you!
I though that perhaps there was a way to tell Kondo that superstring.core/join etc. exists and is the same as clojure.core/string etc. Ok, we will just exclude this lint check for the ns then.
one way is to have an explicit declare
for all the things being generated, Fulcro uses this approach for the DOM namespace: https://github.com/fulcrologic/fulcro/blob/main/src/main/com/fulcrologic/fulcro/dom.cljs#L17-L30
another way to "fix" this is to use clj-easy/stub https://github.com/clj-easy/stub which can generate stub namespaces with vars detected at runtime. Then you need to add this to your "lint" path so clj-kondo will pick up on those stubs
what I like about declare
is that it will work with any tool (like LSP, but also Cursive)
yup, others have been, like on the CSK library: https://github.com/clj-commons/camel-snake-kebab/pull/54/files
awesome, thanks! I will talk to the maintainer
FYI superstring has a new release with the declare
s. Thanks for the tip!