{"id":17398433,"url":"https://github.com/vweevers/remark-common-changelog","last_synced_at":"2025-04-30T05:22:09.069Z","repository":{"id":40574882,"uuid":"427345337","full_name":"vweevers/remark-common-changelog","owner":"vweevers","description":"Lint or fix a changelog written in markdown, following Common Changelog.","archived":false,"fork":false,"pushed_at":"2024-10-08T20:47:07.000Z","size":86,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T01:58:22.079Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vweevers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-12T12:04:02.000Z","updated_at":"2024-10-08T20:47:11.000Z","dependencies_parsed_at":"2024-04-04T12:27:16.113Z","dependency_job_id":"101dd439-79b0-4e70-ba22-c7344ac03ea2","html_url":"https://github.com/vweevers/remark-common-changelog","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fremark-common-changelog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fremark-common-changelog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fremark-common-changelog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fremark-common-changelog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/remark-common-changelog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251645984,"owners_count":21620846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-16T14:56:23.784Z","updated_at":"2025-04-30T05:22:09.050Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# remark-common-changelog\n\n**Lint or fix a changelog written in markdown, following [`Common Changelog`](https://common-changelog.org).** Changelogs should be written by humans, for humans. This tool focuses on helping you do that.\n\n[![npm status](http://img.shields.io/npm/v/remark-common-changelog.svg)](https://www.npmjs.org/package/remark-common-changelog)\n[![Node version](https://img.shields.io/node/v/remark-common-changelog.svg)](https://www.npmjs.org/package/remark-common-changelog)\n[![Test](https://img.shields.io/github/workflow/status/vweevers/remark-common-changelog/Test?label=test)](https://github.com/vweevers/remark-common-changelog/actions/workflows/test.yml)\n[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript\\\u0026logoColor=fff)](https://standardjs.com)\n[![Markdown Style Guide](https://img.shields.io/badge/hallmark-informational?logo=markdown)](https://github.com/vweevers/hallmark)\n[![Common Changelog](https://common-changelog.org/badge.svg)](https://common-changelog.org)\n\n## Usage\n\n_This package is ESM-only._\n\n```js\nimport changelog from 'remark-common-changelog'\nimport vfile from 'to-vfile'\nimport { remark } from 'remark'\n\nremark()\n  .use(changelog)\n  .process(vfile.readSync('CHANGELOG.md'), function (err, file) {\n    if (err) throw err\n    console.log(String(file))\n  })\n```\n\nPair with [`remark-github`](https://github.com/remarkjs/remark-github) for ultimate pleasure. If you're looking for a CLI that includes both, checkout [`hallmark`](https://github.com/vweevers/hallmark), a markdown style guide with linter and automatic fixer.\n\n## Rules\n\n### `title`\n\nChangelog must start with a top-level \"Changelog\" heading. In `fix` mode, it is either added or updated.\n\n### `release-heading-depth`\n\nRelease must start with second-level heading.\n\n### `release-heading`\n\nRelease heading must have the format `\u003cversion\u003e - \u003cdate\u003e`.\n\n### `release-version`\n\nRelease must have a semver-valid version, without `v` prefix. Releases that have no matching git tag are _not_ rejected, to support adding a git tag after updating the changelog.\n\n### `release-version-link`\n\nRelease version must have a link. The destination URL is not linted. In `fix` mode links are automatically inserted (to `https://github.com/OWNER/REPO/releases/tag/$tag`) requiring a nearby `package.json` with a `repository` field. The link is optional for the oldest (last listed) release.\n\n### `release-version-link-reference`\n\nUse a link reference for version link.\n\nValid:\n\n```md\n## [1.0.0] - 2019-08-23\n\n[1.0.0]: https://github.com/vweevers/remark-common-changelog/releases/tag/v1.0.0\n```\n\nInvalid:\n\n```md\n## [1.0.0](https://github.com/vweevers/remark-common-changelog/releases/tag/v1.0.0) - 2019-08-23\n```\n\n### `release-date`\n\nRelease must have a date with format `YYYY-MM-DD`.\n\n### `latest-release-first`\n\nReleases must be sorted latest-first according to semver rules. In `fix` mode, releases are reordered.\n\n### `latest-definition-first`\n\nDefinitions must be sorted latest-first, same as releases. Any additional definitions (that don't describe a release) must be last. In `fix` mode, definitions are reordered.\n\nValid:\n\n```md\n[2.0.0]: https://github.com/vweevers/remark-common-changelog/releases/tag/v2.0.0\n[1.0.0]: https://github.com/vweevers/remark-common-changelog/releases/tag/v1.0.0\n```\n\nInvalid:\n\n```md\n[1.0.0]: https://github.com/vweevers/remark-common-changelog/releases/tag/v1.0.0\n[2.0.0]: https://github.com/vweevers/remark-common-changelog/releases/tag/v2.0.0\n```\n\n### `unique-release`\n\nEach release must have a unique version.\n\n### `no-empty-release`\n\nA release must have content.\n\nIn fix mode, an empty release is filled with a commit log as a leg up. Merge commits are skipped. GitHub merge commits (\"Merge pull request #n\") are used to annotate commits with a PR number (best effort). Squashed GitHub commits that have a default commit description (a list of squashed commits) are converted to sublists.\n\nValid:\n\n```md\n## [2.0.0] - 2019-09-02\n\nfoo\n\n## [1.0.0] - 2019-09-01\n\nbar\n```\n\nInvalid:\n\n```md\n## [2.0.0] - 2019-09-02\n\n## [1.0.0] - 2019-09-01\n```\n\n### `group-heading`\n\nA \"group\" (of changes) must start with a third-level, text-only heading.\n\n### `group-heading-type`\n\nA group heading must be one of Changed, Added, Deprecated, Removed, Fixed, Security.\n\n### `no-empty-group`\n\nA group must not be empty. Invalid:\n\n```md\n### Added\n### Fixed\n```\n\n### `no-uncategorized-changes`\n\nThere should not be a group with heading Uncategorized. This group is added by `remark-common-changelog` if the `fix` option is true and it populates an empty release with commits. This rule then hints that changes should be categorized.\n\n### `filename`\n\nFilename must be `CHANGELOG.md`.\n\nTo support using `remark-common-changelog` in a pipeline that runs on other files too, `remark-common-changelog` ignores files other than `CHANGELOG.md` but it does reject alternative extensions and the alternative names `HISTORY` and `RELEASES`.\n\n## API\n\n### `changelog([options])`\n\nOptions:\n\n- `fix` (boolean): attempt to fix issues\n- `cwd` (string): working directory, defaults to `cwd` of file or `process.cwd()`\n- `pkg` (object): a parsed `package.json`, defaults to reading a nearby `package.json` (starting in `cwd` and then its parent directories)\n- `repository` (string or object): defaults to `repository` field of `pkg`. Used to construct diff URLs.\n- `version` (string): defaults to `version` field of `pkg` or the last tag. Used to identify a new release (anything that's greater than `version` and would normally be rejected in fix mode because it has no git tag yet) to support the workflow of updating a changelog before tagging.\n- `add` (string): add a new release (only if `fix` is true) and populate it with commits. Value must be one of:\n  - A release type: `major`, `minor`, `patch`, `premajor`, `preminor`, `prepatch`, `prerelease`\n    - These take the current version from the semver-latest tag, release or `package.json` (whichever is greatest if found) and bump it\n    - The `major` type bumps the major version (for example `2.4.1 =\u003e 3.0.0`); `minor` and `patch` work the same way.\n    - The `premajor` type bumps the version up to the next major version and down to a prerelease of that major version; `preminor` and `prepatch` work the same way.\n    - The `prerelease` type works the same as `prepatch` if the current version is a non-prerelease. If the current is already a prerelease then it's simply incremented (for example `4.0.0-rc.2` to `4.0.0-rc.3`).\n  - A [semver-valid](https://semver.org/) version like 2.4.0.\n- `commits` (boolean, default `true`, only relevant for `add`): if `false`, don't populate the release with commits.\n- `submodules` (boolean, only relevant for `add`): enable experimental git submodule support. Will collect commits from submodules and list them in the changelog as `\u003cname\u003e: \u003cmessage\u003e`.\n\n#### Notes on `add`\n\nIf the (resulting) version is greater than the current version then commits will be taken from the semver-latest tag until HEAD. I.e. documenting a new release before it's git-tagged. If the version matches an existing tag then a release will be inserted at the appriopriate place, populated with commits between that version's tag and the one before it. I.e. documenting a past release after it's git-tagged. If the version equals `0.0.1`, `0.1.0` or `1.0.0` and zero versions exist, then a [notice](https://common-changelog.org/#23notice) will be inserted (rather than commits) containing the text `:seedling: Initial release.`.\n\nWorks best on a linear git history without merge commits. If `remark-common-changelog` encounters other tags in the commit range it will stop there and not include further (older) commits.\n\nGit [trailers](https://git-scm.com/docs/git-interpret-trailers) (\"lines that look similar to RFC 822 e-mail headers, at the end of the otherwise free-form part of a commit message\") can provide structured information to the generated changelog. The following trailer keys are supported (case-insensitive):\n\n- `Category`: one of `change`, `addition`, `removal`, `fix`, or `none`. If `none` then the commit will be excluded from the changelog. If not present then the change will be listed under Uncategorized and will require manual categorization.\n- `Notice`: a [notice](https://common-changelog.org/#23-notice) for the release. If multiple commits contain a notice, they will be joined as sentences (i.e. ending with a dot) separated by a space.\n- `Ref`, `Refs`, `Fixes`, `Closes` or `CVE-ID`: a numeric reference in the form of `#N`, `PREFIX-N` or `CVE-N-N` where `N` is a number and `PREFIX` is at least 2 letters. For example `#123`, `GH-123`, `JIRA-123` or `CVE-2024-123`. Can be repeated, either with multiple trailer lines or by separating references with a comma - e.g. `Ref: #1, #2`. Non-numeric references are ignored.\n- `Co-Authored-By`: co-author in the form of `name \u003cemail\u003e`. Can be repeated.\n\nFor example, the following commit (which has Bob as git author, let's say):\n\n```\nBump math-utils to 4.5.6\n\nRef: JIRA-123\nCategory: change\nCo-Authored-By: Alice \u003calice@example.com\u003e\n```\n\nTurns into:\n\n```md\n## Changed\n\n- Bump math-utils to 4.5.6 (d23ba8f) (JIRA-123) (Bob, Alice)\n```\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install remark-common-changelog\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fremark-common-changelog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Fremark-common-changelog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fremark-common-changelog/lists"}