npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-diff

v2.1.6

Published

Run ESLint on your changes only

Downloads

603,382

Readme

eslint-plugin-diff

npm codecov

Lint what changed, not the entire codebase. eslint-plugin-diff keeps feedback focused by filtering ESLint output to changed lines.

Why this matters

  • Focused feedback: keep lint output tied to changed code.
  • Safer lint upgrades: avoid being blocked by legacy violations in untouched files.
  • Better developer flow: reduce noise while enforcing existing lint rules.

Quick start

Install

npm install --save-dev eslint eslint-plugin-diff

Flat config (ESLint 9+)

import diff from "eslint-plugin-diff";

export default [
  // ...your existing config
  ...diff.configs["flat/diff"],
];

Legacy config (.eslintrc.*)

{
  "extends": ["plugin:diff/diff"]
}

What it does and how it works

This plugin does not provide lint rules. It provides ESLint processors and preset configs.

Behavior:

  1. It computes changed files from git diff --name-only.
  2. It skips unchanged files in processor preprocess (performance optimization).
  3. It filters lint messages in postprocess to changed line ranges from diff hunks.
  4. Untracked files are treated as changed, so their messages are not filtered out.

Modes

| Mode | Legacy config | Flat config | Typical use | | -------- | -------------------- | ------------------------ | ---------------------------------------- | | diff | plugin:diff/diff | configs["flat/diff"] | Local dev against working tree changes | | ci | plugin:diff/ci | configs["flat/ci"] | PR CI diff-only in CI, full lint locally | | staged | plugin:diff/staged | configs["flat/staged"] | Pre-commit staged-only workflows |

Important staged caveat: if a file has unstaged changes, the plugin emits a fatal message: <file> has unstaged changes. Please stage or remove the changes.

Environment variables and CI autodetection

ESLINT_PLUGIN_DIFF_COMMIT

Sets diff base commit-ish. Default: HEAD.

ESLINT_PLUGIN_DIFF_COMMIT="origin/main" npx eslint --max-warnings=0 .

CI

ci mode behavior:

  • CI set: active diff filtering.
  • CI not set: no-op processor (lint everything).

If CI is set and ESLINT_PLUGIN_DIFF_COMMIT is not set, the plugin attempts provider-based target branch detection and fetches from origin before diffing.

VSCODE_PID

When set, the plugin can refresh the initial diff snapshot once to avoid delayed diagnostics in editor workflows.

Recipes

Local diff vs default base (HEAD)

npx eslint --max-warnings=0 .

Local diff vs main

ESLINT_PLUGIN_DIFF_COMMIT="origin/main" npx eslint --max-warnings=0 .

Pre-commit staged-only

Use plugin:diff/staged or configs["flat/staged"].

PR CI with autodetect (ci mode)

Use plugin:diff/ci or configs["flat/ci"] and run ESLint normally in CI.

PR CI with explicit base

git fetch --quiet origin main
ESLINT_PLUGIN_DIFF_COMMIT="main" npx eslint --max-warnings=0 .

Compose with another processor (for example Vue)

When a file type needs another processor, compose it with diff instead of overriding one processor with another.

import diffPlugin from "eslint-plugin-diff";
import vuePlugin from "eslint-plugin-vue";

const vueProcessor = vuePlugin.processors.vue ?? vuePlugin.processors[".vue"];

export default [
  ...vuePlugin.configs["flat/recommended"],
  ...diffPlugin.configs["flat/diff"].map((config) => ({
    ...config,
    ignores: ["**/*.vue"],
  })),
  {
    files: ["**/*.vue"],
    processor: diffPlugin.composeProcessor(vueProcessor, "diff"),
  },
];

Compatibility and trade-offs

  • ESLint allows one processor per file. If another integration requires a processor for the same files, compose processors (see recipe above) or scope one of them by file patterns.
  • Diff-only linting is a signal-over-completeness strategy. It can miss issues outside changed lines. Many teams run full lint in scheduled jobs or on protected branches.

Troubleshooting

“Too many CI providers found (...)”

Set ESLINT_PLUGIN_DIFF_COMMIT explicitly.

<file> has unstaged changes. Please stage or remove the changes.

This comes from staged mode with partially staged files.

Editor diagnostics appear late

VSCODE_PID enables a one-time diff refresh path intended to reduce this.

FAQ

Does this replace ESLint rules?

No. Your normal rules stay the same. This plugin changes which files/lines can surface diagnostics.

Does ci mode always filter diffs?

No. Outside CI it is intentionally a no-op so local linting stays complete.

License

MIT. See LICENSE.md.