瀏覽代碼

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

dev1
hristoterezov 8 年之前
父節點
當前提交
e4352d2188

+ 1
- 0
.eslintrc.js 查看文件

81
         'no-caller': 2,
81
         'no-caller': 2,
82
         'no-case-declarations': 2,
82
         'no-case-declarations': 2,
83
         'no-div-regex': 0,
83
         'no-div-regex': 0,
84
+        'no-else-return': 2,
84
         'no-empty-pattern': 2,
85
         'no-empty-pattern': 2,
85
         'no-eval': 2,
86
         'no-eval': 2,
86
         'no-extend-native': 2,
87
         'no-extend-native': 2,

+ 7
- 7
JitsiConference.js 查看文件

444
             // to attempt to add the same local video track twice.
444
             // to attempt to add the same local video track twice.
445
             if (track === localVideoTrack) {
445
             if (track === localVideoTrack) {
446
                 return Promise.resolve(track);
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
 JitsiConference.prototype._doReplaceTrack = function(oldTrack, newTrack) {
576
 JitsiConference.prototype._doReplaceTrack = function(oldTrack, newTrack) {
577
     if (this.jingleSession) {
577
     if (this.jingleSession) {
578
         return this.jingleSession.replaceTrack(oldTrack, newTrack);
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
 JitsiConference.prototype.getConnectionState = function() {
1326
 JitsiConference.prototype.getConnectionState = function() {
1327
     if (this.jingleSession) {
1327
     if (this.jingleSession) {
1328
         return this.jingleSession.getIceConnectionState();
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
     if (dataChannels && dataChannels.length !== 0) {
237
     if (dataChannels && dataChannels.length !== 0) {
238
         if (thisArg) {
238
         if (thisArg) {
239
             return dataChannels.some(callback, thisArg);
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
     }
484
     }
485
     if (this.isVideoTrack() && !this.isActive()) {
485
     if (this.isVideoTrack() && !this.isActive()) {
486
         return true;
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
         return this.ssrc.groups[0].ssrcs[0];
527
         return this.ssrc.groups[0].ssrcs[0];
528
     } else if(this.ssrc && this.ssrc.ssrcs && this.ssrc.ssrcs.length) {
528
     } else if(this.ssrc && this.ssrc.ssrcs && this.ssrc.ssrcs.length) {
529
         return this.ssrc.ssrcs[0];
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
 JitsiTrack.prototype.getUsageLabel = function() {
210
 JitsiTrack.prototype.getUsageLabel = function() {
211
     if (this.isAudioTrack()) {
211
     if (this.isAudioTrack()) {
212
         return 'mic';
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
 JitsiTrack.prototype.getId = function() {
319
 JitsiTrack.prototype.getId = function() {
320
     if(this.stream) {
320
     if(this.stream) {
321
         return RTCUtils.getStreamID(this.stream);
321
         return RTCUtils.getStreamID(this.stream);
322
-    } else {
323
-        return null;
324
     }
322
     }
323
+    return null;
324
+
325
 };
325
 };
326
 
326
 
327
 /**
327
 /**
333
 JitsiTrack.prototype.isActive = function() {
333
 JitsiTrack.prototype.isActive = function() {
334
     if(typeof this.stream.active !== 'undefined') {
334
     if(typeof this.stream.active !== 'undefined') {
335
         return this.stream.active;
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
             // NOTE Remote tracks are not removed here.
247
             // NOTE Remote tracks are not removed here.
248
             this.peerConnections.delete(id);
248
             this.peerConnections.delete(id);
249
             return true;
249
             return true;
250
-        } else {
251
-            return false;
252
         }
250
         }
251
+        return false;
252
+
253
     }
253
     }
254
 
254
 
255
     addLocalTrack(track) {
255
     addLocalTrack(track) {
334
     getRemoteTrackByType(type, resource) {
334
     getRemoteTrackByType(type, resource) {
335
         if (this.remoteTracks[resource]) {
335
         if (this.remoteTracks[resource]) {
336
             return this.remoteTracks[resource][type];
336
             return this.remoteTracks[resource][type];
337
-        } else {
338
-            return null;
339
         }
337
         }
338
+        return null;
339
+
340
     }
340
     }
341
 
341
 
342
     /**
342
     /**
461
                         && mediaTrack.getTrackId() == trackId) {
461
                         && mediaTrack.getTrackId() == trackId) {
462
                         result = mediaTrack;
462
                         result = mediaTrack;
463
                         return true;
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
         var videoElemName = RTCUIHelper.getVideoElementName();
25
         var videoElemName = RTCUIHelper.getVideoElementName();
26
         if (!RTCBrowserType.isTemasysPluginUsed()) {
26
         if (!RTCBrowserType.isTemasysPluginUsed()) {
27
             return $(containerElement).find(videoElemName)[0];
27
             return $(containerElement).find(videoElemName)[0];
28
-        } else {
29
-            var matching = $(containerElement).find(
28
+        }
29
+        var matching = $(containerElement).find(
30
                 ' ' + videoElemName + '>param[value="video"]');
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
                         'Container with more than one video elements: ',
34
                         'Container with more than one video elements: ',
35
                         containerElement);
35
                         containerElement);
36
-                }
37
-                return matching.parent()[0];
38
             }
36
             }
37
+            return matching.parent()[0];
39
         }
38
         }
39
+
40
         return undefined;
40
         return undefined;
41
     },
41
     },
42
     /**
42
     /**

+ 9
- 9
modules/RTC/RTCUtils.js 查看文件

1160
     onRTCReady() {
1160
     onRTCReady() {
1161
         if (rtcReady) {
1161
         if (rtcReady) {
1162
             return Promise.resolve();
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
                 // We have no failed event, so... it either resolves or nothing
1170
                 // We have no failed event, so... it either resolves or nothing
1171
                 // happens
1171
                 // happens
1172
-            });
1173
-        }
1172
+        });
1173
+
1174
     }
1174
     }
1175
 
1175
 
1176
     /**
1176
     /**

+ 4
- 4
modules/statistics/RTPStatsCollector.js 查看文件

316
         var key = keys[name];
316
         var key = keys[name];
317
         if (key) {
317
         if (key) {
318
             return key;
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
     // Define the function which retrieves the value from a specific report
324
     // Define the function which retrieves the value from a specific report
349
                 if (pair.hasOwnProperty(key)) {
349
                 if (pair.hasOwnProperty(key)) {
350
                     value = pair[key];
350
                     value = pair[key];
351
                     return true;
351
                     return true;
352
-                } else {
353
-                    return false;
354
                 }
352
                 }
353
+                return false;
354
+
355
             });
355
             });
356
             return value;
356
             return value;
357
         };
357
         };

+ 5
- 5
modules/transcription/audioRecorder.js 查看文件

93
         return AUDIO_WEBM;
93
         return AUDIO_WEBM;
94
     } else if(MediaRecorder.isTypeSupported(AUDIO_OGG)) {
94
     } else if(MediaRecorder.isTypeSupported(AUDIO_OGG)) {
95
         return AUDIO_OGG;
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
         return new MediaStream();
295
         return new MediaStream();
296
     } else if(typeof webkitMediaStream !== 'undefined') {
296
     } else if(typeof webkitMediaStream !== 'undefined') {
297
         return new webkitMediaStream(); // eslint-disable-line new-cap
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
         var toReturn = config.sphinxURL;
117
         var toReturn = config.sphinxURL;
118
         if(toReturn.includes !== undefined && toReturn.includes('https://')) {
118
         if(toReturn.includes !== undefined && toReturn.includes('https://')) {
119
             return toReturn;
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
         var member = this.members[mucJid];
682
         var member = this.members[mucJid];
683
         if (member) {
683
         if (member) {
684
             return member.isFocus;
684
             return member.isFocus;
685
-        } else {
686
-            return null;
687
         }
685
         }
686
+        return null;
687
+
688
     }
688
     }
689
 
689
 
690
     isModerator() {
690
     isModerator() {

+ 7
- 7
modules/xmpp/RtxModifier.spec.js 查看文件

40
     const videoMLine = parsedSdp.media.find(m => m.type === 'video');
40
     const videoMLine = parsedSdp.media.find(m => m.type === 'video');
41
     if (numVideoSsrcs(parsedSdp) === 1) {
41
     if (numVideoSsrcs(parsedSdp) === 1) {
42
         return [videoMLine.ssrcs[0].id];
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
 function _getSSRCCount(mLine) {
26
 function _getSSRCCount(mLine) {
27
     if (!mLine.ssrcs) {
27
     if (!mLine.ssrcs) {
28
         return 0;
28
         return 0;
29
-    } else {
30
-        return mLine.ssrcs
29
+    }
30
+    return mLine.ssrcs
31
             .map(ssrcInfo => ssrcInfo.id)
31
             .map(ssrcInfo => ssrcInfo.id)
32
             .filter((ssrc, index, array) => array.indexOf(ssrc) === index)
32
             .filter((ssrc, index, array) => array.indexOf(ssrc) === index)
33
             .length;
33
             .length;
34
-    }
34
+
35
 }
35
 }
36
 
36
 
37
 /**
37
 /**
269
         if (numSsrcs === 1) {
269
         if (numSsrcs === 1) {
270
             // Not using _ssrcs on purpose here
270
             // Not using _ssrcs on purpose here
271
             return this.mLine.ssrcs[0].id;
271
             return this.mLine.ssrcs[0].id;
272
-        } else {
272
+        }
273
             // Look for a SIM or FID group
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
     /**

Loading…
取消
儲存