-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
Fix clojure-sort-ns with comments in the end #646
Changes from 2 commits
74550a9
b53c714
4c81348
4e5cc6b
357cfc2
3d4fc8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,18 @@ | |
(:require [my-app.views [user-page :as user-page]] | ||
[rum.core :as rum] ;comment\n))"))) | ||
|
||
(it "should sort requires in a basic ns with comments in the end" | ||
(with-clojure-buffer "(ns my-app.core | ||
(:require [rum.core :as rum] ;comment | ||
[my-app.views [user-page :as user-page]] | ||
;;[comment2]\n))" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please let's have an additional test case looking like this: ;; Copyright (c) John Doe. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
(ns clojure.core
(:require
;; The first comment (note that it starts with "T")
[foo] ;; foo comment
;; Middle comment
[bar] ;; bar comment
;; A last comment (note that it starts with "A")
)) ...not that supporting such a ns is tremendouly important, but it can helps us make sure the fix will have an overall great quality. The copyright header part should remain untouched (certainly not sorted a-z). I don't have a fixed expectation for the other comments (i.e. do they get sorted? Placed at the bottom? Beginning?). If the current code works (i.e. doesn't loop) and emits something reasonable, we would ship that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the above test case. The docstring for fn Based on this the last comment does't belong to any import. My change here ignores this last comment before sorting the imports/requires. |
||
(clojure-sort-ns) | ||
(expect (buffer-string) :to-equal | ||
"(ns my-app.core | ||
(:require [my-app.views [user-page :as user-page]] | ||
[rum.core :as rum] ;comment\n | ||
;;[comment2]\n))"))) | ||
|
||
(it "should also sort imports in a ns" | ||
(with-clojure-buffer "\n(ns my-app.core | ||
(:require [my-app.views [front-page :as front-page]] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit surprising to see
\n
in addition to line breaks. I'd prefer if we only had line breaks(I see it's also in existing tests. Good to change also)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the
\n
s to linebreaks.