Skip to content

Scripts: format has unknown option parenSpacing #34622

Closed

Description

@TobiasBg

Description

I'm trying to use @wordpress/scripts for my plugin's JS code.
Calling wp-scripts format src/index.js results in warning like

[warn] Ignored unknown option { parenSpacing: true }.
src/index.js 57ms

and spaces after/before parentheses are removed, contrary to WP Coding Standards.

Step-by-step reproduction instructions

  1. In some project, run npm install @wordpress/scripts --save-dev.
  2. Run wp-scripts format src/index.js (with src/index.js being a JS file).
  3. A warning [warn] Ignored unknown option { parenSpacing: true }. is shown, and spaces are wrong.

Screenshots, screen recording, code snippet

No response

Environment info

node v16.8.0
npm 7.21.0
@wordpress/scripts 18.0.0

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

  1. TobiasBg commented on Sep 7, 2021

    @TobiasBg
    ContributorAuthor

    Ok, after some research, I found that
    npm install "prettier@npm:wp-prettier@latest" --save-dev
    is necessary in the project folder.
    For some reason the declared dependency to this in the package.jsons of @wordpress/scripts and @wordpress/eslint-plugin is not sufficient?

  2. added
    [Tool] WP Scripts
    [Status] Duplicate
    on Sep 10, 2021
  3. gziolo commented on Sep 10, 2021

    @gziolo
    Member

    It looks like it's exactly the same issue as reported in #21872. It's just the context is different. { parenSpacing: true } is a custom config from the Prettier's fork we use to follow WordPress coding standards.

    The best way to move forward is to stop using the fork and use what the official Prettier has to offer. This is where it is heading, we just need to go through the formal standard of changing coding conventions.

    Let's close this issue as a duplicate of #21872. Thank you for reporting back your findings and documentation of all the issues you had. It's a good reminder why using an npm alias doesn't scale well 👍🏻

  4. TobiasBg commented on Sep 10, 2021

    @TobiasBg
    ContributorAuthor

    Thanks for finding the duplicate, @gziolo! Indeed, this seems to be the same underlying issue. Too bad that a custom fork of Prettier is needed. However, changing the WP JS coding standards doesn't sound too intriguiing either, as it would quite differ much from the WP PHP coding standards. But that's not for this thread :-)

  5. gziolo commented on Sep 10, 2021

    @gziolo
    Member

    changing the WP JS coding standards doesn't sound too intriguiing either

    Couldn't agree more 😅

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

    [Status] Duplicate[Tool] WP Scripts

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions