tamzinblake / js3-mode

A chimeric fork of js2-mode and js-mode
GNU General Public License v3.0
181 stars 13 forks source link

function indenting in function arguments is stupid #41

Closed tamzinblake closed 12 years ago

tamzinblake commented 12 years ago

it does:

    Crafty.load(['sprite.png'], function() {
                   Crafty.scene('main')
    })

Should be:

    Crafty.load(['sprite.png'], function() {
      Crafty.scene('main')
    })

or:

    Crafty.load(['sprite.png'], function() {
                                  Crafty.scene('main')
    })
tamzinblake commented 12 years ago

One problem is that the preferred indentation level isn't obvious. In the following case, you want function bodies indented past the function keyword to be clear:

Crafty.load( ['sprite.png']
           , function () {
               Crafty.scene('main')
             }
           , function () {
               foo()
             }
           )

But in most cases, you'll only pass one function to a function and it will look more like:

    Crafty.load(['sprite.png'], function() {
      Crafty.scene('main')
      return DoLotsOfStuff + UseReallyLongNames * Makethisfunctionunreadablein80charwidth
    })

So which indentation is correct, or how do we disambiguate between the two? Is the indentation difference just caused by whether the function keyword is on a different line than the opening brace of its parent?