Skip to content

Commit edb22df

Browse files
committed
build: migrated to ESLint v9
1 parent 1e985da commit edb22df

File tree

12 files changed

+320
-242
lines changed

12 files changed

+320
-242
lines changed

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
]

middleware.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import { NextRequest, NextResponse } from 'next/server'
33
export function middleware(req: NextRequest) {
44
const { pathname } = req.nextUrl
55

6-
// Match only /news/<segment> (single segment)
7-
const match = pathname.match(/^\/news\/([^\/]+)$/)
6+
const match = pathname.match(new RegExp('^/news/([^/]+)$'))
87
if (match) {
98
const year = match[1]
10-
// Return 404 for non four-digit or out-of-range years
119
if (!/^\d{4}$/.test(year)) {
1210
return new NextResponse('Not Found', { status: 404 })
1311
}
@@ -23,4 +21,3 @@ export function middleware(req: NextRequest) {
2321
export const config = {
2422
matcher: ['/news/:year*'],
2523
}
26-

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"name": "phpmyfaq-new",
2+
"name": "phpmyfaq-website",
33
"version": "4.0.0",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
88
"postbuild": "cp -f static/.htaccess out/.htaccess || true",
9-
"lint": "next lint",
9+
"lint": "eslint .",
10+
"lint:fix": "eslint . --fix",
1011
"test": "vitest",
1112
"test:ui": "vitest --ui",
1213
"test:ci": "vitest --run",
@@ -40,8 +41,13 @@
4041
"@types/react-dom": "^19.2.2",
4142
"@vitejs/plugin-react": "^5.1.0",
4243
"@vitest/coverage-v8": "3.2.4",
43-
"eslint": "^8.57.1",
44+
"eslint": "^9.0.0",
4445
"eslint-config-next": "15.5.4",
46+
"@typescript-eslint/parser": "^8.0.0",
47+
"@typescript-eslint/eslint-plugin": "^8.0.0",
48+
"@eslint/js": "^9.0.0",
49+
"@next/eslint-plugin-next": "15.5.4",
50+
"globals": "^15.12.0",
4551
"jsdom": "^27.0.1",
4652
"postcss": "^8.5.6",
4753
"tailwindcss": "^3.4.18",

0 commit comments

Comments
 (0)