-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Project clj-kondo config file not being considered #1026
Comments
Thanks for the detailed report. @ericdallo, since Calva's really just the middleman here, I think this would be more something with clojure-lsp itself. Calva doesn't affect what clojure-lsp uses as the clj-kondo config or how files are linted. |
I will test it locally soon with only clojure-lsp + emacs |
@lread I found the issue, it is a clj-kondo issue that happens with libs that use |
The question remains why clj-kondo itself gives no warnings for @lread's project but clojure-lsp does? @lread has these hooks:
which are used to "teach" clj-kondo how to interpret their custom import-vars macros. It seems this isn't recognized by the clj-kondo invocation of clojure-lsp. |
I checked the referenced issue and that turned out to be a non-issue. |
Got it, didn't notice that, I will double-check clojure-lsp so |
Testing local I confirmed clojure-lsp is not considering the project clj-kondo config file for some reason, I'll take a look, created this issue to track: clojure-lsp/clojure-lsp#308 |
Fixed on latest clojure-lsp release, it seems it was a bug introduced during the kondo integration, I'll think in some kind of integration test to catch bugs like that. @lread after Calva updates clojure-lsp version, you should get no warnings in your project again :) |
@lread Please try out the latest version and see if the issue is resolved. (2.0.171) |
Much thanks for the fix, I am no longer getting unresolved-var errors in Calva v2.0.171 for my But... something else seems amiss now. If you look up at my original example screenshot code snippit from this issue: (deftest of-string-simple-sexpr
(let [sexpr "(+ 1 2)"]
(is (= sexpr (-> sexpr z/of-string z/root-string))))) It's good, no unresolved-var errors. But.. if I add in something obviously invalid: (deftest of-string-simple-sexpr
(let [sexpr "(+ 1 2)"]
(is (= sexpr (-> sexpr z/of-string z/invalid z/root-string))))) I would expect an unresolved-var error for If I run clj-kondo from the command line, I get the expected warning: $ clj-kondo --lint src test script
test/rewrite_clj/zip_test.cljc:10:39: warning: Unresolved var: z/invalid
linting took 1395ms, errors: 0, warnings: 1 If I temporarily add in something contrived like: (string/notgood) Calva correctly reports the clj-kondo unresolved-var warning. Do you see this as unexpected behaviour? If so, do you want me to raise a separate issue? |
Hmm @ericdallo ^? |
Yeah, I confirmed this is happening in clojure-lsp with lsp-mode too. $ cat ./rewrite-clj-repro/test/rewrite_clj/zip_test.cljc | clj-kondo --config '{:cache false}' --lint -
=> linting took 201ms, errors: 0, warnings: 0 Am I missing something @borkdude ? |
@ericdallo Clj-kondo will only complain about unresolved vars when you lint both namespaces at the same time, or one the required namespaces comes from the cache. |
There's probably a good reason Calva/lsp is not using clj-kondo cache? |
oh, got it, I changed clojure-lsp to not use the cache when linting a single file, so that is not fixed correctly, I could not make it work without not using the cache though, I'll need to understand why adding the cache make clj-kondo ignore the config |
Yeah, that's not so beneficial since clj-kondo won't get updated information while the user is typing. |
@ericdallo nope, makes sense |
So as discussed here this is a corner case bug on clj-kondo, I'll fix clojure-lsp side to always use the cache thought, but we still need a fix on clj-kondo @lread |
Coolio, thanks for update! Nice troubleshooting! |
Symptom
When I run clj-kondo from the command line I get no errors and no warnings.
In Calva, clj-kondo issues are reported.
Enviromnent
Reproduction
Clone my project's v1 branch (I'll refine this to something smaller if its too much)
If you want to match the exact commit I tested against:
$ cd rewrite-clj-repro $ git reset --hard 377bb5d7f86a4751350b0d347856b60a25528bc4 $ git clean -f -d
Run clj-kondo on the command line and witness no errors/warnings:
Open the cloned repo in Calva and navigate to
test/rewrite_clj/zip_test.cljc
Expected Behaviour
I would expect to see no clj-kondo errors, matching the command line invoked clj-kondo results.
Actual Behaviour
![image](https://user-images.githubusercontent.com/967328/107415365-47d10a80-6ae1-11eb-9ac0-b67ca3ef0cf3.png)
I see unresolved-var clj-kondo warnings, for example:
Extra Info
.clj-kondo/config.edn
maybe there's something else amiss in there that clj-kondo handles just fine but affects Calva.:lint-as
config forimport-vars
and rerun clj-kondo from the command line, as expected, tons of unresolved symbol errors are reported from clj-kondo command-line.The text was updated successfully, but these errors were encountered: