Merge pull request #2073 from thelounge/astorije/eslint-object-shorthand
Enforce object literal shorthand syntax with ESLint
This commit is contained in:
commit
3873c4def1
@ -47,6 +47,10 @@ rules:
|
||||
no-use-before-define: [error, {functions: false}]
|
||||
no-var: error
|
||||
object-curly-spacing: [error, never]
|
||||
object-shorthand:
|
||||
- error
|
||||
- methods
|
||||
- avoidExplicitReturnArrows: true
|
||||
padded-blocks: [error, never]
|
||||
padding-line-between-statements:
|
||||
- error
|
||||
|
@ -14,7 +14,7 @@ let enabled = false;
|
||||
|
||||
module.exports = {
|
||||
enable: enableAutocomplete,
|
||||
disable: () => {
|
||||
disable() {
|
||||
if (enabled) {
|
||||
input.off("input.tabcomplete");
|
||||
Mousetrap(input.get(0)).off("tab", "keydown");
|
||||
|
@ -79,6 +79,7 @@ const condensedTypes = [
|
||||
"kick",
|
||||
"mode",
|
||||
];
|
||||
const condensedTypesQuery = "." + condensedTypes.join(", .");
|
||||
|
||||
const timeFormats = {
|
||||
msgDefault: "HH:mm",
|
||||
@ -86,9 +87,9 @@ const timeFormats = {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
colorCodeMap: colorCodeMap,
|
||||
commands: commands,
|
||||
condensedTypes: condensedTypes,
|
||||
condensedTypesQuery: "." + condensedTypes.join(", ."),
|
||||
timeFormats: timeFormats,
|
||||
colorCodeMap,
|
||||
commands,
|
||||
condensedTypes,
|
||||
condensedTypesQuery,
|
||||
timeFormats,
|
||||
};
|
||||
|
@ -30,9 +30,7 @@ Mousetrap.bind([
|
||||
scrollTop = Math.ceil(scrollTop + offset);
|
||||
}
|
||||
|
||||
container.animate({
|
||||
scrollTop: scrollTop,
|
||||
}, 200);
|
||||
container.animate({scrollTop}, 200);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
@ -8,12 +8,9 @@ function assign(textPart, fragment) {
|
||||
const fragStart = fragment.start;
|
||||
const start = Math.max(fragment.start, textPart.start);
|
||||
const end = Math.min(fragment.end, textPart.end);
|
||||
const text = fragment.text.slice(start - fragStart, end - fragStart);
|
||||
|
||||
return Object.assign({}, fragment, {
|
||||
start: start,
|
||||
end: end,
|
||||
text: fragment.text.slice(start - fragStart, end - fragStart),
|
||||
});
|
||||
return Object.assign({}, fragment, {start, end, text});
|
||||
}
|
||||
|
||||
// Merge the style fragments withing the text parts, taking into account
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
set: function(key, value) {
|
||||
set(key, value) {
|
||||
try {
|
||||
window.localStorage.setItem(key, value);
|
||||
} catch (e) {
|
||||
@ -10,10 +10,10 @@ module.exports = {
|
||||
// available. See http://stackoverflow.com/q/14555347/1935861.
|
||||
}
|
||||
},
|
||||
get: function(key) {
|
||||
get(key) {
|
||||
return window.localStorage.getItem(key);
|
||||
},
|
||||
remove: function(key, value) {
|
||||
remove(key, value) {
|
||||
window.localStorage.removeItem(key, value);
|
||||
},
|
||||
};
|
||||
|
@ -242,6 +242,7 @@ $(function() {
|
||||
$("#form").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
utils.forceFocus();
|
||||
const target = chat.data("id");
|
||||
const text = input.val();
|
||||
|
||||
if (text.length === 0) {
|
||||
@ -260,10 +261,7 @@ $(function() {
|
||||
}
|
||||
}
|
||||
|
||||
socket.emit("input", {
|
||||
target: chat.data("id"),
|
||||
text: text,
|
||||
});
|
||||
socket.emit("input", {target, text});
|
||||
});
|
||||
|
||||
$("button#set-nick").on("click", function() {
|
||||
@ -520,29 +518,29 @@ $(function() {
|
||||
});
|
||||
|
||||
const contextMenuActions = {
|
||||
join: function(itemData) {
|
||||
join(itemData) {
|
||||
const network = $(`#join-channel-${itemData}`).closest(".network");
|
||||
JoinChannel.openForm(network);
|
||||
},
|
||||
close: function(itemData) {
|
||||
close(itemData) {
|
||||
closeChan($(`.networks .chan[data-target="${itemData}"]`));
|
||||
},
|
||||
focusChan: function(itemData) {
|
||||
focusChan(itemData) {
|
||||
$(`.networks .chan[data-target="${itemData}"]`).trigger("click");
|
||||
},
|
||||
list: function(itemData) {
|
||||
list(itemData) {
|
||||
socket.emit("input", {
|
||||
target: itemData,
|
||||
text: "/list",
|
||||
});
|
||||
},
|
||||
banlist: function(itemData) {
|
||||
banlist(itemData) {
|
||||
socket.emit("input", {
|
||||
target: itemData,
|
||||
text: "/banlist",
|
||||
});
|
||||
},
|
||||
whois: function(itemData) {
|
||||
whois(itemData) {
|
||||
const chan = utils.findCurrentNetworkChan(itemData);
|
||||
|
||||
if (chan.length) {
|
||||
@ -556,7 +554,7 @@ $(function() {
|
||||
|
||||
$(`.channel.active .userlist .user[data-name="${itemData}"]`).trigger("click");
|
||||
},
|
||||
query: function(itemData) {
|
||||
query(itemData) {
|
||||
const chan = utils.findCurrentNetworkChan(itemData);
|
||||
|
||||
if (chan.length) {
|
||||
@ -568,7 +566,7 @@ $(function() {
|
||||
text: "/query " + itemData,
|
||||
});
|
||||
},
|
||||
kick: function(itemData) {
|
||||
kick(itemData) {
|
||||
socket.emit("input", {
|
||||
target: $("#chat").data("id"),
|
||||
text: "/kick " + itemData,
|
||||
|
@ -70,11 +70,11 @@ if (typeof userSettings.theme === "string" && $theme.attr("href") !== `themes/${
|
||||
userSettings = null;
|
||||
|
||||
module.exports = {
|
||||
alwaysSync: alwaysSync,
|
||||
noSync: noSync,
|
||||
alwaysSync,
|
||||
noSync,
|
||||
initialized: false,
|
||||
highlightsRE: null,
|
||||
settings: settings,
|
||||
settings,
|
||||
shouldOpenMessagePreview,
|
||||
noServerSettings,
|
||||
processSetting,
|
||||
@ -166,10 +166,7 @@ function applySetting(name, value) {
|
||||
}
|
||||
|
||||
function settingSetEmit(name, value) {
|
||||
socket.emit("setting:set", {
|
||||
name: name,
|
||||
value: value,
|
||||
});
|
||||
socket.emit("setting:set", {name, value});
|
||||
}
|
||||
|
||||
// When sync is `true` the setting will also be send to the backend for syncing.
|
||||
|
@ -17,7 +17,7 @@ function renderPreview(preview, msg) {
|
||||
|
||||
preview.shown = preview.shown && options.shouldOpenMessagePreview(preview.type);
|
||||
|
||||
const template = $(templates.msg_preview({preview: preview}));
|
||||
const template = $(templates.msg_preview({preview}));
|
||||
const image = template.find("img:first");
|
||||
|
||||
if (image.length === 0) {
|
||||
@ -61,7 +61,7 @@ function appendPreview(preview, msg, template) {
|
||||
|
||||
msg.find(`.text a[href="${escapedLink}"]`)
|
||||
.first()
|
||||
.after(templates.msg_preview_toggle({preview: preview}).trim());
|
||||
.after(templates.msg_preview_toggle({preview}).trim());
|
||||
|
||||
previewContainer.append(template);
|
||||
|
||||
|
@ -65,12 +65,8 @@ socket.on("auth", function(data) {
|
||||
|
||||
if (token) {
|
||||
$("#loading-page-message, #connection-error").text("Authorizing…");
|
||||
|
||||
socket.emit("auth", {
|
||||
user: user,
|
||||
token: token,
|
||||
lastMessage: utils.lastMessageId,
|
||||
});
|
||||
const lastMessage = utils.lastMessageId;
|
||||
socket.emit("auth", {user, token, lastMessage});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,10 @@
|
||||
const $ = require("jquery");
|
||||
const io = require("socket.io-client");
|
||||
const utils = require("./utils");
|
||||
const path = window.location.pathname + "socket.io/";
|
||||
|
||||
const socket = io({
|
||||
transports: $(document.body).data("transports"),
|
||||
path: path,
|
||||
path: window.location.pathname + "socket.io/",
|
||||
autoConnect: false,
|
||||
reconnection: !$(document.body).hasClass("public"),
|
||||
});
|
||||
|
@ -17,18 +17,18 @@ module.exports = function() {
|
||||
forcePlaceholderSize: true,
|
||||
tolerance: "pointer", // Use the pointer to figure out where the network is in the list
|
||||
|
||||
update: function() {
|
||||
update() {
|
||||
const order = [];
|
||||
|
||||
sidebar.find(".network").each(function() {
|
||||
const id = $(this).data("id");
|
||||
order.push(id);
|
||||
});
|
||||
socket.emit(
|
||||
"sort", {
|
||||
|
||||
socket.emit("sort", {
|
||||
type: "networks",
|
||||
order: order,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
options.settings.ignoreSortSync = true;
|
||||
},
|
||||
@ -43,20 +43,20 @@ module.exports = function() {
|
||||
forcePlaceholderSize: true,
|
||||
tolerance: "pointer", // Use the pointer to figure out where the channel is in the list
|
||||
|
||||
update: function(e, ui) {
|
||||
update(e, ui) {
|
||||
const order = [];
|
||||
const network = ui.item.parent();
|
||||
|
||||
network.find(".chan").each(function() {
|
||||
const id = $(this).data("id");
|
||||
order.push(id);
|
||||
});
|
||||
socket.emit(
|
||||
"sort", {
|
||||
|
||||
socket.emit("sort", {
|
||||
type: "channels",
|
||||
target: network.data("id"),
|
||||
order: order,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
options.settings.ignoreSortSync = true;
|
||||
},
|
||||
|
@ -142,7 +142,7 @@ function requestIdleCallback(callback, timeout) {
|
||||
if (window.requestIdleCallback) {
|
||||
// During an idle period the user agent will run idle callbacks in FIFO order
|
||||
// until either the idle period ends or there are no more idle callbacks eligible to be run.
|
||||
window.requestIdleCallback(callback, {timeout: timeout});
|
||||
window.requestIdleCallback(callback, {timeout});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
|
@ -132,10 +132,7 @@ Client.prototype.find = function(channelId) {
|
||||
}
|
||||
|
||||
if (network && chan) {
|
||||
return {
|
||||
network: network,
|
||||
chan: chan,
|
||||
};
|
||||
return {network, chan};
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -557,10 +554,8 @@ Client.prototype.clientAttach = function(socketId, token) {
|
||||
});
|
||||
}
|
||||
|
||||
client.attachedClients[socketId] = {
|
||||
token: token,
|
||||
openChannel: client.lastActiveChannel,
|
||||
};
|
||||
const openChannel = client.lastActiveChannel;
|
||||
client.attachedClients[socketId] = {token, openChannel};
|
||||
|
||||
// Update old networks to store ip and hostmask
|
||||
client.networks.forEach((network) => {
|
||||
|
@ -51,7 +51,7 @@ ClientManager.prototype.autoloadUsers = function() {
|
||||
|
||||
// Existing users removed since last time users were loaded
|
||||
_.difference(loaded, updatedUsers).forEach((name) => {
|
||||
const client = _.find(this.clients, {name: name});
|
||||
const client = _.find(this.clients, {name});
|
||||
|
||||
if (client) {
|
||||
client.quit(true);
|
||||
|
@ -69,7 +69,7 @@ class Identification {
|
||||
addSocket(socket, user) {
|
||||
const id = ++this.connectionId;
|
||||
|
||||
this.connections.set(id, {socket: socket, user: user});
|
||||
this.connections.set(id, {socket, user});
|
||||
|
||||
if (this.oidentdFile) {
|
||||
this.refresh();
|
||||
|
@ -43,13 +43,11 @@ Chan.prototype.destroy = function() {
|
||||
};
|
||||
|
||||
Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
|
||||
const obj = {
|
||||
chan: this.id,
|
||||
msg: msg,
|
||||
};
|
||||
const chan = this.id;
|
||||
const obj = {chan, msg};
|
||||
|
||||
// If this channel is open in any of the clients, do not increase unread counter
|
||||
const isOpen = _.find(client.attachedClients, {openChannel: this.id}) !== undefined;
|
||||
const isOpen = _.find(client.attachedClients, {openChannel: chan}) !== undefined;
|
||||
|
||||
if ((increasesUnread || msg.highlight) && !isOpen) {
|
||||
obj.unread = ++this.unread;
|
||||
@ -131,7 +129,7 @@ Chan.prototype.findUser = function(nick) {
|
||||
};
|
||||
|
||||
Chan.prototype.getUser = function(nick) {
|
||||
return this.findUser(nick) || new User({nick: nick});
|
||||
return this.findUser(nick) || new User({nick});
|
||||
};
|
||||
|
||||
Chan.prototype.setUser = function(user) {
|
||||
|
@ -31,11 +31,8 @@ exports.input = function({irc}, chan, cmd, args) {
|
||||
port = port.substring(1);
|
||||
}
|
||||
|
||||
this.connect({
|
||||
host: args[0],
|
||||
port: port,
|
||||
tls: tls,
|
||||
});
|
||||
const host = args[0];
|
||||
this.connect({host, port, tls});
|
||||
|
||||
return true;
|
||||
};
|
||||
|
@ -269,10 +269,8 @@ function emitPreview(client, msg, preview) {
|
||||
}
|
||||
}
|
||||
|
||||
client.emit("msg:preview", {
|
||||
id: msg.id,
|
||||
preview: preview,
|
||||
});
|
||||
const id = msg.id;
|
||||
client.emit("msg:preview", {id, preview});
|
||||
}
|
||||
|
||||
function getRequestHeaders(language) {
|
||||
@ -349,11 +347,8 @@ function fetch(uri, {language}, cb) {
|
||||
type = req.response.headers["content-type"].split(/ *; */).shift();
|
||||
}
|
||||
|
||||
cb({
|
||||
data: Buffer.concat(buffers, length),
|
||||
type: type,
|
||||
size: size,
|
||||
});
|
||||
const data = Buffer.concat(buffers, length);
|
||||
cb({data, type, size});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -58,11 +58,9 @@ function makePackageThemeObject(moduleName, module) {
|
||||
}
|
||||
|
||||
const modulePath = Helper.getPackageModulePath(moduleName);
|
||||
const displayName = module.name || moduleName;
|
||||
const filename = path.join(modulePath, module.css);
|
||||
return {
|
||||
displayName: displayName,
|
||||
filename: filename,
|
||||
displayName: module.name || moduleName,
|
||||
filename: path.join(modulePath, module.css),
|
||||
name: moduleName,
|
||||
};
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ describe("Commands", function() {
|
||||
lastCommand: null,
|
||||
nick: "xPaw",
|
||||
irc: {
|
||||
raw: function(...args) {
|
||||
raw(...args) {
|
||||
testableNetwork.lastCommand = args.join(" ");
|
||||
},
|
||||
},
|
||||
|
@ -90,7 +90,7 @@ describe("Chan", function() {
|
||||
const chan = new Chan();
|
||||
[
|
||||
"JocelynD", "YaManicKill", "astorije", "xPaw", "Max-P",
|
||||
].forEach((nick) => chan.setUser(new User({nick: nick})));
|
||||
].forEach((nick) => chan.setUser(new User({nick})));
|
||||
|
||||
expect(chan.getSortedUsers().map((u) => u.nick)).to.deep.equal([
|
||||
"JocelynD", "YaManicKill", "astorije", "xPaw", "Max-P",
|
||||
@ -101,7 +101,7 @@ describe("Chan", function() {
|
||||
const chan = new Chan();
|
||||
[
|
||||
"JocelynD", "YaManicKill", "astorije", "xPaw", "Max-P",
|
||||
].forEach((nick) => chan.setUser(new User({nick: nick}, prefixLookup)));
|
||||
].forEach((nick) => chan.setUser(new User({nick}, prefixLookup)));
|
||||
|
||||
expect(getUserNames(chan)).to.deep.equal([
|
||||
"astorije", "JocelynD", "Max-P", "xPaw", "YaManicKill",
|
||||
@ -138,7 +138,7 @@ describe("Chan", function() {
|
||||
const chan = new Chan();
|
||||
[
|
||||
"aB", "Ad", "AA", "ac",
|
||||
].forEach((nick) => chan.setUser(new User({nick: nick}, prefixLookup)));
|
||||
].forEach((nick) => chan.setUser(new User({nick}, prefixLookup)));
|
||||
|
||||
expect(getUserNames(chan)).to.deep.equal(["AA", "aB", "ac", "Ad"]);
|
||||
});
|
||||
@ -148,7 +148,7 @@ describe("Chan", function() {
|
||||
[
|
||||
"[foo", "]foo", "(foo)", "{foo}", "<foo>", "_foo", "@foo", "^foo",
|
||||
"&foo", "!foo", "+foo", "Foo",
|
||||
].forEach((nick) => chan.setUser(new User({nick: nick}, prefixLookup)));
|
||||
].forEach((nick) => chan.setUser(new User({nick}, prefixLookup)));
|
||||
|
||||
expect(getUserNames(chan)).to.deep.equal([
|
||||
"!foo", "&foo", "(foo)", "+foo", "<foo>", "@foo", "[foo", "]foo",
|
||||
|
@ -37,10 +37,10 @@ function mockLogger(callback) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createClient: function() {
|
||||
createClient() {
|
||||
return new MockClient();
|
||||
},
|
||||
createNetwork: function() {
|
||||
createNetwork() {
|
||||
return new Network({
|
||||
host: "example.com",
|
||||
channels: [new Chan({
|
||||
@ -48,7 +48,7 @@ module.exports = {
|
||||
})],
|
||||
});
|
||||
},
|
||||
createWebserver: function() {
|
||||
createWebserver() {
|
||||
return express();
|
||||
},
|
||||
mockLogger,
|
||||
|
Loading…
Reference in New Issue
Block a user