Skip to content

Commit

Permalink
lint: refactor to more current patterns
Browse files Browse the repository at this point in the history
Change from indexed array access to for/of syntax.

Signed-off-by: Chris. Webster <[email protected]>
  • Loading branch information
webstech committed Sep 19, 2024
1 parent 129dd75 commit 9e6532f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/commit-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ export class LintCommit {
this.block("The first line must be separated from the rest by an empty line");
}

for (let i = 1; i < this.lines.length; i++) {
if (this.lines[i].length > this.maxColumns &&
for (const line of this.lines) {
if (line.length > this.maxColumns &&
// Allow long lines if prefixed with whitespace (ex. quoted error messages)
!this.lines[i].match(/^\s+/) &&
// Allow long lines if they cannot be wrapped at some
// white-space character, e.g. URLs. To allow a short
// preamble such as `ref [1] <URL>` lines, we skip the
// first 10 (arbitrary) characters.
this.lines[i].slice(10).match(/\s/)) {
!line.match(/^\s+/) &&
// Allow long lines if they cannot be wrapped at some white-space character, e.g. URLs. To allow a
// short preamble such as `ref [1] <URL>` lines, we skip the first 10 (arbitrary) characters.
line.slice(10).match(/\s/)) {
this.block(`Lines in the body of the commit messages should be wrapped between 60 and ${
this.maxColumns} characters.\nIndented lines, and lines without whitespace, are exempt`);
break;
Expand Down

0 comments on commit 9e6532f

Please sign in to comment.