diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 9b1c8b1..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -/dist diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 42b8cf4..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - root: true, - env: { browser: true, es2020: true }, - extends: [ - "prettier", - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended', - "plugin:prettier/recommended" - ], - ignorePatterns: ['dist', '.eslintrc.cjs'], - parser: '@typescript-eslint/parser', - plugins: ['react-refresh'], - rules: { - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..c1ec3ca --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,66 @@ +import { fixupConfigRules } from '@eslint/compat' +import reactRefresh from 'eslint-plugin-react-refresh' +import globals from 'globals' +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, +}) + +export default [ + { + ignores: ['**/dist', '**/.eslintrc.cjs', 'eslint.config.mjs'], + }, + ...fixupConfigRules( + compat.extends( + 'prettier', + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + 'plugin:prettier/recommended' + ) + ), + { + plugins: { + 'react-refresh': reactRefresh, + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + parser: tsParser, + ecmaVersion: 'latest', + sourceType: 'module', + + parserOptions: { + project: ['./tsconfig.json', './tsconfig.base.json'], + tsconfigRootDir: __dirname, + }, + }, + + settings: { + react: { + version: 'detect', + }, + }, + + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { + allowConstantExport: true, + }, + ], + }, + }, +] diff --git a/package.json b/package.json index 3503a1b..98bcfd7 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build": "npm run build:dev", "build:dev": "tsc && vite build", "build:prod": "tsc --project tsconfig.prod.json && vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "lint": "eslint . --report-unused-disable-directives --max-warnings 0", "lint:fix": "npm run lint -- --fix", "preview": "vite preview", "test": "vitest",