瀏覽代碼

[eslint] no-shadow

dev1
Lyubo Marinov 8 年之前
父節點
當前提交
146148483e

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

146
         'no-delete-var': 2,
146
         'no-delete-var': 2,
147
         'no-label-var': 2,
147
         'no-label-var': 2,
148
         'no-restricted-globals': 0,
148
         'no-restricted-globals': 0,
149
+        'no-shadow': 2,
149
         'no-shadow-restricted-names': 2,
150
         'no-shadow-restricted-names': 2,
150
         'no-undef': 2,
151
         'no-undef': 2,
151
         'no-undef-init': 2,
152
         'no-undef-init': 2,

+ 3
- 3
JitsiMeetJS.js 查看文件

39
     let res = null;
39
     let res = null;
40
     let resName = null;
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
         if (!res || (res.order < value.order && value.order < order)) {
45
         if (!res || (res.order < value.order && value.order < order)) {
46
-            resName = resolution;
46
+            resName = r;
47
             res = value;
47
             res = value;
48
         }
48
         }
49
     });
49
     });

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

69
         logger.error('Data Channel Error:', error, dataChannel);
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
         // JSON
73
         // JSON
76
         let obj;
74
         let obj;
77
 
75
 

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

380
     // do not matter. This fixes situation when we have no devices initially,
380
     // do not matter. This fixes situation when we have no devices initially,
381
     // and then plug in a new one.
381
     // and then plug in a new one.
382
     if (rawEnumerateDevicesWithCallback) {
382
     if (rawEnumerateDevicesWithCallback) {
383
-        rawEnumerateDevicesWithCallback(devices => {
383
+        rawEnumerateDevicesWithCallback(ds => {
384
             // We don't fire RTCEvents.DEVICE_LIST_CHANGED for the first time
384
             // We don't fire RTCEvents.DEVICE_LIST_CHANGED for the first time
385
             // we call enumerateDevices(). This is the initial step.
385
             // we call enumerateDevices(). This is the initial step.
386
             if (typeof currentlyAvailableMediaDevices === 'undefined') {
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
             window.setTimeout(pollForAvailableMediaDevices,
392
             window.setTimeout(pollForAvailableMediaDevices,
443
     initRawEnumerateDevicesWithCallback();
443
     initRawEnumerateDevicesWithCallback();
444
 
444
 
445
     if (rtcUtils.isDeviceListAvailable() && rawEnumerateDevicesWithCallback) {
445
     if (rtcUtils.isDeviceListAvailable() && rawEnumerateDevicesWithCallback) {
446
-        rawEnumerateDevicesWithCallback(devices => {
447
-            currentlyAvailableMediaDevices = devices.splice(0);
446
+        rawEnumerateDevicesWithCallback(ds => {
447
+            currentlyAvailableMediaDevices = ds.splice(0);
448
 
448
 
449
             eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
449
             eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
450
                 currentlyAvailableMediaDevices);
450
                 currentlyAvailableMediaDevices);
564
     }
564
     }
565
 
565
 
566
     const device = options.devices.splice(0, 1);
566
     const device = options.devices.splice(0, 1);
567
-    const devices = [];
568
 
567
 
569
-    devices.push(device);
570
     options.deviceGUM[device](
568
     options.deviceGUM[device](
571
         stream => {
569
         stream => {
572
             options.streams = options.streams || {};
570
             options.streams = options.streams || {};
574
             obtainDevices(options);
572
             obtainDevices(options);
575
         },
573
         },
576
         error => {
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
             logger.error(
577
             logger.error(
581
                 `failed to obtain ${device} stream - stop`, error);
578
                 `failed to obtain ${device} stream - stop`, error);
582
 
579
 
949
                         this.getUserMediaWithConstraints.bind(this));
946
                         this.getUserMediaWithConstraints.bind(this));
950
                 };
947
                 };
951
                 const webRTCReadyPromise
948
                 const webRTCReadyPromise
952
-                    = new Promise(resolve => AdapterJS.webRTCReady(resolve));
949
+                    = new Promise(r => AdapterJS.webRTCReady(r));
953
 
950
 
954
                 // Resolve or reject depending on whether the Temasys plugin is
951
                 // Resolve or reject depending on whether the Temasys plugin is
955
                 // installed.
952
                 // installed.
1137
                                 // didn't get corresponding MediaStreamTrack in
1134
                                 // didn't get corresponding MediaStreamTrack in
1138
                                 // response stream. We don't know the reason why
1135
                                 // response stream. We don't know the reason why
1139
                                 // this happened, so reject with general error.
1136
                                 // this happened, so reject with general error.
1137
+                                // eslint-disable-next-line no-shadow
1140
                                 const devices = [];
1138
                                 const devices = [];
1141
 
1139
 
1142
                                 if (audioDeviceRequested
1140
                                 if (audioDeviceRequested
1374
      * @returns {MediaDeviceInfo} device.
1372
      * @returns {MediaDeviceInfo} device.
1375
      */
1373
      */
1376
     getEventDataForActiveDevice(device) {
1374
     getEventDataForActiveDevice(device) {
1377
-        const devices = [];
1375
+        const deviceList = [];
1378
         const deviceData = {
1376
         const deviceData = {
1379
             'deviceId': device.deviceId,
1377
             'deviceId': device.deviceId,
1380
             'kind': device.kind,
1378
             'kind': device.kind,
1382
             'groupId': device.groupId
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
         }
81
         }
82
 
82
 
83
         if (RTCBrowserType.isNWJS()) {
83
         if (RTCBrowserType.isNWJS()) {
84
-            obtainDesktopStream = (options, onSuccess, onFailure) => {
84
+            obtainDesktopStream = (_, onSuccess, onFailure) => {
85
                 window.JitsiMeetNW.obtainDesktopStream(
85
                 window.JitsiMeetNW.obtainDesktopStream(
86
                     onSuccess,
86
                     onSuccess,
87
                     (error, constraints) => {
87
                     (error, constraints) => {
116
                     });
116
                     });
117
             };
117
             };
118
         } else if (RTCBrowserType.isElectron()) {
118
         } else if (RTCBrowserType.isElectron()) {
119
-            obtainDesktopStream = (options, onSuccess, onFailure) =>
119
+            obtainDesktopStream = (_, onSuccess, onFailure) =>
120
                 window.JitsiMeetElectron.obtainDesktopStream(
120
                 window.JitsiMeetElectron.obtainDesktopStream(
121
                     streamId =>
121
                     streamId =>
122
                         onGetStreamResponse({ streamId }, onSuccess, onFailure),
122
                         onGetStreamResponse({ streamId }, onSuccess, onFailure),

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

185
 
185
 
186
                 for (let i = 0; i < results.length; ++i) {
186
                 for (let i = 0; i < results.length; ++i) {
187
                     results[i].names().forEach(name => {
187
                     results[i].names().forEach(name => {
188
+                        // eslint-disable-next-line no-shadow
188
                         const id = `${results[i].id}-${name}`;
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
                                 startTime: now,
194
                                 startTime: now,
193
                                 endTime: now,
195
                                 endTime: now,
194
                                 values: [],
196
                                 values: [],
195
                                 times: []
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
 
289
 
288
     const remoteSDP = new SDP(this.remoteDescription.sdp);
290
     const remoteSDP = new SDP(this.remoteDescription.sdp);
289
     const mediaLines
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
     if (!mediaLines.length) {
294
     if (!mediaLines.length) {
294
         GlobalOnErrorHandler.callErrorHandler(
295
         GlobalOnErrorHandler.callErrorHandler(
542
         return desc;
543
         return desc;
543
     }
544
     }
544
 
545
 
546
+    // eslint-disable-next-line no-shadow
545
     const transform = require('sdp-transform');
547
     const transform = require('sdp-transform');
546
     const session = transform.parse(desc.sdp);
548
     const session = transform.parse(desc.sdp);
547
 
549
 

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

71
     const originalStream = trackRecorder.track.getOriginalStream();
71
     const originalStream = trackRecorder.track.getOriginalStream();
72
     const stream = createEmptyStream();
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
     // Create the MediaRecorder
76
     // Create the MediaRecorder
77
     trackRecorder.recorder = new MediaRecorder(stream,
77
     trackRecorder.recorder = new MediaRecorder(stream,

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

348
     }
348
     }
349
 
349
 
350
     readSsrcInfo(contents) {
350
     readSsrcInfo(contents) {
351
-        $(contents).each((idx, content) => {
351
+        $(contents).each((i1, content) => {
352
             const ssrcs
352
             const ssrcs
353
                 = $(content).find(
353
                 = $(content).find(
354
                     'description>'
354
                     'description>'
355
                         + 'source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
355
                         + 'source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
356
 
356
 
357
-            ssrcs.each((idx, ssrcElement) => {
357
+            ssrcs.each((i2, ssrcElement) => {
358
                 const ssrc = ssrcElement.getAttribute('ssrc');
358
                 const ssrc = ssrcElement.getAttribute('ssrc');
359
 
359
 
360
                 $(ssrcElement)
360
                 $(ssrcElement)
361
                     .find('>ssrc-info[xmlns="http://jitsi.org/jitmeet"]')
361
                     .find('>ssrc-info[xmlns="http://jitsi.org/jitmeet"]')
362
-                    .each((idx, ssrcInfoElement) => {
362
+                    .each((i3, ssrcInfoElement) => {
363
                         const owner = ssrcInfoElement.getAttribute('owner');
363
                         const owner = ssrcInfoElement.getAttribute('owner');
364
 
364
 
365
                         if (owner && owner.length) {
365
                         if (owner && owner.length) {
682
     _parseSsrcInfoFromSourceAdd(sourceAddElem, currentRemoteSdp) {
682
     _parseSsrcInfoFromSourceAdd(sourceAddElem, currentRemoteSdp) {
683
         const addSsrcInfo = [];
683
         const addSsrcInfo = [];
684
 
684
 
685
-        $(sourceAddElem).each((idx, content) => {
685
+        $(sourceAddElem).each((i1, content) => {
686
             const name = $(content).attr('name');
686
             const name = $(content).attr('name');
687
             let lines = '';
687
             let lines = '';
688
 
688
 
729
                     lines += '\r\n';
729
                     lines += '\r\n';
730
                 });
730
                 });
731
             });
731
             });
732
-            currentRemoteSdp.media.forEach((media, idx) => {
732
+            currentRemoteSdp.media.forEach((media, i2) => {
733
                 if (!SDPUtil.findLine(media, `a=mid:${name}`)) {
733
                 if (!SDPUtil.findLine(media, `a=mid:${name}`)) {
734
                     return;
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
     _parseSsrcInfoFromSourceRemove(sourceRemoveElem, currentRemoteSdp) {
1091
     _parseSsrcInfoFromSourceRemove(sourceRemoveElem, currentRemoteSdp) {
1092
         const removeSsrcInfo = [];
1092
         const removeSsrcInfo = [];
1093
 
1093
 
1094
-        $(sourceRemoveElem).each((idx, content) => {
1094
+        $(sourceRemoveElem).each((i1, content) => {
1095
             const name = $(content).attr('name');
1095
             const name = $(content).attr('name');
1096
             let lines = '';
1096
             let lines = '';
1097
 
1097
 
1125
 
1125
 
1126
                 ssrcs.push(ssrc);
1126
                 ssrcs.push(ssrc);
1127
             });
1127
             });
1128
-            currentRemoteSdp.media.forEach((media, idx) => {
1128
+            currentRemoteSdp.media.forEach((media, i2) => {
1129
                 if (!SDPUtil.findLine(media, `a=mid:${name}`)) {
1129
                 if (!SDPUtil.findLine(media, `a=mid:${name}`)) {
1130
                     return;
1130
                     return;
1131
                 }
1131
                 }
1132
-                if (!removeSsrcInfo[idx]) {
1133
-                    removeSsrcInfo[idx] = '';
1132
+                if (!removeSsrcInfo[i2]) {
1133
+                    removeSsrcInfo[i2] = '';
1134
                 }
1134
                 }
1135
                 ssrcs.forEach(ssrc => {
1135
                 ssrcs.forEach(ssrc => {
1136
                     const ssrcLines
1136
                     const ssrcLines
1137
                         = SDPUtil.findLines(media, `a=ssrc:${ssrc}`);
1137
                         = SDPUtil.findLines(media, `a=ssrc:${ssrc}`);
1138
 
1138
 
1139
                     if (ssrcLines.length) {
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
                         if (kv.indexOf(':') === -1) {
287
                         if (kv.indexOf(':') === -1) {
288
                             elem.attrs({ name: kv });
288
                             elem.attrs({ name: kv });
289
                         } else {
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
                             let v = kv.split(':', 2)[1];
294
                             let v = kv.split(':', 2)[1];
295
 
295
 
352
                     if (ssrcs.length) {
352
                     if (ssrcs.length) {
353
                         elem.c('ssrc-group', { semantics,
353
                         elem.c('ssrc-group', { semantics,
354
                             xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
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
                         elem.up();
356
                         elem.up();
357
                     }
357
                     }
358
                 });
358
                 });
586
             const contents
586
             const contents
587
                 = $(group)
587
                 = $(group)
588
                     .find('>content')
588
                     .find('>content')
589
-                    .map((idx, content) => content.getAttribute('name'))
589
+                    .map((_, content) => content.getAttribute('name'))
590
                     .get();
590
                     .get();
591
 
591
 
592
             if (contents.length > 0) {
592
             if (contents.length > 0) {

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

194
             if (newState === 'pending') {
194
             if (newState === 'pending') {
195
                 self.connection.addHandler(iq => {
195
                 self.connection.addHandler(iq => {
196
                     // eslint-disable-next-line newline-per-chained-call
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
                         self.state = newState;
200
                         self.state = newState;
201
-                        callback(state);
201
+                        callback(s);
202
                     }
202
                     }
203
                 }, 'http://jitsi.org/protocol/colibri', 'iq', null, null, null);
203
                 }, 'http://jitsi.org/protocol/colibri', 'iq', null, null, null);
204
             }
204
             }

Loading…
取消
儲存