Bläddra i källkod

chore: fix eslint rules

C4illin 10 månader sedan
förälder
incheckning
ee9207a7f4
9 ändrade filer med 33 tillägg och 42 borttagningar
  1. BIN
      bun.lockb
  2. 6 14
      eslint.config.js
  3. 6 9
      package.json
  4. 2 2
      postcss.config.cjs
  5. 2 1
      src/converters/ffmpeg.ts
  6. 5 8
      src/converters/main.ts
  7. 6 4
      src/index.tsx
  8. 4 3
      src/public/script.js
  9. 2 1
      tailwind.config.js

BIN
bun.lockb


+ 6 - 14
eslint.config.js

@@ -1,28 +1,22 @@
-import comments from "@eslint-community/eslint-plugin-eslint-comments/configs";
 import { fixupPluginRules } from "@eslint/compat";
-import js from "@eslint/js";
+import eslint from '@eslint/js';
 import deprecationPlugin from "eslint-plugin-deprecation";
-import importPlugin from "eslint-plugin-import";
 import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
 import tailwind from "eslint-plugin-tailwindcss";
 import globals from "globals";
-import tseslint from "typescript-eslint";
+import tseslint from 'typescript-eslint';
 
 
 export default tseslint.config(
-  js.configs.recommended,
-  importPlugin.flatConfigs.recommended,
-  comments.recommended,
+  eslint.configs.recommended,
   ...tseslint.configs.recommended,
   ...tailwind.configs["flat/recommended"],
   {
     plugins: {
-      "@typescript-eslint": tseslint.plugin,
       deprecation: fixupPluginRules(deprecationPlugin),
-      import: fixupPluginRules(importPlugin),
       "simple-import-sort": simpleImportSortPlugin,
     },
-    ignores: ["**/node_modules/**", "**/public/**"],
+    ignores: ["**/node_modules/**"],
     languageOptions: {
       parserOptions: {
         projectService: true,
@@ -36,12 +30,11 @@ export default tseslint.config(
         ...globals.browser,
       },
     },
-    files: ["**/*.{js,mjs,cjs}"],
+    files: ["**/*.{js,mjs,cjs,tsx}"],
     rules: {
       "tailwindcss/no-custom-classname": [
-        "error",
+        "warn",
         {
-          config: "./tailwind.config.js",
           whitelist: [
             "select_container",
             "convert_to_popup",
@@ -51,7 +44,6 @@ export default tseslint.config(
           ],
         },
       ],
-      "import/no-named-as-default": "off",
     },
   },
 );

+ 6 - 9
package.json

@@ -4,12 +4,12 @@
   "scripts": {
     "dev": "bun run --watch src/index.tsx",
     "hot": "bun run --hot src/index.tsx",
-    "format": "eslint --fix ./src",
-    "build": "postcss  ./src/main.css -o ./src/public/generated.css",
+    "format": "eslint --fix .",
+    "build": "postcss ./src/main.css -o ./src/public/generated.css",
     "lint": "run-p 'lint:*'",
     "lint:tsc": "tsc --noEmit",
     "lint:knip": "knip",
-    "lint:eslint": "eslint ./src",
+    "lint:eslint": "eslint ."
   },
   "dependencies": {
     "@elysiajs/cookie": "^0.8.0",
@@ -24,12 +24,10 @@
     "start": "bun run src/index.tsx"
   },
   "devDependencies": {
-    "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
     "@eslint/compat": "^1.1.1",
-    "@eslint/js": "^9.11.1",
+    "@eslint/js": "^9.12.0",
     "@ianvs/prettier-plugin-sort-imports": "^4.3.1",
     "@kitajs/ts-html-plugin": "^4.1.0",
-    "@picocss/pico": "^2.0.6",
     "@total-typescript/ts-reset": "^0.6.1",
     "@types/bun": "^1.1.10",
     "@types/eslint": "^9.6.1",
@@ -40,10 +38,9 @@
     "@typescript-eslint/parser": "^8.7.0",
     "autoprefixer": "^10.4.20",
     "cssnano": "^7.0.6",
-    "eslint": "^9.11.1",
+    "eslint": "^9.12.0",
     "eslint-config-prettier": "^9.1.0",
     "eslint-plugin-deprecation": "^3.0.0",
-    "eslint-plugin-import": "^2.30.0",
     "eslint-plugin-isaacscript": "^4.0.0",
     "eslint-plugin-prettier": "^5.2.1",
     "eslint-plugin-simple-import-sort": "^12.1.1",
@@ -58,6 +55,6 @@
     "tailwind-scrollbar": "^3.1.0",
     "tailwindcss": "^3.4.13",
     "typescript": "^5.6.2",
-    "typescript-eslint": "^8.7.0"
+    "typescript-eslint": "^8.8.0"
   }
 }

+ 2 - 2
postcss.config.cjs

@@ -1,9 +1,9 @@
-// eslint-disable-next-line no-undef
+ 
 module.exports = {
   plugins: {
     tailwindcss: {},
     autoprefixer: {},
-    // eslint-disable-next-line no-undef
+     
     ...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {})
   }
 }

