clj-kondo

https://github.com/clj-kondo/clj-kondo
borkdude 2020-06-17T19:27:46.390300Z

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

borkdude 2020-06-17T20:12:44.392400Z

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).

borkdude 2020-06-17T21:44:57.392700Z

so like this:

dominicm 2020-06-17T21:48:10.393600Z

@borkdude it would be nice to attach location info somehow

borkdude 2020-06-17T21:48:49.394100Z

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

borkdude 2020-06-17T21:49:57.394600Z

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

borkdude 2020-06-17T21:50:45.395400Z

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

borkdude 2020-06-17T21:51:35.396100Z

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

borkdude 2020-06-17T21:51:45.396400Z

and then you can lookup the metadata yourself

borkdude 2020-06-17T21:52:10.396700Z

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

dominicm 2020-06-17T21:56:17.397200Z

A basic thing to do is point at the argument

dominicm 2020-06-17T21:56:46.397800Z

The rewrite node is most powerful

borkdude 2020-06-17T21:57:08.398Z

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

dominicm 2020-06-17T21:58:39.398400Z

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

borkdude 2020-06-17T21:59:54.398900Z

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

borkdude 2020-06-17T22:00:00.399100Z

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

borkdude 2020-06-17T22:00:23.399400Z

and then clj-kondo can figure it out

borkdude 2020-06-17T22:05:46.400600Z

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

dominicm 2020-06-17T22:07:11.400900Z

Yeah I think you're right

dominicm 2020-06-17T22:11:51.401900Z

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

borkdude 2020-06-17T22:14:09.402300Z

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

borkdude 2020-06-17T22:18:32.402700Z

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

borkdude 2020-06-17T22:32:44.403Z

with fixed location:

borkdude 2020-06-17T22:41:32.403700Z

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

borkdude 2020-06-17T22:41:50.404Z

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