Add React and hooks ESLint plugins and config

Enhanced the ESLint configuration to include 'eslint-plugin-react', 'eslint-plugin-react-hooks', and 'globals' for improved React and browser environment linting. Updated rules and overrides for React files, test files, and Node.js scripts. Updated dependencies in package.json and package-lock.json to include the new plugins and bumped several related packages.
This commit is contained in:
Ludy87 2025-09-22 22:14:45 +02:00
parent c76edebf0f
commit 3517f22c23
No known key found for this signature in database
GPG Key ID: 92696155E0220F94
3 changed files with 1803 additions and 47 deletions

View File

@ -1,18 +1,21 @@
// @ts-check // @ts-check
import eslint from '@eslint/js'; import eslint from '@eslint/js';
import globals from 'globals';
import { defineConfig } from 'eslint/config'; import { defineConfig } from 'eslint/config';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactPlugin from 'eslint-plugin-react';
import tseslint from 'typescript-eslint'; import tseslint from 'typescript-eslint';
export default defineConfig( export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommended,
{ {
ignores: [ ignores: [
"dist", // Contains 3rd party code "dist", // Contains 3rd party code
"public", // Contains 3rd party code "public", // Contains 3rd party code
], ],
}, },
eslint.configs.recommended,
tseslint.configs.recommended,
{ {
rules: { rules: {
"no-undef": "off", // Temporarily disabled until codebase conformant "no-undef": "off", // Temporarily disabled until codebase conformant
@ -28,15 +31,65 @@ export default defineConfig(
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [
"error", "error",
{ {
"args": "all", // All function args must be used (or explicitly ignored) args: 'all', // All function args must be used (or explicitly ignored)
"argsIgnorePattern": "^_", // Allow unused variables beginning with an underscore argsIgnorePattern: '^_', // Allow unused variables beginning with an underscore
"caughtErrors": "all", // Caught errors must be used (or explicitly ignored) caughtErrors: 'all', // Caught errors must be used (or explicitly ignored)
"caughtErrorsIgnorePattern": "^_", // Allow unused variables beginning with an underscore caughtErrorsIgnorePattern: '^_', // Allow unused variables beginning with an underscore
"destructuredArrayIgnorePattern": "^_", // Allow unused variables beginning with an underscore destructuredArrayIgnorePattern: '^_', // Allow unused variables beginning with an underscore
"varsIgnorePattern": "^_", // Allow unused variables beginning with an underscore varsIgnorePattern: '^_', // Allow unused variables beginning with an underscore
"ignoreRestSiblings": true, // Allow unused variables when removing attributes from objects (otherwise this requires explicit renaming like `({ x: _x, ...y }) => y`, which is clunky) ignoreRestSiblings: true, // Allow unused variables when removing attributes from objects (otherwise this requires explicit renaming like `({ x: _x, ...y }) => y`, which is clunky)
}, },
], ],
}, },
},
{
files: ['src/**/*.{ts,tsx,js,jsx}'],
languageOptions: {
globals: {
...globals.browser,
},
},
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'warn',
},
},
{
files: [
'src/**/*.{test,spec}.{ts,tsx}',
'src/tests/**/*.{ts,tsx}',
],
languageOptions: {
globals: {
...globals.browser,
...globals.vitest,
},
},
},
{
files: [
'scripts/**/*.{js,ts}',
'vite.config.ts',
'vitest.config.ts',
'vitest.minimal.config.ts',
'playwright.config.ts',
'tailwind.config.js',
'postcss.config.js',
'eslint.config.mjs',
],
languageOptions: {
globals: {
...globals.node,
},
},
} }
); );

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,7 @@
"jszip": "^3.10.1", "jszip": "^3.10.1",
"pdf-lib": "^1.17.1", "pdf-lib": "^1.17.1",
"pdfjs-dist": "^3.11.174", "pdfjs-dist": "^3.11.174",
"posthog-js": "^1.261.0", "posthog-js": "^1.268.0",
"react": "^19.1.0", "react": "^19.1.0",
"react-dom": "^19.1.0", "react-dom": "^19.1.0",
"react-i18next": "^15.5.2", "react-i18next": "^15.5.2",
@ -72,12 +72,6 @@
"test:e2e:ui": "playwright test --ui", "test:e2e:ui": "playwright test --ui",
"test:e2e:install": "playwright install" "test:e2e:install": "playwright install"
}, },
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": { "browserslist": {
"production": [ "production": [
">0.2%", ">0.2%",
@ -101,6 +95,9 @@
"@vitejs/plugin-react": "^4.5.0", "@vitejs/plugin-react": "^4.5.0",
"@vitest/coverage-v8": "^1.0.0", "@vitest/coverage-v8": "^1.0.0",
"eslint": "^9.34.0", "eslint": "^9.34.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"globals": "^16.4.0",
"jsdom": "^23.0.0", "jsdom": "^23.0.0",
"license-checker": "^25.0.1", "license-checker": "^25.0.1",
"madge": "^8.0.0", "madge": "^8.0.0",