Hello 👋 I'm using custom linters in my project. And the code for the linters lives there too. Is it possible to extract that into a library, so that I can use it in other projects? Any public repo that I can peek at for 'inspiration'?
https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting
here's a very basic example from a library i wrote: https://github.com/NoahTheDuke/cond-plus/tree/master/resources/clj-kondo.exports/io.github.noahtheduke/cond_plus
nice! thank you 🙏
I think @franquito might be referring to the new LSP custom linters?
Yep, but the idea is more or less the same, I guess?
I'm sure the idea was inspired by what clj-kondo does, but they are not the same
oh crap, i didn't know lsp supported custom linters, my apologies
the file just has to be on the classpath:
clojure-lsp.exports/linters/my_org/my_linter.clj
so it doesn't matter if it's in a library or in your local project
so the answer to your original question is: yes
right! I'm not familiar with writing libraries so I'll be checking Noah's code. thanks both of you!
Noah's code is about clj-kondo hooks, not about lsp custom linters
Just make a directory with a deps.edn. Add your file in src/clojure-lsp.exports/linters/my_org/my_linter.clj .
Add it to github. You have a library you can reference as {:deps {io.github.your-account/my-library {:git/sha "..."}}}
you don't even have to add it to github. you can also reference it with {:deps {io.github.your-account/my-library {:local/root "../my-project"}}}
Yep 🤔 I'll go that way, since I'm still tweaking the code
you might have to restart clojure-lsp before it finds this stuff
Answering the original question, yes, and we do that for nubank, having a common lein library that has all clojure-lsp custom linters + kondo hooks (called codestyle), so you could do the same.
The lib must just be avaialble on classpath, usually in dev alias for clojure-lsp be able to use it
The custom linters page linked above references clj-depend which I navigated to and saw the following. Wth.
That's weird, @contato794 is the maintainer, maybe he knows
Just talked with @contato794 and fixed docs, the correct is https://github.com/fabiodomingues/clj-depend
Just thought about a clojure-lsp doctor command which outputs the classpath used for analysis and any other relevant info which might help a lot debugging multiple issues 🤔