[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8576: js-mode doesn't support multi-line variable declarations
From: |
Zeth |
Subject: |
bug#8576: js-mode doesn't support multi-line variable declarations |
Date: |
Sat, 03 Mar 2012 01:46:27 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
Hello Emacs people,
Daniel Colascione in message 8 said:
"Additionally, this construct is relatively rare; if you're going to
split variable declarations across several lines, you might as well use
another "var"."
Actually the format required by JSLint, for good reason, is that one
single var statement per function, at the very start of the function, i.e.:
var name, another-name, another-name;
When you have more than 80 characters worth of variable declarations,
you need to start a new line:
var first-name, second-name, third-name,
fourth-name, fifth-name;
The first-name and fourth-name above should align (i.e. the second and
subsequent lines should be indented by 4 characters).
Emacs does not highlight the second and subsequent lines correctly, and
it does not indent them correctly either.
This is a shame because in all other respects, Emacs indents and
highlights in the way you would expect when following the demands of JSLint.
(JSLint demands this behaviour to avoid making hoisting and scoping
mistakes, i.e. those used to other languages with block scope might
believe the placement of var statements further down in a function
implies that a variable is not defined yet, when actually it is.)
Best Wishes,
Zeth
- bug#8576: js-mode doesn't support multi-line variable declarations,
Zeth <=