Fork me on GitHub
#clj-kondo
<
2020-06-17
>
borkdude19:06:46

I'm soon resuming work on the macroexpand feature and would still very much like feedback on this. https://clojureverse.org/t/feedback-wanted-on-new-clj-kondo-macroexpansion-feature/6043

borkdude20:06:44

In a different issue someone suggested it would be useful to have a hook in the function call so you can lint arguments to some function yourself. This would be a generalization of the macroexpand feature as it is proposed now. E.g. with re-frame, a dispatch function should get a qualified keyword. This is something people can't do with the analysis output today (although that could also be extended with the sexpr).

borkdude21:06:57

so like this:

dominicm21:06:10

@borkdude it would be nice to attach location info somehow

borkdude21:06:49

one of the problems in the above example is that keywords and numbers don't carry metadata

borkdude21:06:57

also I think rather than throwing people can return :findings with :level, :row, :col etc.

borkdude21:06:45

The row and col come from the metadata of the sexpr elements, but in case of numbers of keywords these aren't present

borkdude21:06:35

Of course the function could get an additional :node thing which is the raw rewrite-clj node

borkdude21:06:45

and then you can lookup the metadata yourself

borkdude21:06:10

using (-> node :children second meta) for example

dominicm21:06:17

A basic thing to do is point at the argument

dominicm21:06:46

The rewrite node is most powerful

borkdude21:06:08

> A basic thing to do is point at the argument what do you mean?

dominicm21:06:39

A common use case that it would be nice to make easy.

borkdude21:06:54

right, or a path into the sexpr, like [1 0]

borkdude22:06:00

which would mean the second child node and then the first child node of that

borkdude22:06:23

and then clj-kondo can figure it out

borkdude22:06:46

this is probably already a power-feature, so the raw rewrite-clj node is probably good to start with

dominicm22:06:11

Yeah I think you're right

dominicm22:06:51

I'm not sure you can close 468 from this, as custom linters might be broader, like less than 10 functions per namespace.

borkdude22:06:09

I followed you until like less than 10 functions per namespace.

borkdude22:06:32

I mean, then I became confused about what you are trying to say

borkdude22:06:44

with fixed location:

borkdude22:06:32

unless people give me more concrete use cases, I don't know what to make of 468 really

borkdude22:06:50

but I think the macroexpansion -> hooks generalization is a good one