浏览代码

Coding style

A few occurrences of coding style/formatting which I noticed while
reviewing 'feat(eslint): Enable for non react files'. These are
definitely not all occurrences I could've noticed during the review
but... we're talking about files outside react/ anyway.
j8
Lyubo Marinov 8 年前
父节点
当前提交
5d313a8cd8
共有 8 个文件被更改,包括 110 次插入108 次删除
  1. 0
    1
      analytics.js
  2. 43
    46
      conference.js
  3. 3
    1
      config.js
  4. 12
    6
      connection.js
  5. 2
    0
      interface_config.js
  6. 1
    2
      modules/FollowMe.js
  7. 41
    40
      modules/UI/UI.js
  8. 8
    12
      webpack.config.js

+ 0
- 1
analytics.js 查看文件

1
 /* global ga */
1
 /* global ga */
2
-/* eslint-disable indent */
3
 
2
 
4
 (function(ctx) {
3
 (function(ctx) {
5
     /**
4
     /**

+ 43
- 46
conference.js 查看文件

1
 /* global $, APP, JitsiMeetJS, config, interfaceConfig */
1
 /* global $, APP, JitsiMeetJS, config, interfaceConfig */
2
-const logger = require('jitsi-meet-logger').getLogger(__filename);
3
 
2
 
4
 import { openConnection } from './connection';
3
 import { openConnection } from './connection';
5
 
4
 
88
     showDesktopSharingButton
87
     showDesktopSharingButton
89
 } from './react/features/toolbox';
88
 } from './react/features/toolbox';
90
 
89
 
90
+const logger = require('jitsi-meet-logger').getLogger(__filename);
91
+
91
 const eventEmitter = new EventEmitter();
92
 const eventEmitter = new EventEmitter();
92
 
93
 
93
 let room;
94
 let room;
211
 
212
 
212
     // if Welcome page is enabled redirect to welcome page after 3 sec.
213
     // if Welcome page is enabled redirect to welcome page after 3 sec.
213
     if (config.enableWelcomePage) {
214
     if (config.enableWelcomePage) {
214
-        setTimeout(() => {
215
-            APP.settings.setWelcomePageEnabled(true);
216
-            assignWindowLocationPathname('./');
217
-        }, 3000);
215
+        setTimeout(
216
+            () => {
217
+                APP.settings.setWelcomePageEnabled(true);
218
+                assignWindowLocationPathname('./');
219
+            },
220
+            3000);
218
     }
221
     }
219
 }
222
 }
220
 
223
 
595
                         // Try audio only...
598
                         // Try audio only...
596
                         audioAndVideoError = err;
599
                         audioAndVideoError = err;
597
 
600
 
598
-                        return createLocalTracksF(
599
-                            { devices: [ 'audio' ] },
600
-                            true
601
-                        );
601
+                        return (
602
+                            createLocalTracksF({ devices: [ 'audio' ] }, true));
602
                     } else if (requestedAudio && !requestedVideo) {
603
                     } else if (requestedAudio && !requestedVideo) {
603
                         audioOnlyError = err;
604
                         audioOnlyError = err;
604
 
605
 
949
     isParticipantModerator(id) {
950
     isParticipantModerator(id) {
950
         const user = room.getParticipantById(id);
951
         const user = room.getParticipantById(id);
951
 
952
 
952
-
953
         return user && user.isModerator();
953
         return user && user.isModerator();
954
     },
954
     },
955
+
955
     get membersCount() {
956
     get membersCount() {
956
         return room.getParticipants().length + 1;
957
         return room.getParticipants().length + 1;
957
     },
958
     },
1084
     getParticipantConnectionStatus(id) {
1085
     getParticipantConnectionStatus(id) {
1085
         const participant = this.getParticipantById(id);
1086
         const participant = this.getParticipantById(id);
1086
 
1087
 
1087
-
1088
         return participant ? participant.getConnectionStatus() : null;
1088
         return participant ? participant.getConnectionStatus() : null;
1089
     },
1089
     },
1090
 
1090
 
1109
         }
1109
         }
1110
 
1110
 
1111
         return interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
1111
         return interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
1112
-
1113
-
1114
     },
1112
     },
1113
+
1115
     getMyUserId() {
1114
     getMyUserId() {
1116
-        return this._room
1117
-            && this._room.myUserId();
1115
+        return this._room && this._room.myUserId();
1118
     },
1116
     },
1119
 
1117
 
1120
     /**
1118
     /**
1287
         const options = config;
1285
         const options = config;
1288
 
1286
 
1289
         if (config.enableRecording && !config.recordingType) {
1287
         if (config.enableRecording && !config.recordingType) {
1290
-            options.recordingType = config.hosts
1291
-                && (typeof config.hosts.jirecon !== 'undefined')
1292
-                ? 'jirecon' : 'colibri';
1288
+            options.recordingType
1289
+                = config.hosts && (typeof config.hosts.jirecon !== 'undefined')
1290
+                    ? 'jirecon'
1291
+                    : 'colibri';
1293
         }
1292
         }
1294
 
1293
 
1295
         return options;
1294
         return options;
1296
     },
1295
     },
1297
 
1296
 
1298
-
1299
     /**
1297
     /**
1300
      * Start using provided video stream.
1298
      * Start using provided video stream.
1301
      * Stops previous video stream.
1299
      * Stops previous video stream.
1484
         }
1482
         }
1485
 
1483
 
1486
         return this._untoggleScreenSharing();
1484
         return this._untoggleScreenSharing();
1487
-
1488
     },
1485
     },
1489
 
1486
 
1490
     /**
1487
     /**
1595
         this.videoSwitchInProgress = true;
1592
         this.videoSwitchInProgress = true;
1596
 
1593
 
1597
         return this._createDesktopTrack(options)
1594
         return this._createDesktopTrack(options)
1598
-        .then(stream => this.useVideoStream(stream))
1599
-        .then(() => {
1600
-            this.videoSwitchInProgress = false;
1601
-            sendEvent('conference.sharingDesktop.start');
1602
-            logger.log('sharing local desktop');
1603
-        })
1604
-        .catch(error => {
1605
-            this.videoSwitchInProgress = false;
1606
-
1607
-            // Pawel: With this call I'm trying to preserve the original
1608
-            // behaviour although it is not clear why would we "untoggle"
1609
-            // on failure. I suppose it was to restore video in case there
1610
-            // was some problem during "this.useVideoStream(desktopStream)".
1611
-            // It's important to note that the handler will not be available
1612
-            // if we fail early on trying to get desktop media (which makes
1613
-            // sense, because the camera video is still being used, so
1614
-            // nothing to "untoggle").
1615
-            if (this._untoggleScreenSharing) {
1616
-                this._untoggleScreenSharing();
1617
-            }
1595
+            .then(stream => this.useVideoStream(stream))
1596
+            .then(() => {
1597
+                this.videoSwitchInProgress = false;
1598
+                sendEvent('conference.sharingDesktop.start');
1599
+                logger.log('sharing local desktop');
1600
+            })
1601
+            .catch(error => {
1602
+                this.videoSwitchInProgress = false;
1603
+
1604
+                // Pawel: With this call I'm trying to preserve the original
1605
+                // behaviour although it is not clear why would we "untoggle"
1606
+                // on failure. I suppose it was to restore video in case there
1607
+                // was some problem during "this.useVideoStream(desktopStream)".
1608
+                // It's important to note that the handler will not be available
1609
+                // if we fail early on trying to get desktop media (which makes
1610
+                // sense, because the camera video is still being used, so
1611
+                // nothing to "untoggle").
1612
+                if (this._untoggleScreenSharing) {
1613
+                    this._untoggleScreenSharing();
1614
+                }
1618
 
1615
 
1619
-            // FIXME the code inside of _handleScreenSharingError is
1620
-            // asynchronous, but does not return a Promise and is not part
1621
-            // of the current Promise chain.
1622
-            this._handleScreenSharingError(error);
1616
+                // FIXME the code inside of _handleScreenSharingError is
1617
+                // asynchronous, but does not return a Promise and is not part
1618
+                // of the current Promise chain.
1619
+                this._handleScreenSharingError(error);
1623
 
1620
 
1624
-            return Promise.reject(error);
1625
-        });
1621
+                return Promise.reject(error);
1622
+            });
1626
     },
1623
     },
1627
 
1624
 
1628
     /**
1625
     /**

+ 3
- 1
config.js 查看文件

1
 /* eslint-disable no-unused-vars, no-var */
1
 /* eslint-disable no-unused-vars, no-var */
2
-var config = { // eslint-disable-line no-unused-vars
2
+
3
+var config = {
3
     // Configuration
4
     // Configuration
4
     //
5
     //
5
 
6
 
288
         // userRegion: "asia"
289
         // userRegion: "asia"
289
     }
290
     }
290
 };
291
 };
292
+
291
 /* eslint-enable no-unused-vars, no-var */
