|
| 1 | +// ESLint v9 Flat Config for phpMyFAQ website |
| 2 | +import js from '@eslint/js' |
| 3 | +import nextPlugin from '@next/eslint-plugin-next' |
| 4 | +import tsParser from '@typescript-eslint/parser' |
| 5 | +import tsPlugin from '@typescript-eslint/eslint-plugin' |
| 6 | +import globals from 'globals' |
| 7 | + |
| 8 | +export default [ |
| 9 | + // Ignore patterns (Flat Config ersetzt .eslintignore) |
| 10 | + { |
| 11 | + ignores: [ |
| 12 | + '.next/**', |
| 13 | + 'out/**', |
| 14 | + 'coverage/**', |
| 15 | + 'playwright-report/**', |
| 16 | + 'node_modules/**', |
| 17 | + 'dist/**', |
| 18 | + 'next-env.d.ts', |
| 19 | + ], |
| 20 | + }, |
| 21 | + |
| 22 | + // JavaScript/TypeScript Standardempfehlungen |
| 23 | + js.configs.recommended, |
| 24 | + |
| 25 | + // Next.js Core Web Vitals Regeln (teilweise entschärft für Migration) |
| 26 | + { |
| 27 | + name: 'next/core-web-vitals', |
| 28 | + plugins: { |
| 29 | + '@next/next': nextPlugin, |
| 30 | + }, |
| 31 | + rules: { |
| 32 | + ...nextPlugin.configs['core-web-vitals'].rules, |
| 33 | + '@next/next/no-html-link-for-pages': 'off', |
| 34 | + }, |
| 35 | + }, |
| 36 | + |
| 37 | + // TypeScript Setup + empfohlene Regeln |
| 38 | + { |
| 39 | + files: ['**/*.{ts,tsx}'], |
| 40 | + languageOptions: { |
| 41 | + parser: tsParser, |
| 42 | + parserOptions: { |
| 43 | + ecmaVersion: 'latest', |
| 44 | + sourceType: 'module', |
| 45 | + ecmaFeatures: { jsx: true }, |
| 46 | + }, |
| 47 | + globals: { |
| 48 | + ...globals.browser, |
| 49 | + ...globals.node, |
| 50 | + }, |
| 51 | + }, |
| 52 | + plugins: { |
| 53 | + '@typescript-eslint': tsPlugin, |
| 54 | + }, |
| 55 | + rules: { |
| 56 | + ...tsPlugin.configs.recommended.rules, |
| 57 | + // TS übernimmt Undef-Prüfung |
| 58 | + 'no-undef': 'off', |
| 59 | + // Migrationserleichterung |
| 60 | + 'no-useless-escape': 'warn', |
| 61 | + // Verbot von triple-slash references (außer next-env.d.ts, die ignoriert wird) |
| 62 | + '@typescript-eslint/triple-slash-reference': ['error', { types: 'never', lib: 'never', path: 'never' }], |
| 63 | + // Häufige kleine Verstöße sanfter behandeln |
| 64 | + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', ignoreRestSiblings: true, caughtErrors: 'none' }], |
| 65 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 66 | + }, |
| 67 | + }, |
| 68 | + |
| 69 | + // Tests: Vitest-Globals aktivieren |
| 70 | + { |
| 71 | + files: ['src/**/*.{test,spec}.{js,jsx,ts,tsx}'], |
| 72 | + languageOptions: { |
| 73 | + globals: { |
| 74 | + ...globals.vitest, |
| 75 | + ...globals.browser, |
| 76 | + ...globals.node, |
| 77 | + }, |
| 78 | + }, |
| 79 | + }, |
| 80 | + |
| 81 | + // Node/Config-Dateien (optional) |
| 82 | + { |
| 83 | + files: ['*.config.*', 'scripts/**/*.{ts,js,mjs,cjs}'], |
| 84 | + languageOptions: { |
| 85 | + globals: globals.node, |
| 86 | + }, |
| 87 | + }, |
| 88 | +] |
0 commit comments