From 151fca0619b945ce7b8b1c55f78c94309b71ce5a Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Tue, 30 Sep 2025 18:32:15 +0200 Subject: [PATCH] Update TypeScript and ESLint configs for Vite React Extend tsconfig.json from @tsconfig/vite-react and add the package to dependencies. Adjust TypeScript compiler options for improved compatibility with Vite and React, including type inclusions and path aliases. Simplify ESLint config to use recommended settings and remove TypeScript-specific parser options. --- frontend/eslint.config.mjs | 4 +--- frontend/package-lock.json | 8 ++++++++ frontend/package.json | 1 + frontend/tsconfig.json | 39 +++++++++++++++++++------------------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs index a0585f5de..831344e19 100644 --- a/frontend/eslint.config.mjs +++ b/frontend/eslint.config.mjs @@ -199,15 +199,13 @@ export default defineConfig( ], extends: [ reactPlugin.configs.flat.recommended, - ...tseslint.configs.recommended, + eslint.configs.recommended, ], languageOptions: { - parser: tseslint.parser, parserOptions: { ecmaFeatures: { jsx: true, }, - projectService: true, tsconfigRootDir: __dirname, }, globals: { diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6398cd340..44e380d10 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -65,6 +65,7 @@ "@testing-library/jest-dom": "^6.8.0", "@testing-library/react": "^16.3.0", "@testing-library/user-event": "^14.6.1", + "@tsconfig/vite-react": "^7.0.1", "@types/node": "^24.5.2", "@types/react": "^19.1.13", "@types/react-dom": "^19.1.9", @@ -3566,6 +3567,13 @@ "node": ">=18" } }, + "node_modules/@tsconfig/vite-react": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/vite-react/-/vite-react-7.0.1.tgz", + "integrity": "sha512-IVbW532kRhqqiMbX1N+vnGYb+B6vNBw5FM/QXh1wGZOHG8HNeBzGEO8irFSNQUThg9mAHiNirCdwjsYeRyvU+Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/aria-query": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", diff --git a/frontend/package.json b/frontend/package.json index 3ab8d4cfe..22f372024 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -104,6 +104,7 @@ "@testing-library/jest-dom": "^6.8.0", "@testing-library/react": "^16.3.0", "@testing-library/user-event": "^14.6.1", + "@tsconfig/vite-react": "^7.0.1", "@types/node": "^24.5.2", "@types/react": "^19.1.13", "@types/react-dom": "^19.1.9", diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index bb386d1f8..586893a96 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "@tsconfig/vite-react/tsconfig.json", "compilerOptions": { /* Visit https://aka.ms/tsconfig to read more about this file */ @@ -11,9 +12,9 @@ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - "jsx": "react-jsx", /* Specify what JSX code is generated. */ + "jsx": "react-jsx", /* Specify what JSX code is generated. */ // "libReplacement": true, /* Enable lib replacement. */ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ @@ -26,15 +27,16 @@ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "esnext", /* Specify what module code is generated. */ + "module": "esnext", /* Specify what module code is generated. */ // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. */ - "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - "paths": { /* Specify a set of entries that re-map imports to additional lookup locations. */ + "moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. */ + "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + "paths": { /* Specify a set of entries that re-map imports to additional lookup locations. */ + "@/*": ["src/*"] }, // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + "types": ["vite/client", "vitest/globals"], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ @@ -43,7 +45,7 @@ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ - "resolveJsonModule": true, /* Enable importing .json files. */ + "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ @@ -58,7 +60,7 @@ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ + "noEmit": true, /* Disable emitting files from a compilation. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ // "outDir": "./", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ @@ -77,9 +79,9 @@ /* Interop Constraints */ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + "verbatimModuleSyntax": false, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */ + "erasableSyntaxOnly": false, /* Do not allow runtime constructs that are not part of ECMAScript. */ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ @@ -96,8 +98,8 @@ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + "noUnusedLocals": false, /* Enable error reporting when local variables aren't read. */ + "noUnusedParameters": false, /* Raise an error when a function parameter isn't read. */ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ @@ -113,12 +115,6 @@ }, "include": [ "src", - "src/*.js", - "src/*.jsx", - "src/**/*.js", - "src/**/*.jsx", - "src/**/*.ts", - "src/**/*.tsx", "src/global.d.ts", "vite.config.ts", "vitest.config.ts", @@ -126,5 +122,10 @@ "playwright.config.ts", "tailwind.config.js", "postcss.config.js" + ], + "exclude": [ + "dist", + "node_modules", + "public" ] }