From b84d177158a40fa9d714ff01005b6e5722ec82a3 Mon Sep 17 00:00:00 2001 From: m-tartari <37861893+m-tartari@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:49:42 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(lint):=20use=20new=20eslin?= =?UTF-8?q?t=20file=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 1 - .eslintrc.cjs | 20 -------------- eslint.config.mjs | 66 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 4 files changed, 67 insertions(+), 22 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.cjs create mode 100644 eslint.config.mjs 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",