Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESLint rules prefer-template and template-curly-spacing #6456

Merged
merged 10 commits into from
Mar 24, 2017
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ packages/rocketchat-favico/favico.js
packages/rocketchat-katex/client/katex/katex.min.js
packages/rocketchat-livechat/app/node_modules
packages/rocketchat-livechat/assets/rocketchat-livechat.min.js
packages/rocketchat-livechat/assets/rocket-livechat.js
packages/rocketchat-migrations/
packages/rocketchat-theme/client/minicolors/jquery.minicolors.js
packages/rocketchat-ui/client/lib/customEventPolyfill.js
Expand Down
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
"use-isnan": 2,
"valid-typeof": 2,
"linebreak-style": [2, "unix"],
"prefer-template": 2,
"template-curly-spacing": [2, "always"],
"quotes": [2, "single"],
"semi": [2, "always"],
"prefer-const": 2
Expand Down
2 changes: 1 addition & 1 deletion client/routes/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ FlowRouter.route('/account/:group?', {
params.group = 'Preferences';
}
params.group = _.capitalize(params.group, true);
BlazeLayout.render('main', { center: `account${params.group}` });
BlazeLayout.render('main', { center: `account${ params.group }` });
}
});

Expand Down
6 changes: 3 additions & 3 deletions client/startup/roomObserve.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Meteor.startup(function() {
ChatRoom.find().observe({
added(data) {
Session.set('roomData' + data._id, data);
Session.set(`roomData${ data._id }`, data);
},
changed(data) {
Session.set('roomData' + data._id, data);
Session.set(`roomData${ data._id }`, data);
},
removed(data) {
Session.set('roomData' + data._id, undefined);
Session.set(`roomData${ data._id }`, undefined);
}
});
});
2 changes: 1 addition & 1 deletion client/startup/unread.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ Meteor.startup(function() {
});
}

document.title = unread === '' ? siteName : `(${unread}) ${siteName}`;
document.title = unread === '' ? siteName : `(${ unread }) ${ siteName }`;
});
});
6 changes: 3 additions & 3 deletions client/startup/usersObserve.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Meteor.startup(function() {
Meteor.users.find({}, { fields: { name: 1, username: 1, pictures: 1, status: 1, emails: 1, phone: 1, services: 1, utcOffset: 1 } }).observe({
added(user) {
Session.set('user_' + user.username + '_status', user.status);
Session.set(`user_${ user.username }_status`, user.status);
RoomManager.updateUserStatus(user, user.status, user.utcOffset);
},
changed(user) {
Session.set('user_' + user.username + '_status', user.status);
Session.set(`user_${ user.username }_status`, user.status);
RoomManager.updateUserStatus(user, user.status, user.utcOffset);
},
removed(user) {
Session.set('user_' + user.username + '_status', null);
Session.set(`user_${ user.username }_status`, null);
RoomManager.updateUserStatus(user, 'offline', null);
}
});
Expand Down
4 changes: 2 additions & 2 deletions lib/fileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ if (UploadFS) {
const initFileStore = function() {
const cookie = new Cookies();
if (Meteor.isClient) {
document.cookie = 'rc_uid=' + escape(Meteor.userId()) + '; path=/';
document.cookie = 'rc_token=' + escape(Accounts._storedLoginToken()) + '; path=/';
document.cookie = `rc_uid=${ escape(Meteor.userId()) }; path=/`;
document.cookie = `rc_token=${ escape(Accounts._storedLoginToken()) }; path=/`;
}

Meteor.fileStore = new UploadFS.store.GridFS({
Expand Down
4 changes: 2 additions & 2 deletions packages/meteor-accounts-saml/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Package.describe({
});

Package.on_use(function(api) {
api.use(['rocketchat:lib'], 'server');
api.use(['ecmascript'], 'server');
api.use('rocketchat:lib', 'server');
api.use('ecmascript');
api.use(['routepolicy', 'webapp', 'underscore', 'service-configuration'], 'server');
api.use(['http', 'accounts-base'], ['client', 'server']);

Expand Down
8 changes: 4 additions & 4 deletions packages/meteor-accounts-saml/saml_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ var openCenteredPopup = function(url, width, height) {
// positioning the popup centered relative to the current window
var left = screenX + (outerWidth - width) / 2;
var top = screenY + (outerHeight - height) / 2;
var features = ('width=' + width + ',height=' + height +
',left=' + left + ',top=' + top + ',scrollbars=yes');
var features = (`width=${ width },height=${ height
},left=${ left },top=${ top },scrollbars=yes`);

newwindow = window.open(url, 'Login', features);
if (newwindow.focus) {
Expand All @@ -74,7 +74,7 @@ var openCenteredPopup = function(url, width, height) {
Accounts.saml.initiateLogin = function(options, callback, dimensions) {
// default dimensions that worked well for facebook and google
var popup = openCenteredPopup(
Meteor.absoluteUrl('_saml/authorize/' + options.provider + '/' + options.credentialToken), (dimensions && dimensions.width) || 650, (dimensions && dimensions.height) || 500);
Meteor.absoluteUrl(`_saml/authorize/${ options.provider }/${ options.credentialToken }`), (dimensions && dimensions.width) || 650, (dimensions && dimensions.height) || 500);

var checkPopupOpen = setInterval(function() {
var popupClosed;
Expand Down Expand Up @@ -124,6 +124,6 @@ Meteor.logoutWithSaml = function(options/*, callback*/) {
}
// A nasty bounce: 'result' has the SAML LogoutRequest but we need a proper 302 to redirected from the server.
//window.location.replace(Meteor.absoluteUrl('_saml/sloRedirect/' + options.provider + '/?redirect='+result));
window.location.replace(Meteor.absoluteUrl('_saml/sloRedirect/' + options.provider + '/?redirect=' + encodeURIComponent(result)));
window.location.replace(Meteor.absoluteUrl(`_saml/sloRedirect/${ options.provider }/?redirect=${ encodeURIComponent(result) }`));
});
};
46 changes: 23 additions & 23 deletions packages/meteor-accounts-saml/saml_rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,76 +10,76 @@ RocketChat.settings.addGroup('SAML');

Meteor.methods({
addSamlService(name) {
RocketChat.settings.add(`SAML_Custom_${name}`, false, {
RocketChat.settings.add(`SAML_Custom_${ name }`, false, {
type: 'boolean',
group: 'SAML',
section: name,
i18nLabel: 'Accounts_OAuth_Custom_Enable'
});
RocketChat.settings.add(`SAML_Custom_${name}_provider`, 'provider-name', {
RocketChat.settings.add(`SAML_Custom_${ name }_provider`, 'provider-name', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Provider'
});
RocketChat.settings.add(`SAML_Custom_${name}_entry_point`, 'https://example.com/simplesaml/saml2/idp/SSOService.php', {
RocketChat.settings.add(`SAML_Custom_${ name }_entry_point`, 'https://example.com/simplesaml/saml2/idp/SSOService.php', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Entry_point'
});
RocketChat.settings.add(`SAML_Custom_${name}_idp_slo_redirect_url`, 'https://example.com/simplesaml/saml2/idp/SingleLogoutService.php', {
RocketChat.settings.add(`SAML_Custom_${ name }_idp_slo_redirect_url`, 'https://example.com/simplesaml/saml2/idp/SingleLogoutService.php', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_IDP_SLO_Redirect_URL'
});
RocketChat.settings.add(`SAML_Custom_${name}_issuer`, 'https://your-rocket-chat/_saml/metadata/provider-name', {
RocketChat.settings.add(`SAML_Custom_${ name }_issuer`, 'https://your-rocket-chat/_saml/metadata/provider-name', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Issuer'
});
RocketChat.settings.add(`SAML_Custom_${name}_cert`, '', {
RocketChat.settings.add(`SAML_Custom_${ name }_cert`, '', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Cert',
multiline: true
});
RocketChat.settings.add(`SAML_Custom_${name}_public_cert`, '', {
RocketChat.settings.add(`SAML_Custom_${ name }_public_cert`, '', {
type: 'string',
group: 'SAML',
section: name,
multiline: true,
i18nLabel: 'SAML_Custom_Public_Cert'
});
RocketChat.settings.add(`SAML_Custom_${name}_private_key`, '', {
RocketChat.settings.add(`SAML_Custom_${ name }_private_key`, '', {
type: 'string',
group: 'SAML',
section: name,
multiline: true,
i18nLabel: 'SAML_Custom_Private_Key'
});
RocketChat.settings.add(`SAML_Custom_${name}_button_label_text`, '', {
RocketChat.settings.add(`SAML_Custom_${ name }_button_label_text`, '', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Text'
});
RocketChat.settings.add(`SAML_Custom_${name}_button_label_color`, '#FFFFFF', {
RocketChat.settings.add(`SAML_Custom_${ name }_button_label_color`, '#FFFFFF', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Color'
});
RocketChat.settings.add(`SAML_Custom_${name}_button_color`, '#13679A', {
RocketChat.settings.add(`SAML_Custom_${ name }_button_color`, '#13679A', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'Accounts_OAuth_Custom_Button_Color'
});
RocketChat.settings.add(`SAML_Custom_${name}_generate_username`, false, {
RocketChat.settings.add(`SAML_Custom_${ name }_generate_username`, false, {
type: 'boolean',
group: 'SAML',
section: name,
Expand All @@ -90,20 +90,20 @@ Meteor.methods({

const getSamlConfigs = function(service) {
return {
buttonLabelText: RocketChat.settings.get(service.key + '_button_label_text'),
buttonLabelColor: RocketChat.settings.get(service.key + '_button_label_color'),
buttonColor: RocketChat.settings.get(service.key + '_button_color'),
buttonLabelText: RocketChat.settings.get(`${ service.key }_button_label_text`),
buttonLabelColor: RocketChat.settings.get(`${ service.key }_button_label_color`),
buttonColor: RocketChat.settings.get(`${ service.key }_button_color`),
clientConfig: {
provider: RocketChat.settings.get(service.key + '_provider')
provider: RocketChat.settings.get(`${ service.key }_provider`)
},
entryPoint: RocketChat.settings.get(service.key + '_entry_point'),
idpSLORedirectURL: RocketChat.settings.get(service.key + '_idp_slo_redirect_url'),
generateUsername: RocketChat.settings.get(service.key + '_generate_username'),
issuer: RocketChat.settings.get(service.key + '_issuer'),
entryPoint: RocketChat.settings.get(`${ service.key }_entry_point`),
idpSLORedirectURL: RocketChat.settings.get(`${ service.key }_idp_slo_redirect_url`),
generateUsername: RocketChat.settings.get(`${ service.key }_generate_username`),
issuer: RocketChat.settings.get(`${ service.key }_issuer`),
secret: {
privateKey: RocketChat.settings.get(service.key + '_private_key'),
publicCert: RocketChat.settings.get(service.key + '_public_cert'),
cert: RocketChat.settings.get(service.key + '_cert')
privateKey: RocketChat.settings.get(`${ service.key }_private_key`),
publicCert: RocketChat.settings.get(`${ service.key }_public_cert`),
cert: RocketChat.settings.get(`${ service.key }_cert`)
}
};
};
Expand Down
26 changes: 13 additions & 13 deletions packages/meteor-accounts-saml/saml_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Meteor.methods({
var providerConfig = getSamlProviderConfig(provider);

if (Accounts.saml.settings.debug) {
console.log('Logout request from ' + JSON.stringify(providerConfig));
console.log(`Logout request from ${ JSON.stringify(providerConfig) }`);
}
// This query should respect upcoming array of SAML logins
var user = Meteor.users.findOne({
Expand All @@ -52,7 +52,7 @@ Meteor.methods({
var sessionIndex = user.services.saml.idpSession;
nameID = sessionIndex;
if (Accounts.saml.settings.debug) {
console.log('NameID for user ' + Meteor.userId() + ' found: ' + JSON.stringify(nameID));
console.log(`NameID for user ${ Meteor.userId() } found: ${ JSON.stringify(nameID) }`);
}

var _saml = new SAML(providerConfig);
Expand All @@ -76,7 +76,7 @@ Meteor.methods({
var _syncRequestToUrl = Meteor.wrapAsync(_saml.requestToUrl, _saml);
var result = _syncRequestToUrl(request.request, 'logout');
if (Accounts.saml.settings.debug) {
console.log('SAML Logout Request ' + result);
console.log(`SAML Logout Request ${ result }`);
}


Expand All @@ -91,7 +91,7 @@ Accounts.registerLoginHandler(function(loginRequest) {

var loginResult = Accounts.saml.retrieveCredential(loginRequest.credentialToken);
if (Accounts.saml.settings.debug) {
console.log('RESULT :' + JSON.stringify(loginResult));
console.log(`RESULT :${ JSON.stringify(loginResult) }`);
}

if (loginResult === undefined) {
Expand Down Expand Up @@ -186,7 +186,7 @@ var closePopup = function(res, err) {
});
var content = '<html><head><script>window.close()</script></head><body><H1>Verified</H1></body></html>';
if (err) {
content = '<html><body><h2>Sorry, an annoying error occured</h2><div>' + err + '</div><a onclick="window.close();">Close Window</a></body></html>';
content = `<html><body><h2>Sorry, an annoying error occured</h2><div>${ err }</div><a onclick="window.close();">Close Window</a></body></html>`;
}
res.end(content, 'utf-8');
};
Expand Down Expand Up @@ -239,13 +239,13 @@ var middleware = function(req, res, next) {

// Skip everything if there's no service set by the saml middleware
if (!service) {
throw new Error('Unexpected SAML service ' + samlObject.serviceName);
throw new Error(`Unexpected SAML service ${ samlObject.serviceName }`);
}
var _saml;
switch (samlObject.actionName) {
case 'metadata':
_saml = new SAML(service);
service.callbackUrl = Meteor.absoluteUrl('_saml/validate/' + service.provider);
service.callbackUrl = Meteor.absoluteUrl(`_saml/validate/${ service.provider }`);
res.writeHead(200);
res.write(_saml.generateServiceProviderMetadata(service.callbackUrl));
res.end();
Expand All @@ -258,14 +258,14 @@ var middleware = function(req, res, next) {
if (!err) {
var logOutUser = function(inResponseTo) {
if (Accounts.saml.settings.debug) {
console.log('Logging Out user via inResponseTo ' + inResponseTo);
console.log(`Logging Out user via inResponseTo ${ inResponseTo }`);
}
var loggedOutUser = Meteor.users.find({
'services.saml.inResponseTo': inResponseTo
}).fetch();
if (loggedOutUser.length === 1) {
if (Accounts.saml.settings.debug) {
console.log('Found user ' + loggedOutUser[0]._id);
console.log(`Found user ${ loggedOutUser[0]._id }`);
}
Meteor.users.update({
_id: loggedOutUser[0]._id
Expand Down Expand Up @@ -310,7 +310,7 @@ var middleware = function(req, res, next) {
res.end();
break;
case 'authorize':
service.callbackUrl = Meteor.absoluteUrl('_saml/validate/' + service.provider);
service.callbackUrl = Meteor.absoluteUrl(`_saml/validate/${ service.provider }`);
service.id = samlObject.credentialToken;
_saml = new SAML(service);
_saml.getAuthorizeUrl(req, function(err, url) {
Expand All @@ -328,7 +328,7 @@ var middleware = function(req, res, next) {
Accounts.saml.RelayState = req.body.RelayState;
_saml.validateResponse(req.body.SAMLResponse, req.body.RelayState, function(err, profile/*, loggedOut*/) {
if (err) {
throw new Error('Unable to validate response url: ' + err);
throw new Error(`Unable to validate response url: ${ err }`);
}

var credentialToken = profile.inResponseToId || profile.InResponseTo || samlObject.credentialToken;
Expand All @@ -338,7 +338,7 @@ var middleware = function(req, res, next) {
Accounts.saml._loginResultForCredentialToken[saml_idp_credentialToken] = {
profile: profile
};
var url = Meteor.absoluteUrl('home') + '?saml_idp_credentialToken='+saml_idp_credentialToken;
var url = `${ Meteor.absoluteUrl('home') }?saml_idp_credentialToken=${ saml_idp_credentialToken }`;
res.writeHead(302, {
'Location': url
});
Expand All @@ -352,7 +352,7 @@ var middleware = function(req, res, next) {
});
break;
default:
throw new Error('Unexpected SAML action ' + samlObject.actionName);
throw new Error(`Unexpected SAML action ${ samlObject.actionName }`);

}
} catch (err) {
Expand Down
Loading