diff --git a/.eslintrc.json b/.eslintrc.json index 203acba0..3be16144 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,30 +1,14 @@ { - "extends": [ - "next/core-web-vitals", - "next/typescript" - ], + "extends": ["next/core-web-vitals", "next/typescript", "prettier"], + "plugins": ["prettier"], "rules": { - "@typescript-eslint/no-explicit-any": "warn", - "@typescript-eslint/no-unused-vars": "warn", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": "off", "react/no-unescaped-entities": "warn", "react/display-name": "warn", "@typescript-eslint/ban-ts-comment": "warn", "@typescript-eslint/no-unsafe-function-type": "warn", - "@typescript-eslint/no-unused-expressions": "warn" - } -} -{ - "extends": [ - "next/core-web-vitals", - "next/typescript", - "prettier" - ], - "plugins": [ - "prettier" - ], - "rules": { - "@typescript-eslint/no-unused-vars": "off", - "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-expressions": "warn", "prettier/prettier": "error" } } diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..7feaf41a --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,45 @@ +import { dirname } from 'path'; +import { fileURLToPath } from 'url'; +import { FlatCompat } from '@eslint/eslintrc'; +import prettierPlugin from 'eslint-plugin-prettier'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const compat = new FlatCompat({ + baseDirectory: __dirname, +}); + +const eslintConfig = [ + { + ignores: [ + '**/*.test.ts', + '**/*.test.tsx', + '**/__tests__/**', + '**/testing/**', + '**/form-management/**/*.test.ts', + '.next/**', + 'node_modules/**', + '.eslintignore', + ], + }, + ...compat.extends('next/core-web-vitals', 'next/typescript'), + { + plugins: { + prettier: prettierPlugin, + }, + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unused-vars': 'off', + 'react/no-unescaped-entities': 'warn', + 'react/display-name': 'warn', + '@typescript-eslint/ban-ts-comment': 'warn', + '@typescript-eslint/no-unsafe-function-type': 'warn', + '@typescript-eslint/no-unused-expressions': 'warn', + 'prettier/prettier': 'error', + 'import/no-anonymous-default-export': 'off', + }, + }, +]; + +export default eslintConfig; diff --git a/lint-staged.config.js b/lint-staged.config.js index 8d610e47..5fc2fd23 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -1,9 +1,11 @@ -module.exports = { +const config = { '*.{js,jsx,ts,tsx}': (filenames) => [ // run eslint --fix on changed files `eslint --max-warnings=0 --fix ${filenames.join(' ')}`, // then format with prettier `prettier --write ${filenames.join(' ')}`, ], - '*.{json,md,css,scss,html}': [`prettier --write ${filenames.join(' ')}`], + '*.{json,md,css,scss,html}': (filenames) => [`prettier --write ${filenames.join(' ')}`], }; + +export default config; diff --git a/package-lock.json b/package-lock.json index 96bb66ff..92ed1ebf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5500,7 +5500,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.30.tgz", "integrity": "sha512-WJtwWJu7UdlvzEAUm484QNg5eAoq5QR08KDNx7g45Usrs2NtOPiX8ugDqmKdXkyL03rBqU5dYNYVQetEpBHq2g==", "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~6.21.0" } diff --git a/package.json b/package.json index f31c781a..965f9e21 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "my-app", "version": "0.1.0", "private": true, + "type": "module", "scripts": { "dev": "next dev --turbopack", "build": "next build", diff --git a/src/components/i18n/InternationalizationEngine.tsx b/src/components/i18n/InternationalizationEngine.tsx index 5ec995ba..bb6ae40d 100644 --- a/src/components/i18n/InternationalizationEngine.tsx +++ b/src/components/i18n/InternationalizationEngine.tsx @@ -39,7 +39,6 @@ export function InternationalizationEngine({ children, }: InternationalizationEngineProps) { const { language, isLoading, error, changeLanguage } = useInternationalization(); - const [preloadStatus, setPreloadStatus] = useState>({} as Record); const [preloadStatus, setPreloadStatus] = useState>>({}); // Preload translations on mount @@ -55,7 +54,6 @@ export function InternationalizationEngine({ await preloadTranslations(languagesToPreload); if (!cancelled) { - const status = {} as Record; const status: Partial> = {}; languagesToPreload.forEach((lang) => { status[lang] = true; diff --git a/tsconfig.json b/tsconfig.json index 8c48606c..81fec4e6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,12 +26,7 @@ "noImplicitReturns": true, "noImplicitAny": false }, - "include": [ - "**/*.ts", - "**/*.tsx", - "next-env.d.ts", - ".next/types/**/*.ts" - ], + "include": ["**/*.ts", "**/*.tsx", "next-env.d.ts", ".next/types/**/*.ts"], "exclude": [ "node_modules", ".next", @@ -39,7 +34,5 @@ "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx" - "**/*.test.ts", - "**/*.test.tsx" ] }