Skip to content

Commit 47e1d6d

Browse files
feat: support co-authorship lines in body (#130)
1 parent 39b93a3 commit 47e1d6d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lib/rules/line-length.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ export default {
2929
let failed = false
3030
for (let i = 0; i < parsed.body.length; i++) {
3131
const line = parsed.body[i]
32+
3233
// Skip quoted lines, e.g. for original commit messages of V8 backports.
3334
if (line.startsWith(' ')) { continue }
3435
// Skip lines with URLs.
3536
if (/https?:\/\//.test(line)) { continue }
37+
// Skip co-authorship.
38+
if (/^co-authored-by:/i.test(line)) { continue }
39+
3640
if (line.length > len) {
3741
failed = true
3842
context.report({

test/rules/line-length.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,37 @@ https://${'very-'.repeat(80)}-long-url.org/
129129
tt.end()
130130
})
131131

132+
t.test('Co-author lines', (tt) => {
133+
const v = new Validator()
134+
135+
const good = new Commit({
136+
sha: 'f1496de5a7d5474e39eafaafe6f79befe5883a5b',
137+
author: {
138+
name: 'Jacob Smith',
139+
email: '3012099+JakobJingleheimer@users.noreply.github.com',
140+
date: '2025-12-22T09:40:42Z'
141+
},
142+
message: [
143+
'fixup!: apply case-insensitive suggestion',
144+
'Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>'
145+
].join('\n')
146+
}, v)
147+
148+
good.report = (opts) => {
149+
tt.pass('called report')
150+
tt.equal(opts.id, 'line-length', 'id')
151+
tt.equal(opts.string, '', 'string')
152+
tt.equal(opts.level, 'pass', 'level')
153+
}
154+
155+
Rule.validate(good, {
156+
options: {
157+
length: 72
158+
}
159+
})
160+
161+
tt.end()
162+
})
163+
132164
t.end()
133165
})

0 commit comments

Comments
 (0)