fix(eslint): now is activated and normed using ts comparaison

This commit is contained in:
Raphael 2025-08-18 14:45:46 +02:00
parent 11befcbad4
commit 561d3e92a6
14 changed files with 122 additions and 145 deletions

View file

@ -1,2 +1,2 @@
#!/usr/bin/env sh #!/usr/bin/env sh
bunx prettier --write . ; bunx eslint --fix . bunx lint-staged

View file

@ -1,53 +1,55 @@
import js from '@eslint/js'; import js from "@eslint/js";
import ts from "typescript-eslint";
export default [ export default [
js.configs.recommended, js.configs.recommended,
...ts.configs.recommended,
{ {
languageOptions: { languageOptions: {
ecmaVersion: 'latest', ecmaVersion: "latest",
}, },
rules: { rules: {
'arrow-spacing': ['warn', { before: true, after: true }], "arrow-spacing": ["warn", { before: true, after: true }],
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }], "brace-style": ["error", "stroustrup", { allowSingleLine: true }],
'comma-dangle': ['error', 'always-multiline'], "comma-dangle": ["error", "always-multiline"],
'comma-spacing': 'error', "comma-spacing": "error",
'comma-style': 'error', "comma-style": "error",
curly: ['error', 'multi-line', 'consistent'], curly: ["error", "multi-line", "consistent"],
'dot-location': ['error', 'property'], "dot-location": ["error", "property"],
'handle-callback-err': 'off', "handle-callback-err": "off",
indent: ['error', 'tab'], indent: ["error", "tab"],
'keyword-spacing': 'error', "keyword-spacing": "error",
'max-nested-callbacks': ['error', { max: 4 }], "max-nested-callbacks": ["error", { max: 4 }],
'max-statements-per-line': ['error', { max: 2 }], "max-statements-per-line": ["error", { max: 2 }],
'no-console': 'off', "no-console": "off",
'no-empty-function': 'error', "no-empty-function": "error",
'no-floating-decimal': 'error', "no-floating-decimal": "error",
'no-inline-comments': 'error', "no-inline-comments": "error",
'no-lonely-if': 'error', "no-lonely-if": "error",
'no-multi-spaces': 'error', "no-multi-spaces": "error",
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1, maxBOF: 0 }], "no-multiple-empty-lines": ["error", { max: 2, maxEOF: 1, maxBOF: 0 }],
'no-shadow': ['error', { allow: ['err', 'resolve', 'reject'] }], "no-shadow": ["error", { allow: ["err", "resolve", "reject"] }],
'no-trailing-spaces': ['error'], "no-trailing-spaces": ["error"],
'no-var': 'error', "no-var": "error",
'no-undef': 'off', "no-undef": "off",
'object-curly-spacing': ['error', 'always'], "object-curly-spacing": ["error", "always"],
'prefer-const': 'error', "prefer-const": "error",
quotes: ['error', 'single'], quotes: ["error", "single"],
semi: ['error', 'always'], semi: ["error", "always"],
'space-before-blocks': 'error', "space-before-blocks": "error",
'space-before-function-paren': [ "space-before-function-paren": [
'error', "error",
{ {
anonymous: 'never', anonymous: "never",
named: 'never', named: "never",
asyncArrow: 'always', asyncArrow: "always",
}, },
], ],
'space-in-parens': 'error', "space-in-parens": "error",
'space-infix-ops': 'error', "space-infix-ops": "error",
'space-unary-ops': 'error', "space-unary-ops": "error",
'spaced-comment': 'error', "spaced-comment": "error",
yoda: 'error', yoda: "error",
}, },
}, },
]; ];

View file

