UNPKG

1.24 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.footerLeadingBlank = void 0;
7const to_lines_1 = __importDefault(require("@commitlint/to-lines"));
8const message_1 = __importDefault(require("@commitlint/message"));
9const footerLeadingBlank = (parsed, when = 'always') => {
10 // Flunk if no footer is found
11 if (!parsed.footer) {
12 return [true];
13 }
14 const negated = when === 'never';
15 const rawLines = to_lines_1.default(parsed.raw);
16 const bodyLines = parsed.body ? to_lines_1.default(parsed.body) : [];
17 const bodyOffset = bodyLines.length > 0 ? rawLines.indexOf(bodyLines[0]) : 1;
18 const [leading] = rawLines.slice(bodyLines.length + bodyOffset);
19 // Check if the first line of footer is empty
20 const succeeds = leading === '';
21 return [
22 negated ? !succeeds : succeeds,
23 message_1.default([
24 'footer',
25 negated ? 'may not' : 'must',
26 'have leading blank line',
27 ]),
28 ];
29};
30exports.footerLeadingBlank = footerLeadingBlank;
31//# sourceMappingURL=footer-leading-blank.js.map
\No newline at end of file