Registry / testing / eslint-plugin-diff

eslint-plugin-diff

JSON →
library2.1.7jsnpmunverified

ESLint plugin that filters lint output to only show errors on changed lines of code. Version 2.1.7 actively maintained, semver releases. Differentiators: works with both flat config (ESLint 9+) and legacy config, supports multiple modes (diff, ci, staged), includes CI autodetection with provider-based target branch detection. Ships TypeScript types. Requires eslint >=6.7.0 and node >=14.0.0. Does not provide custom rules, only processors and config presets.

npm install eslint-plugin-diff
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-DIFF
E
eslint-plugin-diff
testingjavascriptv2.1.7
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.

default export
import diff from 'eslint-plugin-diff'
const diff = require('eslint-plugin-diff')
ESM default import; package ships TypeScript types.
flat config preset
diff.configs["flat/diff"]
diff.configs.diff
Access via bracket notation with flat/ prefix; 'diff' key does not exist directly.
legacy config preset
"extends": ["plugin:diff/diff"]
"extends": ["diff/diff"]
Must include 'plugin:' prefix for ESLint to resolve plugin scoped configs.

Flat config example with eslint-plugin-diff in diff mode, filtering lint output to changed lines.

import diff from 'eslint-plugin-diff'; export default [ { files: ['**/*.js', '**/*.ts'], rules: { semi: 'error' } }, ...diff.configs['flat/diff'] ];
Debug
Known issues
gotchaFor staged mode, files with unstaged changes will emit a fatal error and block linting.
fix
Stage or revert unstaged changes before running ESLint in staged mode.
affects: >=2.0.0
breakingv2.0.0 migrated from legacy config to flat config internally; old require() usage may break.
fix
Use ESM import instead of require; update config to use configs['flat/*'] if on ESLint 9.
affects: >=2.0.0
gotchaIn CI mode, if ESLINT_PLUGIN_DIFF_COMMIT is not set, the plugin fetches from origin, which may fail in shallow clone environments.
fix
Explicitly set ESLINT_PLUGIN_DIFF_COMMIT to a commit you have locally, or ensure full git history.
affects: >=2.0.0
deprecatedESLint <6.7.0 is no longer supported as of v2.0.0.
fix
Upgrade eslint to >=6.7.0.
affects: >=2.0.0
gotchaThe plugin uses git diff internally; if git is not installed or the project is not a git repo, it throws an error.
fix
Run lint only in a git repository with git installed.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'eslint-plugin-diff'
Package not installed or not in node_modules.
fix
Run 'npm install --save-dev eslint-plugin-diff'.
Configuration for rule 'diff/diff' is invalid
Using the plugin name 'diff' in config but plugin not registered.
fix
Add 'plugins: [diff]' or use 'plugin:diff/diff' extends preset.
fatal: not a git repository (or any of the parent directories): .git
eslint-plugin-diff requires a git repository to compute diff.
fix
Initialize a git repository with 'git init' or run ESLint on a git repo.
Upgrade
Version history
2.1.7latest on npm
Audit
Dependencies
eslintoptionalpeer dependency for plugin integration
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-diff — npm install eslint-plugin-diff · libregistry