Socket
Socket
Sign inDemoInstall

conventional-commits-filter

Package Overview
Dependencies
0
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    conventional-commits-filter

Filter out reverted commits parsed by conventional-commits-parser.


Version published
Weekly downloads
3.7M
decreased by-3.41%
Maintainers
4
Created
Weekly downloads
 

Package description

What is conventional-commits-filter?

The conventional-commits-filter npm package is used to filter out commit messages that do not follow the Conventional Commits specification. This is useful in projects that enforce a specific commit message format for better readability, automation, and tooling.

What are conventional-commits-filter's main functionalities?

Filtering valid commits

This feature allows you to filter out commits that do not follow the Conventional Commits specification. In the example, only the commits with headers 'feat: add new feature' and 'fix: fix bug' will be considered valid.

const filter = require('conventional-commits-filter');
const commits = [
  { header: 'feat: add new feature' },
  { header: 'fix: fix bug' },
  { header: 'invalid commit message' }
];
const validCommits = filter(commits);
console.log(validCommits);

Filtering invalid commits

This feature allows you to filter out valid commits and only keep the invalid ones. In the example, only the commit with the header 'invalid commit message' will be considered invalid.

const filter = require('conventional-commits-filter');
const commits = [
  { header: 'feat: add new feature' },
  { header: 'fix: fix bug' },
  { header: 'invalid commit message' }
];
const invalidCommits = filter(commits, { ignore: true });
console.log(invalidCommits);

Other packages similar to conventional-commits-filter

Readme

Source

conventional-commits-filter

ESM-only package NPM version Node version Dependencies status Install size Build status Coverage status

Filter out reverted commits parsed by conventional-commits-parser.

Install

# pnpm
pnpm add conventional-commits-filter
# yarn
yarn add conventional-commits-filter
# npm
npm i conventional-commits-filter

Usage

import {
  filterRevertedCommitsSync,
  filterRevertedCommits,
  filterRevertedCommitsStream
} from 'conventional-commits-filter'
import { pipeline } from 'stream/promises'
import { Readable } from 'stream'

const commits = [{
  type: 'revert',
  scope: null,
  subject: 'feat(): amazing new module',
  header: 'revert: feat(): amazing new module\n',
  body: 'This reverts commit 56185b7356766d2b30cfa2406b257080272e0b7a.\n',
  footer: null,
  notes: [],
  references: [],
  revert: {
    header: 'feat(): amazing new module',
    hash: '56185b7356766d2b30cfa2406b257080272e0b7a',
    body: null
  },
  hash: '789d898b5f8422d7f65cc25135af2c1a95a125ac\n',
  raw: {
    type: 'revert',
    scope: null,
    subject: 'feat(): amazing new module',
    header: 'revert: feat(): amazing new module\n',
    body: 'This reverts commit 56185b7356766d2b30cfa2406b257080272e0b7a.\n',
    footer: null,
    notes: [],
    references: [],
    revert: {
      header: 'feat(): amazing new module',
      hash: '56185b7356766d2b30cfa2406b257080272e0b7a',
      body: null
    },
    hash: '789d898b5f8422d7f65cc25135af2c1a95a125ac\n'
  }
}, {
  type: 'Features',
  scope: null,
  subject: 'wow',
  header: 'amazing new module\n',
  body: null,
  footer: 'BREAKING CHANGE: Not backward compatible.\n',
  notes: [],
  references: [],
  revert: null,
  hash: '56185b',
  raw: {
    type: 'feat',
    scope: null,
    subject: 'amazing new module',
    header: 'feat(): amazing new module\n',
    body: null,
    footer: 'BREAKING CHANGE: Not backward compatible.\n',
    notes: [],
    references: [],
    revert: null,
    hash: '56185b7356766d2b30cfa2406b257080272e0b7a\n'
  }
}, {
  type: 'What',
  scope: null,
  subject: 'new feature',
  header: 'feat(): new feature\n',
  body: null,
  footer: null,
  notes: [],
  references: [],
  revert: null,
  hash: '815a3f0',
  raw: {
    type: 'feat',
    scope: null,
    subject: 'new feature',
    header: 'feat(): new feature\n',
    body: null,
    footer: null,
    notes: [],
    references: [],
    revert: null,
    hash: '815a3f0717bf1dfce007bd076420c609504edcf3\n'
  }
}, {
  type: 'Chores',
  scope: null,
  subject: 'first commit',
  header: 'chore: first commit\n',
  body: null,
  footer: null,
  notes: [],
  references: [],
  revert: null,
  hash: '74a3e4d6d25',
  raw: {
    type: 'chore',
    scope: null,
    subject: 'first commit',
    header: 'chore: first commit\n',
    body: null,
    footer: null,
    notes: [],
    references: [],
    revert: null,
    hash: '74a3e4d6d25dee2c0d6483a0a3887417728cbe0a\n'
  }
}];

// to filter reverted commits syncronously:
for (const commit of filterRevertedCommitsSync(commits)) {
  console.log(commit)
}

// to filter reverted commits in async iterables:
await pipeline(
  commits,
  filterRevertedCommits,
  async function* (filteredCommits) {
    for await (const commit of filteredCommits) {
      console.log(commit)
    }
  }
)

// to filter reverted commits in streams:
Readable.from(commits)
  .pipe(filterRevertedCommitsStream())
  .on('data', commit => console.log(commit))

Output:

{
  type: 'What',
  scope: null,
  subject: 'new feature',
  header: 'feat(): new feature\n',
  body: null,
  footer: null,
  notes: [],
  references: [],
  revert: null,
  hash: '815a3f0',
  raw: {
    type: 'feat',
    scope: null,
    subject: 'new feature',
    header: 'feat(): new feature\n',
    body: null,
    footer: null,
    notes: [],
    references: [],
    revert: null,
    hash: '815a3f0717bf1dfce007bd076420c609504edcf3\n'
  }
}
{
  type: 'Chores',
  scope: null,
  subject: 'first commit',
  header: 'chore: first commit\n',
  body: null,
  footer: null,
  notes: [],
  references: [],
  revert: null,
  hash: '74a3e4d6d25',
  raw: {
    type: 'chore',
    scope: null,
    subject: 'first commit',
    header: 'chore: first commit\n',
    body: null,
    footer: null,
    notes: [],
    references: [],
    revert: null,
    hash: '74a3e4d6d25dee2c0d6483a0a3887417728cbe0a\n'
  }
}

License

MIT © Steve Mao

Keywords

FAQs

Last updated on 03 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc