|
| 1 | +import path from 'node:path' |
| 2 | +import { fileURLToPath } from 'node:url' |
| 3 | + |
| 4 | +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat' |
| 5 | +import { FlatCompat } from '@eslint/eslintrc' |
| 6 | +import js from '@eslint/js' |
| 7 | +import typescriptEslint from '@typescript-eslint/eslint-plugin' |
| 8 | +import tsParser from '@typescript-eslint/parser' |
| 9 | +import _import from 'eslint-plugin-import' |
| 10 | +import n from 'eslint-plugin-n' |
| 11 | +import simpleImportSort from 'eslint-plugin-simple-import-sort' |
| 12 | +import globals from 'globals' |
| 13 | + |
| 14 | +const __filename = fileURLToPath(import.meta.url) |
| 15 | +const __dirname = path.dirname(__filename) |
| 16 | +const compat = new FlatCompat({ |
| 17 | + baseDirectory: __dirname, |
| 18 | + recommendedConfig: js.configs.recommended, |
| 19 | + allConfig: js.configs.all, |
| 20 | +}) |
| 21 | + |
| 22 | +export default [ |
| 23 | + ...fixupConfigRules( |
| 24 | + compat.extends( |
| 25 | + 'eslint:recommended', |
| 26 | + 'plugin:import/typescript', |
| 27 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 28 | + 'plugin:@typescript-eslint/recommended' |
| 29 | + ) |
| 30 | + ), |
| 31 | + { |
| 32 | + plugins: { |
| 33 | + import: fixupPluginRules(_import), |
| 34 | + 'simple-import-sort': simpleImportSort, |
| 35 | + n, |
| 36 | + '@typescript-eslint': fixupPluginRules(typescriptEslint), |
| 37 | + }, |
| 38 | + |
| 39 | + languageOptions: { |
| 40 | + globals: { |
| 41 | + ...globals.browser, |
| 42 | + ...globals.node, |
| 43 | + }, |
| 44 | + |
| 45 | + parser: tsParser, |
| 46 | + ecmaVersion: 5, |
| 47 | + sourceType: 'module', |
| 48 | + |
| 49 | + parserOptions: { |
| 50 | + project: 'tsconfig.json', |
| 51 | + }, |
| 52 | + }, |
| 53 | + |
| 54 | + rules: { |
| 55 | + 'import/no-cycle': 'error', |
| 56 | + 'n/no-extraneous-import': 'error', |
| 57 | + '@typescript-eslint/no-explicit-any': 'error', |
| 58 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 59 | + 'simple-import-sort/imports': 'error', |
| 60 | + 'simple-import-sort/exports': 'error', |
| 61 | + }, |
| 62 | + }, |
| 63 | + { |
| 64 | + files: ['test/**'], |
| 65 | + |
| 66 | + rules: { |
| 67 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 68 | + }, |
| 69 | + }, |
| 70 | +] |
0 commit comments