Fork me on GitHub
#clj-kondo
<
2022-07-08
>
Noah Bogart17:07:42

I just ran into a bug where I had (:require [example.company.common :as ecc]) and then later wrote :ecc/some-keyword, and was getting an error because I only used a single colon and the keyword didn't autoresolve to the right namespace. Would you be interested in a linter that checks qualified keywords that share a namespace with an existing namespace alias but aren't auto-resolving?

imre19:07:13

This is an interesting one. Using it like you wrote is perfectly valid but it can help find these typos. Would keep it at warning level for sure. And it should not only cover keywords but symbols and destructuring as well IMO

Noah Bogart19:07:07

are there auto-resolving symbols?

imre19:07:02

I guess only in ::keys vs :keys destructuring but I might be wrong

👍 1
borkdude16:07:04

I haven't made many mistakes that I can remember with this I actually saw a counter-example today:

(require '[sci.core :as sci])
:sci/error 
A bit on the fence about this one, but let's see how others feel about it.

👍 1
Noah Bogart19:07:15

yeah, i suspected this wouldn't be a sure-fire lint lol

Noah Bogart19:07:36

If included, I would want it off by default

Stefan T20:07:36

If you want to configure a :lint-as for a macro in a single namespace, is the best option using namespace metadata? Is there any way to avoid using the fully qualified symbol?

{:clj-kondo/config '{:lint-as {shared-lib.asset-caching-test/with-test-file clj-kondo.lint-as/def-catch-all}}}

borkdude20:07:54

Not sure why you would like to avoid a fully qualified symbol?

borkdude20:07:17

Metadata is one possibility. Another one is using :config-in-ns

Stefan T20:07:06

To clarify, it’s a macro defined in the same namespace

(ns shared-lib.asset-caching-test
  {:clj-kondo/config '{:lint-as {shared-lib.asset-caching-test/with-test-file clj-kondo.lint-as/def-catch-all}}}}
it’s pretty minor, just wondering if there was a way since it seems like it’s possible with other config options like :exclude

borkdude20:07:28

It's not possible to avoid the fqs

thanks3 1
Stefan T21:07:35

Is it possible to disable type-mismatch in the body of a macro? For example: (korma.core/where (< :start_date start-date)

🙌 1
borkdude21:07:19

Currently not, but a #_:clj-kondo/ignore before the form should work. A hook would be a better solution here probably

borkdude21:07:36

oh wait, yes, it is possible

🙌 1
borkdude21:07:00

:config-in-call {korma.core/where {:linters {:type-mismatch ...}}

Stefan T21:07:24

Nice! That worked. I wasn’t aware of :config-in-call and I don’t see it documented in the config README, is this new?

borkdude21:07:49

We should document that. If you can post an issue and/or a PR, that would be helpful

Stefan T21:07:08

Very useful, thanks!

Stefan T21:07:35

I can post a quick issue but I don’t know enough about the feature to PR something

borkdude21:07:47

sure, quick issue is fine

borkdude21:07:21

the korma example is very useful, please also include that in the issue

Stefan T21:07:32

Cool, creating a ticket now

Stefan T21:07:52

Still getting a hang of the configuration. Currently using

:config-in-call {korma.core/where {:linters {:type-mismatch {:level :off}}}}
I’m curious if there’s a way to be more specific to functions like <?

borkdude21:07:40

like a CSS selector but for nested calls?

borkdude21:07:17

I think you can even teach clj-kondo to override the type checking for <

borkdude21:07:28

see the type mismatch docs

Stefan T21:07:59

I meant is there a way to only disable :type-mismatch for < instead of for everything (in the context of the korma.core/where call)

Stefan T21:07:40

I’m perfectly happy with using {:level :off} and I see the “types” config is still WIP so I think I’ll leave it.

borkdude21:07:34

yeah, I also tested this but it doesn't work on this granular level yet

borkdude21:07:13

I think in this case, writing a hook for some of those korma macros would be the best solution

borkdude21:07:34

which is more work, but it can be shared with all korma users

Stefan T21:07:39

Yeah. If that was to happen would it make most sense to PR that into clj-kondo/config?

borkdude21:07:05

That would be a good place

borkdude21:07:13

or the korma lib itself

Stefan T21:07:46

> or the korma lib itself all cobwebs over there 🙂

😆 1
Stefan T23:07:34

Maybe I overlooked something, when using the CLI is it possible to only emit errors and hide warnings?

borkdude06:07:28

You can set the fail level but it still will output everything. You can use grep to see only errors