|
| 1 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 2 | +import jest from 'eslint-plugin-jest'; |
| 3 | +import _import from 'eslint-plugin-import'; |
| 4 | +import {fixupPluginRules} from '@eslint/compat'; |
| 5 | +import globals from 'globals'; |
| 6 | +import tsParser from '@typescript-eslint/parser'; |
| 7 | +import path from 'node:path'; |
| 8 | +import {fileURLToPath} from 'node:url'; |
| 9 | +import js from '@eslint/js'; |
| 10 | +import {FlatCompat} from '@eslint/eslintrc'; |
| 11 | + |
| 12 | +const __filename = fileURLToPath(import.meta.url); |
| 13 | +const __dirname = path.dirname(__filename); |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all, |
| 18 | +}); |
| 19 | + |
| 20 | +export default [ |
| 21 | + { |
| 22 | + ignores: ['**/lib/', '**/coverage/', '**/node_modules/', '**/fixtures/'], |
| 23 | + }, |
| 24 | + ...compat.extends('eslint:recommended', 'prettier'), |
| 25 | + { |
| 26 | + plugins: { |
| 27 | + '@typescript-eslint': typescriptEslint, |
| 28 | + jest, |
| 29 | + import: fixupPluginRules(_import), |
| 30 | + }, |
| 31 | + |
| 32 | + languageOptions: { |
| 33 | + globals: { |
| 34 | + ...globals.node, |
| 35 | + }, |
| 36 | + |
| 37 | + ecmaVersion: 11, |
| 38 | + sourceType: 'module', |
| 39 | + |
| 40 | + parserOptions: { |
| 41 | + ecmaFeatures: { |
| 42 | + jsx: false, |
| 43 | + }, |
| 44 | + }, |
| 45 | + }, |
| 46 | + |
| 47 | + rules: { |
| 48 | + 'import/first': 'error', |
| 49 | + 'import/no-absolute-path': 'error', |
| 50 | + 'import/no-amd': 'error', |
| 51 | + 'import/no-mutable-exports': 'error', |
| 52 | + 'import/no-named-default': 'error', |
| 53 | + 'import/no-self-import': 'error', |
| 54 | + |
| 55 | + 'import/no-extraneous-dependencies': [ |
| 56 | + 'error', |
| 57 | + { |
| 58 | + devDependencies: true, |
| 59 | + }, |
| 60 | + ], |
| 61 | + }, |
| 62 | + }, |
| 63 | + ...compat |
| 64 | + .extends( |
| 65 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 66 | + 'plugin:@typescript-eslint/recommended', |
| 67 | + 'prettier' |
| 68 | + ) |
| 69 | + .map((config) => ({ |
| 70 | + ...config, |
| 71 | + files: ['**/*.cts', '**/*.ts'], |
| 72 | + })), |
| 73 | + { |
| 74 | + files: ['**/*.cts', '**/*.ts'], |
| 75 | + |
| 76 | + languageOptions: { |
| 77 | + parser: tsParser, |
| 78 | + }, |
| 79 | + |
| 80 | + rules: { |
| 81 | + '@typescript-eslint/no-unused-vars': 'off', |
| 82 | + '@typescript-eslint/no-use-before-define': 'off', |
| 83 | + '@typescript-eslint/no-explicit-any': 'off', |
| 84 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 85 | + '@typescript-eslint/no-var-requires': 'off', |
| 86 | + '@typescript-eslint/no-inferrable-types': 'off', |
| 87 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 88 | + '@typescript-eslint/triple-slash-reference': 'off', |
| 89 | + 'no-empty': 'off', |
| 90 | + 'no-var': 'off', |
| 91 | + }, |
| 92 | + }, |
| 93 | + ...compat.extends('plugin:jest/recommended').map((config) => ({ |
| 94 | + ...config, |
| 95 | + files: ['**/*.test.ts', '**/*.test.js'], |
| 96 | + })), |
| 97 | + { |
| 98 | + files: ['**/*.test.ts', '**/*.test.js'], |
| 99 | + |
| 100 | + rules: { |
| 101 | + '@typescript-eslint/no-explicit-any': 'off', |
| 102 | + '@typescript-eslint/no-var-requires': 'off', |
| 103 | + 'import/first': 'off', |
| 104 | + 'import/no-extraneous-dependencies': 'off', |
| 105 | + 'jest/no-deprecated-functions': 'off', |
| 106 | + }, |
| 107 | + }, |
| 108 | +]; |
0 commit comments