Fork me on GitHub
#clj-kondo
<
2022-10-22
>
borkdude11:10:10

Clj-kondo configs clj-kondo https://github.com/clj-kondo/configs A repository with clj-kondo configurations for libraries, as dependencies

borkdude11:10:44

@alex.sheluchin I think we could add a dependency to that project with community aliases instead of building them into clj-kondo, like you requested. This seems more flexible

borkdude11:10:12

So then you can add io.github.clj-kondo/config-bbatsov-clojure-style-guide to your deps and it will "just work"

borkdude11:10:37

I see @seancorfield also accepted a PR in that repo. Do you think that would be a good idea?

sheluchin14:10:17

@U04V15CAJ Thank you! I think this is a fine approach for my use case. @UEENNMX0T raised a concern about using it in this way when installing clj-kondo as a bin rather than a project dep. Will a bin kondo not pick up on configs installed this way? I'm not sure I fully understand the difficulty there.

borkdude14:10:35

there is no difference between binary or JVM clj-kondo

seancorfield16:10:45

I think an automated checker for the style guide would be awesome, if it's possible.

borkdude18:10:40

@seancorfield @alex.sheluchin OK, you can try to add:

io.github.clj-kondo/config-bbatsov-clojure-style-guide-aliases {:mvn/version "0.1.1"}
to your project dependencies and then restart your clojure-lsp, or run: clj-kondo --lint $(clojure -Spath) --dependencies --skip-lint --copy-configs and then you should get a warning like this:

borkdude18:10:12

I noticed that Alex uses jio a lot for so I think there will never be 100% consensus about these things, I'd rather leave it as an optional library than baking it in

borkdude18:10:11

The library comes from here: https://github.com/clj-kondo/configs/tree/main/configs/bbatsov/clojure-style-guide-aliases If you want to provide more configurations for other libraries that you don't manage yourself, then this is the place to do so, if the original maintainer doesn't want to have it in their repo

seancorfield18:10:26

Nice! I'll take a look at that when I get back to work on Monday.

👍 1
sheluchin18:10:47

Thanks for the instruction, @U04V15CAJ. I'll probably have time to try it tomorrow. I'm planning on showing a breakdown of aliases per namespace so maybe that will help promote a consensus, but it'll probably never be 100%. That's okay, choice is good :man-shrugging:

seancorfield18:10:53

We only have a few standard aliases at work, for third party libs (we have quite a few for our own nses):

clojure.data.json json
    clojure.spec.alpha s
    clojure.string str
    com.stuartsierra.component component
    exoscale.coax c
    next.jdbc jdbc, next.jdbc.result-set rs, next.jdbc.sql sql
    ring.util.response resp

borkdude19:10:04

Of course you can configure your own with :consistent-alias as well

seancorfield22:10:35

And that would override the style guide ones?

:linters
 {:consistent-alias
  {:aliases
☝️:skin-tone-2: is the fragment above what I posted.

borkdude06:10:12

Yes, your own would override but with merging

sheluchin17:10:21

@U04V15CAJ works nice 👍 thank you. I guess I can close https://github.com/clj-kondo/clj-kondo/issues/1839 as completed?

borkdude17:10:50

ok, maybe make a comment in there that this is the solution we landed on

borkdude17:10:07

and then close it

sheluchin18:10:53

done and done. ty sir

👍 1
seancorfield16:10:30

Seems to work nicely -- thanks! I was a bit surprised that clojure.data.json wasn't aliased to json but it isn't in the guide (only because cheshire.core is aliased to json lower down and I didn't want to introduce a conflict when I did that).

👍 1
borkdude18:10:40

@seancorfield @alex.sheluchin OK, you can try to add:

io.github.clj-kondo/config-bbatsov-clojure-style-guide-aliases {:mvn/version "0.1.1"}
to your project dependencies and then restart your clojure-lsp, or run: clj-kondo --lint $(clojure -Spath) --dependencies --skip-lint --copy-configs and then you should get a warning like this: