浏览代码

[eslint] prefer-rest-params

dev1
Lyubo Marinov 8 年前
父节点
当前提交
1068233eac
共有 6 个文件被更改,包括 10 次插入11 次删除
  1. 1
    0
      .eslintrc.js
  2. 2
    4
      JitsiConnection.js
  3. 2
    2
      JitsiMediaDevices.js
  4. 1
    0
      modules/RTC/RTCUtils.js
  5. 1
    1
      modules/statistics/CallStats.js
  6. 3
    4
      modules/util/EventEmitterForwarder.js

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

211
         ],
211
         ],
212
         'prefer-const': 2,
212
         'prefer-const': 2,
213
         'prefer-reflect': 0,
213
         'prefer-reflect': 0,
214
+        'prefer-rest-params': 2,
214
         'prefer-spread': 2,
215
         'prefer-spread': 2,
215
         'prefer-template': 2,
216
         'prefer-template': 2,
216
         'require-yield': 2,
217
         'require-yield': 2,

+ 2
- 4
JitsiConnection.js 查看文件

65
 /**
65
 /**
66
  * Disconnect the client from the server.
66
  * Disconnect the client from the server.
67
  */
67
  */
68
-JitsiConnection.prototype.disconnect = function() {
68
+JitsiConnection.prototype.disconnect = function(...args) {
69
     // XXX Forward any arguments passed to JitsiConnection.disconnect to
69
     // XXX Forward any arguments passed to JitsiConnection.disconnect to
70
     // XMPP.disconnect. For example, the caller of JitsiConnection.disconnect
70
     // XMPP.disconnect. For example, the caller of JitsiConnection.disconnect
71
     // may optionally pass the event which triggered the disconnect in order to
71
     // may optionally pass the event which triggered the disconnect in order to
72
     // provide the implementation with finer-grained context.
72
     // provide the implementation with finer-grained context.
73
-    const x = this.xmpp;
74
-
75
-    x.disconnect(...arguments);
73
+    this.xmpp.disconnect(...args);
76
 };
74
 };
77
 
75
 
78
 /**
76
 /**

+ 2
- 2
JitsiMediaDevices.js 查看文件

129
      * Emits an event.
129
      * Emits an event.
130
      * @param {string} event - event name
130
      * @param {string} event - event name
131
      */
131
      */
132
-    emitEvent(event) { // eslint-disable-line no-unused-vars
133
-        eventEmitter.emit(...arguments);
132
+    emitEvent(event, ...args) {
133
+        eventEmitter.emit(event, ...args);
134
     }
134
     }
135
 };
135
 };
136
 
136
 

+ 1
- 0
modules/RTC/RTCUtils.js 查看文件

650
  */
650
  */
651
 function wrapAttachMediaStream(origAttachMediaStream) {
651
 function wrapAttachMediaStream(origAttachMediaStream) {
652
     return function(element, stream) {
652
     return function(element, stream) {
653
+        // eslint-disable-next-line prefer-rest-params
653
         const res = origAttachMediaStream.apply(rtcUtils, arguments);
654
         const res = origAttachMediaStream.apply(rtcUtils, arguments);
654
 
655
 
655
         if (stream
656
         if (stream

+ 1
- 1
modules/statistics/CallStats.js 查看文件

127
 function _try_catch(f) {
127
 function _try_catch(f) {
128
     return function() {
128
     return function() {
129
         try {
129
         try {
130
-            f.apply(this, arguments);
130
+            f.apply(this, arguments); // eslint-disable-line prefer-rest-params
131
         } catch (e) {
131
         } catch (e) {
132
             GlobalOnErrorHandler.callErrorHandler(e);
132
             GlobalOnErrorHandler.callErrorHandler(e);
133
             logger.error(e);
133
             logger.error(e);

+ 3
- 4
modules/util/EventEmitterForwarder.js 查看文件

22
  * @param arguments all other passed arguments are going to be fired with
22
  * @param arguments all other passed arguments are going to be fired with
23
  * dstEvent.
23
  * dstEvent.
24
  */
24
  */
25
-EventEmitterForwarder.prototype.forward = function() {
26
-    // This line is only for fixing jshint errors.
27
-    const args = arguments;
25
+EventEmitterForwarder.prototype.forward = function(...args) {
28
     const srcEvent = args[0];
26
     const srcEvent = args[0];
29
     // This will be the "this" value for emit function.
27
     // This will be the "this" value for emit function.
30
     args[0] = this.dest;
28
     args[0] = this.dest;
31
     // Using bind.apply to pass the arguments as Array-like object ("arguments")
29
     // Using bind.apply to pass the arguments as Array-like object ("arguments")
32
-    this.src.addListener(srcEvent,
30
+    this.src.addListener(
31
+        srcEvent,
33
         Function.prototype.bind.apply(this.dest.emit, args));
32
         Function.prototype.bind.apply(this.dest.emit, args));
34
 };
33
 };
35
 
34
 

正在加载...
取消
保存