Fork me on GitHub

@stefan.van.den.oord is working on a namespace linter that warns when the name of the ns does not match the filename. But for scripts (clojure and babashka) it is fine to use normal dashes in the name. So foo-bar.clj and (ns foo-bar) is fine for scripts that you invoke directly with bb foo-bar.clj, but not for files on the classpath. Any suggestions on how to deal with this? Maybe a heuristic that when there is no "src" or "test" in the parent segments, the file isn't on the classpath and can be assumed a script?

🎉 1

Would it make sense to have a different set of default linter configs for that type of use? In other words, invoking clj-kondo slightly differently so that it knows it is running in “scripting mode” and then have different defaults?


No, if you are using clj-kondo in your editor you don't invoke it yourself and that's the primary mode of usage as far as I'm concerned


People could just use #_:clj-kondo/ignore in this case or just adopt the convention to use underscores in their script file names perhaps.


Might be worth making a test case to see if the ignore annotation works correctly with this linter

👍 1

Checking for the presence of a shebang could also work


shebang is not always present in scripting mode I think.

cat some-text-file-containing-clojure.clj | bb


In your example using a namespace form is pretty unusual.


Example updated 🙂


You're right that a shebang isn't always present, but that would be a way for people to get rid of the warning


That feels a bit like magic to me…


But maybe we could let it be for now and just let people use the ignore annotation


So please add a test for that one


Yes good idea.

Noah Bogart14:02:39

i'm writing a hook. what's the best way to debug it?

Alex Miller (Clojure team)14:02:16

I read that as "writing a book" and laughed

😂 6

I was asking the same a while back, check out this thread

👍 1
🙏 2
Noah Bogart15:02:01

a combination of --debug and with-in-str nailed it. thanks so much!

Noah Bogart17:02:16

to follow up, I have a macro that creates a private function and then binds the function to public atom, which allows for repl-based testing while keeping the in-code usage through the atom. is it possible to output the {:node node} in my :analyze-call hook that ignores the unused-private-var warning?

Noah Bogart17:02:35

oh wait, this is a clojure-lsp issue, i'll work from there. never mind, this is in fact a clj-kondo issue. any ideas on how to fix this?


@nbtheduke Just use the unused private var once in your hook, that will take care of the warning, e.g. (let [_ private-var])

Noah Bogart18:02:12

mind if i PM you about this? i don't want to share the code publicly but i'm unsure how to do that with the code i have written