+ 2 - 1
src/converters/ffmpeg.ts

@@ -689,7 +689,8 @@ export async function convert(
   fileType: string,
   convertTo: string,
   targetPath: string,
-  options?: any,
+  // eslint-disable-next-line @typescript-eslint/no-unused-vars
+  options?: unknown,
 ): Promise<string> {
   const command = `ffmpeg -i "${filePath}" "${targetPath}"`;
 

+ 5 - 8
src/converters/main.ts

@@ -54,10 +54,9 @@ const properties: Record<
       fileType: string,
       convertTo: string,
       targetPath: string,
-      // eslint-disable-next-line @typescript-eslint/no-unused-vars
+
       options?: unknown,
-      // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    ) => any;
+    ) => unknown;
   }
 > = {
   libjxl: {
@@ -97,17 +96,14 @@ const properties: Record<
 export async function mainConverter(
   inputFilePath: string,
   fileTypeOriginal: string,
-  // eslint-disable-next-line @typescript-eslint/no-unused-vars
-  convertTo: any,
+  convertTo: string,
   targetPath: string,
-  // eslint-disable-next-line @typescript-eslint/no-unused-vars
   options?: unknown,
   converterName?: string,
 ) {
   const fileType = normalizeFiletype(fileTypeOriginal);
 
-  // eslint-disable-next-line @typescript-eslint/no-unused-vars
-  let converterFunc: any;
+  let converterFunc: ((filePath: string, fileType: string, convertTo: string, targetPath: string, options?: unknown) => unknown) | undefined;
   // let converterName = converterName;
 
   if (converterName) {
@@ -211,6 +207,7 @@ for (const converterName in properties) {
 }
 possibleInputs.sort();
 
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
 const getPossibleInputs = () => {
   return possibleInputs;
 };

+ 6 - 4
src/index.tsx

@@ -141,7 +141,9 @@ const app = new Elysia({
         <main class="mx-auto w-full max-w-4xl px-4">
           <h1 class="my-8 text-3xl">Welcome to ConvertX!</h1>
           <article class="article p-0">
-            <header class="w-full bg-neutral-800 p-4">Create your account</header>
+            <header class="w-full bg-neutral-800 p-4">
+              Create your account
+            </header>
             <form method="post" action="/register" class="p-4">
               <fieldset class="mb-4 flex flex-col gap-4">
                 <label class="flex flex-col gap-1">
@@ -565,7 +567,7 @@ const app = new Elysia({
                     {Object.entries(getAllTargets()).map(
                       ([converter, targets]) => (
                         <article
-                          class="convert_to_group w-full border-b border-neutral-700 p-4 flex flex-col"
+                          class="convert_to_group flex w-full flex-col border-b border-neutral-700 p-4"
                           data-converter={converter}
                         >
                           <header class="mb-2 w-full text-xl font-bold" safe>
@@ -633,7 +635,7 @@ const app = new Elysia({
             {Object.entries(getPossibleTargets(body.fileType)).map(
               ([converter, targets]) => (
                 <article
-                  class="convert_to_group w-full border-b border-neutral-700 p-4 flex flex-col"
+                  class="convert_to_group flex w-full flex-col border-b border-neutral-700 p-4"
                   data-converter={converter}
                 >
                   <header class="mb-2 w-full text-xl font-bold" safe>
@@ -713,7 +715,7 @@ const app = new Elysia({
             await Bun.write(`${userUploadsDir}${file.name}`, file);
           }
         } else {
-          // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/dot-notation
+           
           await Bun.write(`${userUploadsDir}${body.file["name"]}`, body.file);
         }
       }

+ 4 - 3
src/public/script.js

@@ -4,11 +4,11 @@ const dropZone = document.getElementById("dropzone");
 const fileNames = [];
 let fileType;
 
-dropZone.addEventListener("dragover", (e) => {
+dropZone.addEventListener("dragover", () => {
   dropZone.classList.add("dragover");
 });
 
-dropZone.addEventListener("dragleave", (e) => {
+dropZone.addEventListener("dragleave", () => {
   dropZone.classList.remove("dragover");
 });
 
@@ -153,6 +153,7 @@ const setTitle = () => {
 };
 
 // Add a onclick for the delete button
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
 const deleteRow = (target) => {
   const filename = target.parentElement.parentElement.children[0].textContent;
   const row = target.parentElement.parentElement;
@@ -203,7 +204,7 @@ const uploadFiles = (files) => {
 
 const formConvert = document.querySelector("form[action='/convert']");
 
-formConvert.addEventListener("submit", (e) => {
+formConvert.addEventListener("submit", () => {
   const hiddenInput = document.querySelector("input[name='file_names']");
   hiddenInput.value = JSON.stringify(fileNames);
 });

+ 2 - 1
tailwind.config.js

@@ -1,5 +1,6 @@
+/* eslint-disable @typescript-eslint/no-require-imports */
 /** @type {import('tailwindcss').Config} */
-// eslint-disable-next-line no-undef
+ 
 module.exports = {
   content: ["./src/**/*.{html,js,tsx,jsx,cjs,mjs}"],
   theme: {