Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support namespace groups in unresolved-namespace linter #2025

Closed
Juholei opened this issue Mar 23, 2023 · 6 comments
Closed

Support namespace groups in unresolved-namespace linter #2025

Juholei opened this issue Mar 23, 2023 · 6 comments
Projects

Comments

@Juholei
Copy link

Juholei commented Mar 23, 2023

Is your feature request related to a problem? Please describe.
We use an sql library that generates query namespaces in a macro so when running clj-kondo it gives us a lot of unresolved namespace warnings. It would be nice to be able exclude these without listing every single one of the generated namespaces.

Describe the solution you'd like
https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#namespace-groups says to create an issue if you want support for namespace groups for other linters. For our problem it would be a solution to define a namespace group with pattern ".*-db$" if unresolved-namespace linter also supported namespace groups.

Describe alternatives you've considered
I haven't come up with any other solution apart from listing all the namespaces manually to be excluded.

@borkdude
Copy link
Member

@Juholei Thanks for the issue.

Can you give me more context in the form of real code so I can understand the problem better?
Why aren't you require-ing those namespaces first before where they are used?

Other options:

  • support the regex directly in the unresolved-namespace linter.

@borkdude borkdude added this to Needs triage in clj-kondo via automation Mar 23, 2023
@Juholei
Copy link
Author

Juholei commented Mar 23, 2023

We use yesql (or its fork jeesql) sql library which generates functions based on sql files the project. These are then namespaced with a macro defined here in our project https://github.com/solita/etp-core/blob/26b24be0e0bb5b82d93be73ade4952320564a3c1/etp-backend/src/main/clj/solita/etp/db.clj#L79. So the functions and namespaces are generated during runtime so they cannot be required in the actual code files as far as I can tell.

Your suggested other option would work too for this issue.

@borkdude
Copy link
Member

So the functions and namespaces are generated during runtime

That doesn't mean you can't write a (:require [your-generated-namespace]) though

@borkdude
Copy link
Member

I mean, you just have to ensure that the creation of those namespaces is done before you require those namespaces.

@borkdude
Copy link
Member

But happy to support both options.

@borkdude borkdude moved this from Needs triage to High priority (next release) in clj-kondo Mar 23, 2023
@borkdude borkdude moved this from High priority (next release) to In progress in clj-kondo Apr 5, 2023
clj-kondo automation moved this from In progress to Done Apr 5, 2023
@borkdude
Copy link
Member

borkdude commented Apr 5, 2023

:ns-groups + :unresolved-namespace combo is now supported on master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
clj-kondo
  
Done
Development

No branches or pull requests

2 participants