How to use @commitlint/core - 7 common examples

To help you get started, we’ve selected a few @commitlint/core 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 paulirish / commitlintbot / src / lint.js View on Github external
const baseConfig = lintOpts.clintConfig || defaultClintConfig;
  baseConfig.extends = baseConfig.extends || [];

  let mergedConfig;
  if (czConfigContent) {
    // Hack because of some weird expectation inside of commitlint-config-cz/lib/config').get;
    if (!baseConfig.rules['scope-enum']) baseConfig.rules['scope-enum'] = [0, 'never', 'bullshit'];
    if (!baseConfig.rules['type-enum']) baseConfig.rules['type-enum'] = [0, 'never', 'bullshit'];

    mergedConfig = mergeCZWithBaseConfig(czConfigContent, baseConfig);
  } else {
    mergedConfig = baseConfig;
  }

  const opts = await commitlint.load(mergedConfig);
  const reportObj = await commitlint.lint(prTitle, opts.rules);
  const report = await commitlint.format(reportObj, {color: false});
  return {reportObj, report};
}
github z0al / commitlint-bot / lib / lint.js View on Github external
return paginate(pullRequests.getCommits(pull), async ({ data }) => {
		// empty summary
		const report = { valid: true, commits: [] };
		const { rules } = await load(config);

		// Keep counters
		let errorsCount = 0;
		let warnsCount = 0;

		// Iterates over all commits
		for (const d of data) {
			const { valid, errors, warnings } = await lint(
				d.commit.message,
				rules
			);
			if (!valid) {
				report.valid = false;
			}

			if (errors.length > 0 || warnings.length > 0) {
				// Update counts
				errorsCount += errors.length;
				warnsCount += warnings.length;

				report.commits.push({ sha: d.sha, errors, warnings });
			}
		}
github z0al / commitlint-bot / lib / lint.js View on Github external
return paginate(pullRequests.getCommits(pull), async ({ data }) => {
		// empty summary
		const report = { valid: true, commits: [] };
		const { rules } = await load(config);

		// Keep counters
		let errorsCount = 0;
		let warnsCount = 0;

		// Iterates over all commits
		for (const d of data) {
			const { valid, errors, warnings } = await lint(
				d.commit.message,
				rules
			);
			if (!valid) {
				report.valid = false;
			}

			if (errors.length > 0 || warnings.length > 0) {
github paulirish / commitlintbot / src / lint.js View on Github external
// Use provided commitlint.config or fallback to our local preset
  const baseConfig = lintOpts.clintConfig || defaultClintConfig;
  baseConfig.extends = baseConfig.extends || [];

  let mergedConfig;
  if (czConfigContent) {
    // Hack because of some weird expectation inside of commitlint-config-cz/lib/config').get;
    if (!baseConfig.rules['scope-enum']) baseConfig.rules['scope-enum'] = [0, 'never', 'bullshit'];
    if (!baseConfig.rules['type-enum']) baseConfig.rules['type-enum'] = [0, 'never', 'bullshit'];

    mergedConfig = mergeCZWithBaseConfig(czConfigContent, baseConfig);
  } else {
    mergedConfig = baseConfig;
  }

  const opts = await commitlint.load(mergedConfig);
  const reportObj = await commitlint.lint(prTitle, opts.rules);
  const report = await commitlint.format(reportObj, {color: false});
  return {reportObj, report};
}
github paulirish / commitlintbot / src / lint.js View on Github external
baseConfig.extends = baseConfig.extends || [];

  let mergedConfig;
  if (czConfigContent) {
    // Hack because of some weird expectation inside of commitlint-config-cz/lib/config').get;
    if (!baseConfig.rules['scope-enum']) baseConfig.rules['scope-enum'] = [0, 'never', 'bullshit'];
    if (!baseConfig.rules['type-enum']) baseConfig.rules['type-enum'] = [0, 'never', 'bullshit'];

    mergedConfig = mergeCZWithBaseConfig(czConfigContent, baseConfig);
  } else {
    mergedConfig = baseConfig;
  }

  const opts = await commitlint.load(mergedConfig);
  const reportObj = await commitlint.lint(prTitle, opts.rules);
  const report = await commitlint.format(reportObj, {color: false});
  return {reportObj, report};
}
github UiPath / angular-components / .build / commitlint / index.js View on Github external
const run = async () => {
    const head = await getPullRequestHead()

    console.log(blue('👮‍   Calling Git Police...'))

    await reportStatus('pending', head.sha, 'Checking commits...')

    const commits = await getCommits()

    const { rules } = await load(path.resolve('commitlint.config.js'))

    const lintResultList = await Promise.all(
        commits.map(({ commit }) => lint(commit.message, rules))
    )

    const isConventionalCommitGuidelineRespected = lintResultList.every(result => result.valid)
    const isAnyFixupCommit = commits.some(({ commit }) => commit.message.startsWith('fixup!'))

    if (
        isConventionalCommitGuidelineRespected &&
        !isAnyFixupCommit
    ) {
        console.log(green(`💯   Good to go!`))

        await reportStatus('success', head.sha, '✔ Good to go!')
            .catch(_handleUnexpectedError)
github UiPath / angular-components / .build / commitlint / index.js View on Github external
        commits.map(({ commit }) => lint(commit.message, rules))
    )

@commitlint/core

Lint your commit messages

MIT
Latest version published 28 days ago

Package Health Score

93 / 100
Full package analysis