浏览代码

[eslint] no-negated-condition

release-8443
Lyubo Marinov 8 年前
父节点
当前提交
0da7f6b98f

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

152
         'no-array-constructor': 2,
152
         'no-array-constructor': 2,
153
         'no-inline-comments': 0,
153
         'no-inline-comments': 0,
154
         'no-mixed-spaces-and-tabs': 2,
154
         'no-mixed-spaces-and-tabs': 2,
155
+        'no-negated-condition': 2,
155
         'no-nested-ternary': 0,
156
         'no-nested-ternary': 0,
156
         'no-new-object': 2,
157
         'no-new-object': 2,
157
         'no-plusplus': 0,
158
         'no-plusplus': 0,

+ 4
- 4
modules/RTC/JitsiLocalTrack.js 查看文件

326
                     const mediaType = self.getType();
326
                     const mediaType = self.getType();
327
                     const streamInfo = streamsInfo.find(info => info.mediaType === mediaType);
327
                     const streamInfo = streamsInfo.find(info => info.mediaType === mediaType);
328
 
328
 
329
-                    if(!streamInfo) {
330
-                        throw new JitsiTrackError(
331
-                            JitsiTrackErrors.TRACK_NO_STREAM_FOUND);
332
-                    }else {
329
+                    if (streamInfo) {
333
                         self._setStream(streamInfo.stream);
330
                         self._setStream(streamInfo.stream);
334
                         self.track = streamInfo.track;
331
                         self.track = streamInfo.track;
335
                         // This is not good when video type changes after
332
                         // This is not good when video type changes after
340
                                 self.videoType, streamInfo.videoType);
337
                                 self.videoType, streamInfo.videoType);
341
                             self.videoType = streamInfo.videoType;
338
                             self.videoType = streamInfo.videoType;
342
                         }
339
                         }
340
+                    }else {
341
+                        throw new JitsiTrackError(
342
+                            JitsiTrackErrors.TRACK_NO_STREAM_FOUND);
343
                     }
343
                     }
344
 
344
 
345
                     self.containers = self.containers.map(cont => RTCUtils.attachMediaStream(cont, self.stream));
345
                     self.containers = self.containers.map(cont => RTCUtils.attachMediaStream(cont, self.stream));

+ 3
- 3
modules/RTC/JitsiTrack.js 查看文件

46
  */
46
  */
47
 function addMediaStreamInactiveHandler(mediaStream, handler) {
47
 function addMediaStreamInactiveHandler(mediaStream, handler) {
48
     // Temasys will use onended
48
     // Temasys will use onended
49
-    if(typeof mediaStream.active !== 'undefined') {
50
-        mediaStream.oninactive = handler;
51
-    } else {
49
+    if (typeof mediaStream.active === 'undefined') {
52
         mediaStream.onended = handler;
50
         mediaStream.onended = handler;
51
+    } else {
52
+        mediaStream.oninactive = handler;
53
     }
53
     }
54
 }
54
 }
55
 
55
 

+ 5
- 4
modules/RTC/RTC.js 查看文件

95
         return RTCUtils.obtainAudioAndVideoPermissions(options).then(
95
         return RTCUtils.obtainAudioAndVideoPermissions(options).then(
96
             tracksInfo => {
96
             tracksInfo => {
97
                 const tracks = createLocalTracks(tracksInfo, options);
97
                 const tracks = createLocalTracks(tracksInfo, options);
98
-                return !tracks.some(track =>
99
-                    !track._isReceivingData()) ? tracks
100
-                        : Promise.reject(new JitsiTrackError(
101
-                            JitsiTrackErrors.NO_DATA_FROM_SOURCE));
98
+                return tracks.some(track => !track._isReceivingData())
99
+                    ? Promise.reject(
100
+                        new JitsiTrackError(
101
+                            JitsiTrackErrors.NO_DATA_FROM_SOURCE))
102
+                    : tracks;
102
             });
103
             });
103
     }
104
     }
104
 
105
 

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

200
             // The react-native-webrtc project that we're currently using
200
             // The react-native-webrtc project that we're currently using
201
             // expects the audio constraint to be a boolean.
201
             // expects the audio constraint to be a boolean.
202
             constraints.audio = true;
202
             constraints.audio = true;
203
-        } else if (!RTCBrowserType.isFirefox()) {
203
+        } else if (RTCBrowserType.isFirefox()) {
204
+            if (options.micDeviceId) {
205
+                constraints.audio = {
206
+                    mandatory: {},
207
+                    deviceId: options.micDeviceId, // new style
208
+                    optional: [{
209
+                        sourceId: options.micDeviceId // old style
210
+                    }]};
211
+            } else {
212
+                constraints.audio = true;
213
+            }
214
+        } else {
204
             // same behaviour as true
215
             // same behaviour as true
205
             constraints.audio = { mandatory: {}, optional: []};
216
             constraints.audio = { mandatory: {}, optional: []};
206
             if (options.micDeviceId) {
217
             if (options.micDeviceId) {
223
                 {googEchoCancellation2: !disableAEC},
234
                 {googEchoCancellation2: !disableAEC},
224
                 {googAutoGainControl2: true}
235
                 {googAutoGainControl2: true}
225
             );
236
             );
226
-        } else {
227
-            if (options.micDeviceId) {
228
-                constraints.audio = {
229
-                    mandatory: {},
230
-                    deviceId: options.micDeviceId, // new style
231
-                    optional: [{
232
-                        sourceId: options.micDeviceId // old style
233
-                    }]};
234
-            } else {
235
-                constraints.audio = true;
236
-            }
237
         }
237
         }
238
     }
238
     }
239
     if (um.indexOf('screen') >= 0) {
239
     if (um.indexOf('screen') >= 0) {

+ 13
- 10
modules/RTC/ScreenObtainer.js 查看文件

121
         } else if (RTCBrowserType.isTemasysPluginUsed()) {
121
         } else if (RTCBrowserType.isTemasysPluginUsed()) {
122
             // XXX Don't require Temasys unless it's to be used because it
122
             // XXX Don't require Temasys unless it's to be used because it
123
             // doesn't run on React Native, for example.
123
             // doesn't run on React Native, for example.
124
-            const AdapterJS = require('./adapter.screenshare');
124
+            const plugin
125
+                = require('./adapter.screenshare').WebRTCPlugin.plugin;
125
 
126
 
126
-            if (!AdapterJS.WebRTCPlugin.plugin.HasScreensharingFeature) {
127
-                logger.info('Screensharing not supported by this plugin '
128
-                    + 'version');
129
-            } else if(!AdapterJS.WebRTCPlugin.plugin.isScreensharingAvailable) {
130
-                logger.info(
131
-                    'Screensharing not available with Temasys plugin on'
132
-                    + ' this site');
127
+            if (plugin.HasScreensharingFeature) {
128
+                if (plugin.isScreensharingAvailable) {
129
+                    obtainDesktopStream = obtainWebRTCScreen;
130
+                    logger.info('Using Temasys plugin for desktop sharing');
131
+                } else {
132
+                    logger.info(
133
+                        'Screensharing not available with Temasys plugin on'
134
+                            + ' this site');
135
+                }
133
             } else {
136
             } else {
134
-                obtainDesktopStream = obtainWebRTCScreen;
135
-                logger.info('Using Temasys plugin for desktop sharing');
137
+                logger.info(
138
+                    'Screensharing not supported by this plugin version');
136
             }
139
             }
137
         } else if (RTCBrowserType.isChrome()) {
140
         } else if (RTCBrowserType.isChrome()) {
138
             if (options.desktopSharingChromeDisabled
141
             if (options.desktopSharingChromeDisabled

+ 5
- 7
modules/transcription/transcriptionServices/AbstractTranscriptionService.js 查看文件

19
 TranscriptionService.prototype.send = function send(recordingResult, callback) {
19
 TranscriptionService.prototype.send = function send(recordingResult, callback) {
20
     const t = this;
20
     const t = this;
21
     this.sendRequest(recordingResult.blob, response => {
21
     this.sendRequest(recordingResult.blob, response => {
22
-        if(!t.verify(response)) {
23
-            console.log('the retrieved response from the server'
24
-                   + ' is not valid!');
25
-            recordingResult.wordArray = [];
26
-            callback(recordingResult);
27
-        } else{
22
+        if(t.verify(response)) {
28
             recordingResult.wordArray = t.formatResponse(response);
23
             recordingResult.wordArray = t.formatResponse(response);
29
-            callback(recordingResult);
24
+        } else{
25
+            console.log('the retrieved response from the server is not valid!');
26
+            recordingResult.wordArray = [];
30
         }
27
         }
28
+        callback(recordingResult);
31
     });
29
     });
32
 };
30
 };
33
 
31
 

+ 1
- 1
modules/xmpp/JingleSession.js 查看文件

80
         this.rtc = rtc;
80
         this.rtc = rtc;
81
         this.state = JingleSessionState.PENDING;
81
         this.state = JingleSessionState.PENDING;
82
         this.initiator = isInitiator ? this.localJid : this.peerjid;
82
         this.initiator = isInitiator ? this.localJid : this.peerjid;
83
-        this.responder = !isInitiator ? this.localJid : this.peerjid;
83
+        this.responder = isInitiator ? this.peerjid : this.localJid;
84
         this.doInitialize();
84
         this.doInitialize();
85
     }
85
     }
86
 
86
 

+ 6
- 21
modules/xmpp/JingleSessionPC.js 查看文件

975
             this.modificationQueue.push(
975
             this.modificationQueue.push(
976
                 workFunction,
976
                 workFunction,
977
                 error => {
977
                 error => {
978
-                    if (!error) {
979
-                        resolve();
980
-                    } else {
981
-                        reject(error);
982
-                    }
983
-                }
984
-            );
978
+                    error ? reject(error) : resolve();
979
+                });
985
         });
