From 9e6532fc56a256ccf947b43842eef7853c32c287 Mon Sep 17 00:00:00 2001 From: "Chris. Webster" Date: Wed, 18 Sep 2024 21:38:32 -0700 Subject: [PATCH] lint: refactor to more current patterns Change from indexed array access to for/of syntax. Signed-off-by: Chris. Webster --- lib/commit-lint.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/commit-lint.ts b/lib/commit-lint.ts index 61caab65df..b62ed887bb 100644 --- a/lib/commit-lint.ts +++ b/lib/commit-lint.ts @@ -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] ` 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] ` 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;