3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

chore: fix lint errors; tweak lint rules

This commit is contained in:
Dragory 2023-05-08 22:58:51 +03:00
parent 9b3d6f5d68
commit 5f194bf1ef
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
115 changed files with 176 additions and 264 deletions

View file

@ -31,7 +31,7 @@ export class MessageBuffer {
protected timeoutMs: number | null = null;
protected textSeparator: string = "";
protected textSeparator = "";
protected chunk: Chunk | null = null;

View file

@ -15,7 +15,7 @@ export async function asyncReduce<T, V>(
arrayToIterate = arr.slice(1);
}
for (const [i, currentValue] of arr.entries()) {
for (const [i, currentValue] of arrayToIterate.entries()) {
accumulator = await callback(accumulator, currentValue, i, arr);
}

View file

@ -6,17 +6,14 @@ type CategoryReturnType<T, C extends Categories<T>> = {
[key in keyof C]: T[];
};
function initCategories<T extends unknown, C extends Categories<T>>(categories: C): CategoryReturnType<T, C> {
function initCategories<T, C extends Categories<T>>(categories: C): CategoryReturnType<T, C> {
return Object.keys(categories).reduce((map, key) => {
map[key] = [];
return map;
}, {}) as CategoryReturnType<T, C>;
}
export function categorize<T extends unknown, C extends Categories<T>>(
arr: T[],
categories: C,
): CategoryReturnType<T, C> {
export function categorize<T, C extends Categories<T>>(arr: T[], categories: C): CategoryReturnType<T, C> {
const result = initCategories<T, C>(categories);
const categoryEntries = Object.entries(categories);

View file

@ -5,7 +5,7 @@ export async function encryptJson(obj: any): Promise<string> {
return encrypt(serialized);
}
export async function decryptJson<T extends unknown>(encrypted: string): Promise<T> {
export async function decryptJson(encrypted: string): Promise<unknown> {
const decrypted = await decrypt(encrypted);
return JSON.parse(decrypted);
}

View file

@ -1,7 +1,7 @@
import { EmbedField } from "discord.js";
import { chunkMessageLines, emptyEmbedValue } from "../utils";
export function getChunkedEmbedFields(name: string, value: string, inline?: boolean): EmbedField[] {
export function getChunkedEmbedFields(name: string, value: string): EmbedField[] {
const fields: EmbedField[] = [];
const chunks = chunkMessageLines(value, 1014);

View file

@ -12,7 +12,7 @@ export function getMissingPermissions(
const allowedPermissions = resolvedPermissions;
const nRequiredPermissions = requiredPermissions;
if (Boolean(allowedPermissions.bitfield & PermissionsBitField.Flags.Administrator)) {
if (allowedPermissions.bitfield & PermissionsBitField.Flags.Administrator) {
return BigInt(0);
}

View file

@ -17,5 +17,5 @@ export function hasDiscordPermissions(
}
const nRequiredPermissions = BigInt(requiredPermissions);
return Boolean((resolvedPermissions?.bitfield! & nRequiredPermissions) === nRequiredPermissions);
return Boolean((resolvedPermissions.bitfield! & nRequiredPermissions) === nRequiredPermissions);
}

View file

@ -2,7 +2,7 @@ import { MessageCreateOptions } from "discord.js";
import { StrictMessageContent } from "../utils.js";
function embedHasContent(embed: any) {
for (const [key, value] of Object.entries(embed)) {
for (const [, value] of Object.entries(embed)) {
if (typeof value === "string" && value.trim() !== "") {
return true;
}

View file

@ -25,6 +25,6 @@ export function parseCustomId(customId: string): { namespace: string; data: any
return {
namespace: parts[1],
// Skipping timestamp
data: JSON.parse(parts[2]),
data: parsedData,
};
}

View file

@ -1,7 +1,7 @@
import escapeStringRegexp from "escape-string-regexp";
import moment from "moment-timezone";
const normalizeTzName = (str) => str.replace(/[^a-zA-Z0-9+\-]/g, "").toLowerCase();
const normalizeTzName = (str) => str.replace(/[^a-zA-Z0-9+-]/g, "").toLowerCase();
const validTimezones = moment.tz.names();
const normalizedTimezoneMap = validTimezones.reduce((map, tz) => {

View file

@ -3,7 +3,7 @@ import { GuildPluginData } from "knub";
import { getChannelIdFromMessageId } from "../data/getChannelIdFromMessageId";
import { isSnowflake } from "../utils";
const channelAndMessageIdRegex = /^(\d+)[\-\/](\d+)$/;
const channelAndMessageIdRegex = /^(\d+)[-/](\d+)$/;
const messageLinkRegex = /^https:\/\/(?:\w+\.)?discord(?:app)?\.com\/channels\/\d+\/(\d+)\/(\d+)$/i;
export interface MessageTarget {

View file

@ -5,12 +5,12 @@ export class ObjectAliasError extends Error {}
/**
* Removes object aliases/anchors from a loaded YAML object
*/
export function validateNoObjectAliases<T extends {}>(obj: T, seen?: WeakSet<any>): void {
export function validateNoObjectAliases<T extends object>(obj: T, seen?: WeakSet<any>): void {
if (!seen) {
seen = new WeakSet();
}
for (const [key, value] of Object.entries(obj)) {
for (const [, value] of Object.entries(obj)) {
if (value == null || scalarTypes.includes(typeof value)) {
continue;
}
@ -19,7 +19,7 @@ export function validateNoObjectAliases<T extends {}>(obj: T, seen?: WeakSet<any
throw new ObjectAliasError("Object aliases are not allowed");
}
validateNoObjectAliases(value as {}, seen);
validateNoObjectAliases(value, seen);
seen.add(value);
}
}