980
         });
986
     }
981
     }
987
 
982
 
1113
         this.modificationQueue.push(
1108
         this.modificationQueue.push(
1114
             workFunction,
1109
             workFunction,
1115
             error => {
1110
             error => {
1116
-                if (!error) {
1117
-                    callback();
1118
-                } else {
1119
-                    errorCallback(error);
1120
-                }
1121
-            }
1122
-        );
1111
+                error ? errorCallback(error) : callback();
1112
+            });
1123
     }
1113
     }
1124
 
1114
 
1125
     /**
1115
     /**
1234
         this.modificationQueue.push(
1224
         this.modificationQueue.push(
1235
             workFunction,
1225
             workFunction,
1236
             error => {
1226
             error => {
1237
-                if (!error) {
1238
-                    callback();
1239
-                } else {
1240
-                    errorCallback(error);
1241
-                }
1242
-            }
1243
-        );
1227
+                error ? errorCallback(error) : callback();
1228
+            });
1244
     }
1229
     }
1245
 
1230
 
1246
     /**
1231
     /**

+ 8
- 9
modules/xmpp/SDP.js 查看文件

509
     } else {
509
     } else {
510
         tmp.proto = 'RTP/AVPF';
510
         tmp.proto = 'RTP/AVPF';
511
     }
511
     }
512
-    if (!sctp.length) {
513
-        tmp.fmt = desc.find('payload-type').map(
514
-            function() {
515
-                return this.getAttribute('id');
516
-            }).get();
517
-        media += `${SDPUtil.build_mline(tmp)}\r\n`;
518
-    } else {
512
+    if (sctp.length) {
519
         media += `m=application 1 DTLS/SCTP ${sctp.attr('number')}\r\n`;
513
         media += `m=application 1 DTLS/SCTP ${sctp.attr('number')}\r\n`;
520
-        media += `a=sctpmap:${sctp.attr('number')
521
-             } ${sctp.attr('protocol')}`;
514
+        media += `a=sctpmap:${sctp.attr('number')} ${sctp.attr('protocol')}`;
522
 
515
 
523
         const streamCount = sctp.attr('streams');
516
         const streamCount = sctp.attr('streams');
524
         if (streamCount) {
517
         if (streamCount) {
526
         } else {
519
         } else {
527
             media += '\r\n';
520
             media += '\r\n';
528
         }
521
         }
522
+    } else {
523
+        tmp.fmt = desc.find('payload-type').map(
524
+            function() {
525
+                return this.getAttribute('id');
526
+            }).get();
527
+        media += `${SDPUtil.build_mline(tmp)}\r\n`;
529
     }
528
     }
530
 
529
 
531
     media += 'c=IN IP4 0.0.0.0\r\n';
530
     media += 'c=IN IP4 0.0.0.0\r\n';

+ 3
- 3
modules/xmpp/SDPUtil.js 查看文件

217
         const parts = line.substr(9).split(' ');
217
         const parts = line.substr(9).split(' ');
218
         const data = {};
218
         const data = {};
219
         data.value = parts.shift();
219
         data.value = parts.shift();
220
-        if (data.value.indexOf('/') != -1) {
220
+        if (data.value.indexOf('/') === -1) {
221
+            data.direction = 'both';
222
+        } else {
221
             data.direction = data.value.substr(data.value.indexOf('/') + 1);
223
             data.direction = data.value.substr(data.value.indexOf('/') + 1);
222
             data.value = data.value.substr(0, data.value.indexOf('/'));
224
             data.value = data.value.substr(0, data.value.indexOf('/'));
223
-        } else {
224
-            data.direction = 'both';
225
         }
225
         }
226
         data.uri = parts.shift();
226
         data.uri = parts.shift();
227
         data.params = parts;
227
         data.params = parts;

+ 7
- 8
modules/xmpp/SdpConsistency.js 查看文件

88
                 logger.info('Sdp-consistency couldn\'t parse new primary ssrc');
88
                 logger.info('Sdp-consistency couldn\'t parse new primary ssrc');
89
                 return sdpStr;
89
                 return sdpStr;
90
             }
90
             }
91
-            if (!this.cachedPrimarySsrc) {
92
-                this.cachedPrimarySsrc = newPrimarySsrc;
93
-                logger.info(
94
-                    `Sdp-consistency caching primary ssrc ${
95
-                        this.cachedPrimarySsrc}`);
96
-            } else {
91
+            if (this.cachedPrimarySsrc) {
97
                 logger.info(
92
                 logger.info(
98
                     `Sdp-consistency replacing new ssrc ${newPrimarySsrc
93
                     `Sdp-consistency replacing new ssrc ${newPrimarySsrc
99
                         } with cached ${this.cachedPrimarySsrc}`);
94
                         } with cached ${this.cachedPrimarySsrc}`);
100
-                videoMLine.replaceSSRC(
101
-                    newPrimarySsrc, this.cachedPrimarySsrc);
95
+                videoMLine.replaceSSRC(newPrimarySsrc, this.cachedPrimarySsrc);
102
                 for (const group of videoMLine.ssrcGroups) {
96
                 for (const group of videoMLine.ssrcGroups) {
103
                     if (group.semantics === 'FID') {
97
                     if (group.semantics === 'FID') {
104
                         const primarySsrc = parsePrimarySSRC(group);
98
                         const primarySsrc = parsePrimarySSRC(group);
109
                         }
103
                         }
110
                     }
104
                     }
111
                 }
105
                 }
106
+            } else {
107
+                this.cachedPrimarySsrc = newPrimarySsrc;
108
+                logger.info(
109
+                    `Sdp-consistency caching primary ssrc ${
110
+                        this.cachedPrimarySsrc}`);
112
             }
111
             }
113
         }
112
         }
114
         return sdpTransformer.toRawSDP();
113
         return sdpTransformer.toRawSDP();

+ 4
- 4
modules/xmpp/xmpp.js 查看文件

162
                 this.eventEmitter.emit(
162
                 this.eventEmitter.emit(
163
                     JitsiConnectionEvents.CONNECTION_FAILED,
163
                     JitsiConnectionEvents.CONNECTION_FAILED,
164
                     JitsiConnectionErrors.OTHER_ERROR, errMsg);
164
                     JitsiConnectionErrors.OTHER_ERROR, errMsg);
165
-            } else if (!wasIntentionalDisconnect) {
165
+            } else if (wasIntentionalDisconnect) {
166
+                this.eventEmitter.emit(
167
+                    JitsiConnectionEvents.CONNECTION_DISCONNECTED, errMsg);
168
+            } else {
166
                 // XXX if Strophe drops the connection while not being asked to,
169
                 // XXX if Strophe drops the connection while not being asked to,
167
                 // it means that most likely some serious error has occurred.
170
                 // it means that most likely some serious error has occurred.
168
                 // One currently known case is when a BOSH request fails for
171
                 // One currently known case is when a BOSH request fails for
183
                         JitsiConnectionErrors.CONNECTION_DROPPED_ERROR,
186
                         JitsiConnectionErrors.CONNECTION_DROPPED_ERROR,
184
                         errMsg ? errMsg : 'connection-dropped-error');
187
                         errMsg ? errMsg : 'connection-dropped-error');
185
                 }
188
                 }
186
-            } else {
187
-                this.eventEmitter.emit(
188
-                    JitsiConnectionEvents.CONNECTION_DISCONNECTED, errMsg);
189
             }
189
             }
190
         } else if (status === Strophe.Status.AUTHFAIL) {
190
         } else if (status === Strophe.Status.AUTHFAIL) {
191
             // wrong password or username, prompt user
191
             // wrong password or username, prompt user

正在加载...
取消
保存