-
Notifications
You must be signed in to change notification settings - Fork 407
Expand file tree
/
Copy patheslint.config.mjs
More file actions
165 lines (164 loc) Β· 4.08 KB
/
eslint.config.mjs
File metadata and controls
165 lines (164 loc) Β· 4.08 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import eslint from '@eslint/js'
import json from '@eslint/json'
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
import * as pluginImportX from 'eslint-plugin-import-x'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import react from 'eslint-plugin-react'
// eslint-disable-next-line import-x/default
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
import globals from 'globals'
import * as tseslint from 'typescript-eslint'
export default tseslint.config(
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/public/**',
'**/.cache/**',
'.log/**',
'**/.yarn/**',
'**/tmp/**'
]
},
eslint.configs.recommended,
json.configs.recommended,
tseslint.configs.recommended,
{
plugins: {
'@typescript-eslint': tseslint.plugin
},
languageOptions: {
parser: tseslint.parser
},
rules: {
'no-useless-escape': 'warn',
'no-tabs': [
'error',
{
allowIndentationTabs: true
}
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase']
},
{
selector: 'variableLike',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow'
}
],
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' }
]
}
},
pluginImportX.flatConfigs.recommended,
pluginImportX.flatConfigs.typescript,
{
settings: {
'import-x/resolver-next': [
createTypeScriptImportResolver({
project: './tsconfig.json',
alwaysTryTypes: true // Always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
})
]
},
rules: {
'import-x/prefer-default-export': 'off',
'import-x/extensions': [
'error',
'ignorePackages',
{ ts: 'never', tsx: 'never', js: 'always', jsx: 'always' }
],
'import-x/order': [
'error',
{
alphabetize: { caseInsensitive: true, order: 'asc' },
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object'
],
pathGroups: [
{
pattern: '@/components/**',
group: 'external',
position: 'after'
},
{ pattern: '@/composites/**', group: 'external', position: 'after' }
],
'newlines-between': 'always'
}
]
}
},
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
jsxA11y.flatConfigs.recommended,
...eslintPluginReactHooks.configs.recommended,
{
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
plugins: {
react
},
languageOptions: {
globals: {
...globals.browser
},
parserOptions: {
ecmaFeatures: {
jsx: true
}
}
},
settings: {
react: {
// TODO: change back to 'detect' once eslint-plugin-react supports ESLint 10
// See: https://github.com/jsx-eslint/eslint-plugin-react/issues/3977
version: '19'
}
},
rules: {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off'
}
},
// JavaScript-specific rules
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
globals: {
...globals.node
}
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off'
}
},
// Vitest test file globals
{
files: ['**/*.test.{js,ts,tsx}'],
languageOptions: {
globals: {
describe: 'readonly',
it: 'readonly',
expect: 'readonly',
vi: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly'
}
}
},
eslintPluginPrettierRecommended
)