-
Notifications
You must be signed in to change notification settings - Fork 35
/
eslint.config.mjs
103 lines (100 loc) · 2.72 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
import antfu from '@antfu/eslint-config'
import { fixupPluginRules } from '@eslint/compat'
import eslintPluginReact from '@eslint-react/eslint-plugin'
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
export default antfu(
{
formatters: {
css: true,
html: true,
markdown: 'prettier',
},
},
{
plugins: {
'react': eslintPluginReact,
// @see https://github.com/facebook/react/issues/28313#issuecomment-2180984628
'react-hooks': fixupPluginRules(eslintPluginReactHooks),
},
},
// Common rules
{
rules: {
'ts/no-explicit-any': 'error',
'ts/consistent-type-definitions': ['error', 'type'],
'import/no-default-export': 'error',
'no-restricted-syntax': ['error', {
selector: 'MemberExpression[object.meta.name=\'import\'][object.property.name=\'meta\'][property.name=\'env\']',
message: 'The use of import.meta.env is not allowed. Use import { env } from \'@/shared/lib\'',
}],
'no-restricted-imports': ['error', {
paths: [
{
name: '@/shared/lib/server',
message: 'Don\'t use server modules in client code',
},
{
name: 'react-router-dom',
importNames: ['useParams'],
message: 'Use `import { useTypedParams } from @/shared/lib/router` instead.',
},
],
}],
},
},
// Feature-Sliced Design rules
{
rules: {
'import/order': ['error', {
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling'],
'pathGroups': [{
pattern: 'react',
group: 'external',
position: 'before',
}, {
pattern: '*.css',
group: 'index',
patternOptions: {
matchBase: true,
},
position: 'after',
}, {
pattern: '@/**',
group: 'external',
position: 'after',
}],
// "pathGroupsExcludedImportTypes": ["react"],
'newlines-between': 'never',
'alphabetize': {
order: 'asc',
caseInsensitive: true,
},
}],
},
// TODO: Turn on
// feature-sliced/layers-slices
// 'boundaries/element-types': 'error',
// TODO: Turn on
// feature-sliced/public-api
// "import/no-internal-modules": "warn" // ~ 1,
},
{
files: [
'**/*.stories.tsx',
'vite.config.mts',
'eslint.config.mjs',
'public/mockServiceWorker.js',
],
rules: {
'eslint-comments/no-unlimited-disable': 'off',
'import/no-default-export': 'off',
'no-restricted-imports': 'off',
},
},
{
files: ['**/__mocks__/**/*.ts'],
rules: {
'no-restricted-imports': 'off',
},
},
)