|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + env: { |
| 4 | + browser: true, |
| 5 | + es2021: true, |
| 6 | + node: true, |
| 7 | + }, |
| 8 | + extends: [ |
| 9 | + 'eslint:recommended', |
| 10 | + 'plugin:@typescript-eslint/recommended', |
| 11 | + 'plugin:react/recommended', |
| 12 | + 'plugin:react-hooks/recommended', |
| 13 | + 'plugin:jsx-a11y/recommended', |
| 14 | + 'plugin:import/recommended', |
| 15 | + 'plugin:import/typescript', |
| 16 | + 'plugin:tailwindcss/recommended', |
| 17 | + 'next/core-web-vitals', |
| 18 | + 'prettier', // Make sure this is last to override other configs |
| 19 | + ], |
| 20 | + parser: '@typescript-eslint/parser', |
| 21 | + parserOptions: { |
| 22 | + ecmaFeatures: { |
| 23 | + jsx: true, |
| 24 | + }, |
| 25 | + ecmaVersion: 2021, |
| 26 | + sourceType: 'module', |
| 27 | + project: './tsconfig.json', |
| 28 | + }, |
| 29 | + plugins: [ |
| 30 | + '@typescript-eslint', |
| 31 | + 'react', |
| 32 | + 'react-hooks', |
| 33 | + 'import', |
| 34 | + 'jsx-a11y', |
| 35 | + 'tailwindcss', |
| 36 | + ], |
| 37 | + settings: { |
| 38 | + react: { |
| 39 | + version: 'detect', |
| 40 | + }, |
| 41 | + 'import/resolver': { |
| 42 | + typescript: {}, |
| 43 | + node: { |
| 44 | + extensions: ['.js', '.jsx', '.ts', '.tsx'], |
| 45 | + }, |
| 46 | + }, |
| 47 | + }, |
| 48 | + rules: { |
| 49 | + // React rules |
| 50 | + 'react/react-in-jsx-scope': 'off', // Not needed in Next.js |
| 51 | + 'react/prop-types': 'off', // Use TypeScript for prop validation |
| 52 | + 'react/jsx-filename-extension': [1, { extensions: ['.tsx', '.jsx'] }], |
| 53 | + 'react/jsx-props-no-spreading': 'off', // Allow JSX props spreading |
| 54 | + 'react/jsx-sort-props': [ |
| 55 | + 'warn', |
| 56 | + { |
| 57 | + callbacksLast: true, |
| 58 | + shorthandFirst: true, |
| 59 | + ignoreCase: true, |
| 60 | + reservedFirst: true, |
| 61 | + }, |
| 62 | + ], |
| 63 | + |
| 64 | + // TypeScript rules |
| 65 | + '@typescript-eslint/explicit-module-boundary-types': 'off', // Let TypeScript infer return types |
| 66 | + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], |
| 67 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 68 | + '@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports' }], |
| 69 | + '@typescript-eslint/consistent-type-definitions': ['warn', 'interface'], |
| 70 | + |
| 71 | + // Import rules |
| 72 | + 'import/order': [ |
| 73 | + 'warn', |
| 74 | + { |
| 75 | + groups: [ |
| 76 | + 'builtin', // Node.js built-in modules |
| 77 | + 'external', // npm packages |
| 78 | + 'internal', // Absolute imports |
| 79 | + ['parent', 'sibling'], // Relative imports |
| 80 | + 'index', // index imports |
| 81 | + 'object', // object imports |
| 82 | + 'type', // type imports |
| 83 | + ], |
| 84 | + 'newlines-between': 'always', |
| 85 | + alphabetize: { |
| 86 | + order: 'asc', |
| 87 | + caseInsensitive: true, |
| 88 | + }, |
| 89 | + pathGroups: [ |
| 90 | + { |
| 91 | + pattern: 'react', |
| 92 | + group: 'builtin', |
| 93 | + position: 'before', |
| 94 | + }, |
| 95 | + { |
| 96 | + pattern: 'next/**', |
| 97 | + group: 'builtin', |
| 98 | + position: 'after', |
| 99 | + }, |
| 100 | + { |
| 101 | + pattern: '@/**', |
| 102 | + group: 'internal', |
| 103 | + position: 'after', |
| 104 | + }, |
| 105 | + ], |
| 106 | + pathGroupsExcludedImportTypes: ['react'], |
| 107 | + }, |
| 108 | + ], |
| 109 | + 'import/no-duplicates': 'error', |
| 110 | + |
| 111 | + // General rules |
| 112 | + 'no-console': ['warn', { allow: ['warn', 'error'] }], |
| 113 | + 'prefer-const': 'error', |
| 114 | + 'no-nested-ternary': 'warn', |
| 115 | + |
| 116 | + // Tailwind rules |
| 117 | + 'tailwindcss/no-custom-classname': 'warn', |
| 118 | + 'tailwindcss/classnames-order': 'warn', |
| 119 | + }, |
| 120 | + overrides: [ |
| 121 | + // Override rules for specific file patterns |
| 122 | + { |
| 123 | + files: ['*.js', '*.jsx', '*.ts', '*.tsx'], |
| 124 | + rules: { |
| 125 | + 'import/no-anonymous-default-export': 'warn', |
| 126 | + }, |
| 127 | + }, |
| 128 | + { |
| 129 | + files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'], |
| 130 | + extends: ['plugin:testing-library/react'], |
| 131 | + rules: { |
| 132 | + 'import/no-extraneous-dependencies': 'off', |
| 133 | + }, |
| 134 | + }, |
| 135 | + ], |
| 136 | +}; |
0 commit comments