Fork me on GitHub
Noah Bogart17:07:42

I just ran into a bug where I had (:require [ :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?


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?


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

👍 1

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

(require '[sci.core :as sci])
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}}}


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


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


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

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


oh wait, yes, it is possible

🙌 1

: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?


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


sure, quick issue is fine


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 <?


like a CSS selector but for nested calls?


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


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.


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


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


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?


That would be a good place


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?


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