clj-kondo

https://github.com/clj-kondo/clj-kondo
2021-01-14T01:18:50.001200Z

So, @seancorfield made me realize that if you change the arity of a fn in one namespace, and use it with the wrong arity in another namespace clj-kondo will catch the error. But, if the fn is deleted from the other namespace, or renamed, it won't catch those. Is that normal? Would it be possible for clj-kondo to warn on those as well? It seems to me if it can track the arity, it must also track what var is defined in each namespace no ?

borkdude 2021-01-14T08:22:45.003Z

Work in progress. I worked on this issue but it requires more work. It is something that I want to support eventually though.

1
Aleksander Rendtslev 2021-01-14T15:53:19.004900Z

Hi, This might be a naive question, but I haven’t been able to figure it out: How do I import library provided configs? Eg. Pathom comes with a .clj-kondo/config.edn, but my editor doesn’t pick it up. The guide of the config repo worked fine. So I got it to work for rum/fulcro etc. But I can’t figure out how to do it for everything outside of that (I’m still pretty new to Clojure so this is probably a rookie mistake)

borkdude 2021-01-14T15:57:54.005600Z

@aleksander990 There is a difference between a config that a project itself uses and the config that is needed for consuming the code of that project.

borkdude 2021-01-14T15:58:23.006Z

You can read more about this here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration I'm going into a meeting now, but I'd be happy to answer more questions later.

Aleksander Rendtslev 2021-01-14T16:15:25.006300Z

yeah, I think I got that part. Eg: Adding the fulcro config to .clj-kondo/config/fulcro/config.edn (by following the instructions in the config repo) and then adding that to config-paths in my own config.edn. I just can’t figure out how to do the same for pathom (outside of simply copy pasting the config from their repo) No worries. clj-kondo feels like a lifesaver and is absolutely great for beginners. So I figured my ignorance might be of some help

Aleksander Rendtslev 2021-01-14T16:15:51.006500Z

I did read through the guide below, but still can’t wrap my head around it

Aleksander Rendtslev 2021-01-14T16:18:03.006700Z

Sounds good. Thank you for being so responsive!

borkdude 2021-01-14T16:57:59.006900Z

ok, I'm back.

Aleksander Rendtslev 2021-01-14T17:08:45.007100Z

So my question is: How do I add an external libraries configuration to my linter? (in this particular case pathom) https://github.com/wilkerlucio/pathom I followed this guide to add the ones provided in this repo, and I figured I just have to tweak the approach for pathom? https://github.com/clj-kondo/config I just haven’t been able to figure out how

borkdude 2021-01-14T17:16:08.007500Z

So what pathom should do in this case is export the config for its library in a clj-kondo.exports directory that will be part of the library artifact

borkdude 2021-01-14T17:16:30.007700Z

and preferable it should only export config for itself, not for other libraries (like fulcro, because fulcro is not part of pathom)

borkdude 2021-01-14T17:17:10.007900Z

But for now you could also copy this config to clj-kondo/config, if pathom isn't doing this in the foreseeable future. Or just copy the relevant bits to your own config.edn file.

borkdude 2021-01-14T17:17:15.008100Z

@wilkerlucio ^

Aleksander Rendtslev 2021-01-14T17:34:39.008300Z

Ok, so it’s the clj-kondo.export part that’s missing. That makes sense. Thanks! I’ll copy it over for now

wilkerlucio 2021-01-14T17:36:10.008500Z

cool, sounds nice, I'll take a time to check on it later today 👍

wilkerlucio 2021-01-14T18:16:54.008700Z

@borkdude looks right? https://github.com/wilkerlucio/pathom/pull/186

🙌 1
borkdude 2021-01-14T18:48:53.009Z

@wilkerlucio Looks right to me!

wilkerlucio 2021-01-14T19:05:03.009300Z

cool, does this works with deps dependencies too?

2021-01-14T19:22:22.009600Z

So I assume there is already an issue for it and I shouldn't create one?

2021-01-14T19:26:48.010100Z

Can you teach clj-kondo to recognize data_readers ?

borkdude 2021-01-14T19:34:02.010500Z

@didibus I don't think there is any logic for that yet.

borkdude 2021-01-14T19:34:12.010800Z

Feel free to create an issue

1
borkdude 2021-01-14T19:35:12.010900Z

This is the issue: https://github.com/clj-kondo/clj-kondo/issues/634

borkdude 2021-01-14T19:51:12.011700Z

it works with whatever build tool, as long as its on the classpath

borkdude 2021-01-14T19:52:30.011900Z

So anyone who has pathom on their classpath, should get a hint about the config with:

clj-kondo --no-warnings --lint "$(clojure -Spath -Sdeps)"

wilkerlucio 2021-01-14T19:56:58.012100Z

I was playing with it here

wilkerlucio 2021-01-14T19:57:08.012300Z

I updated my async library to provide those

wilkerlucio 2021-01-14T19:57:35.012500Z

and then add as a dep, when I used the clj-kondo --no-warnings --lint "$(clojure -Spath -A:provided)" --parallel, it copied the file, as expected

wilkerlucio 2021-01-14T19:58:01.012700Z

but, if I get the same library, and add it via deps (instead of the clojars), then when I run the lint, no copy happens

wilkerlucio 2021-01-14T19:58:19.012900Z

I guess because in the second case the clj-kondo.exports isn't at the root, but at resources instead

borkdude 2021-01-14T19:58:39.013100Z

it depends on your deps.edn, does it have "resources" in its :paths ?

wilkerlucio 2021-01-14T19:58:54.013300Z

good point, let me check that

wilkerlucio 2021-01-14T20:01:13.013600Z

that was the missing bit! now that resources in the classpath its working 👍 thanks!

wilkerlucio 2021-01-14T20:02:01.013800Z

should a library commit those loaded external kondo configs, or leave ignored in the repo?

borkdude 2021-01-14T20:02:38.014100Z

I think it's good to commit so anyone working on that project gets it automatically

wilkerlucio 2021-01-14T20:03:05.014300Z

makes sense

wilkerlucio 2021-01-14T20:33:34.014500Z

@aleksander990 released in pathom 2.3.1

Aleksander Rendtslev 2021-01-14T22:48:20.014700Z

Amazing! Thank you @wilkerlucio

borkdude 2021-01-14T22:49:55.014900Z

🙏