|
| 1 | +import eslint from '@eslint/js'; |
| 2 | +import tseslint from 'typescript-eslint'; |
| 3 | +import stylistic from '@stylistic/eslint-plugin'; |
| 4 | +import importPlugin from 'eslint-plugin-import'; |
| 5 | +import simpleImportSort from 'eslint-plugin-simple-import-sort'; |
| 6 | +import unusedImports from 'eslint-plugin-unused-imports'; |
| 7 | +import unicorn from 'eslint-plugin-unicorn'; |
| 8 | + |
| 9 | +export default tseslint.config( |
| 10 | + // Ignore patterns |
| 11 | + { |
| 12 | + ignores: ['**/lib/**', 'node_modules/**', 'dist/**', 'target/**', 'test-results/**', 'playwright/.cache', 'playwright-report/**'] |
| 13 | + }, |
| 14 | + |
| 15 | + // Base ESLint recommended config |
| 16 | + eslint.configs.recommended, |
| 17 | + |
| 18 | + // TypeScript ESLint recommended configs |
| 19 | + ...tseslint.configs.recommended, |
| 20 | + |
| 21 | + // Unicorn recommended config |
| 22 | + unicorn.configs['flat/recommended'], |
| 23 | + |
| 24 | + // Main configuration |
| 25 | + { |
| 26 | + files: ['**/*.ts', '**/*.tsx'], |
| 27 | + languageOptions: { |
| 28 | + parser: tseslint.parser, |
| 29 | + parserOptions: { |
| 30 | + ecmaVersion: 6, |
| 31 | + sourceType: 'module', |
| 32 | + project: [ |
| 33 | + './tsconfig.eslint.json', |
| 34 | + ], |
| 35 | + }, |
| 36 | + }, |
| 37 | + plugins: { |
| 38 | + '@typescript-eslint': tseslint.plugin, |
| 39 | + '@stylistic': stylistic, |
| 40 | + 'import': importPlugin, |
| 41 | + 'simple-import-sort': simpleImportSort, |
| 42 | + 'unused-imports': unusedImports, |
| 43 | + }, |
| 44 | + rules: { |
| 45 | + 'simple-import-sort/imports': 'error', |
| 46 | + 'simple-import-sort/exports': 'error', |
| 47 | + 'sort-imports': 'off', |
| 48 | + 'import/order': 'off', |
| 49 | + 'unused-imports/no-unused-imports': 'error', |
| 50 | + |
| 51 | + 'no-multiple-empty-lines': ['warn', { |
| 52 | + 'max': 1, |
| 53 | + }], |
| 54 | + |
| 55 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 56 | + |
| 57 | + // Formatting rules using @stylistic plugin |
| 58 | + '@stylistic/indent': ['error', 4, { |
| 59 | + 'MemberExpression': 'off', |
| 60 | + 'SwitchCase': 1, |
| 61 | + }], |
| 62 | + |
| 63 | + '@stylistic/quotes': ['error', 'single', { |
| 64 | + 'allowTemplateLiterals': 'always', |
| 65 | + 'avoidEscape': true, |
| 66 | + }], |
| 67 | + |
| 68 | + '@typescript-eslint/no-explicit-any': 'off', // todo: review |
| 69 | + |
| 70 | + '@typescript-eslint/no-unused-vars': ['warn', { |
| 71 | + 'args': 'none', |
| 72 | + 'vars': 'all', |
| 73 | + 'varsIgnorePattern': '^.*_$', |
| 74 | + }], |
| 75 | + |
| 76 | + 'unicorn/empty-brace-spaces': 'off', |
| 77 | + |
| 78 | + 'unicorn/filename-case': [ 'error', { |
| 79 | + 'cases': { |
| 80 | + 'kebabCase': true, // packages |
| 81 | + 'pascalCase': true, // classes |
| 82 | + 'camelCase': true, // functions |
| 83 | + } |
| 84 | + }], |
| 85 | + |
| 86 | + 'unicorn/no-array-for-each': 'off', |
| 87 | + 'unicorn/no-array-reduce': 'off', |
| 88 | + 'unicorn/no-array-callback-reference': 'off', |
| 89 | + 'unicorn/no-static-only-class': 'off', |
| 90 | + |
| 91 | + 'unicorn/numeric-separators-style': 'off', |
| 92 | + |
| 93 | + 'unicorn/prefer-module': 'off', // fixme disable when we can provide support for ESM |
| 94 | + 'unicorn/prefer-node-protocol': 'off', // fixme requires Node 14.13 or newer, disable until we no longer have to support Node 12 |
| 95 | + 'unicorn/prefer-spread': 'off', |
| 96 | + |
| 97 | + 'unicorn/prevent-abbreviations': [ 'error', { |
| 98 | + 'allowList': { |
| 99 | + 'conf': true, |
| 100 | + 'wdio': true, |
| 101 | + } |
| 102 | + }] |
| 103 | + } |
| 104 | + } |
| 105 | +); |
| 106 | + |
0 commit comments