Repository navigation
fix(tooling): make Prettier plugins resolvable so the pre-commit hook works (#108) - #111
Merged
Merged
Conversation
…fig (#108) Prettier resolves bare plugin names from process.cwd(), i.e. the repo root, but pnpm installs @repo/prettier-config's devDependencies only under packages/prettier-config/node_modules. Every pre-commit run of lint-staged (and `pnpm format` / `format:check`) therefore failed with "Cannot find package 'prettier-plugin-packagejson'", so commits either skipped the hook or landed unformatted. Resolve the plugin with require.resolve from the config file itself. Prettier imports absolute plugin paths through pathToFileURL, so this also works on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015v1boe4iagzc2mQVMuU39b
Same root cause as the shared config: Prettier resolves bare plugin names from process.cwd(), so running Prettier from the repo root (`pnpm format`, `pnpm format:check`) failed on every apps/web file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015v1boe4iagzc2mQVMuU39b
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What changed? In both Prettier configs, plugins are now resolved with
require.resolvefrom the config file's own package instead of by bare package name:packages/prettier-config/prettier.config.js→prettier-plugin-packagejsonapps/web/prettier.config.js→prettier-plugin-tailwindcss(I also formatted this 8-line file with its own config; nothing in lint-staged covers it)Why? Prettier 3 resolves a bare plugin name from
process.cwd()(importPlugin→importFromDirectory(name, cwd)). pnpm installs each package's plugins only under that package's ownnode_modules. The result: every commit failed at the husky pre-commit step:This hit both the root lint-staged config and
apps/web/.lintstagedrc.js. Agents then either skipped the hook or committed unformatted code.pnpm formatandpnpm format:checkfailed the same way. Absolute paths go throughpathToFileURLinside Prettier, so the fix works on Windows as well.Verification (before → after, real
git commitwith hooks enabled, on throwaway branches):apps/web/.../RadarBadge.tsx,packages/shared-data/src/index.tsandDocs/Resources/ROADMAP.md. Before the fix the commit failed with the errors above (exit 1). After it, the commit succeeded (exit 0) and each staged file was formatted ({a:1, b:"x"}became{ a: 1, b: 'x' }).commitlintcommit-msg hook, with noHUSKY=0.pnpm format:checknow runs to completion and lists 158 files that were already not formatted ondev. I deliberately did not mass-format them here, to avoid conflicts with other agents' work in progress. With the hook working, each file gets formatted the next time someone commits it.Checklist
pnpm --filter @repo/web typecheckpnpm format:checkexecutes@repo/crawlers test+test:dist,@repo/extension test,@repo/web testNotes
packages/prettier-config,apps/web(Prettier config only)Closes #108
🤖 Generated with Claude Code
https://claude.ai/code/session_015v1boe4iagzc2mQVMuU39b
Generated by Claude Code