From f511dafad2b9ca96bd07fafb930e209d795e8a3f Mon Sep 17 00:00:00 2001 From: LordMathis Date: Sat, 24 May 2025 00:15:10 +0200 Subject: [PATCH] Refactor ESLint config --- app/eslint.config.mjs | 151 +++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 68 deletions(-) diff --git a/app/eslint.config.mjs b/app/eslint.config.mjs index 4aac029..b85bc40 100644 --- a/app/eslint.config.mjs +++ b/app/eslint.config.mjs @@ -1,92 +1,107 @@ -import { defineConfig, globalIgnores } from "eslint/config"; -import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"; -import react from "eslint-plugin-react"; -import reactHooks from "eslint-plugin-react-hooks"; -import typescriptEslint from "@typescript-eslint/eslint-plugin"; -import tsParser from "@typescript-eslint/parser"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; -import js from "@eslint/js"; -import { FlatCompat } from "@eslint/eslintrc"; +import { defineConfig, globalIgnores } from 'eslint/config'; +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'; +import react from 'eslint-plugin-react'; +import reactHooks from 'eslint-plugin-react-hooks'; +import typescriptEslint from '@typescript-eslint/eslint-plugin'; +import tsParser from '@typescript-eslint/parser'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import js from '@eslint/js'; +import { FlatCompat } from '@eslint/eslintrc'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, }); -export default defineConfig([globalIgnores([ - "**/node_modules", - "**/dist", - "**/build", - "**/coverage", - "**/public", - "**/*.js", - "**/vite.config.ts", -]), { - extends: fixupConfigRules(compat.extends( - "eslint:recommended", - "plugin:react/recommended", - "plugin:react-hooks/recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - )), +export default defineConfig([ + globalIgnores([ + '**/node_modules', + '**/dist', + '**/build', + '**/coverage', + '**/public', + '**/*.js', + '**/vite.config.ts', + '**/eslint.config.mjs', + ]), + { + extends: fixupConfigRules( + compat.extends( + 'eslint:recommended', + 'plugin:react/recommended', + 'plugin:react-hooks/recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking' + ) + ), plugins: { - react: fixupPluginRules(react), - "react-hooks": fixupPluginRules(reactHooks), - "@typescript-eslint": fixupPluginRules(typescriptEslint), + react: fixupPluginRules(react), + 'react-hooks': fixupPluginRules(reactHooks), + '@typescript-eslint': fixupPluginRules(typescriptEslint), }, languageOptions: { - parser: tsParser, - ecmaVersion: 2022, - sourceType: "module", + parser: tsParser, + ecmaVersion: 2022, + sourceType: 'module', - parserOptions: { - ecmaFeatures: { - jsx: true, - }, - - project: "./tsconfig.json", + parserOptions: { + ecmaFeatures: { + jsx: true, }, + + project: './tsconfig.json', + }, }, settings: { - react: { - version: "detect", - }, + react: { + version: 'detect', + }, }, rules: { - "no-console": ["warn", { - allow: ["warn", "error", "debug"], - }], + 'no-console': [ + 'warn', + { + allow: ['warn', 'error', 'debug'], + }, + ], - "no-duplicate-imports": "error", - "no-unused-vars": "off", - "react/prop-types": "off", - "react/react-in-jsx-scope": "off", - "react-hooks/rules-of-hooks": "error", - "react-hooks/exhaustive-deps": "warn", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/no-explicit-any": "warn", + 'no-duplicate-imports': 'error', + 'no-unused-vars': 'off', + 'react/prop-types': 'off', + 'react/react-in-jsx-scope': 'off', + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'warn', - "@typescript-eslint/no-unused-vars": ["warn", { - argsIgnorePattern: "^_", - varsIgnorePattern: "^_", - caughtErrorsIgnorePattern: "^_", - }], + '@typescript-eslint/no-unused-vars': [ + 'warn', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }, + ], - "@typescript-eslint/consistent-type-imports": ["warn", { - prefer: "type-imports", - }], + '@typescript-eslint/consistent-type-imports': [ + 'warn', + { + prefer: 'type-imports', + }, + ], - "@typescript-eslint/no-misused-promises": "warn", - "@typescript-eslint/no-floating-promises": "warn", - "@typescript-eslint/unbound-method": "off", - "@typescript-eslint/no-non-null-assertion": "warn", + '@typescript-eslint/no-misused-promises': 'warn', + '@typescript-eslint/no-floating-promises': 'warn', + '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/no-non-null-assertion': 'warn', }, -}]); \ No newline at end of file + }, +]);