body-leading-blank.js 962 B

123456789101112131415161718192021222324
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.bodyLeadingBlank = void 0;
  7. const to_lines_1 = __importDefault(require("@commitlint/to-lines"));
  8. const message_1 = __importDefault(require("@commitlint/message"));
  9. const bodyLeadingBlank = (parsed, when) => {
  10. // Flunk if no body is found
  11. if (!parsed.body) {
  12. return [true];
  13. }
  14. const negated = when === 'never';
  15. const [leading] = (0, to_lines_1.default)(parsed.raw).slice(1);
  16. // Check if the first line of body is empty
  17. const succeeds = leading === '';
  18. return [
  19. negated ? !succeeds : succeeds,
  20. (0, message_1.default)(['body', negated ? 'may not' : 'must', 'have leading blank line']),
  21. ];
  22. };
  23. exports.bodyLeadingBlank = bodyLeadingBlank;
  24. //# sourceMappingURL=body-leading-blank.js.map