Comments (1)
Two of those cases should be easy to solve without controversy. Just remove all trailing whitespace on non-empty lines and decide on wether to have zero or one trailing empty line at the end of the files.
As for the empty lines within a form, I personally think they can always be removed.
Of course, an editor might, and probably will, relax these rules while code is being entered and enforce them more strictly on save and on command.
Let me add what I think might be a trickier one to agree on:
Between top level forms
Some people suggest to use two lines. Having tried that, I have kind of started to like it. But I am not using it for all forms.
(def foo :foo)
(def bar :bar)
(defn re-pos-first
"Find position of first match of `re` in `s`"
[re s]
(if-let [m (.match s re)]
(.-index m)
-1))
(defn split-into-lines
[s]
(clojure.string/split s #"\r?\n" -1))
(defn enclosing? [text]
(let [ast (cljify (paredit/parse text))
children (:children ast)]
(and (= 1 (count children))
(= "list" (:type (first children))))))
I think the pattern I follow might be that forms that are often one-liners get zero lines between them and otherwise I opt for two. Maybe the formatter could use these rules:
- No empty lines between one-liner forms
- X (whatever we agree on) empty newlines between multi-line forms, as well as between one-liner forms and multi-line forms.
from formatter.
Related Issues (11)
- Do we only support UTF-8 files?
- Reordering ns forms? HOT 1
- Should there be a space between #_ and the next form?
- How do we deal with comments? HOT 3
- Formatting reader conditionals
- Formatting map literals
- Formatting let bindings HOT 5
- Indentation HOT 41
- Empty lines between forms HOT 2
- Feature prioritization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formatter.