Introduction
Boy Scout Rule for your linter — suppress baseline violations and report only new ones.
bsr brings the Boy Scout Rule — leave things cleaner than you found them — to any linter.
Pipe lint output into bsr. It suppresses errors already recorded in a baseline and reports only new ones. You can turn on strict lint rules even if the project already has many errors. You can also require that changed code must be clean before merge.
Inspired by PHPStan’s baseline.
Installation
Install with mise, go install, or build from source.
Quickstart
Create a baseline and check for new errors.
Boy Scout Policy
Require cleanups on files or lines you changed.
Managing the baseline
Update .bsr-baseline.json.
Why bsr?
A new lint rule often finds thousands of old errors. Teams then:
- Turn the rule off forever, or
- Fix everything in one big effort
bsr gives another option:
- Start by saving existing errors as a baseline
- CI fails on new errors and existing errors on changed lines
- Old errors gradually disappear as you work
Features
- Works with many linters — golangci-lint, ESLint, buf, and other tools that print
file:line:... - Content-based matching — uses a SHA-256 hash of the source line, not the line number
- Count-based suppression cap — never hides more copies of an error than the baseline recorded
- Boy Scout Policy — for changed files or lines, ignore the baseline and report all errors there
- Git-native —
--base-reffinds changes withbase...HEAD - CI-friendly — exits with code
1only when there are new errors
Basic workflow
# Once: save current errors
eslint . | bsr init
# On every PR: fail on new errors and on old errors in changed lines
eslint . | bsr check --boy-scout-policy hunk --base-ref origin/main