Generated by GPT-5-mini| Lint-staged | |
|---|---|
| Name | Lint-staged |
| Programming language | JavaScript |
| Operating system | Cross-platform |
| Platform | Node.js |
| Genre | Developer tool |
| License | MIT |
Lint-staged is a Node.js-based developer tool that runs linters on staged files in a Git commit workflow, designed to reduce commit-time errors and enforce code quality. It integrates with task runners and package managers to execute linters, formatters, and custom scripts on files selected by Git staging, enabling pre-commit automation with minimal latency. The project is used across diverse projects in the JavaScript and TypeScript ecosystems and commonly pairs with popular tools and services in modern software development.
Lint-staged operates as a lightweight wrapper around command-line tools to run them only on the subset of files staged for a Git commit, minimizing work compared to running across entire repositories. It is often combined with Husky for Git hook management, and with continuous integration platforms such as Travis CI, CircleCI, GitHub Actions, and GitLab CI/CD to provide multi-layered quality gates. Teams using Node.js monorepos, Babel transpilation, or TypeScript projects integrate lint-staged to maintain standards alongside services like Snyk, Dependabot, and Greenkeeper (historical).
Lint-staged provides pattern-based file selection using Git's staging index, supports parallel execution akin to GNU Parallel style workflows, and allows configuration for synchronous or asynchronous tasks. It supports chaining of tools such as ESLint, Prettier, Stylelint, Jest, Mocha, and Flow to perform linting, formatting, or testing on staged code. The tool can run arbitrary shell commands and integrates with package managers like npm, Yarn, and pnpm for script resolution. Additional features include automatic staging after fixes, caching strategies comparable to Babel Cache, and verbose logging suitable for integration with observability stacks like Prometheus and Elasticsearch.
Installation typically uses package managers; developers install lint-staged as a devDependency via npm, Yarn, or pnpm and configure it within package.json or in dedicated configuration files inspired by ESLint and Prettier config conventions. Configuration supports glob patterns similar to .gitignore syntax and YAML/JSON formats influenced by tools like Travis CI and CircleCI config files. Integration with Husky is often documented alongside examples derived from Create React App and Next.js starter templates. Commands are resolved through Node.js's module resolution algorithm as specified by CommonJS and ECMAScript module semantics.
Common usage pairs lint-staged with Husky pre-commit hooks to run ESLint and Prettier on staged JavaScript and TypeScript files in projects such as those bootstrapped by Create React App, Angular CLI, or Vue CLI. Example configurations mirror patterns used by projects like React, Angular, Vue.js, and Ember.js to format code and run unit tests before committing. Teams working on Electron apps or Node.js libraries often add custom scripts to run Jest snapshots or Mocha suites selectively. Open-source maintainers in organizations like Mozilla, Facebook, Google, Microsoft, and Airbnb have influenced best-practice examples for staged linting workflows.
While lint-staged targets pre-commit developer workflows, it complements CI/CD pipelines on GitHub Actions, GitLab CI/CD, Travis CI, CircleCI, and enterprise systems like Jenkins and Azure DevOps by reducing noise from trivial style issues. Integration examples show editors such as Visual Studio Code, WebStorm, Atom, Sublime Text, and Vim configured for on-save formatting with Prettier and linting with ESLint, mirroring staged checks for consistency. Developer platforms like Bitbucket, Phabricator, and Gerrit can incorporate staged linting practices into local workflows to align with repository-level linters used by organizations like Netflix and Uber.
Lint-staged is compatible with ecosystems centered on Node.js and cross-platform shells used in macOS, Windows, and Linux development environments. It interoperates with build tools and bundlers including Webpack, Rollup, and Parcel, and with transpilers such as Babel and TypeScript Compiler for projects maintained by communities around npm Registry, Yarn Workspaces, and pnpm Workspaces. The ecosystem includes integrations and plugins maintained by authors and organizations like Typicode, Sindre Sorhus, and corporate projects at GitHub and Microsoft.
Security considerations include ensuring that commands executed by lint-staged do not introduce arbitrary code execution risks; organizations often audit pre-commit scripts similarly to practices at OWASP and compliance frameworks referenced by ISO/IEC standards. Performance strategies mirror techniques from Babel and Webpack caching and incremental builds popularized by Bazel and Nx, minimizing IO and leveraging in-memory operations. Large monorepos managed by organizations like Google and Facebook demonstrate patterns—such as selective targeting and parallelism—to avoid blocking developer productivity.
Lint-staged emerged from community needs within the JavaScript ecosystem to run linters on staged files, evolving alongside projects such as ESLint, Prettier, and Husky. Its development timeline parallels advancements in package management and Git workflow tooling influenced by contributors across open-source communities including npm, Yarn, and pnpm maintainers. Adoption grew in the mid-to-late 2010s as continuous integration practices spread through platforms like Travis CI and CircleCI, and the project received contributions from individual maintainers and organizations participating in collaborative tooling efforts observed in foundations such as the OpenJS Foundation.
Category:JavaScript tools