feat!: show input from a new line#4727
feat!: show input from a new line#4727knocte wants to merge 6 commits intoconventional-changelog:masterfrom
Conversation
Review Summary by QodoAdd multi-line input display with legacy output flag support
WalkthroughsDescription• Change default input output format to multi-line with --- input --- banner • Add --legacy-output flag to restore single-line input: ... format • Add comprehensive test cases for both new and legacy output formats • Update documentation examples to reflect new default output format Diagramflowchart LR
A["CLI Input"] --> B["Format Module"]
B --> C{"legacyOutput Flag?"}
C -->|true| D["Single-line: input: ..."]
C -->|false| E["Multi-line: --- input ---"]
D --> F["Output Display"]
E --> F
File Changes1. @commitlint/cli/src/cli.ts
|
Code Review by Qodo
1. URL-in-body regression test missing
|
There was a problem hiding this comment.
Pull request overview
Updates commitlint’s text formatter to display the commit message input starting on a new line (with an --- input --- banner) to make error output clearer and easier to copy/paste, while adding an opt-in legacy mode for the previous single-line input: display.
Changes:
- Change the default formatted “input” output to a banner + newline style in
@commitlint/format. - Add
legacyOutput/--legacy-outputto preserve the previous single-lineinput: ...output format. - Update several docs/examples and extend formatter test coverage for the new/legacy outputs.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/guides/local-setup.md | Updates example output to match the new multi-line input banner format. |
| @commitlint/types/src/format.ts | Extends FormatOptions with legacyOutput?: boolean. |
| @commitlint/format/src/format.ts | Implements the new input banner output and legacy toggle. |
| @commitlint/format/src/format.test.ts | Adds tests for new banner output and legacy output. |
| @commitlint/config-rush-scopes/readme.md | Updates shown CLI output to use the new input banner. |
| @commitlint/config-pnpm-scopes/readme.md | Updates shown CLI output to use the new input banner. |
| @commitlint/config-nx-scopes/readme.md | Updates shown CLI output to use the new input banner. |
| @commitlint/config-lerna-scopes/readme.md | Updates shown CLI output to use the new input banner. |
| @commitlint/cli/src/types.ts | Adds legacy-output to CLI flags typing. |
| @commitlint/cli/src/cli.ts | Adds --legacy-output yargs option and passes through to formatter options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ❯ echo "build(api): change something in api's build" | commitlint | ||
| ⧗ input: build(api): change something in api's build | ||
| ⧗ --- input --- | ||
| build(api): change something in api's build | ||
| ✔ found 0 problems, 0 warnings |
There was a problem hiding this comment.
These examples show output for a successful lint ("found 0 problems") but the CLI doesn't print anything on success unless --verbose is used (see docs/guides/local-setup.md). To keep the README accurate, either add --verbose to the example commands or remove the success output blocks.
| ❯ echo "build(api): change something in api's build" | commitlint | ||
| ⧗ input: build(api): change something in api's build | ||
| ⧗ --- input --- | ||
| build(api): change something in api's build | ||
| ✔ found 0 problems, 0 warnings |
There was a problem hiding this comment.
These examples include output for passing commits without showing --verbose, but commitlint suppresses output on success by default. Please update the commands to include --verbose (or adjust the shown output) so the README matches actual CLI behavior.
| ❯ echo "build(api): change something in api's build" | commitlint | ||
| ⧗ input: build(api): change something in api's build | ||
| ⧗ --- input --- | ||
| build(api): change something in api's build | ||
| ✔ found 0 problems, 0 warnings | ||
|
|
There was a problem hiding this comment.
The success-case examples here show output even though commitlint prints nothing for valid messages unless --verbose is provided. Consider adding --verbose to the example commands (or removing the success output) to avoid confusing users who copy/paste.
| ❯ echo "build(api): change something in api's build" | commitlint | ||
| ⧗ input: build(api): change something in api's build | ||
| ⧗ --- input --- | ||
| build(api): change something in api's build | ||
| ✔ found 0 problems, 0 warnings | ||
|
|
There was a problem hiding this comment.
Like the other config READMEs, this shows output for a passing commit without --verbose, but commitlint is silent on success by default. Please align the example commands/output (e.g., add --verbose) so the documentation reflects real behavior.
52731bb to
7f02bb0
Compare
|
@escapedcat I think this is ready to merge (when we're ready to do the big version bump with breaking changes, not now). The only feedback I didn't address from Copilot is:
|
And by this I mean that they'll likely find about this change in the CHANGELOG/ReleaseNotes; they're not going to read the documentation ;) |
|
I guess we don't lose anything by adding it to the docs and removing it later again. I don't think it's polluting them. Another small feedback from Claude I think it's worth doing:
So maybe write a commit body and state this plan? |
|
@knocte thanks for picking this up! 👍 |
This will be less confusing to read, and also easier to test and copy/paste.
Previous commit adtoped a new output format by default, so we need to reflect it in the docs like it's done here.
As instructed by GitHub Copilot, we add a new testcase.
To restore old single-line input output.
Alright, added a commit to address this. |
Supersedes #4102
This will be less confusing to read, and also easier to test and copy/paste (for example for #4101).
This error log is confusing for people not familiar with
commitlint.This one should be more clear.
Or maybe even this one.
Motivation and Context
Error output should not mess up original commit message, because it is hard to understand what is wrong.
Usage examples
How Has This Been Tested?
Types of changes
Checklist: