|
| 1 | +import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'; |
| 2 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 3 | +import { default as eslint, default as js } from '@eslint/js'; |
| 4 | +import tanstackQuery from '@tanstack/eslint-plugin-query'; |
| 5 | +import cssModules from 'eslint-plugin-css-modules'; |
| 6 | +import importPlugin from 'eslint-plugin-import'; |
| 7 | +import react from 'eslint-plugin-react'; |
| 8 | +import requireExplicitGenerics from 'eslint-plugin-require-explicit-generics'; |
| 9 | +import path from 'node:path'; |
| 10 | +import { fileURLToPath } from 'node:url'; |
| 11 | +import tseslint from 'typescript-eslint'; |
| 12 | + |
| 13 | +const __filename = fileURLToPath(import.meta.url); |
| 14 | +const __dirname = path.dirname(__filename); |
| 15 | +const compat = new FlatCompat({ |
| 16 | + baseDirectory: __dirname, |
| 17 | + recommendedConfig: js.configs.recommended, |
| 18 | + allConfig: js.configs.all, |
| 19 | +}); |
| 20 | + |
| 21 | +export default [ |
| 22 | + { |
| 23 | + ignores: [ |
| 24 | + 'src/xpanse-api/**/*', |
| 25 | + 'public/OidcServiceWorker.js', |
| 26 | + 'public/inject.js', |
| 27 | + '**/dist', |
| 28 | + '**/node_modules', |
| 29 | + 'public/OidcTrustedDomains.js', |
| 30 | + 'eslint.config.mjs', |
| 31 | + ], |
| 32 | + }, |
| 33 | + { |
| 34 | + files: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts'], |
| 35 | + }, |
| 36 | + { |
| 37 | + languageOptions: { |
| 38 | + parserOptions: { |
| 39 | + sourceType: 'module', |
| 40 | + projectService: { |
| 41 | + defaultProject: './tsconfig.json', |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | + }, |
| 46 | + eslint.configs.recommended, |
| 47 | + ...tseslint.configs.strictTypeChecked, |
| 48 | + ...tseslint.configs.stylisticTypeChecked, |
| 49 | + ...tseslint.configs.recommendedTypeChecked, |
| 50 | + importPlugin.flatConfigs.recommended, |
| 51 | + ...fixupConfigRules( |
| 52 | + compat.extends( |
| 53 | + 'eslint:recommended', |
| 54 | + 'plugin:prettier/recommended', |
| 55 | + 'plugin:react/recommended', |
| 56 | + 'plugin:react-hooks/recommended', |
| 57 | + 'plugin:import/typescript' |
| 58 | + ) |
| 59 | + ), |
| 60 | + { |
| 61 | + plugins: { |
| 62 | + react: fixupPluginRules(react), |
| 63 | + '@tanstack/query': tanstackQuery, |
| 64 | + 'require-explicit-generics': requireExplicitGenerics, |
| 65 | + 'css-modules': fixupPluginRules(cssModules), |
| 66 | + }, |
| 67 | + rules: { |
| 68 | + 'react/jsx-uses-react': 'error', |
| 69 | + 'react/jsx-uses-vars': 'error', |
| 70 | + 'no-undef': 'off', |
| 71 | + '@typescript-eslint/no-inferrable-types': 'off', |
| 72 | + '@tanstack/query/exhaustive-deps': 'error', |
| 73 | + 'no-console': 'error', |
| 74 | + '@typescript-eslint/no-dynamic-delete': 'off', |
| 75 | + 'react/react-in-jsx-scope': 'off', |
| 76 | + '@typescript-eslint/no-deprecated': 'error', |
| 77 | + 'no-unused-vars': 'off', |
| 78 | + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], |
| 79 | + }, |
| 80 | + settings: { |
| 81 | + 'import/parsers': { |
| 82 | + '@typescript-eslint/parser': ['.ts', '.tsx'], |
| 83 | + }, |
| 84 | + 'import/resolver': { |
| 85 | + typescript: true, |
| 86 | + node: false, |
| 87 | + }, |
| 88 | + react: { |
| 89 | + version: 'detect', |
| 90 | + defaultVersion: '', |
| 91 | + }, |
| 92 | + }, |
| 93 | + }, |
| 94 | +]; |
0 commit comments