From a3e448acf52537a38f3d735d3553fed6ea3a3322 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 11 Jan 2018 13:33:36 +0200 Subject: [PATCH] Enable no-var rule Fixes #1961 --- .eslintrc.yml | 1 + client/js/libs/handlebars/colorClass.js | 4 +- client/js/libs/handlebars/diff.js | 2 +- client/js/libs/handlebars/modes.js | 19 ++-- client/js/libs/slideout.js | 22 ++--- client/js/loading-error-handlers.js | 2 +- client/js/lounge.js | 71 +++++++-------- client/js/options.js | 5 +- client/js/render.js | 2 +- client/js/socket-events/msg.js | 2 +- client/js/utils.js | 6 +- index.js | 2 +- src/client.js | 116 ++++++++++++------------ src/command-line/config.js | 2 +- src/command-line/users/add.js | 2 +- src/command-line/users/edit.js | 2 +- src/command-line/users/reset.js | 4 +- src/helper.js | 14 +-- src/identification.js | 6 +- src/log.js | 6 +- src/models/chan.js | 8 +- src/models/msg.js | 4 +- src/models/network.js | 6 +- src/models/user.js | 2 +- src/plugins/inputs/action.js | 6 +- src/plugins/inputs/ban.js | 4 +- src/plugins/inputs/connect.js | 6 +- src/plugins/inputs/disconnect.js | 2 +- src/plugins/inputs/invite.js | 4 +- src/plugins/inputs/kick.js | 4 +- src/plugins/inputs/mode.js | 4 +- src/plugins/inputs/msg.js | 13 ++- src/plugins/inputs/nick.js | 4 +- src/plugins/inputs/notice.js | 12 +-- src/plugins/inputs/part.js | 6 +- src/plugins/inputs/query.js | 16 ++-- src/plugins/inputs/quit.js | 4 +- src/plugins/inputs/rejoin.js | 4 +- src/plugins/inputs/topic.js | 4 +- src/plugins/irc-events/link.js | 5 +- src/server.js | 61 ++++++------- src/userLog.js | 18 ++-- test/commands/mode.js | 6 +- test/fixtures/env.js | 2 +- test/models/chan.js | 2 +- test/models/network.js | 8 +- test/tests/nickhighlights.js | 6 +- test/util.js | 14 +-- 48 files changed, 260 insertions(+), 265 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index e3cf6e84..181bc3a2 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -45,6 +45,7 @@ rules: no-useless-constructor: error no-useless-return: error no-use-before-define: [error, {functions: false}] + no-var: error object-curly-spacing: [error, never] padded-blocks: [error, never] prefer-const: error diff --git a/client/js/libs/handlebars/colorClass.js b/client/js/libs/handlebars/colorClass.js index e7b8d8e4..2780f3f2 100644 --- a/client/js/libs/handlebars/colorClass.js +++ b/client/js/libs/handlebars/colorClass.js @@ -2,8 +2,8 @@ // Generates a string from "color-1" to "color-32" based on an input string module.exports = function(str) { - var hash = 0; - for (var i = 0; i < str.length; i++) { + let hash = 0; + for (let i = 0; i < str.length; i++) { hash += str.charCodeAt(i); } diff --git a/client/js/libs/handlebars/diff.js b/client/js/libs/handlebars/diff.js index 198c8882..fe463895 100644 --- a/client/js/libs/handlebars/diff.js +++ b/client/js/libs/handlebars/diff.js @@ -1,6 +1,6 @@ "use strict"; -var diff; +let diff; module.exports = function(a, opt) { if (a !== diff) { diff --git a/client/js/libs/handlebars/modes.js b/client/js/libs/handlebars/modes.js index f7d0c786..271361f3 100644 --- a/client/js/libs/handlebars/modes.js +++ b/client/js/libs/handlebars/modes.js @@ -1,14 +1,15 @@ "use strict"; +const modes = { + "~": "owner", + "&": "admin", + "!": "admin", + "@": "op", + "%": "half-op", + "+": "voice", + "": "normal", +}; + module.exports = function(mode) { - var modes = { - "~": "owner", - "&": "admin", - "!": "admin", - "@": "op", - "%": "half-op", - "+": "voice", - "": "normal", - }; return modes[mode]; }; diff --git a/client/js/libs/slideout.js b/client/js/libs/slideout.js index 55bb0387..5d833b5d 100644 --- a/client/js/libs/slideout.js +++ b/client/js/libs/slideout.js @@ -4,12 +4,12 @@ * Simple slideout menu implementation. */ module.exports = function slideoutMenu(viewport, menu) { - var touchStartPos = null; - var touchCurPos = null; - var touchStartTime = 0; - var menuWidth = 0; - var menuIsOpen = false; - var menuIsMoving = false; + let touchStartPos = null; + let touchCurPos = null; + let touchStartTime = 0; + let menuWidth = 0; + let menuIsOpen = false; + let menuIsMoving = false; function toggleMenu(state) { menuIsOpen = state; @@ -26,7 +26,7 @@ module.exports = function slideoutMenu(viewport, menu) { return; } - var touch = e.touches.item(0); + const touch = e.touches.item(0); viewport.classList.toggle("menu-dragging", true); menuWidth = parseFloat(window.getComputedStyle(menu).width); @@ -42,8 +42,8 @@ module.exports = function slideoutMenu(viewport, menu) { } function onTouchMove(e) { - var touch = touchCurPos = e.touches.item(0); - var setX = touch.screenX - touchStartPos.screenX; + const touch = touchCurPos = e.touches.item(0); + let setX = touch.screenX - touchStartPos.screenX; if (Math.abs(setX > 30)) { menuIsMoving = true; @@ -73,8 +73,8 @@ module.exports = function slideoutMenu(viewport, menu) { } function onTouchEnd() { - var diff = touchCurPos.screenX - touchStartPos.screenX; - var absDiff = Math.abs(diff); + const diff = touchCurPos.screenX - touchStartPos.screenX; + const absDiff = Math.abs(diff); if (absDiff > menuWidth / 2 || Date.now() - touchStartTime < 180 && absDiff > 50) { toggleMenu(diff > 0); diff --git a/client/js/loading-error-handlers.js b/client/js/loading-error-handlers.js index fe774b01..18e69182 100644 --- a/client/js/loading-error-handlers.js +++ b/client/js/loading-error-handlers.js @@ -1,4 +1,4 @@ -/* eslint strict: 0 */ +/* eslint strict: 0, no-var: 0 */ "use strict"; /* diff --git a/client/js/lounge.js b/client/js/lounge.js index fd870d74..954cf0dd 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -24,15 +24,15 @@ const Changelog = require("./socket-events/changelog"); const JoinChannel = require("./join-channel"); $(function() { - var sidebar = $("#sidebar, #footer"); - var chat = $("#chat"); + const sidebar = $("#sidebar, #footer"); + const chat = $("#chat"); $(document.body).data("app-name", document.title); - var viewport = $("#viewport"); - var sidebarSlide = slideoutMenu(viewport[0], sidebar[0]); - var contextMenuContainer = $("#context-menu-container"); - var contextMenu = $("#context-menu"); + const viewport = $("#viewport"); + const sidebarSlide = slideoutMenu(viewport[0], sidebar[0]); + const contextMenuContainer = $("#context-menu-container"); + const contextMenu = $("#context-menu"); $("#main").on("click", function(e) { if ($(e.target).is(".lt")) { @@ -43,16 +43,16 @@ $(function() { }); viewport.on("click", ".rt", function(e) { - var self = $(this); + const self = $(this); viewport.toggleClass(self.prop("class")); e.stopPropagation(); chat.find(".chan.active .chat").trigger("msg.sticky"); }); function positionContextMenu(that, e) { - var offset; - var menuWidth = contextMenu.outerWidth(); - var menuHeight = contextMenu.outerHeight(); + let offset; + const menuWidth = contextMenu.outerWidth(); + const menuHeight = contextMenu.outerHeight(); if (that.hasClass("menu")) { offset = that.offset(); @@ -75,8 +75,8 @@ $(function() { } function showContextMenu(that, e) { - var target = $(e.currentTarget); - var output = ""; + const target = $(e.currentTarget); + let output = ""; if (target.hasClass("user")) { output = templates.contextmenu_item({ @@ -193,10 +193,10 @@ $(function() { input.style.height = input.style.minHeight; } - var input = $("#input") + const input = $("#input") .history() .on("input", function() { - var style = window.getComputedStyle(this); + const style = window.getComputedStyle(this); // Start by resetting height before computing as scrollHeight does not // decrease when deleting characters @@ -212,7 +212,7 @@ $(function() { chat.find(".chan.active .chat").trigger("msg.sticky"); // fix growing }); - var focus = $.noop; + let focus = $.noop; if (!("ontouchstart" in window || navigator.maxTouchPoints > 0)) { focus = function() { if (chat.find(".active").hasClass("chan")) { @@ -238,7 +238,7 @@ $(function() { $("#form").on("submit", function(e) { e.preventDefault(); utils.forceFocus(); - var text = input.val(); + const text = input.val(); if (text.length === 0) { return; @@ -265,11 +265,11 @@ $(function() { utils.toggleNickEditor(true); // Selects existing nick in the editable text field - var element = document.querySelector("#nick-value"); + const element = document.querySelector("#nick-value"); element.focus(); - var range = document.createRange(); + const range = document.createRange(); range.selectNodeContents(element); - var selection = window.getSelection(); + const selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range); }); @@ -278,7 +278,7 @@ $(function() { $("button#submit-nick").on("click", submitNick); function submitNick() { - var newNick = $("#nick-value").text().trim(); + const newNick = $("#nick-value").text().trim(); if (newNick.length === 0) { cancelNick(); @@ -316,8 +316,8 @@ $(function() { }); chat.on("click", ".inline-channel", function() { - var name = $(this).data("chan"); - var chan = utils.findCurrentNetworkChan(name); + const name = $(this).data("chan"); + const chan = utils.findCurrentNetworkChan(name); if (chan.length) { chan.trigger("click"); @@ -334,8 +334,8 @@ $(function() { }); const openWindow = function openWindow(e, data) { - var self = $(this); - var target = self.data("target"); + const self = $(this); + const target = self.data("target"); if (!target) { return; } @@ -372,9 +372,7 @@ $(function() { sidebarSlide.toggle(false); } - var lastActive = $("#windows > .active"); - - lastActive + const lastActive = $("#windows > .active") .removeClass("active") .find(".chat") .unsticky(); @@ -391,7 +389,7 @@ $(function() { render.trimMessageInChannel(lastActiveChan, 100); } - var chan = $(target) + const chan = $(target) .addClass("active") .trigger("show"); @@ -403,7 +401,7 @@ $(function() { document.title = title; const type = chan.data("type"); - var placeholder = ""; + let placeholder = ""; if (type === "channel" || type === "query") { placeholder = `Write to ${chanTitle}`; } @@ -417,7 +415,7 @@ $(function() { utils.setNick(self.closest(".network").data("nick")); } - var chanChat = chan.find(".chat"); + const chanChat = chan.find(".chat"); if (chanChat.length > 0 && type !== "special") { chanChat.sticky(); } @@ -481,11 +479,11 @@ $(function() { }); function closeChan(chan) { - var cmd = "/close"; + let cmd = "/close"; if (chan.hasClass("lobby")) { cmd = "/quit"; - var server = chan.find(".name").html(); + const server = chan.find(".name").html(); if (!confirm("Disconnect from " + server + "?")) { // eslint-disable-line no-alert return false; } @@ -601,17 +599,16 @@ $(function() { if ($("body").hasClass("public") && (window.location.hash === "#connect" || window.location.hash === "")) { $("#connect").one("show", function() { - var params = URI(document.location.search); - params = params.search(true); + const params = URI(document.location.search).search(true); // 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 - for (var key in params) { + for (let key in params) { if (params.hasOwnProperty(key)) { - var value = params[key]; + const value = params[key]; // \W searches for non-word characters 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 (element.length > 0 && !element.is(":disabled") && !element.is(":hidden")) { if (element.is(":checkbox")) { diff --git a/client/js/options.js b/client/js/options.js index 7c61df88..5444f416 100644 --- a/client/js/options.js +++ b/client/js/options.js @@ -57,7 +57,7 @@ module.exports.initialize = () => { const settings = $("#settings"); - for (var i in options) { + for (const i in options) { if (i === "userStyles") { settings.find("#user-specified-css-input").val(options[i]); } else if (i === "highlights") { @@ -139,8 +139,7 @@ module.exports.initialize = () => { } else if (name === "userStyles") { userStyles.html(options[name]); } else if (name === "highlights") { - var highlightString = options[name]; - options.highlights = highlightString.split(",").map(function(h) { + options.highlights = options[name].split(",").map(function(h) { return h.trim(); }).filter(function(h) { // Ensure we don't have empty string in the list of highlights diff --git a/client/js/render.js b/client/js/render.js index bf5d2e36..28920fb1 100644 --- a/client/js/render.js +++ b/client/js/render.js @@ -276,7 +276,7 @@ function loadMoreHistory(entries) { return; } - var target = $(entry.target).find(".show-more-button"); + const target = $(entry.target).find(".show-more-button"); if (target.prop("disabled")) { return; diff --git a/client/js/socket-events/msg.js b/client/js/socket-events/msg.js index 925b15b7..98aa8800 100644 --- a/client/js/socket-events/msg.js +++ b/client/js/socket-events/msg.js @@ -68,7 +68,7 @@ function processReceivedMessage(data) { notifyMessage(targetId, channel, data); - var lastVisible = container.find("div:visible").last(); + const lastVisible = container.find("div:visible").last(); if (data.msg.self || lastVisible.hasClass("unread-marker") || (lastVisible.hasClass("date-marker") diff --git a/client/js/utils.js b/client/js/utils.js index a3ff9835..9fdaaede 100644 --- a/client/js/utils.js +++ b/client/js/utils.js @@ -4,8 +4,8 @@ const $ = require("jquery"); const escape = require("css.escape"); const input = $("#input"); -var serverHash = -1; -var lastMessageId = -1; +var serverHash = -1; // eslint-disable-line no-var +var lastMessageId = -1; // eslint-disable-line no-var module.exports = { inputCommands: {collapse, expand, join}, @@ -92,7 +92,7 @@ const favicon = $("#favicon"); function toggleNotificationMarkers(newState) { // Toggles the favicon to red when there are unread notifications if (favicon.data("toggled") !== newState) { - var old = favicon.prop("href"); + const old = favicon.prop("href"); favicon.prop("href", favicon.data("other")); favicon.data("other", old); favicon.data("toggled", newState); diff --git a/index.js b/index.js index 0834b105..da973d69 100755 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ process.chdir(__dirname); // Doing this check as soon as possible allows us to avoid ES6 parser errors or // other issues // 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)) { let colors; let log; diff --git a/src/client.js b/src/client.js index 87571ab6..668ec677 100644 --- a/src/client.js +++ b/src/client.js @@ -1,20 +1,20 @@ "use strict"; -var _ = require("lodash"); -var colors = require("colors/safe"); -var pkg = require("../package.json"); -var Chan = require("./models/chan"); -var crypto = require("crypto"); -var Msg = require("./models/msg"); -var Network = require("./models/network"); -var ircFramework = require("irc-framework"); -var Helper = require("./helper"); +const _ = require("lodash"); +const colors = require("colors/safe"); +const pkg = require("../package.json"); +const Chan = require("./models/chan"); +const crypto = require("crypto"); +const Msg = require("./models/msg"); +const Network = require("./models/network"); +const ircFramework = require("irc-framework"); +const Helper = require("./helper"); const UAParser = require("ua-parser-js"); module.exports = Client; -var id = 0; -var events = [ +let id = 0; +const events = [ "away", "connection", "unhandled", @@ -37,7 +37,7 @@ var events = [ "list", "whois", ]; -var inputs = [ +const inputs = [ "ban", "ctcp", "msg", @@ -59,8 +59,7 @@ var inputs = [ "list", "whois", ].reduce(function(plugins, name) { - var path = "./plugins/inputs/" + name; - var plugin = require(path); + const plugin = require(`./plugins/inputs/${name}`); plugin.commands.forEach((command) => plugins[command] = plugin); return plugins; }, {}); @@ -78,9 +77,9 @@ function Client(manager, name, config = {}) { manager: manager, }); - var client = this; + const client = this; - var delay = 0; + let delay = 0; (client.config.networks || []).forEach((n) => { setTimeout(function() { client.connect(n); @@ -114,10 +113,10 @@ Client.prototype.emit = function(event, data) { }; Client.prototype.find = function(channelId) { - var network = null; - var chan = null; - for (var i in this.networks) { - var n = this.networks[i]; + let network = null; + let chan = null; + for (const i in this.networks) { + const n = this.networks[i]; chan = _.find(n.channels, {id: channelId}); if (chan) { network = n; @@ -135,15 +134,13 @@ Client.prototype.find = function(channelId) { }; Client.prototype.connect = function(args) { - var config = Helper.config; - var client = this; - - var nick = args.nick || "lounge-user"; - var webirc = null; - var channels = []; + const client = this; + const nick = args.nick || "lounge-user"; + let webirc = null; + let channels = []; if (args.channels) { - var badName = false; + let badName = false; args.channels.forEach((chan) => { if (!chan.name) { @@ -177,8 +174,8 @@ Client.prototype.connect = function(args) { args.ip = args.ip || (client.config && client.config.ip) || client.ip; args.hostname = args.hostname || (client.config && client.config.hostname) || client.hostname; - var network = new Network({ - name: args.name || (config.displayNetwork ? "" : config.defaults.name) || "", + const network = new Network({ + name: args.name || (Helper.config.displayNetwork ? "" : Helper.config.defaults.name) || "", host: args.host || "", port: parseInt(args.port, 10) || (args.tls ? 6697 : 6667), tls: !!args.tls, @@ -197,9 +194,9 @@ Client.prototype.connect = function(args) { networks: [network.getFilteredClone(this.lastActiveChannel, -1)], }); - if (config.lockNetwork) { + if (Helper.config.lockNetwork) { // 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({ type: Msg.Type.ERROR, text: "Hostname you specified is not allowed.", @@ -207,9 +204,9 @@ Client.prototype.connect = function(args) { return; } - network.host = config.defaults.host; - network.port = config.defaults.port; - network.tls = config.defaults.tls; + network.host = Helper.config.defaults.host; + network.port = Helper.config.defaults.port; + network.tls = Helper.config.defaults.tls; } if (network.host.length === 0) { @@ -220,17 +217,17 @@ Client.prototype.connect = function(args) { return; } - if (config.webirc && network.host in config.webirc) { + if (Helper.config.webirc && network.host in Helper.config.webirc) { if (!args.hostname) { args.hostname = args.ip; } if (args.ip) { - if (config.webirc[network.host] instanceof Function) { - webirc = config.webirc[network.host](client, args); + if (Helper.config.webirc[network.host] instanceof Function) { + webirc = Helper.config.webirc[network.host](client, args); } else { webirc = { - password: config.webirc[network.host], + password: Helper.config.webirc[network.host], username: pkg.name, address: args.ip, hostname: args.hostname, @@ -247,11 +244,11 @@ Client.prototype.connect = function(args) { host: network.host, port: network.port, nick: nick, - username: config.useHexIp ? Helper.ip2hex(args.ip) : network.username, + username: Helper.config.useHexIp ? Helper.ip2hex(args.ip) : network.username, gecos: network.realname, password: network.password, tls: network.tls, - outgoing_addr: config.bind, + outgoing_addr: Helper.config.bind, rejectUnauthorized: false, enable_chghost: true, enable_echomessage: true, @@ -266,8 +263,7 @@ Client.prototype.connect = function(args) { ]); events.forEach((plugin) => { - var path = "./plugins/irc-events/" + plugin; - require(path).apply(client, [ + require(`./plugins/irc-events/${plugin}`).apply(client, [ network.irc, network, ]); @@ -319,7 +315,7 @@ Client.prototype.updateSession = function(token, ip, request) { }; Client.prototype.setPassword = function(hash, callback) { - var client = this; + const client = this; client.manager.updateUser(client.name, { password: hash, @@ -334,7 +330,7 @@ Client.prototype.setPassword = function(hash, callback) { }; Client.prototype.input = function(data) { - var client = this; + const client = this; data.text.split("\n").forEach((line) => { data.text = line; client.inputLine(data); @@ -342,9 +338,8 @@ Client.prototype.input = function(data) { }; Client.prototype.inputLine = function(data) { - var client = this; - var text = data.text; - var target = client.find(data.target); + const client = this; + const target = client.find(data.target); if (!target) { return; } @@ -353,6 +348,8 @@ Client.prototype.inputLine = function(data) { // so that reloading the page will open this channel this.lastActiveChannel = target.chan.id; + let text = data.text; + // This is either a normal message or a command escaped with a leading '/' if (text.charAt(0) !== "/" || text.charAt(1) === "/") { if (target.chan.type === Chan.Type.LOBBY) { @@ -368,14 +365,14 @@ Client.prototype.inputLine = function(data) { text = text.substr(1); } - var args = text.split(" "); - var cmd = args.shift().toLowerCase(); + const args = text.split(" "); + const cmd = args.shift().toLowerCase(); - var irc = target.network.irc; - var connected = irc && irc.connection && irc.connection.connected; + const irc = target.network.irc; + let connected = irc && irc.connection && irc.connection.connected; if (cmd in inputs) { - var plugin = inputs[cmd]; + const plugin = inputs[cmd]; if (connected || plugin.allowDisconnected) { connected = true; plugin.input.apply(client, [target.network, target.chan, cmd, args]); @@ -460,8 +457,8 @@ Client.prototype.sort = function(data) { break; - case "channels": - var network = _.find(this.networks, {id: data.target}); + case "channels": { + const network = _.find(this.networks, {id: data.target}); if (!network) { return; } @@ -473,13 +470,14 @@ Client.prototype.sort = function(data) { break; } + } this.save(); }; Client.prototype.names = function(data) { - var client = this; - var target = client.find(data.target); + const client = this; + const target = client.find(data.target); if (!target) { return; } @@ -518,8 +516,8 @@ Client.prototype.quit = function(signOut) { }; Client.prototype.clientAttach = function(socketId, token) { - var client = this; - var save = false; + const client = this; + let save = false; if (client.awayMessage && _.size(client.attachedClients) === 0) { client.networks.forEach(function(network) { @@ -544,7 +542,7 @@ Client.prototype.clientAttach = function(socketId, token) { } if (!network.hostname) { - var hostmask = (client.config && client.config.hostname) || client.hostname; + const hostmask = (client.config && client.config.hostname) || client.hostname; if (hostmask) { save = true; diff --git a/src/command-line/config.js b/src/command-line/config.js index 5c4c391f..37cebb00 100644 --- a/src/command-line/config.js +++ b/src/command-line/config.js @@ -17,7 +17,7 @@ program return; } - var child_spawn = child.spawn( + const child_spawn = child.spawn( process.env.EDITOR || "vi", [Helper.getConfigPath()], {stdio: "inherit"} diff --git a/src/command-line/users/add.js b/src/command-line/users/add.js index 0a5b530f..f22e2285 100644 --- a/src/command-line/users/add.js +++ b/src/command-line/users/add.js @@ -56,7 +56,7 @@ program }); function add(manager, name, password, enableLog) { - var hash = Helper.password.hash(password); + const hash = Helper.password.hash(password); manager.addUser(name, hash, enableLog); log.info(`User ${colors.bold(name)} created.`); diff --git a/src/command-line/users/edit.js b/src/command-line/users/edit.js index 468cbc4e..c3a89819 100644 --- a/src/command-line/users/edit.js +++ b/src/command-line/users/edit.js @@ -28,7 +28,7 @@ program log.error(`User ${colors.bold(name)} does not exist.`); return; } - var child_spawn = child.spawn( + const child_spawn = child.spawn( process.env.EDITOR || "vi", [Helper.getUserConfigPath(name)], {stdio: "inherit"} diff --git a/src/command-line/users/reset.js b/src/command-line/users/reset.js index a0318c67..605f04db 100644 --- a/src/command-line/users/reset.js +++ b/src/command-line/users/reset.js @@ -27,8 +27,8 @@ program log.error(`User ${colors.bold(name)} does not exist.`); return; } - var file = Helper.getUserConfigPath(name); - var user = require(file); + const file = Helper.getUserConfigPath(name); + const user = require(file); log.prompt({ text: "Enter new password:", silent: true, diff --git a/src/helper.js b/src/helper.js index 6b6c2e9a..23398535 100644 --- a/src/helper.js +++ b/src/helper.js @@ -1,12 +1,12 @@ "use strict"; const pkg = require("../package.json"); -var _ = require("lodash"); -var path = require("path"); -var os = require("os"); -var fs = require("fs"); -var net = require("net"); -var bcrypt = require("bcryptjs"); +const _ = require("lodash"); +const path = require("path"); +const os = require("os"); +const fs = require("fs"); +const net = require("net"); +const bcrypt = require("bcryptjs"); const colors = require("colors/safe"); let homePath; @@ -148,7 +148,7 @@ function ip2hex(address) { } return address.split(".").map(function(octet) { - var hex = parseInt(octet, 10).toString(16); + let hex = parseInt(octet, 10).toString(16); if (hex.length === 1) { hex = "0" + hex; diff --git a/src/identification.js b/src/identification.js index 1c953520..e0cee9d5 100644 --- a/src/identification.js +++ b/src/identification.js @@ -22,12 +22,12 @@ class Identification { 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({ port: Helper.config.identd.port || 113, 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)}`); startedCallback(this); @@ -54,7 +54,7 @@ class Identification { return; } - for (var connection of this.connections.values()) { + for (const connection of this.connections.values()) { if (connection.socket.remoteAddress === socket.remoteAddress && connection.socket.remotePort === fport && connection.socket.localPort === lport diff --git a/src/log.js b/src/log.js index 6a54a80b..17ba0aae 100644 --- a/src/log.js +++ b/src/log.js @@ -1,9 +1,9 @@ "use strict"; -var colors = require("colors/safe"); -var moment = require("moment"); +const colors = require("colors/safe"); +const moment = require("moment"); const read = require("read"); -var Helper = require("./helper"); +const Helper = require("./helper"); function timestamp() { const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss"; diff --git a/src/models/chan.js b/src/models/chan.js index 4baa1cea..f3ba6d23 100644 --- a/src/models/chan.js +++ b/src/models/chan.js @@ -1,7 +1,7 @@ "use strict"; -var _ = require("lodash"); -var Helper = require("../helper"); +const _ = require("lodash"); +const Helper = require("../helper"); const User = require("./user"); const userLog = require("../userLog"); const storage = require("../plugins/storage"); @@ -43,7 +43,7 @@ Chan.prototype.destroy = function() { }; Chan.prototype.pushMessage = function(client, msg, increasesUnread) { - var obj = { + const obj = { chan: this.id, msg: msg, }; @@ -110,7 +110,7 @@ Chan.prototype.getSortedUsers = function(irc) { return users; } - var userModeSortPriority = {}; + const userModeSortPriority = {}; irc.network.options.PREFIX.forEach((prefix, index) => { userModeSortPriority[prefix.symbol] = index; }); diff --git a/src/models/msg.js b/src/models/msg.js index e4e82bce..0bafbd4f 100644 --- a/src/models/msg.js +++ b/src/models/msg.js @@ -1,8 +1,8 @@ "use strict"; -var _ = require("lodash"); +const _ = require("lodash"); -var id = 0; +let id = 0; class Msg { constructor(attr) { diff --git a/src/models/network.js b/src/models/network.js index ea120bc1..58458807 100644 --- a/src/models/network.js +++ b/src/models/network.js @@ -1,7 +1,7 @@ "use strict"; -var _ = require("lodash"); -var Chan = require("./chan"); +const _ = require("lodash"); +const Chan = require("./chan"); module.exports = Network; @@ -98,7 +98,7 @@ Network.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) { }; Network.prototype.export = function() { - var network = _.pick(this, [ + const network = _.pick(this, [ "awayMessage", "nick", "name", diff --git a/src/models/user.js b/src/models/user.js index a813bacb..02fce92a 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -1,6 +1,6 @@ "use strict"; -var _ = require("lodash"); +const _ = require("lodash"); module.exports = User; diff --git a/src/plugins/inputs/action.js b/src/plugins/inputs/action.js index 8c6726b6..9bda03e3 100644 --- a/src/plugins/inputs/action.js +++ b/src/plugins/inputs/action.js @@ -1,7 +1,7 @@ "use strict"; -var Chan = require("../../models/chan"); -var Msg = require("../../models/msg"); +const Chan = require("../../models/chan"); +const Msg = require("../../models/msg"); exports.commands = ["slap", "me"]; @@ -15,7 +15,7 @@ exports.input = function({irc}, chan, cmd, args) { return; } - var text; + let text; switch (cmd) { case "slap": diff --git a/src/plugins/inputs/ban.js b/src/plugins/inputs/ban.js index 4649a71f..ee661a15 100644 --- a/src/plugins/inputs/ban.js +++ b/src/plugins/inputs/ban.js @@ -1,7 +1,7 @@ "use strict"; -var Chan = require("../../models/chan"); -var Msg = require("../../models/msg"); +const Chan = require("../../models/chan"); +const Msg = require("../../models/msg"); exports.commands = [ "ban", diff --git a/src/plugins/inputs/connect.js b/src/plugins/inputs/connect.js index 550f918a..95d7e1f0 100644 --- a/src/plugins/inputs/connect.js +++ b/src/plugins/inputs/connect.js @@ -1,6 +1,6 @@ "use strict"; -var Msg = require("../../models/msg"); +const Msg = require("../../models/msg"); exports.commands = ["connect", "server"]; exports.allowDisconnected = true; @@ -24,8 +24,8 @@ exports.input = function({irc}, chan, cmd, args) { return; } - var port = args[1] || ""; - var tls = port[0] === "+"; + let port = args[1] || ""; + const tls = port[0] === "+"; if (tls) { port = port.substring(1); diff --git a/src/plugins/inputs/disconnect.js b/src/plugins/inputs/disconnect.js index 7737d60c..729807a2 100644 --- a/src/plugins/inputs/disconnect.js +++ b/src/plugins/inputs/disconnect.js @@ -5,7 +5,7 @@ const Helper = require("../../helper"); exports.commands = ["disconnect"]; 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); }; diff --git a/src/plugins/inputs/invite.js b/src/plugins/inputs/invite.js index 727df6b9..a50b4083 100644 --- a/src/plugins/inputs/invite.js +++ b/src/plugins/inputs/invite.js @@ -1,7 +1,7 @@ "use strict"; -var Chan = require("../../models/chan"); -var Msg = require("../../models/msg"); +const Chan = require("../../models/chan"); +const Msg = require("../../models/msg"); exports.commands = ["invite"]; diff --git a/src/plugins/inputs/kick.js b/src/plugins/inputs/kick.js index 7482642a..213fe5c2 100644 --- a/src/plugins/inputs/kick.js +++ b/src/plugins/inputs/kick.js @@ -1,7 +1,7 @@ "use strict"; -var Chan = require("../../models/chan"); -var Msg = require("../../models/msg"); +const Chan = require("../../models/chan"); +const Msg = require("../../models/msg"); exports.commands = ["kick"]; diff --git a/src/plugins/inputs/mode.js b/src/plugins/inputs/mode.js index 35f51106..8040d99e 100644 --- a/src/plugins/inputs/mode.js +++ b/src/plugins/inputs/mode.js @@ -1,7 +1,7 @@ "use strict"; -var Chan = require("../../models/chan"); -var Msg = require("../../models/msg"); +const Chan = require("../../models/chan"); +const Msg = require("../../models/msg"); exports.commands = [ "mode", diff --git a/src/plugins/inputs/msg.js b/src/plugins/inputs/msg.js index 58733765..83513041 100644 --- a/src/plugins/inputs/msg.js +++ b/src/plugins/inputs/msg.js @@ -3,26 +3,25 @@ exports.commands = ["msg", "say"]; exports.input = function(network, chan, cmd, args) { - var irc = network.irc; - var target = cmd === "msg" ? args.shift() : chan.name; + const target = cmd === "msg" ? args.shift() : chan.name; if (args.length === 0 || !target) { return true; } - var msg = args.join(" "); + const msg = args.join(" "); if (msg.length === 0) { return true; } - irc.say(target, msg); + network.irc.say(target, msg); if (!network.irc.network.cap.isEnabled("echo-message")) { - var channel = network.getChannel(target); + const channel = network.getChannel(target); if (typeof channel !== "undefined") { - irc.emit("privmsg", { - nick: irc.user.nick, + network.irc.emit("privmsg", { + nick: network.irc.user.nick, target: channel.name, message: msg, }); diff --git a/src/plugins/inputs/nick.js b/src/plugins/inputs/nick.js index fd6385dd..412a47bf 100644 --- a/src/plugins/inputs/nick.js +++ b/src/plugins/inputs/nick.js @@ -1,6 +1,6 @@ "use strict"; -var Msg = require("../../models/msg"); +const Msg = require("../../models/msg"); exports.commands = ["nick"]; exports.allowDisconnected = true; @@ -22,7 +22,7 @@ exports.input = function(network, chan, cmd, args) { return; } - var newNick = args[0]; + const newNick = args[0]; // If connected to IRC, send to server and wait for ACK // otherwise update the nick and UI straight away diff --git a/src/plugins/inputs/notice.js b/src/plugins/inputs/notice.js index 7846b5de..652f5e63 100644 --- a/src/plugins/inputs/notice.js +++ b/src/plugins/inputs/notice.js @@ -7,19 +7,19 @@ exports.input = function(network, chan, cmd, args) { return; } - var message = args.slice(1).join(" "); - var irc = network.irc; - irc.notice(args[0], message); + let targetChan = network.getChannel(args[0]); + let message = args.slice(1).join(" "); + + network.irc.notice(args[0], message); - var targetChan = network.getChannel(args[0]); if (typeof targetChan === "undefined") { message = "{to " + args[0] + "} " + message; targetChan = chan; } if (!network.irc.network.cap.isEnabled("echo-message")) { - irc.emit("notice", { - nick: irc.user.nick, + network.irc.emit("notice", { + nick: network.irc.user.nick, target: targetChan.name, message: message, }); diff --git a/src/plugins/inputs/part.js b/src/plugins/inputs/part.js index acf6eff9..9fda89aa 100644 --- a/src/plugins/inputs/part.js +++ b/src/plugins/inputs/part.js @@ -1,8 +1,8 @@ "use strict"; -var _ = require("lodash"); -var Msg = require("../../models/msg"); -var Chan = require("../../models/chan"); +const _ = require("lodash"); +const Msg = require("../../models/msg"); +const Chan = require("../../models/chan"); const Helper = require("../../helper"); exports.commands = ["close", "leave", "part"]; diff --git a/src/plugins/inputs/query.js b/src/plugins/inputs/query.js index 9882bebd..ee3e40d2 100644 --- a/src/plugins/inputs/query.js +++ b/src/plugins/inputs/query.js @@ -1,13 +1,13 @@ "use strict"; -var _ = require("lodash"); -var Chan = require("../../models/chan"); -var Msg = require("../../models/msg"); +const _ = require("lodash"); +const Chan = require("../../models/chan"); +const Msg = require("../../models/msg"); exports.commands = ["query"]; exports.input = function(network, chan, cmd, args) { - var target = args[0]; + const target = args[0]; if (args.length === 0 || target.length === 0) { chan.pushMessage(this, new Msg({ type: Msg.Type.ERROR, @@ -16,12 +16,12 @@ exports.input = function(network, chan, cmd, args) { return; } - var query = _.find(network.channels, {name: target}); + const query = _.find(network.channels, {name: target}); if (typeof query !== "undefined") { return; } - var char = target[0]; + const char = target[0]; if (network.irc.network.options.CHANTYPES && network.irc.network.options.CHANTYPES.includes(char)) { chan.pushMessage(this, new Msg({ type: Msg.Type.ERROR, @@ -30,7 +30,7 @@ exports.input = function(network, chan, cmd, args) { 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) { chan.pushMessage(this, new Msg({ 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, name: target, }); diff --git a/src/plugins/inputs/quit.js b/src/plugins/inputs/quit.js index 33f442ee..3b21ca49 100644 --- a/src/plugins/inputs/quit.js +++ b/src/plugins/inputs/quit.js @@ -1,13 +1,13 @@ "use strict"; -var _ = require("lodash"); +const _ = require("lodash"); const Helper = require("../../helper"); exports.commands = ["quit"]; exports.allowDisconnected = true; exports.input = function(network, chan, cmd, args) { - var client = this; + const client = this; client.networks = _.without(client.networks, network); network.destroy(); diff --git a/src/plugins/inputs/rejoin.js b/src/plugins/inputs/rejoin.js index 1ff01b58..96c2cca8 100644 --- a/src/plugins/inputs/rejoin.js +++ b/src/plugins/inputs/rejoin.js @@ -1,7 +1,7 @@ "use strict"; -var Msg = require("../../models/msg"); -var Chan = require("../../models/chan"); +const Msg = require("../../models/msg"); +const Chan = require("../../models/chan"); exports.commands = ["cycle", "rejoin"]; diff --git a/src/plugins/inputs/topic.js b/src/plugins/inputs/topic.js index 36e22deb..14fff3ae 100644 --- a/src/plugins/inputs/topic.js +++ b/src/plugins/inputs/topic.js @@ -1,7 +1,7 @@ "use strict"; -var Chan = require("../../models/chan"); -var Msg = require("../../models/msg"); +const Chan = require("../../models/chan"); +const Msg = require("../../models/msg"); exports.commands = ["topic"]; diff --git a/src/plugins/irc-events/link.js b/src/plugins/irc-events/link.js index b082bcea..4c0cff3a 100644 --- a/src/plugins/irc-events/link.js +++ b/src/plugins/irc-events/link.js @@ -50,8 +50,8 @@ module.exports = function(client, chan, msg) { function parse(msg, preview, res, client) { switch (res.type) { - case "text/html": - var $ = cheerio.load(res.data); + case "text/html": { + const $ = cheerio.load(res.data); preview.type = "link"; preview.head = $('meta[property="og:title"]').attr("content") @@ -92,6 +92,7 @@ function parse(msg, preview, res, client) { } break; + } case "image/png": case "image/gif": diff --git a/src/server.js b/src/server.js index 32522fab..9bf6ec00 100644 --- a/src/server.js +++ b/src/server.js @@ -1,16 +1,16 @@ "use strict"; -var _ = require("lodash"); -var pkg = require("../package.json"); -var Client = require("./client"); -var ClientManager = require("./clientManager"); -var express = require("express"); -var fs = require("fs"); -var path = require("path"); -var io = require("socket.io"); -var dns = require("dns"); -var Helper = require("./helper"); -var colors = require("colors/safe"); +const _ = require("lodash"); +const pkg = require("../package.json"); +const Client = require("./client"); +const ClientManager = require("./clientManager"); +const express = require("express"); +const fs = require("fs"); +const path = require("path"); +const io = require("socket.io"); +const dns = require("dns"); +const Helper = require("./helper"); +const colors = require("colors/safe"); const net = require("net"); const Identification = require("./identification"); 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 const serverHash = Math.floor(Date.now() * Math.random()); -var manager = null; +let manager = null; module.exports = function() { log.info(`The Lounge ${colors.green(Helper.getVersion())} \ (Node.js ${colors.green(process.versions.node)} on ${colors.green(process.platform)} ${process.arch})`); log.info(`Configuration file: ${colors.green(Helper.getConfigPath())}`); - var app = express() + const app = express() .disable("x-powered-by") .use(allRequests) .use(index) @@ -72,20 +72,19 @@ module.exports = function() { return res.sendFile(path.join(packagePath, fileName)); }); - var config = Helper.config; - var server = null; + let 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."); } - if (!config.https.enable) { + if (!Helper.config.https.enable) { server = require("http"); server = server.createServer(app); } else { - const keyPath = Helper.expandHome(config.https.key); - const certPath = Helper.expandHome(config.https.certificate); - const caPath = Helper.expandHome(config.https.ca); + const keyPath = Helper.expandHome(Helper.config.https.key); + const certPath = Helper.expandHome(Helper.config.https.certificate); + const caPath = Helper.expandHome(Helper.config.https.ca); if (!keyPath.length || !fs.existsSync(keyPath)) { log.error("Path to SSL key is invalid. Stopping server..."); @@ -112,12 +111,12 @@ module.exports = function() { let listenParams; - if (typeof config.host === "string" && config.host.startsWith("unix:")) { - listenParams = config.host.replace(/^unix:/, ""); + if (typeof Helper.config.host === "string" && Helper.config.host.startsWith("unix:")) { + listenParams = Helper.config.host.replace(/^unix:/, ""); } else { listenParams = { - port: config.port, - host: config.host, + port: Helper.config.port, + host: Helper.config.host, }; } @@ -127,23 +126,23 @@ module.exports = function() { if (typeof listenParams === "string") { log.info("Available on socket " + colors.green(listenParams)); } else { - const protocol = config.https.enable ? "https" : "http"; + const protocol = Helper.config.https.enable ? "https" : "http"; const address = server.address(); log.info( "Available at " + 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, { serveClient: false, - transports: config.transports, + transports: Helper.config.transports, }); sockets.on("connect", (socket) => { - if (config.public) { + if (Helper.config.public) { performAuthentication.call(socket, {}); } else { socket.emit("auth", { @@ -302,9 +301,9 @@ function initializeClient(socket, client, token, lastMessage) { socket.on( "change-password", function(data) { - var old = data.old_password; - var p1 = data.new_password; - var p2 = data.verify_password; + const old = data.old_password; + const p1 = data.new_password; + const p2 = data.verify_password; if (typeof p1 === "undefined" || p1 === "") { socket.emit("change-password", { error: "Please enter a new password", diff --git a/src/userLog.js b/src/userLog.js index 99299c0a..75219c67 100644 --- a/src/userLog.js +++ b/src/userLog.js @@ -1,9 +1,9 @@ "use strict"; -var fs = require("fs"); -var fsextra = require("fs-extra"); -var moment = require("moment"); -var Helper = require("./helper"); +const fs = require("fs"); +const fsextra = require("fs-extra"); +const moment = require("moment"); +const Helper = require("./helper"); module.exports.write = function(user, network, chan, msg) { const path = Helper.getUserLogsPath(user, network); @@ -15,13 +15,13 @@ module.exports.write = function(user, network, chan, msg) { return; } - var format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss"; - var tz = Helper.config.logs.timezone || "UTC+00:00"; + const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss"; + const tz = Helper.config.logs.timezone || "UTC+00:00"; - var time = moment(msg.time).utcOffset(tz).format(format); - var line = `[${time}] `; + const time = moment(msg.time).utcOffset(tz).format(format); + let line = `[${time}] `; - var type = msg.type.trim(); + const type = msg.type.trim(); if (type === "message" || type === "highlight") { // Format: // [2014-01-01 00:00:00] Put that cookie down.. Now!! diff --git a/test/commands/mode.js b/test/commands/mode.js index ac16b290..0b2646f6 100644 --- a/test/commands/mode.js +++ b/test/commands/mode.js @@ -1,9 +1,9 @@ "use strict"; -var expect = require("chai").expect; +const expect = require("chai").expect; -var Chan = require("../../src/models/chan"); -var ModeCommand = require("../../src/plugins/inputs/mode"); +const Chan = require("../../src/models/chan"); +const ModeCommand = require("../../src/plugins/inputs/mode"); describe("Commands", function() { describe("/mode", function() { diff --git a/test/fixtures/env.js b/test/fixtures/env.js index ccf9b90a..88f41e9c 100644 --- a/test/fixtures/env.js +++ b/test/fixtures/env.js @@ -2,5 +2,5 @@ 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); diff --git a/test/models/chan.js b/test/models/chan.js index 52df500f..c6d55148 100644 --- a/test/models/chan.js +++ b/test/models/chan.js @@ -82,7 +82,7 @@ describe("Chan", function() { }); describe("#getSortedUsers(irc)", function() { - var getUserNames = function(chan) { + const getUserNames = function(chan) { return chan.getSortedUsers(network).map((u) => u.nick); }; diff --git a/test/models/network.js b/test/models/network.js index 99b28263..bbd7be81 100644 --- a/test/models/network.js +++ b/test/models/network.js @@ -9,7 +9,7 @@ const Network = require("../../src/models/network"); describe("Network", function() { describe("#export()", function() { it("should produce an valid object", function() { - var network = new Network({ + const network = new Network({ awayMessage: "I am away", name: "networkName", channels: [ @@ -47,7 +47,7 @@ describe("Network", function() { }); it("lobby should be at the top", function() { - var network = new Network({ + const network = new Network({ name: "Super Nice Network", channels: [ new Chan({name: "AAAA!", type: Chan.Type.QUERY}), @@ -62,7 +62,7 @@ describe("Network", function() { }); it("should maintain channel reference", function() { - var chan = new Chan({ + const chan = new Chan({ name: "#506-bug-fix", messages: [ new Msg({ @@ -71,7 +71,7 @@ describe("Network", function() { ], }); - var network = new Network({ + const network = new Network({ name: "networkName", channels: [ chan, diff --git a/test/tests/nickhighlights.js b/test/tests/nickhighlights.js index 9ef9f36b..51b20989 100644 --- a/test/tests/nickhighlights.js +++ b/test/tests/nickhighlights.js @@ -1,10 +1,10 @@ "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() { it("should NOT highlight nickname", function() { diff --git a/test/util.js b/test/util.js index 22027fd8..68ca2903 100644 --- a/test/util.js +++ b/test/util.js @@ -1,11 +1,11 @@ "use strict"; -var EventEmitter = require("events").EventEmitter; -var util = require("util"); -var _ = require("lodash"); -var express = require("express"); -var Network = require("../src/models/network"); -var Chan = require("../src/models/chan"); +const EventEmitter = require("events").EventEmitter; +const util = require("util"); +const _ = require("lodash"); +const express = require("express"); +const Network = require("../src/models/network"); +const Chan = require("../src/models/chan"); function MockClient() { this.user = {nick: "test-user"}; @@ -13,7 +13,7 @@ function MockClient() { util.inherits(MockClient, EventEmitter); MockClient.prototype.createMessage = function(opts) { - var message = _.extend({ + const message = _.extend({ text: "dummy message", nick: "test-user", target: "#test-channel",