|
| 1 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 2 | +import prettier from 'eslint-plugin-prettier'; |
| 3 | +import globals from 'globals'; |
| 4 | +import tsParser from '@typescript-eslint/parser'; |
| 5 | +import path from 'node:path'; |
| 6 | +import { fileURLToPath } from 'node:url'; |
| 7 | +import js from '@eslint/js'; |
| 8 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 9 | +import { includeIgnoreFile } from '@eslint/compat'; |
| 10 | + |
| 11 | +const __filename = fileURLToPath(import.meta.url); |
| 12 | +const __dirname = path.dirname(__filename); |
| 13 | +const gitignorePath = path.resolve(__dirname, '.gitignore'); |
| 14 | + |
| 15 | +const compat = new FlatCompat({ |
| 16 | + baseDirectory: __dirname, |
| 17 | + recommendedConfig: js.configs.recommended, |
| 18 | + allConfig: js.configs.all, |
| 19 | +}); |
| 20 | + |
| 21 | +export default [ |
| 22 | + includeIgnoreFile(gitignorePath), |
| 23 | + |
| 24 | + ...compat.extends( |
| 25 | + 'eslint:recommended', |
| 26 | + 'plugin:@typescript-eslint/recommended', |
| 27 | + ), |
| 28 | + |
| 29 | + { |
| 30 | + files: ['**/*.js', '**/*.mjs', '**/*.ts', '**/*.tsx'], |
| 31 | + |
| 32 | + plugins: { |
| 33 | + '@typescript-eslint': typescriptEslint, |
| 34 | + prettier, |
| 35 | + }, |
| 36 | + |
| 37 | + languageOptions: { |
| 38 | + globals: { |
| 39 | + ...globals.browser, |
| 40 | + ...globals.jest, |
| 41 | + ...globals.node, |
| 42 | + }, |
| 43 | + parser: tsParser, |
| 44 | + }, |
| 45 | + |
| 46 | + rules: { |
| 47 | + '@typescript-eslint/no-var-requires': 'off', |
| 48 | + '@typescript-eslint/no-explicit-any': 'off', |
| 49 | + 'no-console': 'error', |
| 50 | + 'no-debugger': 'error', |
| 51 | + 'prettier/prettier': 'error', |
| 52 | + }, |
| 53 | + }, |
| 54 | + |
| 55 | + { |
| 56 | + files: ['__tests__/**'], |
| 57 | + |
| 58 | + rules: { |
| 59 | + '@typescript-eslint/no-require-imports': 'off', |
| 60 | + }, |
| 61 | + }, |
| 62 | + |
| 63 | + { |
| 64 | + ignores: ['examples/*'], |
| 65 | + }, |
| 66 | +]; |
0 commit comments