Skip to content

feat(fmt): add single-file formatting core - #115

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/feat-format-text-core
Jul 30, 2026
Merged

feat(fmt): add single-file formatting core#115
chenjiahan merged 1 commit into
mainfrom
chenjiahan/feat-format-text-core

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

This PR adds the internal single-file formatting core needed by the future rs fmt pipeline. It resolves per-file options, infers supported parsers without loading external Prettier config or ignore files, and maps cursor positions when requested. Unsupported file types return a structured skip result, while plugin handling remains deferred until project-root plugin resolution is implemented. This change does not add an rs fmt command or public package export.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8363eb7
Status: ✅  Deploy successful!
Preview URL: https://ea0b02c4.rstack-cli.pages.dev
Branch Preview URL: https://chenjiahan-feat-format-text.rstack-cli.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds the typed formatText API and structured formatted or unsupported results. The implementation resolves formatting options, rejects configured plugins, infers parsers from file paths, supports cursor-aware formatting, and formats paths under node_modules. Tests cover per-file overrides, cursor mapping, unknown extensions, explicit parsers, and node_modules paths.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a single-file formatting core.
Description check ✅ Passed The description matches the PR goals and summarizes the formatting core changes accurately.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chenjiahan/feat-format-text-core

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/rstack/tests/fmt/format.test.ts (1)

1-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for plugin rejection.

packages/rstack/src/fmt/format.ts explicitly rejects configured plugins, but this changed test file does not verify that contract. Add a test asserting that formatText rejects with the expected error when plugins are configured.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/rstack/tests/fmt/format.test.ts` around lines 1 - 77, Add a
regression test alongside the existing formatText tests that configures at least
one plugin, invokes formatText with that configuration, and asserts it rejects
with the expected plugin-rejection error from format.ts. Keep the assertion
focused on the established error contract and preserve the existing test
patterns.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/rstack/tests/fmt/format.test.ts`:
- Around line 1-77: Add a regression test alongside the existing formatText
tests that configures at least one plugin, invokes formatText with that
configuration, and asserts it rejects with the expected plugin-rejection error
from format.ts. Keep the assertion focused on the established error contract and
preserve the existing test patterns.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d3c529e1-a7e8-4a49-b075-c9529a759d0c

📥 Commits

Reviewing files that changed from the base of the PR and between 6c563ef and 8363eb7.

📒 Files selected for processing (3)
  • packages/rstack/src/fmt/format.ts
  • packages/rstack/src/fmt/types.ts
  • packages/rstack/tests/fmt/format.test.ts

@chenjiahan
chenjiahan merged commit 06d4704 into main Jul 30, 2026
4 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/feat-format-text-core branch July 30, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant