This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-17
Channels
- # announcements (3)
- # babashka (3)
- # beginners (53)
- # biff (2)
- # calva (16)
- # cider (1)
- # clj-commons (1)
- # clj-kondo (97)
- # clj-on-windows (137)
- # clojure (49)
- # clojure-europe (63)
- # clojure-gamedev (1)
- # clojure-nl (2)
- # clojure-norway (50)
- # clojure-uk (4)
- # clojurescript (36)
- # core-async (28)
- # datomic (32)
- # emacs (22)
- # events (1)
- # graalvm (8)
- # honeysql (6)
- # jobs (2)
- # lambdaisland (5)
- # malli (6)
- # nbb (31)
- # off-topic (171)
- # pathom (14)
- # rdf (2)
- # reitit (4)
- # releases (2)
- # scittle (19)
- # shadow-cljs (46)
- # sql (6)
- # squint (6)
is there a place, which collects recommended :lint-as
definitions for popular clojure libraries?
i saw that page, but on 1st skimming i missed the link to https://github.com/clj-kondo/config btw, this is the config i needed:
❯ cat ~/.config/clj-kondo/config.edn
{:lint-as {;
clojure.test.check.properties/for-all clojure.core/let
clojure.test.check.clojure-test/defspec clojure.core/def #_clj-kondo.lint-as/def-catch-all}}
so i guess this config should go into clj-kondo/config
for reusability.Yes. I won't get my hopes up to get this config into a core library so maybe it's best to create another library with just that config which you can then add to your deps. I've been considering this for a while
Everytime i use org.httpkit client in calva i get “Unresolved var” for each function. Any idea on what i’m doing wrong?
org.httpkit.client/get
[url & [opts callback]]
[url & [callback]]
Issues an async HTTP GET request. See request for details.
Unresolved var: c/getclj-kondo(unresolved-var)
@U06GMV0B0 The issue is that these vars have been created via a custom macro.
https://github.com/http-kit/http-kit/blob/cf1365167c5a2447f66ea2c0f4541a81114d2f74/src/org/httpkit/client.clj#L308
you can solve this by adding {:lint-as {org.httpkit.client/defreq clojure.core/def}}
to your config and the restart your workspace
Would a :consistently-aliased
flag for the :consistent-alias
linter be helpful? Setting it to true would show warnings on usages of a fully qualified namespace symbol (and keyword, ideally) when that same ns has a :consistent-alias
configuration.
I'm trying to fix an Unresolved var
warning in clojure-lsp that comes from clj-kondo.
I'm generating a project from the re-frame-template using this:
clojure -Tclj-new create :template re-frame :name sample/playground :output sample-playground :args '[+kondo +garden +routes "+10x"]'
The generated file styles.cljs
has lots of clj-kondo errors/warnings by default, most of them that I managed to fix in this PR: https://github.com/day8/re-frame-template/pull/174
I'm trying to solve the last one, an Unresolved var: deg
which is referred from garden.units namespace. I tried adding garden.units/defunit clojure.core/def
to :lint-as
of .clj-kondo/config.edn
, seeing deg
is defined as (defunit deg)
, without much success. Any ideas?I'm kind of now transitioning into the clojure ecosystem, could you explain what do you mean by re-linting?
It might also be a good idea to submit those configurations to the libraries themselves rather than just the templates. https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration See here for examples: https://github.com/clj-kondo/clj-kondo/discussions/1528
So on the command line for example:
clj-kondo --lint $(clojure -Spath) --dependencies
and then the garden namespace is seen again by clj-kondo, but this time with your new lint-as configuration
What also might help is blow the clj-kondo and lsp cache:
rm -rf .lsp/.cache
rm -rf .clj-kondo/.cache
I tried rm -rf .lsp .clj-kondo/* (except config.edn), running the clj-kondo command above, and again opening my editor
Generate a sample re-frame project using:
clojure -Tclj-new create :template re-frame :name sample.playground :output sample-playground :args '[+kondo +garden +routes "+10x"]'
and then just replace the .clj-kondo/config.edn
with the patched one from my PR:
{:lint-as {day8.re-frame.tracing/defn-traced clojure.core/defn
day8.re-frame.tracing/fn-traced clojure.core/fn
garden.def/defcssfn clojure.core/defn
garden.def/defkeyframes clojure.core/def
garden.def/defrule clojure.core/def
garden.def/defstyles clojure.core/def
garden.def/defstylesheet clojure.core/def
spade.core/defglobal clojure.core/def
spade.core/defclass clojure.core/def}
:linters {:unresolved-symbol {:exclude [goog.DEBUG]}
:unused-namespace {:exclude [cljs.repl]}
:unused-referred-var {:exclude {cljs.repl [Error->map
apropos
dir
doc
error->str
ex-str
ex-triage
find-doc
print-doc
pst
source]}}}}
Then just cd into sample-playground, open your editor to styles.cljs and see!So if I go into the garden unit project itself and configure it, it does work correctly
So when I add these deps:
$ cat deps.edn
{:deps {garden/garden {:mvn/version "1.3.10"}
garden/garden-units {:mvn/version "1.0.0-RC2"}}}
So this must be a problem with #CPABC1H61 and perhaps the shadow-cljs.edn deps / cc @UKFSJSM38
I don't see the garden-units library appear when doing this:
npx shadow-cljs classpath
rm -rf .clj-kondo/.cache
clj-kondo --lint $(npx shadow-cljs classpath) --dependencies
clj-kondo --lint src/clj_kondo/poc/styles.cljs
src/clj_kondo/poc/styles.cljs:6:6: warning: Unsorted namespace: garden.units
and now I also get no warning when deleting the caches again and restarting the project
@U03PYN9FG77 Could it be that you just need to run npm install
in this project first?
@U04V15CAJ what is the repro exactly on that repo?
I can repro the warning. The project doesn't have any deps.edn right? so the only classpath option is from npx
and npx shadow-cljs classpath
returns "~/.m2/repository/garden/garden/1.3.10/garden-1.3.10.jar
, is the hook inside that version?
I tried fresh clone
-> npm i
-> clj-kondo --lint $(npx shadow-cljs classpath) --dependencies
, opening my editor in styles.cljs
and I can still repro it
I did the same without calling clj-kondo, just opening with clojure-lsp, which should end in the same
The fact that npx shadow-cljs classpath
isn't showing this units library is weird right?
garden itself doesn't seem to depend on that https://github.com/noprompt/garden/blob/master/project.clj
I only see garden
on shadow-cljs.edn, shouldn't you include garden/garden-units
as well?
Its a namespace within garden? https://github.com/noprompt/garden/blob/master/src/garden/units.cljc
AFAICS that happens because npx
classpath doesn't include garden/garden-units
which has the hook, only garden/garden
yeah, my bad, @U04V15CAJ is correct, adding that config is enough to solve since the problem is the defunit
not being recognized as a macro that defines a var
@U04V15CAJ any good tip to make defglobal
Unused public var disappear too?
unused public var is @UKFSJSM38’s department ;)