|
| 1 | +const js = require('@eslint/js') |
| 2 | +const typescript = require('@typescript-eslint/eslint-plugin') |
| 3 | +const typescriptParser = require('@typescript-eslint/parser') |
| 4 | +const prettier = require('eslint-plugin-prettier') |
| 5 | +const prettierConfig = require('eslint-config-prettier') |
| 6 | + |
| 7 | +module.exports = [ |
| 8 | + // Base recommended config for JavaScript files |
| 9 | + js.configs.recommended, |
| 10 | + |
| 11 | + // JavaScript files |
| 12 | + { |
| 13 | + files: ['**/*.js', '**/*.mjs'], |
| 14 | + languageOptions: { |
| 15 | + ecmaVersion: 2020, |
| 16 | + sourceType: 'module', |
| 17 | + globals: { |
| 18 | + process: 'readonly', |
| 19 | + Buffer: 'readonly', |
| 20 | + __dirname: 'readonly', |
| 21 | + __filename: 'readonly', |
| 22 | + module: 'readonly', |
| 23 | + require: 'readonly', |
| 24 | + exports: 'readonly', |
| 25 | + global: 'readonly', |
| 26 | + console: 'readonly', |
| 27 | + setImmediate: 'readonly', |
| 28 | + }, |
| 29 | + }, |
| 30 | + plugins: { |
| 31 | + prettier, |
| 32 | + }, |
| 33 | + rules: { |
| 34 | + 'prettier/prettier': 'error', |
| 35 | + }, |
| 36 | + }, |
| 37 | + |
| 38 | + // TypeScript files |
| 39 | + { |
| 40 | + files: ['**/*.ts'], |
| 41 | + languageOptions: { |
| 42 | + parser: typescriptParser, |
| 43 | + parserOptions: { |
| 44 | + ecmaVersion: 2020, |
| 45 | + sourceType: 'module', |
| 46 | + project: './tsconfig.json', |
| 47 | + warnOnUnsupportedTypeScriptVersion: false, |
| 48 | + }, |
| 49 | + globals: { |
| 50 | + process: 'readonly', |
| 51 | + Buffer: 'readonly', |
| 52 | + __dirname: 'readonly', |
| 53 | + __filename: 'readonly', |
| 54 | + module: 'readonly', |
| 55 | + require: 'readonly', |
| 56 | + exports: 'readonly', |
| 57 | + global: 'readonly', |
| 58 | + console: 'readonly', |
| 59 | + setImmediate: 'readonly', |
| 60 | + }, |
| 61 | + }, |
| 62 | + plugins: { |
| 63 | + '@typescript-eslint': typescript, |
| 64 | + prettier, |
| 65 | + }, |
| 66 | + rules: { |
| 67 | + // Base JavaScript rules we want to keep |
| 68 | + 'constructor-super': 'error', |
| 69 | + 'for-direction': 'error', |
| 70 | + 'getter-return': 'error', |
| 71 | + 'no-async-promise-executor': 'error', |
| 72 | + 'no-case-declarations': 'error', |
| 73 | + 'no-class-assign': 'error', |
| 74 | + 'no-compare-neg-zero': 'error', |
| 75 | + 'no-cond-assign': 'error', |
| 76 | + 'no-const-assign': 'error', |
| 77 | + 'no-constant-condition': 'error', |
| 78 | + 'no-control-regex': 'error', |
| 79 | + 'no-debugger': 'error', |
| 80 | + 'no-delete-var': 'error', |
| 81 | + 'no-dupe-args': 'error', |
| 82 | + 'no-dupe-class-members': 'error', |
| 83 | + 'no-dupe-else-if': 'error', |
| 84 | + 'no-dupe-keys': 'error', |
| 85 | + 'no-duplicate-case': 'error', |
| 86 | + 'no-empty': 'error', |
| 87 | + 'no-empty-character-class': 'error', |
| 88 | + 'no-empty-pattern': 'error', |
| 89 | + 'no-ex-assign': 'error', |
| 90 | + 'no-extra-boolean-cast': 'error', |
| 91 | + 'no-extra-semi': 'error', |
| 92 | + 'no-fallthrough': 'error', |
| 93 | + 'no-func-assign': 'error', |
| 94 | + 'no-global-assign': 'error', |
| 95 | + 'no-import-assign': 'error', |
| 96 | + 'no-inner-declarations': 'error', |
| 97 | + 'no-invalid-regexp': 'error', |
| 98 | + 'no-irregular-whitespace': 'error', |
| 99 | + 'no-misleading-character-class': 'error', |
| 100 | + 'no-mixed-spaces-and-tabs': 'error', |
| 101 | + 'no-new-symbol': 'error', |
| 102 | + 'no-nonoctal-decimal-escape': 'error', |
| 103 | + 'no-obj-calls': 'error', |
| 104 | + 'no-octal': 'error', |
| 105 | + 'no-prototype-builtins': 'error', |
| 106 | + 'no-redeclare': 'error', |
| 107 | + 'no-regex-spaces': 'error', |
| 108 | + 'no-self-assign': 'error', |
| 109 | + 'no-setter-return': 'error', |
| 110 | + 'no-shadow-restricted-names': 'error', |
| 111 | + 'no-sparse-arrays': 'error', |
| 112 | + 'no-this-before-super': 'error', |
| 113 | + 'no-unexpected-multiline': 'error', |
| 114 | + 'no-unreachable': 'error', |
| 115 | + 'no-unsafe-finally': 'error', |
| 116 | + 'no-unsafe-negation': 'error', |
| 117 | + 'no-useless-catch': 'error', |
| 118 | + 'no-useless-escape': 'off', |
| 119 | + 'no-with': 'error', |
| 120 | + 'require-yield': 'error', |
| 121 | + 'use-isnan': 'error', |
| 122 | + 'valid-typeof': 'error', |
| 123 | + |
| 124 | + // Disable rules that TypeScript handles better |
| 125 | + 'no-unused-vars': 'off', |
| 126 | + 'no-undef': 'off', |
| 127 | + |
| 128 | + // TypeScript-specific rules |
| 129 | + '@typescript-eslint/no-unused-vars': [ |
| 130 | + 'error', |
| 131 | + { |
| 132 | + argsIgnorePattern: '^_', |
| 133 | + varsIgnorePattern: '^_', |
| 134 | + caughtErrorsIgnorePattern: '^_|^e$|^error$', |
| 135 | + destructuredArrayIgnorePattern: '^_', |
| 136 | + ignoreRestSiblings: true, |
| 137 | + }, |
| 138 | + ], |
| 139 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 140 | + |
| 141 | + 'prettier/prettier': 'error', |
| 142 | + |
| 143 | + // Custom rules from original config |
| 144 | + 'arrow-body-style': ['error'], |
| 145 | + 'no-template-curly-in-string': 'error', |
| 146 | + 'no-useless-concat': 'error', |
| 147 | + 'no-var': 'error', |
| 148 | + 'one-var': ['error', 'never'], |
| 149 | + 'prefer-arrow-callback': ['error', { allowNamedFunctions: true }], |
| 150 | + 'prefer-const': 'error', |
| 151 | + 'prefer-template': 'error', |
| 152 | + 'template-curly-spacing': 'error', |
| 153 | + 'template-tag-spacing': 'error', |
| 154 | + quotes: ['error', 'single', { avoidEscape: true }], |
| 155 | + |
| 156 | + // TypeScript-specific rule overrides from original config |
| 157 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 158 | + '@typescript-eslint/no-unsafe-argument': 'off', |
| 159 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 160 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 161 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 162 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 163 | + '@typescript-eslint/no-var-requires': 'off', |
| 164 | + '@typescript-eslint/no-require-imports': 'off', |
| 165 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 166 | + }, |
| 167 | + }, |
| 168 | + |
| 169 | + // Jest test files |
| 170 | + { |
| 171 | + files: ['**/*.spec.js'], |
| 172 | + languageOptions: { |
| 173 | + globals: { |
| 174 | + describe: 'readonly', |
| 175 | + it: 'readonly', |
| 176 | + test: 'readonly', |
| 177 | + expect: 'readonly', |
| 178 | + beforeEach: 'readonly', |
| 179 | + afterEach: 'readonly', |
| 180 | + beforeAll: 'readonly', |
| 181 | + afterAll: 'readonly', |
| 182 | + jest: 'readonly', |
| 183 | + }, |
| 184 | + }, |
| 185 | + }, |
| 186 | + |
| 187 | + // Prettier config |
| 188 | + prettierConfig, |
| 189 | + |
| 190 | + // Ignore patterns (replacing .eslintignore) |
| 191 | + { |
| 192 | + ignores: [ |
| 193 | + 'node_modules/**', |
| 194 | + 'bin/**', |
| 195 | + 'dist/**', |
| 196 | + 'website/.astro/**', |
| 197 | + 'website/build/**', |
| 198 | + 'website/src/**', |
| 199 | + ], |
| 200 | + }, |
| 201 | +] |
0 commit comments