This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-26
Channels
- # announcements (1)
- # autochrome-github (1)
- # babashka (9)
- # beginners (112)
- # bristol-clojurians (2)
- # calva (26)
- # cider (10)
- # clj-kondo (31)
- # cljs-dev (40)
- # clojure (114)
- # clojure-austin (1)
- # clojure-dev (112)
- # clojure-europe (22)
- # clojure-germany (5)
- # clojure-italy (1)
- # clojure-nl (2)
- # clojure-norway (1)
- # clojure-spec (10)
- # clojure-uk (96)
- # clojurescript (39)
- # core-logic (5)
- # datomic (40)
- # fulcro (34)
- # graphql (17)
- # jobs (3)
- # kaocha (4)
- # leiningen (10)
- # luminus (1)
- # malli (3)
- # meander (44)
- # midje (2)
- # off-topic (40)
- # pathom (5)
- # re-frame (8)
- # reitit (8)
- # ring (3)
- # ring-swagger (4)
- # shadow-cljs (83)
- # spacemacs (96)
- # tools-deps (16)
- # vim (4)
- # xtdb (15)
- # yada (20)
clj-kondo
newbie. Just getting it set up. We have a git monorepo where there's a build
folder and a clojure
folder, and inside the latter are about thirty subprojects, each with their own deps.edn
. Where should I put the .clj-kondo
folder?
@seancorfield if the namespaces aren't conflicting among those subrepos, you can just put the .clj-kondo one level higher
All unique. Could it go in the top-level of the repo? I'll have to see where my .joker
file was.
yeah, it can go into the top-level. clj-kondo just walks up from your current working dir until it finds one
Woohoo! Atom / linter-kondo
is working! That was a nice, easy switch from Joker!
@seancorfield as a heads up, if you're encountering macros that are not recognized by clj-kondo, you can do mostly two things:
1) lint them as existing supported macros - https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#lint-a-custom-macro-like-a-built-in-macro
2) configure the :unresolved-symbol
linter to ignore all errors inside the macro call - https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#exclude-unresolved-symbols-from-being-reported
Good to know. I had quite a few macros declared in my .joker
file.
the first option is preferred, since you'll still get proper linting, the second option just exists to reduce false positives
Just run it on the entire classpath -- wow! And it only took 30 seconds, producing about 1,000 errors and 2,000 warnings. Guess I'll be curating some .clj-kondo/config.edn
files for a while (and adding those to some of my libraries too it seems).
@seancorfield if you run it on your classpath, the arity information from your libraries is saved to your .clj-kondo directory as well, so you will get arity errors for those inside your editor as well
Yeah, I'll have to start working through all the errors/warnings coming from 3rd party libraries that we use...
@seancorfield you can ignore those in reporting while still benefiting from analyzing them. https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#include-and-exclude-files-from-the-output
I tend to have a fairly zero-tolerance approach to lint warnings so I'll probably work to fix everything I can over the next few weeks, adding macro configs as needed too.
I saw there are two linters that are disabled by default -- those are going to get switched on (I hate non-alphabetical :require
clauses! 🙂 )
:unsorted-required-namespaces {:level :error}
🙂
It flags this as missing a docstring: (defonce sys nil)
-- but defonce
can't take a docstring, right?
@seancorfield that's probably a false positive. I've been fixing some of those recently also for deftest, etc
this was the fixing commit: https://github.com/borkdude/clj-kondo/commit/4d12b70ab7c562023224a4e94f40f3050dc47cca
feel free to post an issue for defonce, it will be fixed in the next release (or you can do so if you wish)
this suffices as a repro:
$ clj-kondo --lint - --config '{:linters {:missing-docstring {:level :warning}}}' <<< '(defonce x 1)'
<stdin>:1:1: warning: Missing docstring.
linting took 8ms, errors: 0, warnings: 1
hmm, like @dominicm says, you could do this:
$ clj-kondo --lint - --config '{:linters {:missing-docstring {:level :warning}}}' <<< '(defonce ^{:doc "foo"} x 1) '
linting took 9ms, errors: 0, warnings: 0
Yeah, I just added ^{:doc "..."}
to it. I wasn't sure that would work. I've seen defonce
followed by an alter-meta
call to add docstrings (ugh!) so literal metadata is better.
I'm not sure if that's really a bug or not. Defonce is as much part of your public api as def
It already found a couple of out-of-order :require
's in my own code. I feel ashamed.
(I expect to find them in other people's code but my OCD normally prevents them in my own...)