@quentinhsu/biome-config 0.1.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.
Files changed (32) hide show
  1. package/README.md +138 -0
  2. package/dist/build.mjs +381 -0
  3. package/dist/index.jsonc +146 -0
  4. package/dist/index.mjs +351 -0
  5. package/dist/next.jsonc +163 -0
  6. package/dist/nuxt.jsonc +218 -0
  7. package/dist/react.jsonc +161 -0
  8. package/dist/types/scripts/generate-biome-types.d.ts +1 -0
  9. package/dist/types/src/build.d.ts +1 -0
  10. package/dist/types/src/constants/biome.d.ts +1 -0
  11. package/dist/types/src/generated/biome/index.d.ts +11 -0
  12. package/dist/types/src/generated/biome/no-compare-neg-zero-configuration.d.ts +986 -0
  13. package/dist/types/src/generated/biome/no-global-object-calls-options.d.ts +306 -0
  14. package/dist/types/src/generated/biome/no-nested-ternary-options.d.ts +292 -0
  15. package/dist/types/src/generated/biome/no-octal-escape-options.d.ts +1138 -0
  16. package/dist/types/src/generated/biome/no-shadow-configuration.d.ts +241 -0
  17. package/dist/types/src/generated/biome/nursery.d.ts +1023 -0
  18. package/dist/types/src/generated/biome/rule-with-no-duplicate-custom-properties-options.d.ts +1095 -0
  19. package/dist/types/src/generated/biome/rule-with-no-useless-catch-options.d.ts +1430 -0
  20. package/dist/types/src/generated/biome/rule-with-use-image-size-options.d.ts +1339 -0
  21. package/dist/types/src/generated/biome/schema.d.ts +291 -0
  22. package/dist/types/src/generated/biome/use-valid-lang-configuration.d.ts +163 -0
  23. package/dist/types/src/index.d.ts +15 -0
  24. package/dist/types/src/presets/next.d.ts +1 -0
  25. package/dist/types/src/presets/nuxt.d.ts +1 -0
  26. package/dist/types/src/presets/react.d.ts +1 -0
  27. package/dist/types/src/presets/vue.d.ts +1 -0
  28. package/dist/types/src/source/index.d.ts +2 -0
  29. package/dist/types/src/types.d.ts +1 -0
  30. package/dist/types/src/utils/merge.d.ts +2 -0
  31. package/dist/vue.jsonc +170 -0
  32. package/package.json +41 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,351 @@
