Skip to content

Commit 5fb638d

Browse files
committed
JS Style Guide: Remove spacing exceptions
Closes gh-104
1 parent 4a78b48 commit 5fb638d

File tree

1 file changed

+27
-49
lines changed

1 file changed

+27
-49
lines changed

pages/style-guide/js.md

+27-49
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,33 @@ try {
102102
} catch ( e ) {
103103
// Expressions
104104
}
105+
106+
array = [ "*" ];
107+
108+
array = [ a, b ];
109+
110+
foo( arg );
111+
112+
foo( options, object[ property ] );
113+
114+
foo( [ a, b ], "property", { c: d } );
115+
116+
foo( { a: "alpha", b: "beta" } );
117+
118+
foo( [ a, b ] );
119+
120+
foo( {
121+
a: "alpha",
122+
b: "beta"
123+
} );
124+
125+
foo( function() {
126+
// Do stuff
127+
}, options );
128+
129+
foo( data, function() {
130+
// Do stuff
131+
} );
105132
```
106133

107134

@@ -172,55 +199,6 @@ array = [
172199
```
173200

174201

175-
### Array and Function Call Spacing
176-
177-
Always include extra spaces around elements and arguments:
178-
179-
```js
180-
array = [ "*" ];
181-
182-
array = [ a, b ];
183-
184-
foo( arg );
185-
186-
foo( "string", object );
187-
188-
foo( options, object[ property ] );
189-
190-
foo( node, "property", 2 );
191-
192-
foo( [ a, b ], "property", { c: d } );
193-
```
194-
195-
Exceptions:
196-
197-
```js
198-
// Function with a single line object or array as the sole argument:
199-
// No space on either side of the argument
200-
foo({ a: "alpha", b: "beta" });
201-
foo([ a, b ]);
202-
203-
// Function with a multiline callback, object, or array as the sole argument:
204-
// No space on either side of the argument
205-
foo({
206-
a: "alpha",
207-
b: "beta"
208-
});
209-
210-
// Function with a multiline callback, object, or array as the first argument:
211-
// No space before the first argument
212-
foo(function() {
213-
// Do stuff
214-
}, options );
215-
216-
// Function with a multiline callback, object, or array as the last argument:
217-
// No space after after the last argument
218-
foo( data, function() {
219-
// Do stuff
220-
});
221-
```
222-
223-
224202
### Multi-line Statements
225203

226204
When a statement is too long to fit on one line, line breaks must occur after an operator.

0 commit comments

Comments
 (0)