rush-lint-staged-plugin v0.2.2
rush-lint-staged-plugin
Rush plugin for lint-staged
Prerequisite
- Rush.js >= 5.57.0
- Node >= 12
Quick Start
- Enabling this rush plugin
Please follow the official doc to enable this plugin in your repo.
- Running
lint-staged
rush lint-staged- Set up Git
pre-commithook
common/git-hooks/pre-commit
#!/bin/sh
node common/scripts/install-run-rush.js lint-staged || exit $?- Add a placeholder
lint-stagedconfig in root path.
The reason of adding this file is the fact that lint-staged behaves differently with the number of config files. With this placeholder config, lint-staged will always find multiple config files in your monorepo, which corrects the working directory of each task.
<monorepo_root_path>/.lintstagedrc.json
{
"*": "echo ok"
}Rational
lint-staged@>=12.2.1 supports a new feature called multiple config files. With this feature, each staged files can load different lint-staged configuration. This plugin invokes lintStaged for you. No more no less.
For example,
monorepo-root
├── scripts
| └── index.js
├── apps/my-app
| ├── index.js
| └── .lintstagedrc.js
└── libraries/my-lib
├── index.js
└── .lintstagedrc.jsAssuming git staged apps/my-app/index.js, libraries/my-lib/index.js and scripts/index.js
when rush lint-staged runs,
apps/my-app/index.jsuses config fromapps/my-app/.lintstagedrc.jslibraries/my-lib/index.jsuses config fromlibraries/my-lib/.lintstagedrc.jsscripts/index.jshas no related config, nothing runs for this file