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

@ -51,7 +51,7 @@ export function strip(text) {
if (isDigit(text[i + 1])) {
i++;
}
if (text[i + 1] == "," && isDigit(text[i + 2])) {
if (text[i + 1] === "," && isDigit(text[i + 2])) {
i += 2;
if (isDigit(text[i + 1])) {
i++;
@ -63,7 +63,7 @@ export function strip(text) {
break;
}
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;
}
break;

View file

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

View file

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

View file

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