293
 /* eslint-enable no-unused-vars, no-var */

+ 12
- 6
connection.js 查看文件

35
         // If the connection optimization is deployed and enabled and there is
35
         // If the connection optimization is deployed and enabled and there is
36
         // a failure the value will be window.XMPPAttachInfo.status = "error"
36
         // a failure the value will be window.XMPPAttachInfo.status = "error"
37
         if (window.XMPPAttachInfo.status === 'error') {
37
         if (window.XMPPAttachInfo.status === 'error') {
38
-            connection.connect({ id,
39
-                password });
38
+            connection.connect({
39
+                id,
40
+                password
41
+            });
40
 
42
 
41
             return;
43
             return;
42
         }
44
         }
47
             connection.attach(attachOptions);
49
             connection.attach(attachOptions);
48
             delete window.XMPPAttachInfo.data;
50
             delete window.XMPPAttachInfo.data;
49
         } else {
51
         } else {
50
-            connection.connect({ id,
51
-                password });
52
+            connection.connect({
53
+                id,
54
+                password
55
+            });
52
         }
56
         }
53
     } else {
57
     } else {
54
         APP.connect.status = 'ready';
58
         APP.connect.status = 'ready';
55
-        APP.connect.handler = checkForAttachParametersAndConnect.bind(null,
56
-            id, password, connection);
59
+        APP.connect.handler
60
+            = checkForAttachParametersAndConnect.bind(
61
+                null,
62
+                id, password, connection);
57
     }
63
     }
58
 }
64
 }
59
 
65
 

+ 2
- 0
interface_config.js 查看文件

1
 /* eslint-disable no-unused-vars, no-var, max-len */
1
 /* eslint-disable no-unused-vars, no-var, max-len */
2
+
2
 var interfaceConfig = {
3
 var interfaceConfig = {
3
     // TO FIX: this needs to be handled from SASS variables. There are some
4
     // TO FIX: this needs to be handled from SASS variables. There are some
4
     // methods allowing to use variables both in css and js.
5
     // methods allowing to use variables both in css and js.
142
      */
143
      */
143
     // ADD_PEOPLE_APP_NAME: ""
144
     // ADD_PEOPLE_APP_NAME: ""
144
 };
145
 };
146
+
145
 /* eslint-enable no-unused-vars, no-var, max-len */
147
 /* eslint-enable no-unused-vars, no-var, max-len */

+ 1
- 2
modules/FollowMe.js 查看文件

339
         }
339
         }
340
 
340
 
341
         if (!this._conference.isParticipantModerator(id)) {
341
         if (!this._conference.isParticipantModerator(id)) {
342
-            logger.warn('Received follow-me command '
343
-                + 'not from moderator');
342
+            logger.warn('Received follow-me command not from moderator');
344
 
343
 
345
             return;
344
             return;
346
         }
345
         }

+ 41
- 40
modules/UI/UI.js 查看文件

122
         () => UI.toggleContactList()
122
         () => UI.toggleContactList()
