Skip to content

feat: use Prettier's CLI function in-memory if possible#144

Merged
JoshuaKGoldberg merged 1 commit intomainfrom
prettier-in-memory
Jun 12, 2025
Merged

feat: use Prettier's CLI function in-memory if possible#144
JoshuaKGoldberg merged 1 commit intomainfrom
prettier-in-memory

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Owner

@JoshuaKGoldberg JoshuaKGoldberg commented May 2, 2025

PR Checklist

Overview

Augments the built-in Prettier formatter by making its runner a function that attempts to require() Prettier's internal CLI run function. This is very hacky and unfortunate but I couldn't find another way to run in-memory. Filed: prettier/prettier#17422

The change ended up needing a bit more refactoring than I thought:

  • Formatter runners are now each a function:
    • Most use createRunCommand() -> runFormatterCommand() to run a single CLI command
    • Prettier has its own runPrettier that falls back to runFormatterCommand() if needed
  • Types are all extracted to a root-level types.ts file to avoid circular dependencies

🧼

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (dbe822d) to head (9c024e8).
Report is 42 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #144   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         8    +4     
  Lines          109       146   +37     
  Branches        25        30    +5     
=========================================
+ Hits           109       146   +37     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JoshuaKGoldberg JoshuaKGoldberg merged commit cd31aab into main Jun 12, 2025
16 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the prettier-in-memory branch June 12, 2025 13:03
@github-actions
Copy link
Copy Markdown

🎉 This is included in version v0.3.0 🎉

The release is available on:

Cheers! 📦🚀

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.

🚀 Feature: Use in-memory API for Prettier if available

1 participant