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

have cljr-clean-ns preserve :as requires for clojurescript npm deps #383

Closed
aiba opened this issue Jul 29, 2022 · 3 comments
Closed

have cljr-clean-ns preserve :as requires for clojurescript npm deps #383

aiba opened this issue Jul 29, 2022 · 3 comments

Comments

@aiba
Copy link
Contributor

aiba commented Jul 29, 2022

Issue

In clojurescript, :require :as with npm libraries works a little differently from jvm clojure's :require :as. This can lead to cljr-clean-ns removing requires that are needed. See also clojure-emacs/clj-refactor.el#476

Expected behavior

In both of the following cases, the require statement is needed, and I would expect cljr-clean-ns to not remove it.

(ns foo
  (:require ["@react-native-async-storage/async-storage" :as AsyncStorage])

(.getItem AsyncStorage "foo")
(ns foo
  (:require ["@react-native-async-storage/async-storage$default" :as AsyncStorage])

(.getItem AsyncStorage "foo")

Actual behavior

cljr-clean-ns removes the require in both cases.

Steps to reproduce the problem

Run cljr-clean-ns on either of the above sample code.

Environment & Version information

clj-refactor 3.5.4 (package: 20220717.2135), refactor-nrepl 3.5.3
CIDER 1.5.0-snapshot (package: 20220721.1551), nREPL 0.9.0
Clojure 1.11.1, Java 18.0.2
GNU Emacs 28.1 (build 2, aarch64-apple-darwin21.5.0, NS appkit-2113.50 Version 12.4 (Build 21F79)) of 2022-07-14
@vemv
Copy link
Member

vemv commented Jul 29, 2022

Got it. So, in cljs :as can also be considered a "refer".

Giving it a quick shot.

@vemv vemv transferred this issue from clojure-emacs/clj-refactor.el Jul 29, 2022
@vemv vemv closed this as completed in 061244f Jul 29, 2022
@vemv
Copy link
Member

vemv commented Jul 29, 2022

Fixed in refactor-nrepl 3.5.4 (released within a few minutes) and clj-refactor 3.5.5 (available in MELPA within a couple hours)

@aiba
Copy link
Contributor Author

aiba commented Jul 29, 2022

This is working perfectly, thank you! I'm running cljr-clean-ns probably 100 times a day at work, so this really helps out. Thank you again!

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