From 1c6a084b48d56c730c19a8e1bbf328633771cbfc Mon Sep 17 00:00:00 2001 From: Lloyd Evans Date: Thu, 8 Oct 2026 22:05:36 +0100 Subject: [PATCH] Say when to make a package and what one carries --- CONTRIBUTING.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a049803..9d65b23 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,10 @@ See [README.md](README.md) for requirements and commands. - Do not nest one conditional expression inside another. Write a choice among several branches as a `switch`, a small function with early returns or a lookup table. - Write a number or bigint directly in a template literal: `` `row ${index + 1}` ``. Convert any other value to a string first: `${error.message}`, `${url.href}`. - Give a function at most three parameters. One that needs more takes a single object of named fields, as in `waitFor({ observe, signal, timeout, reason })`, and so does a table of test cases with more than three columns. Where another API dictates a longer signature, keep it under a disable comment with its reason. -- Code that other code reuses lives in a package under `packages/`, with its own `package.json`, `tsconfig.json` and `src/index.ts`. The application stays under `src/`. +- Make a package for code worth a hard boundary: logic the application reuses, which could be promoted to a shared versioned package if a second project wants it. +- A package lives under `packages/`, with its own `package.json`, `tsconfig.json` and `src/index.ts`. The application stays under `src/`. +- A package has no `version`; the root's is the only one. List another package it uses in its own `package.json`, as `*`. +- A package is compiled without browser or Node globals. Add them in its own `tsconfig.json` only where it needs them. - Import a package by its name, and only what its `src/index.ts` exports. - `scripts/lint/import-boundaries.mts` owns what may import what. Keep imports within it, and change the policy there.