Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
127 lines (125 loc) · 3.71 KB
/
Copy pathvite.config.ts
File metadata and controls
127 lines (125 loc) · 3.71 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
import { defineConfig } from 'vite-plus';
function restrictRuntimeImports(files: string[], regex: string, message: string) {
return {
files,
rules: {
'no-restricted-imports': ['error', { patterns: [{ regex, message, allowTypeImports: true }] }] satisfies [
'error',
object,
],
},
};
}
export default defineConfig({
fmt: {
printWidth: 120,
singleQuote: true,
ignorePatterns: ['__snapshots__', 'test/fixtures', '**/*.md'],
sortImports: {
groups: [['type-import'], ['builtin'], ['external', 'internal'], ['parent', 'sibling', 'index'], ['unknown']],
newlinesBetween: true,
order: 'asc',
},
},
lint: {
env: {
node: true,
vitest: true,
},
rules: {
// Keep e18e rules compatible with ES2022 and Oxlint's JavaScript plugin support.
'e18e/prefer-array-at': 'error',
'e18e/prefer-array-fill': 'error',
'e18e/prefer-includes': 'error',
'e18e/prefer-nullish-coalescing': 'error',
'e18e/prefer-object-has-own': 'error',
'e18e/prefer-url-canparse': 'error',
'e18e/prefer-array-from-map': 'error',
'e18e/prefer-timer-args': 'error',
'e18e/prefer-date-now': 'error',
'e18e/prefer-regex-test': 'error',
'e18e/prefer-array-some': 'error',
'e18e/prefer-static-regex': 'error',
'e18e/prefer-string-fromcharcode': 'error',
'max-params': ['error', 6],
'no-console': 'error',
'import/no-anonymous-default-export': 'error',
'no-unassigned-import': 'allow',
'new-cap': 'allow',
'class-methods-use-this': 'allow',
'import/no-named-export': 'allow',
'unicorn/no-array-sort': 'allow',
'no-param-reassign': 'allow',
'unicorn/prefer-at': 'allow',
'no-process-env': 'allow',
'vite-plus/prefer-vite-plus-imports': 'error',
},
ignorePatterns: ['index.d.ts'],
overrides: [
{
files: ['app/**', 'config/**'],
rules: { 'typescript/no-explicit-any': 'error' },
},
{
files: ['test/repository/**'],
rules: { 'typescript/no-unsafe-type-assertion': 'error' },
},
{
files: ['test/**'],
rules: {
'e18e/prefer-static-regex': 'off',
'no-restricted-imports': [
'error',
{
paths: [
{ name: 'assert', message: 'Use node:assert/strict.' },
{ name: 'node:assert', message: 'Use node:assert/strict.' },
{ name: '@eggjs/mock/bootstrap', importNames: ['assert'], message: 'Use node:assert/strict.' },
],
},
],
},
},
restrictRuntimeImports(
['app/core/entity/**'],
'(^|/)(infra|repository|port|service|leoric)(/|$)|^egg/orm$',
'Keep infrastructure out of entities.',
),
restrictRuntimeImports(
['app/core/service/**'],
'(^|/)(port|repository/model)/|^egg/orm$|^leoric$',
'Use repositories for persistence and keep HTTP in controllers.',
),
restrictRuntimeImports(
['app/port/**'],
'(^|/)repository/model/|^egg/orm$|^leoric$',
'Access persisted models through repositories.',
),
restrictRuntimeImports(
['app/repository/**'],
'(^|/)(port|core/service)/',
'Keep controllers and services out of repositories.',
),
{
files: ['benchmark/**'],
rules: {
'no-console': 'allow',
},
},
],
options: {
typeAware: true,
typeCheck: true,
},
jsPlugins: [
'@e18e/eslint-plugin',
{
name: 'vite-plus',
specifier: 'vite-plus/oxlint-plugin',
},
],
},
staged: {
'*': ['vp check --fix'],
},
});