@quentinhsu/biome-config 0.1.0 → 0.2.1

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 (33) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -16
  3. package/package.json +13 -4
  4. package/dist/build.mjs +0 -381
  5. package/dist/index.jsonc +0 -146
  6. package/dist/index.mjs +0 -351
  7. package/dist/next.jsonc +0 -163
  8. package/dist/nuxt.jsonc +0 -218
  9. package/dist/react.jsonc +0 -161
  10. package/dist/types/scripts/generate-biome-types.d.ts +0 -1
  11. package/dist/types/src/build.d.ts +0 -1
  12. package/dist/types/src/constants/biome.d.ts +0 -1
  13. package/dist/types/src/generated/biome/index.d.ts +0 -11
  14. package/dist/types/src/generated/biome/no-compare-neg-zero-configuration.d.ts +0 -986
  15. package/dist/types/src/generated/biome/no-global-object-calls-options.d.ts +0 -306
  16. package/dist/types/src/generated/biome/no-nested-ternary-options.d.ts +0 -292
  17. package/dist/types/src/generated/biome/no-octal-escape-options.d.ts +0 -1138
  18. package/dist/types/src/generated/biome/no-shadow-configuration.d.ts +0 -241
  19. package/dist/types/src/generated/biome/nursery.d.ts +0 -1023
  20. package/dist/types/src/generated/biome/rule-with-no-duplicate-custom-properties-options.d.ts +0 -1095
  21. package/dist/types/src/generated/biome/rule-with-no-useless-catch-options.d.ts +0 -1430
  22. package/dist/types/src/generated/biome/rule-with-use-image-size-options.d.ts +0 -1339
  23. package/dist/types/src/generated/biome/schema.d.ts +0 -291
  24. package/dist/types/src/generated/biome/use-valid-lang-configuration.d.ts +0 -163
  25. package/dist/types/src/index.d.ts +0 -15
  26. package/dist/types/src/presets/next.d.ts +0 -1
  27. package/dist/types/src/presets/nuxt.d.ts +0 -1
  28. package/dist/types/src/presets/react.d.ts +0 -1
  29. package/dist/types/src/presets/vue.d.ts +0 -1
  30. package/dist/types/src/source/index.d.ts +0 -2
  31. package/dist/types/src/types.d.ts +0 -1
  32. package/dist/types/src/utils/merge.d.ts +0 -2
  33. package/dist/vue.jsonc +0 -170
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 QuentinHsu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,17 +1,23 @@
1
1
  # @quentinhsu/biome-config
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@quentinhsu/biome-config?style=flat-square)](https://www.npmjs.com/package/@quentinhsu/biome-config)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@quentinhsu/biome-config?style=flat-square)](https://www.npmjs.com/package/@quentinhsu/biome-config)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-green?style=flat-square)](https://nodejs.org/)
6
+ [![license](https://img.shields.io/npm/l/@quentinhsu/biome-config?style=flat-square)](LICENSE)
7
+
3
8
  A modular Biome configuration preset collection built with Rslib. Includes a comprehensive base configuration with framework-specific overlays (React, Next.js, Vue, Nuxt), ultimately generating `biome.jsonc` files in the `dist/` directory that can be directly extended in projects.
4
9
 
5
- ## Development
10
+ ## Usage
11
+
12
+ ### Installation
13
+
14
+ Install this package in your project:
6
15
 
7
16
  ```bash
8
- pnpm install
9
- pnpm build
17
+ pnpm add -D @quentinhsu/biome-config
10
18
  ```
11
19
 
12
- The build process first compiles TypeScript modules to `dist/` via Rslib, then executes `dist/build.mjs` to output each preset as a JSONC file.
13
-
14
- ## Available Presets
20
+ ### Available Presets
15
21
 
16
22
  | Preset | Description | Export |
17
23
  | --- | --- | --- |
@@ -23,16 +29,6 @@ The build process first compiles TypeScript modules to `dist/` via Rslib, then e
23
29
 
24
30
  Each preset inherits from and extends the base configuration with framework-specific file patterns, globals, and linter rules.
25
31
 
26
- ## Usage
27
-
28
- ### Installation
29
-
30
- Install this package in your project:
31
-
32
- ```bash
33
- pnpm add -D @quentinhsu/biome-config
34
- ```
35
-
36
32
  ### Basic Setup
37
33
 
38
34
  Create or update your `biome.json` (or `biome.jsonc`) file to use the base configuration:
@@ -116,6 +112,50 @@ The base configuration includes:
116
112
  - **VCS**: Git integration with `.gitignore` support
117
113
  - **Files**: Ignores common output directories (`build`, `dist`, `.next`)
118
114
 
115
+ ### VS Code Integration
116
+
117
+ To integrate Biome with VS Code, install the [Biome extension](https://marketplace.visualstudio.com/items?itemName=biomejs.biome) and configure it in `.vscode/settings.json`:
118
+
119
+ <details>
120
+ <summary><b>.vscode/settings.json</b></summary>
121
+
122
+ ```json
123
+ {
124
+ "editor.formatOnSave": true,
125
+ "editor.defaultFormatter": "biomejs.biome",
126
+ "[javascript]": {
127
+ "editor.defaultFormatter": "biomejs.biome"
128
+ },
129
+ "[javascriptreact]": {
130
+ "editor.defaultFormatter": "biomejs.biome"
131
+ },
132
+ "[typescript]": {
133
+ "editor.defaultFormatter": "biomejs.biome"
134
+ },
135
+ "[typescriptreact]": {
136
+ "editor.defaultFormatter": "biomejs.biome"
137
+ },
138
+ "[json]": {
139
+ "editor.defaultFormatter": "biomejs.biome"
140
+ },
141
+ "[jsonc]": {
142
+ "editor.defaultFormatter": "biomejs.biome"
143
+ },
144
+ "editor.codeActionsOnSave": {
145
+ "source.fixAll.biome": "explicit",
146
+ "source.organizeImports.biome": "explicit",
147
+ "source.action.useSortedKeys.biome": "explicit"
148
+ }
149
+ }
150
+ ```
151
+
152
+ This configuration:
153
+ - Enables automatic formatting on save
154
+ - Sets Biome as the default formatter for JavaScript, TypeScript, and JSON files
155
+ - Automatically runs Biome's fix and import organization on save
156
+
157
+ </details>
158
+
119
159
  ### Running Biome
120
160
 
121
161
  Once configured, you can use Biome commands:
@@ -134,5 +174,29 @@ pnpm biome check .
134
174
  pnpm biome lint . --fix
135
175
  ```
136
176
 
177
+ ## Development
178
+
179
+ ### Setup
180
+
181
+ ```bash
182
+ pnpm install
183
+ pnpm build
184
+ ```
185
+
186
+ The build process first compiles TypeScript modules to `dist/` via Rslib, then executes `dist/build.mjs` to output each preset as a JSONC file.
187
+
188
+ ### Publishing
189
+
190
+ For instructions on how to release a new version, see [PUBLISHING.md](PUBLISHING.md).
191
+
192
+ ## Contributing
193
+
194
+ Found an issue or have a suggestion? Please open an [issue](https://github.com/QuentinHsu/biome-config/issues) on GitHub.
195
+
196
+ ## License
197
+
198
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
199
+
200
+
137
201
 
138
202
 
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@quentinhsu/biome-config",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "author": "QuentinHsu",
5
- "repository": "https://github.com/QuentinHsu/biome-config",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/QuentinHsu/biome-config.git"
9
+ },
6
10
  "description": "Modular Biome configuration presets.",
7
11
  "type": "module",
12
+ "packageManager": "pnpm@9.15.0",
8
13
  "files": [
9
14
  "dist"
10
15
  ],
@@ -19,6 +24,7 @@
19
24
  "generate:types": "tsx scripts/generate-biome-types.ts",
20
25
  "prebuild": "pnpm run generate:types",
21
26
  "build": "rslib build && node dist/build.mjs",
27
+ "dev": "nodemon --exec tsx scripts/build-presets.ts",
22
28
  "lint": "npx biome check ."
23
29
  },
24
30
  "keywords": [
@@ -28,13 +34,16 @@
28
34
  "formatter"
29
35
  ],
30
36
  "publishConfig": {
37
+ "provenance": true,
31
38
  "access": "public"
32
39
  },
33
40
  "devDependencies": {
34
- "@biomejs/biome": "^2.3.0",
35
- "@rslib/core": "^0.16.1",
41
+ "@biomejs/biome": "2.3.2",
42
+ "@quentinhsu/biome-config": "workspace:*",
43
+ "@rslib/core": "^0.17.0",
36
44
  "@types/node": "^24.9.1",
37
45
  "json-schema-to-typescript": "^15.0.4",
46
+ "nodemon": "^3.1.10",
38
47
  "tsx": "^4.16.2",
39
48
  "typescript": "^5.6.3"
40
49
  }
package/dist/build.mjs DELETED
@@ -1,381 +0,0 @@
1
- import { mkdir, writeFile } from "node:fs/promises";
2
- import { dirname, join } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- const isPlainObject = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
5
- const mergeArrays = (a, b)=>{
6
- const result = [
7
- ...a
8
- ];
9
- for (const item of b)if (!result.some((existing)=>deepEqual(existing, item))) result.push(item);
10
- return result;
11
- };
12
- const deepEqual = (a, b)=>{
13
- if (a === b) return true;
14
- if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((item, index)=>deepEqual(item, b[index]));
15
- if (isPlainObject(a) && isPlainObject(b)) {
16
- const keysA = Object.keys(a);
17
- const keysB = Object.keys(b);
18
- return keysA.length === keysB.length && keysA.every((key)=>deepEqual(a[key], b[key]));
19
- }
20
- return false;
21
- };
22
- const deepMerge = (target, source)=>{
23
- for (const [key, value] of Object.entries(source)){
24
- const current = target[key];
25
- if (Array.isArray(value)) {
26
- if (Array.isArray(current)) target[key] = mergeArrays(current, value);
27
- else target[key] = [
28
- ...value
29
- ];
30
- continue;
31
- }
32
- if (isPlainObject(value)) {
33
- const nextTarget = isPlainObject(current) ? {
34
- ...current
35
- } : {};
36
- target[key] = deepMerge(nextTarget, value);
37
- continue;
38
- }
39
- target[key] = value;
40
- }
41
- return target;
42
- };
43
- const mergeConfigs = (...configs)=>{
44
- const merged = configs.reduce((accumulator, config)=>deepMerge(accumulator, config), {});
45
- return merged;
46
- };
47
- const BIOME_SCHEMA_URL = 'https://biomejs.dev/schemas/2.2.6/schema.json';
48
- const indexConfig = {
49
- $schema: BIOME_SCHEMA_URL,
50
- root: true,
51
- vcs: {
52
- enabled: true,
53
- clientKind: 'git',
54
- useIgnoreFile: true,
55
- defaultBranch: 'main'
56
- },
57
- files: {
58
- ignoreUnknown: true,
59
- includes: [
60
- '**',
61
- '!**/build',
62
- '!**/dist',
63
- '!**/.next'
64
- ]
65
- },
66
- formatter: {
67
- enabled: true,
68
- indentStyle: 'space',
69
- lineWidth: 140,
70
- formatWithErrors: true
71
- },
72
- assist: {
73
- actions: {
74
- source: {
75
- organizeImports: {
76
- level: 'on',
77
- options: {
78
- groups: [
79
- [
80
- ':NODE:',
81
- ':BUN:',
82
- ':PACKAGE_WITH_PROTOCOL:',
83
- ':PACKAGE:'
84
- ],
85
- ':BLANK_LINE:',
86
- ':ALIAS:',
87
- ':BLANK_LINE:',
88
- ':PATH:'
89
- ]
90
- }
91
- }
92
- }
93
- }
94
- },
95
- linter: {
96
- enabled: true,
97
- rules: {
98
- recommended: true,
99
- complexity: {
100
- noUselessStringConcat: 'error',
101
- noUselessUndefinedInitialization: 'error',
102
- noVoid: 'error',
103
- useDateNow: 'error'
104
- },
105
- correctness: {
106
- noConstantMathMinMaxClamp: 'error',
107
- noUndeclaredVariables: 'error',
108
- noUnusedImports: 'error',
109
- noUnusedFunctionParameters: 'error',
110
- noUnusedPrivateClassMembers: 'error',
111
- useExhaustiveDependencies: {
112
- level: 'error',
113
- options: {
114
- reportUnnecessaryDependencies: false
115
- }
116
- },
117
- noUnusedVariables: 'error'
118
- },
119
- style: {
120
- noParameterProperties: 'error',
121
- noYodaExpression: 'error',
122
- useConsistentBuiltinInstantiation: 'error',
123
- useFragmentSyntax: 'error',
124
- useImportType: {
125
- level: 'error',
126
- fix: 'safe',
127
- options: {
128
- style: 'separatedType'
129
- }
130
- },
131
- useSelfClosingElements: {
132
- level: 'error',
133
- fix: 'safe',
134
- options: {}
135
- },
136
- useShorthandAssign: 'error',
137
- useArrayLiterals: 'error'
138
- },
139
- nursery: {
140
- useSortedClasses: {
141
- level: 'error',
142
- fix: 'safe',
143
- options: {
144
- functions: [
145
- 'clsx',
146
- 'cn'
147
- ]
148
- }
149
- }
150
- },
151
- suspicious: {
152
- useAwait: 'error',
153
- noEvolvingTypes: 'error'
154
- }
155
- }
156
- },
157
- javascript: {
158
- formatter: {
159
- quoteStyle: 'single',
160
- jsxQuoteStyle: 'single',
161
- arrowParentheses: 'asNeeded',
162
- trailingCommas: 'all'
163
- }
164
- },
165
- overrides: [
166
- {
167
- includes: [
168
- '**/*.jsx',
169
- '**/*.tsx'
170
- ],
171
- linter: {
172
- rules: {
173
- style: {
174
- noParameterAssign: 'error'
175
- }
176
- }
177
- }
178
- },
179
- {
180
- includes: [
181
- '**/*.ts',
182
- '**/*.tsx'
183
- ],
184
- linter: {
185
- rules: {
186
- correctness: {
187
- noUnusedVariables: 'off'
188
- }
189
- }
190
- }
191
- }
192
- ]
193
- };
194
- const reactOverlay = {
195
- files: {
196
- includes: [
197
- '!**/.storybook'
198
- ]
199
- },
200
- javascript: {
201
- jsxRuntime: 'reactClassic'
202
- },
203
- linter: {
204
- rules: {
205
- style: {
206
- useFragmentSyntax: 'error'
207
- }
208
- }
209
- },
210
- overrides: [
211
- {
212
- includes: [
213
- '**/__tests__/**',
214
- '**/*.{test,spec}.{ts,tsx,js,jsx}'
215
- ],
216
- linter: {
217
- rules: {
218
- correctness: {
219
- noUnusedVariables: 'off'
220
- }
221
- }
222
- }
223
- }
224
- ]
225
- };
226
- const reactConfig = mergeConfigs(indexConfig, reactOverlay);
227
- const nextOverlay = {
228
- files: {
229
- includes: [
230
- '!**/.next',
231
- '!**/.vercel',
232
- '!**/out'
233
- ]
234
- },
235
- javascript: {
236
- jsxRuntime: 'transparent'
237
- },
238
- linter: {
239
- rules: {
240
- correctness: {
241
- useExhaustiveDependencies: {
242
- level: 'error',
243
- options: {
244
- reportUnnecessaryDependencies: true
245
- }
246
- }
247
- }
248
- }
249
- }
250
- };
251
- const nextConfig = mergeConfigs(reactConfig, nextOverlay);
252
- const vueOverlay = {
253
- files: {
254
- includes: [
255
- '!**/.vitepress',
256
- '!**/.output'
257
- ]
258
- },
259
- javascript: {
260
- parser: {
261
- jsxEverywhere: false
262
- }
263
- },
264
- html: {
265
- formatter: {
266
- indentScriptAndStyle: true,
267
- selfCloseVoidElements: 'always'
268
- }
269
- },
270
- overrides: [
271
- {
272
- includes: [
273
- '**/*.vue'
274
- ],
275
- formatter: {
276
- lineWidth: 120
277
- },
278
- javascript: {
279
- formatter: {
280
- quoteStyle: 'single'
281
- }
282
- }
283
- }
284
- ]
285
- };
286
- const vueConfig = mergeConfigs(indexConfig, vueOverlay);
287
- const nuxtOverlay = {
288
- files: {
289
- includes: [
290
- '!**/.nuxt',
291
- '!**/.nitro',
292
- '!**/.output'
293
- ]
294
- },
295
- javascript: {
296
- globals: [
297
- 'defineNuxtConfig',
298
- 'defineAppConfig',
299
- 'defineNuxtPlugin',
300
- 'defineNuxtRouteMiddleware',
301
- 'defineNuxtServerPlugin',
302
- 'defineNitroPlugin',
303
- 'defineEventHandler',
304
- 'defineLazyEventHandler',
305
- 'definePayloadPlugin',
306
- 'defineRouteRules',
307
- 'definePageMeta',
308
- 'useRuntimeConfig',
309
- 'useNuxtApp',
310
- 'useAsyncData',
311
- 'useLazyAsyncData',
312
- 'useFetch',
313
- 'useLazyFetch',
314
- 'useState',
315
- 'useCookie',
316
- 'useHead',
317
- 'useSeoMeta',
318
- 'useError',
319
- 'clearError',
320
- 'showError',
321
- 'navigateTo',
322
- 'abortNavigation',
323
- 'refreshNuxtData',
324
- 'onNuxtReady',
325
- 'useRouter',
326
- 'useRoute',
327
- 'useRequestEvent',
328
- 'useRequestHeaders'
329
- ]
330
- },
331
- overrides: [
332
- {
333
- includes: [
334
- '**/*.ts'
335
- ],
336
- linter: {
337
- rules: {
338
- correctness: {
339
- noUndeclaredVariables: 'error'
340
- }
341
- }
342
- }
343
- }
344
- ]
345
- };
346
- const nuxtConfig = mergeConfigs(vueConfig, nuxtOverlay);
347
- const allPresets = Object.freeze({
348
- index: indexConfig,
349
- react: reactConfig,
350
- next: nextConfig,
351
- vue: vueConfig,
352
- nuxt: nuxtConfig
353
- });
354
- const currentDir = dirname(fileURLToPath(import.meta.url));
355
- const outputDir = currentDir;
356
- const serialize = (config)=>`${JSON.stringify(config, null, 2)}\n`;
357
- async function ensureDir(path) {
358
- await mkdir(path, {
359
- recursive: true
360
- });
361
- }
362
- async function buildJsonPresets() {
363
- await ensureDir(outputDir);
364
- const tasks = Object.entries(allPresets).map(async ([name, config])=>{
365
- const filePath = join(outputDir, `${name}.jsonc`);
366
- const data = serialize(config);
367
- await writeFile(filePath, data, 'utf8');
368
- return filePath;
369
- });
370
- const writtenFiles = await Promise.all(tasks);
371
- return writtenFiles;
372
- }
373
- (async ()=>{
374
- try {
375
- const files = await buildJsonPresets();
376
- console.log(`Generated presets: ${files.join(', ')}`);
377
- } catch (error) {
378
- console.error('Failed to generate Biome presets', error);
379
- process.exitCode = 1;
380
- }
381
- })();