|
1 | 1 | import { dirname } from 'path'; |
2 | 2 | import { fileURLToPath } from 'url'; |
3 | 3 | import { FlatCompat } from '@eslint/eslintrc'; |
| 4 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 5 | +import typescriptParser from '@typescript-eslint/parser'; |
| 6 | +// import tailwindcss from 'eslint-plugin-tailwindcss'; // Disabled - v4 compatibility issue |
4 | 7 |
|
5 | 8 | const __filename = fileURLToPath(import.meta.url); |
6 | 9 | const __dirname = dirname(__filename); |
7 | 10 |
|
8 | 11 | const compat = new FlatCompat({ |
9 | | - baseDirectory: __dirname |
| 12 | + baseDirectory: __dirname, |
10 | 13 | }); |
11 | 14 |
|
12 | 15 | const eslintConfig = [ |
| 16 | + // Global ignores |
| 17 | + { |
| 18 | + ignores: [ |
| 19 | + 'node_modules/**', |
| 20 | + '.next/**', |
| 21 | + 'out/**', |
| 22 | + 'build/**', |
| 23 | + 'dist/**', |
| 24 | + 'next-env.d.ts', |
| 25 | + 'tailwind.config.ts', |
| 26 | + 'next.config.ts', |
| 27 | + ], |
| 28 | + }, |
| 29 | + |
| 30 | + // Base Next.js configuration |
13 | 31 | ...compat.extends('next/core-web-vitals', 'next/typescript'), |
| 32 | + |
| 33 | + // TypeScript configuration |
14 | 34 | { |
15 | | - ignores: ['node_modules/**', '.next/**', 'out/**', 'build/**', 'next-env.d.ts'] |
16 | | - } |
| 35 | + files: ['**/*.ts', '**/*.tsx'], |
| 36 | + languageOptions: { |
| 37 | + parser: typescriptParser, |
| 38 | + parserOptions: { |
| 39 | + project: './tsconfig.json', |
| 40 | + ecmaVersion: 'latest', |
| 41 | + sourceType: 'module', |
| 42 | + ecmaFeatures: { |
| 43 | + jsx: true, |
| 44 | + }, |
| 45 | + }, |
| 46 | + }, |
| 47 | + plugins: { |
| 48 | + '@typescript-eslint': typescriptEslint, |
| 49 | + }, |
| 50 | + rules: { |
| 51 | + // TypeScript specific rules |
| 52 | + '@typescript-eslint/no-unused-vars': [ |
| 53 | + 'warn', |
| 54 | + { |
| 55 | + argsIgnorePattern: '^_', |
| 56 | + varsIgnorePattern: '^_', |
| 57 | + destructuredArrayIgnorePattern: '^_', |
| 58 | + }, |
| 59 | + ], |
| 60 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 61 | + '@typescript-eslint/no-non-null-assertion': 'warn', |
| 62 | + '@typescript-eslint/no-unnecessary-type-assertion': 'error', |
| 63 | + '@typescript-eslint/prefer-nullish-coalescing': 'error', |
| 64 | + '@typescript-eslint/prefer-optional-chain': 'error', |
| 65 | + '@typescript-eslint/consistent-type-imports': [ |
| 66 | + 'error', |
| 67 | + { |
| 68 | + prefer: 'type-imports', |
| 69 | + fixStyle: 'inline-type-imports', |
| 70 | + }, |
| 71 | + ], |
| 72 | + |
| 73 | + // General rules |
| 74 | + 'no-console': ['warn', { allow: ['warn', 'error'] }], |
| 75 | + 'prefer-const': 'error', |
| 76 | + 'no-var': 'error', |
| 77 | + 'object-shorthand': 'error', |
| 78 | + 'prefer-template': 'error', |
| 79 | + }, |
| 80 | + }, |
| 81 | + |
| 82 | + // Tailwind CSS configuration - disabled until plugin supports v4 |
| 83 | + // Note: eslint-plugin-tailwindcss doesn't support Tailwind CSS v4 yet |
| 84 | + // Prettier with prettier-plugin-tailwindcss will handle class ordering instead |
| 85 | + |
| 86 | + // Prettier integration - must be last to override other configs |
| 87 | + ...compat.extends('prettier'), |
17 | 88 | ]; |
18 | 89 |
|
19 | 90 | export default eslintConfig; |
0 commit comments