How to use the @commitlint/ensure.enum function in @commitlint/ensure

To help you get started, we’ve selected a few @commitlint/ensure 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 / scope-enum.js View on Github external
export default (parsed, when, value) => {
	if (!parsed.scope) {
		return [true, ''];
	}

	const negated = when === 'never';
	const result = value.length === 0 || ensure.enum(parsed.scope, value);

	return [
		negated ? !result : result,
		message([
			`scope must`,
			negated ? `not` : null,
			`be one of [${value.join(', ')}]`
		])
	];
};
github conventional-changelog / commitlint / @commitlint / rules / src / type-enum.js View on Github external
export default (parsed, when, value) => {
	const {type: input} = parsed;

	if (!input) {
		return [true];
	}

	const negated = when === 'never';
	const result = ensure.enum(input, value);

	return [
		negated ? !result : result,
		message([
			`type must`,
			negated ? `not` : null,
			`be one of [${value.join(', ')}]`
		])
	];
};