|
1 | 1 | // requireParenthesesAroundIIFE |
2 | | -(function(window) { |
| 2 | +(function (window) { |
3 | 3 | <Foo |
4 | 4 | superLongParam="bar" |
5 | 5 | anotherSuperLongParam="baz" |
|
60 | 60 | var api = { |
61 | 61 | // disallowQuotedKeysInObjects |
62 | 62 | // disallowSpaceAfterObjectKeys |
63 | | - foo: function() { |
| 63 | + foo: function () { |
64 | 64 | // safeContextKeyword |
65 | 65 | var _this = this; |
66 | 66 |
|
|
69 | 69 | var _priv = 'yo'; |
70 | 70 |
|
71 | 71 | // disallowEmptyBlocks |
72 | | - return function() { |
| 72 | + return function () { |
73 | 73 | // requireSpaceBetweenArguments |
74 | 74 | console.log('bar', 'foo'); |
75 | 75 | }; |
|
82 | 82 | return api; |
83 | 83 | } |
84 | 84 |
|
| 85 | + // https://github.com/airbnb/javascript#7.11 |
| 86 | + (function () { |
| 87 | + const x = function () {}; |
| 88 | + |
| 89 | + const y = function a() {}; |
| 90 | + })(); |
| 91 | + |
85 | 92 | // requireCapitalizedConstructors |
86 | 93 | function Bar() {} |
87 | 94 |
|
88 | 95 | // https://github.com/airbnb/javascript |
89 | 96 |
|
90 | | - (function() { |
| 97 | + (function () { |
91 | 98 | const foo = 1; |
92 | 99 | let bar = foo; |
93 | 100 |
|
94 | 101 | bar = 9; |
95 | 102 | })(); |
96 | 103 |
|
97 | | - (function() { |
| 104 | + (function () { |
98 | 105 | const foo = [1, 2]; |
99 | 106 | const bar = foo; |
100 | 107 |
|
101 | 108 | bar[0] = 9; |
102 | 109 | })(); |
103 | 110 |
|
104 | | - (function() { |
| 111 | + (function () { |
105 | 112 | function getKey(k) { |
106 | 113 | return `a key named ${k}`; |
107 | 114 | } |
|
113 | 120 | }; |
114 | 121 | })(); |
115 | 122 |
|
116 | | - (function() { |
| 123 | + (function () { |
117 | 124 | const atom = { |
118 | 125 | value: 1, |
119 | 126 |
|
|
123 | 130 | }; |
124 | 131 | })(); |
125 | 132 |
|
126 | | - (function() { |
| 133 | + (function () { |
127 | 134 | const lukeSkywalker = 'Luke Skywalker'; |
128 | 135 |
|
129 | 136 | const obj = { |
130 | 137 | lukeSkywalker, |
131 | 138 | }; |
132 | 139 | })(); |
133 | 140 |
|
134 | | - (function() { |
| 141 | + (function () { |
135 | 142 | const anakinSkywalker = 'Anakin Skywalker'; |
136 | 143 | const lukeSkywalker = 'Luke Skywalker'; |
137 | 144 |
|
|
145 | 152 | }; |
146 | 153 | })(); |
147 | 154 |
|
148 | | - (function() { |
| 155 | + (function () { |
149 | 156 | const someStack = []; |
150 | 157 | someStack.push('abracadabra'); |
151 | 158 | })(); |
152 | 159 |
|
153 | | - (function() { |
| 160 | + (function () { |
154 | 161 | const items = [1, 2, 3]; |
155 | 162 | const itemsCopy = [...items]; |
156 | 163 | })(); |
157 | 164 |
|
158 | | - (function() { |
| 165 | + (function () { |
159 | 166 | function getFullName(obj) { |
160 | 167 | const { firstName, lastName } = obj; |
161 | 168 | return `${firstName} ${lastName}`; |
162 | 169 | } |
163 | 170 | })(); |
164 | 171 |
|
165 | | - (function() { |
| 172 | + (function () { |
166 | 173 | function getFullName({ firstName, lastName }) { |
167 | 174 | return `${firstName} ${lastName}`; |
168 | 175 | } |
169 | 176 | })(); |
170 | 177 |
|
171 | | - (function() { |
| 178 | + (function () { |
172 | 179 | const arr = [1, 2, 3, 4]; |
173 | 180 | const [first, second] = arr; |
174 | 181 | })(); |
175 | 182 |
|
176 | | - (function() { |
| 183 | + (function () { |
177 | 184 | // good |
178 | 185 | function processInput(input) { |
179 | 186 | // then a miracle occurs |
|
184 | 191 | const { left, right } = processInput(input); |
185 | 192 | })(); |
186 | 193 |
|
187 | | - (function() { |
| 194 | + (function () { |
188 | 195 | const errorMessage = 'This is a super long error that was thrown because ' + |
189 | 196 | 'of Batman. When you stop to think about how Batman had anything to do ' + |
190 | 197 | 'with this, you would get nowhere fast.'; |
191 | 198 | })(); |
192 | 199 |
|
193 | | - (function() { |
| 200 | + (function () { |
194 | 201 | let test; |
195 | 202 | if (currentUser) { |
196 | 203 | test = () => { |
|
199 | 206 | } |
200 | 207 | })(); |
201 | 208 |
|
202 | | - (function() { |
| 209 | + (function () { |
203 | 210 | function concatenateAll(...args) { |
204 | 211 | return args.join(''); |
205 | 212 | } |
206 | 213 | })(); |
207 | 214 |
|
208 | | - (function() { |
| 215 | + (function () { |
209 | 216 | [1, 2, 3].map((x) => { |
210 | 217 | return x * x; |
211 | 218 | }); |
212 | 219 | })(); |
213 | 220 |
|
214 | | - (function() { |
| 221 | + (function () { |
215 | 222 | // good |
216 | 223 | [1, 2, 3].map(x => x * x); |
217 | 224 |
|
|
221 | 228 | }, 0); |
222 | 229 | })(); |
223 | 230 |
|
224 | | - (function() { |
| 231 | + (function () { |
225 | 232 | class Queue { |
226 | 233 | constructor(contents = []) { |
227 | 234 | this._queue = [...contents]; |
|
240 | 247 | } |
241 | 248 | })(); |
242 | 249 |
|
243 | | - (function() { |
| 250 | + (function () { |
244 | 251 | class Jedi { |
245 | 252 | jump() { |
246 | 253 | this.jumping = true; |
|
259 | 266 | .setHeight(20); |
260 | 267 | })(); |
261 | 268 |
|
262 | | - (function() { |
| 269 | + (function () { |
263 | 270 | class Jedi { |
264 | 271 | contructor(options = {}) { |
265 | 272 | this.name = options.name || 'no name'; |
|
275 | 282 | } |
276 | 283 | })(); |
277 | 284 |
|
278 | | - (function() { |
| 285 | + (function () { |
279 | 286 | // good |
280 | 287 | let sum = 0; |
281 | 288 | numbers.forEach((num) => sum += num); |
|
286 | 293 | sum === 15; |
287 | 294 | })(); |
288 | 295 |
|
289 | | - (function() { |
| 296 | + (function () { |
290 | 297 | const goSportsTeam = true; |
291 | 298 | const items = getItems(); |
292 | 299 | let dragonball; |
293 | 300 | let i; |
294 | 301 | let length; |
295 | 302 | })(); |
296 | 303 |
|
297 | | - (function() { |
| 304 | + (function () { |
298 | 305 | $('#items') |
299 | 306 | .find('.selected') |
300 | 307 | .highlight() |
|
303 | 310 | .updateCount(); |
304 | 311 | })(); |
305 | 312 |
|
306 | | - (function() { |
| 313 | + (function () { |
307 | 314 | const leds = stage.selectAll('.led') |
308 | 315 | .data(data) |
309 | 316 | .enter().append('svg:svg') |
|
315 | 322 | })(); |
316 | 323 |
|
317 | 324 | // https://github.com/airbnb/javascript#18.6 |
318 | | - (function() { |
| 325 | + (function () { |
319 | 326 | if (foo) { |
320 | 327 | return bar; |
321 | 328 | } |
322 | 329 |
|
323 | 330 | return baz; |
324 | 331 | })(); |
325 | 332 |
|
326 | | - (function() { |
| 333 | + (function () { |
327 | 334 | const obj = { |
328 | 335 | foo() { |
329 | 336 | }, |
|
333 | 340 | }; |
334 | 341 | })(); |
335 | 342 |
|
336 | | - (function() { |
| 343 | + (function () { |
337 | 344 | const arr = [ |
338 | 345 | function foo() { |
339 | 346 | }, |
|
345 | 352 | return arr; |
346 | 353 | })(); |
347 | 354 |
|
348 | | - (function() { |
| 355 | + (function () { |
349 | 356 | const story = [ |
350 | 357 | once, |
351 | 358 | upon, |
|
359 | 366 | }; |
360 | 367 | })(); |
361 | 368 |
|
362 | | - (function() { |
| 369 | + (function () { |
363 | 370 | const totalScore = String(this.reviewScore); |
364 | 371 | const inputValue = '4'; |
365 | 372 | const val = Number(inputValue); |
|
376 | 383 | const hasAge = !!age; |
377 | 384 | })(); |
378 | 385 |
|
379 | | - (function() { |
| 386 | + (function () { |
380 | 387 | const thisIsMyObject = {}; |
381 | 388 | function thisIsMyFunction() {} |
382 | 389 |
|
|
391 | 398 | }); |
392 | 399 | })(); |
393 | 400 |
|
394 | | - (function() { |
| 401 | + (function () { |
395 | 402 | function foo() { |
396 | 403 | return () => { |
397 | 404 | console.log(this); |
398 | 405 | }; |
399 | 406 | } |
400 | 407 | })(); |
401 | 408 |
|
402 | | - (function() { |
| 409 | + (function () { |
403 | 410 | })(); |
404 | 411 |
|
405 | 412 | })(window); |
0 commit comments