-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patheslint.config.ts
More file actions
117 lines (116 loc) · 3.57 KB
/
eslint.config.ts
File metadata and controls
117 lines (116 loc) · 3.57 KB
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
117
import eslintPluginReactModern from '@eslint-react/eslint-plugin'
import eslintPluginJs from '@eslint/js'
import eslintPluginQuery from '@tanstack/eslint-plugin-query'
import eslintPluginJsxA11y from 'eslint-plugin-jsx-a11y'
import eslintPluginReact from 'eslint-plugin-react'
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
import { defineConfig } from 'eslint/config'
import globals from 'globals'
import eslintTypescript from 'typescript-eslint'
export default defineConfig(
eslintPluginJs.configs.recommended,
eslintTypescript.configs.recommended,
eslintPluginJsxA11y.flatConfigs.strict,
eslintPluginReact.configs.flat.recommended,
eslintPluginReactModern.configs.recommended,
eslintPluginReactHooks.configs.flat.recommended,
// ...eslintPluginRouter.configs['flat/recommended'],
...eslintPluginQuery.configs['flat/recommended'],
{ ignores: ['**/vite-env.d.ts'] },
{
languageOptions: {
globals: { ...globals.browser },
parser: eslintTypescript.parser,
parserOptions: { warnOnUnsupportedTypeScriptVersion: false }
}
},
{
rules: {
'no-restricted-syntax': [
'error',
{
selector:
"ImportDeclaration[source.value='react'] :matches(ImportDefaultSpecifier, ImportNamespaceSpecifier)",
message: 'Default React import is not allowed'
},
{
selector: 'Identifier[name="React"]',
message: 'Prefix React is not allowed'
},
{
selector:
'MemberExpression[object.property.name="meta"][property.name="env"]',
message:
'Direct access to `import.meta.env` is forbidden. Use `@/shared/config` instead.'
}
],
'newline-before-return': 'error',
'arrow-body-style': ['warn', 'as-needed']
}
},
{
rules: {
'jsx-a11y/no-autofocus': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/array-type': ['error', { default: 'array' }],
'@typescript-eslint/naming-convention': [
'error',
{ selector: 'typeLike', format: ['PascalCase'] }
],
'@typescript-eslint/no-restricted-types': [
'error',
{
types: {
FC: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177'
}
}
]
}
},
{
files: ['**/ambient/*.d.ts'],
rules: {
'@typescript-eslint/consistent-type-definitions': 'off'
}
},
{
files: ['**/config/*.ts'],
rules: {
'no-restricted-syntax': 'off'
}
},
{
rules: {
'react/react-in-jsx-scope': 'off',
'react/display-name': 'off',
'react/jsx-no-useless-fragment': 'error',
'react/boolean-prop-naming': [
'error',
{
rule: '^(is|as|has|should|can|enable)[A-Z]([A-Za-z0-9]?)+',
validateNested: true
}
],
'react/destructuring-assignment': [
'warn',
'always',
{ destructureInSignature: 'always' }
],
'react/function-component-definition': [
'error',
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function'
}
],
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never' }
],
'react/self-closing-comp': ['warn', { component: true, html: true }]
}
}
)