Add options to format-po formatter - #5
Conversation
🦋 Changeset detectedLatest commit: 8642f75 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 |
WalkthroughThe pull request introduces formatter options for the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
examples/carbon-tsdown/saykit.config.ts (1)
10-11: Consider demonstrating the new formatter options.The output path change is fine, but since this PR introduces formatter options, this example could showcase them explicitly:
formatter: createFormatter({ references: { lineNumbers: true } }),or
formatter: createFormatter({ references: false }),This would help users discover the new functionality.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/carbon-tsdown/saykit.config.ts` around lines 10 - 11, Update the example config to show the new formatter options by passing an options object to createFormatter in the formatter property; specifically demonstrate at least one of the new options such as createFormatter({ references: { lineNumbers: true } }) or createFormatter({ references: false }) so users can see how to enable line numbers for references or disable references entirely when using the formatter symbol createFormatter in the example config.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/format-po/src/formatter.ts`:
- Around line 69-74: The code uses message.references.map(...) which can throw
if message.references is undefined; change the mapping to use the local variable
references (assigned on line 70) so the code becomes references = (typeof
options.references !== 'object' || options.references.lineNumbers !== true) ?
references.map(r => r.split(':')[0]!) : references; then deduplicate and sort
into item.references as before (ensure you reference the variables
options.references, message.references, references, and item.references when
making the change).
---
Nitpick comments:
In `@examples/carbon-tsdown/saykit.config.ts`:
- Around line 10-11: Update the example config to show the new formatter options
by passing an options object to createFormatter in the formatter property;
specifically demonstrate at least one of the new options such as
createFormatter({ references: { lineNumbers: true } }) or createFormatter({
references: false }) so users can see how to enable line numbers for references
or disable references entirely when using the formatter symbol createFormatter
in the example config.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6a1e2c2b-272a-4df2-b778-976672a05904
📒 Files selected for processing (7)
.changeset/bright-foxes-invite.mdexamples/carbon-tsdown/.gitignoreexamples/carbon-tsdown/saykit.config.tsexamples/carbon-tsdown/src/i18n.tsexamples/carbon-tsdown/src/locales/en.poexamples/carbon-tsdown/src/locales/fr.popackages/format-po/src/formatter.ts
b63daa5 to
1b55b5b
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@greptile review |
Greptile SummaryThis PR adds configurable options to the Notable changes beyond the stated options:
One concern flagged:
Confidence Score: 5/5Safe to merge — the feature works correctly for the common Unix-path use case; the one concern is a minor robustness improvement. The logic is straightforward and correct for the targeted environments. The colon-split issue only affects Windows absolute paths, which are very rarely seen in PO file references. The implicit deduplication/sorting change is a net positive. Overall this is a low-risk, well-structured patch. No files require special attention; the single concern is isolated to line 72 of packages/format-po/src/formatter.ts. Prompt To Fix All With AIThis is a comment left during a code review.
Path: packages/format-po/src/formatter.ts
Line: 72
Comment:
**Fragile reference path stripping**
`r.split(':')[0]` splits on the first colon, which works for typical Unix-style `path/to/file.ts:42` references. However, it would silently truncate paths that contain a colon (e.g. Windows absolute paths like `C:\src\file.ts:42` → `"C"`). A more robust approach would be to strip only a trailing `:\d+` pattern:
```suggestion
references = references.map((r) => r.replace(/:\d+$/, ''));
```
This ensures only the line number suffix is removed, leaving all other path characters intact.
```suggestion
references = references.map((r) => r.replace(/:\d+$/, ''));
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Add format-po reference options" | Re-trigger Greptile |
Summary by CodeRabbit
Release Notes
New Features
Chores