|
| 1 | +import js from '@eslint/js'; |
| 2 | +import tseslint from '@typescript-eslint/eslint-plugin'; |
| 3 | +import tsparser from '@typescript-eslint/parser'; |
| 4 | +import importPlugin from 'eslint-plugin-import'; |
| 5 | +import nodePlugin from 'eslint-plugin-n'; |
| 6 | +import promisePlugin from 'eslint-plugin-promise'; |
| 7 | + |
| 8 | +export default [ |
| 9 | + // Base JavaScript rules |
| 10 | + js.configs.recommended, |
| 11 | + |
| 12 | + // TypeScript files configuration |
| 13 | + { |
| 14 | + files: ['**/*.ts', '**/*.tsx'], |
| 15 | + languageOptions: { |
| 16 | + parser: tsparser, |
| 17 | + parserOptions: { |
| 18 | + ecmaVersion: 'latest', |
| 19 | + sourceType: 'module', |
| 20 | + }, |
| 21 | + globals: { |
| 22 | + console: 'readonly', |
| 23 | + navigator: 'readonly', |
| 24 | + self: 'readonly', |
| 25 | + Summarizer: 'readonly', |
| 26 | + Blob: 'readonly', |
| 27 | + URL: 'readonly', |
| 28 | + FileReader: 'readonly', |
| 29 | + AudioContext: 'readonly', |
| 30 | + fetch: 'readonly', |
| 31 | + }, |
| 32 | + }, |
| 33 | + plugins: { |
| 34 | + '@typescript-eslint': tseslint, |
| 35 | + 'import': importPlugin, |
| 36 | + 'n': nodePlugin, |
| 37 | + 'promise': promisePlugin, |
| 38 | + }, |
| 39 | + rules: { |
| 40 | + // TypeScript specific rules |
| 41 | + '@typescript-eslint/no-unused-vars': ['error', { |
| 42 | + 'argsIgnorePattern': '^_', |
| 43 | + 'varsIgnorePattern': '^_' |
| 44 | + }], |
| 45 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 46 | + '@typescript-eslint/no-var-requires': 'error', |
| 47 | + '@typescript-eslint/explicit-function-return-type': 'warn', |
| 48 | + '@typescript-eslint/no-inferrable-types': 'error', |
| 49 | + |
| 50 | + // Import rules |
| 51 | + 'import/order': ['error', { |
| 52 | + 'groups': [ |
| 53 | + 'builtin', |
| 54 | + 'external', |
| 55 | + 'internal', |
| 56 | + 'parent', |
| 57 | + 'sibling', |
| 58 | + 'index' |
| 59 | + ], |
| 60 | + 'newlines-between': 'always', |
| 61 | + 'alphabetize': { |
| 62 | + 'order': 'asc', |
| 63 | + 'caseInsensitive': true |
| 64 | + } |
| 65 | + }], |
| 66 | + 'import/no-duplicates': 'error', |
| 67 | + |
| 68 | + // Promise rules |
| 69 | + 'promise/always-return': 'error', |
| 70 | + 'promise/no-return-wrap': 'error', |
| 71 | + 'promise/param-names': 'error', |
| 72 | + 'promise/catch-or-return': 'error', |
| 73 | + 'promise/no-nesting': 'warn', |
| 74 | + 'promise/no-promise-in-callback': 'warn', |
| 75 | + |
| 76 | + // Code quality rules |
| 77 | + 'no-console': 'warn', |
| 78 | + 'no-debugger': 'error', |
| 79 | + 'no-unused-vars': 'off', // Use TypeScript version instead |
| 80 | + 'no-async-promise-executor': 'warn', // Allow async promise executors with warning |
| 81 | + |
| 82 | + // Style rules |
| 83 | + 'indent': ['error', 2], |
| 84 | + 'quotes': ['error', 'single'], |
| 85 | + 'semi': ['error', 'always'], |
| 86 | + 'comma-dangle': ['error', 'always-multiline'], |
| 87 | + |
| 88 | + // Best practices |
| 89 | + 'eqeqeq': ['error', 'always'], |
| 90 | + 'curly': ['error', 'all'], |
| 91 | + 'no-eval': 'error', |
| 92 | + 'no-implied-eval': 'error', |
| 93 | + 'no-new-func': 'error', |
| 94 | + 'no-return-assign': 'error', |
| 95 | + 'no-sequences': 'error', |
| 96 | + 'no-throw-literal': 'error', |
| 97 | + 'no-unmodified-loop-condition': 'error', |
| 98 | + 'no-unused-expressions': 'error', |
| 99 | + 'prefer-const': 'error', |
| 100 | + 'prefer-arrow-callback': 'error', |
| 101 | + }, |
| 102 | + settings: { |
| 103 | + 'import/resolver': { |
| 104 | + typescript: { |
| 105 | + alwaysTryTypes: true, |
| 106 | + project: './tsconfig.json', |
| 107 | + }, |
| 108 | + }, |
| 109 | + }, |
| 110 | + }, |
| 111 | + |
| 112 | + // Test files configuration |
| 113 | + { |
| 114 | + files: ['**/*.test.ts', '**/*.spec.ts', 'tests/**/*.ts'], |
| 115 | + rules: { |
| 116 | + '@typescript-eslint/no-explicit-any': 'off', |
| 117 | + 'no-console': 'off', |
| 118 | + }, |
| 119 | + }, |
| 120 | + |
| 121 | + // Configuration files |
| 122 | + { |
| 123 | + files: ['*.config.js', '*.config.ts', 'vite.config.*', 'vitest.config.*'], |
| 124 | + rules: { |
| 125 | + '@typescript-eslint/no-var-requires': 'off', |
| 126 | + 'no-console': 'off', |
| 127 | + }, |
| 128 | + }, |
| 129 | + |
| 130 | + // Global ignores |
| 131 | + { |
| 132 | + ignores: [ |
| 133 | + 'node_modules/**', |
| 134 | + 'dist/**', |
| 135 | + 'build/**', |
| 136 | + '*.min.js', |
| 137 | + 'coverage/**', |
| 138 | + ], |
| 139 | + }, |
| 140 | +]; |
0 commit comments