|
| 1 | +import reactPlugin from 'eslint-plugin-react'; |
| 2 | +import reactHooksPlugin from 'eslint-plugin-react-hooks'; |
| 3 | +import reactRefresh from 'eslint-plugin-react-refresh'; |
| 4 | +import testingLibraryPlugin from 'eslint-plugin-testing-library'; |
| 5 | +import vitestPlugin from '@vitest/eslint-plugin'; |
| 6 | +import globals from 'globals'; |
| 7 | +import { config } from '@markuplint-dev/eslint-config'; |
| 8 | + |
| 9 | +/** @type {import('eslint').Linter.Config[]} */ |
| 10 | +export default [ |
| 11 | + ...config, |
| 12 | + reactPlugin.configs.flat.recommended, |
| 13 | + testingLibraryPlugin.configs['flat/react'], |
| 14 | + { |
| 15 | + // global settings |
| 16 | + plugins: { |
| 17 | + 'react-hooks': 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 | + }, |
| 29 | + { |
| 30 | + // TypeScript |
| 31 | + files: ['**/*.{ts,tsx}'], |
| 32 | + languageOptions: { |
| 33 | + parserOptions: { |
| 34 | + // https://typescript-eslint.io/getting-started/typed-linting/ |
| 35 | + projectService: true, |
| 36 | + tsconfigRootDir: import.meta.dirname, |
| 37 | + }, |
| 38 | + }, |
| 39 | + rules: { |
| 40 | + '@typescript-eslint/no-unused-vars': [2, { argsIgnorePattern: '^_', ignoreRestSiblings: true }], |
| 41 | + '@typescript-eslint/prefer-readonly-parameter-types': [ |
| 42 | + 1, |
| 43 | + { |
| 44 | + allow: [ |
| 45 | + { from: 'lib', name: 'URL' }, |
| 46 | + { from: 'package', package: 'json-schema', name: 'JSONSchema7' }, |
| 47 | + { from: 'package', package: 'json-schema', name: 'JSONSchema7Definition' }, |
| 48 | + ], |
| 49 | + checkParameterProperties: false, |
| 50 | + ignoreInferredTypes: true, |
| 51 | + }, |
| 52 | + ], |
| 53 | + }, |
| 54 | + }, |
| 55 | + { |
| 56 | + // React |
| 57 | + files: ['**/*.tsx'], |
| 58 | + rules: { |
| 59 | + // https://github.com/facebook/react/issues/28313 |
| 60 | + ...reactHooksPlugin.configs.recommended.rules, |
| 61 | + 'react/display-name': 0, |
| 62 | + 'react/prop-types': 0, |
| 63 | + 'react-refresh/only-export-components': 'warn', |
| 64 | + 'unicorn/filename-case': 0, |
| 65 | + }, |
| 66 | + }, |
| 67 | + { |
| 68 | + files: ['**/*.spec.ts', '**/*.spec.tsx'], |
| 69 | + rules: { |
| 70 | + 'testing-library/prefer-user-event': 2, |
| 71 | + 'testing-library/no-manual-cleanup': 0, |
| 72 | + }, |
| 73 | + }, |
| 74 | + { |
| 75 | + files: ['vitest.config.ts'], |
| 76 | + rules: { |
| 77 | + 'import/no-default-export': 0, |
| 78 | + }, |
| 79 | + }, |
| 80 | +]; |
0 commit comments