Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Prefer an entry for anything that affects package consumers. Changelog entries a

### Changelog Entry Format

Under the "Unreleased" heading, add entries as list items under an appropriate `###` subheading (see ["Changelog Subsections"](#changelog-subsections)). Each top-level bullet should end with a link to the pull request and a period.
Under the "Unreleased" heading, add entries as list items under an appropriate `###` subheading (see ["Changelog Subsections"](#changelog-subsections)). Each top-level bullet should end with a link to the pull request and a period. Do not leave blank lines between bullets in a subsection, including before nested bullets.

Example:

Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
### Breaking Changes

- `ImageSizeControl`: The event in the `onChangeImage` callback's `{ event }` argument now comes from popup selection rather than a native select change. Read the selected value from the `slug` argument rather than `event.target.value` ([#84546](https://github.com/WordPress/gutenberg/pull/84546)).

- Raise the minimum required Node.js version to `>=22.13.0`, for stable `require(esm)` support ([#84313](https://github.com/WordPress/gutenberg/pull/84313)).

### New Features
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

- `use-recommended-components`: Recommend `useEnableWpCompatOverlaySlot` from `@wordpress/ui` ([#84305](https://github.com/WordPress/gutenberg/pull/84305)).
- `use-recommended-components`: Recommend `Notice` from `@wordpress/ui` instead of `Tip` from `@wordpress/components` ([#84197](https://github.com/WordPress/gutenberg/pull/84197)).

- `use-recommended-components`: Recognize `Avatar` from `@wordpress/ui` as use-with-caution. ([#84145](https://github.com/WordPress/gutenberg/pull/84145))

### Bug Fixes
Expand Down
24 changes: 21 additions & 3 deletions tools/validation/validate-changelogs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,19 @@ describe( 'validateChangelog', () => {
expect( errors ).toEqual( [] );
} );

test( 'accepts a nested PR link after a blank line under the parent bullet', () => {
test( 'finds a nested PR link after a blank line under the parent bullet', () => {
const errors = validateChangelog(
changelog( `### Breaking Changes

- Parent description:

- \`Child\` ([#82570](https://github.com/WordPress/gutenberg/pull/82570))
` )
` ),
{ filePath: 'packages/ui/CHANGELOG.md' }
);
expect( errors ).toEqual( [] );
expect( errors ).toEqual( [
'packages/ui/CHANGELOG.md:9: blank line inside an Unreleased list. Entries and their nested lines must not be separated by blank lines.',
] );
} );

test( 'accepts a PR link on a soft-wrapped continuation line', () => {
Expand Down Expand Up @@ -163,6 +166,21 @@ describe( 'validateChangelog', () => {
] );
} );

test( 'rejects blank lines between top-level entries', () => {
const errors = validateChangelog(
changelog( `### Bug Fixes

- Fixed one thing ([#1](https://github.com/WordPress/gutenberg/pull/1)).

- Fixed another thing ([#2](https://github.com/WordPress/gutenberg/pull/2)).
` ),
{ filePath: 'packages/ui/CHANGELOG.md' }
);
expect( errors ).toEqual( [
'packages/ui/CHANGELOG.md:9: blank line inside an Unreleased list. Entries and their nested lines must not be separated by blank lines.',
] );
} );

test( 'requirePr checks for this pull request link under Unreleased', () => {
const content = changelog( `### Internal

Expand Down
41 changes: 41 additions & 0 deletions tools/validation/validate-changelogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,46 @@ function validateEntryLinks(
return errors;
}

/**
* Rejects blank lines inside an Unreleased list, whether between entries or
* within an entry. One blank line would make the whole list loose.
*
* @param unreleased Unreleased section.
* @param filePath Path for error messages.
* @return Error messages.
*/
function validateEntrySpacing(
unreleased: UnreleasedSection,
filePath: string
): string[] {
const errors: string[] = [];
let inEntry = false;

for ( let i = 1; i < unreleased.lines.length; i++ ) {
const line = unreleased.lines[ i ];
if ( line.trim() === '' ) {
continue;
}
const isTopLevel = /^-\s+/.test( line );
if ( ! isTopLevel && ! /^\s/.test( line ) ) {
inEntry = false;
continue;
}
if ( inEntry && unreleased.lines[ i - 1 ].trim() === '' ) {
errors.push(
`${ filePath }:${
unreleased.start + i + 1
}: blank line inside an Unreleased list. Entries and their nested lines must not be separated by blank lines.`
);
}
if ( isTopLevel ) {
inEntry = true;
}
}

return errors;
}

/**
* Markdown link for a Gutenberg pull request.
*
Expand Down Expand Up @@ -350,6 +390,7 @@ export function validateChangelog(
...validateSubsectionHeadings( unreleased, filePath ),
...validateSectionTitles( unreleased, filePath ),
...validateEntryLinks( unreleased, filePath ),
...validateEntrySpacing( unreleased, filePath ),
...placementErrors,
...( options.requirePr
? validateRequiredPrLink( unreleased, filePath, options.requirePr )
Expand Down
Loading