Skip to content
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

chore(prlint): stricter validation around breaking changes #14278

Merged
merged 4 commits into from
Apr 21, 2021
Merged
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions tools/prlint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,20 @@ function hasLabel(issue, labelName) {
* to be said note, but got misspelled as "BREAKING CHANGES:" or
* "BREAKING CHANGES(module):"
*/
function validateBreakingChangeFormat(body) {
function validateBreakingChangeFormat(title, body) {
const re = /^BREAKING.*$/m;
const m = re.exec(body);
if (m) {
if (!m[0].startsWith('BREAKING CHANGE: ')) {
throw new LinterError(`Breaking changes should be indicated by starting a line with 'BREAKING CHANGE: ', variations are not allowed. (found: '${m[0]}')`);
}
if (m[0].substr('BREAKING CHANGE:'.length).trim().length === 0) {
throw new LinterError("The description of the first breaking change should immediately follow the 'BREAKING CHANGE: ' clause")
}
const titleRe = /^[a-z]+\([0-9a-z-_]+\)/;
if (!titleRe.exec(title)) {
throw new LinterError("The title of this PR must specify the module name that the first breaking change should be associated to");
}
}
}

Expand Down Expand Up @@ -125,7 +132,7 @@ async function validatePr(number) {
fixContainsTest(issue, files);
}

validateBreakingChangeFormat(issue.body);
validateBreakingChangeFormat(issue.title, issue.body);

console.log("✅ Success")

Expand Down