-
Notifications
You must be signed in to change notification settings - Fork 35
Add changeset guidance and a quality floor #1108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #!/usr/bin/env node | ||
| // Checks pending changesets for the mechanical minimums a public changelog entry needs. | ||
| // It cannot judge whether prose is good, only that it is not obviously not-prose: no | ||
| // conventional-commit prefixes, no "Sync"/"Bump" openers, enough words to describe an | ||
| // effect. See the "Writing changesets" section of AGENTS.md for what good looks like. | ||
| // | ||
| // A change with genuinely nothing customer-visible to say starts its body with [internal]; | ||
| // that skips the prose rules and keeps the entry off the public changelog. | ||
| // | ||
| // Usage: node scripts/lint-changesets.mjs [file...] (defaults to .changeset/*.md) | ||
|
|
||
| import { readdirSync, readFileSync } from 'node:fs' | ||
| import { basename, join } from 'node:path' | ||
|
|
||
| const MIN_CHARS = 20 | ||
| const MIN_WORDS = 4 | ||
|
|
||
| const COMMIT_PREFIX = /^(feat|fix|chore|refactor|docs|test|tests|ci|build|perf|style|revert)(\([^)]*\))?!?:/i | ||
| // Only openers that never carry an effect. "Refactor X to improve Y" and "Tweak the Z ui" | ||
| // do describe one, so they are left alone — a change with no effect uses [internal]. | ||
| const WEAK_OPENER = | ||
| /^(sync|syncs|synced|bump|bumps|bumped|upgrade deps|update deps|update dependencies|cleanup|clean up|wip|misc|various|minor (fixes|changes)|small (fixes|changes)|update types)\b/i | ||
|
|
||
| const files = | ||
| process.argv.slice(2).length > 0 | ||
| ? process.argv.slice(2) | ||
| : readdirSync('.changeset') | ||
| .filter((file) => file.endsWith('.md') && basename(file).toLowerCase() !== 'readme.md') | ||
| .map((file) => join('.changeset', file)) | ||
|
|
||
| const problems = [] | ||
| const fail = (file, rule, detail) => problems.push({ file, rule, detail }) | ||
|
|
||
| for (const file of files) { | ||
| const raw = readFileSync(file, 'utf8') | ||
| const match = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/) | ||
|
|
||
| if (!match) { | ||
| fail(file, 'frontmatter', 'no --- frontmatter block naming the packages and bump types') | ||
| continue | ||
| } | ||
| if (!/^\s*['"]?@[^'"\s]+['"]?\s*:\s*(patch|minor|major)\s*$/m.test(match[1])) { | ||
| fail(file, 'frontmatter', 'no `"@scope/package": patch|minor|major` line') | ||
| } | ||
|
|
||
| const body = match[2].trim() | ||
| if (!body) { | ||
| fail(file, 'empty', 'the body is empty — describe the change for someone using the package') | ||
| continue | ||
| } | ||
|
|
||
| if (/^\[internal\]/i.test(body)) continue | ||
|
|
||
| const summary = body.split('\n')[0].trim() | ||
|
|
||
| if (COMMIT_PREFIX.test(summary)) { | ||
| fail(file, 'commit-prefix', `drop the commit-style prefix: ${JSON.stringify(summary.slice(0, 60))}`) | ||
| } | ||
| if (WEAK_OPENER.test(summary)) { | ||
| fail(file, 'weak-opener', `say what changed for the reader, not the mechanics: ${JSON.stringify(summary.slice(0, 60))}`) | ||
| } | ||
| if (body.length < MIN_CHARS) { | ||
| fail(file, 'too-short', `${body.length} characters, minimum ${MIN_CHARS}`) | ||
| } | ||
| if (body.split(/\s+/).filter(Boolean).length < MIN_WORDS) { | ||
| fail(file, 'too-short', `${body.split(/\s+/).filter(Boolean).length} words, minimum ${MIN_WORDS}`) | ||
| } | ||
| } | ||
|
|
||
| if (problems.length === 0) { | ||
| console.log(`changesets ok (${files.length} checked)`) | ||
| process.exit(0) | ||
| } | ||
|
|
||
| console.error(`${problems.length} changeset problem(s):\n`) | ||
| for (const { file, rule, detail } of problems) console.error(` ${file} [${rule}] ${detail}`) | ||
| console.error(` | ||
| These are mechanical minimums, not a judgement of the writing. A changeset becomes a public | ||
| changelog entry at docs.relay.link/changelog, so write it for someone using the package: | ||
| what changed, what it means for them, and what they need to do. | ||
|
|
||
| If the change genuinely has no customer-visible effect, start the body with [internal].`) | ||
| process.exit(1) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[internal]entries remain in public changelogsThe
[internal]marker only bypasses the prose linter; the configured standard Changesets generator does not interpret it as a changelog-exclusion directive. A valid patch changeset beginning with[internal]still bumped the package version and was emitted verbatim intoCHANGELOG.md. Contributors following this guidance can therefore publish refactor, test-only, and dependency-maintenance notes that the documentation promises to suppress. Either configure a generator that filters these entries or correct the guidance to match the release behavior.