Fork me on GitHub
#hyperfiddle
<
2023-07-27
>
Garrett Hopper21:07:35

Is there a way to get clj-kondo to treat e/server and e/client as #?(:clj) and #?(:cljs) reader conditionals to avoid unresolved namespace warnings? And potentially a way to get Clojure-LSP to behave similarly to get JS/JVM specific completions in context? (Cider is asking me "Language context at point" which is interesting) (Just getting started, so forgive me if this is documented somewhere I haven't seen yet.)

💡 3
🙏 2
Dustin Getz22:07:09

i haven’t figured clj kondo out yet, i turned it off

Dustin Getz22:07:55

i am feeling more fluent now in vscode though (i switched) so can possibly start figuring it out this week

Dustin Getz22:07:35

i’m assuming it would be the same as emacs

Garrett Hopper22:07:16

I figure I probably could just add a reader conditional around every context switch, though that feels a bit verbose Curious if the two could be done together somehow :thinking_face: Thanks anyways; things are looking very exciting 😁

lilactown22:07:41

a good question for #CHY97NXE2 - my guess is you'll need to write a custom hook. I'm not sure if custom hooks can control that context, though

Dustin Getz22:07:52

there are some old threads here as well with borkdude comments

sergey.shvets00:07:08

You can completely ignore specific forms (and everything inside) like this:

$ clj-kondo --lint - --config '{:config-in-call {shadow.cljs.modern/defclass {:ignore true}}}' <<< "(require '[shadow.cljs.modern :as m]) (m/defclass 1 2 x y z)"
linting took 39ms, errors: 0, warnings: 0
Or if the form replicates some existing clojure form exactly you can do like that:
{:lint-as {shadow.cljs.modern/defclass clj-kondo.lint-as/def-catch-all}}}
I'm yet to try electric so not sure what will work better, but I think one of the approaches will work.

👀 2
borkdude09:07:08

I'm willing to look into this a bit, I'm not yet sure how support for electric would work

Dustin Getz12:07:42

i think a lot of the lint rules simply do not apply (unless the strategy is changed)

borkdude12:07:24

Ok we can simply shut off the linter in certain electric macros

Dustin Getz12:07:24

that seems to be about the same as shutting it off entirely, because the macros nest

👍 2
Dustin Getz12:07:40

(I think it's fine to shut it off entirely in Electric regions for a while while we learn more from experience, it will at least make the errors go away)

J15:07:17

I use {:ignore [:unresolved-namespace]}

👍 2