explaingit

lint-staged/lint-staged

Analysis updated 2026-06-24 · repo last pushed 2026-05-16

14,623JavaScriptAudience · developerComplexity · 2/5MaintainedSetup · easy

TLDR

Command-line tool that runs linters and formatters only against git-staged files in a pre-commit hook, so checks stay fast and focused on the changes about to be committed.

Mindmap

mindmap
  root((lint-staged))
    Inputs
      Staged files
      Config patterns
      Pre-commit hook
    Outputs
      Lint reports
      Auto-fixed files
      Exit status
    Use Cases
      Run ESLint on staged JS
      Run Prettier on staged JSON
      Block bad commits
    Tech Stack
      JavaScript
      Node
      Husky
      Git
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Run ESLint and Prettier only on the files staged for a commit so checks finish in seconds

USE CASE 2

Block commits that introduce lint errors by wiring lint-staged into a Husky pre-commit hook

USE CASE 3

Auto-fix formatting on JSON, Markdown, and JS as part of the commit step

USE CASE 4

Share the same pre-commit checks with a team by committing the lint-staged config

What is it built with?

JavaScriptNodeHuskyGit

How does it compare?

lint-staged/lint-stagedmyliang/x-spreadsheetyonggekkk/cloudflare-vless-trojan
Stars14,62314,61114,610
LanguageJavaScriptJavaScriptJavaScript
Last pushed2026-05-162026-05-20
MaintenanceMaintainedMaintained
Setup difficultyeasyeasymoderate
Complexity2/53/54/5
Audiencedeveloperdeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

You still need to wire up a pre-commit hook, usually via Husky, since lint-staged itself does not install one.

In plain English

lint-staged is a small command-line program for JavaScript projects that runs code-quality tasks like formatters and linters only against the files a developer has staged for the next git commit. The README's pitch is that running tools across an entire project is slow and noisy, while what you actually care about right before committing is just the files about to enter the repository. Lint-staged narrows the scope to those files so the checks finish quickly and complain only about changes you made. The install path described in the README has four steps. First, add the package as a dev dependency with npm install --save-dev lint-staged. Second, set up a pre-commit git hook that calls lint-staged. The README recommends Husky, a popular helper for configuring git hooks, and links to the git documentation. Third, install the tools you want to run, such as ESLint for finding JavaScript problems or Prettier for formatting. Fourth, write a small piece of configuration that maps file patterns to commands, the README's example, {"*.js": "eslint"}, tells lint-staged to run ESLint on every staged JavaScript file. The configuration and Husky setup go into source control so the rest of the team gets the same checks. A sample run is shown near the top. When git commit is invoked, lint-staged first stashes a backup of the original state so any failed task can be undone safely. It then walks the configured patterns, applying prettier --write to staged JSON and Markdown files and eslint --fix to staged JS files, while skipping patterns that have no matching files. After the tasks finish, it updates the git index and cleans up temporary files. The README marks this stash-and-restore behavior as a caution, since lint-staged is modifying the repository on the user's behalf. A long list of command-line flags follows. Notable ones include --allow-empty for cases where the tasks themselves undo all staged changes, --concurrent for controlling whether tasks run in parallel or one at a time, --config for pointing at a non-default config file or even piping config in through standard input, --diff and --diff-filter for overriding which files git reports as staged, --fail-on-changes to make the program exit with a failure when tasks edit tracked files, and --debug for verbose logs that include staged file lists, commands, and binary locations. The README also lists older blog posts and conference talks about lint-staged, points to a separate MIGRATION.md for breaking changes, and mentions a simpler shell-only variant called lint-staged.sh for people who want to check staged files without auto-fixing them. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Give me a 5-minute setup guide for lint-staged with Husky, ESLint, and Prettier in a Node project
Prompt 2
Write a lint-staged config that runs prettier --write on JSON and Markdown and eslint --fix on JS
Prompt 3
Explain how lint-staged stashes and restores files when a task fails so I do not lose work
Prompt 4
Show me how to use --concurrent and --fail-on-changes flags in a CI pre-commit job
Prompt 5
Debug why lint-staged is skipping files using --debug and the --diff and --diff-filter flags

Frequently asked questions

What is lint-staged?

Command-line tool that runs linters and formatters only against git-staged files in a pre-commit hook, so checks stay fast and focused on the changes about to be committed.

What language is lint-staged written in?

Mainly JavaScript. The stack also includes JavaScript, Node, Husky.

Is lint-staged actively maintained?

Maintained — commit in last 6 months (last push 2026-05-16).

How hard is lint-staged to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is lint-staged for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.