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.
This commit is contained in:
Lyubo Marinov 2017-10-16 15:37:13 -05:00
parent 969f5d67ab
commit 5d313a8cd8
8 changed files with 109 additions and 107 deletions

View File

@ -1,5 +1,4 @@
/* global ga */ /* global ga */
/* eslint-disable indent */
(function(ctx) { (function(ctx) {
/** /**

View File

@ -1,5 +1,4 @@
/* global $, APP, JitsiMeetJS, config, interfaceConfig */ /* global $, APP, JitsiMeetJS, config, interfaceConfig */
const logger = require('jitsi-meet-logger').getLogger(__filename);
import { openConnection } from './connection'; import { openConnection } from './connection';
@ -88,6 +87,8 @@ import {
showDesktopSharingButton showDesktopSharingButton
} from './react/features/toolbox'; } from './react/features/toolbox';
const logger = require('jitsi-meet-logger').getLogger(__filename);
const eventEmitter = new EventEmitter(); const eventEmitter = new EventEmitter();
let room; let room;
@ -211,10 +212,12 @@ function maybeRedirectToWelcomePage(options) {
// if Welcome page is enabled redirect to welcome page after 3 sec. // if Welcome page is enabled redirect to welcome page after 3 sec.
if (config.enableWelcomePage) { if (config.enableWelcomePage) {
setTimeout(() => { setTimeout(
APP.settings.setWelcomePageEnabled(true); () => {
assignWindowLocationPathname('./'); APP.settings.setWelcomePageEnabled(true);
}, 3000); assignWindowLocationPathname('./');
},
3000);
} }
} }
@ -595,10 +598,8 @@ export default {
// Try audio only... // Try audio only...
audioAndVideoError = err; audioAndVideoError = err;
return createLocalTracksF( return (
{ devices: [ 'audio' ] }, createLocalTracksF({ devices: [ 'audio' ] }, true));
true
);
} else if (requestedAudio && !requestedVideo) { } else if (requestedAudio && !requestedVideo) {
audioOnlyError = err; audioOnlyError = err;
@ -949,9 +950,9 @@ export default {
isParticipantModerator(id) { isParticipantModerator(id) {
const user = room.getParticipantById(id); const user = room.getParticipantById(id);
return user && user.isModerator(); return user && user.isModerator();
}, },
get membersCount() { get membersCount() {
return room.getParticipants().length + 1; return room.getParticipants().length + 1;
}, },
@ -1084,7 +1085,6 @@ export default {
getParticipantConnectionStatus(id) { getParticipantConnectionStatus(id) {
const participant = this.getParticipantById(id); const participant = this.getParticipantById(id);
return participant ? participant.getConnectionStatus() : null; return participant ? participant.getConnectionStatus() : null;
}, },
@ -1109,12 +1109,10 @@ export default {
} }
return interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME; return interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
}, },
getMyUserId() { getMyUserId() {
return this._room return this._room && this._room.myUserId();
&& this._room.myUserId();
}, },
/** /**
@ -1287,15 +1285,15 @@ export default {
const options = config; const options = config;
if (config.enableRecording && !config.recordingType) { if (config.enableRecording && !config.recordingType) {
options.recordingType = config.hosts options.recordingType
&& (typeof config.hosts.jirecon !== 'undefined') = config.hosts && (typeof config.hosts.jirecon !== 'undefined')
? 'jirecon' : 'colibri'; ? 'jirecon'
: 'colibri';
} }
return options; return options;
}, },
/** /**
* Start using provided video stream. * Start using provided video stream.
* Stops previous video stream. * Stops previous video stream.
@ -1484,7 +1482,6 @@ export default {
} }
return this._untoggleScreenSharing(); return this._untoggleScreenSharing();
}, },
/** /**
@ -1595,34 +1592,34 @@ export default {
this.videoSwitchInProgress = true; this.videoSwitchInProgress = true;
return this._createDesktopTrack(options) return this._createDesktopTrack(options)
.then(stream => this.useVideoStream(stream)) .then(stream => this.useVideoStream(stream))
.then(() => { .then(() => {
this.videoSwitchInProgress = false; this.videoSwitchInProgress = false;
sendEvent('conference.sharingDesktop.start'); sendEvent('conference.sharingDesktop.start');
logger.log('sharing local desktop'); logger.log('sharing local desktop');
}) })
.catch(error => { .catch(error => {
this.videoSwitchInProgress = false; this.videoSwitchInProgress = false;
// Pawel: With this call I'm trying to preserve the original // Pawel: With this call I'm trying to preserve the original
// behaviour although it is not clear why would we "untoggle" // behaviour although it is not clear why would we "untoggle"
// on failure. I suppose it was to restore video in case there // on failure. I suppose it was to restore video in case there
// was some problem during "this.useVideoStream(desktopStream)". // was some problem during "this.useVideoStream(desktopStream)".
// It's important to note that the handler will not be available // It's important to note that the handler will not be available
// if we fail early on trying to get desktop media (which makes // if we fail early on trying to get desktop media (which makes
// sense, because the camera video is still being used, so // sense, because the camera video is still being used, so
// nothing to "untoggle"). // nothing to "untoggle").
if (this._untoggleScreenSharing) { if (this._untoggleScreenSharing) {
this._untoggleScreenSharing(); this._untoggleScreenSharing();
} }
// FIXME the code inside of _handleScreenSharingError is // FIXME the code inside of _handleScreenSharingError is
// asynchronous, but does not return a Promise and is not part // asynchronous, but does not return a Promise and is not part
// of the current Promise chain. // of the current Promise chain.
this._handleScreenSharingError(error); this._handleScreenSharingError(error);
return Promise.reject(error); return Promise.reject(error);
}); });
}, },
/** /**

View File

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

View File

@ -35,8 +35,10 @@ function checkForAttachParametersAndConnect(id, password, connection) {
// If the connection optimization is deployed and enabled and there is // If the connection optimization is deployed and enabled and there is
// a failure the value will be window.XMPPAttachInfo.status = "error" // a failure the value will be window.XMPPAttachInfo.status = "error"
if (window.XMPPAttachInfo.status === 'error') { if (window.XMPPAttachInfo.status === 'error') {
connection.connect({ id, connection.connect({
password }); id,
password
});
return; return;
} }
@ -47,13 +49,17 @@ function checkForAttachParametersAndConnect(id, password, connection) {
connection.attach(attachOptions); connection.attach(attachOptions);
delete window.XMPPAttachInfo.data; delete window.XMPPAttachInfo.data;
} else { } else {
connection.connect({ id, connection.connect({
password }); id,
password
});
} }
} else { } else {
APP.connect.status = 'ready'; APP.connect.status = 'ready';
APP.connect.handler = checkForAttachParametersAndConnect.bind(null, APP.connect.handler
id, password, connection); = checkForAttachParametersAndConnect.bind(
null,
id, password, connection);
} }
} }

View File

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

View File

@ -339,8 +339,7 @@ class FollowMe {
} }
if (!this._conference.isParticipantModerator(id)) { if (!this._conference.isParticipantModerator(id)) {
logger.warn('Received follow-me command ' logger.warn('Received follow-me command not from moderator');
+ 'not from moderator');
return; return;
} }

View File

@ -122,9 +122,7 @@ const UIListeners = new Map([
() => UI.toggleContactList() () => UI.toggleContactList()
], [ ], [
UIEvents.TOGGLE_PROFILE, UIEvents.TOGGLE_PROFILE,
() => { () => UI.toggleSidePanel('profile_container')
UI.toggleSidePanel('profile_container');
}
], [ ], [
UIEvents.TOGGLE_FILMSTRIP, UIEvents.TOGGLE_FILMSTRIP,
() => UI.handleToggleFilmstrip() () => UI.handleToggleFilmstrip()
@ -139,9 +137,7 @@ const UIListeners = new Map([
* (a.k.a. presentation mode in Chrome). * (a.k.a. presentation mode in Chrome).
*/ */
UI.toggleFullScreen = function() { UI.toggleFullScreen = function() {
UIUtil.isFullScreen() UIUtil.isFullScreen() ? UIUtil.exitFullScreen() : UIUtil.enterFullScreen();
? UIUtil.exitFullScreen()
: UIUtil.enterFullScreen();
}; };
/** /**
@ -158,9 +154,13 @@ UI.notifyGracefulShutdown = function() {
* Notify user that reservation error happened. * Notify user that reservation error happened.
*/ */
UI.notifyReservationError = function(code, msg) { UI.notifyReservationError = function(code, msg) {
const message = APP.translation.generateTranslationHTML( const message
'dialog.reservationErrorMsg', { code, = APP.translation.generateTranslationHTML(
msg }); 'dialog.reservationErrorMsg',
{
code,
msg
});
messageHandler.openDialog( messageHandler.openDialog(
'dialog.reservationError', message, true, {}, () => false); 'dialog.reservationError', message, true, {}, () => false);
@ -171,8 +171,8 @@ UI.notifyReservationError = function(code, msg) {
*/ */
UI.notifyKicked = function() { UI.notifyKicked = function() {
messageHandler.openMessageDialog( messageHandler.openMessageDialog(
'dialog.sessTerminated', 'dialog.sessTerminated',
'dialog.kickMessage'); 'dialog.kickMessage');
}; };
/** /**
@ -192,10 +192,9 @@ UI.notifyConferenceDestroyed = function(reason) {
* @param msg * @param msg
*/ */
UI.showChatError = function(err, msg) { UI.showChatError = function(err, msg) {
if (interfaceConfig.filmStripOnly) { if (!interfaceConfig.filmStripOnly) {
return; Chat.chatAddError(err, msg);
} }
Chat.chatAddError(err, msg);
}; };
/** /**
@ -229,8 +228,11 @@ UI.showLocalConnectionInterrupted = function(isInterrupted) {
UI.setRaisedHandStatus = (participant, raisedHandStatus) => { UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus); VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
if (raisedHandStatus) { if (raisedHandStatus) {
messageHandler.participantNotification(participant.getDisplayName(), messageHandler.participantNotification(
'notify.somebody', 'connected', 'notify.raisedHand'); participant.getDisplayName(),
'notify.somebody',
'connected',
'notify.raisedHand');
} }
}; };
@ -313,7 +315,6 @@ UI.start = function() {
// Set the defaults for prompt dialogs. // Set the defaults for prompt dialogs.
$.prompt.setDefaults({ persistent: false }); $.prompt.setDefaults({ persistent: false });
SideContainerToggler.init(eventEmitter); SideContainerToggler.init(eventEmitter);
Filmstrip.init(eventEmitter); Filmstrip.init(eventEmitter);
@ -471,8 +472,7 @@ UI.addUser = function(user) {
const displayName = user.getDisplayName(); const displayName = user.getDisplayName();
messageHandler.participantNotification( messageHandler.participantNotification(
displayName, 'notify.somebody', 'connected', 'notify.connected' displayName, 'notify.somebody', 'connected', 'notify.connected');
);
if (!config.startAudioMuted if (!config.startAudioMuted
|| config.startAudioMuted > APP.conference.membersCount) { || config.startAudioMuted > APP.conference.membersCount) {
@ -498,11 +498,10 @@ UI.addUser = function(user) {
*/ */
UI.removeUser = function(id, displayName) { UI.removeUser = function(id, displayName) {
messageHandler.participantNotification( messageHandler.participantNotification(
displayName, 'notify.somebody', 'disconnected', 'notify.disconnected' displayName, 'notify.somebody', 'disconnected', 'notify.disconnected');
);
if (!config.startAudioMuted if (!config.startAudioMuted
|| config.startAudioMuted > APP.conference.membersCount) { || config.startAudioMuted > APP.conference.membersCount) {
UIUtil.playSoundNotification('userLeft'); UIUtil.playSoundNotification('userLeft');
} }
@ -558,15 +557,17 @@ UI.updateUserRole = user => {
if (displayName) { if (displayName) {
messageHandler.participantNotification( messageHandler.participantNotification(
displayName, 'notify.somebody', displayName,
'connected', 'notify.grantedTo', { 'notify.somebody',
to: UIUtil.escapeHtml(displayName) 'connected',
} 'notify.grantedTo',
); { to: UIUtil.escapeHtml(displayName) });
} else { } else {
messageHandler.participantNotification( messageHandler.participantNotification(
'', 'notify.somebody', '',
'connected', 'notify.grantedToUnknown'); 'notify.somebody',
'connected',
'notify.grantedToUnknown');
} }
}; };
@ -584,10 +585,11 @@ UI.updateUserStatus = (user, status) => {
const displayName = user.getDisplayName(); const displayName = user.getDisplayName();
messageHandler.participantNotification( messageHandler.participantNotification(
displayName, '', 'connected', 'dialOut.statusMessage', displayName,
{ '',
status: UIUtil.escapeHtml(status) 'connected',
}); 'dialOut.statusMessage',
{ status: UIUtil.escapeHtml(status) });
}; };
/** /**
@ -648,9 +650,10 @@ UI.inputDisplayNameHandler = function(newDisplayName) {
*/ */
// eslint-disable-next-line max-params // eslint-disable-next-line max-params
UI.showCustomToolbarPopup = function(buttonName, popupID, show, timeout) { UI.showCustomToolbarPopup = function(buttonName, popupID, show, timeout) {
const action = show const action
? setButtonPopupTimeout(buttonName, popupID, timeout) = show
: clearButtonPopup(buttonName); ? setButtonPopupTimeout(buttonName, popupID, timeout)
: clearButtonPopup(buttonName);
APP.store.dispatch(action); APP.store.dispatch(action);
}; };
@ -681,10 +684,8 @@ UI.showLoginPopup = function(callback) {
// eslint-disable-next-line max-params // eslint-disable-next-line max-params
const submitFunction = (e, v, m, f) => { const submitFunction = (e, v, m, f) => {
if (v) { if (v && f.username && f.password) {
if (f.username && f.password) { callback(f.username, f.password);
callback(f.username, f.password);
}
} }
}; };

View File

@ -64,6 +64,7 @@ const config = {
rules: [ { rules: [ {
// Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React // Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
// as well. // as well.
exclude: node_modules, // eslint-disable-line camelcase exclude: node_modules, // eslint-disable-line camelcase
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
@ -210,11 +211,10 @@ function devServerProxyBypass({ path }) {
const configs = module.exports; const configs = module.exports;
/* eslint-disable indent */ /* eslint-disable array-callback-return, indent */
let formattedPath = path;
if ((Array.isArray(configs) ? configs : Array(configs)).some(c => { if ((Array.isArray(configs) ? configs : Array(configs)).some(c => {
if (formattedPath.startsWith(c.output.publicPath)) { if (path.startsWith(c.output.publicPath)) {
if (!minimize) { if (!minimize) {
// Since webpack-dev-server is serving non-minimized // Since webpack-dev-server is serving non-minimized
// artifacts, serve them even if the minimized ones are // artifacts, serve them even if the minimized ones are
@ -222,24 +222,20 @@ function devServerProxyBypass({ path }) {
Object.keys(c.entry).some(e => { Object.keys(c.entry).some(e => {
const name = `${e}.min.js`; const name = `${e}.min.js`;
if (formattedPath.indexOf(name) !== -1) { if (path.indexOf(name) !== -1) {
formattedPath // eslint-disable-next-line no-param-reassign
= formattedPath.replace(name, `${e}.js`); path = path.replace(name, `${e}.js`);
return true; return true;
} }
return false;
}); });
} }
return true; return true;
} }
return false;
})) { })) {
return formattedPath; return path;
} }
/* eslint-enable indent */ /* eslint-enable array-callback-return, indent */
} }