Bladeren bron

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

dev1
hristoterezov 8 jaren geleden
bovenliggende
commit
b13348726b

+ 1
- 0
.eslintrc.js Bestand weergeven

@@ -91,6 +91,7 @@ module.exports = {
91 91
         'no-extra-label': 2,
92 92
         'no-fallthrough': 2,
93 93
         'no-floating-decimal': 2,
94
+        'no-implicit-coercion': 2,
94 95
         'no-implicit-globals': 2,
95 96
         'no-implied-eval': 2,
96 97
         'no-iterator': 2,

+ 1
- 1
JitsiConference.js Bestand weergeven

@@ -222,7 +222,7 @@ JitsiConference.prototype.isAuthEnabled = function() {
222 222
  * Check if user is logged in.
223 223
  */
224 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 Bestand weergeven

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

+ 15
- 12
modules/RTC/RTCUtils.js Bestand weergeven

@@ -311,8 +311,8 @@ function getConstraints(um, options) {
311 311
  * @param stream the stream we received from calling getUserMedia.
312 312
  */
313 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 317
     if (um.indexOf('video') != -1) {
318 318
         devices.video = videoTracksReceived;
@@ -868,7 +868,7 @@ class RTCUtils extends Listenable {
868 868
                                     && !containerSel.is(':visible')) {
869 869
                                 containerSel.show();
870 870
                             }
871
-                            const video = !!stream.getVideoTracks().length;
871
+                            const video = stream.getVideoTracks().length > 0;
872 872
                             if (video && !$(element).is(':visible')) {
873 873
                                 throw new Error(
874 874
                                     'video element must be visible to attach'
@@ -1044,10 +1044,14 @@ class RTCUtils extends Listenable {
1044 1044
                     this.getUserMediaWithConstraints(
1045 1045
                         options.devices,
1046 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 1056
                             if((audioDeviceRequested && !audioTracksReceived)
1053 1057
                                 || (videoDeviceRequested && !videoTracksReceived)) {
@@ -1143,11 +1147,10 @@ class RTCUtils extends Listenable {
1143 1147
         if (!rtcReady) {
1144 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 Bestand weergeven

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

+ 3
- 3
modules/xmpp/JingleSessionPC.js Bestand weergeven

@@ -82,14 +82,14 @@ export default class JingleSessionPC extends JingleSession {
82 82
          */
83 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 88
          * Flag used to enforce ICE failure through the URL parameter for
89 89
          * the automatic testing purpose.
90 90
          * @type {boolean}
91 91
          */
92
-        this.failICE = !!options.failICE;
92
+        this.failICE = Boolean(options.failICE);
93 93
 
94 94
         this.modificationQueue
95 95
             = async.queue(this._processQueueTasks.bind(this), 1);

+ 2
- 14
modules/xmpp/SdpTransformUtil.js Bestand weergeven

@@ -148,18 +148,6 @@ class MLineWrap {
148 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 152
      * Obtains value from SSRC attribute.
165 153
      * @param {number} ssrcNumber the SSRC number for which attribute is to be
@@ -249,7 +237,7 @@ class MLineWrap {
249 237
      * <tt>false</tt> otherwise.
250 238
      */
251 239
     containsAnySSRCGroups() {
252
-        return !!this.mLine.ssrcGroups;
240
+        return this.mLine.ssrcGroups !== undefined;
253 241
     }
254 242
 
255 243
     /**
@@ -394,4 +382,4 @@ class MLineWrap {
394 382
     addSSRCGroup(group) {
395 383
         this.ssrcGroups.push(group);
396 384
     }
397
-}
385
+}

+ 1
- 1
modules/xmpp/moderator.js Bestand weergeven

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

Laden…
Annuleren
Opslaan