Enable no-var rule

Fixes #1961
This commit is contained in:
Pavel Djundik 2018-01-11 13:33:36 +02:00
parent 0d068f34a8
commit a3e448acf5
48 changed files with 260 additions and 265 deletions

View File

@ -45,6 +45,7 @@ rules:
no-useless-constructor: error no-useless-constructor: error
no-useless-return: error no-useless-return: error
no-use-before-define: [error, {functions: false}] no-use-before-define: [error, {functions: false}]
no-var: error
object-curly-spacing: [error, never] object-curly-spacing: [error, never]
padded-blocks: [error, never] padded-blocks: [error, never]
prefer-const: error prefer-const: error

View File

@ -2,8 +2,8 @@
// Generates a string from "color-1" to "color-32" based on an input string // Generates a string from "color-1" to "color-32" based on an input string
module.exports = function(str) { module.exports = function(str) {
var hash = 0; let hash = 0;
for (var i = 0; i < str.length; i++) { for (let i = 0; i < str.length; i++) {
hash += str.charCodeAt(i); hash += str.charCodeAt(i);
} }

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
var diff; let diff;
module.exports = function(a, opt) { module.exports = function(a, opt) {
if (a !== diff) { if (a !== diff) {

View File

@ -1,7 +1,6 @@
"use strict"; "use strict";
module.exports = function(mode) { const modes = {
var modes = {
"~": "owner", "~": "owner",
"&": "admin", "&": "admin",
"!": "admin", "!": "admin",
@ -10,5 +9,7 @@ module.exports = function(mode) {
"+": "voice", "+": "voice",
"": "normal", "": "normal",
}; };
module.exports = function(mode) {
return modes[mode]; return modes[mode];
}; };

View File

@ -4,12 +4,12 @@
* Simple slideout menu implementation. * Simple slideout menu implementation.
*/ */
module.exports = function slideoutMenu(viewport, menu) { module.exports = function slideoutMenu(viewport, menu) {
var touchStartPos = null; let touchStartPos = null;
var touchCurPos = null; let touchCurPos = null;
var touchStartTime = 0; let touchStartTime = 0;
var menuWidth = 0; let menuWidth = 0;
var menuIsOpen = false; let menuIsOpen = false;
var menuIsMoving = false; let menuIsMoving = false;
function toggleMenu(state) { function toggleMenu(state) {
menuIsOpen = state; menuIsOpen = state;
@ -26,7 +26,7 @@ module.exports = function slideoutMenu(viewport, menu) {
return; return;
} }
var touch = e.touches.item(0); const touch = e.touches.item(0);
viewport.classList.toggle("menu-dragging", true); viewport.classList.toggle("menu-dragging", true);
menuWidth = parseFloat(window.getComputedStyle(menu).width); menuWidth = parseFloat(window.getComputedStyle(menu).width);
@ -42,8 +42,8 @@ module.exports = function slideoutMenu(viewport, menu) {
} }
function onTouchMove(e) { function onTouchMove(e) {
var touch = touchCurPos = e.touches.item(0); const touch = touchCurPos = e.touches.item(0);
var setX = touch.screenX - touchStartPos.screenX; let setX = touch.screenX - touchStartPos.screenX;
if (Math.abs(setX > 30)) { if (Math.abs(setX > 30)) {
menuIsMoving = true; menuIsMoving = true;
@ -73,8 +73,8 @@ module.exports = function slideoutMenu(viewport, menu) {
} }
function onTouchEnd() { function onTouchEnd() {
var diff = touchCurPos.screenX - touchStartPos.screenX; const diff = touchCurPos.screenX - touchStartPos.screenX;
var absDiff = Math.abs(diff); const absDiff = Math.abs(diff);
if (absDiff > menuWidth / 2 || Date.now() - touchStartTime < 180 && absDiff > 50) { if (absDiff > menuWidth / 2 || Date.now() - touchStartTime < 180 && absDiff > 50) {
toggleMenu(diff > 0); toggleMenu(diff > 0);

View File

@ -1,4 +1,4 @@
/* eslint strict: 0 */ /* eslint strict: 0, no-var: 0 */
"use strict"; "use strict";
/* /*

View File

@ -24,15 +24,15 @@ const Changelog = require("./socket-events/changelog");
const JoinChannel = require("./join-channel"); const JoinChannel = require("./join-channel");
$(function() { $(function() {
var sidebar = $("#sidebar, #footer"); const sidebar = $("#sidebar, #footer");
var chat = $("#chat"); const chat = $("#chat");
$(document.body).data("app-name", document.title); $(document.body).data("app-name", document.title);
var viewport = $("#viewport"); const viewport = $("#viewport");
var sidebarSlide = slideoutMenu(viewport[0], sidebar[0]); const sidebarSlide = slideoutMenu(viewport[0], sidebar[0]);
var contextMenuContainer = $("#context-menu-container"); const contextMenuContainer = $("#context-menu-container");
var contextMenu = $("#context-menu"); const contextMenu = $("#context-menu");
$("#main").on("click", function(e) { $("#main").on("click", function(e) {
if ($(e.target).is(".lt")) { if ($(e.target).is(".lt")) {
@ -43,16 +43,16 @@ $(function() {
}); });
viewport.on("click", ".rt", function(e) { viewport.on("click", ".rt", function(e) {
var self = $(this); const self = $(this);
viewport.toggleClass(self.prop("class")); viewport.toggleClass(self.prop("class"));
e.stopPropagation(); e.stopPropagation();
chat.find(".chan.active .chat").trigger("msg.sticky"); chat.find(".chan.active .chat").trigger("msg.sticky");
}); });
function positionContextMenu(that, e) { function positionContextMenu(that, e) {
var offset; let offset;
var menuWidth = contextMenu.outerWidth(); const menuWidth = contextMenu.outerWidth();
var menuHeight = contextMenu.outerHeight(); const menuHeight = contextMenu.outerHeight();
if (that.hasClass("menu")) { if (that.hasClass("menu")) {
offset = that.offset(); offset = that.offset();
@ -75,8 +75,8 @@ $(function() {
} }
function showContextMenu(that, e) { function showContextMenu(that, e) {
var target = $(e.currentTarget); const target = $(e.currentTarget);
var output = ""; let output = "";
if (target.hasClass("user")) { if (target.hasClass("user")) {
output = templates.contextmenu_item({ output = templates.contextmenu_item({
@ -193,10 +193,10 @@ $(function() {
input.style.height = input.style.minHeight; input.style.height = input.style.minHeight;
} }
var input = $("#input") const input = $("#input")
.history() .history()
.on("input", function() { .on("input", function() {
var style = window.getComputedStyle(this); const style = window.getComputedStyle(this);
// Start by resetting height before computing as scrollHeight does not // Start by resetting height before computing as scrollHeight does not
// decrease when deleting characters // decrease when deleting characters
@ -212,7 +212,7 @@ $(function() {
chat.find(".chan.active .chat").trigger("msg.sticky"); // fix growing chat.find(".chan.active .chat").trigger("msg.sticky"); // fix growing
}); });
var focus = $.noop; let focus = $.noop;
if (!("ontouchstart" in window || navigator.maxTouchPoints > 0)) { if (!("ontouchstart" in window || navigator.maxTouchPoints > 0)) {
focus = function() { focus = function() {
if (chat.find(".active").hasClass("chan")) { if (chat.find(".active").hasClass("chan")) {
@ -238,7 +238,7 @@ $(function() {
$("#form").on("submit", function(e) { $("#form").on("submit", function(e) {
e.preventDefault(); e.preventDefault();
utils.forceFocus(); utils.forceFocus();
var text = input.val(); const text = input.val();
if (text.length === 0) { if (text.length === 0) {
return; return;
@ -265,11 +265,11 @@ $(function() {
utils.toggleNickEditor(true); utils.toggleNickEditor(true);
// Selects existing nick in the editable text field // Selects existing nick in the editable text field
var element = document.querySelector("#nick-value"); const element = document.querySelector("#nick-value");
element.focus(); element.focus();
var range = document.createRange(); const range = document.createRange();
range.selectNodeContents(element); range.selectNodeContents(element);
var selection = window.getSelection(); const selection = window.getSelection();
selection.removeAllRanges(); selection.removeAllRanges();
selection.addRange(range); selection.addRange(range);
}); });
@ -278,7 +278,7 @@ $(function() {
$("button#submit-nick").on("click", submitNick); $("button#submit-nick").on("click", submitNick);
function submitNick() { function submitNick() {
var newNick = $("#nick-value").text().trim(); const newNick = $("#nick-value").text().trim();
if (newNick.length === 0) { if (newNick.length === 0) {
cancelNick(); cancelNick();
@ -316,8 +316,8 @@ $(function() {
}); });
chat.on("click", ".inline-channel", function() { chat.on("click", ".inline-channel", function() {
var name = $(this).data("chan"); const name = $(this).data("chan");
var chan = utils.findCurrentNetworkChan(name); const chan = utils.findCurrentNetworkChan(name);
if (chan.length) { if (chan.length) {
chan.trigger("click"); chan.trigger("click");
@ -334,8 +334,8 @@ $(function() {
}); });
const openWindow = function openWindow(e, data) { const openWindow = function openWindow(e, data) {
var self = $(this); const self = $(this);
var target = self.data("target"); const target = self.data("target");
if (!target) { if (!target) {
return; return;
} }
@ -372,9 +372,7 @@ $(function() {
sidebarSlide.toggle(false); sidebarSlide.toggle(false);
} }
var lastActive = $("#windows > .active"); const lastActive = $("#windows > .active")
lastActive
.removeClass("active") .removeClass("active")
.find(".chat") .find(".chat")
.unsticky(); .unsticky();
@ -391,7 +389,7 @@ $(function() {
render.trimMessageInChannel(lastActiveChan, 100); render.trimMessageInChannel(lastActiveChan, 100);
} }
var chan = $(target) const chan = $(target)
.addClass("active") .addClass("active")
.trigger("show"); .trigger("show");
@ -403,7 +401,7 @@ $(function() {
document.title = title; document.title = title;
const type = chan.data("type"); const type = chan.data("type");
var placeholder = ""; let placeholder = "";
if (type === "channel" || type === "query") { if (type === "channel" || type === "query") {
placeholder = `Write to ${chanTitle}`; placeholder = `Write to ${chanTitle}`;
} }
@ -417,7 +415,7 @@ $(function() {
utils.setNick(self.closest(".network").data("nick")); utils.setNick(self.closest(".network").data("nick"));
} }
var chanChat = chan.find(".chat"); const chanChat = chan.find(".chat");
if (chanChat.length > 0 && type !== "special") { if (chanChat.length > 0 && type !== "special") {
chanChat.sticky(); chanChat.sticky();
} }
@ -481,11 +479,11 @@ $(function() {
}); });
function closeChan(chan) { function closeChan(chan) {
var cmd = "/close"; let cmd = "/close";
if (chan.hasClass("lobby")) { if (chan.hasClass("lobby")) {
cmd = "/quit"; cmd = "/quit";
var server = chan.find(".name").html(); const server = chan.find(".name").html();
if (!confirm("Disconnect from " + server + "?")) { // eslint-disable-line no-alert if (!confirm("Disconnect from " + server + "?")) { // eslint-disable-line no-alert
return false; return false;
} }
@ -601,17 +599,16 @@ $(function() {
if ($("body").hasClass("public") && (window.location.hash === "#connect" || window.location.hash === "")) { if ($("body").hasClass("public") && (window.location.hash === "#connect" || window.location.hash === "")) {
$("#connect").one("show", function() { $("#connect").one("show", function() {
var params = URI(document.location.search); const params = URI(document.location.search).search(true);
params = params.search(true);
// Possible parameters: name, host, port, password, tls, nick, username, realname, join // Possible parameters: name, host, port, password, tls, nick, username, realname, join
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in#Iterating_over_own_properties_only // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in#Iterating_over_own_properties_only
for (var key in params) { for (let key in params) {
if (params.hasOwnProperty(key)) { if (params.hasOwnProperty(key)) {
var value = params[key]; const value = params[key];
// \W searches for non-word characters // \W searches for non-word characters
key = key.replace(/\W/g, ""); key = key.replace(/\W/g, "");
var element = $("#connect input[name='" + key + "']"); const element = $("#connect input[name='" + key + "']");
// if the element exists, it isn't disabled, and it isn't hidden // if the element exists, it isn't disabled, and it isn't hidden
if (element.length > 0 && !element.is(":disabled") && !element.is(":hidden")) { if (element.length > 0 && !element.is(":disabled") && !element.is(":hidden")) {
if (element.is(":checkbox")) { if (element.is(":checkbox")) {

View File

@ -57,7 +57,7 @@ module.exports.initialize = () => {
const settings = $("#settings"); const settings = $("#settings");
for (var i in options) { for (const i in options) {
if (i === "userStyles") { if (i === "userStyles") {
settings.find("#user-specified-css-input").val(options[i]); settings.find("#user-specified-css-input").val(options[i]);
} else if (i === "highlights") { } else if (i === "highlights") {
@ -139,8 +139,7 @@ module.exports.initialize = () => {
} else if (name === "userStyles") { } else if (name === "userStyles") {
userStyles.html(options[name]); userStyles.html(options[name]);
} else if (name === "highlights") { } else if (name === "highlights") {
var highlightString = options[name]; options.highlights = options[name].split(",").map(function(h) {
options.highlights = highlightString.split(",").map(function(h) {
return h.trim(); return h.trim();
}).filter(function(h) { }).filter(function(h) {
// Ensure we don't have empty string in the list of highlights // Ensure we don't have empty string in the list of highlights

View File

@ -276,7 +276,7 @@ function loadMoreHistory(entries) {
return; return;
} }
var target = $(entry.target).find(".show-more-button"); const target = $(entry.target).find(".show-more-button");
if (target.prop("disabled")) { if (target.prop("disabled")) {
return; return;

View File

@ -68,7 +68,7 @@ function processReceivedMessage(data) {
notifyMessage(targetId, channel, data); notifyMessage(targetId, channel, data);
var lastVisible = container.find("div:visible").last(); const lastVisible = container.find("div:visible").last();
if (data.msg.self if (data.msg.self
|| lastVisible.hasClass("unread-marker") || lastVisible.hasClass("unread-marker")
|| (lastVisible.hasClass("date-marker") || (lastVisible.hasClass("date-marker")

View File

@ -4,8 +4,8 @@ const $ = require("jquery");
const escape = require("css.escape"); const escape = require("css.escape");
const input = $("#input"); const input = $("#input");
var serverHash = -1; var serverHash = -1; // eslint-disable-line no-var
var lastMessageId = -1; var lastMessageId = -1; // eslint-disable-line no-var
module.exports = { module.exports = {
inputCommands: {collapse, expand, join}, inputCommands: {collapse, expand, join},
@ -92,7 +92,7 @@ const favicon = $("#favicon");
function toggleNotificationMarkers(newState) { function toggleNotificationMarkers(newState) {
// Toggles the favicon to red when there are unread notifications // Toggles the favicon to red when there are unread notifications
if (favicon.data("toggled") !== newState) { if (favicon.data("toggled") !== newState) {
var old = favicon.prop("href"); const old = favicon.prop("href");
favicon.prop("href", favicon.data("other")); favicon.prop("href", favicon.data("other"));
favicon.data("other", old); favicon.data("other", old);
favicon.data("toggled", newState); favicon.data("toggled", newState);

View File

@ -8,7 +8,7 @@ process.chdir(__dirname);
// Doing this check as soon as possible allows us to avoid ES6 parser errors or // Doing this check as soon as possible allows us to avoid ES6 parser errors or
// other issues // other issues
// Try to display messages nicely, but gracefully degrade if anything goes wrong // Try to display messages nicely, but gracefully degrade if anything goes wrong
var pkg = require("./package.json"); const pkg = require("./package.json");
if (!require("semver").satisfies(process.version, pkg.engines.node)) { if (!require("semver").satisfies(process.version, pkg.engines.node)) {
let colors; let colors;
let log; let log;

View File

@ -1,20 +1,20 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
var colors = require("colors/safe"); const colors = require("colors/safe");
var pkg = require("../package.json"); const pkg = require("../package.json");
var Chan = require("./models/chan"); const Chan = require("./models/chan");
var crypto = require("crypto"); const crypto = require("crypto");
var Msg = require("./models/msg"); const Msg = require("./models/msg");
var Network = require("./models/network"); const Network = require("./models/network");
var ircFramework = require("irc-framework"); const ircFramework = require("irc-framework");
var Helper = require("./helper"); const Helper = require("./helper");
const UAParser = require("ua-parser-js"); const UAParser = require("ua-parser-js");
module.exports = Client; module.exports = Client;
var id = 0; let id = 0;
var events = [ const events = [
"away", "away",
"connection", "connection",
"unhandled", "unhandled",
@ -37,7 +37,7 @@ var events = [
"list", "list",
"whois", "whois",
]; ];
var inputs = [ const inputs = [
"ban", "ban",
"ctcp", "ctcp",
"msg", "msg",
@ -59,8 +59,7 @@ var inputs = [
"list", "list",
"whois", "whois",
].reduce(function(plugins, name) { ].reduce(function(plugins, name) {
var path = "./plugins/inputs/" + name; const plugin = require(`./plugins/inputs/${name}`);
var plugin = require(path);
plugin.commands.forEach((command) => plugins[command] = plugin); plugin.commands.forEach((command) => plugins[command] = plugin);
return plugins; return plugins;
}, {}); }, {});
@ -78,9 +77,9 @@ function Client(manager, name, config = {}) {
manager: manager, manager: manager,
}); });
var client = this; const client = this;
var delay = 0; let delay = 0;
(client.config.networks || []).forEach((n) => { (client.config.networks || []).forEach((n) => {
setTimeout(function() { setTimeout(function() {
client.connect(n); client.connect(n);
@ -114,10 +113,10 @@ Client.prototype.emit = function(event, data) {
}; };
Client.prototype.find = function(channelId) { Client.prototype.find = function(channelId) {
var network = null; let network = null;
var chan = null; let chan = null;
for (var i in this.networks) { for (const i in this.networks) {
var n = this.networks[i]; const n = this.networks[i];
chan = _.find(n.channels, {id: channelId}); chan = _.find(n.channels, {id: channelId});
if (chan) { if (chan) {
network = n; network = n;
@ -135,15 +134,13 @@ Client.prototype.find = function(channelId) {
}; };
Client.prototype.connect = function(args) { Client.prototype.connect = function(args) {
var config = Helper.config; const client = this;
var client = this; const nick = args.nick || "lounge-user";
let webirc = null;
var nick = args.nick || "lounge-user"; let channels = [];
var webirc = null;
var channels = [];
if (args.channels) { if (args.channels) {
var badName = false; let badName = false;
args.channels.forEach((chan) => { args.channels.forEach((chan) => {
if (!chan.name) { if (!chan.name) {
@ -177,8 +174,8 @@ Client.prototype.connect = function(args) {
args.ip = args.ip || (client.config && client.config.ip) || client.ip; args.ip = args.ip || (client.config && client.config.ip) || client.ip;
args.hostname = args.hostname || (client.config && client.config.hostname) || client.hostname; args.hostname = args.hostname || (client.config && client.config.hostname) || client.hostname;
var network = new Network({ const network = new Network({
name: args.name || (config.displayNetwork ? "" : config.defaults.name) || "", name: args.name || (Helper.config.displayNetwork ? "" : Helper.config.defaults.name) || "",
host: args.host || "", host: args.host || "",
port: parseInt(args.port, 10) || (args.tls ? 6697 : 6667), port: parseInt(args.port, 10) || (args.tls ? 6697 : 6667),
tls: !!args.tls, tls: !!args.tls,
@ -197,9 +194,9 @@ Client.prototype.connect = function(args) {
networks: [network.getFilteredClone(this.lastActiveChannel, -1)], networks: [network.getFilteredClone(this.lastActiveChannel, -1)],
}); });
if (config.lockNetwork) { if (Helper.config.lockNetwork) {
// This check is needed to prevent invalid user configurations // This check is needed to prevent invalid user configurations
if (!Helper.config.public && args.host && args.host.length > 0 && args.host !== config.defaults.host) { if (!Helper.config.public && args.host && args.host.length > 0 && args.host !== Helper.config.defaults.host) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "Hostname you specified is not allowed.", text: "Hostname you specified is not allowed.",
@ -207,9 +204,9 @@ Client.prototype.connect = function(args) {
return; return;
} }
network.host = config.defaults.host; network.host = Helper.config.defaults.host;
network.port = config.defaults.port; network.port = Helper.config.defaults.port;
network.tls = config.defaults.tls; network.tls = Helper.config.defaults.tls;
} }
if (network.host.length === 0) { if (network.host.length === 0) {
@ -220,17 +217,17 @@ Client.prototype.connect = function(args) {
return; return;
} }
if (config.webirc && network.host in config.webirc) { if (Helper.config.webirc && network.host in Helper.config.webirc) {
if (!args.hostname) { if (!args.hostname) {
args.hostname = args.ip; args.hostname = args.ip;
} }
if (args.ip) { if (args.ip) {
if (config.webirc[network.host] instanceof Function) { if (Helper.config.webirc[network.host] instanceof Function) {
webirc = config.webirc[network.host](client, args); webirc = Helper.config.webirc[network.host](client, args);
} else { } else {
webirc = { webirc = {
password: config.webirc[network.host], password: Helper.config.webirc[network.host],
username: pkg.name, username: pkg.name,
address: args.ip, address: args.ip,
hostname: args.hostname, hostname: args.hostname,
@ -247,11 +244,11 @@ Client.prototype.connect = function(args) {
host: network.host, host: network.host,
port: network.port, port: network.port,
nick: nick, nick: nick,
username: config.useHexIp ? Helper.ip2hex(args.ip) : network.username, username: Helper.config.useHexIp ? Helper.ip2hex(args.ip) : network.username,
gecos: network.realname, gecos: network.realname,
password: network.password, password: network.password,
tls: network.tls, tls: network.tls,
outgoing_addr: config.bind, outgoing_addr: Helper.config.bind,
rejectUnauthorized: false, rejectUnauthorized: false,
enable_chghost: true, enable_chghost: true,
enable_echomessage: true, enable_echomessage: true,
@ -266,8 +263,7 @@ Client.prototype.connect = function(args) {
]); ]);
events.forEach((plugin) => { events.forEach((plugin) => {
var path = "./plugins/irc-events/" + plugin; require(`./plugins/irc-events/${plugin}`).apply(client, [
require(path).apply(client, [
network.irc, network.irc,
network, network,
]); ]);
@ -319,7 +315,7 @@ Client.prototype.updateSession = function(token, ip, request) {
}; };
Client.prototype.setPassword = function(hash, callback) { Client.prototype.setPassword = function(hash, callback) {
var client = this; const client = this;
client.manager.updateUser(client.name, { client.manager.updateUser(client.name, {
password: hash, password: hash,
@ -334,7 +330,7 @@ Client.prototype.setPassword = function(hash, callback) {
}; };
Client.prototype.input = function(data) { Client.prototype.input = function(data) {
var client = this; const 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);
@ -342,9 +338,8 @@ Client.prototype.input = function(data) {
}; };
Client.prototype.inputLine = function(data) { Client.prototype.inputLine = function(data) {
var client = this; const client = this;
var text = data.text; const target = client.find(data.target);
var target = client.find(data.target);
if (!target) { if (!target) {
return; return;
} }
@ -353,6 +348,8 @@ Client.prototype.inputLine = function(data) {
// so that reloading the page will open this channel // so that reloading the page will open this channel
this.lastActiveChannel = target.chan.id; this.lastActiveChannel = target.chan.id;
let text = data.text;
// This is either a normal message or a command escaped with a leading '/' // This is either a normal message or a command escaped with a leading '/'
if (text.charAt(0) !== "/" || text.charAt(1) === "/") { if (text.charAt(0) !== "/" || text.charAt(1) === "/") {
if (target.chan.type === Chan.Type.LOBBY) { if (target.chan.type === Chan.Type.LOBBY) {
@ -368,14 +365,14 @@ Client.prototype.inputLine = function(data) {
text = text.substr(1); text = text.substr(1);
} }
var args = text.split(" "); const args = text.split(" ");
var cmd = args.shift().toLowerCase(); const cmd = args.shift().toLowerCase();
var irc = target.network.irc; const irc = target.network.irc;
var connected = irc && irc.connection && irc.connection.connected; let connected = irc && irc.connection && irc.connection.connected;
if (cmd in inputs) { if (cmd in inputs) {
var plugin = inputs[cmd]; const plugin = inputs[cmd];
if (connected || plugin.allowDisconnected) { if (connected || plugin.allowDisconnected) {
connected = true; connected = true;
plugin.input.apply(client, [target.network, target.chan, cmd, args]); plugin.input.apply(client, [target.network, target.chan, cmd, args]);
@ -460,8 +457,8 @@ Client.prototype.sort = function(data) {
break; break;
case "channels": case "channels": {
var network = _.find(this.networks, {id: data.target}); const network = _.find(this.networks, {id: data.target});
if (!network) { if (!network) {
return; return;
} }
@ -473,13 +470,14 @@ Client.prototype.sort = function(data) {
break; break;
} }
}
this.save(); this.save();
}; };
Client.prototype.names = function(data) { Client.prototype.names = function(data) {
var client = this; const client = this;
var target = client.find(data.target); const target = client.find(data.target);
if (!target) { if (!target) {
return; return;
} }
@ -518,8 +516,8 @@ Client.prototype.quit = function(signOut) {
}; };
Client.prototype.clientAttach = function(socketId, token) { Client.prototype.clientAttach = function(socketId, token) {
var client = this; const client = this;
var save = false; let save = false;
if (client.awayMessage && _.size(client.attachedClients) === 0) { if (client.awayMessage && _.size(client.attachedClients) === 0) {
client.networks.forEach(function(network) { client.networks.forEach(function(network) {
@ -544,7 +542,7 @@ Client.prototype.clientAttach = function(socketId, token) {
} }
if (!network.hostname) { if (!network.hostname) {
var hostmask = (client.config && client.config.hostname) || client.hostname; const hostmask = (client.config && client.config.hostname) || client.hostname;
if (hostmask) { if (hostmask) {
save = true; save = true;

View File

@ -17,7 +17,7 @@ program
return; return;
} }
var child_spawn = child.spawn( const child_spawn = child.spawn(
process.env.EDITOR || "vi", process.env.EDITOR || "vi",
[Helper.getConfigPath()], [Helper.getConfigPath()],
{stdio: "inherit"} {stdio: "inherit"}

View File

@ -56,7 +56,7 @@ program
}); });
function add(manager, name, password, enableLog) { function add(manager, name, password, enableLog) {
var hash = Helper.password.hash(password); const hash = Helper.password.hash(password);
manager.addUser(name, hash, enableLog); manager.addUser(name, hash, enableLog);
log.info(`User ${colors.bold(name)} created.`); log.info(`User ${colors.bold(name)} created.`);

View File

@ -28,7 +28,7 @@ program
log.error(`User ${colors.bold(name)} does not exist.`); log.error(`User ${colors.bold(name)} does not exist.`);
return; return;
} }
var child_spawn = child.spawn( const child_spawn = child.spawn(
process.env.EDITOR || "vi", process.env.EDITOR || "vi",
[Helper.getUserConfigPath(name)], [Helper.getUserConfigPath(name)],
{stdio: "inherit"} {stdio: "inherit"}

View File

@ -27,8 +27,8 @@ program
log.error(`User ${colors.bold(name)} does not exist.`); log.error(`User ${colors.bold(name)} does not exist.`);
return; return;
} }
var file = Helper.getUserConfigPath(name); const file = Helper.getUserConfigPath(name);
var user = require(file); const user = require(file);
log.prompt({ log.prompt({
text: "Enter new password:", text: "Enter new password:",
silent: true, silent: true,

View File

@ -1,12 +1,12 @@
"use strict"; "use strict";
const pkg = require("../package.json"); const pkg = require("../package.json");
var _ = require("lodash"); const _ = require("lodash");
var path = require("path"); const path = require("path");
var os = require("os"); const os = require("os");
var fs = require("fs"); const fs = require("fs");
var net = require("net"); const net = require("net");
var bcrypt = require("bcryptjs"); const bcrypt = require("bcryptjs");
const colors = require("colors/safe"); const colors = require("colors/safe");
let homePath; let homePath;
@ -148,7 +148,7 @@ function ip2hex(address) {
} }
return address.split(".").map(function(octet) { return address.split(".").map(function(octet) {
var hex = parseInt(octet, 10).toString(16); let hex = parseInt(octet, 10).toString(16);
if (hex.length === 1) { if (hex.length === 1) {
hex = "0" + hex; hex = "0" + hex;

View File

@ -22,12 +22,12 @@ class Identification {
log.warn("Using both identd and oidentd at the same time, this is most likely not intended."); log.warn("Using both identd and oidentd at the same time, this is most likely not intended.");
} }
var server = net.createServer(this.serverConnection.bind(this)); const server = net.createServer(this.serverConnection.bind(this));
server.listen({ server.listen({
port: Helper.config.identd.port || 113, port: Helper.config.identd.port || 113,
host: Helper.config.bind || Helper.config.host, host: Helper.config.bind || Helper.config.host,
}, () => { }, () => {
var address = server.address(); const address = server.address();
log.info(`Identd server available on ${colors.green(address.address + ":" + address.port)}`); log.info(`Identd server available on ${colors.green(address.address + ":" + address.port)}`);
startedCallback(this); startedCallback(this);
@ -54,7 +54,7 @@ class Identification {
return; return;
} }
for (var connection of this.connections.values()) { for (const connection of this.connections.values()) {
if (connection.socket.remoteAddress === socket.remoteAddress if (connection.socket.remoteAddress === socket.remoteAddress
&& connection.socket.remotePort === fport && connection.socket.remotePort === fport
&& connection.socket.localPort === lport && connection.socket.localPort === lport

View File

@ -1,9 +1,9 @@
"use strict"; "use strict";
var colors = require("colors/safe"); const colors = require("colors/safe");
var moment = require("moment"); const moment = require("moment");
const read = require("read"); const read = require("read");
var Helper = require("./helper"); const Helper = require("./helper");
function timestamp() { function timestamp() {
const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss"; const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss";

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
var Helper = require("../helper"); const Helper = require("../helper");
const User = require("./user"); const User = require("./user");
const userLog = require("../userLog"); const userLog = require("../userLog");
const storage = require("../plugins/storage"); const storage = require("../plugins/storage");
@ -43,7 +43,7 @@ Chan.prototype.destroy = function() {
}; };
Chan.prototype.pushMessage = function(client, msg, increasesUnread) { Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
var obj = { const obj = {
chan: this.id, chan: this.id,
msg: msg, msg: msg,
}; };
@ -110,7 +110,7 @@ Chan.prototype.getSortedUsers = function(irc) {
return users; return users;
} }
var userModeSortPriority = {}; const userModeSortPriority = {};
irc.network.options.PREFIX.forEach((prefix, index) => { irc.network.options.PREFIX.forEach((prefix, index) => {
userModeSortPriority[prefix.symbol] = index; userModeSortPriority[prefix.symbol] = index;
}); });

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
var id = 0; let id = 0;
class Msg { class Msg {
constructor(attr) { constructor(attr) {

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
var Chan = require("./chan"); const Chan = require("./chan");
module.exports = Network; module.exports = Network;
@ -98,7 +98,7 @@ Network.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
}; };
Network.prototype.export = function() { Network.prototype.export = function() {
var network = _.pick(this, [ const network = _.pick(this, [
"awayMessage", "awayMessage",
"nick", "nick",
"name", "name",

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
module.exports = User; module.exports = User;

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = ["slap", "me"]; exports.commands = ["slap", "me"];
@ -15,7 +15,7 @@ exports.input = function({irc}, chan, cmd, args) {
return; return;
} }
var text; let text;
switch (cmd) { switch (cmd) {
case "slap": case "slap":

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = [ exports.commands = [
"ban", "ban",

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = ["connect", "server"]; exports.commands = ["connect", "server"];
exports.allowDisconnected = true; exports.allowDisconnected = true;
@ -24,8 +24,8 @@ exports.input = function({irc}, chan, cmd, args) {
return; return;
} }
var port = args[1] || ""; let port = args[1] || "";
var tls = port[0] === "+"; const tls = port[0] === "+";
if (tls) { if (tls) {
port = port.substring(1); port = port.substring(1);

View File

@ -5,7 +5,7 @@ const Helper = require("../../helper");
exports.commands = ["disconnect"]; exports.commands = ["disconnect"];
exports.input = function({irc}, chan, cmd, args) { exports.input = function({irc}, chan, cmd, args) {
var quitMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage; const quitMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
irc.quit(quitMessage); irc.quit(quitMessage);
}; };

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = ["invite"]; exports.commands = ["invite"];

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = ["kick"]; exports.commands = ["kick"];

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = [ exports.commands = [
"mode", "mode",

View File

@ -3,26 +3,25 @@
exports.commands = ["msg", "say"]; exports.commands = ["msg", "say"];
exports.input = function(network, chan, cmd, args) { exports.input = function(network, chan, cmd, args) {
var irc = network.irc; const target = cmd === "msg" ? args.shift() : chan.name;
var target = cmd === "msg" ? args.shift() : chan.name;
if (args.length === 0 || !target) { if (args.length === 0 || !target) {
return true; return true;
} }
var msg = args.join(" "); const msg = args.join(" ");
if (msg.length === 0) { if (msg.length === 0) {
return true; return true;
} }
irc.say(target, msg); network.irc.say(target, msg);
if (!network.irc.network.cap.isEnabled("echo-message")) { if (!network.irc.network.cap.isEnabled("echo-message")) {
var channel = network.getChannel(target); const channel = network.getChannel(target);
if (typeof channel !== "undefined") { if (typeof channel !== "undefined") {
irc.emit("privmsg", { network.irc.emit("privmsg", {
nick: irc.user.nick, nick: network.irc.user.nick,
target: channel.name, target: channel.name,
message: msg, message: msg,
}); });

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = ["nick"]; exports.commands = ["nick"];
exports.allowDisconnected = true; exports.allowDisconnected = true;
@ -22,7 +22,7 @@ exports.input = function(network, chan, cmd, args) {
return; return;
} }
var newNick = args[0]; const newNick = args[0];
// If connected to IRC, send to server and wait for ACK // If connected to IRC, send to server and wait for ACK
// otherwise update the nick and UI straight away // otherwise update the nick and UI straight away

View File

@ -7,19 +7,19 @@ exports.input = function(network, chan, cmd, args) {
return; return;
} }
var message = args.slice(1).join(" "); let targetChan = network.getChannel(args[0]);
var irc = network.irc; let message = args.slice(1).join(" ");
irc.notice(args[0], message);
network.irc.notice(args[0], message);
var targetChan = network.getChannel(args[0]);
if (typeof targetChan === "undefined") { if (typeof targetChan === "undefined") {
message = "{to " + args[0] + "} " + message; message = "{to " + args[0] + "} " + message;
targetChan = chan; targetChan = chan;
} }
if (!network.irc.network.cap.isEnabled("echo-message")) { if (!network.irc.network.cap.isEnabled("echo-message")) {
irc.emit("notice", { network.irc.emit("notice", {
nick: irc.user.nick, nick: network.irc.user.nick,
target: targetChan.name, target: targetChan.name,
message: message, message: message,
}); });

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
const Helper = require("../../helper"); const Helper = require("../../helper");
exports.commands = ["close", "leave", "part"]; exports.commands = ["close", "leave", "part"];

View File

@ -1,13 +1,13 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = ["query"]; exports.commands = ["query"];
exports.input = function(network, chan, cmd, args) { exports.input = function(network, chan, cmd, args) {
var target = args[0]; const target = args[0];
if (args.length === 0 || target.length === 0) { if (args.length === 0 || target.length === 0) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
@ -16,12 +16,12 @@ exports.input = function(network, chan, cmd, args) {
return; return;
} }
var query = _.find(network.channels, {name: target}); const query = _.find(network.channels, {name: target});
if (typeof query !== "undefined") { if (typeof query !== "undefined") {
return; return;
} }
var char = target[0]; const char = target[0];
if (network.irc.network.options.CHANTYPES && network.irc.network.options.CHANTYPES.includes(char)) { if (network.irc.network.options.CHANTYPES && network.irc.network.options.CHANTYPES.includes(char)) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
@ -30,7 +30,7 @@ exports.input = function(network, chan, cmd, args) {
return; return;
} }
for (var i = 0; i < network.irc.network.options.PREFIX.length; i++) { for (let i = 0; i < network.irc.network.options.PREFIX.length; i++) {
if (network.irc.network.options.PREFIX[i].symbol === char) { if (network.irc.network.options.PREFIX[i].symbol === char) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
@ -40,7 +40,7 @@ exports.input = function(network, chan, cmd, args) {
} }
} }
var newChan = new Chan({ const newChan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,
name: target, name: target,
}); });

View File

@ -1,13 +1,13 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
const Helper = require("../../helper"); const Helper = require("../../helper");
exports.commands = ["quit"]; exports.commands = ["quit"];
exports.allowDisconnected = true; exports.allowDisconnected = true;
exports.input = function(network, chan, cmd, args) { exports.input = function(network, chan, cmd, args) {
var client = this; const client = this;
client.networks = _.without(client.networks, network); client.networks = _.without(client.networks, network);
network.destroy(); network.destroy();

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
exports.commands = ["cycle", "rejoin"]; exports.commands = ["cycle", "rejoin"];

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var Chan = require("../../models/chan"); const Chan = require("../../models/chan");
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
exports.commands = ["topic"]; exports.commands = ["topic"];

View File

@ -50,8 +50,8 @@ module.exports = function(client, chan, msg) {
function parse(msg, preview, res, client) { function parse(msg, preview, res, client) {
switch (res.type) { switch (res.type) {
case "text/html": case "text/html": {
var $ = cheerio.load(res.data); const $ = cheerio.load(res.data);
preview.type = "link"; preview.type = "link";
preview.head = preview.head =
$('meta[property="og:title"]').attr("content") $('meta[property="og:title"]').attr("content")
@ -92,6 +92,7 @@ function parse(msg, preview, res, client) {
} }
break; break;
}
case "image/png": case "image/png":
case "image/gif": case "image/gif":

View File

@ -1,16 +1,16 @@
"use strict"; "use strict";
var _ = require("lodash"); const _ = require("lodash");
var pkg = require("../package.json"); const pkg = require("../package.json");
var Client = require("./client"); const Client = require("./client");
var ClientManager = require("./clientManager"); const ClientManager = require("./clientManager");
var express = require("express"); const express = require("express");
var fs = require("fs"); const fs = require("fs");
var path = require("path"); const path = require("path");
var io = require("socket.io"); const io = require("socket.io");
var dns = require("dns"); const dns = require("dns");
var Helper = require("./helper"); const Helper = require("./helper");
var colors = require("colors/safe"); const colors = require("colors/safe");
const net = require("net"); const net = require("net");
const Identification = require("./identification"); const Identification = require("./identification");
const changelog = require("./plugins/changelog"); const changelog = require("./plugins/changelog");
@ -31,14 +31,14 @@ const authPlugins = [
// A random number that will force clients to reload the page if it differs // A random number that will force clients to reload the page if it differs
const serverHash = Math.floor(Date.now() * Math.random()); const serverHash = Math.floor(Date.now() * Math.random());
var manager = null; let manager = null;
module.exports = function() { module.exports = function() {
log.info(`The Lounge ${colors.green(Helper.getVersion())} \ log.info(`The Lounge ${colors.green(Helper.getVersion())} \
(Node.js ${colors.green(process.versions.node)} on ${colors.green(process.platform)} ${process.arch})`); (Node.js ${colors.green(process.versions.node)} on ${colors.green(process.platform)} ${process.arch})`);
log.info(`Configuration file: ${colors.green(Helper.getConfigPath())}`); log.info(`Configuration file: ${colors.green(Helper.getConfigPath())}`);
var app = express() const app = express()
.disable("x-powered-by") .disable("x-powered-by")
.use(allRequests) .use(allRequests)
.use(index) .use(index)
@ -72,20 +72,19 @@ module.exports = function() {
return res.sendFile(path.join(packagePath, fileName)); return res.sendFile(path.join(packagePath, fileName));
}); });
var config = Helper.config; let server = null;
var server = null;
if (config.public && (config.ldap || {}).enable) { if (Helper.config.public && (Helper.config.ldap || {}).enable) {
log.warn("Server is public and set to use LDAP. Set to private mode if trying to use LDAP authentication."); log.warn("Server is public and set to use LDAP. Set to private mode if trying to use LDAP authentication.");
} }
if (!config.https.enable) { if (!Helper.config.https.enable) {
server = require("http"); server = require("http");
server = server.createServer(app); server = server.createServer(app);
} else { } else {
const keyPath = Helper.expandHome(config.https.key); const keyPath = Helper.expandHome(Helper.config.https.key);
const certPath = Helper.expandHome(config.https.certificate); const certPath = Helper.expandHome(Helper.config.https.certificate);
const caPath = Helper.expandHome(config.https.ca); const caPath = Helper.expandHome(Helper.config.https.ca);
if (!keyPath.length || !fs.existsSync(keyPath)) { if (!keyPath.length || !fs.existsSync(keyPath)) {
log.error("Path to SSL key is invalid. Stopping server..."); log.error("Path to SSL key is invalid. Stopping server...");
@ -112,12 +111,12 @@ module.exports = function() {
let listenParams; let listenParams;
if (typeof config.host === "string" && config.host.startsWith("unix:")) { if (typeof Helper.config.host === "string" && Helper.config.host.startsWith("unix:")) {
listenParams = config.host.replace(/^unix:/, ""); listenParams = Helper.config.host.replace(/^unix:/, "");
} else { } else {
listenParams = { listenParams = {
port: config.port, port: Helper.config.port,
host: config.host, host: Helper.config.host,
}; };
} }
@ -127,23 +126,23 @@ module.exports = function() {
if (typeof listenParams === "string") { if (typeof listenParams === "string") {
log.info("Available on socket " + colors.green(listenParams)); log.info("Available on socket " + colors.green(listenParams));
} else { } else {
const protocol = config.https.enable ? "https" : "http"; const protocol = Helper.config.https.enable ? "https" : "http";
const address = server.address(); const address = server.address();
log.info( log.info(
"Available at " + "Available at " +
colors.green(`${protocol}://${address.address}:${address.port}/`) + colors.green(`${protocol}://${address.address}:${address.port}/`) +
` in ${colors.bold(config.public ? "public" : "private")} mode` ` in ${colors.bold(Helper.config.public ? "public" : "private")} mode`
); );
} }
const sockets = io(server, { const sockets = io(server, {
serveClient: false, serveClient: false,
transports: config.transports, transports: Helper.config.transports,
}); });
sockets.on("connect", (socket) => { sockets.on("connect", (socket) => {
if (config.public) { if (Helper.config.public) {
performAuthentication.call(socket, {}); performAuthentication.call(socket, {});
} else { } else {
socket.emit("auth", { socket.emit("auth", {
@ -302,9 +301,9 @@ function initializeClient(socket, client, token, lastMessage) {
socket.on( socket.on(
"change-password", "change-password",
function(data) { function(data) {
var old = data.old_password; const old = data.old_password;
var p1 = data.new_password; const p1 = data.new_password;
var p2 = data.verify_password; const p2 = data.verify_password;
if (typeof p1 === "undefined" || p1 === "") { if (typeof p1 === "undefined" || p1 === "") {
socket.emit("change-password", { socket.emit("change-password", {
error: "Please enter a new password", error: "Please enter a new password",

View File

@ -1,9 +1,9 @@
"use strict"; "use strict";
var fs = require("fs"); const fs = require("fs");
var fsextra = require("fs-extra"); const fsextra = require("fs-extra");
var moment = require("moment"); const moment = require("moment");
var Helper = require("./helper"); const Helper = require("./helper");
module.exports.write = function(user, network, chan, msg) { module.exports.write = function(user, network, chan, msg) {
const path = Helper.getUserLogsPath(user, network); const path = Helper.getUserLogsPath(user, network);
@ -15,13 +15,13 @@ module.exports.write = function(user, network, chan, msg) {
return; return;
} }
var format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss"; const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss";
var tz = Helper.config.logs.timezone || "UTC+00:00"; const tz = Helper.config.logs.timezone || "UTC+00:00";
var time = moment(msg.time).utcOffset(tz).format(format); const time = moment(msg.time).utcOffset(tz).format(format);
var line = `[${time}] `; let line = `[${time}] `;
var type = msg.type.trim(); const type = msg.type.trim();
if (type === "message" || type === "highlight") { if (type === "message" || type === "highlight") {
// Format: // Format:
// [2014-01-01 00:00:00] <Arnold> Put that cookie down.. Now!! // [2014-01-01 00:00:00] <Arnold> Put that cookie down.. Now!!

View File

@ -1,9 +1,9 @@
"use strict"; "use strict";
var expect = require("chai").expect; const expect = require("chai").expect;
var Chan = require("../../src/models/chan"); const Chan = require("../../src/models/chan");
var ModeCommand = require("../../src/plugins/inputs/mode"); const ModeCommand = require("../../src/plugins/inputs/mode");
describe("Commands", function() { describe("Commands", function() {
describe("/mode", function() { describe("/mode", function() {

View File

@ -2,5 +2,5 @@
global.log = require("../../src/log.js"); global.log = require("../../src/log.js");
var home = require("path").join(__dirname, ".lounge"); const home = require("path").join(__dirname, ".lounge");
require("../../src/helper").setHome(home); require("../../src/helper").setHome(home);

View File

@ -82,7 +82,7 @@ describe("Chan", function() {
}); });
describe("#getSortedUsers(irc)", function() { describe("#getSortedUsers(irc)", function() {
var getUserNames = function(chan) { const getUserNames = function(chan) {
return chan.getSortedUsers(network).map((u) => u.nick); return chan.getSortedUsers(network).map((u) => u.nick);
}; };

View File

@ -9,7 +9,7 @@ const Network = require("../../src/models/network");
describe("Network", function() { describe("Network", function() {
describe("#export()", function() { describe("#export()", function() {
it("should produce an valid object", function() { it("should produce an valid object", function() {
var network = new Network({ const network = new Network({
awayMessage: "I am away", awayMessage: "I am away",
name: "networkName", name: "networkName",
channels: [ channels: [
@ -47,7 +47,7 @@ describe("Network", function() {
}); });
it("lobby should be at the top", function() { it("lobby should be at the top", function() {
var network = new Network({ const network = new Network({
name: "Super Nice Network", name: "Super Nice Network",
channels: [ channels: [
new Chan({name: "AAAA!", type: Chan.Type.QUERY}), new Chan({name: "AAAA!", type: Chan.Type.QUERY}),
@ -62,7 +62,7 @@ describe("Network", function() {
}); });
it("should maintain channel reference", function() { it("should maintain channel reference", function() {
var chan = new Chan({ const chan = new Chan({
name: "#506-bug-fix", name: "#506-bug-fix",
messages: [ messages: [
new Msg({ new Msg({
@ -71,7 +71,7 @@ describe("Network", function() {
], ],
}); });
var network = new Network({ const network = new Network({
name: "networkName", name: "networkName",
channels: [ channels: [
chan, chan,

View File

@ -1,10 +1,10 @@
"use strict"; "use strict";
var expect = require("chai").expect; const expect = require("chai").expect;
var Network = require("../../src/models/network"); const Network = require("../../src/models/network");
var network = new Network({name: "networkName"}); const network = new Network({name: "networkName"});
describe("Nickname highlights", function() { describe("Nickname highlights", function() {
it("should NOT highlight nickname", function() { it("should NOT highlight nickname", function() {

View File

@ -1,11 +1,11 @@
"use strict"; "use strict";
var EventEmitter = require("events").EventEmitter; const EventEmitter = require("events").EventEmitter;
var util = require("util"); const util = require("util");
var _ = require("lodash"); const _ = require("lodash");
var express = require("express"); const express = require("express");
var Network = require("../src/models/network"); const Network = require("../src/models/network");
var Chan = require("../src/models/chan"); const Chan = require("../src/models/chan");
function MockClient() { function MockClient() {
this.user = {nick: "test-user"}; this.user = {nick: "test-user"};
@ -13,7 +13,7 @@ function MockClient() {
util.inherits(MockClient, EventEmitter); util.inherits(MockClient, EventEmitter);
MockClient.prototype.createMessage = function(opts) { MockClient.prototype.createMessage = function(opts) {
var message = _.extend({ const message = _.extend({
text: "dummy message", text: "dummy message",
nick: "test-user", nick: "test-user",
target: "#test-channel", target: "#test-channel",