ソースを参照

fix(eslint): Add no-else-return rule

dev1
hristoterezov 8年前
コミット
e4352d2188

+ 1
- 0
.eslintrc.js ファイルの表示

@@ -81,6 +81,7 @@ module.exports = {
81 81
         'no-caller': 2,
82 82
         'no-case-declarations': 2,
83 83
         'no-div-regex': 0,
84
+        'no-else-return': 2,
84 85
         'no-empty-pattern': 2,
85 86
         'no-eval': 2,
86 87
         'no-extend-native': 2,

+ 7
- 7
JitsiConference.js ファイルの表示

@@ -444,10 +444,10 @@ JitsiConference.prototype.addTrack = function(track) {
444 444
             // to attempt to add the same local video track twice.
445 445
             if (track === localVideoTrack) {
446 446
                 return Promise.resolve(track);
447
-            } else {
448
-                return Promise.reject(new Error(
449
-                    'cannot add second video track to the conference'));
450 447
             }
448
+            return Promise.reject(new Error(
449
+                    'cannot add second video track to the conference'));
450
+
451 451
         }
452 452
     }
453 453
 
@@ -576,9 +576,9 @@ JitsiConference.prototype.replaceTrack = function(oldTrack, newTrack) {
576 576
 JitsiConference.prototype._doReplaceTrack = function(oldTrack, newTrack) {
577 577
     if (this.jingleSession) {
578 578
         return this.jingleSession.replaceTrack(oldTrack, newTrack);
579
-    } else {
580
-        return Promise.resolve();
581 579
     }
580
+    return Promise.resolve();
581
+
582 582
 };
583 583
 
584 584
 /**
@@ -1326,9 +1326,9 @@ JitsiConference.prototype.getPhonePin = function() {
1326 1326
 JitsiConference.prototype.getConnectionState = function() {
1327 1327
     if (this.jingleSession) {
1328 1328
         return this.jingleSession.getIceConnectionState();
1329
-    } else {
1330
-        return null;
1331 1329
     }
1330
+    return null;
1331
+
1332 1332
 };
1333 1333
 
1334 1334
 /**

+ 4
- 4
modules/RTC/DataChannels.js ファイルの表示

@@ -237,12 +237,12 @@ DataChannels.prototype._some = function(callback, thisArg) {
237 237
     if (dataChannels && dataChannels.length !== 0) {
238 238
         if (thisArg) {
239 239
             return dataChannels.some(callback, thisArg);
240
-        } else {
241
-            return dataChannels.some(callback);
242 240
         }
243
-    } else {
244
-        return false;
241
+        return dataChannels.some(callback);
242
+
245 243
     }
244
+    return false;
245
+
246 246
 };
247 247
 
248 248
 /**

+ 4
- 4
modules/RTC/JitsiLocalTrack.js ファイルの表示

@@ -484,9 +484,9 @@ JitsiLocalTrack.prototype.isMuted = function() {
484 484
     }
485 485
     if (this.isVideoTrack() && !this.isActive()) {
486 486
         return true;
487
-    } else {
488
-        return !this.track || !this.track.enabled;
489 487
     }
488
+    return !this.track || !this.track.enabled;
489
+
490 490
 };
491 491
 
492 492
 /**
@@ -527,9 +527,9 @@ JitsiLocalTrack.prototype.getSSRC = function() {
527 527
         return this.ssrc.groups[0].ssrcs[0];
528 528
     } else if(this.ssrc && this.ssrc.ssrcs && this.ssrc.ssrcs.length) {
529 529
         return this.ssrc.ssrcs[0];
530
-    } else {
531
-        return null;
532 530
     }
531
+    return null;
532
+
533 533
 };
534 534
 
535 535
 /**

+ 6
- 6
modules/RTC/JitsiTrack.js ファイルの表示

@@ -210,9 +210,9 @@ JitsiTrack.prototype.getTrackId = function() {
210 210
 JitsiTrack.prototype.getUsageLabel = function() {
211 211
     if (this.isAudioTrack()) {
212 212
         return 'mic';
213
-    } else {
214
-        return this.videoType ? this.videoType : 'default';
215 213
     }
214
+    return this.videoType ? this.videoType : 'default';
215
+
216 216
 };
217 217
 
218 218
 /**
@@ -319,9 +319,9 @@ JitsiTrack.prototype.isScreenSharing = function() {
319 319
 JitsiTrack.prototype.getId = function() {
320 320
     if(this.stream) {
321 321
         return RTCUtils.getStreamID(this.stream);
322
-    } else {
323
-        return null;
324 322
     }
323
+    return null;
324
+
325 325
 };
326 326
 
327 327
 /**
@@ -333,9 +333,9 @@ JitsiTrack.prototype.getId = function() {
333 333
 JitsiTrack.prototype.isActive = function() {
334 334
     if(typeof this.stream.active !== 'undefined') {
335 335
         return this.stream.active;
336
-    } else {
337
-        return true;
338 336
     }
337
+    return true;
338
+
339 339
 };
340 340
 
341 341
 /**

+ 6
- 6
modules/RTC/RTC.js ファイルの表示

@@ -247,9 +247,9 @@ export default class RTC extends Listenable {
247 247
             // NOTE Remote tracks are not removed here.
248 248
             this.peerConnections.delete(id);
249 249
             return true;
250
-        } else {
251
-            return false;
252 250
         }
251
+        return false;
252
+
253 253
     }
254 254
 
255 255
     addLocalTrack(track) {
@@ -334,9 +334,9 @@ export default class RTC extends Listenable {
334 334
     getRemoteTrackByType(type, resource) {
335 335
         if (this.remoteTracks[resource]) {
336 336
             return this.remoteTracks[resource][type];
337
-        } else {
338
-            return null;
339 337
         }
338
+        return null;
339
+
340 340
     }
341 341
 
342 342
     /**
@@ -461,9 +461,9 @@ export default class RTC extends Listenable {
461 461
                         && mediaTrack.getTrackId() == trackId) {
462 462
                         result = mediaTrack;
463 463
                         return true;
464
-                    } else {
465
-                        return false;
466 464
                     }
465
+                    return false;
466
+
467 467
                 });
468 468
         });
469 469
 

+ 7
- 7
modules/RTC/RTCUIHelper.js ファイルの表示

@@ -25,18 +25,18 @@ var RTCUIHelper = {
25 25
         var videoElemName = RTCUIHelper.getVideoElementName();
26 26
         if (!RTCBrowserType.isTemasysPluginUsed()) {
27 27
             return $(containerElement).find(videoElemName)[0];
28
-        } else {
29
-            var matching = $(containerElement).find(
28
+        }
29
+        var matching = $(containerElement).find(
30 30
                 ' ' + videoElemName + '>param[value="video"]');
31
-            if (matching.length) {
32
-                if (matching.length > 1) {
33
-                    logger.warn(
31
+        if (matching.length) {
32
+            if (matching.length > 1) {
33
+                logger.warn(
34 34
                         'Container with more than one video elements: ',
35 35
                         containerElement);
36
-                }
37
-                return matching.parent()[0];
38 36
             }
37
+            return matching.parent()[0];
39 38
         }
39
+
40 40
         return undefined;
41 41
     },
42 42
     /**

+ 9
- 9
modules/RTC/RTCUtils.js ファイルの表示

@@ -1160,17 +1160,17 @@ class RTCUtils extends Listenable {
1160 1160
     onRTCReady() {
1161 1161
         if (rtcReady) {
1162 1162
             return Promise.resolve();
1163
-        } else {
1164
-            return new Promise(resolve => {
1165
-                const listener = () => {
1166
-                    eventEmitter.removeListener(RTCEvents.RTC_READY, listener);
1167
-                    resolve();
1168
-                };
1169
-                eventEmitter.addListener(RTCEvents.RTC_READY, listener);
1163
+        }
1164
+        return new Promise(resolve => {
1165
+            const listener = () => {
1166
+                eventEmitter.removeListener(RTCEvents.RTC_READY, listener);
1167
+                resolve();
1168
+            };
1169
+            eventEmitter.addListener(RTCEvents.RTC_READY, listener);
1170 1170
                 // We have no failed event, so... it either resolves or nothing
1171 1171
                 // happens
1172
-            });
1173
-        }
1172
+        });
1173
+
1174 1174
     }
1175 1175
 
1176 1176
     /**

+ 4
- 4
modules/statistics/RTPStatsCollector.js ファイルの表示

@@ -316,9 +316,9 @@ StatsCollector.prototype._defineGetStatValueMethod = function(keys) {
316 316
         var key = keys[name];
317 317
         if (key) {
318 318
             return key;
319
-        } else {
320
-            throw 'The property \'' + name + '\' isn\'t supported!';
321 319
         }
320
+        throw 'The property \'' + name + '\' isn\'t supported!';
321
+
322 322
     };
323 323
 
324 324
     // Define the function which retrieves the value from a specific report
@@ -349,9 +349,9 @@ StatsCollector.prototype._defineGetStatValueMethod = function(keys) {
349 349
                 if (pair.hasOwnProperty(key)) {
350 350
                     value = pair[key];
351 351
                     return true;
352
-                } else {
353
-                    return false;
354 352
                 }
353
+                return false;
354
+
355 355
             });
356 356
             return value;
357 357
         };

+ 5
- 5
modules/transcription/audioRecorder.js ファイルの表示

@@ -93,10 +93,10 @@ function determineCorrectFileType() {
93 93
         return AUDIO_WEBM;
94 94
     } else if(MediaRecorder.isTypeSupported(AUDIO_OGG)) {
95 95
         return AUDIO_OGG;
96
-    } else {
97
-        throw new Error('unable to create a MediaRecorder with the'
98
-            + 'right mimetype!');
99 96
     }
97
+    throw new Error('unable to create a MediaRecorder with the'
98
+            + 'right mimetype!');
99
+
100 100
 }
101 101
 
102 102
 /**
@@ -295,9 +295,9 @@ function createEmptyStream() {
295 295
         return new MediaStream();
296 296
     } else if(typeof webkitMediaStream !== 'undefined') {
297 297
         return new webkitMediaStream(); // eslint-disable-line new-cap
298
-    } else {
299
-        throw new Error('cannot create a clean mediaStream');
300 298
     }
299
+    throw new Error('cannot create a clean mediaStream');
300
+
301 301
 }
302 302
 
303 303
 /**

+ 2
- 2
modules/transcription/transcriptionServices/SphinxTranscriptionService.js ファイルの表示

@@ -117,9 +117,9 @@ function getURL() {
117 117
         var toReturn = config.sphinxURL;
118 118
         if(toReturn.includes !== undefined && toReturn.includes('https://')) {
119 119
             return toReturn;
120
-        } else{
121
-            console.log(message);
122 120
         }
121
+        console.log(message);
122
+
123 123
     }
124 124
 }
125 125
 

+ 2
- 2
modules/xmpp/ChatRoom.js ファイルの表示

@@ -682,9 +682,9 @@ export default class ChatRoom extends Listenable {
682 682
         var member = this.members[mucJid];
683 683
         if (member) {
684 684
             return member.isFocus;
685
-        } else {
686
-            return null;
687 685
         }
686
+        return null;
687
+
688 688
     }
689 689
 
690 690
     isModerator() {

+ 7
- 7
modules/xmpp/RtxModifier.spec.js ファイルの表示

@@ -40,14 +40,14 @@ function getPrimaryVideoSsrcs(parsedSdp) {
40 40
     const videoMLine = parsedSdp.media.find(m => m.type === 'video');
41 41
     if (numVideoSsrcs(parsedSdp) === 1) {
42 42
         return [videoMLine.ssrcs[0].id];
43
-    } else {
44
-        const simGroups = getVideoGroups(parsedSdp, 'SIM');
45
-        if (simGroups.length > 1) {
46
-            return;
47
-        }
48
-        const simGroup = simGroups[0];
49
-        return SDPUtil.parseGroupSsrcs(simGroup);
50 43
     }
44
+    const simGroups = getVideoGroups(parsedSdp, 'SIM');
45
+    if (simGroups.length > 1) {
46
+        return;
47
+    }
48
+    const simGroup = simGroups[0];
49
+    return SDPUtil.parseGroupSsrcs(simGroup);
50
+
51 51
 }
52 52
 
53 53
 /**

+ 13
- 13
modules/xmpp/SdpTransformUtil.js ファイルの表示

@@ -26,12 +26,12 @@ export function parseSecondarySSRC(group) {
26 26
 function _getSSRCCount(mLine) {
27 27
     if (!mLine.ssrcs) {
28 28
         return 0;
29
-    } else {
30
-        return mLine.ssrcs
29
+    }
30
+    return mLine.ssrcs
31 31
             .map(ssrcInfo => ssrcInfo.id)
32 32
             .filter((ssrc, index, array) => array.indexOf(ssrc) === index)
33 33
             .length;
34
-    }
34
+
35 35
 }
36 36
 
37 37
 /**
@@ -269,19 +269,19 @@ class MLineWrap {
269 269
         if (numSsrcs === 1) {
270 270
             // Not using _ssrcs on purpose here
271 271
             return this.mLine.ssrcs[0].id;
272
-        } else {
272
+        }
273 273
             // Look for a SIM or FID group
274
-            if (this.mLine.ssrcGroups) {
275
-                const simGroup = this.findGroup('SIM');
276
-                if (simGroup) {
277
-                    return parsePrimarySSRC(simGroup);
278
-                }
279
-                const fidGroup = this.findGroup('FID');
280
-                if (fidGroup) {
281
-                    return parsePrimarySSRC(fidGroup);
282
-                }
274
+        if (this.mLine.ssrcGroups) {
275
+            const simGroup = this.findGroup('SIM');
276
+            if (simGroup) {
277
+                return parsePrimarySSRC(simGroup);
278
+            }
279
+            const fidGroup = this.findGroup('FID');
280
+            if (fidGroup) {
281
+                return parsePrimarySSRC(fidGroup);
283 282
             }
284 283
         }
284
+
285 285
     }
286 286
 
287 287
     /**

読み込み中…
キャンセル
保存