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

Remove clj-kondo config output for cljs schemas #662

Merged
merged 2 commits into from
Mar 20, 2022

Conversation

dvingo
Copy link
Contributor

@dvingo dvingo commented Mar 9, 2022

I have been trying this out and unfortunately realized that kondo support will not be so simple.

If the cljs schemas use vars that are only available during the cljs runtime
we do not have access to them during macroexpansion and thus will cause exceptions.

This line

schema (if (= :function (m/type schema)) schema (m/into-schema :function nil [schema] (m/options schema)))]

will attempt to construct a malli schema and if there any symbols that represent clojurescript variables then there is no way to know their values in clojure.

For now I think removing the kondo support makes sense to allow the instrumentation to work.

As an alternative, we could potentially add clojurescript code that will print out the kondo config to the javascript console when all the vars are available and the user can copy it to the condo config file. I know it's not a great solution but at least provides some value.

update: I added a printer helper for cljs.

dvingo added 2 commits March 8, 2022 23:28
If the cljs schemas use vars that are only available during the cljs runtime
we do not have access to them during macroexpansion and thus will cause exceptions.
@kovasap
Copy link

kovasap commented Mar 20, 2022

Could you update the documentation to describe how this copy-pasting would work?

Also, is there anything I can do to help get this merged?

@ikitommi
Copy link
Member

Bummer, I really would love the get the clj-kondo to work. Merging in.

@ikitommi ikitommi merged commit 68bb521 into metosin:master Mar 20, 2022
@ikitommi
Copy link
Member

Could we uses delay or similar? just register something that will be later available. when dev/start! is called, everything should be ready, right?

@dvingo
Copy link
Contributor Author

dvingo commented Mar 20, 2022

I'm not sure how to make this happen. The fundamental problem is that the kondo config is emitted at compile (macro-expansion) time, but the values needed to construct that config are only available at runtime.
For JS running in a browser, there is no access to the filesystem, so some other ideas would be:

  • add a browser js function that will trigger a file download dialog containing the kondo config, a user would run this from a REPL.
  • add a function that copies the kondo config to your clipboard (just saves the step a user would have to do with the current console.log helper)
  • implement kondo file emission using node.js - but I'm guessing most users will be targeting browsers so this may cause its own problems when browser APIs aren't available in node environments.

@dvingo dvingo deleted the fix-cljs-kondo-support branch May 5, 2023 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants