Skip to content
4 changes: 4 additions & 0 deletions lib/rules/line-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ export default {
let failed = false
for (let i = 0; i < parsed.body.length; i++) {
const line = parsed.body[i]

// Skip quoted lines, e.g. for original commit messages of V8 backports.
if (line.startsWith(' ')) { continue }
// Skip lines with URLs.
if (/https?:\/\//.test(line)) { continue }
// Skip co-authorship.
if (/^co-authored-by:/i.test(line)) { continue }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'm not sure it's worth doing, but we could have a shared util to avoid duplicating the regex

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I think if we need it in a third place, then it's worth having a shared util.


if (line.length > len) {
failed = true
context.report({
Expand Down
30 changes: 30 additions & 0 deletions test/rules/line-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,35 @@ https://${'very-'.repeat(80)}-long-url.org/
tt.end()
})

t.test('Co-author lines', (tt) => {
const v = new Validator()
const context = new Commit({
sha: 'f1496de5a7d5474e39eafaafe6f79befe5883a5b',
author: {
name: 'Jacob Smith',
email: '[email protected]',
date: '2025-12-22T09:40:42Z'
},
message: `
fixup!: apply case-insensitive suggestion
Co-authored-by: Michaël Zasso <[email protected]>
`
Copy link
Contributor

@aduh95 aduh95 Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good test, it passes without your patch because of the leading spaces

Suggested change
message: `
fixup!: apply case-insensitive suggestion
Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>
`
message: [
'fixup!: apply case-insensitive suggestion',
'Co-authored-by: Michaël Zasso <[email protected]>',
].join('\n')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should fail though, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good regression test fails without the patch, and passes with it. Currently the test passes with and without your patch. If we want a good regression test (we do), we want one that fails without the patch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean it seems suspicious that it isn't failing, which would suggest the implementation is bugged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered why the test is suspiciously passing:

// Skip quoted lines, e.g. for original commit messages of V8 backports.
if (line.startsWith(' ')) { continue }

Copy link
Member Author

@JakobJingleheimer JakobJingleheimer Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(@aduh95 I don't know what to do about it)

}, v)

context.report = (opts) => {
tt.pass('called report')
tt.equal(opts.id, 'line-length', 'id')
tt.equal(opts.string, '', 'string')
tt.equal(opts.level, 'pass', 'level')
}

Rule.validate(context, {
options: {
length: 72
}
})
tt.end()
})

t.end()
})