Fork me on GitHub

who was asking me recently about orchestra/defn-spec? I forgot, but I now have a solution for it on master. possibly also for rum macros (cc @robert-stuttaford)

{:lint-as {foo/my-defn clj-kondo.lint-as/def-catch-call}}

😀 4

Ah, it was probably@duck


no windows build this time?


Fixed. thanks


I'll do the bump later today in scoop


thanks @borkdude - the catch-all is definitely feeling better!


@robert-stuttaford Feel free to provide examples of code in the rum issue. That's what's still missing. Without any repros I can't do much


But if the catch-all is sufficient, that'll do for now


i'll write a short summary of the concern so it's there for future improvements


i did so, @borkdude - super happy to update this comment if better information comes from elsewhere 🙂


Responded in the issue.

Lauri Lehmijoki12:01:49

Hello, I have the following function:

(defn wrap-internal-error [_handler]
  (fn [_req]
     (_handler _req)
     (catch [:type :too-large-pdf] {:keys [request]}
and running clj-kondo gives me the following error: my_file.clj:22:44: error: unresolved symbol request. The try+macro is from slingshot:0.12.2. Any suggestions on how to fix or work around the error?


@lauri.lehmijoki You can ignore unresolved-symbols using a configuration: so something like:

{:linters {:unresolved-symbol {:exclude [(foo/try+)]}}}

Lauri Lehmijoki12:01:39

thank you so much!

Lauri Lehmijoki13:01:02

I have the following expression:

(context "/api" []
                       :header-params [{authorization :- (describe s/Str (str "API key. For demo use: [TOKEN " @api-key "]")) nil}]
and running clj-kondo gives me the following error: my_file.clj:117:41: error: unresolved symbol authorization. The context macro is from Any suggestions on how to fix this one?

Lauri Lehmijoki13:01:39

My .clj-kondo/config.ednis as follows:

{:linters {:unresolved-symbol {:exclude [(compojure.api.core/context)]}}
 :output {:progress true}}


This works for me:

(ns foo
  {:clj-kondo/config '{:linters {:unresolved-symbol {:exclude [(compojure.api.core/context)]}}}}
  (:require [compojure.api.core :refer [context]]))

(context "/api" []
         [{authorization :- (describe s/Str (str "API key. For demo use: [TOKEN " @api-key "]")) nil}])


I mean, no errors in that file

Lauri Lehmijoki13:01:46

Thanks, I realised that my namespace actually required compojure.api.sweet/context instead of compojure.api.core/context. With config.edn being

{:linters {:unresolved-symbol {:exclude [(compojure.api.sweet/context)]}}
                           :output {:progress true}}
I see no clj-kondo errors. Thank you for clj-kondo and fast responses here on Slack!

Filipe Silva13:01:30

@borkdude I'm starting to think that using is better than having a npm package for shadow-cljs projects


if you want to invoke clj-kondo on the JVM, you can just use it as a dependency. if you want to run the binary, then a package manager like npm or scoop may be better

Filipe Silva13:01:01

yeah in the shadow case there is a JVM available

Filipe Silva13:01:31

tbh it wasn't clear (to me) at all how to do it with shadow in the same way it was possible to do it with tools.deps and lein

Filipe Silva13:01:34

hence adding the pr

Filipe Silva14:01:34

does the :exclude-files config entry support wildcards/globs/something to group things by, or does it need each individual file to be listed?


I had to look it up, but it seems each string in that entry is interpreted as a Java regex:


on which re-find is called

Filipe Silva14:01:47

I've been trying to exclude a folder for the last 10 minutes and haven't had much success....


what's the folder name and what did you try?

Filipe Silva14:01:34

I'm running shadow-cljs run clj-kondo.main --lint src/

Filipe Silva14:01:58

I want to exclude everything in src/cljs/devcards/


you probably need to write: "src//cljs//devcards//"

Filipe Silva14:01:23

what's the double slash?


Nope, this should just work:

user=> (re-find (re-pattern "/src/cljs/devcards") "/src/cljs/devcards/foo.cljs")


so only: "/src/cljs/devcards"


but if the paths are reported relatively, you need to omit the starting slash maybe

Filipe Silva14:01:06

I get reports like this

Filipe Silva14:01:07

src\cljs\devcards\d_reactive.cljs:87:16: warning: unused binding *x
src\cljs\devcards\d_reactive.cljs:87:25: error: unresolved symbol conn
src\cljs\devcards\d_reactive.cljs:88:16: warning: unused binding *p
src\cljs\devcards\d_reactive.cljs:90:16: warning: unused binding *titles
src\cljs\devcards\d_reactive.cljs:109:27: error: unresolved symbol _
src\cljs\devcards\d_reactive.cljs:135:24: error: unresolved symbol dispatch
src\cljs\devcards\d_reactive.cljs:141:22: error: unresolved symbol ctx
src\cljs\devcards\keys.cljs:11:23: error: unresolved symbol x
src\cljs\devcards\keys.cljs:25:25: error: unresolved symbol app-state
src\cljs\devcards\keys.cljs:37:23: error: unresolved symbol ctx
src\cljs\devcards\keys.cljs:58:24: error: unresolved symbol id

Filipe Silva14:01:29

maybe it's because I'm on windows

Filipe Silva14:01:34

so the slash never works?

Filipe Silva14:01:17

If I just use :output {:exclude-files ["d_reactive.cljs"]} I can do away with the first file

Filipe Silva14:01:55

but so far I'm unable to exclude the folder...


user=> (re-find (re-pattern "src\\\\cljs\\\\devcards\\\\")  "src\\cljs\\devcards\\keys.cljs")


so the pattern is what goes into re-pattern

Filipe Silva14:01:25

ok I can't do that then, because now the pattern might work locally but it will never work on CI or colleagues machines.... 😕

Filipe Silva14:01:35

is there a way to exclude namespaces?

Filipe Silva14:01:46

those wouldn't have path slash problems


no. I think in this case you just want to pass multiple paths:

--lint src\cljs\your-code src\cljs\your-other-code


the same paths that you have in your production build basically

Filipe Silva14:01:19

ok I'll try that


these are just patterns passed to re-pattern and then applied to the paths with re-find. so there's nothing OS or filesystem specific in there


you can just put more patterns in there to also support Windows


or indeed, use a more flexible regex

Filipe Silva16:01:13

that can be done, but it's one of those "surprising in a bad way" things

Filipe Silva16:01:38

the double escapes were very surprising


not if you know clojure

Filipe Silva16:01:26

I don't think it's a matter of knowing the language, double escapes exist outside of clojure too


but I agree it is annoying. on the other hand, I don't know anyone who uses this feature

Filipe Silva16:01:08

I wouldn't say it's a very important thing, no

Filipe Silva16:01:59

it's just one of those "oh yeah I'm on windows so everything is harder" kind of thing

Filipe Silva16:01:47

tbh most of the windows compat problems in the platforms I've come across are just path separator issues hahah


it took some effort to make the tests work on Windows, mostly due to that

Filipe Silva16:01:21

on another project we tried to put a path abstraction on top of both unix and windows paths and then... we ended up with 3 types of paths to make work 😐

Filipe Silva15:01:56

another question please

Filipe Silva15:01:08

is there any good way of knowing the name of the rule that's failing?

Filipe Silva15:01:17

I'm going through a codebase and need to add some exceptions

Filipe Silva15:01:37

some are straightforward enough to guess like unresolved-symbol


you can figure it out using the EDN or JSON output


or look at clj-kondo/impl/config.clj

Filipe Silva15:01:27

I was looking at that file but some stuff is hard to match

Filipe Silva15:01:39

like use the idiom (seq x) rather than (not (empty? x))

Filipe Silva15:01:39

I was looking for prefer use seq idiom


If you have any ideas about how to make this more accessible, e.g. by relating messages and their key in a table or something, PR welcome 🙂

Filipe Silva15:01:48

I know tslint shows the rule name somewhere


maybe that could also be a configuration option... badum-tss

Filipe Silva15:01:21

but with tslint the usual pattern is to add an exclude comment so it is slightly different

Filipe Silva15:01:33

I don't know if clj-kondo allows exclude comments too


not at the moment. I'm holding back on that a bit, since I don't want to confront users with all kinds of tooling metadata

Filipe Silva15:01:04

I'll open an issue for showing the rule name somewhere for this scenario

Filipe Silva16:01:59

if I have a macro that I can't/know how to make work with :lint-as, is there a good way of just ignoring stuff using it?

Filipe Silva16:01:28

e.g. clojure.core.match

Filipe Silva16:01:52

I can destructure inside of it

Filipe Silva16:01:53

(match [action]
                                            [{:test   t
                                              :action a}] (when (t evt)
                                                            (a evt))
                                            [action]      (do
                                                            (.preventDefault evt)
                                                            (action evt))))

Filipe Silva16:01:07

but will get unresolved symbol t errors


1) There is an issue to add support for core.match. 2) You can ignore unresolved symbols inside a call, see config docs


(This might be unrelated to clj-kondo itself, but I couldn't find a #nix channel or something like that 🙂 - feel free to remove this!) Would it be feasible to make a clj-kondo's nix package that also works on Macs? I got the dreaded clj-kondo/default.nix:45 is not supported on ‘x86_64-darwin’ while trying to add it to a project. Some googling made me realise that my current nix-fu is not even close to sufficient to be able to diagnose/fix this 😬


(@UKFSJSM38 tagging you because I can see you got a PR accepted on that file!)


I don't know for sure if this is the real problem, but its what looks like


Hi, I made the first version of the nix package. The problem is that graalvm doesn't build currently on Darwin (for nixos). I think there is a PR to fix that, once graalvm works on Darwin you should be able to build clj-kondo on Darwin without any modifications


Btw, for nix related questions, there is a relatively active community here:

👏 8

@aisamu It would probably best to talk to the package maintainers

👌 4

Yup, but I'm unsure where nix package maintainers hang out 🙈. I know that at least one of them is here, so I thought it'd be worth a shot. Sorry for the noise!


(and thanks a lot for clj-kondo, btw!)


@aisamu This issue was originally created for the nixOS package: you can ping the author of that issue there as well

👌 4

Ah, that's indeed helpful!

Filipe Silva17:01:11

is it possible to exclude unresolved namespaces?

Filipe Silva17:01:21

adding an exclude to the linter config doesn't seem to do it

Filipe Silva17:01:13

but I'm not having luck adding the ns itself to the unresolved-symbol list

Filipe Silva17:01:45

I can, however, add the macro that uses the unresolved-namespace to the unresolved-symbol exclude list though


which macro is that? can you give an example?

Filipe Silva19:01:50

it's meant to take a namespace


yeah, clj-kondo assumes you forgot a require there, which is in most cases helpful, but maybe in a macro like this isn't. it looks at the exclusions in :unresolved-symbol though, as I suspected most macros that had this problem already needed such a rule there and it would be annoying to repeat rules for the same macro in two places


another option is to just turn off that linting rule, or maybe it works for namespace local config, but I haven't tested that