瀏覽代碼

fix(eslint): Add no-implicit-coercion rule

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

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

91
         'no-extra-label': 2,
91
         'no-extra-label': 2,
92
         'no-fallthrough': 2,
92
         'no-fallthrough': 2,
93
         'no-floating-decimal': 2,
93
         'no-floating-decimal': 2,
94
+        'no-implicit-coercion': 2,
94
         'no-implicit-globals': 2,
95
         'no-implicit-globals': 2,
95
         'no-implied-eval': 2,
96
         'no-implied-eval': 2,
96
         'no-iterator': 2,
97
         'no-iterator': 2,

+ 1
- 1
JitsiConference.js 查看文件

222
  * Check if user is logged in.
222
  * Check if user is logged in.
223
  */
223
  */
224
 JitsiConference.prototype.isLoggedIn = function() {
224
 JitsiConference.prototype.isLoggedIn = function() {
225
-    return !!this.authIdentity;
225
+    return Boolean(this.authIdentity);
226
 };
226
 };
227
 
227
 
228
 /**
228
 /**

+ 1
- 1
modules/RTC/RTCBrowserType.js 查看文件

184
         // This mirrors what sdp-simulcast uses (which is used when deciding
184
         // This mirrors what sdp-simulcast uses (which is used when deciding
185
         // whether to actually enable simulcast or not).
185
         // whether to actually enable simulcast or not).
186
         // TODO: the logic should be in one single place.
186
         // TODO: the logic should be in one single place.
187
-        return !!window.chrome;
187
+        return window.chrome !== undefined;
188
     }
188
     }
189
 
189
 
190
     // Add version getters for other browsers when needed
190
     // Add version getters for other browsers when needed

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

311
  * @param stream the stream we received from calling getUserMedia.
311
  * @param stream the stream we received from calling getUserMedia.
312
  */
312
  */
