Skip to content

fix(tooling): pre-commit lint-staged fails, prettier cannot resolve prettier-plugin-packagejson #108

Closed

Description

@JOY

Problem

.husky/pre-commit runs npx lint-staged, which runs prettier --write on every staged file. Every commit fails with:

[error] Cannot find package 'prettier-plugin-packagejson' imported from /home/user/Rate/noop.js
husky - pre-commit script failed (code 1)

The cause: packages/prettier-config/prettier.config.js lists the plugin by bare name (plugins: ['prettier-plugin-packagejson']), and Prettier resolves bare plugin names from the current working directory, which is the repo root. Under pnpm's strict layout the plugin is installed only in packages/prettier-config/node_modules, so the root cannot find it.

The impact: agents either skip the hook or commit unformatted code. Many files on dev are not Prettier-clean, and pnpm format / pnpm format:check hit the same error.

Plan

  • Resolve the plugin from the shared config's own location (require.resolve), so it loads from any working directory.
  • Verify that a real git commit with the hook enabled formats only the staged files and succeeds, and that pnpm format:check runs again (it will report the existing unformatted files, which is expected).
  • Do not mass-reformat the repo in this change, to avoid conflicts with other agents' in-flight work.

[Agent: Core]

Activity

  1. added
    status:in-reviewTask completed and waiting for review / PR merge
    and removed
    status:in-progressTask currently claimed and being worked on by an Agent
    on Oct 16, 2026
  2. added
    status:doneTask completed and verified
    and removed
    status:in-reviewTask completed and waiting for review / PR merge
    on Oct 16, 2026
  3. JOY commented on Oct 16, 2026

    @JOY
    ContributorAuthor

    ✅ [Agent: Core] Done in #111, squash-merged into dev as 51b169f (Status -> Done).

    • Both Prettier configs now load their plugins with require.resolve from the package that declares them: prettier-plugin-packagejson in @repo/prettier-config, prettier-plugin-tailwindcss in apps/web.
    • I ran real git commits with husky enabled, before and after the fix. Before: the root lint-staged and apps/web/.lintstagedrc.js both failed with Cannot find package. After: the commit succeeds and the staged files get formatted. pnpm format:check now runs to completion.
    • Out of scope, already broken before this fix:
      • pnpm format:check reports 158 files that are not formatted.
      • apps/web/.lintstagedrc.js only formats src/**/*.{js,jsx,ts,tsx}.
      • ESLint in apps/web fails with "typescript-eslint does not support TS 7.0".

    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions