@browsercore/dev 0.1.2
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/CODING_STANDARDS.md +205 -0
- package/README.md +76 -0
- package/bin/coverage-md.mjs +99 -0
- package/dist/coverage-md.d.ts +37 -0
- package/dist/coverage-md.d.ts.map +1 -0
- package/dist/coverage-md.js +48 -0
- package/dist/coverage-md.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/oxlint.d.ts +20 -0
- package/dist/oxlint.d.ts.map +1 -0
- package/dist/oxlint.js +75 -0
- package/dist/oxlint.js.map +1 -0
- package/dist/vitest.d.ts +28 -0
- package/dist/vitest.d.ts.map +1 -0
- package/dist/vitest.js +48 -0
- package/dist/vitest.js.map +1 -0
- package/package.json +70 -0
- package/tsconfig.base.json +27 -0
- package/tsconfig.build.base.json +10 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# TypeScript Coding Standards
|
|
2
|
+
|
|
3
|
+
These rules are the standard for this codebase and **every** sub-package. Every PR,
|
|
4
|
+
every AI-generated snippet, and every hand-written file follows them. They exist so
|
|
5
|
+
the intended behavior lives in the types — never in tribal knowledge or hidden assumptions.
|
|
6
|
+
|
|
7
|
+
> Design for AI modification: before committing, ask *"Could another developer or an
|
|
8
|
+
> LLM understand the intended behavior without asking me?"* If not — add types, split
|
|
9
|
+
> functions, clarify states, rename.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Strict compiler — never relax it
|
|
14
|
+
|
|
15
|
+
Every `tsconfig.json` inherits `tsconfig.base.json`, which carries:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"strict": true,
|
|
20
|
+
"noUncheckedIndexedAccess": true,
|
|
21
|
+
"exactOptionalPropertyTypes": true
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- `noUncheckedIndexedAccess` → `arr[i]` is `T | undefined`.
|
|
26
|
+
- `exactOptionalPropertyTypes` → `?` means absent-or-present, not present-and-undefined.
|
|
27
|
+
|
|
28
|
+
Ambiguity creates bugs and forces LLMs to guess. **Never** override these to `false`
|
|
29
|
+
in a sub-package to dodge an error. Fix the error instead.
|
|
30
|
+
|
|
31
|
+
## 2. Every important data structure has a type
|
|
32
|
+
|
|
33
|
+
If data crosses a module boundary, it has an explicit type. No anonymous object
|
|
34
|
+
literals escaping a function.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// Bad
|
|
38
|
+
const frame = { type: 0x1, streamId: 3, data: buf };
|
|
39
|
+
|
|
40
|
+
// Good
|
|
41
|
+
interface HeadersFrame {
|
|
42
|
+
readonly type: FrameType.HEADERS;
|
|
43
|
+
readonly streamId: StreamId;
|
|
44
|
+
readonly data: Uint8Array;
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 3. Never `any`
|
|
49
|
+
|
|
50
|
+
Unknown external data is `unknown`, then validated. `any` is a build failure.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
function parseFrame(raw: Uint8Array): Frame {
|
|
54
|
+
const unknown = decodeUnknown(raw); // unknown
|
|
55
|
+
return FrameSchema.parse(unknown); // validated → typed
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 4. Interfaces for domain objects, type aliases for states/constraints
|
|
60
|
+
|
|
61
|
+
- Interfaces for real entities (`TlsConnection`, `Http2Stream`, `Cookie`).
|
|
62
|
+
- Type aliases for states/constraints (`RunStatus`, `CipherSuite`).
|
|
63
|
+
- If values come from a known set, encode the set — never bare `string`.
|
|
64
|
+
|
|
65
|
+
## 5. Model states explicitly — make invalid states unrepresentable
|
|
66
|
+
|
|
67
|
+
No "state via nullable-field combos." Use discriminated unions.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// Bad — allows { state: "open", error: "failed" }
|
|
71
|
+
interface Connection {
|
|
72
|
+
state: string;
|
|
73
|
+
stream?: Stream;
|
|
74
|
+
error?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Good
|
|
78
|
+
type ConnectionState =
|
|
79
|
+
| { readonly state: "connecting" }
|
|
80
|
+
| { readonly state: "open"; readonly stream: Stream }
|
|
81
|
+
| { readonly state: "closed"; readonly reason: CloseReason };
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 6. Discriminated unions for every workflow/state
|
|
85
|
+
|
|
86
|
+
The compiler + LLM reason about every case.
|
|
87
|
+
|
|
88
|
+
## 7. Functions declare input AND output types
|
|
89
|
+
|
|
90
|
+
Public functions always define both sides — no inference-only signatures on exported APIs.
|
|
91
|
+
|
|
92
|
+
## 8. One function = one decision
|
|
93
|
+
|
|
94
|
+
No `processHandshake()` that validates + persists + schedules + notifies. Split:
|
|
95
|
+
`validate…`, `decodeStep`, `actuate`, `recordStep`.
|
|
96
|
+
|
|
97
|
+
## 9. No hidden behavior
|
|
98
|
+
|
|
99
|
+
A function named `updateSettings` does not also flush a log. Every side effect is its
|
|
100
|
+
own named call.
|
|
101
|
+
|
|
102
|
+
## 10. Name things explicitly
|
|
103
|
+
|
|
104
|
+
`cipherSuite`, `observedRank`, `clientHello` — never `data`, `result`, `obj`.
|
|
105
|
+
The name is the documentation.
|
|
106
|
+
|
|
107
|
+
## 11. Prefer immutable data + `readonly`
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const next = { ...prev, cipherSuite } as const;
|
|
111
|
+
interface Connection { readonly id: ConnectionId; }
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
No in-place mutation of shared state. `const` over `let`.
|
|
115
|
+
|
|
116
|
+
## 12. Validate external data immediately
|
|
117
|
+
|
|
118
|
+
Everything from outside the boundary is `unknown`: sockets, files, captures, configs.
|
|
119
|
+
Use **Zod** at every boundary:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
const frame = FrameSchema.parse(raw); // never `raw as Frame`
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 13. Types are contracts, not documentation
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// Bad // user id
|
|
129
|
+
// id: string;
|
|
130
|
+
// Good
|
|
131
|
+
type UserId = string & { __brand: "UserId" };
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 14. Branded/opaque ID types — load-bearing
|
|
135
|
+
|
|
136
|
+
Don't use bare `number`/`string` for IDs. This kills the "pass an X where a Y belongs"
|
|
137
|
+
class of bug. The project uses these brands (defined per-package, see `types.ts`):
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
type ConnectionId = string & { __brand: "ConnectionId" };
|
|
141
|
+
type StreamId = number & { __brand: "StreamId" };
|
|
142
|
+
type SessionId = string & { __brand: "SessionId" };
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 15. Exhaustive switches
|
|
146
|
+
|
|
147
|
+
Every `switch` over a union hits `default: assertNever(x)`. Adding a state forces every
|
|
148
|
+
handler to compile-error until handled.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
function assertNever(x: never): never {
|
|
152
|
+
throw new Error(`Unexpected value: ${JSON.stringify(x)}`);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## 16. Explicit, typed errors
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
// Bad
|
|
160
|
+
throw new Error("handshake failed");
|
|
161
|
+
// Good
|
|
162
|
+
throw new TlsHandshakeError("server_hello_parse", cause);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Errors are part of the API. Define them in each package's `errors.ts`.
|
|
166
|
+
|
|
167
|
+
## 17. No magic strings
|
|
168
|
+
|
|
169
|
+
`if (event === Event.COLD_START)` or a string-literal union — never bare `"cold_start"`.
|
|
170
|
+
|
|
171
|
+
## 18. Clear dependency boundaries
|
|
172
|
+
|
|
173
|
+
Domain (pure protocol logic) knows nothing of AWS / HTTP / DDB / sockets. Infrastructure
|
|
174
|
+
adapts. The protocol state machines stay I/O-free so they're unit-testable.
|
|
175
|
+
|
|
176
|
+
**Within this repo**, the dependency graph flows upward only — never sideways or downward:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
@browsercore/fetch
|
|
180
|
+
└─ @browsercore/http2 @browsercore/http1 @browsercore/cookies @browsercore/profiles
|
|
181
|
+
└─ @browsercore/tls
|
|
182
|
+
└─ @browsercore/crypto @browsercore/transport
|
|
183
|
+
└─ node:net / node:crypto
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
A package may only import from packages *below* it in this graph.
|
|
187
|
+
|
|
188
|
+
## 19. Documentation: why, not what
|
|
189
|
+
|
|
190
|
+
Comments explain *why* ("crawl past our position so the competitor snapshot covers the
|
|
191
|
+
neighborhood"), never *what* the code obviously does. Priority: Types > Names > Structure >
|
|
192
|
+
Comments.
|
|
193
|
+
|
|
194
|
+
## 20. API contracts in one place
|
|
195
|
+
|
|
196
|
+
Domain types live in each package's `types.ts`; wire schemas in `schemas.ts`. One source
|
|
197
|
+
of truth, never duplicated shapes.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## The Golden Rule
|
|
202
|
+
|
|
203
|
+
Every piece of important information exists as one of: **a type, a function signature,
|
|
204
|
+
an explicit state model, a schema validation, or clear naming.** Never rely on tribal
|
|
205
|
+
knowledge or hidden assumptions.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @browsercore/dev
|
|
2
|
+
|
|
3
|
+
Shared build, lint, test, and governance config for the `@browsercore/*` package
|
|
4
|
+
family (14 sibling git repos cloned side-by-side). One published package is the
|
|
5
|
+
single source of truth; consumers eat the extendable parts live via npm, and the
|
|
6
|
+
non-extendable GitHub files arrive via a sync script.
|
|
7
|
+
|
|
8
|
+
## What's distributed, and how
|
|
9
|
+
|
|
10
|
+
| Artifact | Mechanism |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `tsconfig` strict flags | `tsconfig.json` `"extends": "@browsercore/dev/tsconfig.base.json"` |
|
|
13
|
+
| `vitest` config | factory import: `definePackageConfig({ name })` from `@browsercore/dev/vitest` |
|
|
14
|
+
| `.oxlintrc.json` → `oxlint.config.ts` | import the base object from `@browsercore/dev/oxlint` |
|
|
15
|
+
| `coverage-md` (coverage report generator) | npm `bin` |
|
|
16
|
+
| `CODING_STANDARDS.md`, `.github/{ci.yml,ruleset.json,bootstrap-ruleset.sh}` | `scripts/sync.mjs` (GitHub reads only each repo's own `.github/`) |
|
|
17
|
+
|
|
18
|
+
Why a TS import for oxlint rather than `.oxlintrc.json` `extends`: oxlint's JSON
|
|
19
|
+
`extends` resolves only relative file paths, not `node_modules`
|
|
20
|
+
(see oxc-project/oxc#15538). The `oxlint.config.ts` form imports the config object
|
|
21
|
+
directly, which resolves through `node_modules`.
|
|
22
|
+
|
|
23
|
+
## Consumer adoption (per repo)
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
# 1. depend on it (use the npm version once published; locally: file:../dev)
|
|
27
|
+
npm install -D @browsercore/dev
|
|
28
|
+
|
|
29
|
+
# 2. tsconfig.json — replace with:
|
|
30
|
+
# { "extends": "@browsercore/dev/tsconfig.base.json",
|
|
31
|
+
# "compilerOptions": { "rootDir": "src", "outDir": "dist" },
|
|
32
|
+
# "include": ["src/**/*.ts"], "exclude": ["node_modules","dist","tests","scripts"] }
|
|
33
|
+
|
|
34
|
+
# 3. vitest.config.ts — replace with:
|
|
35
|
+
# import { definePackageConfig } from "@browsercore/dev/vitest";
|
|
36
|
+
# export default definePackageConfig({ name: "<pkg>" });
|
|
37
|
+
|
|
38
|
+
# 4. oxlint — delete .oxlintrc.json, create oxlint.config.ts:
|
|
39
|
+
# import { defineConfig } from "oxlint";
|
|
40
|
+
# import base from "@browsercore/dev/oxlint";
|
|
41
|
+
# export default defineConfig({ extends: [base] });
|
|
42
|
+
|
|
43
|
+
# 5. drop scripts/coverage-md.mjs; CI uses the `coverage-md` bin.
|
|
44
|
+
|
|
45
|
+
# 6. refresh governance files (run from THIS repo):
|
|
46
|
+
node scripts/sync.mjs <pkg> # copy templates in
|
|
47
|
+
node scripts/sync.mjs --check <pkg> # drift gate (exit 1 on mismatch)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Type-aware oxlint (`--type-aware`) requires the `oxlint-tsgolint` package in the
|
|
51
|
+
consumer's devDependencies.
|
|
52
|
+
|
|
53
|
+
## Repo layout
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
src/vitest.ts definePackageConfig() factory
|
|
57
|
+
src/oxlint.ts base OxlintConfig object (default export)
|
|
58
|
+
src/index.ts re-exports
|
|
59
|
+
bin/coverage-md.mjs coverage-md bin
|
|
60
|
+
scripts/sync.mjs distribute + drift-check governance files
|
|
61
|
+
tsconfig.base.json universal compilerOptions (consumers extend this)
|
|
62
|
+
tsconfig.build.base.json emit flags layered on the base
|
|
63
|
+
templates/.github/* ci.yml, ruleset.json, bootstrap-ruleset.sh (synced, not published)
|
|
64
|
+
CODING_STANDARDS.md synced to every consumer
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Develop
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
npm install
|
|
71
|
+
npm run typecheck
|
|
72
|
+
npm run build
|
|
73
|
+
npm run lint -- --deny-warnings
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Node >= 26. ESM only.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Convert vitest's coverage-summary.json into a markdown coverage table.
|
|
4
|
+
*
|
|
5
|
+
* Run AFTER `vitest run --coverage` (with the json-summary reporter) so
|
|
6
|
+
* coverage-summary.json exists. Writes COVERAGE.md and coverage/badge.json to
|
|
7
|
+
* the current working directory (the consumer package root).
|
|
8
|
+
*
|
|
9
|
+
* Distributed as the `coverage-md` bin of @browsercore/dev, replacing the
|
|
10
|
+
* per-repo scripts/coverage-md.mjs copies.
|
|
11
|
+
*
|
|
12
|
+
* Dependency-free: only node:fs + node:path. Safe in CI with no install step.
|
|
13
|
+
*/
|
|
14
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { join, relative } from "node:path";
|
|
16
|
+
|
|
17
|
+
const pkgRoot = process.cwd();
|
|
18
|
+
const summaryPath = join(pkgRoot, "coverage", "coverage-summary.json");
|
|
19
|
+
const outPath = join(pkgRoot, "COVERAGE.md");
|
|
20
|
+
const badgePath = join(pkgRoot, "coverage", "badge.json");
|
|
21
|
+
|
|
22
|
+
/** @type {Record<string, { lines:{total:number,covered:number,pct:number}, statements:{total:number,covered:number,pct:number}, functions:{total:number,covered:number,pct:number}, branches:{total:number,covered:number,pct:number} }>} */
|
|
23
|
+
let data;
|
|
24
|
+
try {
|
|
25
|
+
data = JSON.parse(readFileSync(summaryPath, "utf-8"));
|
|
26
|
+
} catch {
|
|
27
|
+
console.error(
|
|
28
|
+
`[coverage-md] Could not read ${summaryPath}. ` +
|
|
29
|
+
`Run vitest with the json-summary reporter first.`,
|
|
30
|
+
);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const total = data.total;
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {Object} Metric
|
|
37
|
+
* @property {string} label
|
|
38
|
+
* @property {keyof typeof total} key
|
|
39
|
+
*/
|
|
40
|
+
/** @type {Metric[]} */
|
|
41
|
+
const metrics = [
|
|
42
|
+
{ label: "Statements", key: "statements" },
|
|
43
|
+
{ label: "Branches", key: "branches" },
|
|
44
|
+
{ label: "Functions", key: "functions" },
|
|
45
|
+
{ label: "Lines", key: "lines" },
|
|
46
|
+
];
|
|
47
|
+
/** @param {{pct:number,covered:number,total:number}} m */
|
|
48
|
+
const render = (m) => `${m.pct}% (${m.covered}/${m.total})`;
|
|
49
|
+
|
|
50
|
+
const fileEntries = Object.entries(data)
|
|
51
|
+
.filter(([key]) => key !== "total")
|
|
52
|
+
.map(([file, m]) => {
|
|
53
|
+
// coverage-summary.json keys are absolute paths; show repo-relative.
|
|
54
|
+
const rel = relative(pkgRoot, file).split("\\").join("/");
|
|
55
|
+
return { file: rel, m };
|
|
56
|
+
})
|
|
57
|
+
.sort((a, b) => a.file.localeCompare(b.file));
|
|
58
|
+
|
|
59
|
+
const lines = [];
|
|
60
|
+
lines.push(`# Coverage report`);
|
|
61
|
+
lines.push("");
|
|
62
|
+
lines.push(`Generated from \`coverage-summary.json\` by \`coverage-md\` (@browsercore/dev).`);
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push(`## Total`);
|
|
65
|
+
lines.push("");
|
|
66
|
+
lines.push(`| Metric | Coverage |`);
|
|
67
|
+
lines.push(`| --- | --- |`);
|
|
68
|
+
for (const { label, key } of metrics) {
|
|
69
|
+
lines.push(`| ${label} | ${render(total[key])} |`);
|
|
70
|
+
}
|
|
71
|
+
lines.push("");
|
|
72
|
+
lines.push(`## Per-file`);
|
|
73
|
+
lines.push("");
|
|
74
|
+
const header = `| File | ${metrics.map((m) => m.label).join(" | ")} |`;
|
|
75
|
+
const sep = `| --- | ${metrics.map(() => "---").join(" | ")} |`;
|
|
76
|
+
lines.push(header);
|
|
77
|
+
lines.push(sep);
|
|
78
|
+
for (const { file, m } of fileEntries) {
|
|
79
|
+
lines.push(`| \`${file}\` | ${metrics.map((met) => render(m[met.key])).join(" | ")} |`);
|
|
80
|
+
}
|
|
81
|
+
lines.push("");
|
|
82
|
+
|
|
83
|
+
writeFileSync(outPath, lines.join("\n"));
|
|
84
|
+
console.log(`[coverage-md] wrote ${relative(process.cwd(), outPath)}`);
|
|
85
|
+
|
|
86
|
+
// shields.io endpoint badge: a single coverage figure (statements %) for the
|
|
87
|
+
// README badge. Color tiers mirror shields.io conventions.
|
|
88
|
+
const pct = total.statements.pct;
|
|
89
|
+
const badgeColor =
|
|
90
|
+
pct >= 90 ? "brightgreen" : pct >= 75 ? "green" : pct >= 50 ? "yellow" : "red";
|
|
91
|
+
const badge = {
|
|
92
|
+
schemaVersion: 1,
|
|
93
|
+
label: "coverage",
|
|
94
|
+
message: `${pct}%`,
|
|
95
|
+
color: badgeColor,
|
|
96
|
+
namedLogo: "vitest",
|
|
97
|
+
};
|
|
98
|
+
writeFileSync(badgePath, JSON.stringify(badge));
|
|
99
|
+
console.log(`[coverage-md] wrote ${relative(process.cwd(), badgePath)}`);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure rendering logic for the coverage-md bin, extracted from bin/coverage-md.mjs
|
|
3
|
+
* so it can be unit-tested without touching the filesystem. The bin imports these
|
|
4
|
+
* helpers and handles I/O; everything here is deterministic given a coverage summary.
|
|
5
|
+
*/
|
|
6
|
+
export interface MetricTotals {
|
|
7
|
+
total: number;
|
|
8
|
+
covered: number;
|
|
9
|
+
pct: number;
|
|
10
|
+
}
|
|
11
|
+
export interface CoverageSummary {
|
|
12
|
+
total: {
|
|
13
|
+
statements: MetricTotals;
|
|
14
|
+
branches: MetricTotals;
|
|
15
|
+
functions: MetricTotals;
|
|
16
|
+
lines: MetricTotals;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface Metric {
|
|
20
|
+
label: string;
|
|
21
|
+
key: keyof CoverageSummary["total"];
|
|
22
|
+
}
|
|
23
|
+
export declare const METRICS: Metric[];
|
|
24
|
+
export declare const renderMetric: (m: MetricTotals) => string;
|
|
25
|
+
export declare const badgeColor: (pct: number) => string;
|
|
26
|
+
export declare const renderCoverageMarkdown: (data: CoverageSummary, fileEntries: Array<{
|
|
27
|
+
file: string;
|
|
28
|
+
m: CoverageSummary["total"];
|
|
29
|
+
}>) => string;
|
|
30
|
+
export declare const renderBadge: (statementsPct: number) => {
|
|
31
|
+
schemaVersion: number;
|
|
32
|
+
label: string;
|
|
33
|
+
message: string;
|
|
34
|
+
color: string;
|
|
35
|
+
namedLogo: string;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=coverage-md.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-md.d.ts","sourceRoot":"","sources":["../src/coverage-md.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE;QACH,UAAU,EAAE,YAAY,CAAC;QACzB,QAAQ,EAAE,YAAY,CAAC;QACvB,SAAS,EAAE,YAAY,CAAC;QACxB,KAAK,EAAE,YAAY,CAAC;KACvB,CAAC;CACL;AAED,MAAM,WAAW,MAAM;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,OAAO,EAAE,MAAM,EAK3B,CAAC;AAEF,eAAO,MAAM,YAAY,MAAO,YAAY,KAAG,MAA+C,CAAC;AAE/F,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MACyC,CAAC;AAEnF,eAAO,MAAM,sBAAsB,SAAU,eAAe,eAAe,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC,KAAG,MA2BjI,CAAC;AAEF,eAAO,MAAM,WAAW,kBAAmB,MAAM,KAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAM3I,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure rendering logic for the coverage-md bin, extracted from bin/coverage-md.mjs
|
|
3
|
+
* so it can be unit-tested without touching the filesystem. The bin imports these
|
|
4
|
+
* helpers and handles I/O; everything here is deterministic given a coverage summary.
|
|
5
|
+
*/
|
|
6
|
+
export const METRICS = [
|
|
7
|
+
{ label: "Statements", key: "statements" },
|
|
8
|
+
{ label: "Branches", key: "branches" },
|
|
9
|
+
{ label: "Functions", key: "functions" },
|
|
10
|
+
{ label: "Lines", key: "lines" },
|
|
11
|
+
];
|
|
12
|
+
export const renderMetric = (m) => `${m.pct}% (${m.covered}/${m.total})`;
|
|
13
|
+
export const badgeColor = (pct) => pct >= 90 ? "brightgreen" : pct >= 75 ? "green" : pct >= 50 ? "yellow" : "red";
|
|
14
|
+
export const renderCoverageMarkdown = (data, fileEntries) => {
|
|
15
|
+
const total = data.total;
|
|
16
|
+
const lines = [];
|
|
17
|
+
lines.push("# Coverage report");
|
|
18
|
+
lines.push("");
|
|
19
|
+
lines.push("Generated from `coverage-summary.json` by `coverage-md` (@browsercore/dev).");
|
|
20
|
+
lines.push("");
|
|
21
|
+
lines.push("## Total");
|
|
22
|
+
lines.push("");
|
|
23
|
+
lines.push("| Metric | Coverage |");
|
|
24
|
+
lines.push("| --- | --- |");
|
|
25
|
+
for (const { label, key } of METRICS) {
|
|
26
|
+
lines.push(`| ${label} | ${renderMetric(total[key])} |`);
|
|
27
|
+
}
|
|
28
|
+
lines.push("");
|
|
29
|
+
lines.push("## Per-file");
|
|
30
|
+
lines.push("");
|
|
31
|
+
const header = `| File | ${METRICS.map((m) => m.label).join(" | ")} |`;
|
|
32
|
+
const sep = `| --- | ${METRICS.map(() => "---").join(" | ")} |`;
|
|
33
|
+
lines.push(header);
|
|
34
|
+
lines.push(sep);
|
|
35
|
+
for (const { file, m } of fileEntries) {
|
|
36
|
+
lines.push(`| \`${file}\` | ${METRICS.map((met) => renderMetric(m[met.key])).join(" | ")} |`);
|
|
37
|
+
}
|
|
38
|
+
lines.push("");
|
|
39
|
+
return lines.join("\n");
|
|
40
|
+
};
|
|
41
|
+
export const renderBadge = (statementsPct) => ({
|
|
42
|
+
schemaVersion: 1,
|
|
43
|
+
label: "coverage",
|
|
44
|
+
message: `${statementsPct}%`,
|
|
45
|
+
color: badgeColor(statementsPct),
|
|
46
|
+
namedLogo: "vitest",
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=coverage-md.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage-md.js","sourceRoot":"","sources":["../src/coverage-md.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entrypoint for @browsercore/dev.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the convenience helpers; consumers normally import the subpath
|
|
5
|
+
* directly (`@browsercore/dev/vitest`, `@browsercore/dev/oxlint`), but the root
|
|
6
|
+
* export is here for `import { definePackageConfig, oxlintBase } from "@browsercore/dev"`.
|
|
7
|
+
*/
|
|
8
|
+
export { definePackageConfig } from "./vitest.js";
|
|
9
|
+
export { default as oxlintBase } from "./oxlint.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entrypoint for @browsercore/dev.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the convenience helpers; consumers normally import the subpath
|
|
5
|
+
* directly (`@browsercore/dev/vitest`, `@browsercore/dev/oxlint`), but the root
|
|
6
|
+
* export is here for `import { definePackageConfig, oxlintBase } from "@browsercore/dev"`.
|
|
7
|
+
*/
|
|
8
|
+
export { definePackageConfig } from "./vitest.js";
|
|
9
|
+
export { default as oxlintBase } from "./oxlint.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/oxlint.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OxlintConfig } from "oxlint";
|
|
2
|
+
/**
|
|
3
|
+
* Base oxlint config shared by every @browsercore/* package.
|
|
4
|
+
*
|
|
5
|
+
* Consumers extend it in an `oxlint.config.ts` (which replaces `.oxlintrc.json`):
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { defineConfig } from "oxlint";
|
|
9
|
+
* import base from "@browsercore/dev/oxlint";
|
|
10
|
+
* export default defineConfig({ extends: [base] });
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Why a TS import rather than `.oxlintrc.json` `extends`: oxlint's JSON
|
|
14
|
+
* `extends` resolves only relative file paths, not `node_modules` (see
|
|
15
|
+
* oxc-project/oxc#15538). The `oxlint.config.ts` form imports the config object
|
|
16
|
+
* directly, which does resolve through `node_modules`.
|
|
17
|
+
*/
|
|
18
|
+
declare const base: OxlintConfig;
|
|
19
|
+
export default base;
|
|
20
|
+
//# sourceMappingURL=oxlint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oxlint.d.ts","sourceRoot":"","sources":["../src/oxlint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,IAAI,EAAE,YAwDX,CAAC;eAEa,IAAI"}
|
package/dist/oxlint.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base oxlint config shared by every @browsercore/* package.
|
|
3
|
+
*
|
|
4
|
+
* Consumers extend it in an `oxlint.config.ts` (which replaces `.oxlintrc.json`):
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { defineConfig } from "oxlint";
|
|
8
|
+
* import base from "@browsercore/dev/oxlint";
|
|
9
|
+
* export default defineConfig({ extends: [base] });
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Why a TS import rather than `.oxlintrc.json` `extends`: oxlint's JSON
|
|
13
|
+
* `extends` resolves only relative file paths, not `node_modules` (see
|
|
14
|
+
* oxc-project/oxc#15538). The `oxlint.config.ts` form imports the config object
|
|
15
|
+
* directly, which does resolve through `node_modules`.
|
|
16
|
+
*/
|
|
17
|
+
const base = {
|
|
18
|
+
plugins: ["typescript", "unicorn", "import", "promise", "node"],
|
|
19
|
+
env: {
|
|
20
|
+
node: true,
|
|
21
|
+
},
|
|
22
|
+
categories: {
|
|
23
|
+
correctness: "error",
|
|
24
|
+
suspicious: "error",
|
|
25
|
+
pedantic: "error",
|
|
26
|
+
perf: "warn",
|
|
27
|
+
style: "off",
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
"no-console": "warn",
|
|
31
|
+
"no-debugger": "error",
|
|
32
|
+
eqeqeq: "error",
|
|
33
|
+
"no-var": "error",
|
|
34
|
+
"prefer-const": "error",
|
|
35
|
+
"object-shorthand": "error",
|
|
36
|
+
curly: "error",
|
|
37
|
+
"no-duplicate-imports": "error",
|
|
38
|
+
"no-useless-constructor": "error",
|
|
39
|
+
"no-unreachable": "error",
|
|
40
|
+
"no-constant-condition": "error",
|
|
41
|
+
"no-self-compare": "error",
|
|
42
|
+
"no-template-curly-in-string": "error",
|
|
43
|
+
"no-unneeded-ternary": "error",
|
|
44
|
+
"typescript/no-explicit-any": "error",
|
|
45
|
+
"typescript/no-non-null-assertion": "error",
|
|
46
|
+
"typescript/no-namespace": "error",
|
|
47
|
+
"typescript/consistent-type-imports": "error",
|
|
48
|
+
"typescript/ban-ts-comment": "error",
|
|
49
|
+
"unicorn/prefer-node-protocol": "error",
|
|
50
|
+
"unicorn/prefer-array-find": "error",
|
|
51
|
+
"unicorn/prefer-array-flat": "error",
|
|
52
|
+
"unicorn/prefer-structured-clone": "error",
|
|
53
|
+
"unicorn/no-array-reduce": "off",
|
|
54
|
+
"unicorn/no-process-exit": "error",
|
|
55
|
+
"unicorn/no-array-sort": "off",
|
|
56
|
+
// Transport extends node:EventEmitter — its .emit()/.on() contract is the
|
|
57
|
+
// wire-level primitive; EventTarget is not a behavioral substitute.
|
|
58
|
+
"unicorn/prefer-event-target": "off",
|
|
59
|
+
"no-inline-comments": "off",
|
|
60
|
+
"max-lines": "off",
|
|
61
|
+
"max-lines-per-function": "off",
|
|
62
|
+
"import/no-cycle": "error",
|
|
63
|
+
"import/no-duplicates": "error",
|
|
64
|
+
"import/no-self-import": "error",
|
|
65
|
+
"promise/no-return-wrap": "error",
|
|
66
|
+
"promise/no-nesting": "warn",
|
|
67
|
+
"typescript/no-unsafe-type-assertion": "off",
|
|
68
|
+
"typescript/no-unnecessary-type-assertion": "off",
|
|
69
|
+
"max-classes-per-file": "off",
|
|
70
|
+
"prefer-readonly-parameter-types": "off",
|
|
71
|
+
},
|
|
72
|
+
ignorePatterns: ["dist", "coverage", "node_modules", "*.config.js"],
|
|
73
|
+
};
|
|
74
|
+
export default base;
|
|
75
|
+
//# sourceMappingURL=oxlint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oxlint.js","sourceRoot":"","sources":["../src/oxlint.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,IAAI,GAAiB;IACvB,OAAO,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;IAC/D,GAAG,EAAE;QACD,IAAI,EAAE,IAAI;KACb;IACD,UAAU,EAAE;QACR,WAAW,EAAE,OAAO;QACpB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,KAAK;KACf;IACD,KAAK,EAAE;QACH,YAAY,EAAE,MAAM;QACpB,aAAa,EAAE,OAAO;QACtB,MAAM,EAAE,OAAO;QACf,QAAQ,EAAE,OAAO;QACjB,cAAc,EAAE,OAAO;QACvB,kBAAkB,EAAE,OAAO;QAC3B,KAAK,EAAE,OAAO;QACd,sBAAsB,EAAE,OAAO;QAC/B,wBAAwB,EAAE,OAAO;QACjC,gBAAgB,EAAE,OAAO;QACzB,uBAAuB,EAAE,OAAO;QAChC,iBAAiB,EAAE,OAAO;QAC1B,6BAA6B,EAAE,OAAO;QACtC,qBAAqB,EAAE,OAAO;QAC9B,4BAA4B,EAAE,OAAO;QACrC,kCAAkC,EAAE,OAAO;QAC3C,yBAAyB,EAAE,OAAO;QAClC,oCAAoC,EAAE,OAAO;QAC7C,2BAA2B,EAAE,OAAO;QACpC,8BAA8B,EAAE,OAAO;QACvC,2BAA2B,EAAE,OAAO;QACpC,2BAA2B,EAAE,OAAO;QACpC,iCAAiC,EAAE,OAAO;QAC1C,yBAAyB,EAAE,KAAK;QAChC,yBAAyB,EAAE,OAAO;QAClC,uBAAuB,EAAE,KAAK;QAC9B,0EAA0E;QAC1E,oEAAoE;QACpE,6BAA6B,EAAE,KAAK;QACpC,oBAAoB,EAAE,KAAK;QAC3B,WAAW,EAAE,KAAK;QAClB,wBAAwB,EAAE,KAAK;QAC/B,iBAAiB,EAAE,OAAO;QAC1B,sBAAsB,EAAE,OAAO;QAC/B,uBAAuB,EAAE,OAAO;QAChC,wBAAwB,EAAE,OAAO;QACjC,oBAAoB,EAAE,MAAM;QAC5B,qCAAqC,EAAE,KAAK;QAC5C,0CAA0C,EAAE,KAAK;QACjD,sBAAsB,EAAE,KAAK;QAC7B,iCAAiC,EAAE,KAAK;KAC3C;IACD,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,CAAC;CACtE,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/vitest.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type PackageOptions = {
|
|
2
|
+
name: string;
|
|
3
|
+
/** Test files to run; defaults to the `tests/` directory. */
|
|
4
|
+
include?: string[];
|
|
5
|
+
/** Overrides merged into the `coverage` block (e.g. extra `exclude`). */
|
|
6
|
+
coverage?: {
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Shared vitest config for every @browsercore/* package.
|
|
13
|
+
*
|
|
14
|
+
* One job: kill the reporter/timeout drift that happened when each repo kept its
|
|
15
|
+
* own copy. Every consumer now gets the same reporters (`text`, `html`,
|
|
16
|
+
* `json-summary` — the last is what the coverage gate reads), the same v8
|
|
17
|
+
* coverage over `src/` (all `.ts` files), the same 30s timeouts, and `globals: false`.
|
|
18
|
+
*
|
|
19
|
+
* Consumers opt in with just their name:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { definePackageConfig } from "@browsercore/dev/vitest";
|
|
23
|
+
* export default definePackageConfig({ name: "crypto" });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function definePackageConfig(options: PackageOptions): import("vite").UserConfig;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=vitest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,yEAAyE;IACzE,QAAQ,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KAC1B,CAAC;CACL,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,6BA8B1D"}
|
package/dist/vitest.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
/**
|
|
3
|
+
* Shared vitest config for every @browsercore/* package.
|
|
4
|
+
*
|
|
5
|
+
* One job: kill the reporter/timeout drift that happened when each repo kept its
|
|
6
|
+
* own copy. Every consumer now gets the same reporters (`text`, `html`,
|
|
7
|
+
* `json-summary` — the last is what the coverage gate reads), the same v8
|
|
8
|
+
* coverage over `src/` (all `.ts` files), the same 30s timeouts, and `globals: false`.
|
|
9
|
+
*
|
|
10
|
+
* Consumers opt in with just their name:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { definePackageConfig } from "@browsercore/dev/vitest";
|
|
14
|
+
* export default definePackageConfig({ name: "crypto" });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function definePackageConfig(options) {
|
|
18
|
+
return defineConfig({
|
|
19
|
+
test: {
|
|
20
|
+
name: options.name,
|
|
21
|
+
root: ".",
|
|
22
|
+
include: options.include ?? ["tests/**/*.test.ts"],
|
|
23
|
+
environment: "node",
|
|
24
|
+
globals: false,
|
|
25
|
+
testTimeout: 30_000,
|
|
26
|
+
hookTimeout: 30_000,
|
|
27
|
+
coverage: {
|
|
28
|
+
provider: "v8",
|
|
29
|
+
include: ["src/**/*.ts"],
|
|
30
|
+
reporter: ["text", "html", "json-summary"],
|
|
31
|
+
// Pure-reexport entrypoints can't be observed by V8's coverage
|
|
32
|
+
// instrumentation: `export { … } from` compiles to no executable
|
|
33
|
+
// lines, so a file that only re-exports reports 0% even when every
|
|
34
|
+
// re-exported symbol is exercised by tests. The symbols remain
|
|
35
|
+
// fully covered at their origin modules. Append (don't replace)
|
|
36
|
+
// any excludes the consumer passed in via options.coverage.
|
|
37
|
+
...options.coverage,
|
|
38
|
+
exclude: [
|
|
39
|
+
"**/index.ts",
|
|
40
|
+
"tests/**",
|
|
41
|
+
"node_modules/**",
|
|
42
|
+
...(options.coverage?.exclude ?? []),
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAa7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IACvD,OAAO,YAAY,CAAC;QAChB,IAAI,EAAE;YACF,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC,oBAAoB,CAAC;YAClD,WAAW,EAAE,MAAM;YACnB,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE;gBACN,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,CAAC,aAAa,CAAC;gBACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC;gBAC1C,+DAA+D;gBAC/D,iEAAiE;gBACjE,mEAAmE;gBACnE,+DAA+D;gBAC/D,gEAAgE;gBAChE,4DAA4D;gBAC5D,GAAG,OAAO,CAAC,QAAQ;gBACnB,OAAO,EAAE;oBACL,aAAa;oBACb,UAAU;oBACV,iBAAiB;oBACjB,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC;iBACvC;aACJ;SACJ;KACJ,CAAC,CAAC;AACP,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@browsercore/dev",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Shared build/lint/test config and governance for the @browsercore/* packages.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/jverneuer/browsercore-dev.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/jverneuer/browsercore-dev#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/jverneuer/browsercore-dev/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./vitest": {
|
|
24
|
+
"types": "./dist/vitest.d.ts",
|
|
25
|
+
"import": "./dist/vitest.js"
|
|
26
|
+
},
|
|
27
|
+
"./oxlint": {
|
|
28
|
+
"types": "./dist/oxlint.d.ts",
|
|
29
|
+
"import": "./dist/oxlint.js"
|
|
30
|
+
},
|
|
31
|
+
"./tsconfig.base.json": "./tsconfig.base.json",
|
|
32
|
+
"./tsconfig.build.base.json": "./tsconfig.build.base.json",
|
|
33
|
+
"./CODING_STANDARDS.md": "./CODING_STANDARDS.md"
|
|
34
|
+
},
|
|
35
|
+
"bin": {
|
|
36
|
+
"coverage-md": "./bin/coverage-md.mjs"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"bin",
|
|
41
|
+
"tsconfig.base.json",
|
|
42
|
+
"tsconfig.build.base.json",
|
|
43
|
+
"CODING_STANDARDS.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=26.0.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.build.json",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"lint": "oxlint --type-aware src/",
|
|
54
|
+
"sync": "node scripts/sync.mjs",
|
|
55
|
+
"clean": "rm -rf dist coverage",
|
|
56
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"oxlint": "^1.76.0",
|
|
60
|
+
"vitest": "^4.1.10"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/node": "^26.1.2",
|
|
64
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
65
|
+
"oxlint": "^1.76.0",
|
|
66
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
67
|
+
"typescript": "^7.0.0",
|
|
68
|
+
"vitest": "^4.1.10"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2024",
|
|
4
|
+
"lib": ["ES2024"],
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"exactOptionalPropertyTypes": true,
|
|
10
|
+
"noUncheckedIndexedAccess": true,
|
|
11
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
12
|
+
"noImplicitOverride": true,
|
|
13
|
+
"noImplicitReturns": true,
|
|
14
|
+
"noFallthroughCasesInSwitch": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"useUnknownInCatchVariables": true,
|
|
18
|
+
"allowUnreachableCode": false,
|
|
19
|
+
"allowUnusedLabels": false,
|
|
20
|
+
"isolatedModules": true,
|
|
21
|
+
"verbatimModuleSyntax": true,
|
|
22
|
+
"forceConsistentCasingInFileNames": true,
|
|
23
|
+
"resolveJsonModule": true,
|
|
24
|
+
"skipLibCheck": true,
|
|
25
|
+
"types": ["node"]
|
|
26
|
+
}
|
|
27
|
+
}
|