313
 function setAvailableDevices(um, stream) {
313
 function setAvailableDevices(um, stream) {
314
-    const audioTracksReceived = stream && !!stream.getAudioTracks().length;
315
-    const videoTracksReceived = stream && !!stream.getVideoTracks().length;
314
+    const audioTracksReceived = stream && stream.getAudioTracks().length > 0;
315
+    const videoTracksReceived = stream && stream.getVideoTracks().length > 0;
316
 
316
 
317
     if (um.indexOf('video') != -1) {
317
     if (um.indexOf('video') != -1) {
318
         devices.video = videoTracksReceived;
318
         devices.video = videoTracksReceived;
868
                                     && !containerSel.is(':visible')) {
868
                                     && !containerSel.is(':visible')) {
869
                                 containerSel.show();
869
                                 containerSel.show();
870
                             }
870
                             }
871
-                            const video = !!stream.getVideoTracks().length;
871
+                            const video = stream.getVideoTracks().length > 0;
872
                             if (video && !$(element).is(':visible')) {
872
                             if (video && !$(element).is(':visible')) {
873
                                 throw new Error(
873
                                 throw new Error(
874
                                     'video element must be visible to attach'
874
                                     'video element must be visible to attach'
1044
                     this.getUserMediaWithConstraints(
1044
                     this.getUserMediaWithConstraints(
1045
                         options.devices,
1045
                         options.devices,
1046
                         function(stream) {
1046
                         function(stream) {
1047
-                            const audioDeviceRequested = options.devices.indexOf('audio') !== -1;
1048
-                            const videoDeviceRequested = options.devices.indexOf('video') !== -1;
1049
-                            const audioTracksReceived = !!stream.getAudioTracks().length;
1050
-                            const videoTracksReceived = !!stream.getVideoTracks().length;
1047
+                            const audioDeviceRequested
1048
+                                = options.devices.indexOf('audio') !== -1;
1049
+                            const videoDeviceRequested
1050
+                                = options.devices.indexOf('video') !== -1;
1051
+                            const audioTracksReceived
1052
+                                = stream.getAudioTracks().length > 0;
1053
+                            const videoTracksReceived
1054
+                                = stream.getVideoTracks().length > 0;
1051
 
1055
 
1052
                             if((audioDeviceRequested && !audioTracksReceived)
1056
                             if((audioDeviceRequested && !audioTracksReceived)
1053
                                 || (videoDeviceRequested && !videoTracksReceived)) {
1057
                                 || (videoDeviceRequested && !videoTracksReceived)) {
1143
         if (!rtcReady) {
1147
         if (!rtcReady) {
1144
             throw new Error('WebRTC not ready yet');
1148
             throw new Error('WebRTC not ready yet');
1145
         }
1149
         }
1146
-        return !!(
1147
-            navigator.mediaDevices
1148
-                && navigator.mediaDevices.enumerateDevices
1149
-                && typeof MediaStreamTrack !== 'undefined'
1150
-                && MediaStreamTrack.getSources);
1150
+        return Boolean(navigator.mediaDevices
1151
+            && navigator.mediaDevices.enumerateDevices
1152
+            && typeof MediaStreamTrack !== 'undefined'
1153
+            && MediaStreamTrack.getSources);
1151
     }
1154
     }
1152
 
1155
 
1153
     /**
1156
     /**

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

173
      * @returns {boolean}
173
      * @returns {boolean}
174
      */
174
      */
175
     isSupported() {
175
     isSupported() {
176
-        return !!this.obtainStream;
176
+        return this.obtainStream !== null;
177
     },
177
     },
178
 
178
 
179
     /**
179
     /**

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

82
          */
82
          */
83
         this.ssrcOwners = {};
83
         this.ssrcOwners = {};
84
 
84
 
85
-        this.webrtcIceUdpDisable = !!options.webrtcIceUdpDisable;
86
-        this.webrtcIceTcpDisable = !!options.webrtcIceTcpDisable;
85
+        this.webrtcIceUdpDisable = Boolean(options.webrtcIceUdpDisable);
86
+        this.webrtcIceTcpDisable = Boolean(options.webrtcIceTcpDisable);
87
         /**
87
         /**
88
          * Flag used to enforce ICE failure through the URL parameter for
88
          * Flag used to enforce ICE failure through the URL parameter for
89
          * the automatic testing purpose.
89
          * the automatic testing purpose.
90
          * @type {boolean}
90
          * @type {boolean}
91
          */
91
          */
92
-        this.failICE = !!options.failICE;
92
+        this.failICE = Boolean(options.failICE);
93
 
93
 
94
         this.modificationQueue
94
         this.modificationQueue
95
             = async.queue(this._processQueueTasks.bind(this), 1);
95
             = async.queue(this._processQueueTasks.bind(this), 1);

+ 2
- 14
modules/xmpp/SdpTransformUtil.js 查看文件

148
         this.mLine.ssrcGroups = ssrcGroups;
148
         this.mLine.ssrcGroups = ssrcGroups;
149
     }
149
     }
150
 
150
 
151
-    /**
152
-     * Checks whether the underlying media description contains given SSRC
153
-     * number.
154
-     * @param {string} ssrcNumber
155
-     * @return {boolean} <tt>true</tt> if given SSRC has been found or
156
-     * <tt>false</tt> otherwise.
157
-     */
158
-    containsSSRC(ssrcNumber) {
159
-        return !!this._ssrcs.find(
160
-            ssrcObj => ssrcObj.id == ssrcNumber);
161
-    }
162
-
163
     /**
151
     /**
164
      * Obtains value from SSRC attribute.
152
      * Obtains value from SSRC attribute.
165
      * @param {number} ssrcNumber the SSRC number for which attribute is to be
153
      * @param {number} ssrcNumber the SSRC number for which attribute is to be
249
      * <tt>false</tt> otherwise.
237
      * <tt>false</tt> otherwise.
250
      */
238
      */
251
     containsAnySSRCGroups() {
239
     containsAnySSRCGroups() {
252
-        return !!this.mLine.ssrcGroups;
240
+        return this.mLine.ssrcGroups !== undefined;
253
     }
241
     }
254
 
242
 
255
     /**
243
     /**
394
     addSSRCGroup(group) {
382
     addSSRCGroup(group) {
395
         this.ssrcGroups.push(group);
383
         this.ssrcGroups.push(group);
396
     }
384
     }
397
-}
385
+}

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

147
     elem.c(
147
     elem.c(
148
         'property', {
148
         'property', {
149
             name: 'disableRtx',
149
             name: 'disableRtx',
150
-            value: !!this.options.conference.disableRtx
150
+            value: Boolean(this.options.conference.disableRtx)
151
         }).up();
151
         }).up();
152
     elem.c(
152
     elem.c(
153
         'property', {
153
         'property', {

Loading…
取消
儲存