Skip to content

wp-prettier should be a dependency, not devDependency #235

@GaryJones

Description

@GaryJones

Summary

The wp-prettier package is declared as a devDependency in package.json, but it should be a regular dependency (or peerDependency). This causes projects using @automattic/eslint-plugin-wpvip to get the wrong Prettier version.

Current behaviour

When a project installs @automattic/eslint-plugin-wpvip, npm installs:

  • eslint-plugin-prettier@5.5.4 (from dependencies)
  • prettier@3.7.4 (regular Prettier, resolved by eslint-plugin-prettier)

But wp-prettier@3.0.3 is only in devDependencies, so it's not installed.

Expected behaviour

Projects should get wp-prettier (which supports parenSpacing: true for WordPress coding standards) instead of regular Prettier.

Impact

When running eslint --fix, the prettier plugin uses regular Prettier which:

  • Ignores the parenSpacing: true option from the provided prettierrc.js
  • Removes spaces inside parentheses, e.g. $( this ) becomes $(this) (example)
  • Produces output that doesn't match WordPress coding standards

Reproduction

  1. Create a project with:
    {
      "devDependencies": {
        "@automattic/eslint-plugin-wpvip": "^1.1.1",
        "eslint": "^9.7.0"
      }
    }
  2. Run npm install
  3. Check npm ls prettier - shows prettier@3.7.4, not wp-prettier
  4. Run eslint --fix on code with WordPress-style spacing
  5. Spaces inside parentheses are removed

Suggested fix

Move prettier from devDependencies to dependencies:

  "dependencies": {
+   "prettier": "npm:wp-prettier@3.0.3",
    "eslint-plugin-prettier": "5.5.4",

Or alternatively, add it as a peerDependency and document that users should install wp-prettier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions