|
| 1 | +import nextTypescript from 'eslint-config-next/typescript' |
| 2 | +import nextCoreWebVitals from 'eslint-config-next/core-web-vitals' |
| 3 | +import { dirname } from 'path' |
| 4 | +import { fileURLToPath } from 'url' |
| 5 | +import js from '@eslint/js' |
| 6 | +import tsPlugin from '@typescript-eslint/eslint-plugin' |
| 7 | +import tsParser from '@typescript-eslint/parser' |
| 8 | + |
| 9 | +const __filename = fileURLToPath(import.meta.url) |
| 10 | +const __dirname = dirname(__filename) |
| 11 | + |
| 12 | +export default [ |
| 13 | + ...nextTypescript, |
| 14 | + js.configs.recommended, |
| 15 | + ...nextCoreWebVitals, |
| 16 | + { |
| 17 | + files: ['src/**/*.{ts,tsx}'], |
| 18 | + languageOptions: { |
| 19 | + parser: tsParser, |
| 20 | + parserOptions: { |
| 21 | + project: './tsconfig.json', |
| 22 | + }, |
| 23 | + globals: { |
| 24 | + React: 'readonly', |
| 25 | + }, |
| 26 | + }, |
| 27 | + plugins: { |
| 28 | + '@typescript-eslint': tsPlugin, |
| 29 | + }, |
| 30 | + rules: { |
| 31 | + ...tsPlugin.configs['recommended'].rules, |
| 32 | + '@typescript-eslint/no-misused-promises': 'off', |
| 33 | + '@typescript-eslint/no-unused-vars': [ |
| 34 | + 'error', |
| 35 | + { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, |
| 36 | + ], |
| 37 | + // TypeScript handles redeclaration checks - allows type + value with same name |
| 38 | + 'no-redeclare': 'off', |
| 39 | + // TODO: Refactor hooks to use React Query instead of useEffect + setState pattern |
| 40 | + 'react-hooks/set-state-in-effect': 'off', |
| 41 | + }, |
| 42 | + }, |
| 43 | + { |
| 44 | + // TypeScript declaration files - disable no-undef as types are ambient |
| 45 | + files: ['src/**/*.d.ts'], |
| 46 | + rules: { |
| 47 | + 'no-undef': 'off', |
| 48 | + }, |
| 49 | + }, |
| 50 | + { |
| 51 | + // TODO: add linting for tests |
| 52 | + // Test files - lint without type-checking (not in tsconfig.json project) |
| 53 | + // TODO: add type checking for tests |
| 54 | + // files: ['test/**/*.{ts,tsx}'], |
| 55 | + // languageOptions: { |
| 56 | + // parser: tsParser, |
| 57 | + // globals: jestPlugin.environments.globals.globals, |
| 58 | + // }, |
| 59 | + // plugins: { |
| 60 | + // '@typescript-eslint': tsPlugin, |
| 61 | + // jest: jestPlugin, |
| 62 | + // }, |
| 63 | + // rules: { |
| 64 | + // ...tsPlugin.configs['recommended'].rules, |
| 65 | + // ...jestPlugin.configs['recommended'].rules, |
| 66 | + // '@typescript-eslint/no-unused-vars': [ |
| 67 | + // 'error', |
| 68 | + // { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, |
| 69 | + // ], |
| 70 | + // // TODO: clean up conditional tests |
| 71 | + // 'jest/no-conditional-expect': 'off', |
| 72 | + // }, |
| 73 | + }, |
| 74 | + { |
| 75 | + // TODO: lint tests |
| 76 | + ignores: ['node_modules/', '.next/', 'build/', 'test/', '*.mjs', '*.js'], |
| 77 | + }, |
| 78 | +] |
0 commit comments