|
| 1 | +import { fileURLToPath } from 'url'; |
| 2 | +import { dirname } from 'path'; |
| 3 | +import eslintPluginImport from 'eslint-plugin-import'; |
| 4 | +import eslintPluginPrettier from 'eslint-plugin-prettier'; |
| 5 | +import eslintPluginTypescript from '@typescript-eslint/eslint-plugin'; |
| 6 | +import parser from '@typescript-eslint/parser'; |
| 7 | + |
| 8 | +const __filename = fileURLToPath(import.meta.url); |
| 9 | +const __dirname = dirname(__filename); |
| 10 | + |
| 11 | +export default [ |
| 12 | + { |
| 13 | + ignores: [ |
| 14 | + '**/tests/*', |
| 15 | + '**/build/**', |
| 16 | + '**/*.js', |
| 17 | + '**/*.d.ts', |
| 18 | + ], |
| 19 | + files: ['**/*.ts'], |
| 20 | + languageOptions: { |
| 21 | + parser, |
| 22 | + parserOptions: { |
| 23 | + tsconfigRootDir: __dirname, |
| 24 | + project: ['./tsconfig.eslint.json'], |
| 25 | + sourceType: 'module', |
| 26 | + }, |
| 27 | + globals: { |
| 28 | + console: false, // no-console rule |
| 29 | + }, |
| 30 | + }, |
| 31 | + plugins: { |
| 32 | + '@typescript-eslint': eslintPluginTypescript, |
| 33 | + import: eslintPluginImport, |
| 34 | + prettier: eslintPluginPrettier, |
| 35 | + }, |
| 36 | + rules: { |
| 37 | + 'no-constant-condition': 'warn', |
| 38 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 39 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 40 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 41 | + '@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false, variables: true }], |
| 42 | + '@typescript-eslint/explicit-member-accessibility': 'error', |
| 43 | + 'no-console': 'error', |
| 44 | + '@typescript-eslint/ban-ts-comment': 'warn', |
| 45 | + '@typescript-eslint/consistent-type-imports': 'error', |
| 46 | + 'import/no-cycle': 'error', |
| 47 | + 'import/order': [ |
| 48 | + 'error', |
| 49 | + { |
| 50 | + groups: ['type', ['builtin', 'external'], 'parent', 'sibling', 'index'], |
| 51 | + alphabetize: { |
| 52 | + order: 'asc', |
| 53 | + }, |
| 54 | + 'newlines-between': 'always', |
| 55 | + }, |
| 56 | + ], |
| 57 | + 'import/no-extraneous-dependencies': [ |
| 58 | + 'error', |
| 59 | + { |
| 60 | + devDependencies: false, |
| 61 | + }, |
| 62 | + ], |
| 63 | + 'prettier/prettier': 'error', |
| 64 | + }, |
| 65 | + }, |
| 66 | + { |
| 67 | + files: ['jest.config.ts', 'eslint.config.js'], |
| 68 | + languageOptions: { |
| 69 | + parserOptions: { |
| 70 | + sourceType: 'commonjs', |
| 71 | + }, |
| 72 | + globals: { |
| 73 | + require: true, |
| 74 | + module: true, |
| 75 | + __dirname: true, |
| 76 | + }, |
| 77 | + }, |
| 78 | + }, |
| 79 | + { |
| 80 | + files: ['*.test.ts', '**/__tests__/**', '**/tests/**', 'jest.*.ts', '**/samples/**'], |
| 81 | + languageOptions: { |
| 82 | + globals: { |
| 83 | + describe: true, |
| 84 | + test: true, |
| 85 | + expect: true, |
| 86 | + jest: true, |
| 87 | + }, |
| 88 | + }, |
| 89 | + rules: { |
| 90 | + 'import/no-extraneous-dependencies': [ |
| 91 | + 'error', |
| 92 | + { |
| 93 | + devDependencies: true, |
| 94 | + }, |
| 95 | + ], |
| 96 | + }, |
| 97 | + }, |
| 98 | +]; |
0 commit comments