OSS TanbouSign in with GitHub

Run formatting and checking tasks only on staged Git files for faster pre-commit feedback

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
14,740
Primary language
JavaScript
License
MIT
Repository last updated
Sep 26, 2026
On this page

Overview

lint-staged is a development tool that runs linters, formatters, and other tasks only against Git files included in the next commit. Projects map file patterns to commands and invoke it from a pre-commit hook or directly. This narrows quality checks to changed files instead of scanning the whole project every time.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Match staged files by pattern and pass them to existing tools

Commands configured for each glob pattern receive the matching staged-file list as arguments. Existing tools such as ESLint and Prettier can be combined, and multiple commands can run sequentially or in parallel. By default, lint-staged backs up the original state in a Git stash and stages changes produced by tasks.

Sources: [1]

Best fit

Fits teams that want shared commit checks without scanning an entire repository

lint-staged is useful in large repositories where only changed JavaScript, JSON, Markdown, or other matched files need formatting and static checks. Committing its configuration and Git hook lets contributors run the same checks before each commit.

Sources: [1]

Before adoption

Tasks can change both the worktree and index, so review their side effects

Because configurations run arbitrary shell commands, broad rewrites and commands that ignore their file arguments need care. In a repository with at least one commit, the default workflow first creates a backup stash. In v17.6.0, all tracked files changed by tasks are staged; if a task edits a file with unstaged work, that work can be staged as well. Use --hide-unstaged when appropriate and test the workflow on a small change first. Version 17.6.0 requires Node.js 22.22.1 or newer and is MIT licensed.

Sources: [1][3][2][4]

Official sources

  1. [1]lint-staged — README at v17.6.0(2026-10-04)
  2. [2]lint-staged — package.json at v17.6.0(2026-10-04)
  3. [3]lint-staged v17.6.0 release(2026-10-04)
  4. [4]lint-staged — MIT license(2026-10-04)
Supplemental curator note

lint-staged reduces feedback time by narrowing checks to commit candidates rather than skipping quality gates. During adoption, test how every configured task affects the index and any unstaged work, not just whether formatting succeeds.

Try it in 3 steps

  1. 1

    Install the checking tools as development dependencies

    Use Node.js 22.22.1 or newer in a new disposable Git/npm test project or test branch with at least one commit. The following step creates configuration files.

    npm install --save-dev lint-staged@17.6.0 eslint@9
  2. 2

    Configure ESLint and lint-staged

    Create a minimal ESLint flat config and a lint-staged config that fixes staged JavaScript from the project root.

    cat > eslint.config.mjs <<'EOF' export default [{ files: ["**/*.js"], rules: { semi: ["error", "always"] } }] EOF cat > lint-staged.config.mjs <<'EOF' export default { "*.js": "eslint --fix" } EOF
  3. 3

    Stage a real file and run the check

    Confirm that ESLint adds the semicolon and lint-staged stages the task change. By default it creates a backup stash for tracked state, so test on a clean disposable branch.

    printf 'const answer = 42\n' > lint-demo.js git add lint-demo.js eslint.config.mjs lint-staged.config.mjs package.json package-lock.json npx lint-staged
Check the official README

Growth

Growth trends · Last 30 days

14,740 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
44
Open PRs
0

Development activity is still being collected.

Built with

Categories and tags

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • stage-files
  • linter
  • stylelint
  • eslint
  • git
  • developer-experience
  • workflow
Stars
14,740
Forks
473
Watchers
39
Open issues
2
Contributors
157
Owner type
Organization
Primary language
JavaScript
License
MIT
Repository last updated
Sep 26, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?