{"id":13739402,"url":"https://github.com/unifiedjs/unified-diff","last_synced_at":"2025-04-28T11:47:20.239Z","repository":{"id":57386192,"uuid":"67618885","full_name":"unifiedjs/unified-diff","owner":"unifiedjs","description":"plugin to ignore unrelated CI messages","archived":false,"fork":false,"pushed_at":"2023-08-30T11:42:27.000Z","size":118,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-19T02:36:09.826Z","etag":null,"topics":["diff","difference","travis","unified","unifiedjs"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","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/unifiedjs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"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},"funding":{"github":"unifiedjs","open_collective":"unified"}},"created_at":"2016-09-07T15:19:23.000Z","updated_at":"2024-08-01T16:32:19.000Z","dependencies_parsed_at":"2022-09-14T17:02:11.308Z","dependency_job_id":"dc0f9548-76b4-4a55-b5a6-a2e02f575762","html_url":"https://github.com/unifiedjs/unified-diff","commit_stats":{"total_commits":88,"total_committers":2,"mean_commits":44.0,"dds":"0.022727272727272707","last_synced_commit":"c174e4df726138eaabefec529a032b0deec93a0f"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unifiedjs%2Funified-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unifiedjs%2Funified-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unifiedjs%2Funified-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unifiedjs%2Funified-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unifiedjs","download_url":"https://codeload.github.com/unifiedjs/unified-diff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251284903,"owners_count":21564692,"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":["diff","difference","travis","unified","unifiedjs"],"created_at":"2024-08-03T04:00:33.636Z","updated_at":"2025-04-28T11:47:20.201Z","avatar_url":"https://github.com/unifiedjs.png","language":"JavaScript","readme":"# unified-diff\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n**[unified][]** plugin to ignore unrelated messages in GitHub Actions and\nTravis.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`unified().use(unifiedDiff)`](#unifieduseunifieddiff)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a [unified][] plugin to ignore unrelated lint messages in a CI.\n\n**unified** is a project that transforms content with abstract syntax trees\n(ASTs).\n**vfile** is the virtual file interface used in unified which manages messages.\nThis is a unified plugin that filters messages on the vfile.\n\n## When should I use this?\n\nYou can use this plugin when you are dealing with a large, existing project.\n\nUsing tools that check whether things follow a style guide is typically very\nuseful.\nHowever, it can be hard to start using something in a large existing project.\nThis plugin helps, because it ignores messages that occur in lines that are not\ntouched by a PR in a CI.\nWhen this plugin is used outside of a supported CIs, it doesn’t do anything.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install unified-diff\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport unifiedDiff from 'https://esm.sh/unified-diff@5'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import unifiedDiff from 'https://esm.sh/unified-diff@5?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay our document `example.md` contains:\n\n```markdown\nThis is an an example.\n```\n\n\u003e 👉 **Note**: `an an` is a typo.\n\n…and our module `example.js` looks as follows:\n\n```js\nimport process from 'node:process'\nimport remarkParse from 'remark-parse'\nimport remarkRetext from 'remark-retext'\nimport remarkStringify from 'remark-stringify'\nimport retextEnglish from 'retext-english'\nimport retextIndefiniteArticle from 'retext-indefinite-article'\nimport retextRepeatedWords from 'retext-repeated-words'\nimport {read} from 'to-vfile'\nimport {unified} from 'unified'\nimport unifiedDiff from 'unified-diff'\nimport {reporter} from 'vfile-reporter'\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(\n    remarkRetext,\n    unified()\n      .use(retextEnglish)\n      .use(retextRepeatedWords)\n      .use(retextIndefiniteArticle)\n  )\n  .use(remarkStringify)\n  .use(unifiedDiff)\n  .process(await read('example.md'))\n\nconsole.error(reporter(file))\nprocess.exitCode = file.messages.length \u003e 0 ? 1 : 0\n```\n\n…and our Travis configuration `.travis.yml` contains:\n\n```yml\n# …\nscript:\n- npm test\n- node example.js\n# …\n```\n\n\u003e 👉 **Note**: an equivalent GH Actions workflow file is also supported.\n\nThen, say someone creates a PR which adds the following diff:\n\n```diff\ndiff --git a/example.md b/example.md\nindex 360b225..5a96b86 100644\n--- a/example.md\n+++ b/example.md\n@@ -1 +1,3 @@\n This is an an example.\n+\n+Some more more text. A error.\n```\n\n\u003e 👉 **Note**: `more more` and `A` before `error` are typos.\n\nWhen run in CI, we’ll see the following printed on **stderr**(4).\n\n```txt\nexample.md\n   3:6-3:15  warning  Expected `more` once, not twice   retext-repeated-words      retext-repeated-words\n  3:22-3:23  warning  Use `An` before `error`, not `A`  retext-indefinite-article  retext-indefinite-article\n\n⚠ 2 warnings\n```\n\n\u003e 👉 **Note**: `an an` on L1 is not included because it’s unrelated to this PR.\n\nThe build exits with `1` as there are messages, thus failing CI.\nThe user sees this and amends the PR to the following:\n\n```diff\ndiff --git a/example.md b/example.md\nindex 360b225..5a96b86 100644\n--- a/example.md\n+++ b/example.md\n@@ -1 +1,3 @@\n This is an an example.\n+\n+Some more text. An error.\n```\n\nThis time our lint task exits successfully, even though L1 would normally emit\nan error, but it’s unrelated to the PR.\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`unifiedDiff`][api-unified-diff].\n\n### `unified().use(unifiedDiff)`\n\nIgnore unrelated messages in GitHub Actions and Travis.\n\nThere are no options.\nIf there’s a `TRAVIS_COMMIT_RANGE`, `GITHUB_BASE_REF` and `GITHUB_HEAD_REF`, or\n`GITHUB_SHA` environment variable, then this plugin runs, otherwise it does\nnothing.\n\n###### To do\n\n*   [ ] Add support for other CIs (ping if you want to work on this)\n*   [ ] Add non-CI support (I’m not sure how though)\n\nPRs welcome!\n\n###### Returns\n\nTransform ([`Transformer`][transformer]).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `unified-diff@^5`,\ncompatible with Node.js 16.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`unifiedjs/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/unifiedjs/unified-diff/workflows/main/badge.svg\n\n[build]: https://github.com/unifiedjs/unified-diff/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/unifiedjs/unified-diff.svg\n\n[coverage]: https://codecov.io/github/unifiedjs/unified-diff\n\n[downloads-badge]: https://img.shields.io/npm/dm/unified-diff.svg\n\n[downloads]: https://www.npmjs.com/package/unified-diff\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/unifiedjs/unified/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[health]: https://github.com/unifiedjs/.github\n\n[contributing]: https://github.com/unifiedjs/.github/blob/main/contributing.md\n\n[support]: https://github.com/unifiedjs/.github/blob/main/support.md\n\n[coc]: https://github.com/unifiedjs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[unified]: https://github.com/unifiedjs/unified\n\n[transformer]: https://github.com/unifiedjs/unified#transformer\n\n[api-unified-diff]: #unifieduseunifieddiff\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["Projects"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funifiedjs%2Funified-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funifiedjs%2Funified-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funifiedjs%2Funified-diff/lists"}