Przeglądaj źródła

fix(eslint): Add no-extra-parens rule

master
hristoterezov 8 lat temu
rodzic
commit
fceb8606d8

+ 6
- 1
.eslintrc.js Wyświetl plik

@@ -39,6 +39,11 @@ module.exports = {
39 39
         'no-empty': 2,
40 40
         'no-empty-character-class': 2,
41 41
         'no-ex-assign': 2,
42
-        'no-extra-boolean-cast': 2
42
+        'no-extra-boolean-cast': 2,
43
+        'no-extra-parens': [
44
+            'error',
45
+            'all',
46
+            { 'nestedBinaryExpressions': false }
47
+        ]
43 48
     }
44 49
 };

+ 3
- 3
JitsiConference.js Wyświetl plik

@@ -1185,7 +1185,7 @@ JitsiConference.prototype.isDTMFSupported = function () {
1185 1185
  * @return {string} local user's ID
1186 1186
  */
1187 1187
 JitsiConference.prototype.myUserId = function () {
1188
-    return (this.room && this.room.myroomjid)? Strophe.getResourceFromJid(this.room.myroomjid) : null;
1188
+    return this.room && this.room.myroomjid? Strophe.getResourceFromJid(this.room.myroomjid) : null;
1189 1189
 };
1190 1190
 
1191 1191
 JitsiConference.prototype.sendTones = function (tones, duration, pause) {
@@ -1227,14 +1227,14 @@ JitsiConference.prototype.isRecordingSupported = function () {
1227 1227
  * and "off" if the recording is not started.
1228 1228
  */
1229 1229
 JitsiConference.prototype.getRecordingState = function () {
1230
-    return (this.room) ? this.room.getRecordingState() : undefined;
1230
+    return this.room ? this.room.getRecordingState() : undefined;
1231 1231
 };
1232 1232
 
1233 1233
 /**
1234 1234
  * Returns the url of the recorded video.
1235 1235
  */
1236 1236
 JitsiConference.prototype.getRecordingURL = function () {
1237
-    return (this.room) ? this.room.getRecordingURL() : null;
1237
+    return this.room ? this.room.getRecordingURL() : null;
1238 1238
 };
1239 1239
 
1240 1240
 /**

+ 1
- 1
modules/DTMF/JitsiDTMFManager.js Wyświetl plik

@@ -12,5 +12,5 @@ function JitsiDTMFManager (localAudio, peerConnection) {
12 12
 
13 13
 
14 14
 JitsiDTMFManager.prototype.sendTones = function (tones, duration, pause) {
15
-    this.dtmfSender.insertDTMF(tones, (duration || 200), (pause || 200));
15
+    this.dtmfSender.insertDTMF(tones, duration || 200, pause || 200);
16 16
 };

+ 5
- 5
modules/RTC/DataChannels.js Wyświetl plik

@@ -85,7 +85,7 @@ DataChannels.prototype.onDataChannel = function (event) {
85 85
                 dataChannel,
86 86
                 e);
87 87
         }
88
-        if (('undefined' !== typeof(obj)) && (null !== obj)) {
88
+        if (('undefined' !== typeof obj) && (null !== obj)) {
89 89
             var colibriClass = obj.colibriClass;
90 90
 
91 91
             if ("DominantSpeakerEndpointChangeEvent" === colibriClass) {
@@ -107,14 +107,14 @@ DataChannels.prototype.onDataChannel = function (event) {
107 107
 
108 108
                 if ((type = typeof oldValue) !== 'boolean') {
109 109
                     if (type === 'string') {
110
-                        oldValue = (oldValue == "true");
110
+                        oldValue = oldValue == "true";
111 111
                     } else {
112 112
                         oldValue = new Boolean(oldValue).valueOf();
113 113
                     }
114 114
                 }
115 115
                 if ((type = typeof newValue) !== 'boolean') {
116 116
                     if (type === 'string') {
117
-                        newValue = (newValue == "true");
117
+                        newValue = newValue == "true";
118 118
                     } else {
119 119
                         newValue = new Boolean(newValue).valueOf();
120 120
                     }
@@ -225,9 +225,9 @@ DataChannels.prototype._onXXXEndpointChanged = function (xxx, userResource) {
225 225
 
226 226
     var jsonObject = {};
227 227
 
228
-    jsonObject.colibriClass = (upper + 'EndpointChangedEvent');
228
+    jsonObject.colibriClass = upper + 'EndpointChangedEvent';
229 229
     jsonObject[lower + "Endpoint"]
230
-        = (userResource ? userResource : null);
230
+        = userResource ? userResource : null;
231 231
 
232 232
     this.send(jsonObject);
233 233
 

+ 2
- 2
modules/RTC/JitsiLocalTrack.js Wyświetl plik

@@ -647,8 +647,8 @@ JitsiLocalTrack.prototype._isReceivingData = function () {
647 647
     // the users for error if the stream is muted or ended on it's
648 648
     // creation.
649 649
     return this.stream.getTracks().some(track =>
650
-        ((!("readyState" in track) || track.readyState === "live")
651
-            && (!("muted" in track) || track.muted !== true)));
650
+        (!("readyState" in track) || track.readyState === "live")
651
+            && (!("muted" in track) || track.muted !== true));
652 652
 };
653 653
 
654 654
 module.exports = JitsiLocalTrack;

+ 1
- 1
modules/RTC/JitsiRemoteTrack.js Wyświetl plik

@@ -135,7 +135,7 @@ JitsiRemoteTrack.prototype._setVideoType = function (type) {
135 135
 };
136 136
 
137 137
 JitsiRemoteTrack.prototype._playCallback = function () {
138
-    var type = (this.isVideoTrack() ? 'video' : 'audio');
138
+    var type = this.isVideoTrack() ? 'video' : 'audio';
139 139
 
140 140
     var now = window.performance.now();
141 141
     console.log("(TIME) Render " + type + ":\t", now);

+ 2
- 2
modules/RTC/JitsiTrack.js Wyświetl plik

@@ -124,7 +124,7 @@ JitsiTrack.prototype._setHandler = function (type, handler) {
124 124
 JitsiTrack.prototype._setStream = function (stream) {
125 125
     this.stream = stream;
126 126
     Object.keys(this.handlers).forEach(function (type) {
127
-        typeof(this.handlers[type]) === "function" &&
127
+        typeof this.handlers[type] === "function" &&
128 128
             this._setHandler(type, this.handlers[type]);
129 129
     }, this);
130 130
 };
@@ -378,7 +378,7 @@ JitsiTrack.prototype.setAudioLevel = function (audioLevel) {
378 378
 JitsiTrack.prototype.getMSID = function () {
379 379
     var streamId = this.getStreamId();
380 380
     var trackId = this.getTrackId();
381
-    return (streamId && trackId) ? (streamId + " " + trackId) : null;
381
+    return streamId && trackId ? streamId + " " + trackId : null;
382 382
 };
383 383
 
384 384
 /**

+ 2
- 2
modules/RTC/RTC.js Wyświetl plik

@@ -590,8 +590,8 @@ export default class RTC extends Listenable {
590 590
      * @returns {boolean}
591 591
      */
592 592
     static isUserStreamById (streamId) {
593
-        return (streamId && streamId !== "mixedmslabel"
594
-            && streamId !== "default");
593
+        return streamId && streamId !== "mixedmslabel"
594
+            && streamId !== "default";
595 595
     }
596 596
 
597 597
     /**

+ 1
- 1
modules/RTC/RTCBrowserType.js Wyświetl plik

@@ -232,7 +232,7 @@ function detectFirefox() {
232 232
 }
233 233
 
234 234
 function detectSafari() {
235
-    if ((/^((?!chrome).)*safari/i.test(navigator.userAgent))) {
235
+    if (/^((?!chrome).)*safari/i.test(navigator.userAgent)) {
236 236
         currentBrowser = RTCBrowserType.RTC_BROWSER_SAFARI;
237 237
         logger.info("This appears to be Safari");
238 238
         // FIXME detect Safari version when needed

+ 7
- 7
modules/RTC/RTCUtils.js Wyświetl plik

@@ -79,7 +79,7 @@ function initRawEnumerateDevicesWithCallback() {
79 79
         // "ReferenceError: Can't find variable: MediaStreamTrack"
80 80
         // when Temasys plugin is not installed yet, have to delay this call
81 81
         // until WebRTC is ready.
82
-        : (MediaStreamTrack && MediaStreamTrack.getSources)
82
+        : MediaStreamTrack && MediaStreamTrack.getSources
83 83
         ? function (callback) {
84 84
             MediaStreamTrack.getSources(function (sources) {
85 85
                 callback(sources.map(convertMediaStreamTrackSource));
@@ -538,7 +538,7 @@ function convertMediaStreamTrackSource(source) {
538 538
         // not return 'audiooutput' devices but let's handle it in any
539 539
         // case
540 540
         kind: kind
541
-            ? (kind === 'audiooutput' ? kind : kind + 'input')
541
+            ? kind === 'audiooutput' ? kind : kind + 'input'
542 542
             : null,
543 543
         deviceId: source.id,
544 544
         groupId: source.groupId || null
@@ -737,11 +737,11 @@ class RTCUtils extends Listenable {
737 737
     }
738 738
 
739 739
     init(options) {
740
-        if (typeof(options.disableAEC) === "boolean") {
740
+        if (typeof options.disableAEC === "boolean") {
741 741
             disableAEC = options.disableAEC;
742 742
             logger.info("Disable AEC: " + disableAEC);
743 743
         }
744
-        if (typeof(options.disableNS) === "boolean") {
744
+        if (typeof options.disableNS === "boolean") {
745 745
             disableNS = options.disableNS;
746 746
             logger.info("Disable NS: " + disableNS);
747 747
         }
@@ -824,7 +824,7 @@ class RTCUtils extends Listenable {
824 824
                     // semicolon insertion (ASI). No line terminator is allowed
825 825
                     // between the return keyword and the expression.
826 826
                     return (
827
-                        (typeof id === 'number')
827
+                        typeof id === 'number'
828 828
                             ? id
829 829
                             : SDPUtil.filter_special_chars(id));
830 830
                 };
@@ -1154,8 +1154,8 @@ class RTCUtils extends Listenable {
1154 1154
         if (isEnumerateDevicesAvailable) {
1155 1155
             return true;
1156 1156
         }
1157
-        return (typeof MediaStreamTrack !== "undefined" &&
1158
-            MediaStreamTrack.getSources)? true : false;
1157
+        return typeof MediaStreamTrack !== "undefined" &&
1158
+            MediaStreamTrack.getSources? true : false;
1159 1159
     }
1160 1160
 
1161 1161
     /**

+ 4
- 4
modules/RTC/ScreenObtainer.js Wyświetl plik

@@ -105,7 +105,7 @@ var ScreenObtainer = {
105 105
                             jitsiError = new JitsiTrackError(
106 106
                                 error, constraints, ["desktop"]);
107 107
                         }
108
-                        (typeof(onFailure) === "function") &&
108
+                        (typeof onFailure === "function") &&
109 109
                             onFailure(jitsiError);
110 110
                     });
111 111
             };
@@ -276,8 +276,8 @@ var ScreenObtainer = {
276 276
         if ((CHROME_EXTENSION_POPUP_ERROR === e
277 277
              || CHROME_EXTENSION_IFRAME_ERROR === e)
278 278
                 && options.interval > 0
279
-                && typeof(options.checkAgain) === "function"
280
-                && typeof(options.listener) === "function") {
279
+                && typeof options.checkAgain === "function"
280
+                && typeof options.listener === "function") {
281 281
             options.listener("waitingForExtension", webStoreInstallUrl);
282 282
             this.checkForChromeExtensionOnInterval(options, streamCallback,
283 283
                 failCallback, e);
@@ -555,7 +555,7 @@ function initFirefoxExtensionDetection(options) {
555 555
     // Where EXT_ID is the ID of the extension with "@" replaced by ".", and
556 556
     // DOMAIN is a domain whitelisted by the extension.
557 557
     var src = "chrome://" +
558
-        (options.desktopSharingFirefoxExtId.replace('@', '.')) +
558
+        options.desktopSharingFirefoxExtId.replace('@', '.') +
559 559
         "/content/" + document.location.hostname + ".png";
560 560
     img.setAttribute('src', src);
561 561
 }

+ 1
- 1
modules/statistics/CallStats.js Wyświetl plik

@@ -71,7 +71,7 @@ function initCallback (err, msg) {
71 71
         this.confID,
72 72
         this.pcCallback.bind(this));
73 73
 
74
-    var fabricInitialized = (ret.status === 'success');
74
+    var fabricInitialized = ret.status === 'success';
75 75
 
76 76
     if(!fabricInitialized) {
77 77
         CallStats.initializeFailed = true;

+ 2
- 2
modules/statistics/RTPStatsCollector.js Wyświetl plik

@@ -492,8 +492,8 @@ StatsCollector.prototype.processStatsReport = function () {
492 492
 
493 493
         // TODO: clean this mess up!
494 494
         var nowBytesTransmitted = getStatValue(now, "bytesSent");
495
-        if(typeof(nowBytesTransmitted) === "number" ||
496
-            typeof(nowBytesTransmitted) === "string") {
495
+        if(typeof nowBytesTransmitted === "number" ||
496
+            typeof nowBytesTransmitted === "string") {
497 497
             nowBytesTransmitted = Number(nowBytesTransmitted);
498 498
             if(!isNaN(nowBytesTransmitted)){
499 499
                 byteSentStats[ssrc] = nowBytesTransmitted;

+ 2
- 2
modules/transcription/audioRecorder.js Wyświetl plik

@@ -294,10 +294,10 @@ audioRecorder.prototype.getFileType = function () {
294 294
  */
295 295
 function createEmptyStream() {
296 296
     // Firefox supports the MediaStream object, Chrome webkitMediaStream
297
-    if(typeof(MediaStream) !== 'undefined') {
297
+    if(typeof MediaStream !== 'undefined') {
298 298
         return new MediaStream();
299 299
     }
300
-    else if(typeof(webkitMediaStream) !== 'undefined') {
300
+    else if(typeof webkitMediaStream !== 'undefined') {
301 301
         return new webkitMediaStream(); // eslint-disable-line new-cap
302 302
     }
303 303
     else {

+ 1
- 1
modules/transcription/transcriptionServices/SphinxTranscriptionService.js Wyświetl plik

@@ -79,7 +79,7 @@ SphinxService.prototype.formatResponse = function(response) {
79 79
 SphinxService.prototype.verify = function(response){
80 80
     console.log("response from server:" + response.toString());
81 81
     //test if server responded with a string object
82
-    if(typeof(response) !== "string"){
82
+    if(typeof response !== "string"){
83 83
         return false;
84 84
     }
85 85
     //test if the string can be parsed into valid JSON

+ 2
- 2
modules/util/EventEmitterForwarder.js Wyświetl plik

@@ -6,8 +6,8 @@
6 6
  * implements emit method which will emit an event.
7 7
  */
8 8
 function EventEmitterForwarder (src, dest) {
9
-    if (!src || !dest || typeof(src.addListener) !== "function" ||
10
-        typeof(dest.emit) !== "function")
9
+    if (!src || !dest || typeof src.addListener !== "function" ||
10
+        typeof dest.emit !== "function")
11 11
         throw new Error("Invalid arguments passed to EventEmitterForwarder");
12 12
     this.src = src;
13 13
     this.dest = dest;

+ 2
- 2
modules/xmpp/Caps.js Wyświetl plik

@@ -103,10 +103,10 @@ export default class Caps extends Listenable {
103 103
      */
104 104
     getFeatures(jid, timeout = 5000) {
105 105
         let user
106
-            = (jid in this.jidToVersion) ? this.jidToVersion[jid] : null;
106
+            = jid in this.jidToVersion ? this.jidToVersion[jid] : null;
107 107
         if(!user || !(user.version in this.versionToCapabilities))
108 108
         {
109
-            const node = (user)? user.node + "#" + user.version : null;
109
+            const node = user? user.node + "#" + user.version : null;
110 110
             return new Promise ( (resolve, reject) =>
111 111
                 this.disco.info(jid, node, response => {
112 112
                         const features = new Set();

+ 2
- 2
modules/xmpp/ChatRoom.js Wyświetl plik

@@ -790,14 +790,14 @@ export default class ChatRoom extends Listenable {
790 790
      * and "off" if the recording is not started.
791 791
      */
792 792
     getRecordingState () {
793
-        return (this.recording) ? this.recording.getState() : undefined;
793
+        return this.recording ? this.recording.getState() : undefined;
794 794
     }
795 795
 
796 796
     /**
797 797
      * Returns the url of the recorded video.
798 798
      */
799 799
     getRecordingURL () {
800
-        return (this.recording) ? this.recording.getURL() : null;
800
+        return this.recording ? this.recording.getURL() : null;
801 801
     }
802 802
 
803 803
     /**

+ 1
- 1
modules/xmpp/JingleSessionPC.js Wyświetl plik

@@ -266,7 +266,7 @@ export default class JingleSessionPC extends JingleSession {
266 266
                 cand.c('content', {
267 267
                     creator: this.initiator == this.localJid
268 268
                                     ? 'initiator' : 'responder',
269
-                    name: (cands[0].sdpMid ? cands[0].sdpMid : mline.media)
269
+                    name: cands[0].sdpMid ? cands[0].sdpMid : mline.media
270 270
                 }).c('transport', ice);
271 271
                 for (let i = 0; i < cands.length; i++) {
272 272
                     const candidate

+ 4
- 4
modules/xmpp/SDP.js Wyświetl plik

@@ -398,8 +398,8 @@ SDP.prototype.transportToJingle = function (mediaindex, elem) {
398 398
                 if (self.failICE) {
399 399
                     candidate.ip = "1.1.1.1";
400 400
                 }
401
-                var protocol = (candidate &&
402
-                        typeof candidate.protocol === 'string')
401
+                var protocol = candidate &&
402
+                        typeof candidate.protocol === 'string'
403 403
                     ? candidate.protocol.toLowerCase() : '';
404 404
                 if ((self.removeTcpCandidates
405 405
                         && (protocol === 'tcp' || protocol === 'ssltcp')) ||
@@ -587,7 +587,7 @@ SDP.prototype.jingle2media = function (content) {
587 587
             media += 'a=fmtp:' + this.getAttribute('id') + ' ';
588 588
             media += $(this).find('parameter').map(function () {
589 589
                 return (this.getAttribute('name')
590
-                        ? (this.getAttribute('name') + '=') : '') +
590
+                        ? this.getAttribute('name') + '=' : '') +
591 591
                     this.getAttribute('value');
592 592
             }).get().join('; ');
593 593
             media += '\r\n';
@@ -607,7 +607,7 @@ SDP.prototype.jingle2media = function (content) {
607 607
 
608 608
     content.find('>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]>candidate').each(function () {
609 609
         var protocol = this.getAttribute('protocol');
610
-        protocol = (typeof protocol === 'string') ? protocol.toLowerCase(): '';
610
+        protocol = typeof protocol === 'string' ? protocol.toLowerCase(): '';
611 611
 
612 612
         if ((self.removeTcpCandidates
613 613
                 && (protocol === 'tcp' || protocol === 'ssltcp')) ||

+ 7
- 7
modules/xmpp/recording.js Wyświetl plik

@@ -17,9 +17,9 @@ function Recording(type, eventEmitter, connection, focusMucJid, jirecon,
17 17
     this.url = null;
18 18
     this.type = type;
19 19
     this._isSupported
20
-        = ( type === Recording.types.JIRECON && !this.jirecon
20
+        =  type === Recording.types.JIRECON && !this.jirecon
21 21
             || (type !== Recording.types.JIBRI
22
-                && type !== Recording.types.COLIBRI))
22
+                && type !== Recording.types.COLIBRI)
23 23
             ? false : true;
24 24
 
25 25
     /**
@@ -94,7 +94,7 @@ Recording.prototype.setRecordingJibri
94 94
     var iq = $iq({to: this.focusMucJid, type: 'set'})
95 95
         .c('jibri', {
96 96
         "xmlns": 'http://jitsi.org/protocol/jibri',
97
-        "action": (state === Recording.status.ON)
97
+        "action": state === Recording.status.ON
98 98
                     ? Recording.action.START
99 99
                     : Recording.action.STOP,
100 100
         "streamid": options.streamId,
@@ -124,7 +124,7 @@ Recording.prototype.setRecordingJirecon =
124 124
 
125 125
     var iq = $iq({to: this.jirecon, type: 'set'})
126 126
         .c('recording', {xmlns: 'http://jitsi.org/protocol/jirecon',
127
-            action: (state === Recording.status.ON)
127
+            action: state === Recording.status.ON
128 128
                 ? Recording.action.START
129 129
                 : Recording.action.STOP,
130 130
             mucjid: this.roomjid});
@@ -141,7 +141,7 @@ Recording.prototype.setRecordingJirecon =
141 141
             // provisional?
142 142
             self.jireconRid = $(result).find('recording').attr('rid');
143 143
             logger.log('Recording ' +
144
-                ((state === Recording.status.ON) ? 'started' : 'stopped') +
144
+                (state === Recording.status.ON ? 'started' : 'stopped') +
145 145
                 '(jirecon)' + result);
146 146
             self.state = state;
147 147
             if (state === Recording.status.OFF){
@@ -244,8 +244,8 @@ Recording.prototype.toggleRecording = function (options, statusChangeHandler) {
244 244
         return;
245 245
     }
246 246
 
247
-    var newState = (oldState === Recording.status.AVAILABLE
248
-                    || oldState === Recording.status.OFF)
247
+    var newState = oldState === Recording.status.AVAILABLE
248
+                    || oldState === Recording.status.OFF
249 249
                     ? Recording.status.ON
250 250
                     : Recording.status.OFF;
251 251
 

+ 1
- 1
modules/xmpp/xmpp.js Wyświetl plik

@@ -266,7 +266,7 @@ export default class XMPP extends Listenable {
266 266
         let mucNickname = Strophe.getNodeFromJid(this.connection.jid);
267 267
         let roomjid = roomName  + "@" + this.options.hosts.muc + "/";
268 268
         let cfgNickname
269
-            = (options.useNicks && options.nick) ? options.nick : null;
269
+            = options.useNicks && options.nick ? options.nick : null;
270 270
 
271 271
         if (cfgNickname) {
272 272
             // Use nick if it's defined

Ładowanie…
Anuluj
Zapisz