Use pnpm (not npm).
pnpm install
pnpm test # vitest, with coverage
pnpm check # types
pnpm lint # oxlint + oxfmt
pnpm knip # unused code
pnpm build # build + publint- New code uses
snake_casefor functions, variables and parameters, andPascalCasefor types and classes. Existing camelCase names in the public API stay as they are. constwherever possible;letonly for bindings that are reassigned.- Functions are declarations (
function my_fn() {}), neverconst my_fn = () => {}. Arrow functions are fine as inline callbacks.
pnpm lint enforces most of this.
- Tests live next to the code they test:
src/values/colors.tshas its tests insrc/values/colors.test.ts. - Test a utility by calling it directly. Test a metric through
analyze(css)and assert only the part of the result you care about. - Prefer
test.eachtables over long fixtures.
- Avoid repeated CSS node property reads: each
.text,.name,.columnetc. makes the css-parser node read from its memory arena. Read it once and keep it in aconst. - Compare names case-insensitively with
str_equals('var', node.name)from@projectwallace/css-parser, not withnode.name.toLowerCase() === 'var'. - Search case-insensitively with
str_index_of('var(', text) !== -1from@projectwallace/css-parser, not withtext.toLowerCase().includes('var('). The search string must be lowercase. str_equalsandstr_index_ofdo not allocate a new string,toLowerCase()does. Use them wherever a value is only compared or searched, not transformed.