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

Is it true that cljfmt can't compute alias map when used as a CLJS library? #200

Open
lread opened this issue Aug 2, 2020 · 3 comments
Open

Comments

@lread
Copy link
Contributor

lread commented Aug 2, 2020

I'm currently reviewing aspects of namespace handling for rewrite-cljc and came to cljfmt to review how it handles namespaces.

Under docs for alias-map we have:

:alias-map - a map of namespace alias strings to fully qualified namespace names. This option is unnecessary in almost all cases, because cljfmt can compute the alias map from an ns declaration.

However, it can't do that when used as a CLJS library, or when indenting something with no ns declaration like an EDN file.

After reviewing the code, I might be missing something or maybe I have a blind spot, but I'm not sure why cljfmt would not be able to parse out alias maps from a ns declaration when used as a CLJS library. Is that maybe a historical, rather than current, limitation?

If it is no longer a CLJS limitation, and with the understanding that :alias-map is still useful in other cases, I am happy to update the docs and tests accordingly.

@weavejester
Copy link
Owner

PR #109 has an explanation. At the time, rewrite-cljs didn't have the capabilities required. That may have changed, but I haven't checked.

@lread
Copy link
Contributor Author

lread commented Aug 3, 2020

Oh that's a wonderful PR description, thanks @weavejester (and @MatthewDarling). It states that the limitation is due to the current version of rewrite-cljs not being able to handle namespaced keywords #106 as evidenced here.

I am (oh so slowly) creating a successor for rewrite-cljs and rewrite-clj in rewrite-cljc, which should benefit tools like cljfmt.

I am hoping you are good with leaving this issue open while I work to reproduce an example of the limitation of parsing alias-maps from namespace declarations in cljfmt when using rewrite-cljs and then verify that is (or can be) resolved in rewrite-cljc.

@weavejester
Copy link
Owner

Yep, I'm fine with leaving it open.

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

No branches or pull requests

2 participants