Registry / devops / conventional-commits-filter

conventional-commits-filter

JSON →
library5.0.0jsnpmunverified

The `conventional-commits-filter` package, currently at stable version 5.0.0, provides utilities for processing commit data, specifically designed to identify and remove "revert" commits and their corresponding reverted original commits. This ensures that generated changelogs or commit analyses accurately reflect the effective state of the codebase by omitting changes that were later undone. It integrates seamlessly within the conventional-changelog ecosystem, which typically follows a regular, synchronized release schedule across its components. A key differentiator is its robust handling of commit revert logic, which is crucial for maintaining a clean and meaningful commit history in projects adhering to Conventional Commits specifications. The library offers synchronous, asynchronous (Promise-based), and stream-based APIs to suit various data processing needs.

npm install conventional-commits-filter
INSTALL
IMPORT
SIG · CONVENTIONAL-COMMI
C
conventional-commits-filter
devopsjavascriptv5.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

filterRevertedCommitsSync
import { filterRevertedCommitsSync } from 'conventional-commits-filter'
const { filterRevertedCommitsSync } = require('conventional-commits-filter')
This package is ESM-only since v5.0.0; CommonJS `require` is not supported.
filterRevertedCommits
import { filterRevertedCommits } from 'conventional-commits-filter'
const { filterRevertedCommits } = require('conventional-commits-filter')
This is the asynchronous (Promise-based) version, primarily used with `await`.
filterRevertedCommitsStream
import { filterRevertedCommitsStream } from 'conventional-commits-filter'
const { filterRevertedCommitsStream } = require('conventional-commits-filter')
Provides a Transform stream interface for filtering large commit lists efficiently.

This example demonstrates both synchronous and stream-based filtering of an array of parsed conventional commits, showing how revert commits and their reverted counterparts are removed to yield a clean commit list.

import { filterRevertedCommitsSync, filterRevertedCommitsStream } from 'conventional-commits-filter'; import { pipeline } from 'stream/promises'; import { Readable } from 'stream'; const commits = [ { type: 'revert', subject: 'feat(): amazing new module', body: 'This reverts commit 56185b7356766d2b30cfa2406b257080272e0b7a.\n', revert: { hash: '56185b7356766d2b30cfa2406b257080272e0b7a' }, hash: '789d898b5f8422d7f65cc25135af2c1a95a125ac' }, { type: 'feat', subject: 'amazing new module', hash: '56185b7356766d2b30cfa2406b257080272e0b7a' }, { type: 'feat', subject: 'new feature', hash: '815a3f0717bf1dfce007bd076420c609504edcf3' } ]; // Synchronous usage const filteredSync = filterRevertedCommitsSync(commits); console.log('Synchronous filtered commits:', filteredSync.map(c => c.subject)); // Stream usage (for larger datasets) const commitStream = Readable.from(commits, { objectMode: true }); const filteredStream = commitStream.pipe(filterRevertedCommitsStream()); (async () => { const results = []; for await (const chunk of filteredStream) { results.push(chunk); } console.log('Stream filtered commits:', results.map(c => c.subject)); })();
Debug
Known issues
breakingVersion 5.0.0 and above are pure ESM (ECMAScript Modules) and no longer support CommonJS `require()`. You must use `import` statements.
fix
Migrate your project to use ESM imports (`import ... from 'package'`) and ensure your `package.json` specifies `"type": "module"` or uses `.mjs` file extensions.
affects: >=5.0.0
breakingNode.js version requirement has been updated to `^18.0.0 || >=20.0.0`.
fix
Upgrade your Node.js runtime to version 18 or higher to ensure compatibility and leverage modern JavaScript features.
affects: >=5.0.0
gotchaThis package expects commit objects to conform to the structure produced by `conventional-commits-parser`, specifically looking for a `revert` property on revert commits and a `hash` property for identification. Malformed or unparsed input will not be filtered correctly.
fix
Ensure all commit objects passed to the filter functions have been processed by `conventional-commits-parser` or a compatible parser that populates the `revert` and `hash` fields accurately.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` to import an ESM-only package.
fix
Change `const filter = require('conventional-commits-filter')` to `import { filterRevertedCommitsSync } from 'conventional-commits-filter'`.
ERR_REQUIRE_ESM
Node.js detected a CommonJS `require()` call trying to load an ES module.
fix
Update your import statements to use `import` syntax and ensure your project or file is configured for ES modules (e.g., `"type": "module"` in `package.json` or using `.mjs` extension).
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies
conventional-commits-parserrequiredThis library expects input commits to be parsed by `conventional-commits-parser` or a compatible tool to correctly identify revert information.
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
2
Resources
conventional-commits-filter — npm install conventional-commits-filter · libregistry