{"id":12999,"library":"conventional-commits-filter","title":"Conventional Commits Filter","description":"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.","status":"active","version":"5.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/conventional-changelog/conventional-changelog","tags":["javascript","filter","conventional","changelog","commits"],"install":[{"cmd":"npm install conventional-commits-filter","lang":"bash","label":"npm"},{"cmd":"yarn add conventional-commits-filter","lang":"bash","label":"yarn"},{"cmd":"pnpm add conventional-commits-filter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This library expects input commits to be parsed by `conventional-commits-parser` or a compatible tool to correctly identify revert information.","package":"conventional-commits-parser","optional":false}],"imports":[{"note":"This package is ESM-only since v5.0.0; CommonJS `require` is not supported.","wrong":"const { filterRevertedCommitsSync } = require('conventional-commits-filter')","symbol":"filterRevertedCommitsSync","correct":"import { filterRevertedCommitsSync } from 'conventional-commits-filter'"},{"note":"This is the asynchronous (Promise-based) version, primarily used with `await`.","wrong":"const { filterRevertedCommits } = require('conventional-commits-filter')","symbol":"filterRevertedCommits","correct":"import { filterRevertedCommits } from 'conventional-commits-filter'"},{"note":"Provides a Transform stream interface for filtering large commit lists efficiently.","wrong":"const { filterRevertedCommitsStream } = require('conventional-commits-filter')","symbol":"filterRevertedCommitsStream","correct":"import { filterRevertedCommitsStream } from 'conventional-commits-filter'"}],"quickstart":{"code":"import { filterRevertedCommitsSync, filterRevertedCommitsStream } from 'conventional-commits-filter';\nimport { pipeline } from 'stream/promises';\nimport { Readable } from 'stream';\n\nconst commits = [\n  {\n    type: 'revert',\n    subject: 'feat(): amazing new module',\n    body: 'This reverts commit 56185b7356766d2b30cfa2406b257080272e0b7a.\\n',\n    revert: { hash: '56185b7356766d2b30cfa2406b257080272e0b7a' },\n    hash: '789d898b5f8422d7f65cc25135af2c1a95a125ac'\n  },\n  {\n    type: 'feat',\n    subject: 'amazing new module',\n    hash: '56185b7356766d2b30cfa2406b257080272e0b7a'\n  },\n  {\n    type: 'feat',\n    subject: 'new feature',\n    hash: '815a3f0717bf1dfce007bd076420c609504edcf3'\n  }\n];\n\n// Synchronous usage\nconst filteredSync = filterRevertedCommitsSync(commits);\nconsole.log('Synchronous filtered commits:', filteredSync.map(c => c.subject));\n\n// Stream usage (for larger datasets)\nconst commitStream = Readable.from(commits, { objectMode: true });\nconst filteredStream = commitStream.pipe(filterRevertedCommitsStream());\n\n(async () => {\n  const results = [];\n  for await (const chunk of filteredStream) {\n    results.push(chunk);\n  }\n  console.log('Stream filtered commits:', results.map(c => c.subject));\n})();","lang":"javascript","description":"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."},"warnings":[{"fix":"Migrate your project to use ESM imports (`import ... from 'package'`) and ensure your `package.json` specifies `\"type\": \"module\"` or uses `.mjs` file extensions.","message":"Version 5.0.0 and above are pure ESM (ECMAScript Modules) and no longer support CommonJS `require()`. You must use `import` statements.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Upgrade your Node.js runtime to version 18 or higher to ensure compatibility and leverage modern JavaScript features.","message":"Node.js version requirement has been updated to `^18.0.0 || >=20.0.0`.","severity":"breaking","affected_versions":">=5.0.0"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `const filter = require('conventional-commits-filter')` to `import { filterRevertedCommitsSync } from 'conventional-commits-filter'`.","cause":"Attempting to use `require()` to import an ESM-only package.","error":"ReferenceError: require is not defined"},{"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).","cause":"Node.js detected a CommonJS `require()` call trying to load an ES module.","error":"ERR_REQUIRE_ESM"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}