clojure-emacs / clojure-emacs/refactor-nrepl

Don't unwrap CLJC lib specs when cleaning a namespace

Open
#266 4 comments 4 reactions 0 assignees View on GitHub
enhancement
Dominant language
Clojure
Stars
262
Forks
68
PR merge metrics
No merged PRs in 30d

Description

We have a namespace like this:

```cljc
(ns my.app.ns
(:require [vlad.core :as vlad :refer [attr chain join present Validation]]
#? (:cljs [goog.date.Interval :as Interval])
[clojure.string :as string]
[cemerick.url :as url]))
```

after running `cljr-clean-ns`, it fully expands the clj and cljs versions to:

```cljc
(ns my.app.ns
#?@
(:clj
[(:require
[cemerick.url :as url]
[clojure.string :as string]
[vlad.core :as vlad :refer [attr chain join present Validation]])]
:cljs
[(:require
[cemerick.url :as url]
[clojure.string :as string]
[goog.date.Interval :as Interval]
[vlad.core :as vlad :refer [attr chain join present Validation]])]))
```

This namespace form is twice as long, and (IMO) obscures which parts of the namespace differ between clj and cljs. To tell the difference, you need to check each line and find the corresponding one in the other branch.

Would you consider a feature request to not fully expand CLJC forms in the `:require`?

I'd argue this should be the default behaviour, but could also see it being an option if people liked this kind of expansion. The new feature wouldn't automatically convert fully expanded CLJC forms back, it would just preserve what was already there.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.