|
| 1 | +import eslint from '@eslint/js'; |
| 2 | +import stylistic from '@stylistic/eslint-plugin'; |
| 3 | +import vitest from '@vitest/eslint-plugin'; |
| 4 | +import importPlugin from 'eslint-plugin-import'; |
| 5 | +import globals from 'globals'; |
| 6 | +import tseslint from 'typescript-eslint'; |
| 7 | + |
| 8 | +export default tseslint.config( |
| 9 | + // Global ignores |
| 10 | + { |
| 11 | + ignores: [ |
| 12 | + 'dist/**', |
| 13 | + 'docs/**', |
| 14 | + 'src/generated-client/**', |
| 15 | + 'lib/**', |
| 16 | + 'node_modules/**' |
| 17 | + ] |
| 18 | + }, |
| 19 | + |
| 20 | + // Base config for all files |
| 21 | + eslint.configs.recommended, |
| 22 | + ...tseslint.configs.recommended, |
| 23 | + |
| 24 | + // Main source files config |
| 25 | + { |
| 26 | + files: ['**/*.ts', '**/*.mjs', '**/*.js'], |
| 27 | + plugins: { |
| 28 | + '@stylistic': stylistic, |
| 29 | + 'import': importPlugin |
| 30 | + }, |
| 31 | + languageOptions: { |
| 32 | + globals: { |
| 33 | + ...globals.node |
| 34 | + } |
| 35 | + }, |
| 36 | + settings: { |
| 37 | + 'import/resolver': { |
| 38 | + typescript: true, |
| 39 | + node: true |
| 40 | + } |
| 41 | + }, |
| 42 | + rules: { |
| 43 | + 'import/order': ['error', { |
| 44 | + 'alphabetize': { 'order': 'asc', 'caseInsensitive': true }, |
| 45 | + 'newlines-between': 'always-and-inside-groups' |
| 46 | + }], |
| 47 | + |
| 48 | + '@stylistic/type-annotation-spacing': ['error'], |
| 49 | + |
| 50 | + '@typescript-eslint/consistent-type-imports': ['error'], |
| 51 | + |
| 52 | + 'array-callback-return': ['error'], |
| 53 | + 'arrow-spacing': ['error'], |
| 54 | + 'block-spacing': ['error'], |
| 55 | + 'brace-style': ['error', '1tbs', { 'allowSingleLine': true }], |
| 56 | + 'comma-dangle': ['error', 'never'], |
| 57 | + 'comma-spacing': ['error'], |
| 58 | + 'curly': ['error', 'multi-line'], |
| 59 | + 'eol-last': ['error'], |
| 60 | + 'indent': ['error', 'tab', { 'SwitchCase': 1 }], |
| 61 | + 'jsx-quotes': ['error', 'prefer-single'], |
| 62 | + 'key-spacing': ['error'], |
| 63 | + 'keyword-spacing': ['error'], |
| 64 | + 'max-statements-per-line': ['error'], |
| 65 | + 'no-floating-decimal': ['error'], |
| 66 | + 'no-multi-spaces': ['error'], |
| 67 | + 'no-multiple-empty-lines': ['error', { 'max': 1 }], |
| 68 | + 'no-restricted-globals': ['error'], |
| 69 | + 'no-trailing-spaces': ['error'], |
| 70 | + 'no-unreachable': ['error'], |
| 71 | + 'no-unused-expressions': ['error', { 'allowShortCircuit': true, 'allowTernary': true, 'allowTaggedTemplates': true }], |
| 72 | + 'object-curly-spacing': ['error', 'always'], |
| 73 | + 'one-var': ['error', 'never'], |
| 74 | + 'padded-blocks': ['error', 'never'], |
| 75 | + 'prefer-const': ['error', { 'destructuring': 'all' }], |
| 76 | + 'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': false }], |
| 77 | + 'semi': ['error'], |
| 78 | + 'no-var': ['error'], |
| 79 | + 'space-before-blocks': ['error'], |
| 80 | + 'space-before-function-paren': ['error', { 'anonymous': 'never', 'named': 'never', 'asyncArrow': 'always' }], |
| 81 | + 'space-infix-ops': 'error', |
| 82 | + 'yoda': 'error' |
| 83 | + } |
| 84 | + }, |
| 85 | + |
| 86 | + // Source files - browser environment |
| 87 | + { |
| 88 | + files: ['src/**/*.ts'], |
| 89 | + languageOptions: { |
| 90 | + globals: { |
| 91 | + ...globals.browser |
| 92 | + } |
| 93 | + } |
| 94 | + }, |
| 95 | + |
| 96 | + // Test files config |
| 97 | + { |
| 98 | + files: ['**/*.test.ts'], |
| 99 | + plugins: { |
| 100 | + vitest |
| 101 | + }, |
| 102 | + languageOptions: { |
| 103 | + globals: { |
| 104 | + ...globals.node |
| 105 | + } |
| 106 | + }, |
| 107 | + rules: { |
| 108 | + ...vitest.configs.recommended.rules, |
| 109 | + 'vitest/consistent-test-it': ['error'], |
| 110 | + 'vitest/prefer-lowercase-title': ['error', { 'ignoreTopLevelDescribe': true }], |
| 111 | + 'vitest/require-top-level-describe': ['error'], |
| 112 | + // Disable because we use custom `itIf` helper that the plugin doesn't recognize |
| 113 | + 'vitest/no-standalone-expect': 'off', |
| 114 | + // Disable rules that require type information (would need parserOptions.project) |
| 115 | + 'vitest/valid-title': 'off' |
| 116 | + } |
| 117 | + } |
| 118 | +); |
0 commit comments