Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit f55cb18

Browse files
Joe Bartletthzoo
authored andcommitted
1 parent c704e9e commit f55cb18

File tree

2 files changed

+46
-41
lines changed

2 files changed

+46
-41
lines changed

presets/airbnb.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
"disallowSpacesInNamedFunctionExpression": {
44
"beforeOpeningRoundBrace": true
55
},
6-
"disallowSpacesInFunctionExpression": {
7-
"beforeOpeningRoundBrace": true
8-
},
9-
"disallowSpacesInAnonymousFunctionExpression": {
10-
"beforeOpeningRoundBrace": true
11-
},
126
"disallowSpacesInFunctionDeclaration": {
137
"beforeOpeningRoundBrace": true
148
},
@@ -38,6 +32,10 @@
3832
"disallowSpaceBeforeSemicolon": true,
3933
"requireSpaceBeforeBlockStatements": true,
4034
"requireParenthesesAroundIIFE": true,
35+
"requireSpacesInAnonymousFunctionExpression": {
36+
"beforeOpeningRoundBrace": true,
37+
"allExcept": ["shorthand"]
38+
},
4139
"requireSpacesInConditionalExpression": true,
4240
"requireBlocksOnNewline": 1,
4341
"requireCommaBeforeLineBreak": true,

test/data/options/preset/airbnb.js

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// requireParenthesesAroundIIFE
2-
(function(window) {
2+
(function (window) {
33
<Foo
44
superLongParam="bar"
55
anotherSuperLongParam="baz"
@@ -60,7 +60,7 @@
6060
var api = {
6161
// disallowQuotedKeysInObjects
6262
// disallowSpaceAfterObjectKeys
63-
foo: function() {
63+
foo: function () {
6464
// safeContextKeyword
6565
var _this = this;
6666

@@ -69,7 +69,7 @@
6969
var _priv = 'yo';
7070

7171
// disallowEmptyBlocks
72-
return function() {
72+
return function () {
7373
// requireSpaceBetweenArguments
7474
console.log('bar', 'foo');
7575
};
@@ -82,26 +82,33 @@
8282
return api;
8383
}
8484

85+
// https://github.com/airbnb/javascript#7.11
86+
(function () {
87+
const x = function () {};
88+
89+
const y = function a() {};
90+
})();
91+
8592
// requireCapitalizedConstructors
8693
function Bar() {}
8794

8895
// https://github.com/airbnb/javascript
8996

90-
(function() {
97+
(function () {
9198
const foo = 1;
9299
let bar = foo;
93100

94101
bar = 9;
95102
})();
96103

97-
(function() {
104+
(function () {
98105
const foo = [1, 2];
99106
const bar = foo;
100107

101108
bar[0] = 9;
102109
})();
103110

104-
(function() {
111+
(function () {
105112
function getKey(k) {
106113
return `a key named ${k}`;
107114
}
@@ -113,7 +120,7 @@
113120
};
114121
})();
115122

116-
(function() {
123+
(function () {
117124
const atom = {
118125
value: 1,
119126

@@ -123,15 +130,15 @@
123130
};
124131
})();
125132

126-
(function() {
133+
(function () {
127134
const lukeSkywalker = 'Luke Skywalker';
128135

129136
const obj = {
130137
lukeSkywalker,
131138
};
132139
})();
133140

134-
(function() {
141+
(function () {
135142
const anakinSkywalker = 'Anakin Skywalker';
136143
const lukeSkywalker = 'Luke Skywalker';
137144

@@ -145,35 +152,35 @@
145152
};
146153
})();
147154

148-
(function() {
155+
(function () {
149156
const someStack = [];
150157
someStack.push('abracadabra');
151158
})();
152159

153-
(function() {
160+
(function () {
154161
const items = [1, 2, 3];
155162
const itemsCopy = [...items];
156163
})();
157164

158-
(function() {
165+
(function () {
159166
function getFullName(obj) {
160167
const { firstName, lastName } = obj;
161168
return `${firstName} ${lastName}`;
162169
}
163170
})();
164171

165-
(function() {
172+
(function () {
166173
function getFullName({ firstName, lastName }) {
167174
return `${firstName} ${lastName}`;
168175
}
169176
})();
170177

171-
(function() {
178+
(function () {
172179
const arr = [1, 2, 3, 4];
173180
const [first, second] = arr;
174181
})();
175182

176-
(function() {
183+
(function () {
177184
// good
178185
function processInput(input) {
179186
// then a miracle occurs
@@ -184,13 +191,13 @@
184191
const { left, right } = processInput(input);
185192
})();
186193

187-
(function() {
194+
(function () {
188195
const errorMessage = 'This is a super long error that was thrown because ' +
189196
'of Batman. When you stop to think about how Batman had anything to do ' +
190197
'with this, you would get nowhere fast.';
191198
})();
192199

193-
(function() {
200+
(function () {
194201
let test;
195202
if (currentUser) {
196203
test = () => {
@@ -199,19 +206,19 @@
199206
}
200207
})();
201208

202-
(function() {
209+
(function () {
203210
function concatenateAll(...args) {
204211
return args.join('');
205212
}
206213
})();
207214

208-
(function() {
215+
(function () {
209216
[1, 2, 3].map((x) => {
210217
return x * x;
211218
});
212219
})();
213220

214-
(function() {
221+
(function () {
215222
// good
216223
[1, 2, 3].map(x => x * x);
217224

@@ -221,7 +228,7 @@
221228
}, 0);
222229
})();
223230

224-
(function() {
231+
(function () {
225232
class Queue {
226233
constructor(contents = []) {
227234
this._queue = [...contents];
@@ -240,7 +247,7 @@
240247
}
241248
})();
242249

243-
(function() {
250+
(function () {
244251
class Jedi {
245252
jump() {
246253
this.jumping = true;
@@ -259,7 +266,7 @@
259266
.setHeight(20);
260267
})();
261268

262-
(function() {
269+
(function () {
263270
class Jedi {
264271
contructor(options = {}) {
265272
this.name = options.name || 'no name';
@@ -275,7 +282,7 @@
275282
}
276283
})();
277284

278-
(function() {
285+
(function () {
279286
// good
280287
let sum = 0;
281288
numbers.forEach((num) => sum += num);
@@ -286,15 +293,15 @@
286293
sum === 15;
287294
})();
288295

289-
(function() {
296+
(function () {
290297
const goSportsTeam = true;
291298
const items = getItems();
292299
let dragonball;
293300
let i;
294301
let length;
295302
})();
296303

297-
(function() {
304+
(function () {
298305
$('#items')
299306
.find('.selected')
300307
.highlight()
@@ -303,7 +310,7 @@
303310
.updateCount();
304311
})();
305312

306-
(function() {
313+
(function () {
307314
const leds = stage.selectAll('.led')
308315
.data(data)
309316
.enter().append('svg:svg')
@@ -315,15 +322,15 @@
315322
})();
316323

317324
// https://github.com/airbnb/javascript#18.6
318-
(function() {
325+
(function () {
319326
if (foo) {
320327
return bar;
321328
}
322329

323330
return baz;
324331
})();
325332

326-
(function() {
333+
(function () {
327334
const obj = {
328335
foo() {
329336
},
@@ -333,7 +340,7 @@
333340
};
334341
})();
335342

336-
(function() {
343+
(function () {
337344
const arr = [
338345
function foo() {
339346
},
@@ -345,7 +352,7 @@
345352
return arr;
346353
})();
347354

348-
(function() {
355+
(function () {
349356
const story = [
350357
once,
351358
upon,
@@ -359,7 +366,7 @@
359366
};
360367
})();
361368

362-
(function() {
369+
(function () {
363370
const totalScore = String(this.reviewScore);
364371
const inputValue = '4';
365372
const val = Number(inputValue);
@@ -376,7 +383,7 @@
376383
const hasAge = !!age;
377384
})();
378385

379-
(function() {
386+
(function () {
380387
const thisIsMyObject = {};
381388
function thisIsMyFunction() {}
382389

@@ -391,15 +398,15 @@
391398
});
392399
})();
393400

394-
(function() {
401+
(function () {
395402
function foo() {
396403
return () => {
397404
console.log(this);
398405
};
399406
}
400407
})();
401408

402-
(function() {
409+
(function () {
403410
})();
404411

405412
})(window);

0 commit comments

Comments
 (0)