clj-kondo

https://github.com/clj-kondo/clj-kondo
dominicm 2020-07-08T13:52:31.130500Z

Random thought (rooted in how many of these I have due to react) that I wanted to get some basic feedback on before opening an issue: linting unused arguments when calling a function which destructures in it's arglist.

dominicm 2020-07-08T13:53:09.130600Z

(defn foo [{:keys [a b]}])

...

(foo {:c 10})
For react, this is a lot of code because of props.

dominicm 2020-07-08T13:53:28.130700Z

Obviously it only works for literal maps, but I still think it's pretty useful for that?

borkdude 2020-07-08T14:03:30.131Z

What do you mean with unused arguments?

borkdude 2020-07-08T14:03:42.131300Z

Something else than clj-kondo already does apparently?

dominicm 2020-07-08T14:10:41.131400Z

*unused parameters that should be

dominicm 2020-07-08T14:11:00.131500Z

So in the above example you'd lint :c is not a used key

borkdude 2020-07-08T14:16:25.132100Z

I don't think Clojure works that way in most cases: data is passing through all the time which is not used in one place but maybe down the line

dominicm 2020-07-08T14:21:22.132200Z

It would be specifically for arglists destructuring where :as is not used.

borkdude 2020-07-08T14:36:58.132700Z

I think in most cases Clojure doesn't care about extra keys, except maybe in edges of systems

dominicm 2020-07-08T14:37:37.132800Z

Wouldn't be an error, for sure. It's for when something is removed from use I guess.

dominicm 2020-07-08T14:38:10.133Z

Hmm, which would be a breaking change I guess. Only in internal use is it not. So perhaps not a good choice. But then again, arglists are warned about.

dominicm 2020-07-08T14:38:36.133100Z

The change that got me here was removing a keyword arg from a component, and then replacing uses of that arg with a different one.

borkdude 2020-07-08T15:22:45.133500Z

clj-kondo does have an option to check for required keys

dominicm 2020-07-08T16:45:16.134400Z

I don't see that in the list of optional linters, could you point me the right way?

borkdude 2020-07-08T18:40:19.135Z

@dominicm it's part of the type stuff: https://github.com/borkdude/clj-kondo/blob/master/doc/types.md so you explicitly have to state the required and optional keys for a function's argument

borkdude 2020-07-08T18:40:41.135600Z

I use it in one place in clj-kondo where I need to construct a map with 5 keys of which I always forget one