Skip to content

Instantly share code, notes, and snippets.

@YonatanKra

YonatanKra/lintpr.js

Last active Jun 27, 2020
Embed
What would you like to do?
const load = require('@commitlint/load').default;
const lint = require('@commitlint/lint').default;
const CONFIG = {
extends: ['@commitlint/config-conventional'],
};
function buildLintError(lintErrors) {
return lintErrors.map((error) => error.message);
}
export async function testTitle(title) {
const lintOptions = await load(CONFIG);
const lintResult = await lint(
title,
lintOptions.rules,
lintOptions.parserPreset ? lintOptions.parserPreset : {}
);
if (!lintResult.valid) {
throw new Error(buildLintError(lintResult.errors));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.