From 341ded198f3229ea11b73206e8e9f8bcff6e864d Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Wed, 26 Feb 2025 15:07:34 +0100 Subject: [PATCH] fix(react-vite): Update eslint and use new config file (#1862) --- react-vite/base/.eslintrc.js | 17 ----------------- react-vite/base/eslint.config.js | 30 ++++++++++++++++++++++++++++++ react-vite/base/package.json | 6 +++++- 3 files changed, 35 insertions(+), 18 deletions(-) delete mode 100644 react-vite/base/.eslintrc.js create mode 100644 react-vite/base/eslint.config.js diff --git a/react-vite/base/.eslintrc.js b/react-vite/base/.eslintrc.js deleted file mode 100644 index af472a1f7..000000000 --- a/react-vite/base/.eslintrc.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - root: true, - env: { - node: true - }, - 'extends': [ - 'plugin:react/recommended', - 'eslint:recommended' - ], - parserOptions: { - ecmaVersion: 2020 - }, - rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - } -} diff --git a/react-vite/base/eslint.config.js b/react-vite/base/eslint.config.js new file mode 100644 index 000000000..0542f72c3 --- /dev/null +++ b/react-vite/base/eslint.config.js @@ -0,0 +1,30 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + { ignores: ['dist', 'cypress.config.ts'] }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + }, + }, +) diff --git a/react-vite/base/package.json b/react-vite/base/package.json index 3d43195c1..361db6295 100644 --- a/react-vite/base/package.json +++ b/react-vite/base/package.json @@ -32,11 +32,15 @@ "@vitejs/plugin-legacy": "^5.0.0", "@vitejs/plugin-react": "^4.0.1", "cypress": "^13.5.0", - "eslint": "^8.35.0", + "eslint": "^9.20.1", "eslint-plugin-react": "^7.32.2", + "eslint-plugin-react-hooks": "^5.1.0", + "eslint-plugin-react-refresh": "^0.4.19", + "globals": "^15.15.0", "jsdom": "^22.1.0", "terser": "^5.4.0", "typescript": "^5.1.6", + "typescript-eslint": "^8.24.0", "vite": "~5.2.0", "vitest": "^0.34.6" }