Repository navigation
chore: refactor check-config handler - #3181
Conversation
🦋 Changeset detectedLatest commit: f58206c The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Performance Benchmark (Lower is Faster)
|
vadyvas
left a comment
There was a problem hiding this comment.
2 questions, but generally lgtm
| command: 'check-config', | ||
| }); | ||
|
|
||
| printConfigLintTotals(totals, getCommandNameFromArgs(argv as Arguments)); |
There was a problem hiding this comment.
I tried, but it's still needed (same as in other command handlers). It's a different story anyway.
| import { getCommandNameFromArgs } from '../utils/get-command-name-from-args.js'; | ||
|
|
||
| // Every command loads and checks the config before its handler, so the `check-config` command itself has no handler. | ||
| export async function loadAndCheckConfig( |
There was a problem hiding this comment.
should this file live in /commands/?
every other command exports a handle<Command>
maybe it worth to move it to utils/, or keep it near the wrapper.ts ?
There was a problem hiding this comment.
Good question. I decided to put it as a regular handler even though it doesn't get triggered by the command itself just for the sake of consistency, and to encapsulate everything related to the feature in one place.
4be51a4 to
f58206c
Compare
What/Why/How?
Refactored config checker:
stderrin thecodeframeformat for every command, regardless of the--formatoption.json,junit,checkstyle, andsarifnow report configuration problems too, instead of hiding them.Reference
A follow-up to #3080 (comment).
Testing
Screenshots (optional)
Check yourself
Security
Note
Medium Risk
Changes CLI output and exit behavior for all commands when configs are invalid, which can affect CI parsers that assumed config issues were omitted from machine-readable formats.
Overview
Centralizes config loading and validation in
loadAndCheckConfig, wired fromcommandWrapperinstead of the oldloadConfigAndHandleErrors/handleLintConfigsplit inlintandmiscellaneous.Config problems are always emitted on stderr as codeframe, via
formatProblemswithcommand: 'check-config'(no--formatpassthrough). That meansjson,junit,checkstyle, andsarifruns no longer hide config issues—machine-readable primary output stays clean on stdout while config diagnostics appear separately (see updated e2e snapshot for--format=json).Load failures now surface
Failed to load the configuration fileinstead of API-oriented error text. Config lint errors abort withAbortFlowErrorrather thanConfigValidationError.Docs and changeset note the stderr/codeframe behavior; tests move to
check-config.test.tsand drop the old “skip config output for json/junit” expectations.Reviewed by Cursor Bugbot for commit f58206c. Bugbot is set up for automated code reviews on this repo. Configure here.