@zhangyu1818/oxlint-config 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +121 -116
- package/dist/index.js +825 -988
- package/dist/react-agent-rules.d.ts +45 -44
- package/dist/react-agent-rules.js +71 -101
- package/package.json +20 -19
package/dist/index.js
CHANGED
|
@@ -1,1030 +1,867 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
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
|
-
|
|
1
|
+
import { isPackageExists } from "local-pkg";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
//#region src/shared/ignore-patterns.ts
|
|
5
|
+
const defaultIgnorePatterns = [
|
|
6
|
+
"**/node_modules",
|
|
7
|
+
"**/dist",
|
|
8
|
+
"**/package-lock.json",
|
|
9
|
+
"**/yarn.lock",
|
|
10
|
+
"**/pnpm-lock.yaml",
|
|
11
|
+
"**/bun.lockb",
|
|
12
|
+
"**/output",
|
|
13
|
+
"**/coverage",
|
|
14
|
+
"**/temp",
|
|
15
|
+
"**/.temp",
|
|
16
|
+
"**/tmp",
|
|
17
|
+
"**/.tmp",
|
|
18
|
+
".tmp-*",
|
|
19
|
+
"**/.history",
|
|
20
|
+
"**/.vitepress/cache",
|
|
21
|
+
"**/.nuxt",
|
|
22
|
+
"**/.next",
|
|
23
|
+
"**/.vercel",
|
|
24
|
+
"**/.changeset",
|
|
25
|
+
"**/.idea",
|
|
26
|
+
"**/.cache",
|
|
27
|
+
"**/.output",
|
|
28
|
+
"**/.vite-inspect",
|
|
29
|
+
"**/.yarn",
|
|
30
|
+
"**/CHANGELOG*.md",
|
|
31
|
+
"**/*.min.*",
|
|
32
|
+
"**/LICENSE*",
|
|
33
|
+
"**/__snapshots__",
|
|
34
|
+
"**/auto-import.d.ts",
|
|
35
|
+
"**/auto-imports.d.ts",
|
|
36
|
+
"**/components.d.ts",
|
|
37
|
+
"tests/fixtures/**"
|
|
37
38
|
];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/oxlint/presets/imports.ts
|
|
41
|
+
const importRules = {
|
|
42
|
+
"import/first": "error",
|
|
43
|
+
"import/no-duplicates": ["error", { "prefer-inline": true }],
|
|
44
|
+
"import/no-mutable-exports": "error",
|
|
45
|
+
"import/no-named-default": "error",
|
|
46
|
+
"import/no-self-import": "error",
|
|
47
|
+
"import/no-webpack-loader-syntax": "error"
|
|
47
48
|
};
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
],
|
|
186
|
-
"prefer-const": ["error", { destructuring: "all" }],
|
|
187
|
-
"prefer-exponentiation-operator": "error",
|
|
188
|
-
"prefer-promise-reject-errors": "error",
|
|
189
|
-
"prefer-rest-params": "error",
|
|
190
|
-
"prefer-spread": "error",
|
|
191
|
-
"prefer-template": "error",
|
|
192
|
-
"symbol-description": "error",
|
|
193
|
-
"unicode-bom": ["error", "never"],
|
|
194
|
-
"use-isnan": [
|
|
195
|
-
"error",
|
|
196
|
-
{
|
|
197
|
-
enforceForIndexOf: true,
|
|
198
|
-
enforceForSwitchCase: true
|
|
199
|
-
}
|
|
200
|
-
],
|
|
201
|
-
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
202
|
-
"vars-on-top": "error",
|
|
203
|
-
yoda: ["error", "never"]
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/oxlint/presets/javascript.ts
|
|
51
|
+
const javascriptRules = {
|
|
52
|
+
"accessor-pairs": ["error", {
|
|
53
|
+
enforceForClassMembers: true,
|
|
54
|
+
setWithoutGet: true
|
|
55
|
+
}],
|
|
56
|
+
"array-callback-return": "error",
|
|
57
|
+
"block-scoped-var": "error",
|
|
58
|
+
"constructor-super": "error",
|
|
59
|
+
"default-case-last": "error",
|
|
60
|
+
eqeqeq: ["error", "smart"],
|
|
61
|
+
"new-cap": ["error", {
|
|
62
|
+
capIsNew: false,
|
|
63
|
+
newIsCap: true,
|
|
64
|
+
properties: true
|
|
65
|
+
}],
|
|
66
|
+
"no-alert": "error",
|
|
67
|
+
"no-array-constructor": "error",
|
|
68
|
+
"no-async-promise-executor": "error",
|
|
69
|
+
"no-caller": "error",
|
|
70
|
+
"no-case-declarations": "error",
|
|
71
|
+
"no-class-assign": "error",
|
|
72
|
+
"no-compare-neg-zero": "error",
|
|
73
|
+
"no-cond-assign": ["error", "always"],
|
|
74
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
75
|
+
"no-const-assign": "error",
|
|
76
|
+
"no-control-regex": "error",
|
|
77
|
+
"no-debugger": "error",
|
|
78
|
+
"no-delete-var": "error",
|
|
79
|
+
"no-dupe-class-members": "error",
|
|
80
|
+
"no-dupe-keys": "error",
|
|
81
|
+
"no-duplicate-case": "error",
|
|
82
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
83
|
+
"no-empty-character-class": "error",
|
|
84
|
+
"no-empty-pattern": "error",
|
|
85
|
+
"no-eval": "error",
|
|
86
|
+
"no-ex-assign": "error",
|
|
87
|
+
"no-extend-native": "error",
|
|
88
|
+
"no-extra-bind": "error",
|
|
89
|
+
"no-extra-boolean-cast": "error",
|
|
90
|
+
"no-fallthrough": "error",
|
|
91
|
+
"no-func-assign": "error",
|
|
92
|
+
"no-global-assign": "error",
|
|
93
|
+
"no-import-assign": "error",
|
|
94
|
+
"no-invalid-regexp": "error",
|
|
95
|
+
"no-irregular-whitespace": "error",
|
|
96
|
+
"no-iterator": "error",
|
|
97
|
+
"no-labels": ["error", {
|
|
98
|
+
allowLoop: false,
|
|
99
|
+
allowSwitch: false
|
|
100
|
+
}],
|
|
101
|
+
"no-lone-blocks": "error",
|
|
102
|
+
"no-loss-of-precision": "error",
|
|
103
|
+
"no-misleading-character-class": "error",
|
|
104
|
+
"no-multi-str": "error",
|
|
105
|
+
"no-new": "error",
|
|
106
|
+
"no-new-func": "error",
|
|
107
|
+
"no-new-native-nonconstructor": "error",
|
|
108
|
+
"no-new-wrappers": "error",
|
|
109
|
+
"no-obj-calls": "error",
|
|
110
|
+
"no-proto": "error",
|
|
111
|
+
"no-prototype-builtins": "error",
|
|
112
|
+
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
113
|
+
"no-regex-spaces": "error",
|
|
114
|
+
"no-restricted-globals": [
|
|
115
|
+
"error",
|
|
116
|
+
{
|
|
117
|
+
message: "Use `globalThis` instead.",
|
|
118
|
+
name: "global"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
message: "Use `globalThis` instead.",
|
|
122
|
+
name: "self"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"no-self-assign": ["error", { props: true }],
|
|
126
|
+
"no-self-compare": "error",
|
|
127
|
+
"no-sequences": "error",
|
|
128
|
+
"no-shadow-restricted-names": "error",
|
|
129
|
+
"no-sparse-arrays": "error",
|
|
130
|
+
"no-template-curly-in-string": "error",
|
|
131
|
+
"no-this-before-super": "error",
|
|
132
|
+
"no-throw-literal": "error",
|
|
133
|
+
"no-undef": "error",
|
|
134
|
+
"no-unmodified-loop-condition": "error",
|
|
135
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
136
|
+
"no-unreachable": "error",
|
|
137
|
+
"no-unsafe-finally": "error",
|
|
138
|
+
"no-unsafe-negation": "error",
|
|
139
|
+
"no-unused-expressions": ["error", {
|
|
140
|
+
allowTaggedTemplates: true,
|
|
141
|
+
allowTernary: true
|
|
142
|
+
}],
|
|
143
|
+
"no-unused-vars": ["error", {
|
|
144
|
+
args: "none",
|
|
145
|
+
caughtErrors: "none",
|
|
146
|
+
vars: "all"
|
|
147
|
+
}],
|
|
148
|
+
"no-use-before-define": ["error", {
|
|
149
|
+
classes: false,
|
|
150
|
+
functions: false,
|
|
151
|
+
variables: true
|
|
152
|
+
}],
|
|
153
|
+
"no-useless-backreference": "error",
|
|
154
|
+
"no-useless-call": "error",
|
|
155
|
+
"no-useless-catch": "error",
|
|
156
|
+
"no-useless-computed-key": "error",
|
|
157
|
+
"no-useless-constructor": "error",
|
|
158
|
+
"no-useless-rename": "error",
|
|
159
|
+
"no-useless-return": "error",
|
|
160
|
+
"no-var": "error",
|
|
161
|
+
"no-with": "error",
|
|
162
|
+
"object-shorthand": [
|
|
163
|
+
"error",
|
|
164
|
+
"always",
|
|
165
|
+
{
|
|
166
|
+
avoidExplicitReturnArrows: true,
|
|
167
|
+
avoidQuotes: true
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
"prefer-const": ["error", { destructuring: "all" }],
|
|
171
|
+
"prefer-exponentiation-operator": "error",
|
|
172
|
+
"prefer-promise-reject-errors": "error",
|
|
173
|
+
"prefer-rest-params": "error",
|
|
174
|
+
"prefer-spread": "error",
|
|
175
|
+
"prefer-template": "error",
|
|
176
|
+
"symbol-description": "error",
|
|
177
|
+
"unicode-bom": ["error", "never"],
|
|
178
|
+
"use-isnan": ["error", {
|
|
179
|
+
enforceForIndexOf: true,
|
|
180
|
+
enforceForSwitchCase: true
|
|
181
|
+
}],
|
|
182
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
183
|
+
"vars-on-top": "error",
|
|
184
|
+
yoda: ["error", "never"]
|
|
204
185
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/oxlint/presets/next.ts
|
|
188
|
+
const nextjsRules = {
|
|
189
|
+
"nextjs/google-font-display": "warn",
|
|
190
|
+
"nextjs/google-font-preconnect": "warn",
|
|
191
|
+
"nextjs/inline-script-id": "error",
|
|
192
|
+
"nextjs/next-script-for-ga": "warn",
|
|
193
|
+
"nextjs/no-assign-module-variable": "error",
|
|
194
|
+
"nextjs/no-async-client-component": "warn",
|
|
195
|
+
"nextjs/no-before-interactive-script-outside-document": "warn",
|
|
196
|
+
"nextjs/no-css-tags": "warn",
|
|
197
|
+
"nextjs/no-document-import-in-page": "error",
|
|
198
|
+
"nextjs/no-duplicate-head": "error",
|
|
199
|
+
"nextjs/no-head-element": "warn",
|
|
200
|
+
"nextjs/no-head-import-in-document": "error",
|
|
201
|
+
"nextjs/no-html-link-for-pages": "off",
|
|
202
|
+
"nextjs/no-img-element": "warn",
|
|
203
|
+
"nextjs/no-page-custom-font": "warn",
|
|
204
|
+
"nextjs/no-script-component-in-head": "error",
|
|
205
|
+
"nextjs/no-styled-jsx-in-document": "warn",
|
|
206
|
+
"nextjs/no-sync-scripts": "error",
|
|
207
|
+
"nextjs/no-title-in-document-head": "warn",
|
|
208
|
+
"nextjs/no-typos": "warn",
|
|
209
|
+
"nextjs/no-unwanted-polyfillio": "warn"
|
|
229
210
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/oxlint/presets/node.ts
|
|
213
|
+
const nodeRules = {
|
|
214
|
+
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
215
|
+
"node/no-exports-assign": "error",
|
|
216
|
+
"node/no-new-require": "error",
|
|
217
|
+
"node/no-path-concat": "error"
|
|
237
218
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
import { existsSync } from "fs";
|
|
241
|
-
import { fileURLToPath } from "url";
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/oxlint/presets/react-agent-rules.ts
|
|
242
221
|
function resolveReactAgentRulesPluginPath() {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
if (existsSync(sourcePluginPath)) {
|
|
247
|
-
return sourcePluginPath;
|
|
248
|
-
}
|
|
249
|
-
return fileURLToPath(new URL("./react-agent-rules.js", import.meta.url));
|
|
222
|
+
const sourcePluginPath = fileURLToPath(new URL("../../react-agent-rules.ts", import.meta.url));
|
|
223
|
+
if (existsSync(sourcePluginPath)) return sourcePluginPath;
|
|
224
|
+
return fileURLToPath(new URL("./react-agent-rules.js", import.meta.url));
|
|
250
225
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
226
|
+
const reactAgentRulesPlugin = resolveReactAgentRulesPluginPath();
|
|
227
|
+
const reactAgentRules = {
|
|
228
|
+
"react-agent-rules/effect-empty-deps-only": "error",
|
|
229
|
+
"react-agent-rules/no-forward-ref": "error",
|
|
230
|
+
"react-agent-rules/no-manual-memoization": "error",
|
|
231
|
+
"react-agent-rules/no-use-context": "error"
|
|
257
232
|
};
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
"jsx-a11y/role-supports-aria-props": "error",
|
|
308
|
-
"jsx-a11y/scope": "error",
|
|
309
|
-
"jsx-a11y/tabindex-no-positive": "error"
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/oxlint/presets/react.ts
|
|
235
|
+
const jsxA11yRules = {
|
|
236
|
+
"jsx-a11y/alt-text": "error",
|
|
237
|
+
"jsx-a11y/anchor-ambiguous-text": "off",
|
|
238
|
+
"jsx-a11y/anchor-has-content": "error",
|
|
239
|
+
"jsx-a11y/anchor-is-valid": "error",
|
|
240
|
+
"jsx-a11y/aria-activedescendant-has-tabindex": "error",
|
|
241
|
+
"jsx-a11y/aria-props": "error",
|
|
242
|
+
"jsx-a11y/aria-proptypes": "error",
|
|
243
|
+
"jsx-a11y/aria-role": "error",
|
|
244
|
+
"jsx-a11y/aria-unsupported-elements": "error",
|
|
245
|
+
"jsx-a11y/autocomplete-valid": "error",
|
|
246
|
+
"jsx-a11y/click-events-have-key-events": "error",
|
|
247
|
+
"jsx-a11y/heading-has-content": "error",
|
|
248
|
+
"jsx-a11y/html-has-lang": "error",
|
|
249
|
+
"jsx-a11y/iframe-has-title": "error",
|
|
250
|
+
"jsx-a11y/img-redundant-alt": "error",
|
|
251
|
+
"jsx-a11y/interactive-supports-focus": "error",
|
|
252
|
+
"jsx-a11y/label-has-associated-control": "error",
|
|
253
|
+
"jsx-a11y/media-has-caption": "error",
|
|
254
|
+
"jsx-a11y/mouse-events-have-key-events": "error",
|
|
255
|
+
"jsx-a11y/no-access-key": "error",
|
|
256
|
+
"jsx-a11y/no-autofocus": "error",
|
|
257
|
+
"jsx-a11y/no-distracting-elements": "error",
|
|
258
|
+
"jsx-a11y/no-interactive-element-to-noninteractive-role": "error",
|
|
259
|
+
"jsx-a11y/no-noninteractive-element-interactions": "error",
|
|
260
|
+
"jsx-a11y/no-noninteractive-element-to-interactive-role": "error",
|
|
261
|
+
"jsx-a11y/no-noninteractive-tabindex": ["error", {
|
|
262
|
+
allowExpressionValues: true,
|
|
263
|
+
roles: ["tabpanel"],
|
|
264
|
+
tags: []
|
|
265
|
+
}],
|
|
266
|
+
"jsx-a11y/no-redundant-roles": "error",
|
|
267
|
+
"jsx-a11y/no-static-element-interactions": ["error", {
|
|
268
|
+
allowExpressionValues: true,
|
|
269
|
+
handlers: [
|
|
270
|
+
"onClick",
|
|
271
|
+
"onMouseDown",
|
|
272
|
+
"onMouseUp",
|
|
273
|
+
"onKeyPress",
|
|
274
|
+
"onKeyDown",
|
|
275
|
+
"onKeyUp"
|
|
276
|
+
]
|
|
277
|
+
}],
|
|
278
|
+
"jsx-a11y/role-has-required-aria-props": "error",
|
|
279
|
+
"jsx-a11y/role-supports-aria-props": "error",
|
|
280
|
+
"jsx-a11y/scope": "error",
|
|
281
|
+
"jsx-a11y/tabindex-no-positive": "error"
|
|
310
282
|
};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
{
|
|
344
|
-
component: true,
|
|
345
|
-
html: true
|
|
346
|
-
}
|
|
347
|
-
],
|
|
348
|
-
"react/void-dom-elements-no-children": "error"
|
|
283
|
+
const baseReactRules = {
|
|
284
|
+
"react/exhaustive-deps": "warn",
|
|
285
|
+
"react/jsx-boolean-value": "error",
|
|
286
|
+
"react/jsx-curly-brace-presence": ["error", {
|
|
287
|
+
children: "never",
|
|
288
|
+
propElementValues: "always",
|
|
289
|
+
props: "never"
|
|
290
|
+
}],
|
|
291
|
+
"react/jsx-key": "error",
|
|
292
|
+
"react/jsx-no-comment-textnodes": "error",
|
|
293
|
+
"react/jsx-no-duplicate-props": "error",
|
|
294
|
+
"react/jsx-no-target-blank": "error",
|
|
295
|
+
"react/jsx-no-undef": "error",
|
|
296
|
+
"react/jsx-no-useless-fragment": "error",
|
|
297
|
+
"react/no-array-index-key": "warn",
|
|
298
|
+
"react/no-children-prop": "error",
|
|
299
|
+
"react/no-danger-with-children": "error",
|
|
300
|
+
"react/no-direct-mutation-state": "error",
|
|
301
|
+
"react/no-find-dom-node": "error",
|
|
302
|
+
"react/no-is-mounted": "error",
|
|
303
|
+
"react/no-render-return-value": "error",
|
|
304
|
+
"react/no-string-refs": "error",
|
|
305
|
+
"react/no-unknown-property": "error",
|
|
306
|
+
"react/no-unescaped-entities": "error",
|
|
307
|
+
"react/react-in-jsx-scope": "off",
|
|
308
|
+
"react/require-render-return": "error",
|
|
309
|
+
"react/rules-of-hooks": "error",
|
|
310
|
+
"react/self-closing-comp": ["error", {
|
|
311
|
+
component: true,
|
|
312
|
+
html: true
|
|
313
|
+
}],
|
|
314
|
+
"react/void-dom-elements-no-children": "error"
|
|
349
315
|
};
|
|
350
316
|
function createReactRules(options, nextEnabled) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
]
|
|
376
|
-
};
|
|
317
|
+
const framework = options.framework ?? {};
|
|
318
|
+
const next = framework.next ?? nextEnabled;
|
|
319
|
+
const vite = framework.vite ?? isPackageExists("vite");
|
|
320
|
+
return {
|
|
321
|
+
...baseReactRules,
|
|
322
|
+
"react/only-export-components": ["warn", {
|
|
323
|
+
allowConstantExport: vite,
|
|
324
|
+
allowExportNames: next ? [
|
|
325
|
+
"dynamic",
|
|
326
|
+
"dynamicParams",
|
|
327
|
+
"revalidate",
|
|
328
|
+
"fetchCache",
|
|
329
|
+
"runtime",
|
|
330
|
+
"preferredRegion",
|
|
331
|
+
"maxDuration",
|
|
332
|
+
"generateStaticParams",
|
|
333
|
+
"metadata",
|
|
334
|
+
"generateMetadata",
|
|
335
|
+
"viewport",
|
|
336
|
+
"generateViewport"
|
|
337
|
+
] : []
|
|
338
|
+
}]
|
|
339
|
+
};
|
|
377
340
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/oxlint/presets/test.ts
|
|
343
|
+
const vitestRules = {
|
|
344
|
+
"no-unused-expressions": "off",
|
|
345
|
+
"vitest/expect-expect": "error",
|
|
346
|
+
"vitest/no-commented-out-tests": "error",
|
|
347
|
+
"vitest/no-conditional-expect": "error",
|
|
348
|
+
"vitest/no-disabled-tests": "warn",
|
|
349
|
+
"vitest/no-focused-tests": "error",
|
|
350
|
+
"vitest/no-identical-title": "error",
|
|
351
|
+
"vitest/no-import-node-test": "error",
|
|
352
|
+
"vitest/no-interpolation-in-snapshots": "error",
|
|
353
|
+
"vitest/no-mocks-import": "error",
|
|
354
|
+
"vitest/no-standalone-expect": "error",
|
|
355
|
+
"vitest/no-unneeded-async-expect-function": "error",
|
|
356
|
+
"vitest/prefer-called-exactly-once-with": "error",
|
|
357
|
+
"vitest/require-local-test-context-for-concurrent-snapshots": "error",
|
|
358
|
+
"vitest/valid-describe-callback": "error",
|
|
359
|
+
"vitest/valid-expect": "error",
|
|
360
|
+
"vitest/valid-expect-in-promise": "error",
|
|
361
|
+
"vitest/valid-title": "error"
|
|
399
362
|
};
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
"typescript/no-unsafe-function-type": "error",
|
|
469
|
-
"typescript/no-useless-empty-export": "error",
|
|
470
|
-
"typescript/no-var-requires": "error",
|
|
471
|
-
"typescript/no-wrapper-object-types": "error",
|
|
472
|
-
"typescript/non-nullable-type-assertion-style": "error",
|
|
473
|
-
"typescript/only-throw-error": "error",
|
|
474
|
-
"typescript/prefer-as-const": "error",
|
|
475
|
-
"typescript/prefer-literal-enum-member": "error",
|
|
476
|
-
"typescript/prefer-optional-chain": "error",
|
|
477
|
-
"typescript/triple-slash-reference": "warn",
|
|
478
|
-
"typescript/unified-signatures": "error"
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/oxlint/presets/typescript.ts
|
|
365
|
+
const typeScriptRules = {
|
|
366
|
+
"no-throw-literal": "off",
|
|
367
|
+
"no-undef": "off",
|
|
368
|
+
"no-unused-vars": "error",
|
|
369
|
+
"typescript/adjacent-overload-signatures": "off",
|
|
370
|
+
"typescript/array-type": "error",
|
|
371
|
+
"typescript/await-thenable": "warn",
|
|
372
|
+
"typescript/ban-ts-comment": ["error", {
|
|
373
|
+
minimumDescriptionLength: 3,
|
|
374
|
+
"ts-check": false,
|
|
375
|
+
"ts-expect-error": "allow-with-description",
|
|
376
|
+
"ts-ignore": true,
|
|
377
|
+
"ts-nocheck": true
|
|
378
|
+
}],
|
|
379
|
+
"typescript/consistent-generic-constructors": "error",
|
|
380
|
+
"typescript/consistent-indexed-object-style": "error",
|
|
381
|
+
"typescript/consistent-type-definitions": "warn",
|
|
382
|
+
"typescript/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
383
|
+
"typescript/consistent-type-imports": ["error", {
|
|
384
|
+
disallowTypeAnnotations: false,
|
|
385
|
+
fixStyle: "separate-type-imports",
|
|
386
|
+
prefer: "type-imports"
|
|
387
|
+
}],
|
|
388
|
+
"typescript/dot-notation": ["error", { allowKeywords: true }],
|
|
389
|
+
"typescript/no-implied-eval": "error",
|
|
390
|
+
"typescript/no-array-delete": "error",
|
|
391
|
+
"typescript/no-base-to-string": "error",
|
|
392
|
+
"typescript/no-duplicate-enum-values": "error",
|
|
393
|
+
"typescript/no-duplicate-type-constituents": "error",
|
|
394
|
+
"typescript/no-dynamic-delete": "error",
|
|
395
|
+
"typescript/no-empty-interface": "error",
|
|
396
|
+
"typescript/no-empty-object-type": "error",
|
|
397
|
+
"typescript/no-explicit-any": "warn",
|
|
398
|
+
"typescript/no-extra-non-null-assertion": "error",
|
|
399
|
+
"typescript/no-extraneous-class": "error",
|
|
400
|
+
"typescript/no-for-in-array": "error",
|
|
401
|
+
"typescript/no-import-type-side-effects": "error",
|
|
402
|
+
"typescript/no-invalid-void-type": "error",
|
|
403
|
+
"typescript/no-meaningless-void-operator": "error",
|
|
404
|
+
"typescript/no-misused-new": "error",
|
|
405
|
+
"typescript/no-misused-promises": "error",
|
|
406
|
+
"typescript/no-mixed-enums": "error",
|
|
407
|
+
"typescript/no-namespace": "error",
|
|
408
|
+
"typescript/no-non-null-asserted-nullish-coalescing": "error",
|
|
409
|
+
"typescript/no-non-null-asserted-optional-chain": "error",
|
|
410
|
+
"typescript/no-non-null-assertion": "off",
|
|
411
|
+
"typescript/no-redundant-type-constituents": "error",
|
|
412
|
+
"typescript/no-this-alias": "error",
|
|
413
|
+
"typescript/no-unnecessary-boolean-literal-compare": "error",
|
|
414
|
+
"typescript/no-unnecessary-condition": "error",
|
|
415
|
+
"typescript/no-unnecessary-template-expression": "error",
|
|
416
|
+
"typescript/no-unnecessary-type-arguments": "error",
|
|
417
|
+
"typescript/no-unnecessary-type-assertion": "error",
|
|
418
|
+
"typescript/no-unnecessary-type-constraint": "error",
|
|
419
|
+
"typescript/no-unsafe-declaration-merging": "error",
|
|
420
|
+
"typescript/no-unsafe-function-type": "error",
|
|
421
|
+
"typescript/no-useless-empty-export": "error",
|
|
422
|
+
"typescript/no-var-requires": "error",
|
|
423
|
+
"typescript/no-wrapper-object-types": "error",
|
|
424
|
+
"typescript/non-nullable-type-assertion-style": "error",
|
|
425
|
+
"typescript/only-throw-error": "error",
|
|
426
|
+
"typescript/prefer-as-const": "error",
|
|
427
|
+
"typescript/prefer-literal-enum-member": "error",
|
|
428
|
+
"typescript/prefer-optional-chain": "error",
|
|
429
|
+
"typescript/triple-slash-reference": "warn",
|
|
430
|
+
"typescript/unified-signatures": "error"
|
|
479
431
|
};
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
"unicorn/throw-new-error": "error"
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/oxlint/presets/unicorn.ts
|
|
434
|
+
const unicornRules = {
|
|
435
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
436
|
+
"unicorn/consistent-function-scoping": "error",
|
|
437
|
+
"unicorn/error-message": "error",
|
|
438
|
+
"unicorn/escape-case": "error",
|
|
439
|
+
"unicorn/explicit-length-check": ["error", { "non-zero": "not-equal" }],
|
|
440
|
+
"unicorn/new-for-builtins": "error",
|
|
441
|
+
"unicorn/no-anonymous-default-export": "error",
|
|
442
|
+
"unicorn/no-await-expression-member": "error",
|
|
443
|
+
"unicorn/no-await-in-promise-methods": "error",
|
|
444
|
+
"unicorn/no-instanceof-builtins": "error",
|
|
445
|
+
"unicorn/no-new-array": "error",
|
|
446
|
+
"unicorn/no-new-buffer": "error",
|
|
447
|
+
"unicorn/no-useless-length-check": "error",
|
|
448
|
+
"unicorn/no-useless-spread": "error",
|
|
449
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
450
|
+
"unicorn/prefer-includes": "error",
|
|
451
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
452
|
+
"unicorn/prefer-node-protocol": "error",
|
|
453
|
+
"unicorn/prefer-number-properties": "error",
|
|
454
|
+
"unicorn/prefer-query-selector": "error",
|
|
455
|
+
"unicorn/prefer-string-raw": "error",
|
|
456
|
+
"unicorn/prefer-type-error": "error",
|
|
457
|
+
"unicorn/throw-new-error": "error"
|
|
507
458
|
};
|
|
508
|
-
|
|
509
|
-
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/shared/utils.ts
|
|
510
461
|
function resolvePreset(preset, defaultEnabled) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
options: preset.options
|
|
520
|
-
};
|
|
462
|
+
if (typeof preset === "boolean" || preset == null) return {
|
|
463
|
+
enabled: preset ?? defaultEnabled,
|
|
464
|
+
options: void 0
|
|
465
|
+
};
|
|
466
|
+
return {
|
|
467
|
+
enabled: preset.enabled ?? true,
|
|
468
|
+
options: preset.options
|
|
469
|
+
};
|
|
521
470
|
}
|
|
522
471
|
function dedupe(values) {
|
|
523
|
-
|
|
472
|
+
return [...new Set(values)];
|
|
524
473
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region src/oxlint/shared.ts
|
|
476
|
+
const scriptFiles = [
|
|
477
|
+
"scripts/**/*.js",
|
|
478
|
+
"scripts/**/*.mjs",
|
|
479
|
+
"scripts/**/*.cjs",
|
|
480
|
+
"scripts/**/*.jsx",
|
|
481
|
+
"scripts/**/*.ts",
|
|
482
|
+
"scripts/**/*.mts",
|
|
483
|
+
"scripts/**/*.cts",
|
|
484
|
+
"scripts/**/*.tsx",
|
|
485
|
+
"cli.js",
|
|
486
|
+
"cli.mjs",
|
|
487
|
+
"cli.cjs",
|
|
488
|
+
"cli.jsx",
|
|
489
|
+
"cli.ts",
|
|
490
|
+
"cli.mts",
|
|
491
|
+
"cli.cts",
|
|
492
|
+
"cli.tsx"
|
|
493
|
+
];
|
|
494
|
+
const tsFiles = [
|
|
495
|
+
"**/*.ts",
|
|
496
|
+
"**/*.mts",
|
|
497
|
+
"**/*.cts",
|
|
498
|
+
"**/*.tsx",
|
|
499
|
+
"**/*.mtsx",
|
|
500
|
+
"**/*.ctsx"
|
|
501
|
+
];
|
|
502
|
+
const sourceFiles = [
|
|
503
|
+
"**/*.js",
|
|
504
|
+
"**/*.mjs",
|
|
505
|
+
"**/*.cjs",
|
|
506
|
+
"**/*.jsx",
|
|
507
|
+
"**/*.ts",
|
|
508
|
+
"**/*.mts",
|
|
509
|
+
"**/*.cts",
|
|
510
|
+
"**/*.tsx",
|
|
511
|
+
"**/*.mtsx",
|
|
512
|
+
"**/*.ctsx"
|
|
544
513
|
];
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
"**/*.mtsx",
|
|
551
|
-
"**/*.ctsx"
|
|
514
|
+
const componentFiles = [
|
|
515
|
+
"**/*.jsx",
|
|
516
|
+
"**/*.tsx",
|
|
517
|
+
"**/*.mtsx",
|
|
518
|
+
"**/*.ctsx"
|
|
552
519
|
];
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
"**/*.jsx",
|
|
558
|
-
"**/*.ts",
|
|
559
|
-
"**/*.mts",
|
|
560
|
-
"**/*.cts",
|
|
561
|
-
"**/*.tsx",
|
|
562
|
-
"**/*.mtsx",
|
|
563
|
-
"**/*.ctsx"
|
|
520
|
+
const dtsFiles = [
|
|
521
|
+
"**/*.d.ts",
|
|
522
|
+
"**/*.d.mts",
|
|
523
|
+
"**/*.d.cts"
|
|
564
524
|
];
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
"**/*.benchmark.mtsx",
|
|
618
|
-
"**/*.benchmark.ctsx"
|
|
525
|
+
const jsRequireFiles = ["**/*.js", "**/*.cjs"];
|
|
526
|
+
const testFiles = [
|
|
527
|
+
"**/__tests__/**/*.js",
|
|
528
|
+
"**/__tests__/**/*.mjs",
|
|
529
|
+
"**/__tests__/**/*.cjs",
|
|
530
|
+
"**/__tests__/**/*.jsx",
|
|
531
|
+
"**/__tests__/**/*.ts",
|
|
532
|
+
"**/__tests__/**/*.mts",
|
|
533
|
+
"**/__tests__/**/*.cts",
|
|
534
|
+
"**/__tests__/**/*.tsx",
|
|
535
|
+
"**/__tests__/**/*.mtsx",
|
|
536
|
+
"**/__tests__/**/*.ctsx",
|
|
537
|
+
"**/*.spec.js",
|
|
538
|
+
"**/*.spec.mjs",
|
|
539
|
+
"**/*.spec.cjs",
|
|
540
|
+
"**/*.spec.jsx",
|
|
541
|
+
"**/*.spec.ts",
|
|
542
|
+
"**/*.spec.mts",
|
|
543
|
+
"**/*.spec.cts",
|
|
544
|
+
"**/*.spec.tsx",
|
|
545
|
+
"**/*.spec.mtsx",
|
|
546
|
+
"**/*.spec.ctsx",
|
|
547
|
+
"**/*.test.js",
|
|
548
|
+
"**/*.test.mjs",
|
|
549
|
+
"**/*.test.cjs",
|
|
550
|
+
"**/*.test.jsx",
|
|
551
|
+
"**/*.test.ts",
|
|
552
|
+
"**/*.test.mts",
|
|
553
|
+
"**/*.test.cts",
|
|
554
|
+
"**/*.test.tsx",
|
|
555
|
+
"**/*.test.mtsx",
|
|
556
|
+
"**/*.test.ctsx",
|
|
557
|
+
"**/*.bench.js",
|
|
558
|
+
"**/*.bench.mjs",
|
|
559
|
+
"**/*.bench.cjs",
|
|
560
|
+
"**/*.bench.jsx",
|
|
561
|
+
"**/*.bench.ts",
|
|
562
|
+
"**/*.bench.mts",
|
|
563
|
+
"**/*.bench.cts",
|
|
564
|
+
"**/*.bench.tsx",
|
|
565
|
+
"**/*.bench.mtsx",
|
|
566
|
+
"**/*.bench.ctsx",
|
|
567
|
+
"**/*.benchmark.js",
|
|
568
|
+
"**/*.benchmark.mjs",
|
|
569
|
+
"**/*.benchmark.cjs",
|
|
570
|
+
"**/*.benchmark.jsx",
|
|
571
|
+
"**/*.benchmark.ts",
|
|
572
|
+
"**/*.benchmark.mts",
|
|
573
|
+
"**/*.benchmark.cts",
|
|
574
|
+
"**/*.benchmark.tsx",
|
|
575
|
+
"**/*.benchmark.mtsx",
|
|
576
|
+
"**/*.benchmark.ctsx"
|
|
619
577
|
];
|
|
620
578
|
function resolveRulePreset(preset, defaultEnabled) {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
};
|
|
579
|
+
return {
|
|
580
|
+
...resolvePreset(preset, defaultEnabled),
|
|
581
|
+
rules: typeof preset === "boolean" || preset == null ? {} : preset.rules ?? {}
|
|
582
|
+
};
|
|
626
583
|
}
|
|
627
584
|
function resolveIgnorePreset(preset, defaultEnabled) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
patterns: preset.patterns ?? []
|
|
637
|
-
};
|
|
585
|
+
if (typeof preset === "boolean" || preset == null) return {
|
|
586
|
+
enabled: preset ?? defaultEnabled,
|
|
587
|
+
patterns: []
|
|
588
|
+
};
|
|
589
|
+
return {
|
|
590
|
+
enabled: preset.enabled ?? defaultEnabled,
|
|
591
|
+
patterns: preset.patterns ?? []
|
|
592
|
+
};
|
|
638
593
|
}
|
|
639
594
|
function mergeRules(...entries) {
|
|
640
|
-
|
|
595
|
+
return Object.assign({}, ...entries);
|
|
641
596
|
}
|
|
642
597
|
function pickRules(rules, predicate) {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
return Object.fromEntries(
|
|
647
|
-
Object.entries(rules).filter(([rule]) => predicate(rule))
|
|
648
|
-
);
|
|
598
|
+
if (!rules) return {};
|
|
599
|
+
return Object.fromEntries(Object.entries(rules).filter(([rule]) => predicate(rule)));
|
|
649
600
|
}
|
|
650
601
|
function appendPlugin(plugins, plugin) {
|
|
651
|
-
|
|
652
|
-
plugins.push(plugin);
|
|
653
|
-
}
|
|
602
|
+
if (!plugins.includes(plugin)) plugins.push(plugin);
|
|
654
603
|
}
|
|
655
604
|
function pruneOverride(override) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
}
|
|
665
|
-
if (override.globals && Object.keys(override.globals).length !== 0) {
|
|
666
|
-
result.globals = override.globals;
|
|
667
|
-
}
|
|
668
|
-
if (override.jsPlugins && override.jsPlugins.length !== 0) {
|
|
669
|
-
result.jsPlugins = override.jsPlugins;
|
|
670
|
-
}
|
|
671
|
-
if (override.plugins && override.plugins.length !== 0) {
|
|
672
|
-
result.plugins = override.plugins;
|
|
673
|
-
}
|
|
674
|
-
if (override.rules && Object.keys(override.rules).length !== 0) {
|
|
675
|
-
result.rules = override.rules;
|
|
676
|
-
}
|
|
677
|
-
return result.rules || result.plugins || result.jsPlugins || result.env || result.globals ? result : null;
|
|
605
|
+
const result = { files: override.files };
|
|
606
|
+
if (override.env && Object.keys(override.env).length !== 0) result.env = override.env;
|
|
607
|
+
if (override.excludeFiles && override.excludeFiles.length !== 0) result.excludeFiles = override.excludeFiles;
|
|
608
|
+
if (override.globals && Object.keys(override.globals).length !== 0) result.globals = override.globals;
|
|
609
|
+
if (override.jsPlugins && override.jsPlugins.length !== 0) result.jsPlugins = override.jsPlugins;
|
|
610
|
+
if (override.plugins && override.plugins.length !== 0) result.plugins = override.plugins;
|
|
611
|
+
if (override.rules && Object.keys(override.rules).length !== 0) result.rules = override.rules;
|
|
612
|
+
return result.rules || result.plugins || result.jsPlugins || result.env || result.globals ? result : null;
|
|
678
613
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
614
|
+
//#endregion
|
|
615
|
+
//#region src/oxlint/index.ts
|
|
616
|
+
const defaultOxlintPresets = {
|
|
617
|
+
ignores: true,
|
|
618
|
+
imports: true,
|
|
619
|
+
javascript: true,
|
|
620
|
+
next: isPackageExists("next"),
|
|
621
|
+
node: false,
|
|
622
|
+
react: isPackageExists("react"),
|
|
623
|
+
reactAgentRules: isPackageExists("react"),
|
|
624
|
+
test: isPackageExists("vitest"),
|
|
625
|
+
typescript: isPackageExists("typescript"),
|
|
626
|
+
unicorn: true
|
|
692
627
|
};
|
|
693
628
|
function defineOxlintConfig(options = {}) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
reactRules,
|
|
817
|
-
a11y && reactPreset.enabled ? jsxA11yRules : void 0,
|
|
818
|
-
nextRules,
|
|
819
|
-
reactAgentRulesPreset.enabled ? {
|
|
820
|
-
"react/exhaustive-deps": "off"
|
|
821
|
-
} : void 0,
|
|
822
|
-
reactPreset.rules,
|
|
823
|
-
nextPreset.rules
|
|
824
|
-
);
|
|
825
|
-
if (reactPreset.enabled) {
|
|
826
|
-
appendPlugin(overridePlugins, "react");
|
|
827
|
-
}
|
|
828
|
-
if (reactPreset.enabled && a11y) {
|
|
829
|
-
appendPlugin(overridePlugins, "jsx-a11y");
|
|
830
|
-
}
|
|
831
|
-
if (nextPreset.enabled) {
|
|
832
|
-
appendPlugin(overridePlugins, "nextjs");
|
|
833
|
-
}
|
|
834
|
-
const override = pruneOverride({
|
|
835
|
-
files: sourceFiles,
|
|
836
|
-
plugins: overridePlugins,
|
|
837
|
-
rules: mergedRules
|
|
838
|
-
});
|
|
839
|
-
if (override) {
|
|
840
|
-
overrides.push(override);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
overrides.push({
|
|
844
|
-
files: testFiles,
|
|
845
|
-
plugins: testPreset.enabled ? ["vitest"] : void 0,
|
|
846
|
-
rules: mergeRules(
|
|
847
|
-
{
|
|
848
|
-
"max-lines": [
|
|
849
|
-
"error",
|
|
850
|
-
{
|
|
851
|
-
max: 500,
|
|
852
|
-
skipBlankLines: true,
|
|
853
|
-
skipComments: true
|
|
854
|
-
}
|
|
855
|
-
]
|
|
856
|
-
},
|
|
857
|
-
testPreset.enabled ? vitestRules : void 0,
|
|
858
|
-
testPreset.rules
|
|
859
|
-
)
|
|
860
|
-
});
|
|
861
|
-
const config = {
|
|
862
|
-
$schema: "./node_modules/oxlint/configuration_schema.json",
|
|
863
|
-
categories: {
|
|
864
|
-
correctness: "off",
|
|
865
|
-
...options.categories ?? {}
|
|
866
|
-
},
|
|
867
|
-
env: {
|
|
868
|
-
browser: true,
|
|
869
|
-
builtin: true,
|
|
870
|
-
es2024: true,
|
|
871
|
-
node: true,
|
|
872
|
-
...options.env ?? {}
|
|
873
|
-
},
|
|
874
|
-
extends: options.extends,
|
|
875
|
-
globals: options.globals,
|
|
876
|
-
ignorePatterns: ignorePreset.enabled ? dedupe([
|
|
877
|
-
...defaultIgnorePatterns,
|
|
878
|
-
...ignorePreset.patterns,
|
|
879
|
-
...options.ignorePatterns ?? []
|
|
880
|
-
]) : options.ignorePatterns,
|
|
881
|
-
jsPlugins: reactAgentRulesPreset.enabled ? [reactAgentRulesPlugin, ...options.jsPlugins ?? []] : options.jsPlugins,
|
|
882
|
-
overrides: [...overrides, ...options.overrides ?? []].map(pruneOverride).filter((override) => override !== null),
|
|
883
|
-
plugins,
|
|
884
|
-
rules,
|
|
885
|
-
settings: options.settings
|
|
886
|
-
};
|
|
887
|
-
if (typeScriptPreset.enabled) {
|
|
888
|
-
config.options = {
|
|
889
|
-
typeAware: typeScriptPreset.options?.typeAware ?? true
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
if (!config.ignorePatterns || config.ignorePatterns.length === 0) {
|
|
893
|
-
delete config.ignorePatterns;
|
|
894
|
-
}
|
|
895
|
-
if (!config.extends || config.extends.length === 0) {
|
|
896
|
-
delete config.extends;
|
|
897
|
-
}
|
|
898
|
-
if (!config.globals || Object.keys(config.globals).length === 0) {
|
|
899
|
-
delete config.globals;
|
|
900
|
-
}
|
|
901
|
-
if (!config.overrides || config.overrides.length === 0) {
|
|
902
|
-
delete config.overrides;
|
|
903
|
-
}
|
|
904
|
-
if (!config.jsPlugins || config.jsPlugins.length === 0) {
|
|
905
|
-
delete config.jsPlugins;
|
|
906
|
-
}
|
|
907
|
-
if (!config.plugins || config.plugins.length === 0) {
|
|
908
|
-
delete config.plugins;
|
|
909
|
-
}
|
|
910
|
-
if (!config.rules || Object.keys(config.rules).length === 0) {
|
|
911
|
-
delete config.rules;
|
|
912
|
-
}
|
|
913
|
-
if (!config.settings || Object.keys(config.settings).length === 0) {
|
|
914
|
-
delete config.settings;
|
|
915
|
-
}
|
|
916
|
-
return config;
|
|
629
|
+
const presets = {
|
|
630
|
+
...defaultOxlintPresets,
|
|
631
|
+
...options.presets
|
|
632
|
+
};
|
|
633
|
+
const ignorePreset = resolveIgnorePreset(presets.ignores, true);
|
|
634
|
+
const importPreset = resolveRulePreset(presets.imports, true);
|
|
635
|
+
const javascriptPreset = resolveRulePreset(presets.javascript, true);
|
|
636
|
+
const nextPreset = resolveRulePreset(presets.next, defaultOxlintPresets.next);
|
|
637
|
+
const nodePreset = resolveRulePreset(presets.node, false);
|
|
638
|
+
const reactPreset = resolveRulePreset(presets.react, defaultOxlintPresets.react);
|
|
639
|
+
const reactAgentRulesPreset = resolveRulePreset(options.presets?.reactAgentRules, reactPreset.enabled);
|
|
640
|
+
const testPreset = resolveRulePreset(presets.test, defaultOxlintPresets.test);
|
|
641
|
+
const typeScriptPreset = resolveRulePreset(presets.typescript, defaultOxlintPresets.typescript);
|
|
642
|
+
const unicornPreset = resolveRulePreset(presets.unicorn, true);
|
|
643
|
+
const reactAgentRulesForSourceFiles = reactAgentRulesPreset.enabled ? mergeRules(reactAgentRules, reactAgentRulesPreset.rules, pickRules(options.rules, (rule) => rule.startsWith("react-agent-rules/"))) : void 0;
|
|
644
|
+
const plugins = [];
|
|
645
|
+
const rules = mergeRules({ "max-lines": ["error", {
|
|
646
|
+
max: 300,
|
|
647
|
+
skipBlankLines: true,
|
|
648
|
+
skipComments: true
|
|
649
|
+
}] }, unicornPreset.enabled ? unicornRules : void 0, unicornPreset.rules, importPreset.enabled ? importRules : void 0, importPreset.rules, javascriptPreset.enabled ? javascriptRules : void 0, javascriptPreset.rules, nodePreset.enabled ? nodeRules : void 0, nodePreset.rules, reactAgentRulesPreset.enabled ? reactAgentRules : void 0, reactAgentRulesPreset.rules, options.rules);
|
|
650
|
+
if (unicornPreset.enabled) appendPlugin(plugins, "unicorn");
|
|
651
|
+
if (importPreset.enabled) appendPlugin(plugins, "import");
|
|
652
|
+
if (typeScriptPreset.enabled) appendPlugin(plugins, "typescript");
|
|
653
|
+
if (nodePreset.enabled) appendPlugin(plugins, "node");
|
|
654
|
+
const overrides = [];
|
|
655
|
+
if (reactAgentRulesPreset.enabled && reactAgentRulesForSourceFiles) overrides.push({
|
|
656
|
+
files: sourceFiles,
|
|
657
|
+
jsPlugins: [reactAgentRulesPlugin],
|
|
658
|
+
rules: reactAgentRulesForSourceFiles
|
|
659
|
+
});
|
|
660
|
+
if (javascriptPreset.enabled) overrides.push({
|
|
661
|
+
files: scriptFiles,
|
|
662
|
+
rules: { "no-console": "off" }
|
|
663
|
+
});
|
|
664
|
+
if (typeScriptPreset.enabled) {
|
|
665
|
+
overrides.push({
|
|
666
|
+
files: tsFiles,
|
|
667
|
+
rules: mergeRules(typeScriptRules, typeScriptPreset.rules)
|
|
668
|
+
});
|
|
669
|
+
overrides.push({
|
|
670
|
+
files: dtsFiles,
|
|
671
|
+
rules: { "import/no-duplicates": "off" }
|
|
672
|
+
});
|
|
673
|
+
overrides.push({
|
|
674
|
+
files: jsRequireFiles,
|
|
675
|
+
rules: {
|
|
676
|
+
"typescript/no-require-imports": "off",
|
|
677
|
+
"typescript/no-var-requires": "off"
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
overrides.push({
|
|
682
|
+
files: componentFiles,
|
|
683
|
+
rules: { "max-lines": ["error", {
|
|
684
|
+
max: 200,
|
|
685
|
+
skipBlankLines: true,
|
|
686
|
+
skipComments: true
|
|
687
|
+
}] }
|
|
688
|
+
});
|
|
689
|
+
if (reactPreset.enabled || nextPreset.enabled) {
|
|
690
|
+
const reactOptions = reactPreset.options ?? {};
|
|
691
|
+
const a11y = reactOptions.a11y ?? true;
|
|
692
|
+
const overridePlugins = [];
|
|
693
|
+
const reactRules = reactPreset.enabled ? createReactRules(reactOptions, nextPreset.enabled) : {};
|
|
694
|
+
const nextRules = nextPreset.enabled ? nextjsRules : {};
|
|
695
|
+
const mergedRules = mergeRules(reactRules, a11y && reactPreset.enabled ? jsxA11yRules : void 0, nextRules, reactAgentRulesPreset.enabled ? { "react/exhaustive-deps": "off" } : void 0, reactPreset.rules, nextPreset.rules);
|
|
696
|
+
if (reactPreset.enabled) appendPlugin(overridePlugins, "react");
|
|
697
|
+
if (reactPreset.enabled && a11y) appendPlugin(overridePlugins, "jsx-a11y");
|
|
698
|
+
if (nextPreset.enabled) appendPlugin(overridePlugins, "nextjs");
|
|
699
|
+
const override = pruneOverride({
|
|
700
|
+
files: sourceFiles,
|
|
701
|
+
plugins: overridePlugins,
|
|
702
|
+
rules: mergedRules
|
|
703
|
+
});
|
|
704
|
+
if (override) overrides.push(override);
|
|
705
|
+
}
|
|
706
|
+
overrides.push({
|
|
707
|
+
files: testFiles,
|
|
708
|
+
plugins: testPreset.enabled ? ["vitest"] : void 0,
|
|
709
|
+
rules: mergeRules({ "max-lines": ["error", {
|
|
710
|
+
max: 500,
|
|
711
|
+
skipBlankLines: true,
|
|
712
|
+
skipComments: true
|
|
713
|
+
}] }, testPreset.enabled ? vitestRules : void 0, testPreset.rules)
|
|
714
|
+
});
|
|
715
|
+
const config = {
|
|
716
|
+
$schema: "./node_modules/oxlint/configuration_schema.json",
|
|
717
|
+
categories: {
|
|
718
|
+
correctness: "off",
|
|
719
|
+
...options.categories ?? {}
|
|
720
|
+
},
|
|
721
|
+
env: {
|
|
722
|
+
browser: true,
|
|
723
|
+
builtin: true,
|
|
724
|
+
es2024: true,
|
|
725
|
+
node: true,
|
|
726
|
+
...options.env ?? {}
|
|
727
|
+
},
|
|
728
|
+
extends: options.extends,
|
|
729
|
+
globals: options.globals,
|
|
730
|
+
ignorePatterns: ignorePreset.enabled ? dedupe([
|
|
731
|
+
...defaultIgnorePatterns,
|
|
732
|
+
...ignorePreset.patterns,
|
|
733
|
+
...options.ignorePatterns ?? []
|
|
734
|
+
]) : options.ignorePatterns,
|
|
735
|
+
jsPlugins: reactAgentRulesPreset.enabled ? [reactAgentRulesPlugin, ...options.jsPlugins ?? []] : options.jsPlugins,
|
|
736
|
+
overrides: [...overrides, ...options.overrides ?? []].map(pruneOverride).filter((override) => override !== null),
|
|
737
|
+
plugins,
|
|
738
|
+
rules,
|
|
739
|
+
settings: options.settings
|
|
740
|
+
};
|
|
741
|
+
if (typeScriptPreset.enabled) config.options = { typeAware: typeScriptPreset.options?.typeAware ?? true };
|
|
742
|
+
if (!config.ignorePatterns || config.ignorePatterns.length === 0) delete config.ignorePatterns;
|
|
743
|
+
if (!config.extends || config.extends.length === 0) delete config.extends;
|
|
744
|
+
if (!config.globals || Object.keys(config.globals).length === 0) delete config.globals;
|
|
745
|
+
if (!config.overrides || config.overrides.length === 0) delete config.overrides;
|
|
746
|
+
if (!config.jsPlugins || config.jsPlugins.length === 0) delete config.jsPlugins;
|
|
747
|
+
if (!config.plugins || config.plugins.length === 0) delete config.plugins;
|
|
748
|
+
if (!config.rules || Object.keys(config.rules).length === 0) delete config.rules;
|
|
749
|
+
if (!config.settings || Object.keys(config.settings).length === 0) delete config.settings;
|
|
750
|
+
return config;
|
|
917
751
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
752
|
+
const defineConfig = defineOxlintConfig;
|
|
753
|
+
//#endregion
|
|
754
|
+
//#region src/oxfmt/presets/imports.ts
|
|
755
|
+
const defaultSortImports = {
|
|
756
|
+
customGroups: [
|
|
757
|
+
{
|
|
758
|
+
elementNamePattern: ["next", "next/**"],
|
|
759
|
+
groupName: "next"
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
elementNamePattern: [
|
|
763
|
+
"react",
|
|
764
|
+
"react-dom",
|
|
765
|
+
"react-dom/**"
|
|
766
|
+
],
|
|
767
|
+
groupName: "react"
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
elementNamePattern: ["three", "three/**"],
|
|
771
|
+
groupName: "three"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
elementNamePattern: ["@react-three/**"],
|
|
775
|
+
groupName: "reactThree"
|
|
776
|
+
}
|
|
777
|
+
],
|
|
778
|
+
groups: [
|
|
779
|
+
"value-builtin",
|
|
780
|
+
"next",
|
|
781
|
+
"react",
|
|
782
|
+
"three",
|
|
783
|
+
"reactThree",
|
|
784
|
+
"value-external",
|
|
785
|
+
"value-internal",
|
|
786
|
+
[
|
|
787
|
+
"value-index",
|
|
788
|
+
"value-sibling",
|
|
789
|
+
"value-parent"
|
|
790
|
+
],
|
|
791
|
+
"type-builtin",
|
|
792
|
+
"type-external",
|
|
793
|
+
"type-internal",
|
|
794
|
+
[
|
|
795
|
+
"type-index",
|
|
796
|
+
"type-sibling",
|
|
797
|
+
"type-parent"
|
|
798
|
+
],
|
|
799
|
+
"style",
|
|
800
|
+
"side_effect",
|
|
801
|
+
"side_effect_style",
|
|
802
|
+
"unknown"
|
|
803
|
+
],
|
|
804
|
+
ignoreCase: false,
|
|
805
|
+
internalPattern: ["^@/.*", "^~/.*"],
|
|
806
|
+
newlinesBetween: true,
|
|
807
|
+
order: "asc",
|
|
808
|
+
partitionByComment: false,
|
|
809
|
+
partitionByNewline: false,
|
|
810
|
+
sortSideEffects: true
|
|
965
811
|
};
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region src/oxfmt/presets/package-json.ts
|
|
814
|
+
const defaultSortPackageJson = { sortScripts: false };
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region src/oxfmt/presets/tailwindcss.ts
|
|
817
|
+
const defaultTailwindSort = { functions: [
|
|
818
|
+
"clsx",
|
|
819
|
+
"cn",
|
|
820
|
+
"cva",
|
|
821
|
+
"tw"
|
|
822
|
+
] };
|
|
823
|
+
//#endregion
|
|
824
|
+
//#region src/oxfmt/index.ts
|
|
825
|
+
const defaultOxfmtPresets = {
|
|
826
|
+
imports: true,
|
|
827
|
+
packageJson: true,
|
|
828
|
+
tailwindcss: false
|
|
982
829
|
};
|
|
983
830
|
function defineOxfmtConfig(options = {}) {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
trailingComma: options.trailingComma ?? "all",
|
|
1019
|
-
useTabs: options.useTabs ?? false
|
|
1020
|
-
};
|
|
831
|
+
const presets = {
|
|
832
|
+
...defaultOxfmtPresets,
|
|
833
|
+
...options.presets
|
|
834
|
+
};
|
|
835
|
+
const importsPreset = resolvePreset(presets.imports, true);
|
|
836
|
+
const packageJsonPreset = resolvePreset(presets.packageJson, true);
|
|
837
|
+
const tailwindPreset = resolvePreset(presets.tailwindcss, false);
|
|
838
|
+
const sortImports = importsPreset.enabled ? {
|
|
839
|
+
...defaultSortImports,
|
|
840
|
+
...importsPreset.options
|
|
841
|
+
} : false;
|
|
842
|
+
const sortPackageJson = packageJsonPreset.enabled ? {
|
|
843
|
+
...defaultSortPackageJson,
|
|
844
|
+
...packageJsonPreset.options
|
|
845
|
+
} : false;
|
|
846
|
+
const sortTailwindcss = tailwindPreset.enabled ? {
|
|
847
|
+
...defaultTailwindSort,
|
|
848
|
+
...tailwindPreset.options
|
|
849
|
+
} : false;
|
|
850
|
+
return {
|
|
851
|
+
$schema: "./node_modules/oxfmt/configuration_schema.json",
|
|
852
|
+
endOfLine: options.endOfLine ?? "lf",
|
|
853
|
+
ignorePatterns: dedupe([...defaultIgnorePatterns, ...options.ignorePatterns ?? []]),
|
|
854
|
+
overrides: options.overrides,
|
|
855
|
+
printWidth: options.printWidth ?? 80,
|
|
856
|
+
semi: options.semi ?? false,
|
|
857
|
+
singleQuote: options.singleQuote ?? true,
|
|
858
|
+
sortImports,
|
|
859
|
+
sortPackageJson,
|
|
860
|
+
sortTailwindcss,
|
|
861
|
+
tabWidth: options.tabWidth ?? 2,
|
|
862
|
+
trailingComma: options.trailingComma ?? "all",
|
|
863
|
+
useTabs: options.useTabs ?? false
|
|
864
|
+
};
|
|
1021
865
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
defaultOxfmtPresets,
|
|
1025
|
-
defaultOxlintPresets,
|
|
1026
|
-
defaultSortImports,
|
|
1027
|
-
defineConfig,
|
|
1028
|
-
defineOxfmtConfig,
|
|
1029
|
-
defineOxlintConfig
|
|
1030
|
-
};
|
|
866
|
+
//#endregion
|
|
867
|
+
export { defaultIgnorePatterns, defaultOxfmtPresets, defaultOxlintPresets, defaultSortImports, defineConfig, defineOxfmtConfig, defineOxlintConfig };
|