1
+ const isPlainObject = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
2
+ const mergeArrays = (a, b)=>{
3
+ const result = [
4
+ ...a
5
+ ];
6
+ for (const item of b)if (!result.some((existing)=>deepEqual(existing, item))) result.push(item);
7
+ return result;
8
+ };
9
+ const deepEqual = (a, b)=>{
10
+ if (a === b) return true;
11
+ if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((item, index)=>deepEqual(item, b[index]));
12
+ if (isPlainObject(a) && isPlainObject(b)) {
13
+ const keysA = Object.keys(a);
14
+ const keysB = Object.keys(b);
15
+ return keysA.length === keysB.length && keysA.every((key)=>deepEqual(a[key], b[key]));
16
+ }
17
+ return false;
18
+ };
19
+ const deepMerge = (target, source)=>{
20
+ for (const [key, value] of Object.entries(source)){
21
+ const current = target[key];
22
+ if (Array.isArray(value)) {
23
+ if (Array.isArray(current)) target[key] = mergeArrays(current, value);
24
+ else target[key] = [
25
+ ...value
26
+ ];
27
+ continue;
28
+ }
29
+ if (isPlainObject(value)) {
30
+ const nextTarget = isPlainObject(current) ? {
31
+ ...current
32
+ } : {};
33
+ target[key] = deepMerge(nextTarget, value);
34
+ continue;
35
+ }
36
+ target[key] = value;
37
+ }
38
+ return target;
39
+ };
40
+ const mergeConfigs = (...configs)=>{
41
+ const merged = configs.reduce((accumulator, config)=>deepMerge(accumulator, config), {});
42
+ return merged;
43
+ };
44
+ const BIOME_SCHEMA_URL = 'https://biomejs.dev/schemas/2.2.6/schema.json';
45
+ const indexConfig = {
46
+ $schema: BIOME_SCHEMA_URL,
47
+ root: true,
48
+ vcs: {
49
+ enabled: true,
50
+ clientKind: 'git',
51
+ useIgnoreFile: true,
52
+ defaultBranch: 'main'
53
+ },
54
+ files: {
55
+ ignoreUnknown: true,
56
+ includes: [
57
+ '**',
58
+ '!**/build',
59
+ '!**/dist',
60
+ '!**/.next'
61
+ ]
62
+ },
63
+ formatter: {
64
+ enabled: true,
65
+ indentStyle: 'space',
66
+ lineWidth: 140,
67
+ formatWithErrors: true
68
+ },
69
+ assist: {
70
+ actions: {
71
+ source: {
72
+ organizeImports: {
73
+ level: 'on',
74
+ options: {
75
+ groups: [
76
+ [
77
+ ':NODE:',
78
+ ':BUN:',
79
+ ':PACKAGE_WITH_PROTOCOL:',
80
+ ':PACKAGE:'
81
+ ],
82
+ ':BLANK_LINE:',
83
+ ':ALIAS:',
84
+ ':BLANK_LINE:',
85
+ ':PATH:'
86
+ ]
87
+ }
88
+ }
89
+ }
90
+ }
91
+ },
92
+ linter: {
93
+ enabled: true,
94
+ rules: {
95
+ recommended: true,
96
+ complexity: {
97
+ noUselessStringConcat: 'error',
98
+ noUselessUndefinedInitialization: 'error',
99
+ noVoid: 'error',
100
+ useDateNow: 'error'
101
+ },
102
+ correctness: {
103
+ noConstantMathMinMaxClamp: 'error',
104
+ noUndeclaredVariables: 'error',
105
+ noUnusedImports: 'error',
106
+ noUnusedFunctionParameters: 'error',
107
+ noUnusedPrivateClassMembers: 'error',
108
+ useExhaustiveDependencies: {
109
+ level: 'error',
110
+ options: {
111
+ reportUnnecessaryDependencies: false
112
+ }
113
+ },
114
+ noUnusedVariables: 'error'
115
+ },
116
+ style: {
117
+ noParameterProperties: 'error',
118
+ noYodaExpression: 'error',
119
+ useConsistentBuiltinInstantiation: 'error',
120
+ useFragmentSyntax: 'error',
121
+ useImportType: {
122
+ level: 'error',
123
+ fix: 'safe',
124
+ options: {
125
+ style: 'separatedType'
126
+ }
127
+ },
128
+ useSelfClosingElements: {
129
+ level: 'error',
130
+ fix: 'safe',
131
+ options: {}
132
+ },
133
+ useShorthandAssign: 'error',
134
+ useArrayLiterals: 'error'
135
+ },
136
+ nursery: {
137
+ useSortedClasses: {
138
+ level: 'error',
139
+ fix: 'safe',
140
+ options: {
141
+ functions: [
142
+ 'clsx',
143
+ 'cn'
144
+ ]
145
+ }
146
+ }
147
+ },
148
+ suspicious: {
149
+ useAwait: 'error',
150
+ noEvolvingTypes: 'error'
151
+ }
152
+ }
153
+ },
154
+ javascript: {
155
+ formatter: {
156
+ quoteStyle: 'single',
157
+ jsxQuoteStyle: 'single',
158
+ arrowParentheses: 'asNeeded',
159
+ trailingCommas: 'all'
160
+ }
161
+ },
162
+ overrides: [
163
+ {
164
+ includes: [
165
+ '**/*.jsx',
166
+ '**/*.tsx'
167
+ ],
168
+ linter: {
169
+ rules: {
170
+ style: {
171
+ noParameterAssign: 'error'
172
+ }
173
+ }
174
+ }
175
+ },
176
+ {
177
+ includes: [
178
+ '**/*.ts',
179
+ '**/*.tsx'
180
+ ],
181
+ linter: {
182
+ rules: {
183
+ correctness: {
184
+ noUnusedVariables: 'off'
185
+ }
186
+ }
187
+ }
188
+ }
189
+ ]
190
+ };
191
+ const reactOverlay = {
192
+ files: {
193
+ includes: [
194
+ '!**/.storybook'
195
+ ]
196
+ },
197
+ javascript: {
198
+ jsxRuntime: 'reactClassic'
199
+ },
200
+ linter: {
201
+ rules: {
202
+ style: {
203
+ useFragmentSyntax: 'error'
204
+ }
205
+ }
206
+ },
207
+ overrides: [
208
+ {
209
+ includes: [
210
+ '**/__tests__/**',
211
+ '**/*.{test,spec}.{ts,tsx,js,jsx}'
212
+ ],
213
+ linter: {
214
+ rules: {
215
+ correctness: {
216
+ noUnusedVariables: 'off'
217
+ }
218
+ }
219
+ }
220
+ }
221
+ ]
222
+ };
223
+ const reactConfig = mergeConfigs(indexConfig, reactOverlay);
224
+ const nextOverlay = {
225
+ files: {
226
+ includes: [
227
+ '!**/.next',
228
+ '!**/.vercel',
229
+ '!**/out'
230
+ ]
231
+ },
232
+ javascript: {
233
+ jsxRuntime: 'transparent'
234
+ },
235
+ linter: {
236
+ rules: {
237
+ correctness: {
238
+ useExhaustiveDependencies: {
239
+ level: 'error',
240
+ options: {
241
+ reportUnnecessaryDependencies: true
242
+ }
243
+ }
244
+ }
245
+ }
246
+ }
247
+ };
248
+ const nextConfig = mergeConfigs(reactConfig, nextOverlay);
249
+ const vueOverlay = {
250
+ files: {
251
+ includes: [
252
+ '!**/.vitepress',
253
+ '!**/.output'
254
+ ]
255
+ },
256
+ javascript: {
257
+ parser: {
258
+ jsxEverywhere: false
259
+ }
260
+ },
261
+ html: {
262
+ formatter: {
263
+ indentScriptAndStyle: true,
264
+ selfCloseVoidElements: 'always'
265
+ }
266
+ },
267
+ overrides: [
268
+ {
269
+ includes: [
270
+ '**/*.vue'
271
+ ],
272
+ formatter: {
273
+ lineWidth: 120
274
+ },
275
+ javascript: {
276
+ formatter: {
277
+ quoteStyle: 'single'
278
+ }
279
+ }
280
+ }
281
+ ]
282
+ };
283
+ const vueConfig = mergeConfigs(indexConfig, vueOverlay);
284
+ const nuxtOverlay = {
285
+ files: {
286
+ includes: [
287
+ '!**/.nuxt',
288
+ '!**/.nitro',
289
+ '!**/.output'
290
+ ]
291
+ },
292
+ javascript: {
293
+ globals: [
294
+ 'defineNuxtConfig',
295
+ 'defineAppConfig',
296
+ 'defineNuxtPlugin',
297
+ 'defineNuxtRouteMiddleware',
298
+ 'defineNuxtServerPlugin',
299
+ 'defineNitroPlugin',
300
+ 'defineEventHandler',
301
+ 'defineLazyEventHandler',
302
+ 'definePayloadPlugin',
303
+ 'defineRouteRules',
304
+ 'definePageMeta',
305
+ 'useRuntimeConfig',
306
+ 'useNuxtApp',
307
+ 'useAsyncData',
308
+ 'useLazyAsyncData',
309
+ 'useFetch',
310
+ 'useLazyFetch',
311
+ 'useState',
312
+ 'useCookie',
313
+ 'useHead',
314
+ 'useSeoMeta',
315
+ 'useError',
316
+ 'clearError',
317
+ 'showError',
318
+ 'navigateTo',
319
+ 'abortNavigation',
320
+ 'refreshNuxtData',
321
+ 'onNuxtReady',
322
+ 'useRouter',
323
+ 'useRoute',
324
+ 'useRequestEvent',
325
+ 'useRequestHeaders'
326
+ ]
327
+ },
328
+ overrides: [
329
+ {
330
+ includes: [
331
+ '**/*.ts'
332
+ ],
333
+ linter: {
334
+ rules: {
335
+ correctness: {
336
+ noUndeclaredVariables: 'error'
337
+ }
338
+ }
339
+ }
340
+ }
341
+ ]
342
+ };
343
+ const nuxtConfig = mergeConfigs(vueConfig, nuxtOverlay);
344
+ const allPresets = Object.freeze({
345
+ index: indexConfig,
346
+ react: reactConfig,
347
+ next: nextConfig,
348
+ vue: vueConfig,
349
+ nuxt: nuxtConfig
350
+ });
351
+ export { BIOME_SCHEMA_URL, allPresets, indexConfig, nextConfig, nuxtConfig, reactConfig, vueConfig };
@@ -0,0 +1,163 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
3
+ "root": true,
4
+ "vcs": {
5
+ "enabled": true,
6
+ "clientKind": "git",
7
+ "useIgnoreFile": true,
8
+ "defaultBranch": "main"
9
+ },
10
+ "files": {
11
+ "ignoreUnknown": true,
12
+ "includes": [
13
+ "**",
14
+ "!**/build",
15
+ "!**/dist",
16
+ "!**/.next",
17
+ "!**/.storybook",
18
+ "!**/.vercel",
19
+ "!**/out"
20
+ ]
21
+ },
22
+ "formatter": {
23
+ "enabled": true,
24
+ "indentStyle": "space",
25
+ "lineWidth": 140,
26
+ "formatWithErrors": true
27
+ },
28
+ "assist": {
29
+ "actions": {
30
+ "source": {
31
+ "organizeImports": {
32
+ "level": "on",
33
+ "options": {
34
+ "groups": [
35
+ [
36
+ ":NODE:",
37
+ ":BUN:",
38
+ ":PACKAGE_WITH_PROTOCOL:",
39
+ ":PACKAGE:"
40
+ ],
41
+ ":BLANK_LINE:",
42
+ ":ALIAS:",
43
+ ":BLANK_LINE:",
44
+ ":PATH:"
45
+ ]
46
+ }
47
+ }
48
+ }
49
+ }
50
+ },
51
+ "linter": {
52
+ "enabled": true,
53
+ "rules": {
54
+ "recommended": true,
55
+ "complexity": {
56
+ "noUselessStringConcat": "error",
57
+ "noUselessUndefinedInitialization": "error",
58
+ "noVoid": "error",
59
+ "useDateNow": "error"
60
+ },
61
+ "correctness": {
62
+ "noConstantMathMinMaxClamp": "error",
63
+ "noUndeclaredVariables": "error",
64
+ "noUnusedImports": "error",
65
+ "noUnusedFunctionParameters": "error",
66
+ "noUnusedPrivateClassMembers": "error",
67
+ "useExhaustiveDependencies": {
68
+ "level": "error",
69
+ "options": {
70
+ "reportUnnecessaryDependencies": true
71
+ }
72
+ },
73
+ "noUnusedVariables": "error"
74
+ },
75
+ "style": {
76
+ "noParameterProperties": "error",
77
+ "noYodaExpression": "error",
78
+ "useConsistentBuiltinInstantiation": "error",
79
+ "useFragmentSyntax": "error",
80
+ "useImportType": {
81
+ "level": "error",
82
+ "fix": "safe",
83
+ "options": {
84
+ "style": "separatedType"
85
+ }
86
+ },
87
+ "useSelfClosingElements": {
88
+ "level": "error",
89
+ "fix": "safe",
90
+ "options": {}
91
+ },
92
+ "useShorthandAssign": "error",
93
+ "useArrayLiterals": "error"
94
+ },
95
+ "nursery": {
96
+ "useSortedClasses": {
97
+ "level": "error",
98
+ "fix": "safe",
99
+ "options": {
100
+ "functions": [
101
+ "clsx",
102
+ "cn"
103
+ ]
104
+ }
105
+ }
106
+ },
107
+ "suspicious": {
108
+ "useAwait": "error",
109
+ "noEvolvingTypes": "error"
110
+ }
111
+ }
112
+ },
113
+ "javascript": {
114
+ "formatter": {
115
+ "quoteStyle": "single",
116
+ "jsxQuoteStyle": "single",
117
+ "arrowParentheses": "asNeeded",
118
+ "trailingCommas": "all"
119
+ },
120
+ "jsxRuntime": "transparent"
121
+ },
122
+ "overrides": [
123
+ {
124
+ "includes": [
125
+ "**/*.jsx",
126
+ "**/*.tsx"
127
+ ],
128
+ "linter": {
129
+ "rules": {
130
+ "style": {
131
+ "noParameterAssign": "error"
132
+ }
133
+ }
134
+ }
135
+ },
136
+ {
137
+ "includes": [
138
+ "**/*.ts",
139
+ "**/*.tsx"
140
+ ],
141
+ "linter": {
142
+ "rules": {
143
+ "correctness": {
144
+ "noUnusedVariables": "off"
145
+ }
146
+ }
147
+ }
148
+ },
149
+ {
150
+ "includes": [
151
+ "**/__tests__/**",
152
+ "**/*.{test,spec}.{ts,tsx,js,jsx}"
153
+ ],
154
+ "linter": {
155
+ "rules": {
156
+ "correctness": {
157
+ "noUnusedVariables": "off"
158
+ }
159
+ }
160
+ }
161
+ }
162
+ ]
163
+ }