Fork me on GitHub

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


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

Sean Poulter19:06:49

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?

Sean Poulter19:06:41

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:

👍 3

see :var-usages

Sean Poulter19:06:10

Yea, I’ve found the call sites that way which is awesome.

Sean Poulter19:06:55

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

Sean Poulter19:06:35

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' } 

Sean Poulter19:06:13

Oh…. oh. 😐

Sean Poulter19:06:26

Yea… macros!

Sean Poulter19:06:43

The macros have me all confused. Thanks!


so with from-var + from (the ns) you know in which defn this happens

👍 3

I do notice that this isn't in the documentation


so sorry for the confusion

Sean Poulter19:06:04

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:


@sean.poulter I'm also building something like this: 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

Sean Poulter19:06:28

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

👍 3
Sean Poulter19:06:44

Wow. That’s neat too! Thanks! 😀

Sean Poulter19:06:34

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.