Skip to content

fix: throw clear error when prettier is not installed instead of hanging#782

Open
isamu wants to merge 2 commits intoprettier:mainfrom
isamu:fix/prettier-not-installed-hang
Open

fix: throw clear error when prettier is not installed instead of hanging#782
isamu wants to merge 2 commits intoprettier:mainfrom
isamu:fix/prettier-not-installed-hang

Conversation

@isamu
Copy link
Copy Markdown

@isamu isamu commented Feb 10, 2026

Summary

  • Add a require.resolve('prettier') check before creating the synckit worker thread
  • When prettier is not installed, ESLint now throws a clear error message instead of hanging indefinitely

Fixes #781

Root Cause

worker.mjs imports prettier as a top-level static import. When prettier is not installed, the worker thread crashes on startup. synckit doesn't handle worker startup failures — the main thread blocks forever on Atomics.wait().

Fix

Check for prettier availability via require.resolve('prettier') before creating the worker. If not found, throw:

Error: eslint-plugin-prettier requires "prettier" package to be installed. Please install it with: npm install -D prettier

Test plan

  • All existing tests pass (pnpm test)
  • Manual verification: remove prettier from node_modules and confirm ESLint fails with the new error message instead of hanging

Important

Adds a check for Prettier's installation in eslint-plugin-prettier.js to prevent ESLint from hanging, throwing a clear error if missing.

  • Behavior:
    • Adds require.resolve('prettier') check in eslint-plugin-prettier.js before creating the synckit worker thread.
    • Throws error if Prettier is not installed, preventing ESLint from hanging.
  • Error Handling:
    • Throws error: eslint-plugin-prettier requires "prettier" package to be installed. Please install it with: npm install -D prettier.
  • Testing:
    • All existing tests pass.
    • Manual verification to ensure ESLint fails with the new error message when Prettier is not installed.

This description was created by Ellipsis for 297bc40. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • Bug Fixes
    • Now fails fast with a clear error if Prettier is not installed, instead of hanging during formatting.
  • Documentation
    • Added a changelog entry describing the patch that clarifies the new failure behavior when Prettier is missing.

When prettier is not installed as a dependency, ESLint would hang
indefinitely because the synckit worker thread fails to start and
never responds. Add a require.resolve check before creating the
worker to fail fast with a descriptive error message.

Fixes prettier#781
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: 1318b9b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-prettier Patch

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

Copy link
Copy Markdown

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 297bc40 in 9 seconds. Click for details.
  • Reviewed 19 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_I0hB4LMO2m0e7T0F

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Adds a defensive check to eslint-plugin-prettier to verify the prettier package can be resolved before lazy-loading it; if unresolved, the plugin now throws a clear error message instead of hanging.

Changes

Cohort / File(s) Summary
Prettier Module Validation
eslint-plugin-prettier.js
Add explicit resolve check for the prettier module before loading the Prettier worker; throw a descriptive error when prettier is not installed to avoid an indefinite hang.
Changelog
.changeset/fix-prettier-not-installed-hang.md
Add patch release note documenting the fix where missing prettier now causes a clear failure instead of hanging.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • JounQin

Poem

🐰 I sniffed the code where errors hide,
Prettier absent — no longer bide.
Now when it’s gone, a trumpet calls,
No silent hangs in linting halls.
Hop on, install — the rabbit winks and smiles.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding error handling to fail fast with a clear error when Prettier is not installed, rather than hanging.
Linked Issues check ✅ Passed The PR implements the core requirement from #781: checking Prettier availability at rule creation time and throwing a descriptive error instead of hanging.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the issue: the defensive check in eslint-plugin-prettier.js and the corresponding changelog entry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

- Only catch MODULE_NOT_FOUND errors, re-throw unexpected errors
- Add changeset for patch version bump
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.

ESLint hangs indefinitely when prettier is not installed (instead of throwing an error)

1 participant