Javascript: formatting
-
Thomas George wrote:
What do you do?
i do what i do to all pedants: i point at laugh
-
JsLint (http://www.jslint.com/[^]) includes "Strict whitespace" in its recommended options. How many of you use JsLint, and how many of you follow that formatting guideline? I like to write code as function() { } JsLint wants me to write it as: function() { } What do you do?
Thomas George wrote:
What do you do?
copy & paste ;P
----------------------------------------------------------- Completion Deadline: two days before the day after tomorrow
-
Thomas George wrote:
What do you do?
copy & paste ;P
----------------------------------------------------------- Completion Deadline: two days before the day after tomorrow
-
JsLint (http://www.jslint.com/[^]) includes "Strict whitespace" in its recommended options. How many of you use JsLint, and how many of you follow that formatting guideline? I like to write code as function() { } JsLint wants me to write it as: function() { } What do you do?
Thomas George wrote:
function() { }
As i've grown as a coder, i've started adapting this style. I find it makes code just look more professional... i don't know.
-
Thomas George wrote:
function() { }
As i've grown as a coder, i've started adapting this style. I find it makes code just look more professional... i don't know.
-
JsLint (http://www.jslint.com/[^]) includes "Strict whitespace" in its recommended options. How many of you use JsLint, and how many of you follow that formatting guideline? I like to write code as function() { } JsLint wants me to write it as: function() { } What do you do?
function() { ... }
;P But yeah, i stay away from K&R-style braces. I'm sure they were a great way to save paper back in the day, but now i'd rather see my braces line up.
Citizen 20.1.01
'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'
-
JsLint (http://www.jslint.com/[^]) includes "Strict whitespace" in its recommended options. How many of you use JsLint, and how many of you follow that formatting guideline? I like to write code as function() { } JsLint wants me to write it as: function() { } What do you do?
JSLint scared the bejeezus out of me at first look - my code was apparently riddled with problems, but on closer inspection, most of the stuff can be turned off (though I can see why they recommend most of the rules...) :) The documentation page explains why it dislikes some things - mostly because of potential tpyos as far as I can tell (like banning ++ since it can easilly by typed as + +)
C# has already designed away most of the tedium of C++.
-
JSLint scared the bejeezus out of me at first look - my code was apparently riddled with problems, but on closer inspection, most of the stuff can be turned off (though I can see why they recommend most of the rules...) :) The documentation page explains why it dislikes some things - mostly because of potential tpyos as far as I can tell (like banning ++ since it can easilly by typed as + +)
C# has already designed away most of the tedium of C++.
RichardGrimmer wrote:
JSLint scared the bejeezus out of me at first look
It told me that after 35% of my .js file, it found 150 errors without the formatting turned on. I was writing javascript after a long time, and did many things wrong. Still, it ran well. :omg: There were so many semicolons missing, typos in variable names, declaring local variables as globals. JsLint showed me how much of a mess I had written. Now, I have no errors at all excluding formatting. I can't look at the KR style braces, though. :)
-
Thomas George wrote:
function() { }
As i've grown as a coder, i've started adapting this style. I find it makes code just look more professional... i don't know.
-
JsLint (http://www.jslint.com/[^]) includes "Strict whitespace" in its recommended options. How many of you use JsLint, and how many of you follow that formatting guideline? I like to write code as function() { } JsLint wants me to write it as: function() { } What do you do?
I'm fairly new to Javascript, but I also like to compact things a bit so that I don't get lost in pages and pages, so I kind of prefer the function() { } way of doing things, particularly for nested brackets. But only so long as it remains easy to find/correct/read. :cool:
_________________________________________________ Have a great day!!! -- L.J.
-
I'm fairly new to Javascript, but I also like to compact things a bit so that I don't get lost in pages and pages, so I kind of prefer the function() { } way of doing things, particularly for nested brackets. But only so long as it remains easy to find/correct/read. :cool:
_________________________________________________ Have a great day!!! -- L.J.
I find myself doing if (condition) { statement 1; statement 2; } else { statement3; statement 4; } as long as it remains within reasonable width. I write small functions too in a single line. function() { } But for longer functions, I prefer the function { } than function { } I find it much easier to line up braces.
-
JsLint (http://www.jslint.com/[^]) includes "Strict whitespace" in its recommended options. How many of you use JsLint, and how many of you follow that formatting guideline? I like to write code as function() { } JsLint wants me to write it as: function() { } What do you do?
For JavaScript I tend to follow the majority of the code and do
function() {
}but for all other languages such as C# and C I do
function()
{
}I don't prefer either but for C# I hate to see code other than the way I write it, for JavaScript I prefer the K&R style. Perhaps I'm slightly swayed by the fact that in JS it's slightly more compact thus less overhead to transfer (stupid but I always have that thought in the back of my head).
-
JsLint (http://www.jslint.com/[^]) includes "Strict whitespace" in its recommended options. How many of you use JsLint, and how many of you follow that formatting guideline? I like to write code as function() { } JsLint wants me to write it as: function() { } What do you do?
Putting the start-of-block
{
anywhere but on a line by itself is Pure Evil(tm). If the{
is mixed in with another line, it becomes insanely hard to find the start of a block just by scanning.--Mike-- Visual C++ MVP :cool: LINKS~! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ "That's what's great about doing user interface work. No matter what you do, people will say that what you did was idiotic." -- Raymond Chen