-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy patheslint.config.js
More file actions
150 lines (147 loc) · 4.02 KB
/
Copy patheslint.config.js
File metadata and controls
150 lines (147 loc) · 4.02 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
import stylistic from '@stylistic/eslint-plugin'
import js from '@eslint/js'
import { importX } from 'eslint-plugin-import-x'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
const sourceFiles = ['src/**/*.{ts,tsx}', 'scripts/**/*.ts', '*.config.ts']
const generatedUiFiles = ['src/components/ui/**/*.{ts,tsx}']
const styleConfig = stylistic.configs.customize({
arrowParens: true,
braceStyle: '1tbs',
indent: 2,
quoteProps: 'as-needed',
quotes: 'single',
semi: false,
jsx: true,
})
export default tseslint.config(
{
ignores: [
'coverage',
'dist',
'node_modules',
],
},
{
files: sourceFiles,
extends: [
js.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
ecmaVersion: 2023,
globals: {
...globals.browser,
...globals.node,
},
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
'import-x': importX,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
complexity: ['error', 25],
eqeqeq: ['error', 'always'],
'max-depth': ['error', 4],
'max-params': ['error', 5],
'no-console': ['error', { allow: ['error', 'warn'] }],
'import-x/first': 'error',
'import-x/newline-after-import': 'error',
'import-x/no-cycle': ['error', { ignoreExternal: true }],
'import-x/no-duplicates': 'error',
'import-x/order': ['error', {
alphabetize: { order: 'asc', caseInsensitive: true },
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
'newlines-between': 'never',
}],
'@typescript-eslint/consistent-type-imports': ['error', {
fixStyle: 'inline-type-imports',
}],
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': ['error', {
allowNumber: true,
}],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'react-refresh/only-export-components': ['error', {
allowConstantExport: true,
allowExportNames: ['badgeVariants', 'buttonVariants'],
}],
},
},
{
...styleConfig,
files: sourceFiles,
ignores: generatedUiFiles,
rules: {
...styleConfig.rules,
'@stylistic/jsx-one-expression-per-line': 'off',
'@stylistic/operator-linebreak': 'off',
'@stylistic/member-delimiter-style': ['error', {
multiline: {
delimiter: 'none',
requireLast: false,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
}],
},
},
{
files: generatedUiFiles,
rules: {
'import-x/first': 'off',
'import-x/newline-after-import': 'off',
'import-x/order': 'off',
},
},
{
files: ['src/ai/**/*.ts'],
rules: {
'no-restricted-imports': ['error', {
patterns: [
{
group: ['../app/*', '../components/*', '../editor/*'],
message: 'AI domain code may depend only on shared types and utilities.',
},
],
}],
},
},
{
files: ['src/editor/**/*.ts'],
rules: {
'no-restricted-imports': ['error', {
patterns: [
{
group: ['../ai/*', '../app/*', '../components/*'],
message: 'Editor domain code may depend only on shared types and utilities.',
},
],
}],
},
},
)