adapter-lint-staged
Generates a .lintstagedrc.json config file that maps glob patterns to commands. This is a setup-only adapter: lint-staged is invoked by husky, not by lodestar directly.
Package: @retemper/lodestar-adapter-lint-staged
Managed file: .lintstagedrc.json
Config Options
| Option | Type | Description |
|---|---|---|
commands | Record<string, string | readonly string[]> | Glob pattern to command mapping -- e.g., {"*.ts": "eslint --fix"} |
Example
ts
import { lintStagedAdapter } from '@retemper/lodestar-adapter-lint-staged';
lintStagedAdapter({
commands: {
'*.{ts,tsx}': 'eslint --fix',
'*.{css,scss}': 'stylelint --fix',
'*.{ts,tsx,css,scss,json,md}': 'prettier --write',
},
});How verifySetup Works
- Checks that
.lintstagedrc.jsonexists inrootDir. - Reads the file content and compares it against the JSON that lodestar config produces from the
commandsmapping. - Returns a missing violation if the file does not exist.
- Returns a drift violation (with a diff of expected vs actual) if the content does not match.
- Returns no violations if
.lintstagedrc.jsonmatches.
Drift means the .lintstagedrc.json file was manually edited or overwritten by another tool, so it no longer reflects the lodestar config. Running lodestar check --fix regenerates the file to resolve the violation.
Note: This adapter does not implement
check(). lint-staged is triggered by husky git hooks, not bylodestar check.