This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-18
Channels
- # aleph (1)
- # announcements (31)
- # babashka (9)
- # babashka-sci-dev (36)
- # beginners (72)
- # calva (20)
- # clj-kondo (99)
- # cljsrn (1)
- # clojure (77)
- # clojure-europe (33)
- # clojure-nl (4)
- # clojure-norway (12)
- # clojure-uk (4)
- # clojurescript (23)
- # cursive (2)
- # datascript (5)
- # events (1)
- # fulcro (3)
- # honeysql (3)
- # inf-clojure (82)
- # interop (2)
- # kaocha (10)
- # lsp (15)
- # meander (1)
- # missionary (10)
- # off-topic (22)
- # pathom (4)
- # pedestal (3)
- # polylith (20)
- # re-frame (10)
- # react (4)
- # reagent (4)
- # reitit (27)
- # ring-swagger (1)
- # shadow-cljs (34)
- # specter (3)
- # sql (1)
- # testing (5)
- # tools-deps (22)
- # vim (12)
it seems that I would like to push the clj-kondo config.edn into git, but nothing else, could the config be in the top-level folder? currently doing this in .gitignore
:
.clj-kondo/*
!.clj-kondo/config.edn
@ikitommi both lsp and clj-kondo have the convention that you can just put
.cache
in your .gitignore
so it will work for both projects… but, under clj-kondo, there are the folders per package too? e.g. babashka
, com.gfredericks
, …
if you are using those configs, you can check them into source control, else you can ignore / delete them
I think it’s good to have them, just not in the version control as they get created automatically and don’t need versioning.
if the config.edn
is the only relevant file, this should be ok:
.clj-kondo/*
!.clj-kondo/config.edn
… but maybe if the configurations were imported under one folder, it would be easy to exclude, maybe even under .cache
?
> I think it’s good to have them, just not in the version control as they get created automatically and don’t need versioning. This isn't true. They are only copied from the dependencies because lsp does this. If you want to have the same linting in CI, it's good to version those things into version control.
The recommended way is to include them into version control, so everyone who uses clj-kondo with this repo gets exactly the same linting, whether you use lsp or not
is it normal for clj-kondo
to warn about the new clojure.core/parse-?
functions even when using org.clojure/clojure 1.10.3
?
[lassemaatta@archlinux] 10:58 $ echo '(def parse-long 1)' | clj-kondo --lang clj --lint -
<stdin>:1:1: warning: parse-long already refers to #'clojure.core/parse-long
linting took 7ms, errors: 0, warnings: 1
clj-kondo v2022.03.09
I'm creating the local cache with the typical --dependencies --parallel --copy-configs
the clojure.core.transit.json
within the cache does not (obviously) mention the new parse-
functions
if you lint dependencies using clj-kondo --lint $(clojure -Spath)
this should reset to the clojure version you are using locally
you can add :refer-clojure :exclude [parse-long]
in your namespace to prevent the warning, makes it future-proof anyway
hmm.. if I do something like clj-kondo --lint $(clojure -Spath) --lint some-path-in-project
I still get warnings about parse-long
, parse-double
. Even if I clear the cache. Of course, it's a good idea to deal with those functions, as you said, but I'm curious why do we get these warnings.
and to be clear, clojure -Spath
returns src:/home/lassemaatta/.m2/repository/org/clojure/clojure/1.10.3/clojure-.10.3.jar:/home/lassemaatta/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-.2.56.jar:/home/lassemaatta/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar
yes 🙂
and as I mentioned previously, I looked into the cache and at the clojure.core.transit.json
file and found no references to the parse-
-functions within
no problem, I'll see if I can build a repro 🙂
https://github.com/clj-kondo/clj-kondo/issues/1619 with a link to a simple repro project
Ah I see yeah. This is probably a won't fix as there is a list of clojure vars built-in independent of version and it's already bumped to 1.11. Just future-proof your repo using :exclude
ah, ok 👍
got a bit of a headscratcher, where although i am specifying an exclude for unused-namespace, it's not being applied.
pictured: the file that's being linted, and the output from kondo, with just that linter's config displayed. you can clearly see the namespace, the file path, the error, and the exclude pattern.
both the dep and the cli are on 2022.03.09
. what should i do next to diagnose?
i've already read all the relevant kondo source and i don't have a hypo for why this may be; it all looks correct!
https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/impl/config.clj#L197-L208 https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/impl/linters.clj#L443
i definitely have!
That acts as if the comment doesn't exist. There is now something far better:
{:config-in-comment {...}}
Just use that instead and disable any linters you don't want to activate in comments
{:config-in-comment {:linters {:unresolved-namespace {:level :off}}}}
yes this is so much better!
hm. with that in, i'm still getting the warnings. surely the presence of a comment form is irrelevant here? i wish to control the linting of the top-level ns form
hehe :)\
{:linters {:unused-namespace {:exclude ["^dev.*$"]}}
:skip-comments true}
other than this, we have a bunch of lint-as and a bunch of hooks
ohhh man
so the exclude is about the requires themselves, not the ns in which the unused require is?
hi i'm robert and i am a professional haha
ok so there's no way to do what i thought it did, right
i'd basically have to add a rule to each ns in dev/* separately
cos its full of scripts we use via remote repl, with all the meat in comment forms
so we specifically don't care about unused requires in just this source folder
ok, thanks man, i appreciate your time on this, very helpful
i'll add one for the idea of being able to prevent a rule running within (rather than about) a pattern of namespaces
it's really just the generalisation of :namespaces here
yeah, thanks. clj-kondo already generalized :config-in-comment
as :config-in-call {clojure.core/comment ...}
happy with the language? https://github.com/clj-kondo/clj-kondo/issues/1618
Note that for CI purposes you could lint your sources in multiple steps with different configs
yeah. what we're trying to do right now is get one config in use in hooks and in CI, and with zero known issues. then we'll try to work to keep issues to zero. so, it's important that our editors, our pre-commits, and our CI all agree on what an error / warning is
the other thing is we want our entire classpath to remain compilable so that e.g. lsp or clj-refactor doesn't break when using find-usages or similar
once the issue above is resolved, our 161kloc Clojure codebase will be at zero warnings, zero errors 😄
Hi folks. Consider the function below:
(defn path
[url]
(keyword (re-find (re-matcher #"(?<=\{\{services\.).*?(?=\}\})" url))))
example of usage:
(re-find (re-matcher #"(?<=\{\{services\.).*?(?=\}\})" "{{services.blueprint}}/api/v2/services"))
;; blueprint
Because of keyword
, I’m getting this error:
clj-kondo: Expected: symbol or string or keyword, received: seq.
Is this expected?That seems like a bug. I will create an issue. Workaround:
(defn path
[url]
(keyword #_:clj-kondo/ignore (re-find (re-matcher #"(?<=\{\{services\.).*?(?=\}\})" url))))
I guess clj-kondo assumed the return value would be something like:
user=> (re-find (re-matcher #"foo" "foo"))
"foo"
user=> (re-find (re-matcher #"(foo)" "foo"))
["foo" "foo"]
Is there clj-kondo linter config/code that can help mark places where form 2 components aren't properly passing there arguments on. eg
(defn outer
[a b c] ;; <--- parameters
;; ....
(fn [a b c] ;; <--- forgetting to repeat them, is a rookie mistake
[:div
(str a b c)]))
correct
yea. thats what i was worried about. errr.