mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-18 22:26:35 +02:00
Replace as string with String constructor
This commit is contained in:
parent
c682550e1f
commit
4f41d80b88
|
@ -242,7 +242,7 @@ class Client {
|
|||
// Get channel id for lobby before creating other channels for nicer ids
|
||||
const lobbyChannelId = client.idChan++;
|
||||
|
||||
if (args.channels) {
|
||||
if (Array.isArray(args.channels)) {
|
||||
let badName = false;
|
||||
|
||||
args.channels.forEach((chan: Chan) => {
|
||||
|
@ -266,7 +266,7 @@ class Client {
|
|||
"User '" +
|
||||
client.name +
|
||||
"' on network '" +
|
||||
(args.name as string) +
|
||||
String(args.name) +
|
||||
"' has an invalid channel which has been ignored"
|
||||
);
|
||||
}
|
||||
|
@ -289,12 +289,12 @@ class Client {
|
|||
|
||||
// TODO; better typing for args
|
||||
const network = new Network({
|
||||
uuid: args.uuid as string,
|
||||
uuid: String(args.uuid),
|
||||
name: String(
|
||||
args.name || (Config.values.lockNetwork ? Config.values.defaults.name : "") || ""
|
||||
),
|
||||
host: String(args.host || ""),
|
||||
port: parseInt(args.port as string, 10),
|
||||
port: parseInt(String(args.port), 10),
|
||||
tls: !!args.tls,
|
||||
userDisconnected: !!args.userDisconnected,
|
||||
rejectUnauthorized: !!args.rejectUnauthorized,
|
||||
|
|
|
@ -61,7 +61,7 @@ program
|
|||
log.info("Package(s) have been successfully upgraded.");
|
||||
})
|
||||
.catch((code) => {
|
||||
log.error(`Failed to upgrade package(s). Exit code ${code as string}`);
|
||||
log.error(`Failed to upgrade package(s). Exit code ${String(code)}`);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -230,9 +230,9 @@ class Config {
|
|||
this.values.fileUpload.baseUrl = undefined;
|
||||
|
||||
log.warn(
|
||||
`The ${colors.bold("fileUpload.baseUrl")} you specified is invalid: ${
|
||||
e as string
|
||||
}`
|
||||
`The ${colors.bold("fileUpload.baseUrl")} you specified is invalid: ${String(
|
||||
e
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class User {
|
|||
|
||||
Object.defineProperty(this, "mode", {
|
||||
get() {
|
||||
return (this.modes[0] as string) || "";
|
||||
return String(this.modes[0]);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ function generateAndWrite(folderPath: string, paths: {privateKeyPath: any; certi
|
|||
|
||||
return certificate;
|
||||
} catch (e: any) {
|
||||
log.error("Unable to write certificate", e as string);
|
||||
log.error("Unable to write certificate", String(e));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import {PluginInputHandler} from "./index";
|
||||
import Msg, {MessageType} from "../../models/msg";
|
||||
import {ChanType} from "../../models/chan";
|
||||
import Chan, {ChanType} from "../../models/chan";
|
||||
|
||||
const commands = ["query", "msg", "say"];
|
||||
|
||||
function getTarget(cmd, args, chan) {
|
||||
function getTarget(cmd: string, args: string[], chan: Chan) {
|
||||
switch (cmd) {
|
||||
case "msg":
|
||||
case "query":
|
||||
|
|
|
@ -180,7 +180,7 @@ export default <IrcEventHandler>function (irc, network) {
|
|||
new Msg({
|
||||
text: `Disconnected from the network. Reconnecting in ${Math.round(
|
||||
data.wait / 1000
|
||||
)} seconds… (Attempt ${data.attempt})`,
|
||||
)} seconds… (Attempt ${Number(data.attempt)})`,
|
||||
}),
|
||||
true
|
||||
);
|
||||
|
|
|
@ -54,7 +54,7 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
|
|||
try {
|
||||
fs.mkdirSync(logsPath, {recursive: true});
|
||||
} catch (e: any) {
|
||||
log.error("Unable to create logs directory", e as string);
|
||||
log.error("Unable to create logs directory", String(e));
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class TextFileMessageStorage implements MessageStorage {
|
|||
try {
|
||||
fs.mkdirSync(logPath, {recursive: true});
|
||||
} catch (e: any) {
|
||||
log.error("Unable to create logs directory", e as string);
|
||||
log.error("Unable to create logs directory", String(e));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,9 +84,9 @@ class WebPush {
|
|||
WebPushAPI.sendNotification(subscription, JSON.stringify(payload)).catch((error) => {
|
||||
if (error.statusCode >= 400 && error.statusCode < 500) {
|
||||
log.warn(
|
||||
`WebPush subscription for ${client.name} returned an error (${
|
||||
error.statusCode as string
|
||||
}), removing subscription`
|
||||
`WebPush subscription for ${client.name} returned an error (${String(
|
||||
error.statusCode
|
||||
)}), removing subscription`
|
||||
);
|
||||
|
||||
_.forOwn(client.config.sessions, ({pushSubscription}, token) => {
|
||||
|
@ -98,7 +98,7 @@ class WebPush {
|
|||
return;
|
||||
}
|
||||
|
||||
log.error(`WebPush Error (${error as string})`);
|
||||
log.error(`WebPush Error (${String(error)})`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -344,7 +344,7 @@ function getClientIp(socket: Socket) {
|
|||
let ip = socket.handshake.address || "127.0.0.1";
|
||||
|
||||
if (Config.values.reverseProxy) {
|
||||
const forwarded = ((socket.handshake.headers["x-forwarded-for"] || "") as string)
|
||||
const forwarded = String(socket.handshake.headers["x-forwarded-for"])
|
||||
.split(/\s*,\s*/)
|
||||
.filter(Boolean);
|
||||
|
||||
|
|
1
src/types/modules/irc-framework.d.ts
vendored
1
src/types/modules/irc-framework.d.ts
vendored
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable no-use-before-define */
|
||||
// @ts-nocheck
|
||||
// eslint-disable
|
||||
|
||||
|
|
2
test/fixtures/.thelounge/sts-policies.json
vendored
2
test/fixtures/.thelounge/sts-policies.json
vendored
|
@ -3,6 +3,6 @@
|
|||
"host": "irc.example.com",
|
||||
"port": 7000,
|
||||
"duration": 3600,
|
||||
"expires": 1654034227268
|
||||
"expires": 1654034491040
|
||||
}
|
||||
]
|
||||
|
|
|
@ -178,7 +178,6 @@ describe("Network", function () {
|
|||
});
|
||||
|
||||
it("should apply STS policies iff they match", function () {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const client = {idMsg: 1, emit() {}} as any;
|
||||
STSPolicies.update("irc.example.com", 7000, 3600);
|
||||
|
||||
|
|
Loading…
Reference in a new issue