|
| 1 | +import { fixupPluginRules } from '@eslint/compat'; |
| 2 | +import reactPlugin from 'eslint-plugin-react'; |
| 3 | +import reactHooksPlugin from 'eslint-plugin-react-hooks'; |
| 4 | +import reactRefresh from 'eslint-plugin-react-refresh'; |
| 5 | +import testingLibraryPlugin from 'eslint-plugin-testing-library'; |
| 6 | +import vitestPlugin from '@vitest/eslint-plugin'; |
| 7 | +import globals from 'globals'; |
| 8 | +import { config } from '@markuplint-dev/eslint-config'; |
| 9 | + |
| 10 | +/** @type {import('eslint').Linter.Config[]} */ |
| 11 | +export default [ |
| 12 | + ...config, |
| 13 | + reactPlugin.configs.flat.recommended, |
| 14 | + testingLibraryPlugin.configs['flat/react'], |
| 15 | + { |
| 16 | + plugins: { |
| 17 | + 'react-hooks': fixupPluginRules(reactHooksPlugin), |
| 18 | + 'react-refresh': reactRefresh, |
| 19 | + vitest: vitestPlugin, |
| 20 | + }, |
| 21 | + languageOptions: { |
| 22 | + globals: { ...globals.browser, React: true, JSX: true }, |
| 23 | + parserOptions: { |
| 24 | + ecmaFeatures: { jsx: true }, |
| 25 | + }, |
| 26 | + }, |
| 27 | + settings: { react: { version: 'detect' }, 'import/resolver': { typescript: [] } }, |
| 28 | + rules: { |
| 29 | + // https://github.com/facebook/react/issues/28313 |
| 30 | + ...reactHooksPlugin.configs.recommended.rules, |
| 31 | + 'react/display-name': 0, |
| 32 | + 'react/prop-types': 0, |
| 33 | + 'react-refresh/only-export-components': 'warn', |
| 34 | + }, |
| 35 | + }, |
| 36 | + { |
| 37 | + files: ['*.{ts,tsx}'], |
| 38 | + languageOptions: { |
| 39 | + parserOptions: { |
| 40 | + // https://typescript-eslint.io/getting-started/typed-linting/ |
| 41 | + projectService: true, |
| 42 | + tsconfigRootDir: import.meta.dirname, |
| 43 | + }, |
| 44 | + }, |
| 45 | + rules: { |
| 46 | + '@typescript-eslint/no-unused-vars': [2, { argsIgnorePattern: '^_', ignoreRestSiblings: true }], |
| 47 | + '@typescript-eslint/prefer-readonly-parameter-types': [ |
| 48 | + 1, |
| 49 | + { |
| 50 | + allow: [ |
| 51 | + { from: 'lib', name: 'URL' }, |
| 52 | + { from: 'package', package: 'json-schema', name: 'JSONSchema7' }, |
| 53 | + { from: 'package', package: 'json-schema', name: 'JSONSchema7Definition' }, |
| 54 | + ], |
| 55 | + checkParameterProperties: false, |
| 56 | + ignoreInferredTypes: true, |
| 57 | + }, |
| 58 | + ], |
| 59 | + }, |
| 60 | + }, |
| 61 | + { |
| 62 | + files: ['./*.js'], |
| 63 | + rules: { |
| 64 | + '@typescript-eslint/no-var-requires': 0, |
| 65 | + }, |
| 66 | + }, |
| 67 | + { |
| 68 | + files: ['./*.mjs'], |
| 69 | + rules: { |
| 70 | + 'import/no-named-as-default-member': 0, |
| 71 | + }, |
| 72 | + }, |
| 73 | + { |
| 74 | + files: ['./**/*.tsx'], |
| 75 | + rules: { |
| 76 | + 'unicorn/filename-case': 0, |
| 77 | + }, |
| 78 | + }, |
| 79 | + { |
| 80 | + files: ['./**/*.spec.ts', './**/*.spec.tsx'], |
| 81 | + rules: { |
| 82 | + 'testing-library/prefer-user-event': 2, |
| 83 | + 'testing-library/no-manual-cleanup': 0, |
| 84 | + }, |
| 85 | + }, |
| 86 | + { |
| 87 | + files: ['./vitest.config.ts'], |
| 88 | + rules: { |
| 89 | + 'import/no-default-export': 0, |
| 90 | + }, |
| 91 | + }, |
| 92 | +]; |
0 commit comments