@ -8,12 +8,25 @@
"prepare": "husky" "prepare": "husky"
}, },
"private": true, "private": true,
"lint-staged": {
"*.{ts,js,cts,mts}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md,yml,yaml}": [
"prettier --write"
]
},
"devDependencies": { "devDependencies": {
"@types/bun": "latest", "@types/bun": "latest",
"eslint": "^9.33.0", "eslint": "^9.33.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"husky": "^9.1.7", "husky": "^9.1.7",
"lint-staged": "^16.1.5", "lint-staged": "^16.1.5",
"prisma": "^6.14.0" "prettier": "^3.6.2",
"prisma": "^6.14.0",
"typescript-eslint": "^8.39.1"
}, },
"peerDependencies": { "peerDependencies": {
"typescript": "^5.8.3" "typescript": "^5.8.3"

View file

@ -8,10 +8,6 @@ import {
StringSelectMenuInteraction, StringSelectMenuInteraction,
StringSelectMenuOptionBuilder, StringSelectMenuOptionBuilder,
SlashCommandBuilder, SlashCommandBuilder,
ChatInputCommandInteractionActivityType,
channelMention,
roleMention,
PresenceUpdateStatus,
MessageFlags, MessageFlags,
SlashCommandBuilder, SlashCommandBuilder,
EmbedBuilder, EmbedBuilder,
@ -77,7 +73,14 @@ export default {
} }
const choice: string = interaction.options.getString("action"); const choice: string = interaction.options.getString("action");
switch (choice) { switch (choice) {
case "logs_show": case "logs_show": {
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
flags: MessageFlags.Ephemeral,
});
return;
}
if (guildData.logEnable) { if (guildData.logEnable) {
const logsData: EmbedBuilder = new EmbedBuilder() const logsData: EmbedBuilder = new EmbedBuilder()
.setTitle(`Logs for ${interaction.guild.name}`) .setTitle(`Logs for ${interaction.guild.name}`)
@ -104,7 +107,15 @@ export default {
}); });
} }
return; return;
case "logs_auto": }
case "logs_auto": {
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
flags: MessageFlags.Ephemeral,
});
return;
}
if (guildData.logEnable) { if (guildData.logEnable) {
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | The log is already setup on this server`, content: `${emoji.answer.error} | The log is already setup on this server`,
@ -133,8 +144,8 @@ export default {
const roleSelection = const roleSelection =
new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(menu); new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(menu);
let permSelector: EmbedBuilder = new EmbedBuilder() const permSelector: EmbedBuilder = new EmbedBuilder()
.setTitle(`Which role will have access`) .setTitle("Which role will have access")
.setColor(`${guildData.color}`) .setColor(`${guildData.color}`)
.setFooter({ .setFooter({
text: guildData.footer, text: guildData.footer,
@ -242,7 +253,7 @@ export default {
.map((id) => `- <@&${id}>`) .map((id) => `- <@&${id}>`)
.join("\n"); .join("\n");
const autoConfig = new EmbedBuilder() const autoConfig = new EmbedBuilder()
.setTitle(`The logs category is created`) .setTitle("The logs category is created")
.setDescription( .setDescription(
` `
This following roles will have access to the logs. This following roles will have access to the logs.
@ -260,6 +271,8 @@ export default {
return; return;
}, },
); );
break;
}
default: default:
console.error(`no choice on logs command ${choice}`); console.error(`no choice on logs command ${choice}`);
return; return;

View file

@ -1,12 +1,9 @@
import { prisma } from "../../lib/prisma.ts"; import { prisma } from "../../lib/prisma.ts";
import { import {
ActivityType, ActivityType,
userMention,
roleMention,
PresenceUpdateStatus, PresenceUpdateStatus,
MessageFlags, MessageFlags,
SlashCommandBuilder, SlashCommandBuilder,
EmbedBuilder,
} from "discord.js"; } from "discord.js";
import emoji from "../../../assets/emoji.json" assert { type: "json" }; import emoji from "../../../assets/emoji.json" assert { type: "json" };
@ -111,23 +108,6 @@ export default {
), ),
), ),
async execute(interaction: CommandInteraction) { async execute(interaction: CommandInteraction) {
let guildData: Guild;
try {
guildData = await prisma.guild.findUnique({
where: {
id: interaction.guild.id,
},
});
} catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
await interaction.reply({
content: `${emoji.answer.error} | Cannot connect to the database`,
flags: MessageFlags.Ephemeral,
});
return;
}
let userData: User; let userData: User;
try { try {
userData = await prisma.user.findUnique({ userData = await prisma.user.findUnique({
@ -147,7 +127,7 @@ export default {
} }
const subcommand: string = interaction.options.getSubcommand(); const subcommand: string = interaction.options.getSubcommand();
switch (subcommand) { switch (subcommand) {
case "color": case "color": {
if (!userData.isOwner) { if (!userData.isOwner) {
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`, content: `${emoji.answer.no} | This command is only for owner`,
@ -180,7 +160,8 @@ export default {
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
}); });
return; return;
case "footer": }
case "footer": {
if (!userData.isOwner) { if (!userData.isOwner) {
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`, content: `${emoji.answer.no} | This command is only for owner`,
@ -213,7 +194,8 @@ export default {
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
}); });
return; return;
case "pp": }
case "pp": {
if (!userData.isBuyer) { if (!userData.isBuyer) {
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.no} | This command is only for buyer`, content: `${emoji.answer.no} | This command is only for buyer`,
@ -229,13 +211,17 @@ export default {
content: `${emoji.answer.no} | Error during changing the bot profile picture`, content: `${emoji.answer.no} | Error during changing the bot profile picture`,
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
}); });
console.error(
`\t⚠ | Cannot change the bot profile picture!\n\t\t(${err}).`,
);
} }
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.yes} | The picture profile of the bot is now updated.`, content: `${emoji.answer.yes} | The picture profile of the bot is now updated.`,
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
}); });
return; return;
case "status": }
case "status": {
if (!userData.isBuyer) { if (!userData.isBuyer) {
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.no} | This command is only for buyer`, content: `${emoji.answer.no} | This command is only for buyer`,
@ -331,5 +317,6 @@ export default {
}); });
return; return;
} }
}
}, },
}; };

View file

@ -1,9 +1,4 @@
import { import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
EmbedBuilder,
userMention,
MessageFlags,
SlashCommandBuilder,
} from "discord.js";
import { prisma } from "../../lib/prisma.ts"; import { prisma } from "../../lib/prisma.ts";
import emoji from "../../../assets/emoji.json" assert { type: "json" }; import emoji from "../../../assets/emoji.json" assert { type: "json" };
@ -116,7 +111,7 @@ export default {
}); });
} catch (err) { } catch (err) {
console.error( console.error(
`⚠️ | Error when adding ${target.username} to the buyer list`, `⚠️ | Error when adding ${target.username} to the buyer list\n\t${err}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Error when adding ${target.username} to the owner list`, content: `${emoji.answer.error} | Error when adding ${target.username} to the owner list`,
@ -177,7 +172,7 @@ export default {
}); });
} catch (err) { } catch (err) {
console.error( console.error(
`⚠️ | Error when removing ${target.username} to the username`, `⚠️ | Error when removing ${target.username} to the buyer list\n\t${err}`,
); );
return; return;
} }

View file

@ -1,9 +1,4 @@
import { import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
EmbedBuilder,
userMention,
MessageFlags,
SlashCommandBuilder,
} from "discord.js";
import { prisma } from "../../lib/prisma.ts"; import { prisma } from "../../lib/prisma.ts";
import emoji from "../../../assets/emoji.json" assert { type: "json" }; import emoji from "../../../assets/emoji.json" assert { type: "json" };
@ -109,7 +104,7 @@ export default {
}); });
} catch (err) { } catch (err) {
console.error( console.error(
`⚠️ | Error when adding ${target.username} to the username`, `⚠️ | Error when adding ${target.username} to the owner list\n\t${err}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Error when adding ${target.username} to the owner list`, content: `${emoji.answer.error} | Error when adding ${target.username} to the owner list`,
@ -163,7 +158,7 @@ export default {
}); });
} catch (err) { } catch (err) {
console.error( console.error(
`⚠️ | Error when removing ${target.username} to the username`, `⚠️ | Error when removing ${target.username} to the owner list\n\t${err}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot removing the user from the owner list`, content: `${emoji.answer.error} | Cannot removing the user from the owner list`,

View file

@ -1,9 +1,4 @@
import { import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
EmbedBuilder,
userMention,
MessageFlags,
SlashCommandBuilder,
} from "discord.js";
import { prisma } from "../../lib/prisma.ts"; import { prisma } from "../../lib/prisma.ts";
import emoji from "../../../assets/emoji.json" assert { type: "json" }; import emoji from "../../../assets/emoji.json" assert { type: "json" };
@ -223,7 +218,7 @@ export default {
); );
const toSend: EmbedBuilder = new EmbedBuilder() const toSend: EmbedBuilder = new EmbedBuilder()
.setTitle(`🗞️ | Whitelist`) .setTitle("🗞️ | Whitelist")
.setColor(guildData.color) .setColor(guildData.color)
.setFooter({ .setFooter({
text: guildData.footer, text: guildData.footer,

View file

@ -1,11 +1,4 @@
import { import { MessageFlags, ChannelType, SlashCommandBuilder } from "discord.js";
MessageFlags,
ChatInputCommandInteraction,
CategoryChannel,
ChannelType,
PermissionsBitField,
SlashCommandBuilder,
} from "discord.js";
import emoji from "../../../assets/emoji.json" assert { type: "json" }; import emoji from "../../../assets/emoji.json" assert { type: "json" };
import { prisma } from "../../lib/prisma.ts"; import { prisma } from "../../lib/prisma.ts";

View file

@ -84,7 +84,7 @@ export default {
} }
const subcommand: string = interaction.options.getSubcommand(); const subcommand: string = interaction.options.getSubcommand();
switch (subcommand) { switch (subcommand) {
case "user": case "user": {
const targetGlobal: GuildMember = const targetGlobal: GuildMember =
interaction.options.getUser("target") || interaction.user; interaction.options.getUser("target") || interaction.user;
await targetGlobal.fetch(); await targetGlobal.fetch();
@ -151,7 +151,8 @@ export default {
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
}); });
return; return;
case "server": }
case "server": {
const guild: Guild = interaction.guild; const guild: Guild = interaction.guild;
const serverResult: EmbedBuilder = new EmbedBuilder() const serverResult: EmbedBuilder = new EmbedBuilder()
.setTitle(`${guild.name} Informations`) .setTitle(`${guild.name} Informations`)
@ -191,5 +192,6 @@ export default {
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
}); });
} }
}
}, },
}; };

