Update to eslint 4 and enforce extra rules

This commit is contained in:
Pavel Djundik 2017-04-08 15:34:31 +03:00
parent edc106dadb
commit f6dd616d5e
26 changed files with 131 additions and 130 deletions

View File

@ -9,22 +9,28 @@ env:
node: true node: true
rules: rules:
arrow-body-style: 2
arrow-parens: [2, always]
arrow-spacing: 2
block-scoped-var: 2 block-scoped-var: 2
block-spacing: [2, always] block-spacing: [2, always]
brace-style: [2, 1tbs] brace-style: [2, 1tbs]
comma-dangle: 0 comma-dangle: 0
curly: [2, all] curly: [2, all]
dot-location: [2, property]
dot-notation: 2 dot-notation: 2
eol-last: 2 eol-last: 2
eqeqeq: 2 eqeqeq: 2
handle-callback-err: 2 handle-callback-err: 2
indent: [2, tab, { "MemberExpression": 1 }] indent: [2, tab]
key-spacing: [2, {beforeColon: false, afterColon: true}] key-spacing: [2, {beforeColon: false, afterColon: true}]
keyword-spacing: [2, {before: true, after: true}] keyword-spacing: [2, {before: true, after: true}]
linebreak-style: [2, unix] linebreak-style: [2, unix]
no-compare-neg-zero: 2 no-catch-shadow: 2
no-confusing-arrow: 2
no-console: 0 no-console: 0
no-control-regex: 0 no-control-regex: 0
no-duplicate-imports: 2
no-else-return: 2 no-else-return: 2
no-implicit-globals: 2 no-implicit-globals: 2
no-multi-spaces: 2 no-multi-spaces: 2
@ -33,12 +39,14 @@ rules:
no-template-curly-in-string: 2 no-template-curly-in-string: 2
no-trailing-spaces: 2 no-trailing-spaces: 2
no-unsafe-negation: 2 no-unsafe-negation: 2
no-useless-escape: 2 no-useless-computed-key: 2
no-useless-return: 2 no-useless-return: 2
object-curly-spacing: [2, never] object-curly-spacing: [2, never]
padded-blocks: [2, never] padded-blocks: [2, never]
prefer-const: 2
quote-props: [2, as-needed] quote-props: [2, as-needed]
quotes: [2, double, avoid-escape] quotes: [2, double, avoid-escape]
semi-style: [2, last]
semi: [2, always] semi: [2, always]
space-before-blocks: 2 space-before-blocks: 2
space-before-function-paren: [2, never] space-before-function-paren: [2, never]
@ -46,6 +54,8 @@ rules:
space-infix-ops: 2 space-infix-ops: 2
spaced-comment: [2, always] spaced-comment: [2, always]
strict: 2 strict: 2
template-curly-spacing: 2
yoda: 2
globals: globals:
log: false log: false

View File

@ -16,7 +16,7 @@ const commonSchemes = [
]; ];
function findLinks(text) { function findLinks(text) {
let result = []; const result = [];
// URI.withinString() identifies URIs within text, e.g. to translate them to // URI.withinString() identifies URIs within text, e.g. to translate them to
// <a>-Tags. // <a>-Tags.
@ -29,7 +29,7 @@ function findLinks(text) {
// Check if the scheme of the detected URL matches a common one above. // Check if the scheme of the detected URL matches a common one above.
// In a URL like `foo..http://example.com`, the scheme would be `foo..http`, // In a URL like `foo..http://example.com`, the scheme would be `foo..http`,
// so we need to clean up the end of the scheme and filter out the rest. // so we need to clean up the end of the scheme and filter out the rest.
const matchedScheme = commonSchemes.find(scheme => parsedScheme.endsWith(scheme)); const matchedScheme = commonSchemes.find((scheme) => parsedScheme.endsWith(scheme));
// A known scheme was found, extract the unknown part from the URL // A known scheme was found, extract the unknown part from the URL
if (matchedScheme) { if (matchedScheme) {

View File

@ -48,10 +48,10 @@ function merge(textParts, styleFragments) {
.sort((a, b) => a.start - b.start); .sort((a, b) => a.start - b.start);
// Distribute the style fragments within the text parts // Distribute the style fragments within the text parts
return allParts.map(textPart => { return allParts.map((textPart) => {
textPart.fragments = styleFragments textPart.fragments = styleFragments
.filter(fragment => anyIntersection(textPart, fragment)) .filter((fragment) => anyIntersection(textPart, fragment))
.map(fragment => assign(textPart, fragment)); .map((fragment) => assign(textPart, fragment));
return textPart; return textPart;
}); });

View File

@ -84,7 +84,6 @@ function parseStyle(text) {
// encountered since the previous styling character. // encountered since the previous styling character.
while (position < text.length) { while (position < text.length) {
switch (text[position]) { switch (text[position]) {
case RESET: case RESET:
emitFragment(); emitFragment();
resetStyle(); resetStyle();
@ -178,7 +177,7 @@ function prepare(text) {
.reduce((prev, curr) => { .reduce((prev, curr) => {
if (prev.length) { if (prev.length) {
const lastEntry = prev[prev.length - 1]; const lastEntry = prev[prev.length - 1];
if (properties.every(key => curr[key] === lastEntry[key])) { if (properties.every((key) => curr[key] === lastEntry[key])) {
lastEntry.text += curr.text; lastEntry.text += curr.text;
lastEntry.end += curr.text.length; lastEntry.end += curr.text.length;
return prev; return prev;

View File

@ -8,7 +8,7 @@ const merge = require("./ircmessageparser/merge");
// Create an HTML `span` with styling information for a given fragment // Create an HTML `span` with styling information for a given fragment
function createFragment(fragment) { function createFragment(fragment) {
let classes = []; const classes = [];
if (fragment.bold) { if (fragment.bold) {
classes.push("irc-bold"); classes.push("irc-bold");
} }
@ -50,7 +50,7 @@ function createFragment(fragment) {
module.exports = function parse(text) { module.exports = function parse(text) {
// Extract the styling information and get the plain text version from it // Extract the styling information and get the plain text version from it
const styleFragments = parseStyle(text); const styleFragments = parseStyle(text);
const cleanText = styleFragments.map(fragment => fragment.text).join(""); const cleanText = styleFragments.map((fragment) => fragment.text).join("");
// On the plain text, find channels and URLs, returned as "parts". Parts are // On the plain text, find channels and URLs, returned as "parts". Parts are
// arrays of objects containing start and end markers, as well as metadata // arrays of objects containing start and end markers, as well as metadata
@ -67,7 +67,7 @@ module.exports = function parse(text) {
// Merge the styling information with the channels / URLs / text objects and // Merge the styling information with the channels / URLs / text objects and
// generate HTML strings with the resulting fragments // generate HTML strings with the resulting fragments
return merge(parts, styleFragments).map(textPart => { return merge(parts, styleFragments).map((textPart) => {
// Create HTML strings with styling information // Create HTML strings with styling information
const fragments = textPart.fragments.map(createFragment).join(""); const fragments = textPart.fragments.map(createFragment).join("");

View File

@ -52,7 +52,7 @@ $(function() {
id: "emoji", id: "emoji",
match: /\B:([-+\w]*):?$/, match: /\B:([-+\w]*):?$/,
search(term, callback) { search(term, callback) {
callback(Object.keys(emojiMap).filter(name => name.indexOf(term) === 0)); callback(Object.keys(emojiMap).filter((name) => name.indexOf(term) === 0));
}, },
template(value) { template(value) {
return `<span class="emoji">${emojiMap[value]}</span> ${value}`; return `<span class="emoji">${emojiMap[value]}</span> ${value}`;
@ -69,7 +69,7 @@ $(function() {
search(term, callback) { search(term, callback) {
term = term.slice(1); term = term.slice(1);
if (term[0] === "@") { if (term[0] === "@") {
callback(completeNicks(term.slice(1)).map(val => "@" + val)); callback(completeNicks(term.slice(1)).map((val) => "@" + val));
} else { } else {
callback(completeNicks(term)); callback(completeNicks(term));
} }
@ -119,7 +119,7 @@ $(function() {
search(term, callback) { search(term, callback) {
term = term.toLowerCase(); term = term.toLowerCase();
const matchingColorCodes = constants.colorCodeMap const matchingColorCodes = constants.colorCodeMap
.filter(i => i[0].startsWith(term) || i[1].toLowerCase().startsWith(term)); .filter((i) => i[0].startsWith(term) || i[1].toLowerCase().startsWith(term));
callback(matchingColorCodes); callback(matchingColorCodes);
}, },
@ -138,8 +138,8 @@ $(function() {
search(term, callback, match) { search(term, callback, match) {
term = term.toLowerCase(); term = term.toLowerCase();
const matchingColorCodes = constants.colorCodeMap const matchingColorCodes = constants.colorCodeMap
.filter(i => i[0].startsWith(term) || i[1].toLowerCase().startsWith(term)) .filter((i) => i[0].startsWith(term) || i[1].toLowerCase().startsWith(term))
.map(pair => pair.concat(match[1])); // Needed to pass fg color to `template`... .map((pair) => pair.concat(match[1])); // Needed to pass fg color to `template`...
callback(matchingColorCodes); callback(matchingColorCodes);
}, },
@ -1099,7 +1099,7 @@ $(function() {
const fuzzyOptions = { const fuzzyOptions = {
pre: "<b>", pre: "<b>",
post: "</b>", post: "</b>",
extract: el => $(el).text() extract: (el) => $(el).text()
}; };
const result = fuzzy.filter( const result = fuzzy.filter(
@ -1438,7 +1438,7 @@ $(function() {
return $.grep( return $.grep(
words, words,
w => !w.toLowerCase().indexOf(word.toLowerCase()) (w) => !w.toLowerCase().indexOf(word.toLowerCase())
); );
} }
@ -1447,7 +1447,7 @@ $(function() {
return $.grep( return $.grep(
words, words,
w => !w.toLowerCase().indexOf(word.toLowerCase()) (w) => !w.toLowerCase().indexOf(word.toLowerCase())
); );
} }
@ -1464,7 +1464,7 @@ $(function() {
return $.grep( return $.grep(
words, words,
w => !w.toLowerCase().indexOf(word.toLowerCase()) (w) => !w.toLowerCase().indexOf(word.toLowerCase())
); );
} }
@ -1628,19 +1628,17 @@ $(function() {
// Only start opening socket.io connection after all events have been registered // Only start opening socket.io connection after all events have been registered
socket.open(); socket.open();
window.addEventListener( window.addEventListener("popstate", (e) => {
"popstate",
(e) => {
const {state} = e; const {state} = e;
if (!state) { if (!state) {
return; return;
} }
const {clickTarget} = state; const {clickTarget} = state;
if (clickTarget) { if (clickTarget) {
$(clickTarget).trigger("click", { $(clickTarget).trigger("click", {
pushState: false pushState: false
}); });
} }
} });
);
}); });

View File

@ -63,7 +63,7 @@
"babel-loader": "7.0.0", "babel-loader": "7.0.0",
"babel-preset-env": "1.5.2", "babel-preset-env": "1.5.2",
"chai": "4.0.2", "chai": "4.0.2",
"eslint": "3.19.0", "eslint": "4.0.0",
"font-awesome": "4.7.0", "font-awesome": "4.7.0",
"fuzzy": "0.1.3", "fuzzy": "0.1.3",
"handlebars": "4.0.10", "handlebars": "4.0.10",

View File

@ -58,7 +58,7 @@ var inputs = [
].reduce(function(plugins, name) { ].reduce(function(plugins, name) {
var path = "./plugins/inputs/" + name; var path = "./plugins/inputs/" + name;
var plugin = require(path); var plugin = require(path);
plugin.commands.forEach(command => plugins[command] = plugin); plugin.commands.forEach((command) => plugins[command] = plugin);
return plugins; return plugins;
}, {}); }, {});
@ -88,7 +88,7 @@ function Client(manager, name, config) {
} }
var delay = 0; var delay = 0;
(client.config.networks || []).forEach(n => { (client.config.networks || []).forEach((n) => {
setTimeout(function() { setTimeout(function() {
client.connect(n); client.connect(n);
}, delay); }, delay);
@ -155,7 +155,7 @@ Client.prototype.connect = function(args) {
if (args.channels) { if (args.channels) {
var badName = false; var badName = false;
args.channels.forEach(chan => { args.channels.forEach((chan) => {
if (!chan.name) { if (!chan.name) {
badName = true; badName = true;
return; return;
@ -273,7 +273,7 @@ Client.prototype.connect = function(args) {
"znc.in/self-message", // Legacy echo-message for ZNc "znc.in/self-message", // Legacy echo-message for ZNc
]); ]);
events.forEach(plugin => { events.forEach((plugin) => {
var path = "./plugins/irc-events/" + plugin; var path = "./plugins/irc-events/" + plugin;
require(path).apply(client, [ require(path).apply(client, [
network.irc, network.irc,
@ -319,7 +319,7 @@ Client.prototype.setPassword = function(hash, callback) {
Client.prototype.input = function(data) { Client.prototype.input = function(data) {
var client = this; var client = this;
data.text.split("\n").forEach(line => { data.text.split("\n").forEach((line) => {
data.text = line; data.text = line;
client.inputLine(data); client.inputLine(data);
}); });
@ -422,12 +422,10 @@ Client.prototype.sort = function(data) {
switch (data.type) { switch (data.type) {
case "networks": case "networks":
this.networks.sort((a, b) => { this.networks.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
return order.indexOf(a.id) - order.indexOf(b.id);
});
// Sync order to connected clients // Sync order to connected clients
this.emit("sync_sort", {order: this.networks.map(obj => obj.id), type: data.type, target: data.target}); this.emit("sync_sort", {order: this.networks.map((obj) => obj.id), type: data.type, target: data.target});
break; break;
@ -437,12 +435,10 @@ Client.prototype.sort = function(data) {
return; return;
} }
network.channels.sort((a, b) => { network.channels.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
return order.indexOf(a.id) - order.indexOf(b.id);
});
// Sync order to connected clients // Sync order to connected clients
this.emit("sync_sort", {order: network.channels.map(obj => obj.id), type: data.type, target: data.target}); this.emit("sync_sort", {order: network.channels.map((obj) => obj.id), type: data.type, target: data.target});
break; break;
} }
@ -472,7 +468,7 @@ Client.prototype.quit = function() {
socket.disconnect(); socket.disconnect();
} }
} }
this.networks.forEach(network => { this.networks.forEach((network) => {
if (network.irc) { if (network.irc) {
network.irc.quit("Page closed"); network.irc.quit("Page closed");
} }
@ -496,7 +492,7 @@ Client.prototype.clientAttach = function(socketId) {
client.attachedClients[socketId] = client.lastActiveChannel; client.attachedClients[socketId] = client.lastActiveChannel;
// Update old networks to store ip and hostmask // Update old networks to store ip and hostmask
client.networks.forEach(network => { client.networks.forEach((network) => {
if (!network.ip) { if (!network.ip) {
save = true; save = true;
network.ip = (client.config && client.config.ip) || client.ip; network.ip = (client.config && client.config.ip) || client.ip;
@ -539,7 +535,7 @@ Client.prototype.save = _.debounce(function SaveClient() {
} }
const client = this; const client = this;
let json = {}; const json = {};
json.networks = this.networks.map(n => n.export()); json.networks = this.networks.map((n) => n.export());
client.manager.updateUser(client.name, json); client.manager.updateUser(client.name, json);
}, 1000, {maxWait: 10000}); }, 1000, {maxWait: 10000});

View File

@ -36,17 +36,17 @@ ClientManager.prototype.findClient = function(name, token) {
}; };
ClientManager.prototype.autoloadUsers = function() { ClientManager.prototype.autoloadUsers = function() {
this.getUsers().forEach(name => this.loadUser(name)); this.getUsers().forEach((name) => this.loadUser(name));
fs.watch(Helper.USERS_PATH, _.debounce(() => { fs.watch(Helper.USERS_PATH, _.debounce(() => {
const loaded = this.clients.map(c => c.name); const loaded = this.clients.map((c) => c.name);
const updatedUsers = this.getUsers(); const updatedUsers = this.getUsers();
// New users created since last time users were loaded // New users created since last time users were loaded
_.difference(updatedUsers, loaded).forEach(name => this.loadUser(name)); _.difference(updatedUsers, loaded).forEach((name) => this.loadUser(name));
// Existing users removed since last time users were loaded // Existing users removed since last time users were loaded
_.difference(loaded, updatedUsers).forEach(name => { _.difference(loaded, updatedUsers).forEach((name) => {
const client = _.find(this.clients, {name: name}); const client = _.find(this.clients, {name: name});
if (client) { if (client) {
client.quit(); client.quit();
@ -78,7 +78,7 @@ ClientManager.prototype.getUsers = function() {
var users = []; var users = [];
try { try {
var files = fs.readdirSync(Helper.USERS_PATH); var files = fs.readdirSync(Helper.USERS_PATH);
files.forEach(file => { files.forEach((file) => {
if (file.indexOf(".json") !== -1) { if (file.indexOf(".json") !== -1) {
users.push(file.replace(".json", "")); users.push(file.replace(".json", ""));
} }
@ -127,7 +127,7 @@ ClientManager.prototype.updateUser = function(name, opts, callback) {
return false; return false;
} }
let user = this.readUserConfig(name); const user = this.readUserConfig(name);
const currentUser = JSON.stringify(user, null, "\t"); const currentUser = JSON.stringify(user, null, "\t");
_.assign(user, opts); _.assign(user, opts);
const newUser = JSON.stringify(user, null, "\t"); const newUser = JSON.stringify(user, null, "\t");

View File

@ -38,7 +38,7 @@ class Identification {
} }
serverConnection(socket) { serverConnection(socket) {
socket.on("data", data => { socket.on("data", (data) => {
this.respondToIdent(socket, data); this.respondToIdent(socket, data);
socket.end(); socket.end();
}); });

View File

@ -12,7 +12,7 @@ function User(attr, prefixLookup) {
}); });
// irc-framework sets character mode, but lounge works with symbols // irc-framework sets character mode, but lounge works with symbols
this.modes = this.modes.map(mode => prefixLookup[mode]); this.modes = this.modes.map((mode) => prefixLookup[mode]);
if (this.modes[0]) { if (this.modes[0]) {
this.mode = this.modes[0]; this.mode = this.modes[0];

View File

@ -30,7 +30,7 @@ module.exports = function(irc, network) {
var delay = 1000; var delay = 1000;
var commands = network.commands; var commands = network.commands;
if (Array.isArray(commands)) { if (Array.isArray(commands)) {
commands.forEach(cmd => { commands.forEach((cmd) => {
setTimeout(function() { setTimeout(function() {
client.input({ client.input({
target: network.channels[0].id, target: network.channels[0].id,
@ -41,7 +41,7 @@ module.exports = function(irc, network) {
}); });
} }
network.channels.forEach(chan => { network.channels.forEach((chan) => {
if (chan.type !== Chan.Type.CHANNEL) { if (chan.type !== Chan.Type.CHANNEL) {
return; return;
} }
@ -126,7 +126,7 @@ module.exports = function(irc, network) {
network.prefixLookup = {}; network.prefixLookup = {};
data.options.PREFIX.forEach(mode => { data.options.PREFIX.forEach((mode) => {
network.prefixLookup[mode.mode] = mode.symbol; network.prefixLookup[mode.mode] = mode.symbol;
}); });

View File

@ -16,13 +16,13 @@ module.exports = function(client, chan, originalMsg) {
const links = originalMsg.text const links = originalMsg.text
.replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/g, "") .replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/g, "")
.split(" ") .split(" ")
.filter(w => /^https?:\/\//.test(w)); .filter((w) => /^https?:\/\//.test(w));
if (links.length === 0) { if (links.length === 0) {
return; return;
} }
let msg = new Msg({ const msg = new Msg({
type: Msg.Type.TOGGLE, type: Msg.Type.TOGGLE,
time: originalMsg.time, time: originalMsg.time,
self: originalMsg.self, self: originalMsg.self,

View File

@ -21,7 +21,7 @@ module.exports = function(irc, network) {
return; return;
} }
data.modes.forEach(mode => { data.modes.forEach((mode) => {
const text = mode.mode; const text = mode.mode;
const add = text[0] === "+"; const add = text[0] === "+";
const char = text[1]; const char = text[1];
@ -46,14 +46,14 @@ module.exports = function(irc, network) {
} }
let usersUpdated; let usersUpdated;
let userModeSortPriority = {}; const userModeSortPriority = {};
const supportsMultiPrefix = network.irc.network.cap.isEnabled("multi-prefix"); const supportsMultiPrefix = network.irc.network.cap.isEnabled("multi-prefix");
irc.network.options.PREFIX.forEach((prefix, index) => { irc.network.options.PREFIX.forEach((prefix, index) => {
userModeSortPriority[prefix.symbol] = index; userModeSortPriority[prefix.symbol] = index;
}); });
data.modes.forEach(mode => { data.modes.forEach((mode) => {
let text = mode.mode; let text = mode.mode;
const add = text[0] === "+"; const add = text[0] === "+";
const char = text[1]; const char = text[1];

View File

@ -8,7 +8,7 @@ module.exports = function(irc, network) {
var lobby = network.channels[0]; var lobby = network.channels[0];
if (data.motd) { if (data.motd) {
data.motd.split("\n").forEach(text => { data.motd.split("\n").forEach((text) => {
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.MOTD, type: Msg.Type.MOTD,
text: text text: text

View File

@ -10,12 +10,10 @@ module.exports = function(irc, network) {
return; return;
} }
chan.users = data.users.map(user => { chan.users = data.users.map((user) => new User({
return new User({
nick: user.nick, nick: user.nick,
modes: user.modes, modes: user.modes,
}, network.prefixLookup); }, network.prefixLookup));
});
chan.sortUsers(irc); chan.sortUsers(irc);

View File

@ -24,7 +24,7 @@ module.exports = function(irc, network) {
}); });
} }
network.channels.forEach(chan => { network.channels.forEach((chan) => {
var user = _.find(chan.users, {nick: data.nick}); var user = _.find(chan.users, {nick: data.nick});
if (typeof user === "undefined") { if (typeof user === "undefined") {
return; return;

View File

@ -6,7 +6,7 @@ var Msg = require("../../models/msg");
module.exports = function(irc, network) { module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("quit", function(data) { irc.on("quit", function(data) {
network.channels.forEach(chan => { network.channels.forEach((chan) => {
var from = data.nick; var from = data.nick;
var user = _.find(chan.users, {nick: from}); var user = _.find(chan.users, {nick: from});
if (typeof user === "undefined") { if (typeof user === "undefined") {

View File

@ -35,7 +35,7 @@ module.exports = function() {
.engine("html", expressHandlebars({ .engine("html", expressHandlebars({
extname: ".html", extname: ".html",
helpers: { helpers: {
tojson: c => JSON.stringify(c) tojson: (c) => JSON.stringify(c)
} }
})) }))
.set("view engine", "html") .set("view engine", "html")
@ -211,7 +211,7 @@ function init(socket, client) {
Helper.password Helper.password
.compare(old || "", client.config.password) .compare(old || "", client.config.password)
.then(matching => { .then((matching) => {
if (!matching) { if (!matching) {
socket.emit("change-password", { socket.emit("change-password", {
error: "The current password field does not match your account password" error: "The current password field does not match your account password"
@ -220,7 +220,7 @@ function init(socket, client) {
} }
const hash = Helper.password.hash(p1); const hash = Helper.password.hash(p1);
client.setPassword(hash, success => { client.setPassword(hash, (success) => {
const obj = {}; const obj = {};
if (success) { if (success) {
@ -232,7 +232,7 @@ function init(socket, client) {
socket.emit("change-password", obj); socket.emit("change-password", obj);
}); });
}).catch(error => { }).catch((error) => {
log.error(`Error while checking users password. Error: ${error}`); log.error(`Error while checking users password. Error: ${error}`);
}); });
} }
@ -291,18 +291,18 @@ function localAuth(client, user, password, callback) {
Helper.password Helper.password
.compare(password, client.config.password) .compare(password, client.config.password)
.then(matching => { .then((matching) => {
if (matching && Helper.password.requiresUpdate(client.config.password)) { if (matching && Helper.password.requiresUpdate(client.config.password)) {
const hash = Helper.password.hash(password); const hash = Helper.password.hash(password);
client.setPassword(hash, success => { client.setPassword(hash, (success) => {
if (success) { if (success) {
log.info(`User ${colors.bold(client.name)} logged in and their hashed password has been updated to match new security requirements`); log.info(`User ${colors.bold(client.name)} logged in and their hashed password has been updated to match new security requirements`);
} }
}); });
} }
callback(matching); callback(matching);
}).catch(error => { }).catch((error) => {
log.error(`Error while checking users password. Error: ${error}`); log.error(`Error while checking users password. Error: ${error}`);
}); });
} }

View File

@ -16,7 +16,7 @@ describe("friendlydate Handlebars helper", () => {
}); });
it("should not render any friendly dates prior to the day before", () => { it("should not render any friendly dates prior to the day before", () => {
[2, 7, 30, 365, 1000].forEach(day => { [2, 7, 30, 365, 1000].forEach((day) => {
const time = new Date().getTime() - 24 * 3600 * 1000 * day; const time = new Date().getTime() - 24 * 3600 * 1000 * day;
expect(friendlydate(time)).to.equal(moment(time).format("D MMMM YYYY")); expect(friendlydate(time)).to.equal(moment(time).format("D MMMM YYYY"));
}); });

View File

@ -13,8 +13,8 @@ describe("parse Handlebars helper", () => {
expected: "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#&amp;&quot;&gt;bug\">#&amp;&quot;&gt;bug</span>" expected: "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#&amp;&quot;&gt;bug\">#&amp;&quot;&gt;bug</span>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -25,8 +25,8 @@ describe("parse Handlebars helper", () => {
expected: "textwithcontrolcodes" expected: "textwithcontrolcodes"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -68,8 +68,8 @@ describe("parse Handlebars helper", () => {
"</a>" "</a>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -119,8 +119,8 @@ describe("parse Handlebars helper", () => {
"</a>" "</a>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -134,8 +134,8 @@ describe("parse Handlebars helper", () => {
expected: "http://." expected: "http://."
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -182,8 +182,8 @@ describe("parse Handlebars helper", () => {
"</span>" "</span>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -197,8 +197,8 @@ describe("parse Handlebars helper", () => {
expected: "#" expected: "#"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -237,8 +237,8 @@ describe("parse Handlebars helper", () => {
"<span class=\"irc-bold\">bold</span>" "<span class=\"irc-bold\">bold</span>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -263,8 +263,8 @@ describe("parse Handlebars helper", () => {
"</span>" "</span>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -279,8 +279,8 @@ describe("parse Handlebars helper", () => {
"</span>" "</span>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -302,8 +302,8 @@ describe("parse Handlebars helper", () => {
"</a>" "</a>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });
@ -318,8 +318,8 @@ describe("parse Handlebars helper", () => {
"</a>" "</a>"
}]; }];
const actual = testCases.map(testCase => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected); const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected); expect(actual).to.deep.equal(expected);
}); });

View File

@ -23,7 +23,7 @@ describe("Chan", function() {
var prefixLookup = {}; var prefixLookup = {};
network.network.options.PREFIX.forEach(mode => { network.network.options.PREFIX.forEach((mode) => {
prefixLookup[mode.mode] = mode.symbol; prefixLookup[mode.mode] = mode.symbol;
}); });
@ -32,7 +32,7 @@ describe("Chan", function() {
}; };
var getUserNames = function(chan) { var getUserNames = function(chan) {
return chan.users.map(u => u.nick); return chan.users.map((u) => u.nick);
}; };
it("should sort a simple user list", function() { it("should sort a simple user list", function() {

View File

@ -21,7 +21,7 @@ describe("Link plugin", function() {
}); });
it("should be able to fetch basic information about URLs", function(done) { it("should be able to fetch basic information about URLs", function(done) {
let message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/basic" text: "http://localhost:9002/basic"
}); });

View File

@ -12,7 +12,7 @@ describe("Server", () => {
const webURL = `http://${Helper.config.host}:${Helper.config.port}/`; const webURL = `http://${Helper.config.host}:${Helper.config.port}/`;
describe("Express", () => { describe("Express", () => {
it("should run a web server on " + webURL, done => { it("should run a web server on " + webURL, (done) => {
request(webURL, (error, response, body) => { request(webURL, (error, response, body) => {
expect(error).to.be.null; expect(error).to.be.null;
expect(body).to.include("<title>The Lounge</title>"); expect(body).to.include("<title>The Lounge</title>");
@ -22,7 +22,7 @@ describe("Server", () => {
}); });
}); });
it("should serve static content correctly", done => { it("should serve static content correctly", (done) => {
request(webURL + "manifest.json", (error, response, body) => { request(webURL + "manifest.json", (error, response, body) => {
expect(error).to.be.null; expect(error).to.be.null;
@ -58,11 +58,11 @@ describe("Server", () => {
client.close(); client.close();
}); });
it("should emit authorized message", done => { it("should emit authorized message", (done) => {
client.on("authorized", done); client.on("authorized", done);
}); });
it("should create network", done => { it("should create network", (done) => {
client.on("init", () => { client.on("init", () => {
client.emit("conn", { client.emit("conn", {
username: "test-user", username: "test-user",
@ -75,7 +75,7 @@ describe("Server", () => {
}); });
}); });
client.on("network", data => { client.on("network", (data) => {
expect(data.networks).to.be.an("array"); expect(data.networks).to.be.an("array");
expect(data.networks).to.have.lengthOf(1); expect(data.networks).to.have.lengthOf(1);
expect(data.networks[0].realname).to.equal("The Lounge Test"); expect(data.networks[0].realname).to.equal("The Lounge Test");
@ -86,8 +86,8 @@ describe("Server", () => {
}); });
}); });
it("should emit init message", done => { it("should emit init message", (done) => {
client.on("init", data => { client.on("init", (data) => {
expect(data.active).to.equal(-1); expect(data.active).to.equal(-1);
expect(data.networks).to.be.an("array"); expect(data.networks).to.be.an("array");
expect(data.networks).to.be.empty; expect(data.networks).to.be.empty;

View File

@ -8,25 +8,25 @@ describe("Client passwords", function() {
it("hashed password should match", function() { it("hashed password should match", function() {
// Generated with third party tool to test implementation // Generated with third party tool to test implementation
let comparedPassword = Helper.password.compare(inputPassword, "$2a$11$zrPPcfZ091WNfs6QrRHtQeUitlgrJcecfZhxOFiQs0FWw7TN3Q1oS"); const comparedPassword = Helper.password.compare(inputPassword, "$2a$11$zrPPcfZ091WNfs6QrRHtQeUitlgrJcecfZhxOFiQs0FWw7TN3Q1oS");
return comparedPassword.then(result => { return comparedPassword.then((result) => {
expect(result).to.be.true; expect(result).to.be.true;
}); });
}); });
it("wrong hashed password should not match", function() { it("wrong hashed password should not match", function() {
// Compare against a fake hash // Compare against a fake hash
let comparedPassword = Helper.password.compare(inputPassword, "$2a$11$zrPPcfZ091WRONGPASSWORDitlgrJcecfZhxOFiQs0FWw7TN3Q1oS"); const comparedPassword = Helper.password.compare(inputPassword, "$2a$11$zrPPcfZ091WRONGPASSWORDitlgrJcecfZhxOFiQs0FWw7TN3Q1oS");
return comparedPassword.then(result => { return comparedPassword.then((result) => {
expect(result).to.be.false; expect(result).to.be.false;
}); });
}); });
it("freshly hashed password should match", function() { it("freshly hashed password should match", function() {
let hashedPassword = Helper.password.hash(inputPassword); const hashedPassword = Helper.password.hash(inputPassword);
let comparedPassword = Helper.password.compare(inputPassword, hashedPassword); const comparedPassword = Helper.password.compare(inputPassword, hashedPassword);
return comparedPassword.then((result) => { return comparedPassword.then((result) => {
expect(result).to.be.true; expect(result).to.be.true;

View File

@ -7,7 +7,7 @@ const path = require("path");
// Common configuration // Common configuration
// ******************** // ********************
let config = { const config = {
entry: { entry: {
"js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"), "js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"),
"js/bundle.vendor.js": [ "js/bundle.vendor.js": [