Giter Site home page Giter Site logo

Comments (1)

PEZ avatar PEZ commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.