From 93f38d4f30707730ac274e158f020ae45c947e85 Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Sat, 18 Feb 2017 18:06:28 -0700
Subject: [PATCH] ESlint no-multi-assign and max-nested-callbacks,
no-mixed-requires, max-statements-per-line
---
.eslintrc | 14 +++++++-------
public/src/admin/admin.js | 3 ++-
public/src/modules/navigator.js | 3 ++-
public/src/modules/translator.js | 3 ++-
public/src/utils.js | 3 ++-
src/categories/data.js | 6 ++++--
src/categories/recentreplies.js | 4 +++-
src/emailer.js | 3 ++-
src/events.js | 6 +++++-
src/messaging/notifications.js | 3 ++-
src/meta/js.js | 3 ++-
src/user/data.js | 3 ++-
test/groups.js | 2 +-
13 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index 777f786b71..3e9ea2e3ae 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -26,6 +26,8 @@
"indent": ["error", "tab"],
"no-eq-null": "off",
"camelcase": "off",
+ "no-new": "off",
+ "no-shadow": "off",
// ES6
"prefer-rest-params": "off",
@@ -33,6 +35,7 @@
"prefer-arrow-callback": "off",
"prefer-template": "off",
"no-var": "off",
+ "object-shorthand": "off",
// TODO
"import/no-unresolved": "off",
@@ -41,27 +44,24 @@
"import/newline-after-import": "off",
"no-bitwise": "off",
"global-require": "off",
- "no-multi-assign": "off",
"max-len": "off",
"no-param-reassign": "off",
- "object-shorthand": "off",
"no-prototype-builtins": "off",
"vars-on-top": "off",
"no-restricted-syntax": "off",
- "no-shadow": "off",
"no-script-url": "off",
"no-use-before-define": "off",
"default-case": "off",
"new-cap": "off",
+ // "no-multi-assign": "off",
// "linebreak-style": "off",
// "one-var": "off",
// "no-undef": "off",
- "no-new": "off",
- "max-nested-callbacks": "off",
- "no-mixed-requires": "off",
+ // "max-nested-callbacks": "off",
+ // "no-mixed-requires": "off",
// "brace-style": "off",
- "max-statements-per-line": "off",
+ // "max-statements-per-line": "off",
// "no-unused-vars": "off",
// "no-mixed-spaces-and-tabs": "off",
// "no-useless-concat": "off",
diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js
index fd0804188f..7ec41a553b 100644
--- a/public/src/admin/admin.js
+++ b/public/src/admin/admin.js
@@ -108,7 +108,8 @@
var mainTitle;
var pageTitle;
if (/admin\/general\/dashboard$/.test(url)) {
- mainTitle = pageTitle = '[[admin/menu:general/dashboard]]';
+ pageTitle = '[[admin/menu:general/dashboard]]';
+ mainTitle = pageTitle;
} else if (/admin\/plugins\//.test(url)) {
mainTitle = fallback;
pageTitle = '[[admin/menu:section-plugins]] > ' + mainTitle;
diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js
index 96ed332e98..68c0359755 100644
--- a/public/src/modules/navigator.js
+++ b/public/src/modules/navigator.js
@@ -75,7 +75,8 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
navigator.disable = function () {
count = 0;
index = 1;
- navigator.selector = navigator.callback = null;
+ navigator.callback = null;
+ navigator.selector = null;
$(window).off('scroll', navigator.update);
toggle(false);
diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js
index 4291c82957..ce49f222f5 100644
--- a/public/src/modules/translator.js
+++ b/public/src/modules/translator.js
@@ -289,7 +289,8 @@
warn('[translator] Parameter `namespace` is ' + namespace + (namespace === '' ? '(empty string)' : ''));
translation = Promise.resolve({});
} else {
- translation = this.translations[namespace] = this.translations[namespace] || this.load(this.lang, namespace).catch(function () { return {}; });
+ this.translations[namespace] = this.translations[namespace] || this.load(this.lang, namespace).catch(function () { return {}; });
+ translation = this.translations[namespace];
}
if (key) {
diff --git a/public/src/utils.js b/public/src/utils.js
index 1506f296e2..171e3d86db 100644
--- a/public/src/utils.js
+++ b/public/src/utils.js
@@ -22,7 +22,7 @@
}
- module.exports = utils = {
+ utils = {
generateUUID: function () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0;
@@ -447,6 +447,7 @@
},
};
+ module.exports = utils;
if (typeof window !== 'undefined') {
window.utils = module.exports;
}
diff --git a/src/categories/data.js b/src/categories/data.js
index 06bd3acfe9..25b7021610 100644
--- a/src/categories/data.js
+++ b/src/categories/data.js
@@ -45,11 +45,13 @@ module.exports = function (Categories) {
category.disabled = category.hasOwnProperty('disabled') ? parseInt(category.disabled, 10) === 1 : undefined;
category.icon = category.icon || 'hidden';
if (category.hasOwnProperty('post_count')) {
- category.post_count = category.totalPostCount = category.post_count || 0;
+ category.post_count = category.post_count || 0;
+ category.totalPostCount = category.post_count;
}
if (category.hasOwnProperty('topic_count')) {
- category.topic_count = category.totalTopicCount = category.topic_count || 0;
+ category.topic_count = category.topic_count || 0;
+ category.totalTopicCount = category.topic_count;
}
if (category.image) {
diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.js
index d516f4f035..c38fec527e 100644
--- a/src/categories/recentreplies.js
+++ b/src/categories/recentreplies.js
@@ -131,7 +131,9 @@ module.exports = function (Categories) {
if (teaser) {
teaser.cid = topicData[index].cid;
teaser.parentCid = parseInt(parentCids[teaser.cid], 10) || 0;
- teaser.tid = teaser.uid = teaser.user.uid = undefined;
+ teaser.tid = undefined;
+ teaser.uid = undefined;
+ teaser.user.uid = undefined;
teaser.topic = {
slug: topicData[index].slug,
title: validator.escape(String(topicData[index].title)),
diff --git a/src/emailer.js b/src/emailer.js
index 09b58a20c3..95ffbdceba 100644
--- a/src/emailer.js
+++ b/src/emailer.js
@@ -29,7 +29,7 @@ var fallbackTransport;
// Enable Gmail transport if enabled in ACP
if (parseInt(meta.config['email:GmailTransport:enabled'], 10) === 1) {
- fallbackTransport = transports.gmail = nodemailer.createTransport(smtpTransport({
+ transports.gmail = nodemailer.createTransport(smtpTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
@@ -38,6 +38,7 @@ var fallbackTransport;
pass: meta.config['email:GmailTransport:pass'],
},
}));
+ fallbackTransport = transports.gmail;
} else {
fallbackTransport = transports.sendmail;
}
diff --git a/src/events.js b/src/events.js
index 3c8ea7a252..ab2864bc23 100644
--- a/src/events.js
+++ b/src/events.js
@@ -61,7 +61,11 @@ var utils = require('../public/src/utils');
}
});
var e = utils.merge(event);
- e.eid = e.uid = e.type = e.ip = e.user = undefined;
+ e.eid = undefined;
+ e.uid = undefined;
+ e.type = undefined;
+ e.ip = undefined;
+ e.user = undefined;
event.jsonString = JSON.stringify(e, null, 4);
event.timestampISO = new Date(parseInt(event.timestamp, 10)).toUTCString();
});
diff --git a/src/messaging/notifications.js b/src/messaging/notifications.js
index 3a333b2ffd..674fa77c3a 100644
--- a/src/messaging/notifications.js
+++ b/src/messaging/notifications.js
@@ -36,9 +36,10 @@ module.exports = function (Messaging) {
queueObj.message.content += '\n' + messageObj.content;
clearTimeout(queueObj.timeout);
} else {
- queueObj = Messaging.notifyQueue[fromUid + ':' + roomId] = {
+ queueObj = {
message: messageObj,
};
+ Messaging.notifyQueue[fromUid + ':' + roomId] = queueObj;
}
queueObj.timeout = setTimeout(function () {
diff --git a/src/meta/js.js b/src/meta/js.js
index f028717ba7..18701349f8 100644
--- a/src/meta/js.js
+++ b/src/meta/js.js
@@ -133,7 +133,8 @@ module.exports = function (Meta) {
winston.verbose('[meta/js] Minifying ' + target);
var forkProcessParams = setupDebugging();
- var minifier = Meta.js.minifierProc = fork('minifier.js', [], forkProcessParams);
+ var minifier = fork('minifier.js', [], forkProcessParams);
+ Meta.js.minifierProc = minifier;
Meta.js.target[target] = {};
diff --git a/src/user/data.js b/src/user/data.js
index 3a7ee731aa..443de8e7aa 100644
--- a/src/user/data.js
+++ b/src/user/data.js
@@ -116,7 +116,8 @@ module.exports = function (User) {
}
if (user.picture && user.picture === user.uploadedpicture) {
- user.picture = user.uploadedpicture = user.picture.startsWith('http') ? user.picture : nconf.get('relative_path') + user.picture;
+ user.uploadedpicture = user.picture.startsWith('http') ? user.picture : nconf.get('relative_path') + user.picture;
+ user.picture = user.uploadedpicture;
} else if (user.uploadedpicture) {
user.uploadedpicture = user.uploadedpicture.startsWith('http') ? user.uploadedpicture : nconf.get('relative_path') + user.uploadedpicture;
}
diff --git a/test/groups.js b/test/groups.js
index 8e70341e00..d2f2df8425 100644
--- a/test/groups.js
+++ b/test/groups.js
@@ -794,7 +794,7 @@ describe('Groups', function () {
helpers.uploadFile(nconf.get('url') + '/api/groups/uploadpicture', logoPath, { params: JSON.stringify({ groupName: 'Test' }) }, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 500);
- assert.equal(body.error, '[[error:no-privileges]]');
+ assert(/\[\[error:no-privileges\]\]/.test(body));
done();
});
});