Skip to content

Commit a1fbe20

Browse files
committed
JS Style Guide: Drop onevar as a requirement
There are various reasons why onevar is bad, like always changing unrelated lines when adding or removing variables. jshint actually remove the onevar option recently. Instead of specifying how variables should be declared without onevar, I've removed the entire Assignments section. We can bring it back in the future when there is consensus, if its needed at all. Also removes two unnecessary blank lines in unrelated code example. Closes #105
1 parent 0736bbe commit a1fbe20

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

pages/style-guide/js.md

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ The following common options must be used in all projects:
3535
"expr": true,
3636
"immed": true,
3737
"noarg": true,
38-
"onevar": true,
3938
"quotmark": "double",
4039
"smarttabs": true,
4140
"trailing": true,
@@ -68,12 +67,10 @@ In general, the jQuery style guide encourages liberal spacing for improved human
6867
### Bad Examples
6968

7069
```js
71-
7270
// Bad
7371
if(condition) doSomething();
7472
while(!condition) iterating++;
7573
for(var i=0;i<100;i++) object[array[i]] = someFn(i);
76-
7774
```
7875

7976
### Good Examples
@@ -292,50 +289,6 @@ For UMD, the factory is indented to visually differentiate it from the body.
292289
}));
293290
```
294291

295-
## Assignments
296-
297-
Assignments in a declaration must be on their own line. Declarations that don't have an assignment must be listed together at the start of the declaration. Each line after the initial line must be indented once. For example:
298-
299-
```js
300-
// Bad
301-
var foo = true;
302-
var bar = false;
303-
var a;
304-
var b;
305-
var c;
306-
307-
// Good
308-
var a, b, c,
309-
foo = true,
310-
bar = false,
311-
obj = {
312-
a: b,
313-
c: d,
314-
},
315-
arr = [
316-
a,
317-
b,
318-
c
319-
],
320-
fn = function() {
321-
body();
322-
};
323-
```
324-
325-
Exception: When a declaration has a single multiline assignment, the subsequent lines are not indented.
326-
327-
```js
328-
// Good
329-
var fn = function() {
330-
body();
331-
};
332-
333-
// Bad
334-
var fn = function() {
335-
body();
336-
};
337-
```
338-
339292
## Equality
340293

341294
Strict equality checks (`===`) must be used in favor of abstract equality checks (`==`). The _only_ exception is when checking for `undefined` and `null` by way of `null`.

0 commit comments

Comments
 (0)