diff --git a/.claude/skills/js-conventions/SKILL.md b/.claude/skills/js-conventions/SKILL.md index d986262..832fdef 100644 --- a/.claude/skills/js-conventions/SKILL.md +++ b/.claude/skills/js-conventions/SKILL.md @@ -4,7 +4,8 @@ description: Apply the Alexis JavaScript style (Metarhia-derived, linted by oxli --- + oxlint + oxfmt instead of ESLint + Prettier, pnpm instead of npm, 100 columns instead of 80; + loops in one pass instead of array iteration methods in library code (src/). --> # JavaScript Code Style @@ -58,15 +59,18 @@ Use following conventions for JavaScript and TypeScript code. - Do not mutate input parameters; avoid `arguments` - Keep functions small and single-purpose - Decompose long expressions into intermediate variables -- Prefer explicit loops (`for`, `for..of`) in hot paths -- Use array methods when they improve readability +- Iterate with `for` and `for..of` loops in library code (`src/`), index loops in hot paths; no + array iteration methods there (`.map`, `.filter`, `.some`, `.every`, `.find`, `.findIndex`, + `.findLast`, `.reduce`, `.flatMap`, `.forEach`), cold paths included +- Compute everything a collection gives in one pass with an early exit; never chain passes + (`.map().join()`, `Object.entries().filter()`, `Array.from().map()`), and do not build an array + only to iterate it (spread of an iterable, `Array.from(string)`, `split` only to test) - Use `===` and `!==` only - Keep return types consistent - Avoid nested ternaries and deep callback nesting - Self-documented and self-descriptive code: do not add obvious comments, code should be clear without comments -- Use iteration methods like `.map`, `.filter`, `.reduce` if it is good for code semantic -- Try to avoid `.forEach` if callback operates with outer context +- Tests, scripts and benchmarks may use array iteration methods where they read better ## Optimizations @@ -86,6 +90,10 @@ Use following conventions for JavaScript and TypeScript code. - Move reusable callbacks outside loops - Keep `try/catch`, spread/rest away from hot loops - Use `Map` for dynamic key dictionaries, plain objects for fixed schemas +- Build a lookup once: a module-level `Set` for membership, a `Map` for keyed search, instead of + repeated linear scans (`.includes`, a `.find` per call) +- Keep caches and metadata on objects you do not own (a message, a config) in a `WeakMap` or + `WeakSet` rather than in a property on them - Use `Set` for big and dynamic collections, prefer arrays for short and stable - Use `Object.create(null)` for pure dictionaries - Use typed arrays for numeric and binary workloads diff --git a/.claude/skills/npm-publish/SKILL.md b/.claude/skills/npm-publish/SKILL.md index 0f50d46..9b0add9 100644 --- a/.claude/skills/npm-publish/SKILL.md +++ b/.claude/skills/npm-publish/SKILL.md @@ -31,13 +31,14 @@ pnpm run lint # oxlint pnpm run format:check # oxfmt pnpm run test:coverage # tests under the c8 coverage gate pnpm run test:types # tsd -pnpm run check:dts # tsc over index.d.ts +pnpm run check:dts # tsc over the d.ts of every entry of the exports map +pnpm size --check # the budgets of scripts/size-budgets.json +pnpm run check:pack # the tarball: every file of the exports map, nothing else ``` -These are the same gates `prepublishOnly` runs. CI adds three more; run them too: +These are the same gates `prepublishOnly` runs. CI adds two more; run them too: ```bash -pnpm size --max-gzip 4 # the bundle budget pnpm docs:comparison && git diff --exit-code docs/guide/comparison.md # the table matches docs/comparison.json pnpm run docs:build # the docs site; a dead link fails it ``` @@ -58,7 +59,7 @@ Compute the new version based on user intent and semver rules: - **prerelease**: `1.2.3` → `1.2.4-