clj-kondo

https://github.com/clj-kondo/clj-kondo
ezmiller77 2021-03-13T17:42:07.301800Z

Wondering if anyone could give me an example of namespace local config for clj-kondo. I've tried:

(ns <http://some.name.space|some.name.space>
  ^{:clj-kondo/config '{:linters {:unresolved-symbol {:level :off}}}}
  (:require ...))

ezmiller77 2021-03-13T17:43:02.302400Z

But I haven't been able to get it to work, and I've not been able to find an example of the syntax in the docs.

borkdude 2021-03-13T17:43:10.302600Z

@ezmiller77 That's almost correct, you have to remove the ^

ezmiller77 2021-03-13T17:43:17.302800Z

Ahhh

borkdude 2021-03-13T17:43:42.303200Z

You can use the ^ but then your config needs to go before the namespace name

borkdude 2021-03-13T17:43:49.303400Z

This is namespace metadata

borkdude 2021-03-13T17:44:04.304Z

And the ns form has special syntax for this: if you put the map after the name it will also work

ezmiller77 2021-03-13T17:44:06.304100Z

🎇 That did it!

ezmiller77 2021-03-13T17:44:42.304400Z

Thank you. I think this is my first time adding metadata to the ns form.

ezmiller77 2021-03-13T17:44:57.304700Z

And thank you for the VERY fast response!

ezmiller77 2021-03-13T18:25:04.305100Z

Is there a way to avoid an error exit code for warnings?

ezmiller77 2021-03-13T18:25:11.305300Z

Or is this not encouraged?

borkdude 2021-03-13T18:51:16.305800Z

@ezmiller77 This is the contract with regards to exit codes: https://github.com/clj-kondo/clj-kondo#exit-codes

ezmiller77 2021-03-13T23:40:11.306700Z

Hmmm. I'm using clj-kondo in the context of github actions, which seem to fail on any exit code other than 0. I'm looking around to see if this is something I can configure....

2021-03-14T11:07:49.313100Z

GH actions by default failed if exit code is not zero. You can wrap call to clj-kondo in a script which will catch exit code, analyze it and transform it to zero in case there's only warnings.

2021-03-14T12:08:56.313300Z

echo '(def x (def x 1))' | clj-kondo --lint - || if [[ $? = 2 ]]; then exit 0; else exit $?; fi
this snippet pipes output of clj-kondo to simple if/else expression which is transforming exit code 2 (more than one warning found but no errors) to exit 0 indicating that this should be OK result in the scope of GH actions.

borkdude 2021-03-13T23:40:55.307100Z

Maybe @delaguardo knows the answer here.

ezmiller77 2021-03-13T23:50:20.309300Z

Another question related to the unresolved-var linter. I'm getting some warnings about unresolved vars in a namespace. I thought the problem was that the namespace used :as instead of :refer but I switched it to refer an am still getting the warning. Any idea what might be happening?