{"_id":"diff-cover","_rev":"5-13401d7dad5ad2c28fe22aea3d3c1778","name":"diff-cover","dist-tags":{"latest":"2.0.5"},"versions":{"1.1.0":{"name":"diff-cover","version":"1.1.0","keywords":["diff","coverage","code","quality","testing"],"_id":"diff-cover@1.1.0","maintainers":[{"name":"huyaotian88","email":"huyaotian88@qq.com"}],"bin":{"diff-cover":"dist/diff-cover.js","diff-quality":"dist/diff-quality.js"},"dist":{"shasum":"707a33468ddd91f6b445aff19c9c0a8b755a3ee8","tarball":"https://registry.npmjs.org/diff-cover/-/diff-cover-1.1.0.tgz","fileCount":5,"integrity":"sha512-gnc/Y9nlvH1gedOFnKI0jdrMf7YNIHvWZJK9RVyOAzW4/LuhTBgK30PVZVyFx2kFP3ZWGf6ZEHZRyKYm6Wpv9g==","signatures":[{"sig":"MEYCIQDtT7Tb7yBs8uTQ72OflIXyE8CVA7Npq1qSQl9FcZVEhwIhAPT2yff37ij+2d3i+ftqYwuPAxj6JpsHpklsPypffz4J","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":58324},"type":"module","module":"index.ts","shasum":"707a33468ddd91f6b445aff19c9c0a8b755a3ee8","scripts":{"lint":"oxlint --type-aware --type-check","test":"bun test","build":"rolldown -c","format":"oxfmt --write .","lint:fix":"oxlint --fix","build:binary":"bun run scripts/build_release.ts","format:check":"oxfmt --check ."},"_npmUser":{"name":"huyaotian88","email":"huyaotian88@qq.com"},"_integrity":"sha512-gnc/Y9nlvH1gedOFnKI0jdrMf7YNIHvWZJK9RVyOAzW4/LuhTBgK30PVZVyFx2kFP3ZWGf6ZEHZRyKYm6Wpv9g==","_npmVersion":"10.8.3","description":"A Tool to Show Code Coverage for Modified Lines in a Diff","directories":{},"_nodeVersion":"24.3.0","dependencies":{"xpath":"^0.0.34","nunjucks":"^3.2.4","commander":"^14.0.2","jschardet":"^3.1.4","minimatch":"^10.1.1","@iarna/toml":"^2.2.5","highlight.js":"^11.11.1","@xmldom/xmldom":"^0.8.11","@types/nunjucks":"^3.2.6","@types/commander":"^2.12.5","@types/minimatch":"^6.0.0","@types/iarna__toml":"^2.0.5","@types/highlight.js":"^10.1.0"},"_hasShrinkwrap":false,"devDependencies":{"oxfmt":"^0.26.0","oxlint":"^1.41.0","rolldown":"^1.0.0-rc.1","@types/bun":"latest","oxlint-tsgolint":"^0.11.1"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/diff-cover_1.1.0_1769087276798_0.7071142593791464","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"diff-cover","version":"2.0.1","keywords":["code","coverage","diff","quality","testing"],"author":"James Hu <jamesishandsome@github.com>","license":"MIT","_id":"diff-cover@2.0.1","maintainers":[{"name":"huyaotian88","email":"huyaotian88@qq.com"}],"homepage":"https://github.com/jamesishandsome/diff_cover_ts#readme","bugs":{"url":"https://github.com/jamesishandsome/diff_cover_ts/issues"},"bin":{"diff-cover":"dist/diff-cover.js","diff-quality":"dist/diff-quality.js"},"dist":{"shasum":"6c54028d4265f3ea398167a3a3868c760d6e58a3","tarball":"https://registry.npmjs.org/diff-cover/-/diff-cover-2.0.1.tgz","fileCount":7,"integrity":"sha512-52Nr33CdIiC0xQsPqOwVHZuU1ka8Dnpr5Rvrg4pKkfb3plIU3nBjskZJ2iE59X7PPqaOrvSTSsAf22lUGi9gmg==","signatures":[{"sig":"MEQCICq1lFJdEyNmKHK9AiwQ4zzhxV5JqBMpcvYa5SNWDMmjAiB75X4boH8EX18UpdRXhLFE16K8INpiuR7m6a+Es/FB5A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69988},"type":"module","module":"index.ts","shasum":"6c54028d4265f3ea398167a3a3868c760d6e58a3","scripts":{"lint":"oxlint --type-aware --type-check","test":"bun test","build":"rolldown -c","format":"oxfmt --write .","prepare":"husky","lint:fix":"oxlint --fix","build:binary":"bun run scripts/build_release.ts","format:check":"oxfmt --check ."},"_npmUser":{"name":"huyaotian88","email":"huyaotian88@qq.com"},"_integrity":"sha512-52Nr33CdIiC0xQsPqOwVHZuU1ka8Dnpr5Rvrg4pKkfb3plIU3nBjskZJ2iE59X7PPqaOrvSTSsAf22lUGi9gmg==","repository":{"url":"git+https://github.com/jamesishandsome/diff_cover_ts.git","type":"git"},"_npmVersion":"10.8.3","description":"A Tool to Show Code Coverage for Modified Lines in a Diff","directories":{},"lint-staged":{"*":["oxfmt --write"],"*.{js,ts}":["oxlint --fix"]},"_nodeVersion":"24.3.0","dependencies":{"xpath":"^0.0.34","nunjucks":"^3.2.4","commander":"^14.0.2","jschardet":"^3.1.4","minimatch":"^10.1.1","@iarna/toml":"^2.2.5","highlight.js":"^11.11.1","@xmldom/xmldom":"^0.8.11","@types/nunjucks":"^3.2.6","@types/commander":"^2.12.5","@types/minimatch":"^6.0.0","@types/iarna__toml":"^2.0.5","@types/highlight.js":"^10.1.0"},"_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","oxfmt":"^0.26.0","oxlint":"^1.41.0","rolldown":"^1.0.0-rc.1","@types/bun":"latest","lint-staged":"^16.2.7","oxlint-tsgolint":"^0.11.1"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/diff-cover_2.0.1_1769091043080_0.18717173102110696","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"diff-cover","version":"2.0.2","keywords":["code","coverage","diff","quality","testing"],"author":"James Hu <jamesishandsome@github.com>","license":"MIT","_id":"diff-cover@2.0.2","maintainers":[{"name":"huyaotian88","email":"huyaotian88@qq.com"}],"homepage":"https://github.com/jamesishandsome/diff_cover_ts#readme","bugs":{"url":"https://github.com/jamesishandsome/diff_cover_ts/issues"},"bin":{"diff-cover":"dist/diff-cover.js","diff-quality":"dist/diff-quality.js"},"dist":{"shasum":"74347ff559c85b0cd0175e1ee6a338172798a7b7","tarball":"https://registry.npmjs.org/diff-cover/-/diff-cover-2.0.2.tgz","fileCount":7,"integrity":"sha512-SLSyg0MRCbx2E/y8/ZlLvZzjr8W/6zPrHK+1NDMEBFP76549UccikPBQ+uQ0Dv0fCbnuKPQLQbYTJIElyAIlRQ==","signatures":[{"sig":"MEYCIQD4cKG6X+NeMlmqrJK47puS1CQi7N7GvRCSrwe3ydaaiwIhAIa1XT0GLwjgawBrAaqHwkxFsuMB4CCTEbBJXhMzLKhS","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":81168},"type":"module","module":"index.ts","shasum":"74347ff559c85b0cd0175e1ee6a338172798a7b7","scripts":{"lint":"oxlint --type-aware --type-check","test":"bun test","build":"bun run scripts/generate_templates.ts && rolldown -c","format":"oxfmt --write .","prepare":"husky","lint:fix":"oxlint --fix","build:binary":"bun run scripts/generate_templates.ts && bun run scripts/build_release.ts","format:check":"oxfmt --check ."},"_npmUser":{"name":"huyaotian88","email":"huyaotian88@qq.com"},"_integrity":"sha512-SLSyg0MRCbx2E/y8/ZlLvZzjr8W/6zPrHK+1NDMEBFP76549UccikPBQ+uQ0Dv0fCbnuKPQLQbYTJIElyAIlRQ==","repository":{"url":"git+https://github.com/jamesishandsome/diff_cover_ts.git","type":"git"},"_npmVersion":"10.8.3","description":"A Tool to Show Code Coverage for Modified Lines in a Diff","directories":{},"lint-staged":{"*":["oxfmt --write"],"*.{js,ts}":["oxlint --fix"]},"_nodeVersion":"24.3.0","dependencies":{"xpath":"^0.0.34","nunjucks":"^3.2.4","commander":"^14.0.2","jschardet":"^3.1.4","minimatch":"^10.1.1","@iarna/toml":"^2.2.5","highlight.js":"^11.11.1","@xmldom/xmldom":"^0.8.11","@types/nunjucks":"^3.2.6","@types/commander":"^2.12.5","@types/minimatch":"^6.0.0","@types/iarna__toml":"^2.0.5","@types/highlight.js":"^10.1.0"},"_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","oxfmt":"^0.26.0","oxlint":"^1.41.0","rolldown":"^1.0.0-rc.1","@types/bun":"latest","lint-staged":"^16.2.7","oxlint-tsgolint":"^0.11.1"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/diff-cover_2.0.2_1769532121642_0.68330164039537","host":"s3://npm-registry-packages-npm-production"}},"2.0.4":{"name":"diff-cover","version":"2.0.4","keywords":["code","coverage","diff","quality","testing"],"author":{"name":"James Hu","email":"jamesishandsome@github.com"},"license":"MIT","_id":"diff-cover@2.0.4","maintainers":[{"name":"huyaotian88","email":"huyaotian88@qq.com"}],"homepage":"https://github.com/jamesishandsome/diff_cover_ts#readme","bugs":{"url":"https://github.com/jamesishandsome/diff_cover_ts/issues"},"bin":{"diff-cover":"dist/diff-cover.js","diff-quality":"dist/diff-quality.js"},"dist":{"shasum":"21317cd092d34badda09a49574942e883ee5cf66","tarball":"https://registry.npmjs.org/diff-cover/-/diff-cover-2.0.4.tgz","fileCount":7,"integrity":"sha512-jmwwF4Ir+8a3lxcDRRYNBz2yR6pK9vj54evPbeRWy4MVjp5ckhoNivh09AlpTqqcWp7Qkul6zcpZyzJ6veHIww==","signatures":[{"sig":"MEUCIQCP5l6JrngvxMby/K4/5CKCU6Y2j1vDJkP/r1HL/j45OQIgGLLoNu9KJ2/sdHf4ejgiy/sGVGIDkeNepe9VDWVYxVQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":81134},"type":"module","module":"index.ts","gitHead":"0af02159e6575338b59c31a87d13a3144d82f5b5","scripts":{"lint":"oxlint --type-aware --type-check","test":"bun test","build":"bun run scripts/generate_templates.ts && rolldown -c","format":"oxfmt --write .","prepare":"husky","lint:fix":"oxlint --fix","build:binary":"bun run scripts/generate_templates.ts && bun run scripts/build_release.ts","format:check":"oxfmt --check ."},"_npmUser":{"name":"huyaotian88","email":"huyaotian88@qq.com"},"repository":{"url":"git+https://github.com/jamesishandsome/diff_cover_ts.git","type":"git"},"_npmVersion":"10.8.2","description":"A Tool to Show Code Coverage for Modified Lines in a Diff","directories":{},"lint-staged":{"*":["oxfmt --write"],"*.{js,ts}":["oxlint --fix"]},"_nodeVersion":"20.20.0","dependencies":{"xpath":"^0.0.34","nunjucks":"^3.2.4","commander":"^14.0.2","jschardet":"^3.1.4","minimatch":"^10.1.1","@iarna/toml":"^2.2.5","highlight.js":"^11.11.1","@xmldom/xmldom":"^0.8.11","@types/nunjucks":"^3.2.6","@types/commander":"^2.12.5","@types/minimatch":"^6.0.0","@types/iarna__toml":"^2.0.5","@types/highlight.js":"^10.1.0"},"_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","oxfmt":"^0.26.0","oxlint":"^1.41.0","rolldown":"^1.0.0-rc.1","@types/bun":"latest","lint-staged":"^16.2.7","oxlint-tsgolint":"^0.11.1"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/diff-cover_2.0.4_1769532916915_0.9375813122929613","host":"s3://npm-registry-packages-npm-production"}},"2.0.5":{"name":"diff-cover","version":"2.0.5","description":"A Tool to Show Code Coverage for Modified Lines in a Diff","keywords":["code","coverage","diff","quality","testing"],"homepage":"https://github.com/jamesishandsome/diff_cover_ts#readme","bugs":{"url":"https://github.com/jamesishandsome/diff_cover_ts/issues"},"license":"MIT","author":{"name":"James Hu","email":"jamesishandsome@github.com"},"repository":{"type":"git","url":"git+https://github.com/jamesishandsome/diff_cover_ts.git"},"bin":{"diff-cover":"dist/diff-cover.js","diff-quality":"dist/diff-quality.js"},"type":"module","module":"index.ts","scripts":{"test":"bun test","lint":"oxlint --type-aware --type-check","lint:fix":"oxlint --fix","format":"oxfmt --write .","format:check":"oxfmt --check .","build:binary":"bun run scripts/generate_templates.ts && bun run scripts/build_release.ts","build":"bun run scripts/generate_templates.ts && rolldown -c","prepare":"husky"},"dependencies":{"@iarna/toml":"^2.2.5","@types/commander":"^2.12.5","@types/highlight.js":"^10.1.0","@types/iarna__toml":"^2.0.5","@types/minimatch":"^6.0.0","@types/nunjucks":"^3.2.6","@xmldom/xmldom":"^0.8.11","commander":"^14.0.2","highlight.js":"^11.11.1","jschardet":"^3.1.4","minimatch":"^10.1.1","nunjucks":"^3.2.4","xpath":"^0.0.34"},"devDependencies":{"@types/bun":"latest","husky":"^9.1.7","lint-staged":"^16.2.7","oxfmt":"^0.26.0","oxlint":"^1.41.0","oxlint-tsgolint":"^0.11.1","rolldown":"^1.0.0-rc.1"},"peerDependencies":{"typescript":"^5"},"lint-staged":{"*":["oxfmt --write"],"*.{js,ts}":["oxlint --fix"]},"_id":"diff-cover@2.0.5","gitHead":"ff0a265577953ef361db2dff2f2a3f020b42118e","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-lgiCSPZ90fABeUsTwH4m0IKjEro8BhotQCbQECtofBGvC9f7ov3LjBFNokL9ygQdXmsHoz/qfSk09VheboNnhA==","shasum":"efcd86bcbef980b36c72b2682de2196bd07716b3","tarball":"https://registry.npmjs.org/diff-cover/-/diff-cover-2.0.5.tgz","fileCount":7,"unpackedSize":81090,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCPFgOORyqp/tSyJwZzFYKgDp0Ifz1Lqedtb684zAY4tAIhAMO9o7GlkfsHMfG1+KiuHWt9FZBCXC0zZ+ZOwe/mImow"}]},"_npmUser":{"name":"huyaotian88","email":"huyaotian88@qq.com"},"directories":{},"maintainers":[{"name":"huyaotian88","email":"huyaotian88@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/diff-cover_2.0.5_1769533228276_0.7156644325312234"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-22T13:07:56.797Z","modified":"2026-01-27T17:00:28.525Z","1.1.0":"2026-01-22T13:07:56.950Z","2.0.1":"2026-01-22T14:10:43.209Z","2.0.2":"2026-01-27T16:42:01.830Z","2.0.4":"2026-01-27T16:55:17.070Z","2.0.5":"2026-01-27T17:00:28.426Z"},"bugs":{"url":"https://github.com/jamesishandsome/diff_cover_ts/issues"},"author":{"name":"James Hu","email":"jamesishandsome@github.com"},"license":"MIT","homepage":"https://github.com/jamesishandsome/diff_cover_ts#readme","keywords":["code","coverage","diff","quality","testing"],"repository":{"type":"git","url":"git+https://github.com/jamesishandsome/diff_cover_ts.git"},"description":"A Tool to Show Code Coverage for Modified Lines in a Diff","maintainers":[{"name":"huyaotian88","email":"huyaotian88@qq.com"}],"readme":"# diff-cover-ts\n\n<div align=\"center\">\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![npm version](https://img.shields.io/npm/v/diff-cover.svg)](https://www.npmjs.com/package/diff-cover)\n[![npm downloads](https://img.shields.io/npm/dm/diff-cover.svg)](https://www.npmjs.com/package/diff-cover)\n[![CI](https://github.com/jamesishandsome/diff_cover_ts/actions/workflows/ci.yml/badge.svg)](https://github.com/jamesishandsome/diff_cover_ts/actions/workflows/ci.yml)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)\n[![Bun](https://img.shields.io/badge/Bun-1.0-orange.svg)](https://bun.sh/)\n[![Code Style](https://img.shields.io/badge/code%20style-oxlint-green)](https://github.com/oxc-project/oxc)\n\n**A high-performance TypeScript port of the [diff_cover](https://github.com/Bachmann1234/diff_cover) tool.**\n\n_Automatically find lines of code in your git diff that are missing test coverage or quality checks._\n\n[English](./README.md) | [简体中文](./README_zh.md)\n\n</div>\n\n---\n\n## 📖 Table of Contents\n\n- [Introduction](#-introduction)\n- [Features](#-features)\n- [Installation](#-installation)\n- [Usage](#-usage)\n  - [Diff Cover](#diff-cover)\n  - [Diff Quality](#diff-quality)\n- [Configuration](#-configuration)\n- [Development](#-development)\n- [License](#-license)\n\n## 🚀 Introduction\n\n`diff_cover_ts` helps you maintain high code quality by focusing on what matters most: **the code you just changed**. Instead of failing builds because of low legacy coverage, this tool ensures that every new commit meets your quality standards.\n\nIt works by comparing your current branch with a base branch (e.g., `origin/main`) and reporting coverage/quality gaps only for the modified lines.\n\n## ✨ Features\n\n- **🎯 Precision Coverage**: Report code coverage only for modified lines in your git diff.\n- **🛡️ Quality Gate**: Enforce linting checks only on changed code.\n- **🤖 Auto-Configuration**: Seamlessly detects `vite.config.ts/js` or `vitest.config.ts/js` to find coverage reports.\n- **📊 Multi-Format Support**: Compatible with `lcov`, `cobertura`, `clover`, `jacoco`, and generic XML reports.\n- **⚡ Git Integration**: Built-in git history analysis to identify modified lines accurately.\n- **🚫 Fail-Under Checks**: Set thresholds to fail CI/CD pipelines if coverage/quality is too low.\n\n## 📦 Installation\n\n```bash\n# Using npm (Global)\nnpm install -g diff-cover\n\n# Using Bun (Global)\nbun add -g diff-cover\n\n# Using npm (Dev Dependency)\nnpm install diff-cover --save-dev\n```\n\n## 🛠 Usage\n\n### Diff Cover\n\nAutomatically identify lines in your diff that lack test coverage.\n\n#### ⚡ Auto Configuration (Recommended)\n\nIf you are using **Vite** or **Vitest**, simply run:\n\n```bash\ndiff-cover\n```\n\nThe tool will intelligently parse your configuration files to locate the coverage report and determine the format.\n\n#### 📝 Manual Usage\n\nYou can explicitly specify the coverage report files:\n\n```bash\ndiff-cover coverage/lcov.info\n# OR\ndiff-cover coverage/cobertura.xml\n```\n\n#### ⚙️ Options\n\n| Option                      | Description                                                  | Default       |\n| :-------------------------- | :----------------------------------------------------------- | :------------ |\n| `--compare-branch <branch>` | Branch to compare against                                    | `origin/main` |\n| `--fail-under <score>`      | Returns a non-zero exit code if coverage is below this value | `0`           |\n| `--show-uncovered`          | Print uncovered lines to the console                         | `false`       |\n| `--expand-coverage-report`  | Append missing lines based on previous line hits             | `false`       |\n| `--ignore-staged`           | Ignore staged changes in the diff                            | `false`       |\n| `--ignore-unstaged`         | Ignore unstaged changes in the diff                          | `false`       |\n| `--include-untracked`       | Include untracked files in the analysis                      | `false`       |\n| `--exclude <patterns...>`   | Exclude files matching glob patterns                         | `[]`          |\n| `--include <patterns...>`   | Include files matching glob patterns                         | `[]`          |\n| `--html-report <file>`      | Generate an HTML report at the specified path                | `null`        |\n| `--json-report <file>`      | Generate a JSON report at the specified path                 | `null`        |\n\n---\n\n### Diff Quality\n\nRun static analysis tools and report violations only on modified lines.\n\n```bash\ndiff-quality report.txt --violations <driver>\n```\n\n#### 🔌 Supported Drivers\n\n- `eslint`\n- `pylint`\n- `flake8`\n- `shellcheck`\n- `cppcheck`\n- `checkstyle`\n- `findbugs`\n\n#### ⚙️ Options\n\n| Option                      | Description                                                  | Default       |\n| :-------------------------- | :----------------------------------------------------------- | :------------ |\n| `--compare-branch <branch>` | Branch to compare against                                    | `origin/main` |\n| `--fail-under <score>`      | Returns a non-zero exit code if quality score is below value | `0`           |\n| `--include-untracked`       | Include untracked files                                      | `false`       |\n| `--exclude <patterns...>`   | Exclude files matching glob patterns                         | `[]`          |\n| `--html-report <file>`      | Generate an HTML report at the specified path                | `null`        |\n\n## 💻 Development\n\n### Setup\n\n```bash\n# Install dependencies\nbun install\n```\n\n### Testing\n\n```bash\n# Run test suite\nbun test\n\n# Run tests with coverage\nbun test --coverage\n```\n\n### Code Quality\n\nWe use `oxlint` for linting and `oxfmt` for formatting. Pre-commit hooks via `husky` ensure code quality.\n\n```bash\n# Lint code\nbun run lint\n\n# Format code\nbun run format\n```\n\n## 📄 License\n\nThis project is licensed under the MIT License.\n","readmeFilename":"README.md"}