Fork me on GitHub
#clj-kondo
<
2020-01-09
>
yuhan10:01:05

would it be possible for clj-kondo to lint function arguments? eg. (update m k f x) would be an error if f did not take 2 args or x was the wrong type

borkdude10:01:51

Worth a research project. I guess it could be made to work

mynomoto18:01:31

I need to use a private var on a library, can clj-kondo ignore the error only for a specific var?

borkdude18:01:20

no, but if you use #'private/var that works?

mynomoto18:01:10

It's on clojurescript so it just works.

mynomoto18:01:50

I'm trying to configure the namespace to ignore the private var linter

borkdude18:01:10

Maybe you can do it in the namespace metadata? Not sure if it works for that specific linter

borkdude18:01:57

(ns foo "foo docs" {:clj-kondo/config '{:linters {...}}})

mynomoto18:01:45

I thought that :private-call could be the one but doesn't seems to work.

mynomoto19:01:59

Can I exclude a single namespace from linting?

borkdude19:01:38

this seems to work:

(ns foo "foo docs"
    {:clj-kondo/config '{:linters {:private-call {:level :off}}}})

(clojure.core/is-annotation? 1)

borkdude19:01:14

the linter should actually be renamed to :private-var since it should also report usages of private vars. I'll make an issue for that

borkdude19:01:30

(I'll make sure it will be non-breaking)

mynomoto19:01:15

Do I have to use the docstring? I tried without it and it didn't work. Not sure if it makes a difference but the variable I'm using is created by defprotocol.

mynomoto19:01:45

Actually is a deftype.

borkdude19:01:28

no, the docstring is optional.

borkdude19:01:29

This works:

(ns bar)

(deftype ^:private Foo [])

(ns foo
  {:clj-kondo/config '{:linters {:private-call {:level :off}}}}
  (:require [bar]))

(clojure.core/is-annotation? 1)
(bar/Foo)

mynomoto19:01:31

Looks like quoting is mandatory?

borkdude19:01:59

yes, Clojure will evaluate your metadata so you have to quote them

mynomoto19:01:05

I just added the ' and it worked.

mynomoto19:01:01

But there is no symbols on it. I cannot see why quoting is necessary in this case.

borkdude19:01:15

Because symbols are evaluated by Clojure

borkdude19:01:40

hmm, yeah, that's weird 🙂

borkdude19:01:23

clj-kondo just always expects a quoted value there because most of the time there are symbols in there

borkdude19:01:51

it's hard-coded in the linter

mynomoto19:01:50

Ok, that makes sense. Thanks for the explanation.

mikerod20:01:21

Anyone faced getting clj-kondo linter error: unresolved symbol for symbols used in a clj comment macro?

mikerod20:01:37

I tried both :exclude on (comment) and (clojure.core/comment), but doesn’t seem to fix it

mikerod21:01:17

using latest ver [clj-kondo "2019.12.14"]

borkdude21:01:18

@mikerod By default clj-kondo will lint comments as if it's "real" code, because often that's useful during experimentation. But you can turn it off using :skip-comments true

mikerod21:01:41

oh interesting. I was on that doc page, but didn’t expect it to be a separate option like that

mikerod21:01:59

that makes sense, I guess the case I had was somewhat special then. perhaps it should be turned into something more valid to avoid needing this skip.

borkdude21:01:20

that option is often useful for CI as well

borkdude21:01:00

because you don't want to trigger any false alarms in CI?

mikerod21:01:48

was thinking there was something special about comment in CI

mikerod21:01:55

I see what you’re saying now though