浏览代码

[eslint] no-shadow

dev1
Lyubo Marinov 8 年前
父节点
当前提交
146148483e

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

@@ -146,6 +146,7 @@ module.exports = {
146 146
         'no-delete-var': 2,
147 147
         'no-label-var': 2,
148 148
         'no-restricted-globals': 0,
149
+        'no-shadow': 2,
149 150
         'no-shadow-restricted-names': 2,
150 151
         'no-undef': 2,
151 152
         'no-undef-init': 2,

+ 3
- 3
JitsiMeetJS.js 查看文件

@@ -39,11 +39,11 @@ function getLowerResolution(resolution) {
39 39
     let res = null;
40 40
     let resName = null;
41 41
 
42
-    Object.keys(Resolutions).forEach(resolution => {
43
-        const value = Resolutions[resolution];
42
+    Object.keys(Resolutions).forEach(r => {
43
+        const value = Resolutions[r];
44 44
 
45 45
         if (!res || (res.order < value.order && value.order < order)) {
46
-            resName = resolution;
46
+            resName = r;
47 47
             res = value;
48 48
         }
49 49
     });

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

@@ -69,9 +69,7 @@ DataChannels.prototype.onDataChannel = function(event) {
69 69
         logger.error('Data Channel Error:', error, dataChannel);
70 70
     };
71 71
 
72
-    dataChannel.onmessage = function(event) {
73
-        const data = event.data;
74
-
72
+    dataChannel.onmessage = function({ data }) {
75 73
         // JSON
76 74
         let obj;
77 75
 

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

@@ -380,13 +380,13 @@ function pollForAvailableMediaDevices() {
380 380
     // do not matter. This fixes situation when we have no devices initially,
381 381
     // and then plug in a new one.
382 382
     if (rawEnumerateDevicesWithCallback) {
383
-        rawEnumerateDevicesWithCallback(devices => {
383
+        rawEnumerateDevicesWithCallback(ds => {
384 384
             // We don't fire RTCEvents.DEVICE_LIST_CHANGED for the first time
385 385
             // we call enumerateDevices(). This is the initial step.
386 386
             if (typeof currentlyAvailableMediaDevices === 'undefined') {
387
-                currentlyAvailableMediaDevices = devices.slice(0);
388
-            } else if (compareAvailableMediaDevices(devices)) {
389
-                onMediaDevicesListChanged(devices);
387
+                currentlyAvailableMediaDevices = ds.slice(0);
388
+            } else if (compareAvailableMediaDevices(ds)) {
389
+                onMediaDevicesListChanged(ds);
390 390
             }
391 391
 
392 392
             window.setTimeout(pollForAvailableMediaDevices,
@@ -443,8 +443,8 @@ function onReady(options, GUM) {
443 443
     initRawEnumerateDevicesWithCallback();
444 444
 
445 445
     if (rtcUtils.isDeviceListAvailable() && rawEnumerateDevicesWithCallback) {
446
-        rawEnumerateDevicesWithCallback(devices => {
447
-            currentlyAvailableMediaDevices = devices.splice(0);
446
+        rawEnumerateDevicesWithCallback(ds => {
447
+            currentlyAvailableMediaDevices = ds.splice(0);
448 448
 
449 449
             eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
450 450
                 currentlyAvailableMediaDevices);
@@ -564,9 +564,7 @@ function obtainDevices(options) {
564 564
     }
565 565
 
566 566
     const device = options.devices.splice(0, 1);
567
-    const devices = [];
568 567
 
569
-    devices.push(device);
570 568
     options.deviceGUM[device](
571 569
         stream => {
572 570
             options.streams = options.streams || {};
@@ -574,9 +572,8 @@ function obtainDevices(options) {
574 572
             obtainDevices(options);
575 573
         },
576 574
         error => {
577
-            Object.keys(options.streams).forEach(device => {
578
-                rtcUtils.stopMediaStream(options.streams[device]);
579
-            });
575
+            Object.keys(options.streams).forEach(
576
+                d => rtcUtils.stopMediaStream(options.streams[d]));
580 577
             logger.error(
581 578
                 `failed to obtain ${device} stream - stop`, error);
582 579
 
@@ -949,7 +946,7 @@ class RTCUtils extends Listenable {
949 946
                         this.getUserMediaWithConstraints.bind(this));
950 947
                 };
951 948
                 const webRTCReadyPromise
952
-                    = new Promise(resolve => AdapterJS.webRTCReady(resolve));
949
+                    = new Promise(r => AdapterJS.webRTCReady(r));
953 950
 
954 951
                 // Resolve or reject depending on whether the Temasys plugin is
955 952
                 // installed.
@@ -1137,6 +1134,7 @@ class RTCUtils extends Listenable {
1137 1134
                                 // didn't get corresponding MediaStreamTrack in
1138 1135
                                 // response stream. We don't know the reason why
1139 1136
                                 // this happened, so reject with general error.
1137
+                                // eslint-disable-next-line no-shadow
1140 1138
                                 const devices = [];
1141 1139
 
1142 1140
                                 if (audioDeviceRequested
@@ -1374,7 +1372,7 @@ class RTCUtils extends Listenable {
1374 1372
      * @returns {MediaDeviceInfo} device.
1375 1373
      */
1376 1374
     getEventDataForActiveDevice(device) {
1377
-        const devices = [];
1375
+        const deviceList = [];
1378 1376
         const deviceData = {
1379 1377
             'deviceId': device.deviceId,
1380 1378
             'kind': device.kind,
@@ -1382,9 +1380,9 @@ class RTCUtils extends Listenable {
1382 1380
             'groupId': device.groupId
1383 1381
         };
1384 1382
 
1385
-        devices.push(deviceData);
1383
+        deviceList.push(deviceData);
1386 1384
 
1387
-        return { deviceList: devices };
1385
+        return { deviceList };
1388 1386
     }
1389 1387
 }
1390 1388
 

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

@@ -81,7 +81,7 @@ const ScreenObtainer = {
81 81
         }
82 82
 
83 83
         if (RTCBrowserType.isNWJS()) {
84
-            obtainDesktopStream = (options, onSuccess, onFailure) => {
84
+            obtainDesktopStream = (_, onSuccess, onFailure) => {
85 85
                 window.JitsiMeetNW.obtainDesktopStream(
86 86
                     onSuccess,
87 87
                     (error, constraints) => {
@@ -116,7 +116,7 @@ const ScreenObtainer = {
116 116
                     });
117 117
             };
118 118
         } else if (RTCBrowserType.isElectron()) {
119
-            obtainDesktopStream = (options, onSuccess, onFailure) =>
119
+            obtainDesktopStream = (_, onSuccess, onFailure) =>
120 120
                 window.JitsiMeetElectron.obtainDesktopStream(
121 121
                     streamId =>
122 122
                         onGetStreamResponse({ streamId }, onSuccess, onFailure),

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

@@ -185,23 +185,25 @@ function TraceablePeerConnection(rtc, id, signalingLayer, iceConfig,
185 185
 
186 186
                 for (let i = 0; i < results.length; ++i) {
187 187
                     results[i].names().forEach(name => {
188
+                        // eslint-disable-next-line no-shadow
188 189
                         const id = `${results[i].id}-${name}`;
190
+                        let s = self.stats[id];
189 191
 
190
-                        if (!self.stats[id]) {
191
-                            self.stats[id] = {
192
+                        if (!s) {
193
+                            self.stats[id] = s = {
192 194
                                 startTime: now,
193 195
                                 endTime: now,
194 196
                                 values: [],
195 197
                                 times: []
196 198
                             };
197 199
                         }
198
-                        self.stats[id].values.push(results[i].stat(name));
199
-                        self.stats[id].times.push(now.getTime());
200
-                        if (self.stats[id].values.length > self.maxstats) {
201
-                            self.stats[id].values.shift();
202
-                            self.stats[id].times.shift();
200
+                        s.values.push(results[i].stat(name));
201
+                        s.times.push(now.getTime());
202
+                        if (s.values.length > self.maxstats) {
203
+                            s.values.shift();
204
+                            s.times.shift();
203 205
                         }
204
-                        self.stats[id].endTime = now;
206
+                        s.endTime = now;
205 207
                     });
206 208
                 }
207 209
             });
@@ -287,8 +289,7 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function(stream, track) {
287 289
 
288 290
     const remoteSDP = new SDP(this.remoteDescription.sdp);
289 291
     const mediaLines
290
-        = remoteSDP.media.filter(
291
-            mediaLines => mediaLines.startsWith(`m=${mediaType}`));
292
+        = remoteSDP.media.filter(mls => mls.startsWith(`m=${mediaType}`));
292 293
 
293 294
     if (!mediaLines.length) {
294 295
         GlobalOnErrorHandler.callErrorHandler(
@@ -542,6 +543,7 @@ const normalizePlanB = function(desc) {
542 543
         return desc;
543 544
     }
544 545
 
546
+    // eslint-disable-next-line no-shadow
545 547
     const transform = require('sdp-transform');
546 548
     const session = transform.parse(desc.sdp);
547 549
 

+ 1
- 1
modules/transcription/audioRecorder.js 查看文件

@@ -71,7 +71,7 @@ function instantiateTrackRecorder(track) {
71 71
     const originalStream = trackRecorder.track.getOriginalStream();
72 72
     const stream = createEmptyStream();
73 73
 
74
-    originalStream.getAudioTracks().forEach(track => stream.addTrack(track));
74
+    originalStream.getAudioTracks().forEach(t => stream.addTrack(t));
75 75
 
76 76
     // Create the MediaRecorder
77 77
     trackRecorder.recorder = new MediaRecorder(stream,

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

@@ -348,18 +348,18 @@ export default class JingleSessionPC extends JingleSession {
348 348
     }
349 349
 
350 350
     readSsrcInfo(contents) {
351
-        $(contents).each((idx, content) => {
351
+        $(contents).each((i1, content) => {
352 352
             const ssrcs
353 353
                 = $(content).find(
354 354
                     'description>'
355 355
                         + 'source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
356 356
 
357
-            ssrcs.each((idx, ssrcElement) => {
357
+            ssrcs.each((i2, ssrcElement) => {
358 358
                 const ssrc = ssrcElement.getAttribute('ssrc');
359 359
 
360 360
                 $(ssrcElement)
361 361
                     .find('>ssrc-info[xmlns="http://jitsi.org/jitmeet"]')
362
-                    .each((idx, ssrcInfoElement) => {
362
+                    .each((i3, ssrcInfoElement) => {
363 363
                         const owner = ssrcInfoElement.getAttribute('owner');
364 364
 
365 365
                         if (owner && owner.length) {
@@ -682,7 +682,7 @@ export default class JingleSessionPC extends JingleSession {
682 682
     _parseSsrcInfoFromSourceAdd(sourceAddElem, currentRemoteSdp) {
683 683
         const addSsrcInfo = [];
684 684
 
685
-        $(sourceAddElem).each((idx, content) => {
685
+        $(sourceAddElem).each((i1, content) => {
686 686
             const name = $(content).attr('name');
687 687
             let lines = '';
688 688
 
@@ -729,14 +729,14 @@ export default class JingleSessionPC extends JingleSession {
729 729
                     lines += '\r\n';
730 730
                 });
731 731
             });
732
-            currentRemoteSdp.media.forEach((media, idx) => {
732
+            currentRemoteSdp.media.forEach((media, i2) => {
733 733
                 if (!SDPUtil.findLine(media, `a=mid:${name}`)) {
734 734
                     return;
735 735
                 }
736
-                if (!addSsrcInfo[idx]) {
737
-                    addSsrcInfo[idx] = '';
736
+                if (!addSsrcInfo[i2]) {
737
+                    addSsrcInfo[i2] = '';
738 738
                 }
739
-                addSsrcInfo[idx] += lines;
739
+                addSsrcInfo[i2] += lines;
740 740
             });
741 741
         });
742 742
 
@@ -1091,7 +1091,7 @@ export default class JingleSessionPC extends JingleSession {
1091 1091
     _parseSsrcInfoFromSourceRemove(sourceRemoveElem, currentRemoteSdp) {
1092 1092
         const removeSsrcInfo = [];
1093 1093
 
1094
-        $(sourceRemoveElem).each((idx, content) => {
1094
+        $(sourceRemoveElem).each((i1, content) => {
1095 1095
             const name = $(content).attr('name');
1096 1096
             let lines = '';
1097 1097
 
@@ -1125,22 +1125,22 @@ export default class JingleSessionPC extends JingleSession {
1125 1125
 
1126 1126
                 ssrcs.push(ssrc);
1127 1127
             });
1128
-            currentRemoteSdp.media.forEach((media, idx) => {
1128
+            currentRemoteSdp.media.forEach((media, i2) => {
1129 1129
                 if (!SDPUtil.findLine(media, `a=mid:${name}`)) {
1130 1130
                     return;
1131 1131
                 }
1132
-                if (!removeSsrcInfo[idx]) {
1133
-                    removeSsrcInfo[idx] = '';
1132
+                if (!removeSsrcInfo[i2]) {
1133
+                    removeSsrcInfo[i2] = '';
1134 1134
                 }
1135 1135
                 ssrcs.forEach(ssrc => {
1136 1136
                     const ssrcLines
1137 1137
                         = SDPUtil.findLines(media, `a=ssrc:${ssrc}`);
1138 1138
 
1139 1139
                     if (ssrcLines.length) {
1140
-                        removeSsrcInfo[idx] += `${ssrcLines.join('\r\n')}\r\n`;
1140
+                        removeSsrcInfo[i2] += `${ssrcLines.join('\r\n')}\r\n`;
1141 1141
                     }
1142 1142
                 });
1143
-                removeSsrcInfo[idx] += lines;
1143
+                removeSsrcInfo[i2] += lines;
1144 1144
             });
1145 1145
         });
1146 1146
 

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

@@ -287,9 +287,9 @@ SDP.prototype.toJingle = function(elem, thecreator) {
287 287
                         if (kv.indexOf(':') === -1) {
288 288
                             elem.attrs({ name: kv });
289 289
                         } else {
290
-                            const k = kv.split(':', 2)[0];
290
+                            const name = kv.split(':', 2)[0];
291 291
 
292
-                            elem.attrs({ name: k });
292
+                            elem.attrs({ name });
293 293
 
294 294
                             let v = kv.split(':', 2)[1];
295 295
 
@@ -352,7 +352,7 @@ SDP.prototype.toJingle = function(elem, thecreator) {
352 352
                     if (ssrcs.length) {
353 353
                         elem.c('ssrc-group', { semantics,
354 354
                             xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
355
-                        ssrcs.forEach(ssrc => elem.c('source', { ssrc }).up());
355
+                        ssrcs.forEach(s => elem.c('source', { ssrc: s }).up());
356 356
                         elem.up();
357 357
                     }
358 358
                 });
@@ -586,7 +586,7 @@ SDP.prototype.fromJingle = function(jingle) {
586 586
             const contents
587 587
                 = $(group)
588 588
                     .find('>content')
589
-                    .map((idx, content) => content.getAttribute('name'))
589
+                    .map((_, content) => content.getAttribute('name'))
590 590
                     .get();
591 591
 
592 592
             if (contents.length > 0) {

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

@@ -194,11 +194,11 @@ Recording.prototype.setRecordingColibri
194 194
             if (newState === 'pending') {
195 195
                 self.connection.addHandler(iq => {
196 196
                     // eslint-disable-next-line newline-per-chained-call
197
-                    const state = $(iq).find('recording').attr('state');
197
+                    const s = $(iq).find('recording').attr('state');
198 198
 
199
-                    if (state) {
199
+                    if (s) {
200 200
                         self.state = newState;
201
-                        callback(state);
201
+                        callback(s);
202 202
                     }
203 203
                 }, 'http://jitsi.org/protocol/colibri', 'iq', null, null, null);
204 204
             }

正在加载...
取消
保存