UNPKG

1.21 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 = (0, to_lines_1.default)(parsed.raw);
16 const footerLines = (0, to_lines_1.default)(parsed.footer);
17 const footerOffset = rawLines.indexOf(footerLines[0]);
18 const [leading] = rawLines.slice(footerOffset - 1);
19 // Check if the first line of footer is empty
20 const succeeds = leading === '';
21 return [
22 negated ? !succeeds : succeeds,
23 (0, 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