hello, one curiosity, when you have many projects and would like to keep the lint configuration consistent between then, is there a nice way to keep a single file serving many projects?
@wilkerlucio I recommend writing a babashka script to generate/update your project configs. Clj-kondo has an API function called merge-configs which can also be used for this and can be invoked as a pod function
@borkdude with 468, it's about linting a single function, it's about linting the whole file. Eg implementing my own version of unused refers, or something like that. Generating an arbitrary message for anywhere in the file.
I'm considering switching entirely to rewrite-clj node based transformations instead of converting them to sexprs and parse the transformed sexpr as rewrite-clj nodes again as it's quite difficult to preserve location metadata, for the "macroexpand" feature
Still, the sexpr can be used for some validations, when people don't "macroexpand"
it's a bit unfortunate since working with sexprs is more ergonomic than rewrite-clj nodes... but preserving location information is really important for clj-kondo
Colin Fleming posted a response: https://clojureverse.org/t/feedback-wanted-on-new-clj-kondo-macroexpansion-feature/6043/10?u=borkdude
I think he just affirmed my belief that it's good to not use sexprs but work directly with the source nodes in that response
Hey folks. Can I bounce a wild idea off someone? I’ve come over JavaScript in the last year and trying to find the Clojure-ish way to walk the AST to find where some of my function calls use third-party libraries. I heard about the analysis output from clj-kondo on Jacek Schae’s podcast, but it seem to have a way to connect the variable usage (call site) to the function that calls it. Does that sound right? I probably need to find something to work with the AST, eh?
Thanks in advance for thinking about it, and a huge thanks to Michiel for sharing all your tools. ❤️
@sean.poulter Using the analysis output you can see where a third party library is called: https://github.com/borkdude/clj-kondo/tree/master/analysis
see :var-usages
Yea, I’ve found the call sites that way which is awesome.
I don’t think we can find the enclosing function though. I’ve got to walk the call stack to figure out where that third-party code is called from our public APIs.
you want to know the enclosing defining function? you can do that I think
there are at least a few tools making visual representations of this using the analysis data, so it should be possible
let me have a look
Here’s an entry from the var-usages
:
{ filename: 'src/my/components/widgets/list/views.cljs',
row: 14,
col: 6,
from: 'my.components.widgets.list.views',
to: 'other.components',
name: 'Flow',
'from-var': 'widget' }
Oh…. oh. 😐
from-var
Yea… macros!
The macros have me all confused. Thanks!
so with from-var + from (the ns) you know in which defn
this happens
I do notice that this isn't in the documentation
so sorry for the confusion
Can I add from-var
to https://github.com/borkdude/clj-kondo/tree/master/analysis for you?
All good.
yes please
Cool. I’ll put something up in the next day or two after work. 🤓
thanks a lot. there are a few cool tools built on top of this: https://github.com/borkdude/clj-kondo/issues/836
these two: https://github.com/SevereOverfl0w/vizns https://github.com/benedekfazekas/morpheus visualize the analysis output in interesting ways
@sean.poulter I'm also building something like this: https://twitter.com/borkdude/status/1273384546269040646/photo/1 so you can write a hook and make a custom linter once clj-kondo analyses the usage of a function. but it won't be released soon probably
Neat.
Wow, thanks. I can use Morpheus to solve my “where is this stuff used?” question too! 👏
Also carve is interesting to cut out unused stuff
Wow. That’s neat too! Thanks! 😀
This is one of those “I wish I could hang out and watch how (person) works” moments. That’s some really neat tooling we weren’t aware of.
anyone want to add clj-kondo to this? https://github.com/github/super-linter https://github.com/github/super-linter/issues/111