-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
116 lines (114 loc) · 3.41 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { fixupConfigRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
// @ts-ignore types package doesn't exist for eslint-plugin-import
import importPlugin from 'eslint-plugin-import';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import reactPlugin from 'eslint-plugin-react';
// @ts-ignore types package doesn't exist for eslint-plugin-react-hooks
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';
const compat = new FlatCompat({ baseDirectory: import.meta.dirname });
export default tseslint.config(
{
ignores: [
'**/.react-router/', //
'**/build/',
'**/coverage/',
'**/playwright-report/',
'**/tmp/',
],
},
{
//
// base config
//
languageOptions: {
globals: {
...globals.browser,
...globals.es2020,
...globals.node,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
projectService: true,
},
},
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
{
//
// non-typescript
//
files: ['**/*.{js,cjs,mjs}'],
extends: [eslint.configs.recommended],
},
{
//
// typescript
//
files: ['**/*.{ts,tsx}'],
extends: [
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylisticTypeChecked,
...fixupConfigRules(compat.config(importPlugin.configs.recommended)),
],
rules: {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/require-await': 'error',
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'no-param-reassign': 'error',
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
},
},
{
//
// react
//
files: ['**/*.tsx'],
extends: [
...compat.config(jsxA11yPlugin.configs.recommended),
// @ts-expect-error reactPlugin uses old-style rules
...fixupConfigRules(compat.config(reactPlugin.configs.recommended)),
// @ts-expect-error reactPlugin uses old-style rules
...fixupConfigRules(compat.config(reactPlugin.configs['jsx-runtime'])),
...fixupConfigRules(compat.config(reactHooksPlugin.configs.recommended)),
],
rules: {
'react/no-unknown-property': ['error', { ignore: ['property', 'resource', 'typeof', 'vocab'] }],
'react/prop-types': 'off',
},
settings: {
formComponents: ['Form'],
linkComponents: [
{ name: 'Link', linkAttribute: 'to' },
{ name: 'NavLink', linkAttribute: 'to' },
],
react: {
version: 'detect',
},
},
},
);