|
| 1 | +const eslintPlugin = require('eslint-plugin-eslint-plugin'); |
| 2 | +const tseslint = require('@typescript-eslint/eslint-plugin'); |
| 3 | +const tsParser = require('@typescript-eslint/parser'); |
| 4 | +const jest = require('eslint-plugin-jest'); |
| 5 | +const importPlugin = require('eslint-plugin-import'); |
| 6 | +const eslintComments = require('eslint-plugin-eslint-comments'); |
| 7 | + |
| 8 | +module.exports = [ |
| 9 | + eslintPlugin.configs['flat/recommended'], |
| 10 | + { |
| 11 | + files: ['src/**/*.ts'], |
| 12 | + plugins: { |
| 13 | + '@typescript-eslint': tseslint, |
| 14 | + 'jest': jest, |
| 15 | + 'import': importPlugin, |
| 16 | + 'eslint-comments': eslintComments, |
| 17 | + }, |
| 18 | + languageOptions: { |
| 19 | + parser: tsParser, |
| 20 | + parserOptions: { |
| 21 | + project: ['./tsconfig.json'], |
| 22 | + }, |
| 23 | + }, |
| 24 | + rules: { |
| 25 | + // TypeScript ESLint recommended rules |
| 26 | + ...tseslint.configs.recommended.rules, |
| 27 | + |
| 28 | + // TypeScript specific rules from @croct/typescript config |
| 29 | + '@typescript-eslint/array-type': ['error', { |
| 30 | + default: 'array-simple', |
| 31 | + }], |
| 32 | + '@typescript-eslint/prefer-as-const': 'error', |
| 33 | + '@typescript-eslint/adjacent-overload-signatures': 'error', |
| 34 | + '@typescript-eslint/strict-boolean-expressions': ['error', { |
| 35 | + allowString: false, |
| 36 | + allowNumber: false, |
| 37 | + allowNullableObject: false, |
| 38 | + }], |
| 39 | + '@typescript-eslint/prefer-optional-chain': 'error', |
| 40 | + '@typescript-eslint/no-shadow': ['error', { |
| 41 | + ignoreTypeValueShadow: true, |
| 42 | + ignoreFunctionTypeParameterNameValueShadow: true, |
| 43 | + }], |
| 44 | + '@typescript-eslint/no-empty-interface': 'off', |
| 45 | + '@typescript-eslint/explicit-member-accessibility': ['error'], |
| 46 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 47 | + '@typescript-eslint/explicit-function-return-type': ['error'], |
| 48 | + '@typescript-eslint/no-explicit-any': 'off', |
| 49 | + '@typescript-eslint/no-use-before-define': 'off', |
| 50 | + '@typescript-eslint/no-unused-expressions': 'error', |
| 51 | + '@typescript-eslint/no-unused-vars': ['error', { |
| 52 | + args: 'after-used', |
| 53 | + ignoreRestSiblings: true, |
| 54 | + }], |
| 55 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 56 | + '@typescript-eslint/no-namespace': 'off', |
| 57 | + |
| 58 | + // Disable base rules in favor of TypeScript versions |
| 59 | + 'no-shadow': 'off', |
| 60 | + 'no-use-before-define': 'off', |
| 61 | + 'no-unused-expressions': 'off', |
| 62 | + 'no-unused-vars': 'off', |
| 63 | + 'no-undef': 'off', |
| 64 | + |
| 65 | + // JavaScript rules from @croct/javascript config (subset relevant for this project) |
| 66 | + 'indent': ['error', 4, {SwitchCase: 1}], |
| 67 | + 'linebreak-style': ['error', 'unix'], |
| 68 | + 'quotes': ['error', 'single', {avoidEscape: true}], |
| 69 | + 'semi': ['error', 'always'], |
| 70 | + 'comma-dangle': ['error', 'always-multiline'], |
| 71 | + 'max-len': ['error', {code: 120}], |
| 72 | + 'no-multiple-empty-lines': ['error', {max: 1, maxEOF: 0, maxBOF: 0}], |
| 73 | + 'eol-last': ['error', 'always'], |
| 74 | + 'object-curly-spacing': ['error', 'never'], |
| 75 | + |
| 76 | + // Import rules |
| 77 | + 'import/no-duplicates': 'error', |
| 78 | + 'import/first': 'error', |
| 79 | + 'import/newline-after-import': 'error', |
| 80 | + |
| 81 | + // ESLint comments rules |
| 82 | + 'eslint-comments/disable-enable-pair': ['error', {allowWholeFile: true}], |
| 83 | + 'eslint-comments/no-unused-disable': 'error', |
| 84 | + }, |
| 85 | + }, |
| 86 | + { |
| 87 | + files: ['src/**/*.test.ts'], |
| 88 | + plugins: { |
| 89 | + 'jest': jest, |
| 90 | + }, |
| 91 | + rules: { |
| 92 | + ...jest.configs.recommended.rules, |
| 93 | + 'jest/consistent-test-it': ['error', {fn: 'it'}], |
| 94 | + 'jest/prefer-lowercase-title': ['error', {ignore: ['describe']}], |
| 95 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 96 | + }, |
| 97 | + }, |
| 98 | +]; |
0 commit comments