Fork me on GitHub
#clj-kondo
<
2020-04-30
>
serioga15:04:01

Hi @borkdude Looks like I cannot disable :unresolved-namespace linter using namespace meta.

(ns dev.playground
  {:clj-kondo/config {:linters {:unresolved-namespace {:level :off}}}})

(clojure.java.shell/sh "whoami")
> warning: Unresolved namespace clojure.java.shell. Are you missing a require? But the option works when placed in the main config.

borkdude16:04:35

@serioga I also noticed that myself and created an issue for it: https://github.com/borkdude/clj-kondo/issues/870

4
borkdude16:04:51

Follow up question: why would you like to turn it off?

serioga16:04:33

I have a single file for experiments in my project. So I don't want to see warnings when I check whole project.

borkdude16:04:29

@serioga You can also ignore that file with clj-kondo --lint "$(clj -Spath)" --config '{:output {:include-files ["^clojure/test"] :exclude-files ["tap"]}}'

serioga16:04:35

Also I think it would be useful to be able to specify exact namespaces to ignore. Especially those which are preloaded using profiles.clj.

serioga16:04:46

> You can also ignore that file not sure I want to ignore it completely when editing 🙂

borkdude16:04:12

ok, then you'll have to wait for #870 🙂

serioga16:04:26

no problem 🙂

serioga16:04:13

> it would be useful to be able to specify exact namespaces to ignore what do you think about this?

borkdude16:04:34

yeah, that makes sense

borkdude16:04:41

post it in another issue

borkdude16:04:07

so far I didn't need that myself yet though

borkdude16:04:15

can you give a good realistic example ?

serioga16:04:11

especially this is annoying inside comment, where Cursive and clj-kondo cannot agree about used/unused namespace aliaces

borkdude16:04:30

you can turn linting off in comment if you want

serioga16:04:12

> can you give a good realistic example ? I'll prepare in the ticket

serioga16:04:05

> turn linting off in comment also bad option, this helps to keep commented code in sync

borkdude16:04:27

yes, I prefer to keep it on as well, but personally I don't have any conflicts with unresolved namespaces in comment sections

borkdude16:04:38

so I'm curious about your example

serioga16:04:56

Also maybe it would be useful to print linter ID with message. It's tricky to find exact configuration option from the message.

borkdude16:04:08

@serioga you can also output as JSON or EDN, this will also print the name of the linter

borkdude16:04:24

also, there's a link on config.md that points to all available linters

borkdude16:04:52

Maybe there can be a setting to turn it on, I think I wouldn't like it by default

serioga16:04:34

I know about config.md. But having message "Unresolved namespace" I cannot find this text there.

serioga16:04:58

So for me the most reliable way it to dig into source code 🙂

serioga16:04:27

> you can also output as JSON or EDN and how to enable EDN output?

serioga16:04:15

> you can also output as JSON or EDN well, it's acceptable for debugging

borkdude16:04:39

@serioga It is documented at the top of config.md how to find those names.

borkdude16:04:11

It has a link to the source where all these keys are defined.

serioga17:04:36

@borkdude > It is documented at the top of config.md how to find those names. Can you point me to exact text? The use-case: I see a message warning: Unresolved namespace clojure.java.shell. Are you missing a require?. How can I find corresponding linter ID from config.md or linked configuration file?

borkdude17:04:20

@serioga "Look at the default configuration for all available options." There is a link in that sentence

serioga17:04:48

Yes, it is liked to https://github.com/borkdude/clj-kondo/blob/master/src/clj_kondo/impl/config.clj But where is no text Unresolved namespace there!

serioga17:04:06

My point is that I should guess linter ID from the message, but I cannot find exact text there, which is located in https://github.com/borkdude/clj-kondo/blob/36c0e7ce65521c0b7eb3a09c787ddf7e9b6d4219/src/clj_kondo/impl/linters.clj

serioga17:04:07

But anyway I'm fine with EDN output as workaround

dominicm19:04:56

I suppose the first person to get their funky macro shape into kondo wins. The trick is to identify a popular macro that doesn't work in kondo with any existing vars, and then name make a library with (defmacro dominic-rules) and then add that to kondo. Then when users of the popular library add the macro alias, they will add it as popular/library dominic-rules. ;)

😆 4