Repository navigation
ci: guard code and docs against growth by appending - #733
Merged
Merged
Conversation
Four checks in scripts/growth.js, each its own step in CI's test job: function length and complexity (ESLint), unused exports and files (knip), duplicated code (jscpd) and lines per docs page. Functions, unused code and docs pages are ratchets on scripts/growth-baseline.json: an offender may not grow, none may be added, and one that shrank lowers the baseline in the same pull request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The disable comments no longer hide a function, the docs total and the duplication threshold sit closer to today's values, unknown options and a baseline without a section fail, and AGENTS.md names the baseline and how to lower it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code and the docs grew mostly by appending. This adds four checks so they can only shrink from here, without fixing the existing offenders.
npm run growthruns them. CI runs each one as its own step in the test job (Node 24).The guards
max-lines-per-function(120 lines, blank lines and comments not counted) andcomplexity(25) overpackages/*/src. ESLint's defaults are 50 and 20. Airbnb lists the same values but switches both rules off; xo warns on complexity at the default. At 50/20 half the code would be listed, so the limits start where the outliers begin: 49 functions over 120 lines, 106 over complexity 25.knip.json. Package entry points and the build entries (esbuild, test pages, type tests) count as used, so public API is not reported. 228 findings today. The analysis counted about 309 exports used outside their own file; knip also counts use by tests and only reports exports nobody imports.packages/*/src(.jscpd.json). Today 0.31 %, threshold 0.35 %.use/300 (one task),concepts/andembed/300,getting-started/400 (read in one go),reference/600 (looked up),decisions/150, pages directly indocs/400. Each limit sits at the upper end of that kind's ordinary pages, so 19 pages are listed,reference/rest.md(2,036 lines) the largest. The total (25,817 lines) is recorded; it may drift 1 % before the baseline must follow, so parallel docs PRs do not all edit the same line.The ratchet
scripts/growth-baseline.jsonlists today's offenders with their numbers, sorted, one per line. It is written bynode scripts/growth.js --update.--updatelowers the baseline in the same PR.--updatenever raises an entry.--accept-growthdoes, and the PR says why. A renamed or moved function counts as new.eslint-disablecomments do not hide a function.Why not plain ESLint rules or bulk suppressions
ESLint's bulk suppressions count violations per file and rule, so a 300-line function that grows to 400 lines would pass. The rules therefore run through the ESLint API in
scripts/growth.jswith the numbers kept in the baseline, not ineslint.config.js; editors do not show them.Notes
--update.package.jsonandpackage-lock.json; whichever merges second needs a rebase.Checked:
npm run lint,npm run types,npm test,npm run growth. Places: AGENTS.md (Commands), CONTRIBUTING.md (Check your change), tests/AGENTS.md (Repository checks), eslint.config.js header. No package changed, so no package changelog.🤖 Generated with Claude Code