Fork me on GitHub
#clj-kondo
<
2020-03-26
>
seancorfield19:03:40

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?

borkdude19:03:29

@seancorfield if the namespaces aren't conflicting among those subrepos, you can just put the .clj-kondo one level higher

borkdude19:03:19

if they are conflicting, just create a .clj-kondo in each of them

seancorfield19:03:12

All unique. Could it go in the top-level of the repo? I'll have to see where my .joker file was.

borkdude19:03:36

yeah, it can go into the top-level. clj-kondo just walks up from your current working dir until it finds one

4
seancorfield19:03:14

Woohoo! Atom / linter-kondo is working! That was a nice, easy switch from Joker!

👍 4
💯 4
clj-kondo 4
borkdude19:03:16

@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

borkdude19:03:33

the second one looks similar to something that joker has

seancorfield19:03:32

Good to know. I had quite a few macros declared in my .joker file.

borkdude19:03:43

the first option is preferred, since you'll still get proper linting, the second option just exists to reduce false positives

seancorfield19:03:55

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).

💯 4
borkdude19:03:26

@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

seancorfield19:03:41

Yeah, I'll have to start working through all the errors/warnings coming from 3rd party libraries that we use...

seancorfield19:03:33

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.

💯 4
seancorfield19:03:07

I saw there are two linters that are disabled by default -- those are going to get switched on (I hate non-alphabetical :require clauses! 🙂 )

seancorfield19:03:57

:unsorted-required-namespaces {:level :error} 🙂

seancorfield19:03:58

It flags this as missing a docstring: (defonce sys nil) -- but defonce can't take a docstring, right?

dominicm19:03:15

Doc meta works

dominicm19:03:31

It just doesn't have a positional argument for it

borkdude20:03:06

@seancorfield that's probably a false positive. I've been fixing some of those recently also for deftest, etc

borkdude20:03:13

feel free to post an issue for defonce, it will be fixed in the next release (or you can do so if you wish)

borkdude20:03:16

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

borkdude20:03:32

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

seancorfield20:03:29

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.

dominicm20:03:01

I'm not sure if that's really a bug or not. Defonce is as much part of your public api as def

borkdude20:03:31

yeah, so maybe it's fine as it is

seancorfield21:03:37

It already found a couple of out-of-order :require's in my own code. I feel ashamed.

seancorfield21:03:10

(I expect to find them in other people's code but my OCD normally prevents them in my own...)