Fork me on GitHub
#clj-kondo
<
2021-10-06
>
Jakub Holý (HolyJak)10:10:46

Hi! Does kondo not support the transducer arities? Here it complains > clojure.core/map is called with 1 arg but expects 2, 3, 4 or moreclj-kondo(invalid-arity) Code: (into [] (map :val) [{:val 1}]) Searching for "transduce[r] in issues yield nothing. (Kondo v. 2021.09.25)

1
borkdude10:10:42

I don't see any error for that example

borkdude10:10:22

@U0522TWDA Can you try on the command linting only that example? It could be a hiccup in your editor or so

Jakub Holý (HolyJak)10:10:57

yes, I am using Calva, perhaps it is doing something weird there

borkdude11:10:04

perhaps try closing and reopening the file or so

👍 1
ericdallo15:10:33

is it possible to exclude some linters from clj-kondo for a whole namespace but via config?

ericdallo15:10:55

like I want to exclude unused-namespace for the user namespace

ericdallo15:10:16

but I'd like to do that via config, not commenting on the code as this config is shared for a lot of projects

ericdallo15:10:44

something like:

{:unused-namespace {:exclude-ns [user]}
 :unused-referred-var {:exclude-ns [user]}}

borkdude15:10:56

not supported right now. I think there are various ways to go about this. we could e.g. also support {:ns-config {user {:unused-namespace {...}}}

ericdallo15:10:51

hum, instead of configuring for each linter, kind of configure which linters you want exclude for a ns?

borkdude15:10:31

no I mean: this would allow you to provide an ns-local config without touching the code

ericdallo15:10:32

we could do much more than excluding right

ericdallo15:10:44

but configuring whole kondo for specific ns

borkdude15:10:51

this would allow you to do the same as (ns foo {:clj-kondo/config ...})

borkdude15:10:55

but then in your config file

ericdallo15:10:31

I didn't even know a :clj-kondo/config exists 😂

borkdude15:10:46

oh I thought you were referring to that

ericdallo15:10:20

i was referring to supress linter via code with {:clj-kondo/ignore} but yeah, your idea would allow do more than just supress lint

borkdude15:10:27

so instead of changing each linter to support an ns, we could support providing configs per ns

borkdude15:10:41

which is only a small change really

ericdallo15:10:44

looks really good

borkdude15:10:54

since the code for reading config is already there

borkdude15:10:58

in the namespace form logic

ericdallo15:10:14

also, do you think would be possible add support for something like:

ericdallo15:10:51

{:ns-config {".*-config" {:unused-namespaces {...}}}}

ericdallo15:10:56

add regex for those namespace match

ericdallo15:10:14

since at Nubank, we have a pattern of <service-name>.config and a lot of ns

ericdallo15:10:25

then the common config code would catch the service name always

ericdallo15:10:30

does that makes sense for you?

borkdude15:10:47

yeah, although having a regex as a key in a map doesn't really make sense to me :)

borkdude15:10:07

but the idea sounds good

borkdude15:10:17

can you make an issue?

borkdude15:10:47

btw this use case is quite rare. I'd like to discuss with you why you would like to suppress unused namespaces only in certain namespaces

ericdallo15:10:59

it's actually quite simple, at nubank we have a service template that all services follow, for example the user ns has only this:

(ns user
  (:require [clojure.tools.namespace.repl :refer [refresh refresh-all]]
            [common-core.misc :as misc]))

ericdallo15:10:11

for REPL functions be easily available after jack-in

ericdallo15:10:43

Also, I can see we easily creating custom linters for specific namespaces!

borkdude15:10:45

for the user ns I can understand, but why for the others?

borkdude15:10:14

yes, with :clj-kondo/config in metadata you can do this for specific namespaces in your template

ericdallo15:10:59

we probably wouldn't want to exclude linters for other namespaces, but configure custom linters for other namespaces via this new config flag specific for some namespaces would be cool

ericdallo15:10:07

but it would require the regex support as well

ericdallo15:10:28

but for now, just having a way to exclude some linters for a namespace via config is quite enough

borkdude15:10:19

so I think if you have a template, just add the config to the template, like:

(ns user {:clj-kondo/config '{:linters {:unused-namespace {:level :off}}}})

ericdallo15:10:20

yes, that would work for new services, but other hundreds of old services we would need to do some kind of migration 😅

borkdude15:10:38

that's a good explanation

ericdallo15:10:49

we already have a custom config created recently for all services

ericdallo15:10:53

using the clj-kondo export feature

ericdallo15:10:16

something like {:config-paths ["nubank/codestyle"]} which has all the common configuration for clj-kondo and etc

ericdallo15:10:43

so my idea was to just add the exclude for user on that common config you know

borkdude15:10:14

yeah that's a good idea

borkdude15:10:31

so the idea is: we should support the namespace local config (override) but outside the scode

👍 1
ericdallo15:10:31

Cool, I'll open the issue then

borkdude15:10:33

and with regex

🙏 1
borkdude18:10:58

I think it should recognize this one in the latest clj-kondo

borkdude18:10:41

if it doesn't, could you make an isolated repro?