Explorar el Código

[eslint] no-param-reassign

master
Lyubo Marinov hace 8 años
padre
commit
8fbc815836

+ 1
- 0
.eslintrc.js Ver fichero

@@ -106,6 +106,7 @@ module.exports = {
106 106
         'no-new-wrappers': 2,
107 107
         'no-octal': 2,
108 108
         'no-octal-escape': 2,
109
+        'no-param-reassign': 2,
109 110
         'no-proto': 2,
110 111
         'no-redeclare': 2,
111 112
         'no-return-assign': 2,

+ 1
- 5
JitsiConference.js Ver fichero

@@ -100,11 +100,7 @@ function JitsiConference(options) {
100 100
  * @param options {object}
101 101
  * @param connection {JitsiConnection} overrides this.connection
102 102
  */
103
-JitsiConference.prototype._init = function(options) {
104
-    if (!options) {
105
-        options = {};
106
-    }
107
-
103
+JitsiConference.prototype._init = function(options = {}) {
108 104
     // Override connection and xmpp properties (Usefull if the connection
109 105
     // reloaded)
110 106
     if (options.connection) {

+ 1
- 5
JitsiConnection.js Ver fichero

@@ -47,11 +47,7 @@ function JitsiConnection(appID, token, options) {
47 47
  * @param options {object} connecting options
48 48
  * (for example authentications parameters).
49 49
  */
50
-JitsiConnection.prototype.connect = function(options) {
51
-    if (!options) {
52
-        options = {};
53
-    }
54
-
50
+JitsiConnection.prototype.connect = function(options = {}) {
55 51
     this.xmpp.connect(options.id, options.password);
56 52
 };
57 53
 

+ 6
- 4
JitsiMeetJS.js Ver fichero

@@ -60,18 +60,20 @@ function getLowerResolution(resolution) {
60 60
  * @returns {*}
61 61
  */
62 62
 function addDeviceTypeToAnalyticsEvent(name, options) {
63
+    let ret;
64
+
63 65
     if (options.devices.indexOf('audio') !== -1) {
64
-        name += '.audio';
66
+        ret += '.audio';
65 67
     }
66 68
     if (options.devices.indexOf('desktop') !== -1) {
67
-        name += '.desktop';
69
+        ret += '.desktop';
68 70
     }
69 71
     if (options.devices.indexOf('video') !== -1) {
70 72
         // we have video add resolution
71
-        name += `.video.${options.resolution}`;
73
+        ret += `.video.${options.resolution}`;
72 74
     }
73 75
 
74
-    return name;
76
+    return ret;
75 77
 }
76 78
 
77 79
 /**

+ 7
- 7
modules/RTC/JitsiTrack.js Ver fichero

@@ -252,16 +252,16 @@ JitsiTrack.prototype._maybeFireTrackAttached = function(container) {
252 252
  *          library. That's the case when Temasys plugin is in use.
253 253
  */
254 254
 JitsiTrack.prototype.attach = function(container) {
255
+    let c;
256
+
255 257
     if (this.stream) {
256
-        container = RTCUtils.attachMediaStream(container, this.stream);
258
+        c = RTCUtils.attachMediaStream(container, this.stream);
257 259
     }
258
-    this.containers.push(container);
259
-
260
-    this._maybeFireTrackAttached(container);
261
-
262
-    this._attachTTFMTracker(container);
260
+    this.containers.push(c);
261
+    this._maybeFireTrackAttached(c);
262
+    this._attachTTFMTracker(c);
263 263
 
264
-    return container;
264
+    return c;
265 265
 };
266 266
 
267 267
 /**

+ 2
- 4
modules/RTC/RTCUtils.js Ver fichero

@@ -1004,8 +1004,7 @@ class RTCUtils extends Listenable {
1004 1004
             um,
1005 1005
             success_callback,
1006 1006
             failure_callback,
1007
-            options) {
1008
-        options = options || {};
1007
+            options = {}) {
1009 1008
         const constraints = getConstraints(um, options);
1010 1009
 
1011 1010
         logger.info('Get media constraints', constraints);
@@ -1050,10 +1049,9 @@ class RTCUtils extends Listenable {
1050 1049
      * @param {string} options.micDeviceId
1051 1050
      * @returns {*} Promise object that will receive the new JitsiTracks
1052 1051
      */
1053
-    obtainAudioAndVideoPermissions(options) {
1052
+    obtainAudioAndVideoPermissions(options = {}) {
1054 1053
         const self = this;
1055 1054
 
1056
-        options = options || {};
1057 1055
         const dsOptions = options.desktopSharingExtensionExternalInstallation;
1058 1056
 
1059 1057
 

+ 1
- 0
modules/RTC/ScreenObtainer.js Ver fichero

@@ -72,6 +72,7 @@ const ScreenObtainer = {
72 72
     init(options, gum) {
73 73
         let obtainDesktopStream = null;
74 74
 
75
+        // eslint-disable-next-line no-param-reassign
75 76
         this.options = options = options || {};
76 77
         gumFunction = gum;
77 78
 

+ 84
- 85
modules/RTC/TraceablePeerConnection.js Ver fichero

@@ -697,93 +697,90 @@ TraceablePeerConnection.prototype.createDataChannel = function(label, opts) {
697 697
 };
698 698
 
699 699
 TraceablePeerConnection.prototype.setLocalDescription
700
-        = function(description, successCallback, failureCallback) {
701
-            this.trace(
702
-                'setLocalDescription::preTransform',
703
-                dumpSDP(description));
704
-
705
-            // if we're running on FF, transform to Plan A first.
706
-            if (RTCBrowserType.usesUnifiedPlan()) {
707
-                description = this.interop.toUnifiedPlan(description);
708
-                this.trace('setLocalDescription::postTransform (Plan A)',
709
-            dumpSDP(description));
710
-            }
700
+    = function(description, successCallback, failureCallback) {
701
+        let d = description;
711 702
 
712
-            const self = this;
703
+        this.trace('setLocalDescription::preTransform', dumpSDP(d));
713 704
 
714
-            this.peerconnection.setLocalDescription(description,
715
-        () => {
716
-            self.trace('setLocalDescriptionOnSuccess');
717
-            successCallback();
718
-        },
719
-        err => {
720
-            self.trace('setLocalDescriptionOnFailure', err);
721
-            self.eventEmitter.emit(
722
-                RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
723
-                err, self.peerconnection);
724
-            failureCallback(err);
705
+        // if we're running on FF, transform to Plan A first.
706
+        if (RTCBrowserType.usesUnifiedPlan()) {
707
+            d = this.interop.toUnifiedPlan(d);
708
+            this.trace(
709
+                'setLocalDescription::postTransform (Plan A)',
710
+                dumpSDP(d));
725 711
         }
726
-    );
727
-        };
728 712
 
729
-TraceablePeerConnection.prototype.setRemoteDescription
730
-        = function(description, successCallback, failureCallback) {
731
-            this.trace(
732
-                'setRemoteDescription::preTransform',
733
-                dumpSDP(description));
713
+        const self = this;
714
+
715
+        this.peerconnection.setLocalDescription(
716
+            d,
717
+            () => {
718
+                self.trace('setLocalDescriptionOnSuccess');
719
+                successCallback();
720
+            },
721
+            err => {
722
+                self.trace('setLocalDescriptionOnFailure', err);
723
+                self.eventEmitter.emit(
724
+                    RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
725
+                    err, self.peerconnection);
726
+                failureCallback(err);
727
+            }
728
+        );
729
+    };
734 730
 
735
-            // TODO the focus should squeze or explode the remote simulcast
736
-            description = this.simulcast.mungeRemoteDescription(description);
737
-            this.trace(
738
-                'setRemoteDescription::postTransform (simulcast)',
739
-                dumpSDP(description));
731
+TraceablePeerConnection.prototype.setRemoteDescription
732
+    = function(description, successCallback, failureCallback) {
733
+        this.trace('setRemoteDescription::preTransform', dumpSDP(description));
734
+
735
+        // TODO the focus should squeze or explode the remote simulcast
736
+        // eslint-disable-next-line no-param-reassign
737
+        description = this.simulcast.mungeRemoteDescription(description);
738
+        this.trace(
739
+            'setRemoteDescription::postTransform (simulcast)',
740
+            dumpSDP(description));
740 741
 
741
-            if (this.options.preferH264) {
742
-                const parsedSdp = transform.parse(description.sdp);
743
-                const videoMLine
744
-                    = parsedSdp.media.find(m => m.type === 'video');
742
+        if (this.options.preferH264) {
743
+            const parsedSdp = transform.parse(description.sdp);
744
+            const videoMLine = parsedSdp.media.find(m => m.type === 'video');
745 745
 
746
-                SDPUtil.preferVideoCodec(videoMLine, 'h264');
747
-                description.sdp = transform.write(parsedSdp);
748
-            }
746
+            SDPUtil.preferVideoCodec(videoMLine, 'h264');
747
+            description.sdp = transform.write(parsedSdp);
748
+        }
749 749
 
750
-            // if we're running on FF, transform to Plan A first.
751
-            if (RTCBrowserType.usesUnifiedPlan()) {
752
-                description.sdp = this.rtxModifier.stripRtx(description.sdp);
753
-                this.trace(
750
+        // if we're running on FF, transform to Plan A first.
751
+        if (RTCBrowserType.usesUnifiedPlan()) {
752
+            description.sdp = this.rtxModifier.stripRtx(description.sdp);
753
+            this.trace(
754 754
                     'setRemoteDescription::postTransform (stripRtx)',
755 755
                     dumpSDP(description));
756
-                description = this.interop.toUnifiedPlan(description);
757
-                this.trace(
758
-            'setRemoteDescription::postTransform (Plan A)',
759
-            dumpSDP(description));
760
-            }
761 756
 
762
-            if (RTCBrowserType.usesPlanB()) {
763
-                description = normalizePlanB(description);
764
-            }
765
-
766
-            const self = this;
757
+            // eslint-disable-next-line no-param-reassign
758
+            description = this.interop.toUnifiedPlan(description);
759
+            this.trace(
760
+                    'setRemoteDescription::postTransform (Plan A)',
761
+                    dumpSDP(description));
762
+        }
767 763
 
768
-            this.peerconnection.setRemoteDescription(description,
769
-        () => {
770
-            self.trace('setRemoteDescriptionOnSuccess');
771
-            successCallback();
772
-        },
773
-        err => {
774
-            self.trace('setRemoteDescriptionOnFailure', err);
775
-            self.eventEmitter.emit(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
776
-                err, self.peerconnection);
777
-            failureCallback(err);
764
+        if (RTCBrowserType.usesPlanB()) {
765
+            // eslint-disable-next-line no-param-reassign
766
+            description = normalizePlanB(description);
778 767
         }
779
-    );
780 768
 
781
-    /*
782
-     if (this.statsinterval === null && this.maxstats > 0) {
783
-     // start gathering stats
784
-     }
785
-     */
786
-        };
769
+        this.peerconnection.setRemoteDescription(
770
+            description,
771
+            () => {
772
+                this.trace('setRemoteDescriptionOnSuccess');
773
+                successCallback();
774
+            },
775
+            err => {
776
+                this.trace('setRemoteDescriptionOnFailure', err);
777
+                this.eventEmitter.emit(
778
+                    RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
779
+                    err,
780
+                    this.peerconnection);
781
+                failureCallback(err);
782
+            });
783
+    };
787 784
 
788 785
 /**
789 786
  * Makes the underlying TraceablePeerConnection generate new SSRC for
@@ -880,9 +877,9 @@ const _fixAnswerRFC4145Setup = function(offer, answer) {
880 877
 };
881 878
 
882 879
 TraceablePeerConnection.prototype.createAnswer
883
-        = function(successCallback, failureCallback, constraints) {
884
-            this.trace('createAnswer', JSON.stringify(constraints, null, ' '));
885
-            this.peerconnection.createAnswer(
880
+    = function(successCallback, failureCallback, constraints) {
881
+        this.trace('createAnswer', JSON.stringify(constraints, null, ' '));
882
+        this.peerconnection.createAnswer(
886 883
         answer => {
887 884
             try {
888 885
                 this.trace(
@@ -890,6 +887,7 @@ TraceablePeerConnection.prototype.createAnswer
890 887
 
891 888
                 // if we're running on FF, transform to Plan A first.
892 889
                 if (RTCBrowserType.usesUnifiedPlan()) {
890
+                    // eslint-disable-next-line no-param-reassign
893 891
                     answer = this.interop.toPlanB(answer);
894 892
                     this.trace('createAnswerOnSuccess::postTransform (Plan B)',
895 893
                         dumpSDP(answer));
@@ -916,7 +914,9 @@ TraceablePeerConnection.prototype.createAnswer
916 914
 
917 915
                 // Add simulcast streams if simulcast is enabled
918 916
                 if (!this.options.disableSimulcast
919
-                    && this.simulcast.isSupported()) {
917
+                        && this.simulcast.isSupported()) {
918
+
919
+                    // eslint-disable-next-line no-param-reassign
920 920
                     answer = this.simulcast.mungeLocalDescription(answer);
921 921
                     this.trace(
922 922
                         'createAnswerOnSuccess::postTransform (simulcast)',
@@ -955,9 +955,8 @@ TraceablePeerConnection.prototype.createAnswer
955 955
                 this.peerconnection);
956 956
             failureCallback(err);
957 957
         },
958
-        constraints
959
-    );
960
-        };
958
+        constraints);
959
+    };
961 960
 
962 961
 TraceablePeerConnection.prototype.addIceCandidate
963 962
 
@@ -986,13 +985,13 @@ TraceablePeerConnection.prototype.getStats = function(callback, errback) {
986 985
     if (RTCBrowserType.isFirefox()
987 986
             || RTCBrowserType.isTemasysPluginUsed()
988 987
             || RTCBrowserType.isReactNative()) {
989
-        if (!errback) {
990
-            errback = function() {
988
+        this.peerconnection.getStats(
989
+            null,
990
+            callback,
991
+            errback || (() => {
991 992
                 // Making sure that getStats won't fail if error callback is
992 993
                 // not passed.
993
-            };
994
-        }
995
-        this.peerconnection.getStats(null, callback, errback);
994
+            }));
996 995
     } else {
997 996
         this.peerconnection.getStats(callback);
998 997
     }

+ 10
- 6
modules/statistics/CallStats.js Ver fichero

@@ -421,18 +421,22 @@ function(overallFeedback, detailedFeedback) {
421 421
  * @private
422 422
  */
423 423
 CallStats._reportError = function(type, e, pc) {
424
-    if (!e) {
424
+    let error = e;
425
+
426
+    if (!error) {
425 427
         logger.warn('No error is passed!');
426
-        e = new Error('Unknown error');
428
+        error = new Error('Unknown error');
427 429
     }
428 430
     if (CallStats.initialized) {
429
-        callStats.reportError(pc, this.confID, type, e);
431
+        callStats.reportError(pc, this.confID, type, error);
430 432
     } else {
431 433
         CallStats.reportsQueue.push({
432 434
             type: reportType.ERROR,
433
-            data: { type,
434
-                error: e,
435
-                pc }
435
+            data: {
436
+                error,
437
+                pc,
438
+                type
439
+            }
436 440
         });
437 441
         CallStats._checkInitialize();
438 442
     }

+ 1
- 1
modules/util/RandomUtil.js Ver fichero

@@ -63,7 +63,7 @@ const RandomUtil = {
63 63
     randomHexString(len) {
64 64
         let ret = '';
65 65
 
66
-        while (len--) {
66
+        while (len--) { // eslint-disable-line no-param-reassign
67 67
             ret += this.randomHexDigit();
68 68
         }
69 69
 

+ 1
- 0
modules/util/ScriptUtil.js Ver fichero

@@ -41,6 +41,7 @@ const ScriptUtil = {
41 41
                     = scriptSrc.substring(0, scriptSrc.lastIndexOf('/') + 1);
42 42
 
43 43
                 if (scriptSrc && baseScriptSrc) {
44
+                    // eslint-disable-next-line no-param-reassign
44 45
                     src = baseScriptSrc + src;
45 46
                 }
46 47
             }

+ 1
- 0
modules/xmpp/JingleSessionPC.js Ver fichero

@@ -886,6 +886,7 @@ export default class JingleSessionPC extends JingleSession {
886 886
         const remoteSdp = new SDP(this.peerconnection.remoteDescription.sdp);
887 887
 
888 888
         removeSsrcInfo.forEach((lines, idx) => {
889
+            // eslint-disable-next-line no-param-reassign
889 890
             lines = lines.split('\r\n');
890 891
             lines.pop(); // remove empty last element;
891 892
             lines.forEach(line => {

+ 2
- 0
modules/xmpp/SDP.js Ver fichero

@@ -461,6 +461,8 @@ SDP.prototype.transportToJingle = function(mediaindex, elem) {
461 461
         tmp.xmlns = 'urn:xmpp:jingle:apps:dtls:0';
462 462
         elem.c('fingerprint').t(tmp.fingerprint);
463 463
         delete tmp.fingerprint;
464
+
465
+        // eslint-disable-next-line no-param-reassign
464 466
         line
465 467
             = SDPUtil.find_line(
466 468
                 self.media[mediaindex],

+ 2
- 0
modules/xmpp/SDPUtil.js Ver fichero

@@ -331,6 +331,7 @@ const SDPUtil = {
331 331
         //      <candidate component=... foundation=... generation=... id=...
332 332
         // ip=... network=... port=... priority=... protocol=... type=.../>
333 333
         if (line.indexOf('candidate:') === 0) {
334
+            // eslint-disable-next-line no-param-reassign
334 335
             line = `a=${line}`;
335 336
         } else if (line.substring(0, 12) != 'a=candidate:') {
336 337
             logger.log(
@@ -341,6 +342,7 @@ const SDPUtil = {
341 342
             return null;
342 343
         }
343 344
         if (line.substring(line.length - 2) == '\r\n') { // chomp it
345
+            // eslint-disable-next-line no-param-reassign
344 346
             line = line.substring(0, line.length - 2);
345 347
         }
346 348
         const candidate = {};

+ 3
- 4
modules/xmpp/recording.js Ver fichero

@@ -1,4 +1,4 @@
1
-/* global $, $iq */
1
+  /* global $, $iq */
2 2
 
3 3
 import { getLogger } from 'jitsi-meet-logger';
4 4
 const logger = getLogger(__filename);
@@ -85,14 +85,13 @@ Recording.prototype.handleJibriPresence = function(jibri) {
85 85
 };
86 86
 
87 87
 Recording.prototype.setRecordingJibri
88
-    = function(state, callback, errCallback, options) {
88
+    = function(state, callback, errCallback, options = {}) {
89 89
 
90 90
         if (state == this.state) {
91 91
             errCallback(JitsiRecorderErrors.INVALID_STATE);
92 92
         }
93
-        options = options || {};
94 93
 
95
-    // FIXME jibri does not accept IQ without 'url' attribute set ?
94
+        // FIXME jibri does not accept IQ without 'url' attribute set ?
96 95
         const iq
97 96
             = $iq({ to: this.focusMucJid,
98 97
                 type: 'set' })

+ 1
- 0
modules/xmpp/strophe.jingle.js Ver fichero

@@ -218,6 +218,7 @@ class JingleConnectionPlugin extends ConnectionPlugin {
218 218
                 const iceservers = [];
219 219
 
220 220
                 $(res).find('>services>service').each((idx, el) => {
221
+                    // eslint-disable-next-line no-param-reassign
221 222
                     el = $(el);
222 223
                     const dict = {};
223 224
                     const type = el.attr('type');

+ 2
- 0
modules/xmpp/strophe.util.js Ver fichero

@@ -53,6 +53,7 @@ export default function() {
53 53
         if (typeof msg === 'string'
54 54
                 && msg.indexOf('Request ') !== -1
55 55
                 && msg.indexOf('timed out (secondary), restarting') !== -1) {
56
+            // eslint-disable-next-line no-param-reassign
56 57
             level = Strophe.LogLevel.WARN;
57 58
         }
58 59
 
@@ -79,6 +80,7 @@ export default function() {
79 80
             break;
80 81
         case Strophe.LogLevel.ERROR:
81 82
         case Strophe.LogLevel.FATAL:
83
+            // eslint-disable-next-line no-param-reassign
82 84
             msg = `Strophe: ${msg}`;
83 85
             GlobalOnErrorHandler.callErrorHandler(new Error(msg));
84 86
             logger.error(msg);

+ 3
- 0
modules/xmpp/xmpp.js Ver fichero

@@ -19,6 +19,7 @@ import Caps from './Caps';
19 19
 function createConnection(token, bosh = '/http-bind') {
20 20
     // Append token as URL param
21 21
     if (token) {
22
+        // eslint-disable-next-line no-param-reassign
22 23
         bosh += `${bosh.indexOf('?') == -1 ? '?' : '&'}token=${token}`;
23 24
     }
24 25
 
@@ -271,6 +272,8 @@ export default class XMPP extends Listenable {
271 272
                         || this.options.token)) {
272 273
                 configDomain = this.options.hosts.domain;
273 274
             }
275
+
276
+            // eslint-disable-next-line no-param-reassign
274 277
             jid = configDomain || window.location.hostname;
275 278
         }
276 279
 

Loading…
Cancelar
Guardar