How to use @commitlint/to-lines - 4 common examples

To help you get started, we’ve selected a few @commitlint/to-lines examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github conventional-changelog / commitlint / @commitlint / rules / src / footer-leading-blank.js View on Github external
export default (parsed, when) => {
	// Flunk if no footer is found
	if (!parsed.footer) {
		return [true];
	}

	const negated = when === 'never';
	const rawLines = toLines(parsed.raw);
	const bodyLines = toLines(parsed.body);
	const bodyOffset = bodyLines.length > 0 ? rawLines.indexOf(bodyLines[0]) : 1;
	const [leading] = rawLines.slice(bodyLines.length + bodyOffset);

	// Check if the first line of footer is empty
	const succeeds = leading === '';

	return [
		negated ? !succeeds : succeeds,
		message(['footer', negated ? 'may not' : 'must', 'have leading blank line'])
	];
};
github conventional-changelog / commitlint / @commitlint / rules / src / body-leading-blank.js View on Github external
export default (parsed, when) => {
	// Flunk if no body is found
	if (!parsed.body) {
		return [true];
	}

	const negated = when === 'never';
	const [leading] = toLines(parsed.raw).slice(1);

	// Check if the first line of body is empty
	const succeeds = leading === '';

	return [
		negated ? !succeeds : succeeds,
		message(['body', negated ? 'may not' : 'must', 'have leading blank line'])
	];
};
github conventional-changelog / commitlint / @commitlint / rules / src / footer-leading-blank.js View on Github external
export default (parsed, when) => {
	// Flunk if no footer is found
	if (!parsed.footer) {
		return [true];
	}

	const negated = when === 'never';
	const rawLines = toLines(parsed.raw);
	const bodyLines = toLines(parsed.body);
	const bodyOffset = bodyLines.length > 0 ? rawLines.indexOf(bodyLines[0]) : 1;
	const [leading] = rawLines.slice(bodyLines.length + bodyOffset);

	// Check if the first line of footer is empty
	const succeeds = leading === '';

	return [
		negated ? !succeeds : succeeds,
		message(['footer', negated ? 'may not' : 'must', 'have leading blank line'])
	];
};
github conventional-changelog / commitlint / @commitlint / rules / src / signed-off-by.js View on Github external
export default (parsed, when, value) => {
	const lines = toLines(parsed.raw).filter(Boolean);
	const last = lines[lines.length - 1];

	const negated = when === 'never';
	const hasSignedOffBy = last.startsWith(value);

	return [
		negated ? !hasSignedOffBy : hasSignedOffBy,
		message(['message', negated ? 'must not' : 'must', 'be signed off'])
	];
};

@commitlint/to-lines

Lint your commit messages

MIT
Latest version published 7 months ago

Package Health Score

98 / 100
Full package analysis

Popular @commitlint/to-lines functions

Popular JavaScript code snippets

Find secure code to use in your application or website