Skip to content

Commit b32d3c0

Browse files
committed
JS Style Guide: Fix full file closures
Closes gh-106
1 parent 5082a86 commit b32d3c0

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

pages/style-guide/js.md

+19-11
Original file line numberDiff line numberDiff line change
@@ -246,47 +246,55 @@ elements
246246
When an entire file is wrapped in a closure, the body of the closure is not indented.
247247

248248
```js
249-
(function( $ ) {
249+
( function( $ ) {
250250

251-
// this doesn't get indented
251+
// This doesn't get indented
252252

253-
})( jQuery );
253+
} )( jQuery );
254+
```
255+
256+
```js
257+
module.exports = function( grunt ) {
258+
259+
// This doesn't get indented
260+
261+
};
254262
```
255263

256264
The same applies to AMD wrappers.
257265

258266
```js
259-
define([
267+
define( [
260268
"foo",
261269
"bar",
262270
"baz"
263271
], function( foo, bar, baz ) {
264272

265-
// this doesn't get indented
273+
// This doesn't get indented
266274

267-
});
275+
} );
268276
```
269277

270278
For UMD, the factory is indented to visually differentiate it from the body.
271279

272280
```js
273-
(function( factory ) {
281+
( function( factory ) {
274282
if ( typeof define === "function" && define.amd ) {
275283

276284
// AMD. Register as an anonymous module.
277-
define([
285+
define( [
278286
"jquery"
279287
], factory );
280288
} else {
281289

282290
// Browser globals
283291
factory( jQuery );
284292
}
285-
}(function( $ ) {
293+
}( function( $ ) {
286294

287-
// this doesn't get indented
295+
// This doesn't get indented
288296

289-
}));
297+
} ) );
290298
```
291299

292300
## Equality

0 commit comments

Comments
 (0)