Last active
June 27, 2020 09:30
-
-
Save YonatanKra/b4baa9c7e62acd6b88c2db7ad6268a28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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