@ovt2/biome-react-kit 2.1.0 → 2.3.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/README.md +111 -10
- package/bin/cli.mjs +41 -8
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -34,17 +34,34 @@ found. The pre-commit hook always calls the locally installed
|
|
|
34
34
|
`node_modules/.bin/biome`, so it works the same regardless of which package
|
|
35
35
|
manager installed it.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
## CLI commands
|
|
38
|
+
|
|
39
|
+
Beyond `init`, the kit's own CLI wraps the Biome binary it already installed
|
|
40
|
+
in your project, so you never have to know Biome's own flags. Once it's
|
|
41
|
+
installed, use the short `biome-kit` alias instead of the full package name
|
|
42
|
+
— `bunx` resolves it from `node_modules/.bin` without touching the network:
|
|
38
43
|
|
|
39
44
|
```sh
|
|
40
|
-
|
|
45
|
+
bunx biome-kit check # biome check .
|
|
46
|
+
bunx biome-kit check:fix # biome check --write .
|
|
47
|
+
bunx biome-kit ci # biome ci --reporter=github .
|
|
48
|
+
bunx biome-kit check src/foo.ts # pass specific paths through
|
|
41
49
|
```
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
(The full name `@ovt2/biome-react-kit` still works everywhere `biome-kit`
|
|
52
|
+
does — it's the same binary under two names. You only _need_ the full name
|
|
53
|
+
once, for the very first `init`, since `bunx` has to resolve that from the
|
|
54
|
+
registry before anything is installed locally.)
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
These require Bun to invoke (same as `init`), since the CLI itself is a Bun
|
|
57
|
+
script. The `check`/`check:fix` scripts that `init` writes into your
|
|
58
|
+
`package.json` call `biome` directly instead, so `npm run check` (or
|
|
59
|
+
`pnpm`/`yarn run check`) stays Bun-free for everyday use — the CLI commands
|
|
60
|
+
above are a convenience for anyone who already has Bun and wants one
|
|
61
|
+
consistent command across projects.
|
|
62
|
+
|
|
63
|
+
See the [Command reference](#command-reference) below for every flag and
|
|
64
|
+
manual (non-CLI) setup path.
|
|
48
65
|
|
|
49
66
|
## Presets
|
|
50
67
|
|
|
@@ -72,10 +89,94 @@ Add scripts:
|
|
|
72
89
|
"check:fix": "biome check --write ."
|
|
73
90
|
```
|
|
74
91
|
|
|
75
|
-
##
|
|
92
|
+
## Command reference
|
|
93
|
+
|
|
94
|
+
Every command this kit provides, for every case.
|
|
95
|
+
|
|
96
|
+
### `init` — one-time project setup
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
# Default: base preset, installs husky + CI workflow
|
|
100
|
+
bunx @ovt2/biome-react-kit init
|
|
101
|
+
|
|
102
|
+
# Pick a different preset
|
|
103
|
+
bunx @ovt2/biome-react-kit init --preset strict
|
|
104
|
+
bunx @ovt2/biome-react-kit init --preset next
|
|
105
|
+
|
|
106
|
+
# Skip the pre-commit hook (no husky install, no .husky/pre-commit, no "prepare" script)
|
|
107
|
+
bunx @ovt2/biome-react-kit init --no-hooks
|
|
108
|
+
|
|
109
|
+
# Skip the GitHub Actions workflow (no .github/workflows/biome.yml)
|
|
110
|
+
bunx @ovt2/biome-react-kit init --no-ci
|
|
111
|
+
|
|
112
|
+
# Don't install anything — just print the install command and write the
|
|
113
|
+
# files that don't depend on packages being present yet
|
|
114
|
+
bunx @ovt2/biome-react-kit init --skip-install
|
|
115
|
+
|
|
116
|
+
# Combine flags freely
|
|
117
|
+
bunx @ovt2/biome-react-kit init --preset next --no-ci
|
|
118
|
+
bunx @ovt2/biome-react-kit init --preset strict --no-hooks --no-ci --skip-install
|
|
119
|
+
|
|
120
|
+
# Show usage
|
|
121
|
+
bunx @ovt2/biome-react-kit -h
|
|
122
|
+
bunx @ovt2/biome-react-kit --help
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`init` is always safe to re-run: it never overwrites an existing
|
|
126
|
+
`biome.json`/`biome.jsonc`, script, `.husky/pre-commit`, or
|
|
127
|
+
`.github/workflows/biome.yml` — it just prints `!` warnings for whatever
|
|
128
|
+
already exists.
|
|
129
|
+
|
|
130
|
+
### `check` / `check:fix` / `ci` — run Biome without calling it directly
|
|
131
|
+
|
|
132
|
+
`biome-kit` is the short alias for `@ovt2/biome-react-kit`, installed
|
|
133
|
+
alongside the full name — use whichever you prefer:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
# Lint/format-check the whole project
|
|
137
|
+
bunx biome-kit check
|
|
138
|
+
|
|
139
|
+
# Auto-fix what's fixable
|
|
140
|
+
bunx biome-kit check:fix
|
|
141
|
+
|
|
142
|
+
# CI-formatted output (GitHub Actions annotations), used by the generated workflow
|
|
143
|
+
bunx biome-kit ci
|
|
144
|
+
|
|
145
|
+
# Any of the three accept specific paths instead of defaulting to "."
|
|
146
|
+
bunx biome-kit check src/
|
|
147
|
+
bunx biome-kit check:fix src/components/Button.tsx
|
|
148
|
+
bunx biome-kit ci src/ tests/
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
These fail with a clear message instead of a stack trace if Biome isn't
|
|
152
|
+
installed yet in the current project (run `init` first).
|
|
153
|
+
|
|
154
|
+
### Scripts `init` writes into your `package.json`
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
npm run check # or: pnpm check / yarn check / bun run check
|
|
158
|
+
npm run check:fix # or: pnpm check:fix / yarn check:fix / bun run check:fix
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
These call the locally installed `biome` binary directly — no Bun required,
|
|
162
|
+
regardless of which package manager your project uses.
|
|
163
|
+
|
|
164
|
+
### Manual setup (without the CLI)
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
# Install Biome + the kit yourself
|
|
168
|
+
bun add -d -E @biomejs/biome @ovt2/biome-react-kit
|
|
169
|
+
npm install --save-dev --save-exact @biomejs/biome @ovt2/biome-react-kit
|
|
170
|
+
pnpm add --save-dev --save-exact @biomejs/biome @ovt2/biome-react-kit
|
|
171
|
+
yarn add --dev --exact @biomejs/biome @ovt2/biome-react-kit
|
|
172
|
+
|
|
173
|
+
# Then create biome.json by hand, extending whichever preset you want:
|
|
174
|
+
# { "extends": ["@ovt2/biome-react-kit/biome"] } — base
|
|
175
|
+
# { "extends": ["@ovt2/biome-react-kit/biome/strict"] } — strict
|
|
176
|
+
# { "extends": ["@ovt2/biome-react-kit/biome/next"] } — next
|
|
177
|
+
```
|
|
76
178
|
|
|
77
|
-
|
|
78
|
-
issues never reach the repo:
|
|
179
|
+
### Manual pre-commit hook (without `init`)
|
|
79
180
|
|
|
80
181
|
```sh
|
|
81
182
|
bun add -d husky
|
|
@@ -92,7 +193,7 @@ git update-index --again
|
|
|
92
193
|
Commits with unfixable errors (e.g. an unsafe-fix-only rule set to error)
|
|
93
194
|
will be blocked until you resolve them.
|
|
94
195
|
|
|
95
|
-
|
|
196
|
+
### Migrating an existing config
|
|
96
197
|
|
|
97
198
|
```sh
|
|
98
199
|
bunx biome migrate eslint --write
|
package/bin/cli.mjs
CHANGED
|
@@ -64,19 +64,36 @@ const PACKAGE_MANAGERS = {
|
|
|
64
64
|
},
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
const
|
|
67
|
+
const BIOME_SUBCOMMANDS = {
|
|
68
|
+
check: (paths) => ["check", ...paths],
|
|
69
|
+
"check:fix": (paths) => ["check", "--write", ...paths],
|
|
70
|
+
ci: (paths) => ["ci", "--reporter=github", ...paths],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const HELP = `Usage: bunx ${KIT_NAME} <command> [options]
|
|
68
74
|
|
|
69
|
-
|
|
75
|
+
Commands:
|
|
76
|
+
init [options] Set up Biome, scripts, hooks, and CI in the current project
|
|
77
|
+
check [paths] Run biome check (defaults to .)
|
|
78
|
+
check:fix [paths] Run biome check --write (defaults to .)
|
|
79
|
+
ci [paths] Run biome ci --reporter=github (defaults to .)
|
|
80
|
+
|
|
81
|
+
init options:
|
|
70
82
|
--preset <base|strict|next> Which preset to extend (default: base)
|
|
71
83
|
--no-hooks Skip husky + pre-commit hook setup
|
|
72
84
|
--no-ci Skip the GitHub Actions workflow
|
|
73
85
|
--skip-install Print install commands instead of running them
|
|
74
86
|
-h, --help Show this help
|
|
75
87
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
check / check:fix / ci run the Biome binary already installed in this
|
|
89
|
+
project's node_modules — you never need to call biome yourself. The
|
|
90
|
+
package manager (bun, npm, pnpm, or yarn) used by \`init\` is detected
|
|
91
|
+
from the "packageManager" field in package.json or from whichever
|
|
92
|
+
lockfile is present. Bun is used as the fallback when neither is found.
|
|
93
|
+
|
|
94
|
+
Once installed (after \`init\`), use the shorter alias for every command
|
|
95
|
+
except the first install: \`bunx biome-kit check\`, \`bunx biome-kit
|
|
96
|
+
check:fix\`, \`bunx biome-kit ci\`.
|
|
80
97
|
`;
|
|
81
98
|
|
|
82
99
|
function fail(message) {
|
|
@@ -124,8 +141,25 @@ if (values.help) {
|
|
|
124
141
|
}
|
|
125
142
|
|
|
126
143
|
const command = positionals[0] ?? "init";
|
|
144
|
+
const cwd = process.cwd();
|
|
145
|
+
|
|
146
|
+
if (command in BIOME_SUBCOMMANDS) {
|
|
147
|
+
const biome = binPath(cwd, "biome");
|
|
148
|
+
if (!existsSync(biome)) {
|
|
149
|
+
fail(`Biome isn't installed in this project. Run: bunx ${KIT_NAME} init`);
|
|
150
|
+
}
|
|
151
|
+
const extraPaths = positionals.slice(1);
|
|
152
|
+
const biomeArgs = BIOME_SUBCOMMANDS[command](extraPaths.length ? extraPaths : ["."]);
|
|
153
|
+
try {
|
|
154
|
+
await $`${biome} ${biomeArgs}`.cwd(cwd);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
process.exit(error.exitCode ?? 1);
|
|
157
|
+
}
|
|
158
|
+
process.exit(0);
|
|
159
|
+
}
|
|
160
|
+
|
|
127
161
|
if (command !== "init") {
|
|
128
|
-
fail(`Unknown command "${command}". Usage: bunx ${KIT_NAME} init [options]`);
|
|
162
|
+
fail(`Unknown command "${command}". Usage: bunx ${KIT_NAME} <init|check|check:fix|ci> [options]`);
|
|
129
163
|
}
|
|
130
164
|
|
|
131
165
|
if (!(values.preset in PRESET_PATHS)) {
|
|
@@ -134,7 +168,6 @@ if (!(values.preset in PRESET_PATHS)) {
|
|
|
134
168
|
);
|
|
135
169
|
}
|
|
136
170
|
|
|
137
|
-
const cwd = process.cwd();
|
|
138
171
|
const pkgPath = join(cwd, "package.json");
|
|
139
172
|
if (!existsSync(pkgPath)) {
|
|
140
173
|
fail("No package.json found in the current directory.");
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ovt2/biome-react-kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Shared Biome lint/format/check preset for React apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"biome-react-kit": "
|
|
8
|
+
"biome-react-kit": "bin/cli.mjs",
|
|
9
|
+
"biome-kit": "bin/cli.mjs"
|
|
9
10
|
},
|
|
10
11
|
"exports": {
|
|
11
12
|
"./biome": "./presets/base.json",
|