Remove usage of == and !=

This commit is contained in:
Simon Ser 2024-10-14 00:56:18 +02:00
parent 205a617c51
commit b67cd10c64
21 changed files with 79 additions and 78 deletions

View file

@ -86,7 +86,7 @@ const ban = {
usage: "[nick]", usage: "[nick]",
description: "Ban a user from the channel, or display the current ban list", description: "Ban a user from the channel, or display the current ban list",
execute: (app, args) => { execute: (app, args) => {
if (args.length == 0) { if (args.length === 0) {
let activeChannel = getActiveChannel(app); let activeChannel = getActiveChannel(app);
getActiveClient(app).send({ getActiveClient(app).send({
command: "MODE", command: "MODE",
@ -142,7 +142,7 @@ export default {
description: "Close the current buffer", description: "Close the current buffer",
execute: (app, args) => { execute: (app, args) => {
let activeBuffer = app.state.buffers.get(app.state.activeBuffer); let activeBuffer = app.state.buffers.get(app.state.activeBuffer);
if (!activeBuffer || activeBuffer.type == BufferType.SERVER) { if (!activeBuffer || activeBuffer.type === BufferType.SERVER) {
throw new Error("Not in a user or channel buffer"); throw new Error("Not in a user or channel buffer");
} }
app.close(activeBuffer.id); app.close(activeBuffer.id);
@ -297,7 +297,7 @@ export default {
usage: "[nick]", usage: "[nick]",
description: "Quiet a user in the channel, or display the current quiet list", description: "Quiet a user in the channel, or display the current quiet list",
execute: (app, args) => { execute: (app, args) => {
if (args.length == 0) { if (args.length === 0) {
getActiveClient(app).send({ getActiveClient(app).send({
command: "MODE", command: "MODE",
params: [getActiveChannel(app), "+q"], params: [getActiveChannel(app), "+q"],

View file

@ -94,7 +94,7 @@ function splitHostPort(str) {
function fillConnectParams(params) { function fillConnectParams(params) {
let host = window.location.host || "localhost:8080"; let host = window.location.host || "localhost:8080";
let proto = "wss:"; let proto = "wss:";
if (window.location.protocol != "https:") { if (window.location.protocol !== "https:") {
proto = "ws:"; proto = "ws:";
} }
let path = window.location.pathname || "/"; let path = window.location.pathname || "/";
@ -687,7 +687,7 @@ export default class App extends Component {
} }
let msgUnread = Unread.NONE; let msgUnread = Unread.NONE;
if ((msg.command == "PRIVMSG" || msg.command == "NOTICE") && !isRead) { if ((msg.command === "PRIVMSG" || msg.command === "NOTICE") && !isRead) {
let target = msg.params[0]; let target = msg.params[0];
let text = msg.params[1]; let text = msg.params[1];
@ -702,7 +702,7 @@ export default class App extends Component {
msgUnread = Unread.MESSAGE; msgUnread = Unread.MESSAGE;
} }
if (msgUnread == Unread.HIGHLIGHT && !isDelivered && !irc.parseCTCP(msg)) { if (msgUnread === Unread.HIGHLIGHT && !isDelivered && !irc.parseCTCP(msg)) {
let title = "New " + kind + " from " + msg.prefix.name; let title = "New " + kind + " from " + msg.prefix.name;
if (client.isChannel(bufName)) { if (client.isChannel(bufName)) {
title += " in " + bufName; title += " in " + bufName;
@ -760,7 +760,7 @@ export default class App extends Component {
// Open a new buffer if the message doesn't come from me or is a // Open a new buffer if the message doesn't come from me or is a
// self-message // self-message
if ((!client.isMyNick(msg.prefix.name) || client.isMyNick(bufName)) && (msg.command != "PART" && msg.comand != "QUIT" && msg.command != irc.RPL_MONONLINE && msg.command != irc.RPL_MONOFFLINE)) { if ((!client.isMyNick(msg.prefix.name) || client.isMyNick(bufName)) && (msg.command !== "PART" && msg.comand !== "QUIT" && msg.command !== irc.RPL_MONONLINE && msg.command !== irc.RPL_MONOFFLINE)) {
this.createBuffer(serverID, bufName); this.createBuffer(serverID, bufName);
} }
@ -978,7 +978,7 @@ export default class App extends Component {
affectedBuffers.push(chatHistoryBatch.params[0]); affectedBuffers.push(chatHistoryBatch.params[0]);
} else { } else {
this.state.buffers.forEach((buf) => { this.state.buffers.forEach((buf) => {
if (buf.server != serverID) { if (buf.server !== serverID) {
return; return;
} }
if (!buf.members.has(msg.prefix.name)) { if (!buf.members.has(msg.prefix.name)) {
@ -996,7 +996,7 @@ export default class App extends Component {
affectedBuffers.push(chatHistoryBatch.params[0]); affectedBuffers.push(chatHistoryBatch.params[0]);
} else { } else {
this.state.buffers.forEach((buf) => { this.state.buffers.forEach((buf) => {
if (buf.server != serverID) { if (buf.server !== serverID) {
return; return;
} }
if (!buf.members.has(msg.prefix.name)) { if (!buf.members.has(msg.prefix.name)) {
@ -1149,7 +1149,7 @@ export default class App extends Component {
if (client.isMyNick(msg.prefix.name)) { if (client.isMyNick(msg.prefix.name)) {
this.syncBufferUnread(serverID, channel); this.syncBufferUnread(serverID, channel);
} }
if (channel == this.switchToChannel) { if (channel === this.switchToChannel) {
this.switchBuffer({ server: serverID, name: channel }); this.switchBuffer({ server: serverID, name: channel });
this.switchToChannel = null; this.switchToChannel = null;
} }
@ -1279,7 +1279,7 @@ export default class App extends Component {
}); });
break; break;
default: default:
if (irc.isError(msg.command) && msg.command != irc.ERR_NOMOTD) { if (irc.isError(msg.command) && msg.command !== irc.ERR_NOMOTD) {
let description = msg.params[msg.params.length - 1]; let description = msg.params[msg.params.length - 1];
this.showError(description); this.showError(description);
} }
@ -1527,7 +1527,7 @@ export default class App extends Component {
servers.delete(buf.server); servers.delete(buf.server);
let connectForm = state.connectForm; let connectForm = state.connectForm;
if (servers.size == 0) { if (servers.size === 0) {
connectForm = true; connectForm = true;
} }
@ -1598,7 +1598,7 @@ export default class App extends Component {
} }
privmsg(target, text) { privmsg(target, text) {
if (target == SERVER_BUFFER) { if (target === SERVER_BUFFER) {
this.showError("Cannot send message in server buffer"); this.showError("Cannot send message in server buffer");
return; return;
} }
@ -1743,7 +1743,7 @@ export default class App extends Component {
async handleBufferScrollTop() { async handleBufferScrollTop() {
let buf = this.state.buffers.get(this.state.activeBuffer); let buf = this.state.buffers.get(this.state.activeBuffer);
if (!buf || buf.type == BufferType.SERVER) { if (!buf || buf.type === BufferType.SERVER) {
return; return;
} }
@ -1922,7 +1922,7 @@ export default class App extends Component {
this.dismissDialog(); this.dismissDialog();
if (this.state.dialogData && this.state.dialogData.id) { if (this.state.dialogData && this.state.dialogData.id) {
if (Object.keys(attrs).length == 0) { if (Object.keys(attrs).length === 0) {
return; return;
} }
@ -2062,7 +2062,7 @@ export default class App extends Component {
let bufferHeader = null; let bufferHeader = null;
if (activeBuffer) { if (activeBuffer) {
let activeUser = null; let activeUser = null;
if (activeBuffer.type == BufferType.NICK) { if (activeBuffer.type === BufferType.NICK) {
activeUser = activeServer.users.get(activeBuffer.name); activeUser = activeServer.users.get(activeBuffer.name);
} }
@ -2086,7 +2086,7 @@ export default class App extends Component {
} }
let memberList = null; let memberList = null;
if (activeBuffer && activeBuffer.type == BufferType.CHANNEL) { if (activeBuffer && activeBuffer.type === BufferType.CHANNEL) {
memberList = html` memberList = html`
<section <section
id="member-list" id="member-list"

View file

@ -19,7 +19,7 @@ export default class NetworkForm extends Component {
handleInput(event) { handleInput(event) {
let target = event.target; let target = event.target;
let value = target.type == "checkbox" ? target.checked : target.value; let value = target.type === "checkbox" ? target.checked : target.value;
this.setState({ [target.name]: value }); this.setState({ [target.name]: value });
} }

View file

@ -214,7 +214,7 @@ export default function BufferHeader(props) {
} }
let name = props.buffer.name; let name = props.buffer.name;
if (props.buffer.type == BufferType.SERVER) { if (props.buffer.type === BufferType.SERVER) {
name = getServerName(props.server, props.bouncerNetwork); name = getServerName(props.server, props.bouncerNetwork);
} }

View file

@ -16,7 +16,7 @@ function BufferItem(props) {
} }
let name = props.buffer.name; let name = props.buffer.name;
if (props.buffer.type == BufferType.SERVER) { if (props.buffer.type === BufferType.SERVER) {
name = getServerName(props.server, props.bouncerNetwork); name = getServerName(props.server, props.bouncerNetwork);
} }
@ -25,7 +25,7 @@ function BufferItem(props) {
if (props.active) { if (props.active) {
classes.push("active"); classes.push("active");
} }
if (props.buffer.unread != Unread.NONE) { if (props.buffer.unread !== Unread.NONE) {
classes.push("unread-" + props.buffer.unread); classes.push("unread-" + props.buffer.unread);
} }
switch (props.buffer.type) { switch (props.buffer.type) {
@ -75,7 +75,7 @@ export default function BufferList(props) {
bouncerNetwork=${bouncerNetwork} bouncerNetwork=${bouncerNetwork}
onClick=${() => props.onBufferClick(buf)} onClick=${() => props.onBufferClick(buf)}
onClose=${() => props.onBufferClose(buf)} onClose=${() => props.onBufferClose(buf)}
active=${props.activeBuffer == buf.id} active=${props.activeBuffer === buf.id}
/> />
`; `;
}); });

View file

@ -134,7 +134,7 @@ class LogLine extends Component {
let ctcp = irc.parseCTCP(msg); let ctcp = irc.parseCTCP(msg);
if (ctcp) { if (ctcp) {
if (ctcp.command == "ACTION") { if (ctcp.command === "ACTION") {
lineClass = "me-tell"; lineClass = "me-tell";
content = html`* ${createNick(msg.prefix.name)} ${linkify(stripANSI(ctcp.param), onChannelClick)}`; content = html`* ${createNick(msg.prefix.name)} ${linkify(stripANSI(ctcp.param), onChannelClick)}`;
} else { } else {
@ -145,7 +145,7 @@ class LogLine extends Component {
} else { } else {
lineClass = "talk"; lineClass = "talk";
let prefix = "<", suffix = ">"; let prefix = "<", suffix = ">";
if (msg.command == "NOTICE") { if (msg.command === "NOTICE") {
prefix = suffix = "-"; prefix = suffix = "-";
} }
content = html`${prefix}${createNick(msg.prefix.name)}${suffix} ${linkify(stripANSI(text), onChannelClick)}`; content = html`${prefix}${createNick(msg.prefix.name)}${suffix} ${linkify(stripANSI(text), onChannelClick)}`;
@ -200,7 +200,7 @@ class LogLine extends Component {
let user = html`${createNick(msg.prefix.name)}`; let user = html`${createNick(msg.prefix.name)}`;
// TODO: use irc.forEachChannelModeUpdate() // TODO: use irc.forEachChannelModeUpdate()
if (buf.type == BufferType.CHANNEL && modeStr.length === 2 && server.cm(buf.name) === server.cm(target)) { if (buf.type === BufferType.CHANNEL && modeStr.length === 2 && server.cm(buf.name) === server.cm(target)) {
let plusMinus = modeStr[0]; let plusMinus = modeStr[0];
let mode = modeStr[1]; let mode = modeStr[1];
let arg = msg.params[2]; let arg = msg.params[2];
@ -357,7 +357,7 @@ class LogLine extends Component {
content = html`${createNick(buf.name)} is offline`; content = html`${createNick(buf.name)} is offline`;
break; break;
default: default:
if (irc.isError(msg.command) && msg.command != irc.ERR_NOMOTD) { if (irc.isError(msg.command) && msg.command !== irc.ERR_NOMOTD) {
lineClass = "error"; lineClass = "error";
} }
content = html`${msg.command} ${linkify(msg.params.join(" "))}`; content = html`${msg.command} ${linkify(msg.params.join(" "))}`;
@ -676,13 +676,13 @@ export default class Buffer extends Component {
let serverName = server.name; let serverName = server.name;
let children = []; let children = [];
if (buf.type == BufferType.SERVER) { if (buf.type === BufferType.SERVER) {
children.push(html`<${NotificationNagger}/>`); children.push(html`<${NotificationNagger}/>`);
} }
if (buf.type == BufferType.SERVER && server.isBouncer && !server.bouncerNetID) { if (buf.type === BufferType.SERVER && server.isBouncer && !server.bouncerNetID) {
children.push(html`<${ProtocolHandlerNagger} bouncerName=${serverName}/>`); children.push(html`<${ProtocolHandlerNagger} bouncerName=${serverName}/>`);
} }
if (buf.type == BufferType.SERVER && server.status == ServerStatus.REGISTERED && server.supportsSASLPlain && !server.account) { if (buf.type === BufferType.SERVER && server.status === ServerStatus.REGISTERED && server.supportsSASLPlain && !server.account) {
children.push(html` children.push(html`
<${AccountNagger} <${AccountNagger}
server=${server} server=${server}
@ -752,7 +752,7 @@ export default class Buffer extends Component {
keep[partIndexes.get(msg.prefix.name)] = false; keep[partIndexes.get(msg.prefix.name)] = false;
partIndexes.delete(msg.prefix.name); partIndexes.delete(msg.prefix.name);
keep.push(false); keep.push(false);
} else if (msg.command === "NICK" && msg.prefix.name == msg.params[0]) { } else if (msg.command === "NICK" && msg.prefix.name === msg.params[0]) {
keep.push(false); keep.push(false);
} else { } else {
keep.push(true); keep.push(true);
@ -795,7 +795,7 @@ export default class Buffer extends Component {
} }
} }
if (!hasUnreadSeparator && buf.type != BufferType.SERVER && !isMessageBeforeReceipt(msg, buf.prevReadReceipt)) { if (!hasUnreadSeparator && buf.type !== BufferType.SERVER && !isMessageBeforeReceipt(msg, buf.prevReadReceipt)) {
sep.push(html`<${UnreadSeparator} key="unread"/>`); sep.push(html`<${UnreadSeparator} key="unread"/>`);
hasUnreadSeparator = true; hasUnreadSeparator = true;
} }

View file

@ -34,7 +34,7 @@ export default class ConnectForm extends Component {
handleInput(event) { handleInput(event) {
let target = event.target; let target = event.target;
let value = target.type == "checkbox" ? target.checked : target.value; let value = target.type === "checkbox" ? target.checked : target.value;
this.setState({ [target.name]: value }); this.setState({ [target.name]: value });
} }

View file

@ -21,13 +21,13 @@ export default class Dialog extends Component {
} }
handleBackdropClick(event) { handleBackdropClick(event) {
if (event.target.className == "dialog") { if (event.target.className === "dialog") {
this.dismiss(); this.dismiss();
} }
} }
handleKeyDown(event) { handleKeyDown(event) {
if (event.key == "Escape") { if (event.key === "Escape") {
this.dismiss(); this.dismiss();
} }
} }

View file

@ -18,7 +18,7 @@ export default class JoinForm extends Component {
handleInput(event) { handleInput(event) {
let target = event.target; let target = event.target;
let value = target.type == "checkbox" ? target.checked : target.value; let value = target.type === "checkbox" ? target.checked : target.value;
this.setState({ [target.name]: value }); this.setState({ [target.name]: value });
} }

View file

@ -37,7 +37,7 @@ export default class NetworkForm extends Component {
handleInput(event) { handleInput(event) {
let target = event.target; let target = event.target;
let value = target.type == "checkbox" ? target.checked : target.value; let value = target.type === "checkbox" ? target.checked : target.value;
this.setState({ [target.name]: value }); this.setState({ [target.name]: value });
} }
@ -46,10 +46,10 @@ export default class NetworkForm extends Component {
let params = {}; let params = {};
Object.keys(defaultParams).forEach((k) => { Object.keys(defaultParams).forEach((k) => {
if (!this.props.isNew && this.prevParams[k] == this.state[k]) { if (!this.props.isNew && this.prevParams[k] === this.state[k]) {
return; return;
} }
if (this.props.isNew && defaultParams[k] == this.state[k]) { if (this.props.isNew && defaultParams[k] === this.state[k]) {
return; return;
} }
params[k] = this.state[k]; params[k] = this.state[k];

View file

@ -15,7 +15,7 @@ export default class RegisterForm extends Component {
handleInput(event) { handleInput(event) {
let target = event.target; let target = event.target;
let value = target.type == "checkbox" ? target.checked : target.value; let value = target.type === "checkbox" ? target.checked : target.value;
this.setState({ [target.name]: value }); this.setState({ [target.name]: value });
} }

View file

@ -48,13 +48,13 @@ export default class ScrollManager extends Component {
} }
} }
if (target.scrollTop == 0) { if (target.scrollTop === 0) {
this.props.onScrollTop(); this.props.onScrollTop();
} }
} }
handleScroll() { handleScroll() {
if (this.props.target.current.scrollTop == 0) { if (this.props.target.current.scrollTop === 0) {
this.props.onScrollTop(); this.props.onScrollTop();
} }
} }

View file

@ -15,7 +15,7 @@ export default class SettingsForm extends Component {
handleInput(event) { handleInput(event) {
let target = event.target; let target = event.target;
let value = target.type == "checkbox" ? target.checked : target.value; let value = target.type === "checkbox" ? target.checked : target.value;
this.setState({ [target.name]: value }, () => { this.setState({ [target.name]: value }, () => {
this.props.onChange(this.state); this.props.onChange(this.state);
}); });

View file

@ -15,7 +15,7 @@ export default class RegisterForm extends Component {
handleInput(event) { handleInput(event) {
let target = event.target; let target = event.target;
let value = target.type == "checkbox" ? target.checked : target.value; let value = target.type === "checkbox" ? target.checked : target.value;
this.setState({ [target.name]: value }); this.setState({ [target.name]: value });
} }

View file

@ -23,6 +23,7 @@ export default [
destructuredArrayIgnorePattern: "^_", destructuredArrayIgnorePattern: "^_",
}], }],
"no-var": "error", "no-var": "error",
"eqeqeq": "error",
"@stylistic/js/indent": ["warn", "tab"], "@stylistic/js/indent": ["warn", "tab"],
"@stylistic/js/quotes": ["warn", "double"], "@stylistic/js/quotes": ["warn", "double"],
"@stylistic/js/semi": "warn", "@stylistic/js/semi": "warn",

View file

@ -121,9 +121,9 @@ export function setup(app) {
return; return;
} }
candidates = candidates.filter((binding) => { candidates = candidates.filter((binding) => {
return !!binding.altKey == event.altKey && !!binding.ctrlKey == event.ctrlKey; return !!binding.altKey === event.altKey && !!binding.ctrlKey === event.ctrlKey;
}); });
if (candidates.length != 1) { if (candidates.length !== 1) {
return; return;
} }
event.preventDefault(); event.preventDefault();

View file

@ -51,7 +51,7 @@ export function strip(text) {
if (isDigit(text[i + 1])) { if (isDigit(text[i + 1])) {
i++; i++;
} }
if (text[i + 1] == "," && isDigit(text[i + 2])) { if (text[i + 1] === "," && isDigit(text[i + 2])) {
i += 2; i += 2;
if (isDigit(text[i + 1])) { if (isDigit(text[i + 1])) {
i++; i++;
@ -63,7 +63,7 @@ export function strip(text) {
break; break;
} }
i += HEX_COLOR_LENGTH; i += HEX_COLOR_LENGTH;
if (text[i + 1] == "," && isHexColor(text.slice(i + 2))) { if (text[i + 1] === "," && isHexColor(text.slice(i + 2))) {
i += 1 + HEX_COLOR_LENGTH; i += 1 + HEX_COLOR_LENGTH;
} }
break; break;

View file

@ -25,12 +25,12 @@ export function encode(data) {
out += alphabet[u24 & 0x3F]; out += alphabet[u24 & 0x3F];
} }
if (trailing == 1) { if (trailing === 1) {
let u8 = bytes[bytes.length - 1]; let u8 = bytes[bytes.length - 1];
out += alphabet[u8 >> 2]; out += alphabet[u8 >> 2];
out += alphabet[(u8 << 4) & 0x3F]; out += alphabet[(u8 << 4) & 0x3F];
out += "=="; out += "==";
} else if (trailing == 2) { } else if (trailing === 2) {
let u16 = (bytes[bytes.length - 2] << 8) + bytes[bytes.length - 1]; let u16 = (bytes[bytes.length - 2] << 8) + bytes[bytes.length - 1];
out += alphabet[u16 >> 10]; out += alphabet[u16 >> 10];
out += alphabet[(u16 >> 4) & 0x3F]; out += alphabet[(u16 >> 4) & 0x3F];

View file

@ -354,7 +354,7 @@ export default class Client extends EventTarget {
case "AUTHENTICATE": case "AUTHENTICATE":
// Both PLAIN and EXTERNAL expect an empty challenge // Both PLAIN and EXTERNAL expect an empty challenge
let challengeStr = msg.params[0]; let challengeStr = msg.params[0];
if (challengeStr != "+") { if (challengeStr !== "+") {
this.dispatchError(new Error("Expected an empty challenge, got: " + challengeStr)); this.dispatchError(new Error("Expected an empty challenge, got: " + challengeStr));
this.send({ command: "AUTHENTICATE", params: ["*"] }); this.send({ command: "AUTHENTICATE", params: ["*"] });
} }
@ -425,7 +425,7 @@ export default class Client extends EventTarget {
case irc.ERR_NOPERMFORHOST: case irc.ERR_NOPERMFORHOST:
case irc.ERR_YOUREBANNEDCREEP: case irc.ERR_YOUREBANNEDCREEP:
this.dispatchError(new IRCError(msg)); this.dispatchError(new IRCError(msg));
if (this.status != Client.Status.REGISTERED) { if (this.status !== Client.Status.REGISTERED) {
this.disconnect(); this.disconnect();
} }
break; break;
@ -656,7 +656,7 @@ export default class Client extends EventTarget {
switch (subCmd) { switch (subCmd) {
case "LS": case "LS":
this.supportsCap = true; this.supportsCap = true;
if (args[0] == "*") { if (args[0] === "*") {
break; break;
} }
@ -728,7 +728,7 @@ export default class Client extends EventTarget {
} }
isMyNick(nick) { isMyNick(nick) {
return this.cm(nick) == this.cm(this.nick); return this.cm(nick) === this.cm(this.nick);
} }
isChannel(name) { isChannel(name) {
@ -775,7 +775,7 @@ export default class Client extends EventTarget {
let msg = event.detail.message; let msg = event.detail.message;
let msgLabel = irc.getMessageLabel(msg); let msgLabel = irc.getMessageLabel(msg);
if (msgLabel && msgLabel != label) { if (msgLabel && msgLabel !== label) {
return; return;
} }

View file

@ -120,7 +120,7 @@ export function parseTags(s) {
let parts = s.split("=", 2); let parts = s.split("=", 2);
let k = parts[0]; let k = parts[0];
let v = null; let v = null;
if (parts.length == 2) { if (parts.length === 2) {
v = unescapeTag(parts[1]); v = unescapeTag(parts[1]);
if (v.endsWith("\\")) { if (v.endsWith("\\")) {
v = v.slice(0, v.length - 1); v = v.slice(0, v.length - 1);
@ -315,13 +315,13 @@ function isURIPrefix(text) {
} }
export function isHighlight(msg, nick, cm) { export function isHighlight(msg, nick, cm) {
if (msg.command != "PRIVMSG" && msg.command != "NOTICE") { if (msg.command !== "PRIVMSG" && msg.command !== "NOTICE") {
return false; return false;
} }
nick = cm(nick); nick = cm(nick);
if (msg.prefix && cm(msg.prefix.name) == nick) { if (msg.prefix && cm(msg.prefix.name) === nick) {
return false; // Our own messages aren't highlights return false; // Our own messages aren't highlights
} }
@ -349,7 +349,7 @@ export function isHighlight(msg, nick, cm) {
} }
export function isServerBroadcast(msg) { export function isServerBroadcast(msg) {
if (msg.command != "PRIVMSG" && msg.command != "NOTICE") { if (msg.command !== "PRIVMSG" && msg.command !== "NOTICE") {
return false; return false;
} }
return msg.params[0].startsWith("$"); return msg.params[0].startsWith("$");
@ -387,7 +387,7 @@ export function formatDate(date) {
} }
export function parseCTCP(msg) { export function parseCTCP(msg) {
if (msg.command != "PRIVMSG" && msg.command != "NOTICE") { if (msg.command !== "PRIVMSG" && msg.command !== "NOTICE") {
return null; return null;
} }
@ -507,7 +507,7 @@ export class Isupport {
return stdChanModes; return stdChanModes;
} }
let chanModes = this.raw.get("CHANMODES").split(","); let chanModes = this.raw.get("CHANMODES").split(",");
if (chanModes.length != 4) { if (chanModes.length !== 4) {
console.error("Invalid CHANMODES: ", this.raw.get("CHANMODES")); console.error("Invalid CHANMODES: ", this.raw.get("CHANMODES"));
return stdChanModes; return stdChanModes;
} }
@ -572,13 +572,13 @@ export const CaseMapping = {
let ch = str[i]; let ch = str[i];
if ("A" <= ch && ch <= "Z") { if ("A" <= ch && ch <= "Z") {
ch = ch.toLowerCase(); ch = ch.toLowerCase();
} else if (ch == "{") { } else if (ch === "{") {
ch = "["; ch = "[";
} else if (ch == "}") { } else if (ch === "}") {
ch = "]"; ch = "]";
} else if (ch == "\\") { } else if (ch === "\\") {
ch = "|"; ch = "|";
} else if (ch == "~") { } else if (ch === "~") {
ch = "^"; ch = "^";
} }
out += ch; out += ch;
@ -592,11 +592,11 @@ export const CaseMapping = {
let ch = str[i]; let ch = str[i];
if ("A" <= ch && ch <= "Z") { if ("A" <= ch && ch <= "Z") {
ch = ch.toLowerCase(); ch = ch.toLowerCase();
} else if (ch == "{") { } else if (ch === "{") {
ch = "["; ch = "[";
} else if (ch == "}") { } else if (ch === "}") {
ch = "]"; ch = "]";
} else if (ch == "\\") { } else if (ch === "\\") {
ch = "|"; ch = "|";
} }
out += ch; out += ch;

View file

@ -136,19 +136,19 @@ function updateState(state, updater) {
} }
function isServerBuffer(buf) { function isServerBuffer(buf) {
return buf.type == BufferType.SERVER; return buf.type === BufferType.SERVER;
} }
/* Returns 1 if a should appear after b, -1 if a should appear before b, or /* Returns 1 if a should appear after b, -1 if a should appear before b, or
* 0 otherwise. */ * 0 otherwise. */
function compareBuffers(a, b) { function compareBuffers(a, b) {
if (a.server != b.server) { if (a.server !== b.server) {
return a.server > b.server ? 1 : -1; return a.server > b.server ? 1 : -1;
} }
if (isServerBuffer(a) != isServerBuffer(b)) { if (isServerBuffer(a) !== isServerBuffer(b)) {
return isServerBuffer(b) ? 1 : -1; return isServerBuffer(b) ? 1 : -1;
} }
if (a.name != b.name) { if (a.name !== b.name) {
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
} }
return 0; return 0;
@ -178,7 +178,7 @@ function updateMembership(membership, letter, add, client) {
/* Insert a message in an immutable list of sorted messages. */ /* Insert a message in an immutable list of sorted messages. */
function insertMessage(list, msg) { function insertMessage(list, msg) {
if (list.length == 0) { if (list.length === 0) {
return [msg]; return [msg];
} else if (!irc.findBatchByType(msg, "chathistory") || list[list.length - 1].tags.time <= msg.tags.time) { } else if (!irc.findBatchByType(msg, "chathistory") || list[list.length - 1].tags.time <= msg.tags.time) {
return list.concat(msg); return list.concat(msg);
@ -318,7 +318,7 @@ export const State = {
let id = lastBufferID; let id = lastBufferID;
let type; let type;
if (name == SERVER_BUFFER) { if (name === SERVER_BUFFER) {
type = BufferType.SERVER; type = BufferType.SERVER;
} else if (client.isChannel(name)) { } else if (client.isChannel(name)) {
type = BufferType.CHANNEL; type = BufferType.CHANNEL;
@ -394,7 +394,7 @@ export const State = {
case irc.RPL_ISUPPORT: case irc.RPL_ISUPPORT:
buffers = new Map(state.buffers); buffers = new Map(state.buffers);
state.buffers.forEach((buf) => { state.buffers.forEach((buf) => {
if (buf.server != serverID) { if (buf.server !== serverID) {
return; return;
} }
let members = new irc.CaseMapMap(buf.members, client.cm); let members = new irc.CaseMapMap(buf.members, client.cm);
@ -454,7 +454,7 @@ export const State = {
}); });
case irc.RPL_ENDOFWHO: case irc.RPL_ENDOFWHO:
target = msg.params[1]; target = msg.params[1];
if (msg.list.length == 0 && !client.isChannel(target) && target.indexOf("*") < 0) { if (msg.list.length === 0 && !client.isChannel(target) && target.indexOf("*") < 0) {
// Not a channel nor a mask, likely a nick // Not a channel nor a mask, likely a nick
return updateUser(target, (user) => { return updateUser(target, (user) => {
return { offline: true }; return { offline: true };
@ -544,7 +544,7 @@ export const State = {
case "QUIT": case "QUIT":
buffers = new Map(state.buffers); buffers = new Map(state.buffers);
state.buffers.forEach((buf) => { state.buffers.forEach((buf) => {
if (buf.server != serverID) { if (buf.server !== serverID) {
return; return;
} }
if (!buf.members.has(msg.prefix.name)) { if (!buf.members.has(msg.prefix.name)) {
@ -570,7 +570,7 @@ export const State = {
buffers = new Map(state.buffers); buffers = new Map(state.buffers);
state.buffers.forEach((buf) => { state.buffers.forEach((buf) => {
if (buf.server != serverID) { if (buf.server !== serverID) {
return; return;
} }
if (!buf.members.has(msg.prefix.name)) { if (!buf.members.has(msg.prefix.name)) {
@ -648,7 +648,7 @@ export const State = {
for (let target of targets) { for (let target of targets) {
let prefix = irc.parsePrefix(target); let prefix = irc.parsePrefix(target);
let update = updateUser(prefix.name, { offline: msg.command == irc.RPL_MONOFFLINE }); let update = updateUser(prefix.name, { offline: msg.command === irc.RPL_MONOFFLINE });
state = { ...state, ...update }; state = { ...state, ...update };
} }