|
| 1 | +const eslint = require('@eslint/js') |
| 2 | +const tseslint = require('typescript-eslint') |
| 3 | +const jestPlugin = require('eslint-plugin-jest') |
| 4 | +const githubPlugin = require('eslint-plugin-github') |
| 5 | +const prettierPlugin = require('eslint-plugin-prettier') |
| 6 | + |
| 7 | +module.exports = tseslint.config( |
| 8 | + // Ignore patterns |
| 9 | + { |
| 10 | + ignores: [ |
| 11 | + '**/node_modules/**', |
| 12 | + '**/dist/**', |
| 13 | + '**/coverage/**', |
| 14 | + '**/*.json' |
| 15 | + ] |
| 16 | + }, |
| 17 | + |
| 18 | + // Base ESLint recommended rules |
| 19 | + eslint.configs.recommended, |
| 20 | + |
| 21 | + // TypeScript recommended configurations |
| 22 | + ...tseslint.configs.recommended, |
| 23 | + |
| 24 | + // TypeScript type-checked rules |
| 25 | + ...tseslint.configs.recommendedTypeChecked, |
| 26 | + |
| 27 | + // TypeScript files configuration |
| 28 | + { |
| 29 | + files: ['**/*.ts'], |
| 30 | + languageOptions: { |
| 31 | + parserOptions: { |
| 32 | + projectService: true, |
| 33 | + tsconfigRootDir: __dirname |
| 34 | + } |
| 35 | + }, |
| 36 | + plugins: { |
| 37 | + jest: jestPlugin, |
| 38 | + github: githubPlugin, |
| 39 | + prettier: prettierPlugin |
| 40 | + }, |
| 41 | + rules: { |
| 42 | + // ESLint core rules |
| 43 | + 'camelcase': 'off', |
| 44 | + 'no-console': 'off', |
| 45 | + 'no-unused-vars': 'off', |
| 46 | + 'semi': ['error', 'never'], |
| 47 | + 'func-call-spacing': ['error', 'never'], |
| 48 | + |
| 49 | + // Prettier integration |
| 50 | + 'prettier/prettier': 'error', |
| 51 | + |
| 52 | + // TypeScript custom rules |
| 53 | + '@typescript-eslint/array-type': 'error', |
| 54 | + '@typescript-eslint/await-thenable': 'error', |
| 55 | + '@typescript-eslint/ban-ts-comment': 'error', |
| 56 | + '@typescript-eslint/consistent-type-assertions': 'error', |
| 57 | + '@typescript-eslint/explicit-member-accessibility': [ |
| 58 | + 'error', |
| 59 | + { accessibility: 'no-public' } |
| 60 | + ], |
| 61 | + '@typescript-eslint/explicit-function-return-type': [ |
| 62 | + 'error', |
| 63 | + { allowExpressions: true } |
| 64 | + ], |
| 65 | + '@typescript-eslint/no-array-constructor': 'error', |
| 66 | + '@typescript-eslint/no-empty-interface': 'error', |
| 67 | + '@typescript-eslint/no-explicit-any': 'error', |
| 68 | + '@typescript-eslint/no-extraneous-class': 'error', |
| 69 | + '@typescript-eslint/no-for-in-array': 'error', |
| 70 | + '@typescript-eslint/no-inferrable-types': 'error', |
| 71 | + '@typescript-eslint/no-misused-new': 'error', |
| 72 | + '@typescript-eslint/no-namespace': 'error', |
| 73 | + '@typescript-eslint/no-non-null-assertion': 'warn', |
| 74 | + '@typescript-eslint/no-require-imports': 'error', |
| 75 | + '@typescript-eslint/no-unnecessary-qualifier': 'error', |
| 76 | + '@typescript-eslint/no-unnecessary-type-assertion': 'error', |
| 77 | + '@typescript-eslint/no-unused-vars': 'error', |
| 78 | + '@typescript-eslint/no-useless-constructor': 'error', |
| 79 | + '@typescript-eslint/no-var-requires': 'error', |
| 80 | + '@typescript-eslint/prefer-for-of': 'warn', |
| 81 | + '@typescript-eslint/prefer-function-type': 'warn', |
| 82 | + '@typescript-eslint/prefer-includes': 'error', |
| 83 | + '@typescript-eslint/prefer-string-starts-ends-with': 'error', |
| 84 | + '@typescript-eslint/promise-function-async': 'error', |
| 85 | + '@typescript-eslint/require-array-sort-compare': 'error', |
| 86 | + '@typescript-eslint/restrict-plus-operands': 'error', |
| 87 | + '@typescript-eslint/space-before-function-paren': 'off', |
| 88 | + '@typescript-eslint/unbound-method': 'error', |
| 89 | + |
| 90 | + // GitHub plugin rules |
| 91 | + 'eslint-comments/no-use': 'off', |
| 92 | + 'eslint-comments/no-unused-disable': 'off', |
| 93 | + 'i18n-text/no-en': 'off', |
| 94 | + 'import/no-namespace': 'off', |
| 95 | + |
| 96 | + // Jest plugin rules |
| 97 | + ...jestPlugin.configs.recommended.rules |
| 98 | + } |
| 99 | + }, |
| 100 | + |
| 101 | + // JavaScript files configuration |
| 102 | + { |
| 103 | + files: ['**/*.js'], |
| 104 | + ...tseslint.configs.disableTypeChecked, |
| 105 | + rules: { |
| 106 | + // Disable TypeScript-specific rules for JavaScript files |
| 107 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 108 | + '@typescript-eslint/no-explicit-any': 'off', |
| 109 | + '@typescript-eslint/explicit-member-accessibility': 'off' |
| 110 | + } |
| 111 | + } |
| 112 | +) |
0 commit comments