Run linters against staged git files and don't let anything slip into your code base! Linting makes more sense when run before committing your code. By doing so you can ensure no errors go into the repository and enforce code style. But running a lint process on a whole project is slow, and linting results can be irrelevant. Ultimately you only want to lint files that will be committed. This project contains a script that will run arbitrary shell tasks with a list of staged files as an argument, filtered by a specified glob pattern. Linter commands work on a subset of all staged files, defined by a glob pattern. lint-staged uses micromatch for matching files. The concept of lint-staged is to run configured linter tasks (or other tasks) on files that are staged in git. lint-staged will always pass a list of all staged files to the task, and ignoring any files should be configured in the task itself.
Features
- Resolve the git root automatically, no configuration needed
- Pick the staged files which are present inside the project directory
- Filter them using the specified glob patterns
- Pass absolute paths to the linters as arguments
- Supported are any executables installed locally or globally via npm as well as any executable from your $PATH
- You can run multiple commands in a sequence on every glob