Straitjacket

Tune or disable rules

Straitjacket runs every rule at its strictest by default. You ratchet down from there. This guide covers the common adjustments; the full flag list is in the CLI reference.

Run only some rules

straitjacket --only emoji,color   # nothing but these two
straitjacket --skip motion        # everything except this rule

--only and --skip take comma-separated rule ids. An unknown id is an error — the run stops with exit code 2 rather than silently scanning with a rule you thought you had turned off. See every id in the rules reference or with straitjacket --list-rules.

Adjust thresholds

Two rules have a tunable number:

straitjacket --max-lines 800    # file-size line budget (0 disables)
straitjacket --max-nesting 4    # deep-nesting depth budget (0 disables)

Exempt paths from a rule

file-size and stray-todo take path prefixes in the config file, which is usually tidier than scattering markers through the files themselves:

file-size-exclude = ["notes/", "packages/generated/"]
todo-exclude = ["packages/legacy/"]

color has the same idea in reverse: theme-files names the files that are allowed to define color literals, so your palette module stops being a finding.

theme-files = ["src/theme/tokens.css"]

Change the output

straitjacket --format json    # machine-readable findings
straitjacket --format sarif   # SARIF 2.1.0 for code scanning
straitjacket --no-fail        # report everything but always exit 0

--format json is the right choice when another tool consumes the results. --no-fail is what you want while adopting Straitjacket — you see every finding without breaking the build, which matters because a first run against an established repository usually turns up a lot.

Make it stick

Rather than remember these flags for every run, commit a straitjacket.toml to the repo — the same settings in one file, picked up automatically by every run and by CI:

# straitjacket.toml
skip = ["motion"]
max-lines = 800
theme-files = ["src/theme/tokens.css"]
file-size-exclude = ["notes/"]