View file

@ -1,17 +1,9 @@
import { Events, MessageFlags } from "discord.js"; import { Events } from "discord.js";
import { prisma } from "../../lib/prisma.ts"; import { prisma } from "../../lib/prisma.ts";
export default { export default {
name: Events.GuildCreate, name: Events.GuildCreate,
async execute(guild, client) { async execute(guild) {
const botData = await prisma.bot.findUnique({
where: {
id: 1,
},
include: {
buyers: true,
},
});
await prisma.guild.upsert({ await prisma.guild.upsert({
where: { where: {
id: guild.id, id: guild.id,
@ -23,8 +15,7 @@ export default {
}); });
const members = await guild.members.fetch(); const members = await guild.members.fetch();
let i = 0; for (const [memberId] of members) {
for (const [memberId, member] of members) {
await prisma.user.upsert({ await prisma.user.upsert({
where: { where: {
id: memberId, id: memberId,

View file

@ -6,8 +6,7 @@ export default {
once: true, once: true,
async execute(client) { async execute(client) {
try { try {
let botData: Bot; const botData: Bot = await prisma.bot.findUnique({
botData = await prisma.bot.findUnique({
where: { where: {
id: 1, id: 1,
}, },

View file

@ -3,7 +3,6 @@ import path from "node:path";
import "dotenv/config"; import "dotenv/config";
import { Client, Collection, GatewayIntentBits } from "discord.js"; import { Client, Collection, GatewayIntentBits } from "discord.js";
import { PrismaClient } from "@prisma/client"; import { PrismaClient } from "@prisma/client";
import { deployCommands } from "./internal/deploy-commands.ts";
const prisma = new PrismaClient(); const prisma = new PrismaClient();
@ -23,7 +22,7 @@ client.commands = new Collection();
const commandFolderPath = path.join(__dirname, "commands"); const commandFolderPath = path.join(__dirname, "commands");
const commandFolders = fs.readdirSync(commandFolderPath); const commandFolders = fs.readdirSync(commandFolderPath);
console.log(`\n🔍 | Commands search:`); console.log("\n🔍 | Commands search:");
for (const folder of commandFolders) { for (const folder of commandFolders) {
const commandsPath = path.join(commandFolderPath, folder); const commandsPath = path.join(commandFolderPath, folder);
const commandFiles = fs const commandFiles = fs
@ -48,7 +47,7 @@ console.log("\n\n");
const eventFolderPath = path.join(__dirname, "events"); const eventFolderPath = path.join(__dirname, "events");
const eventFolders = fs.readdirSync(eventFolderPath); const eventFolders = fs.readdirSync(eventFolderPath);
console.log(`\n🔍 | Events search:`); console.log("\n🔍 | Events search:");
for (const folder of eventFolders) { for (const folder of eventFolders) {
const eventsPath = path.join(eventFolderPath, folder); const eventsPath = path.join(eventFolderPath, folder);
const eventFiles = fs const eventFiles = fs
@ -97,7 +96,7 @@ client.once("ready", async () => {
const members = await guild.members.fetch(); const members = await guild.members.fetch();
for (const [memberId, member] of members) { for (const [memberId] of members) {
await prisma.user.upsert({ await prisma.user.upsert({
where: { where: {
id: memberId, id: memberId,

View file

@ -1,12 +1,5 @@
import { REST, Routes } from "discord.js"; import { REST, Routes } from "discord.js";
import { pathToFileURL } from "node:url"; import { Client, Collection, GatewayIntentBits } from "discord.js";
import {
Client,
Collection,
Events,
GatewayIntentBits,
MessageFlags,
} from "discord.js";
import "dotenv/config"; import "dotenv/config";
import fs from "node:fs"; import fs from "node:fs";
import path from "node:path"; import path from "node:path";
@ -35,7 +28,7 @@ for (const folder of commandFolders) {
commands.push(command.data.toJSON()); commands.push(command.data.toJSON());
} else { } else {
console.log( console.log(
`⚠️ | A Command is missing a required "data" or "execute" property.`, '⚠️ | A Command is missing a required "data" or "execute" property.',
); );
} }
} }