Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp-scripts lint-js and format should preserve spaces within parents #54749

Closed
jeremyfelt opened this issue Sep 22, 2023 · 1 comment · Fixed by #54775
Closed

wp-scripts lint-js and format should preserve spaces within parents #54749

jeremyfelt opened this issue Sep 22, 2023 · 1 comment · Fixed by #54775
Labels
[Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended

Comments

@jeremyfelt
Copy link
Member

jeremyfelt commented Sep 22, 2023

Description

The update to @wordpress/scripts 26.13.0 seems to have caused an issue where spaces are being removed around parens via npx wp-scripts format and flagged by npm wp-scripts lint-js. I've noticed this on a couple different projects using the @wordpress/scripts library for formatting and building blocks.

I believe #54539 is the cause, and I don't believe it was intentional. I've posted npm ls prettier output below that may point to that, but I'm not at all sure why. I'm happy to help test any changes though. 😄

Step-by-step reproduction instructions

In a clean directory:

  1. npm install @wordpress/[email protected]
  2. echo "const x = ( a ) => { return a -1 };" > index.js
  3. npx wp-scripts lint-js index.js
  4. See no formatting errors related to paren spacing
  5. npm install @wordpress/[email protected]
  6. npx wp-scripts lint-js index.js
  7. See Replace ·a·)·=>·{·return·a·-1· with a)·=>·{⏎↹return·a·-·1;⏎ (noting space before/after a is removed)

In each scenario, npx wp-scripts format follows the behavior of lint-js.

Screenshots, screen recording, code snippet

No response

Environment info

I've tried this with both Node 16 and Node 18.

With Node 16, when I run npm ls prettier, which I picked up while reading #21872, I see this:

26.12.0:

› npm ls prettier
scripts2@ /Users/jeremyfelt/Development/scripts2
└─┬ @wordpress/[email protected]
  ├─┬ @wordpress/[email protected]
  │ ├─┬ [email protected]
  │ │ └── prettier@npm:[email protected] deduped
  │ └── prettier@npm:[email protected] deduped
  ├─┬ @wordpress/[email protected]
  │ └── prettier@npm:[email protected] deduped
  └── prettier@npm:[email protected]

26.13.0:

› npm ls prettier
scripts2@ /Users/jeremyfelt/Development/scripts2
└─┬ @wordpress/[email protected]
  ├─┬ @wordpress/[email protected]
  │ ├─┬ [email protected]
  │ │ └── [email protected] deduped
  │ └── [email protected]
  ├─┬ @wordpress/[email protected]
  │ └── [email protected] deduped
  └── prettier@npm:[email protected]

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

@jeremyfelt jeremyfelt added the [Tool] WP Scripts /packages/scripts label Sep 22, 2023
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Sep 24, 2023
@jordesign jordesign changed the title wp-scripts lint-js and format should preserve spaces within parens wp-scripts lint-js and format should preserve spaces within parents Sep 24, 2023
@jeremyfelt jeremyfelt added [Type] Bug An existing feature does not function as intended and removed [Type] Enhancement A suggestion for improvement. labels Sep 25, 2023
@gziolo
Copy link
Member

gziolo commented Sep 25, 2023

It looks like #54775 will fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] WP Scripts /packages/scripts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants