Merge pull request #1231 from thelounge/eslint4

Update to eslint 4 and enforce extra rules
This commit is contained in:
Pavel Djundik 2017-06-19 20:30:41 +03:00 committed by GitHub
commit 16795cf2b7
26 changed files with 131 additions and 130 deletions

View File

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

View File

@ -16,7 +16,7 @@ const commonSchemes = [
];
function findLinks(text) {
let result = [];
const result = [];
// URI.withinString() identifies URIs within text, e.g. to translate them to
// <a>-Tags.
@ -29,7 +29,7 @@ function findLinks(text) {
// 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`,
// 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
if (matchedScheme) {

View File

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

View File

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

View File

@ -8,7 +8,7 @@ const merge = require("./ircmessageparser/merge");
// Create an HTML `span` with styling information for a given fragment
function createFragment(fragment) {
let classes = [];
const classes = [];
if (fragment.bold) {
classes.push("irc-bold");
}
@ -50,7 +50,7 @@ function createFragment(fragment) {
module.exports = function parse(text) {
// Extract the styling information and get the plain text version from it
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
// 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
// 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
const fragments = textPart.fragments.map(createFragment).join("");

View File

@ -52,7 +52,7 @@ $(function() {
id: "emoji",
match: /\B:([-+\w]*):?$/,
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) {
return `<span class="emoji">${emojiMap[value]}</span> ${value}`;
@ -69,7 +69,7 @@ $(function() {
search(term, callback) {
term = term.slice(1);
if (term[0] === "@") {
callback(completeNicks(term.slice(1)).map(val => "@" + val));
callback(completeNicks(term.slice(1)).map((val) => "@" + val));
} else {
callback(completeNicks(term));
}
@ -119,7 +119,7 @@ $(function() {
search(term, callback) {
term = term.toLowerCase();
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);
},
@ -138,8 +138,8 @@ $(function() {
search(term, callback, match) {
term = term.toLowerCase();
const matchingColorCodes = constants.colorCodeMap
.filter(i => i[0].startsWith(term) || i[1].toLowerCase().startsWith(term))
.map(pair => pair.concat(match[1])); // Needed to pass fg color to `template`...
.filter((i) => i[0].startsWith(term) || i[1].toLowerCase().startsWith(term))
.map((pair) => pair.concat(match[1])); // Needed to pass fg color to `template`...
callback(matchingColorCodes);
},
@ -476,7 +476,7 @@ $(function() {
$(container).empty();
}
// Check if date changed
// Check if date changed
var prevMsg = $(container.find(".msg")).last();
var prevMsgTime = new Date(prevMsg.attr("data-time"));
var msgTime = new Date(msg.attr("data-time"));
@ -490,7 +490,7 @@ $(function() {
prevMsg.after(templates.date_marker({msgDate: msgTime}));
}
// Add message to the container
// Add message to the container
container
.append(msg)
.trigger("msg", [
@ -1099,7 +1099,7 @@ $(function() {
const fuzzyOptions = {
pre: "<b>",
post: "</b>",
extract: el => $(el).text()
extract: (el) => $(el).text()
};
const result = fuzzy.filter(
@ -1438,7 +1438,7 @@ $(function() {
return $.grep(
words,
w => !w.toLowerCase().indexOf(word.toLowerCase())
(w) => !w.toLowerCase().indexOf(word.toLowerCase())
);
}
@ -1447,7 +1447,7 @@ $(function() {
return $.grep(
words,
w => !w.toLowerCase().indexOf(word.toLowerCase())
(w) => !w.toLowerCase().indexOf(word.toLowerCase())
);
}
@ -1464,7 +1464,7 @@ $(function() {
return $.grep(
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
socket.open();
window.addEventListener(
"popstate",
(e) => {
const {state} = e;
if (!state) {
return;
}
const {clickTarget} = state;
if (clickTarget) {
$(clickTarget).trigger("click", {
pushState: false
});
}
window.addEventListener("popstate", (e) => {
const {state} = e;
if (!state) {
return;
}
);
const {clickTarget} = state;
if (clickTarget) {
$(clickTarget).trigger("click", {
pushState: false
});
}
});
});

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ function User(attr, prefixLookup) {
});
// 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]) {
this.mode = this.modes[0];

View File

@ -30,7 +30,7 @@ module.exports = function(irc, network) {
var delay = 1000;
var commands = network.commands;
if (Array.isArray(commands)) {
commands.forEach(cmd => {
commands.forEach((cmd) => {
setTimeout(function() {
client.input({
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) {
return;
}
@ -126,7 +126,7 @@ module.exports = function(irc, network) {
network.prefixLookup = {};
data.options.PREFIX.forEach(mode => {
data.options.PREFIX.forEach((mode) => {
network.prefixLookup[mode.mode] = mode.symbol;
});

View File

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

View File

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

View File

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

View File

@ -10,12 +10,10 @@ module.exports = function(irc, network) {
return;
}
chan.users = data.users.map(user => {
return new User({
nick: user.nick,
modes: user.modes,
}, network.prefixLookup);
});
chan.users = data.users.map((user) => new User({
nick: user.nick,
modes: user.modes,
}, network.prefixLookup));
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});
if (typeof user === "undefined") {
return;

View File

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

View File

@ -35,7 +35,7 @@ module.exports = function() {
.engine("html", expressHandlebars({
extname: ".html",
helpers: {
tojson: c => JSON.stringify(c)
tojson: (c) => JSON.stringify(c)
}
}))
.set("view engine", "html")
@ -211,7 +211,7 @@ function init(socket, client) {
Helper.password
.compare(old || "", client.config.password)
.then(matching => {
.then((matching) => {
if (!matching) {
socket.emit("change-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);
client.setPassword(hash, success => {
client.setPassword(hash, (success) => {
const obj = {};
if (success) {
@ -232,7 +232,7 @@ function init(socket, client) {
socket.emit("change-password", obj);
});
}).catch(error => {
}).catch((error) => {
log.error(`Error while checking users password. Error: ${error}`);
});
}
@ -291,18 +291,18 @@ function localAuth(client, user, password, callback) {
Helper.password
.compare(password, client.config.password)
.then(matching => {
.then((matching) => {
if (matching && Helper.password.requiresUpdate(client.config.password)) {
const hash = Helper.password.hash(password);
client.setPassword(hash, success => {
client.setPassword(hash, (success) => {
if (success) {
log.info(`User ${colors.bold(client.name)} logged in and their hashed password has been updated to match new security requirements`);
}
});
}
callback(matching);
}).catch(error => {
}).catch((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", () => {
[2, 7, 30, 365, 1000].forEach(day => {
[2, 7, 30, 365, 1000].forEach((day) => {
const time = new Date().getTime() - 24 * 3600 * 1000 * day;
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>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -25,8 +25,8 @@ describe("parse Handlebars helper", () => {
expected: "textwithcontrolcodes"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -68,8 +68,8 @@ describe("parse Handlebars helper", () => {
"</a>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -119,8 +119,8 @@ describe("parse Handlebars helper", () => {
"</a>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -134,8 +134,8 @@ describe("parse Handlebars helper", () => {
expected: "http://."
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -182,8 +182,8 @@ describe("parse Handlebars helper", () => {
"</span>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -197,8 +197,8 @@ describe("parse Handlebars helper", () => {
expected: "#"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -237,8 +237,8 @@ describe("parse Handlebars helper", () => {
"<span class=\"irc-bold\">bold</span>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -263,8 +263,8 @@ describe("parse Handlebars helper", () => {
"</span>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -279,8 +279,8 @@ describe("parse Handlebars helper", () => {
"</span>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -302,8 +302,8 @@ describe("parse Handlebars helper", () => {
"</a>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});
@ -318,8 +318,8 @@ describe("parse Handlebars helper", () => {
"</a>"
}];
const actual = testCases.map(testCase => parse(testCase.input));
const expected = testCases.map(testCase => testCase.expected);
const actual = testCases.map((testCase) => parse(testCase.input));
const expected = testCases.map((testCase) => testCase.expected);
expect(actual).to.deep.equal(expected);
});

View File

@ -23,7 +23,7 @@ describe("Chan", function() {
var prefixLookup = {};
network.network.options.PREFIX.forEach(mode => {
network.network.options.PREFIX.forEach((mode) => {
prefixLookup[mode.mode] = mode.symbol;
});
@ -32,7 +32,7 @@ describe("Chan", function() {
};
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() {

View File

@ -21,7 +21,7 @@ describe("Link plugin", function() {
});
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"
});

View File

@ -12,7 +12,7 @@ describe("Server", () => {
const webURL = `http://${Helper.config.host}:${Helper.config.port}/`;
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) => {
expect(error).to.be.null;
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) => {
expect(error).to.be.null;
@ -58,11 +58,11 @@ describe("Server", () => {
client.close();
});
it("should emit authorized message", done => {
it("should emit authorized message", (done) => {
client.on("authorized", done);
});
it("should create network", done => {
it("should create network", (done) => {
client.on("init", () => {
client.emit("conn", {
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.have.lengthOf(1);
expect(data.networks[0].realname).to.equal("The Lounge Test");
@ -86,8 +86,8 @@ describe("Server", () => {
});
});
it("should emit init message", done => {
client.on("init", data => {
it("should emit init message", (done) => {
client.on("init", (data) => {
expect(data.active).to.equal(-1);
expect(data.networks).to.be.an("array");
expect(data.networks).to.be.empty;

View File

@ -8,25 +8,25 @@ describe("Client passwords", function() {
it("hashed password should match", function() {
// 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;
});
});
it("wrong hashed password should not match", function() {
// 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;
});
});
it("freshly hashed password should match", function() {
let hashedPassword = Helper.password.hash(inputPassword);
let comparedPassword = Helper.password.compare(inputPassword, hashedPassword);
const hashedPassword = Helper.password.hash(inputPassword);
const comparedPassword = Helper.password.compare(inputPassword, hashedPassword);
return comparedPassword.then((result) => {
expect(result).to.be.true;

View File

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