clj-kondo 2026-03-19

is there a way to make clj-kondo yell if a hook is broken? i know --debug will print errors, but i'd like to raise an error when ran normally too

✅ 1

define broken. what does it spit out now. example?

noah@Noahs-MacBook-Pro ~/programming/lazytest
jj:[@ wolvmnzn 949752dc]
i $ clj-kondo --lint src/clojure/lazytest/hooks.clj
linting took 26ms, errors: 0, warnings: 0
noah@Noahs-MacBook-Pro ~/programming/lazytest
jj:[@ wolvmnzn 949752dc]
i $ clj-kondo --lint src/clojure/lazytest/hooks.clj  --debug
[clj-kondo] Auto-loading config path: imports/com.noahbogart/sinker
[clj-kondo] Auto-loading config path: imports/io.github.noahtheduke/cond_plus
[clj-kondo] Auto-loading config path: imports/io.github.noahtheduke/lazytest
[clj-kondo] Auto-loading config path: imports/nubank/matcher-combinators
[clj-kondo] Auto-loading config path: imports/rewrite-clj/rewrite-clj
[clj-kondo] Linting file: src/clojure/lazytest/hooks.clj
src/clojure/lazytest/hooks.clj:115:1: error: Not a node: [:tag :list]
src/clojure/lazytest/hooks.clj:115:10: error: Unresolved symbol: profiling
src/clojure/lazytest/hooks.clj:117:4: error: Unresolved symbol: cli-opts
src/clojure/lazytest/hooks.clj:117:14: error: Unresolved symbol: _config
src/clojure/lazytest/hooks.clj:117:22: error: Unresolved symbol: opts
src/clojure/lazytest/hooks.clj:126:4: error: Unresolved symbol: pre-test-suite
src/clojure/lazytest/hooks.clj:127:6: error: Unresolved symbol: config
src/clojure/lazytest/hooks.clj:127:13: error: Unresolved symbol: m
src/clojure/lazytest/hooks.clj:130:4: error: Unresolved symbol: post-test-suite
src/clojure/lazytest/hooks.clj:134:4: error: Unresolved symbol: post-test-run
src/clojure/lazytest/hooks.clj:135:13: error: Unresolved symbol: results
src/clojure/lazytest/hooks.clj:177:1: error: Not a node: [:tag :list]
src/clojure/lazytest/hooks.clj:177:10: error: Unresolved symbol: randomize
src/clojure/lazytest/hooks.clj:194:19: error: Unresolved symbol: _
src/clojure/lazytest/hooks.clj:199:27: error: Unresolved symbol: suite
src/clojure/lazytest/hooks.clj:208:26: error: Unresolved symbol: _run
linting took 25ms, errors: 16, warnings: 0

this comes from calling (api/list (concat [...] (api/coerce ...)))

--debug does extra checking at an extra performance cost

what happens when there's an error without --debug? does it just swallow the error and move on?

I can't see what's happening at src/clojure/lazytest/hooks.clj:115:10: error: Unresolved symbol: profiling but the "Not a node" things are the result of extra runtime checks that you can ignore when your code is correct, which makes it run faster

👍 1

i should have trimmed the output, my apologies. most of the errors for "unresolved symbol" are due to the hook failing to create a new node, so my def-like macro creates a var which clj-kondo doesn't recognize

would you be interested in a config flag or a cli flag that doesn't print extra debug info but does raise an error if a hook throws?

define "when a hook throws"

well, here i've called concat on the output of api/coerce so the list is malformed, and api/list says "`[:tag :node]` is not a valid node". i'd like for the check in api/list to happen but i don't need the extra output from clj-kondo (which files are loaded)

not interested, this is what debug is for

@nbtheduke my thinking is that unit tests can be interesting for hooks. I wrote some for babashka fs, https://github.com/babashka/fs/blob/master/test/babashka/fs_linter_test.clj.

👍 1
👀 2

oh interesting idea, thanks

You are most welcome. Thoses tests give me comfort that the hooks are likely working. I'll eventually revisit other projects where I have custom hooks and write tests for them.

hey @lee i'm finally implementing this based on your work and it's really good

has immediately found multiple bugs in my hooks lol

😆 1
🎉 1