From a4eab091c78cab9c91e93c728aed25c4c5a39c7d Mon Sep 17 00:00:00 2001 From: supositware Date: Fri, 17 Jun 2022 02:14:14 +0200 Subject: [PATCH] fix eslint --- .eslintrc.json | 4 ++-- commands/reddit.js | 4 ++-- commands/vid2gif.js | 9 ++++++--- deploy-commands.cjs | 4 ++-- events/client/ready.js | 2 +- events/process/unhandledRejection.js | 6 +++--- index.js | 4 ++-- package.json | 2 ++ utils/videos.js | 2 +- 9 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8debef1..2252f48 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,9 +5,9 @@ "es6": true }, "parserOptions": { - "ecmaVersion": 2021 + "ecmaVersion": 2022, + "sourceType": "module" }, - "sourceType": "module", "rules": { "arrow-spacing": ["warn", { "before": true, "after": true }], "brace-style": ["error", "stroustrup", { "allowSingleLine": true }], diff --git a/commands/reddit.js b/commands/reddit.js index 6c91563..e16dc37 100644 --- a/commands/reddit.js +++ b/commands/reddit.js @@ -1,6 +1,6 @@ import { SlashCommandBuilder } from '@discordjs/builders'; import { MessageEmbed } from 'discord.js'; -import fetch from 'node-fetch' +import fetch from 'node-fetch'; export default { data: new SlashCommandBuilder() @@ -34,7 +34,7 @@ export default { .setURL('https://reddit.com' + response.data.children[i].data.permalink) .setFooter(`/r/${response.data.children[i].data.subreddit} | ⬆ ${response.data.children[i].data.ups} 🗨 ${response.data.children[i].data.num_comments}`); - interaction.editReply({ embeds: [redditEmbed]}); + interaction.editReply({ embeds: [redditEmbed] }); interaction.followUp(response.data.children[i].data.url); }); }, diff --git a/commands/vid2gif.js b/commands/vid2gif.js index 6595807..b8cb766 100644 --- a/commands/vid2gif.js +++ b/commands/vid2gif.js @@ -25,9 +25,12 @@ export default { const gifskiOutput = output.replace(path.extname(output), '.gif'); const gifsicleOutput = output.replace(path.extname(output), 'gifsicle.gif'); - await utils.ffmpeg(`-i ${output} ${os.tmpdir()}/frame${interaction.id}%04d.png`); // Extract every frame for gifski - await gifski(gifskiOutput, `${os.tmpdir()}/frame${interaction.id}*`); // Make it look better - await gifsicle(gifskiOutput, gifsicleOutput); // Optimize it + // Extract every frame for gifski + await utils.ffmpeg(`-i ${output} ${os.tmpdir()}/frame${interaction.id}%04d.png`); + // Make it look better + await gifski(gifskiOutput, `${os.tmpdir()}/frame${interaction.id}*`); + // Optimize it + await gifsicle(gifskiOutput, gifsicleOutput); const fileStat = fs.statSync(gifsicleOutput); const fileSize = fileStat.size / 1000000.0; diff --git a/deploy-commands.cjs b/deploy-commands.cjs index 49fb8ca..b45255b 100644 --- a/deploy-commands.cjs +++ b/deploy-commands.cjs @@ -44,8 +44,8 @@ const rest = new REST({ version: '9' }).setToken(token); if (process.argv[2] === 'global') { rest.put(Routes.applicationCommands(clientId), { body: commands }) - .then(() => console.log('Successfully registered application commands globally.')) - .catch(console.error); + .then(() => console.log('Successfully registered application commands globally.')) + .catch(console.error); } rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands }) diff --git a/events/client/ready.js b/events/client/ready.js index cd6b3c2..7baf732 100644 --- a/events/client/ready.js +++ b/events/client/ready.js @@ -1,6 +1,6 @@ import { exec } from 'node:child_process'; import https from 'node:https'; -import dotenv from 'dotenv' +import dotenv from 'dotenv'; dotenv.config(); const { uptimeURL, uptimeInterval } = process.env; diff --git a/events/process/unhandledRejection.js b/events/process/unhandledRejection.js index 86c2979..8f1d31b 100644 --- a/events/process/unhandledRejection.js +++ b/events/process/unhandledRejection.js @@ -2,6 +2,6 @@ export default { name: 'unhandledRejection', once: true, async execute(error) { - console.error('Unhandled promise rejection:', error); - } -} + console.error('Unhandled promise rejection:', error); + }, +}; diff --git a/index.js b/index.js index 61986d0..f017e05 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,8 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { Client, Collection, Intents } from 'discord.js'; -import dotenv from 'dotenv' -dotenv.config() +import dotenv from 'dotenv'; +dotenv.config(); const { token } = process.env; const __filename = fileURLToPath(import.meta.url); diff --git a/package.json b/package.json index c8fc9e0..eb81ac1 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "main": "index.js", "scripts": { "start": "node .", + "lint": "eslint .", + "lintfix": "eslint . --fix", "test": "echo \"Error: no test specified\" && exit 1" }, "type": "module", diff --git a/utils/videos.js b/utils/videos.js index a7bd343..4b810bf 100644 --- a/utils/videos.js +++ b/utils/videos.js @@ -4,7 +4,7 @@ import { exec } from 'node:child_process'; export default { downloadVideo, upload, - ffmpeg + ffmpeg, }; async function downloadVideo(url, output, format = 'bestvideo*+bestaudio/best') { await new Promise((resolve, reject) => {