123
     ], [
123
     ], [
124
         UIEvents.TOGGLE_PROFILE,
124
         UIEvents.TOGGLE_PROFILE,
125
-        () => {
126
-            UI.toggleSidePanel('profile_container');
127
-        }
125
+        () => UI.toggleSidePanel('profile_container')
128
     ], [
126
     ], [
129
         UIEvents.TOGGLE_FILMSTRIP,
127
         UIEvents.TOGGLE_FILMSTRIP,
130
         () => UI.handleToggleFilmstrip()
128
         () => UI.handleToggleFilmstrip()
139
  * (a.k.a. presentation mode in Chrome).
137
  * (a.k.a. presentation mode in Chrome).
140
  */
138
  */
141
 UI.toggleFullScreen = function() {
139
 UI.toggleFullScreen = function() {
142
-    UIUtil.isFullScreen()
143
-        ? UIUtil.exitFullScreen()
144
-        : UIUtil.enterFullScreen();
140
+    UIUtil.isFullScreen() ? UIUtil.exitFullScreen() : UIUtil.enterFullScreen();
145
 };
141
 };
146
 
142
 
147
 /**
143
 /**
158
  * Notify user that reservation error happened.
154
  * Notify user that reservation error happened.
159
  */
155
  */
160
 UI.notifyReservationError = function(code, msg) {
156
 UI.notifyReservationError = function(code, msg) {
161
-    const message = APP.translation.generateTranslationHTML(
162
-        'dialog.reservationErrorMsg', { code,
163
-            msg });
157
+    const message
158
+        = APP.translation.generateTranslationHTML(
159
+            'dialog.reservationErrorMsg',
160
+            {
161
+                code,
162
+                msg
163
+            });
164
 
164
 
165
     messageHandler.openDialog(
165
     messageHandler.openDialog(
166
         'dialog.reservationError', message, true, {}, () => false);
166
         'dialog.reservationError', message, true, {}, () => false);
171
  */
171
  */
172
 UI.notifyKicked = function() {
172
 UI.notifyKicked = function() {
173
     messageHandler.openMessageDialog(
173
     messageHandler.openMessageDialog(
174
-            'dialog.sessTerminated',
175
-            'dialog.kickMessage');
174
+        'dialog.sessTerminated',
175
+        'dialog.kickMessage');
176
 };
176
 };
177
 
177
 
178
 /**
178
 /**
192
  * @param msg
192
  * @param msg
193
  */
193
  */
194
 UI.showChatError = function(err, msg) {
194
 UI.showChatError = function(err, msg) {
195
-    if (interfaceConfig.filmStripOnly) {
196
-        return;
195
+    if (!interfaceConfig.filmStripOnly) {
196
+        Chat.chatAddError(err, msg);
197
     }
197
     }
198
-    Chat.chatAddError(err, msg);
199
 };
198
 };
200
 
199
 
201
 /**
200
 /**
229
 UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
228
 UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
230
     VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
229
     VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
231
     if (raisedHandStatus) {
230
     if (raisedHandStatus) {
232
-        messageHandler.participantNotification(participant.getDisplayName(),
233
-            'notify.somebody', 'connected', 'notify.raisedHand');
231
+        messageHandler.participantNotification(
232
+            participant.getDisplayName(),
233
+            'notify.somebody',
234
+            'connected',
235
+            'notify.raisedHand');
234
     }
236
     }
235
 };
237
 };
236
 
238
 
313
     // Set the defaults for prompt dialogs.
315
     // Set the defaults for prompt dialogs.
314
     $.prompt.setDefaults({ persistent: false });
316
     $.prompt.setDefaults({ persistent: false });
315
 
317
 
316
-
317
     SideContainerToggler.init(eventEmitter);
318
     SideContainerToggler.init(eventEmitter);
318
     Filmstrip.init(eventEmitter);
319
     Filmstrip.init(eventEmitter);
319
 
320
 
471
     const displayName = user.getDisplayName();
472
     const displayName = user.getDisplayName();
472
 
473
 
473
     messageHandler.participantNotification(
474
     messageHandler.participantNotification(
474
-        displayName, 'notify.somebody', 'connected', 'notify.connected'
475
-    );
475
+        displayName, 'notify.somebody', 'connected', 'notify.connected');
476
 
476
 
477
     if (!config.startAudioMuted
477
     if (!config.startAudioMuted
478
         || config.startAudioMuted > APP.conference.membersCount) {
478
         || config.startAudioMuted > APP.conference.membersCount) {
498
  */
498
  */
499
 UI.removeUser = function(id, displayName) {
499
 UI.removeUser = function(id, displayName) {
500
     messageHandler.participantNotification(
500
     messageHandler.participantNotification(
501
-        displayName, 'notify.somebody', 'disconnected', 'notify.disconnected'
502
-    );
501
+        displayName, 'notify.somebody', 'disconnected', 'notify.disconnected');
503
 
502
 
504
     if (!config.startAudioMuted
503
     if (!config.startAudioMuted
505
-        || config.startAudioMuted > APP.conference.membersCount) {
504
+            || config.startAudioMuted > APP.conference.membersCount) {
506
         UIUtil.playSoundNotification('userLeft');
505
         UIUtil.playSoundNotification('userLeft');
507
     }
506
     }
508
 
507
 
558
 
557
 
559
     if (displayName) {
558
     if (displayName) {
560
         messageHandler.participantNotification(
559
         messageHandler.participantNotification(
561
-            displayName, 'notify.somebody',
562
-            'connected', 'notify.grantedTo', {
563
-                to: UIUtil.escapeHtml(displayName)
564
-            }
565
-        );
560
+            displayName,
561
+            'notify.somebody',
562
+            'connected',
563
+            'notify.grantedTo',
564
+            { to: UIUtil.escapeHtml(displayName) });
566
     } else {
565
     } else {
567
         messageHandler.participantNotification(
566
         messageHandler.participantNotification(
568
-            '', 'notify.somebody',
569
-            'connected', 'notify.grantedToUnknown');
567
+            '',
568
+            'notify.somebody',
569
+            'connected',
570
+            'notify.grantedToUnknown');
570
     }
571
     }
571
 };
572
 };
572
 
573
 
584
     const displayName = user.getDisplayName();
585
     const displayName = user.getDisplayName();
585
 
586
 
586
     messageHandler.participantNotification(
587
     messageHandler.participantNotification(
587
-        displayName, '', 'connected', 'dialOut.statusMessage',
588
-        {
589
-            status: UIUtil.escapeHtml(status)
590
-        });
588
+        displayName,
589
+        '',
590
+        'connected',
591
+        'dialOut.statusMessage',
592
+        { status: UIUtil.escapeHtml(status) });
591
 };
593
 };
592
 
594
 
593
 /**
595
 /**
648
  */
650
  */
649
 // eslint-disable-next-line max-params
651
 // eslint-disable-next-line max-params
650
 UI.showCustomToolbarPopup = function(buttonName, popupID, show, timeout) {
652
 UI.showCustomToolbarPopup = function(buttonName, popupID, show, timeout) {
651
-    const action = show
652
-        ? setButtonPopupTimeout(buttonName, popupID, timeout)
653
-        : clearButtonPopup(buttonName);
653
+    const action
654
+        = show
655
+            ? setButtonPopupTimeout(buttonName, popupID, timeout)
656
+            : clearButtonPopup(buttonName);
654
 
657
 
655
     APP.store.dispatch(action);
658
     APP.store.dispatch(action);
656
 };
659
 };
681
 
684
 
682
     // eslint-disable-next-line max-params
685
     // eslint-disable-next-line max-params
683
     const submitFunction = (e, v, m, f) => {
686
     const submitFunction = (e, v, m, f) => {
684
-        if (v) {
685
-            if (f.username && f.password) {
686
-                callback(f.username, f.password);
687
-            }
687
+        if (v && f.username && f.password) {
688
+            callback(f.username, f.password);
688
         }
689
         }
689
     };
690
     };
690
 
691
 

+ 8
- 12
webpack.config.js 查看文件

64
         rules: [ {
64
         rules: [ {
65
             // Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
65
             // Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
66
             // as well.
66
             // as well.
67
+
67
             exclude: node_modules, // eslint-disable-line camelcase
68
             exclude: node_modules, // eslint-disable-line camelcase
68
             loader: 'babel-loader',
69
             loader: 'babel-loader',
69
             options: {
70
             options: {
210
 
211
 
211
     const configs = module.exports;
212
     const configs = module.exports;
212
 
213
 
213
-    /* eslint-disable indent */
214
-    let formattedPath = path;
214
+    /* eslint-disable array-callback-return, indent */
215
 
215
 
216
     if ((Array.isArray(configs) ? configs : Array(configs)).some(c => {
216
     if ((Array.isArray(configs) ? configs : Array(configs)).some(c => {
217
-                if (formattedPath.startsWith(c.output.publicPath)) {
217
+                if (path.startsWith(c.output.publicPath)) {
218
                     if (!minimize) {
218
                     if (!minimize) {
219
                         // Since webpack-dev-server is serving non-minimized
219
                         // Since webpack-dev-server is serving non-minimized
220
                         // artifacts, serve them even if the minimized ones are
220
                         // artifacts, serve them even if the minimized ones are
222
                         Object.keys(c.entry).some(e => {
222
                         Object.keys(c.entry).some(e => {
223
                             const name = `${e}.min.js`;
223
                             const name = `${e}.min.js`;
224
 
224
 
225
-                            if (formattedPath.indexOf(name) !== -1) {
226
-                                formattedPath
227
-                                    = formattedPath.replace(name, `${e}.js`);
225
+                            if (path.indexOf(name) !== -1) {
226
+                                // eslint-disable-next-line no-param-reassign
227
+                                path = path.replace(name, `${e}.js`);
228
 
228
 
229
                                 return true;
229
                                 return true;
230
                             }
230
                             }
231
-
232
-                            return false;
233
                         });
231
                         });
234
                     }
232
                     }
235
 
233
 
236
                     return true;
234
                     return true;
237
                 }
235
                 }
238
-
239
-                return false;
240
             })) {
236
             })) {
241
-        return formattedPath;
237
+        return path;
242
     }
238
     }
243
 
239
 
244
-    /* eslint-enable indent */
240
+    /* eslint-enable array-callback-return, indent */
245
 }
241
 }

正在加载...
取消
保存