I'd like to setup a kondo linter to dissallow System/exit. I wanted to add it as a discouraged var (or similar), but I think since it's a method that isn't going to work. Do I need to write a hook? I didn't see a built in one here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md but I might have missed it.
Here's a PR proposal: https://github.com/clj-kondo/clj-kondo/pull/2548
(relevant clj-kondo issue: https://github.com/clj-kondo/clj-kondo/issues/2234)
this could be smart and use clj-kondo, but this could also be dumb and regex on System/exit
this already works with :discouraged-var when you configure it with java.lang.System/exit
(kind of by accident, but someone relied on it so I kept the behavior)
I am not seeing that:
$ clj-kondo --version
clj-kondo v2025.04.07
$ echo '(ns hmm) (System/exit 12)' > hmm.clj
$ clj-kondo --lint hmm.clj --config '{:linters {:discouraged-var {java.lang.System/exit {:message "uh o"}}}}'
linting took 3ms, errors: 0, warnings: 0I might be holding it wrong
do you need to set the level?
Ohh, I'll try that
Hmm, guess not:
$ clj-kondo --version
clj-kondo v2025.04.07
$ echo '(ns hmm) (System/exit 12)' > hmm.clj
$ clj-kondo --lint hmm.clj --config '{:linters {:discouraged-var {java.lang.System/exit {:message "uh o" :level :error}}}}'
linting took 37ms, errors: 0, warnings: 0Tried with warning too:
clj-kondo --lint hmm.clj --config '{:linters {:discouraged-var {java.lang.System/exit {:message "uh o" :level :warning}}}}'
linting took 4ms, errors: 0, warnings: 0interesting
sorry I was confused, it works for analyze-call, not for discouraged-var: https://github.com/clj-kondo/clj-kondo/issues/1603
so you could write a hook for it today, or write a github issue
I wrote an issue here, I think I've captured it well, lmk if you'd like me to ammend it: https://github.com/clj-kondo/clj-kondo/issues/2541