integration with NX affected

Author: hmidmriiCreated Nov 13, 2024Updated Sep 25, 2025

Description

When using lint-staged with nx affected to lint fix a module, some files won't be staged because lint-staged only adds the files that were matched by the micromatch,

the command that I'm using is nx affected -t lint --files=${files} --fix, which means that all modules that those files affected will be linted and fixed, which might cause more files to be linted and fixed

Steps to reproduce

  • initialize NX workspace
  • use @nx/dependency-checks (which means when you use a new package in a module it would automatically add it to pakcage.json)
  • use a new package in a js file in the module
  • commit with lint staged

Debug Logs

No need

Environment

  • OS: Windows 11
  • Node.js: v20.14.0
  • lint-staged: ^15.2.10