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