|
| 1 | +// @ts-check |
| 2 | + |
| 3 | +import fs from 'node:fs'; |
| 4 | + |
| 5 | +import eslint from '@eslint/js'; |
| 6 | +import prettierConfig from 'eslint-config-prettier'; |
| 7 | +import importPlugin from 'eslint-plugin-import'; |
| 8 | +import jest from 'eslint-plugin-jest'; |
| 9 | +import react from 'eslint-plugin-react'; |
| 10 | +import tseslint from 'typescript-eslint'; |
| 11 | + |
| 12 | +export default tseslint.config( |
| 13 | + { |
| 14 | + ignores: ['eslint.config.js'].concat( |
| 15 | + fs.readFileSync('.gitignore', 'utf8').split('\n').filter(Boolean), |
| 16 | + ), |
| 17 | + }, |
| 18 | + |
| 19 | + eslint.configs.recommended, |
| 20 | + ...tseslint.configs.strictTypeChecked, |
| 21 | + { |
| 22 | + languageOptions: { |
| 23 | + parserOptions: { |
| 24 | + project: true, |
| 25 | + ecmaFeatures: { jsx: true }, |
| 26 | + }, |
| 27 | + }, |
| 28 | + }, |
| 29 | + prettierConfig, |
| 30 | + |
| 31 | + { |
| 32 | + linterOptions: { |
| 33 | + reportUnusedDisableDirectives: 'error', |
| 34 | + }, |
| 35 | + plugins: { |
| 36 | + import: importPlugin, |
| 37 | + react, |
| 38 | + }, |
| 39 | + }, |
| 40 | + |
| 41 | + { |
| 42 | + settings: { |
| 43 | + 'import/core-modules': ['bun:test'], |
| 44 | + }, |
| 45 | + |
| 46 | + rules: { |
| 47 | + 'import/order': [ |
| 48 | + 'error', |
| 49 | + { alphabetize: { order: 'asc' }, 'newlines-between': 'always' }, |
| 50 | + ], |
| 51 | + 'no-unused-vars': [ |
| 52 | + 'error', |
| 53 | + { varsIgnorePattern: '[iI]gnored', argsIgnorePattern: '^_' }, |
| 54 | + ], |
| 55 | + curly: 'error', |
| 56 | + 'default-case': 'error', |
| 57 | + }, |
| 58 | + }, |
| 59 | + { |
| 60 | + files: ['**/*.ts', '**/*.tsx', '**/*.mts'], |
| 61 | + rules: { |
| 62 | + 'no-unused-vars': 'off', |
| 63 | + '@typescript-eslint/no-unused-vars': [ |
| 64 | + 'error', |
| 65 | + { varsIgnorePattern: '[iI]gnored', argsIgnorePattern: '^_' }, |
| 66 | + ], |
| 67 | + 'no-void': ['error', { allowAsStatement: true }], |
| 68 | + }, |
| 69 | + }, |
| 70 | + { |
| 71 | + files: ['**/*.spec.ts', '**/*.spec.tsx'], |
| 72 | + plugins: { jest }, |
| 73 | + settings: { jest: { version: 29 } }, |
| 74 | + ...jest.configs['flat/recommended'], |
| 75 | + }, |
| 76 | +); |
0 commit comments