Skip to content

Add prettier, eslint and stylelint to the root package.json - #84017

Merged
jsnajdr merged 5 commits into
trunkfrom
add/root-prettier-dep
Oct 7, 2026
Merged

jsnajdr merged 5 commits into
trunkfrom
add/root-prettier-dep

Conversation

@jsnajdr

@jsnajdr jsnajdr commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

What?

Follow up to #83847 and #84025. Adds prettier, eslint and stylelint to the root package.json.

Why?

Fixing a regression introduced by the isolated deps in #83847. The Prettier, ESLint and Stylelint plugins in Cursor, VS Code or any other IDE no longer find the versions the repo installs (for Prettier, the wp-prettier fork) and use their default built-in ones. That's because these dependencies are not declared in the root package.json, so they are no longer present in the root node_modules: nothing hoists them there from subfolders anymore.

The result is, for example, that the "Format Document" command in VS Code doesn't apply the parenSpacing option.

The managed VS Code settings from #84025 work around this with custom paths, but only in VS Code and only for contributors who use the managed settings file (see #84017 (comment)).

How?

  • Adds the three root devDependencies at the versions their workspaces use, so npm links the same copies.
  • Removes the ESLint, Prettier and Stylelint paths from .vscode/settings.dist.jsonc; only the TypeScript 7 settings remain.

Testing Instructions

  1. npm install
  2. Open a JS file in VS Code or Cursor without custom tool paths and run "Format Document".
  3. Confirm parenSpacing is applied.

Testing Instructions for Keyboard

N/A

Screenshots or screencast

N/A

@jsnajdr jsnajdr self-assigned this Oct 2, 2026
@jsnajdr jsnajdr added the [Type] Code Quality Issues or PRs that relate to code quality label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: 0 B

Total Size: 8.3 MB

b0869a1 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric b3d7dc8 trunk % Change
timeToFirstByte 41 ms +7.56% -9.15% 38.05 ms +10.12% -9.33% 7.75%
largestContentfulPaint 70 ms +8.57% -8.57% 64 ms +15.63% -3.13% 9.38%
lcpMinusTtfb 29.1 ms +13.06% -8.08% 29 ms +6.55% -17.41% 0.34%
wpBeforeTemplate 19.7 ms +20.1% -6.4% 17.83 ms +24.79% -2.36% 10.49%
wpTemplate 16.13 ms +7.01% -4.9% 15.1 ms +6.49% -6.49% 6.82%
wpTotal 37.44 ms +8.89% -8.89% 34.98 ms +9.43% -9.58% 7.03%
wpMemoryUsage 7.66 MB +0% -0% 7.63 MB +0% -0% 0.46%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric b3d7dc8 trunk % Change
timeToFirstByte 32.35 ms +12.52% -2.47% 30.45 ms +6.4% -1.31% 6.24%
largestContentfulPaint 74 ms +2.7% -2.7% 72 ms +2.78% -0% 2.78%
lcpMinusTtfb 40.25 ms +4.6% -1.86% 40.5 ms +3.58% -4.69% -0.62%
wpBeforeTemplate 17.01 ms +13.76% -1.88% 16.51 ms +8.06% -2.54% 3.03%
wpTemplate 12.18 ms +3.86% -4.43% 11.62 ms +3.7% -4.04% 4.82%
wpTotal 29.59 ms +13.65% -2.94% 27.97 ms +6.61% -1.54% 5.79%
wpMemoryUsage 6.29 MB +0% -0% 6.24 MB +0% -0% 0.7%
wpDbQueries 14 +0% -0% 14 +0% -0% 0%

media-processing

Metric b3d7dc8 trunk % Change
mediaProcessingJpeg 232.79 ms +0.91% -2.07% 231.47 ms +1.48% -0.63% 0.57%
mediaProcessingAvif 3768.79 ms +0.27% -1.22% 3782.05 ms +0.57% -0.55% -0.35%
mediaProcessingJpegToAvif 2611.04 ms +0.33% -1.13% 2606.17 ms +0.53% -0.73% 0.19%

media-upload

Metric b3d7dc8 trunk % Change
jpegUploadProcessing 925.63 ms +49.2% -3.56% 1382.77 ms +2.14% -32.87% -33.06%
pngUploadProcessing 166.65 ms +4.35% -3.63% 178.2 ms +1.98% -3.54% -6.48%
largeJpegUploadProcessing 905.03 ms +1.8% -1.9% 1404.15 ms +0.78% -33.26% -35.55%
multipleImageUploadProcessing 1433.12 ms +0.87% -28.92% 1497.96 ms +0.64% -0.81% -4.33%

post-editor

Metric b3d7dc8 trunk % Change
serverResponse 511.2 ms +2.78% -7.42% 525.84 ms +3.33% -11.04% -2.78%
firstPaint 241.93 ms +10.94% -11.06% 284.43 ms +12.96% -16.53% -14.94%
domContentLoaded 1117.05 ms +0.78% -1.98% 1112.15 ms +0.56% -1.24% 0.44%
loaded 1118.5 ms +0.76% -1.98% 1113.43 ms +0.56% -1.25% 0.46%
firstContentfulPaint 461.24 ms +2.75% -3.13% 459.38 ms +0.85% -1.44% 0.4%
firstBlock 3401.86 ms +0.7% -0.49% 3373.81 ms +0.54% -1.16% 0.83%
type 17.32 ms +12.07% -6.64% 18.14 ms +4.96% -3.8% -4.52%
typeWithoutInspector 18.59 ms +8.18% -3.23% 18.35 ms +5.23% -2.18% 1.31%
typeWithTopToolbar 25.18 ms +3.49% -2.7% 23.63 ms +10.11% -8% 6.56%
typeContainer 8.8 ms +7.27% -1.93% 8.67 ms +7.5% -5.77% 1.5%
focus 109.33 ms +7.34% -7.36% 115.55 ms +10.25% -4.99% -5.38%
firstFocus 252.59 ms +0% -0% 224.68 ms +0% -0% 12.42%
selectAll 586.13 ms +2.43% -0.7% 564.4 ms +0.26% -2.05% 3.85%
listViewOpen 81.65 ms +3.2% -9.61% 77.87 ms +7.19% -7.9% 4.85%
inserterOpen 40.41 ms +7.35% -9.16% 40.63 ms +7.06% -9.97% -0.54%
inserterHover 13.02 ms +4.53% -8.6% 11.79 ms +12.21% -7.8% 10.43%
inserterSearch 8.74 ms +7.55% -11.78% 8.25 ms +9.45% -8.12% 5.94%
loadPatterns 647.19 ms +2.78% -2.34% 655.66 ms +4.15% -3.49% -1.29%
wpTotal 501.05 ms +2.88% -7.54% 515.77 ms +3.52% -11.17% -2.85%
wpMemoryUsage 13.22 MB +0% -0% 13.18 MB +0% -0% 0.25%
wpDbQueries 54 +0% -1.85% 54 +0% -1.85% 0%

site-editor

Metric b3d7dc8 trunk % Change
serverResponse 514.11 ms +4% -6.37% 501.65 ms +3.42% -3.1% 2.48%
firstPaint 244.96 ms +17.44% -2.81% 244.95 ms +20.56% -7.83% 0%
domContentLoaded 1188.37 ms +2.37% -1.08% 1181.25 ms +2.95% -0.34% 0.6%
loaded 1189.71 ms +2.38% -1.08% 1182.63 ms +2.96% -0.36% 0.6%
firstContentfulPaint 470.92 ms +1.94% -2.23% 469.44 ms +4.85% -2.99% 0.32%
firstBlock 4496.74 ms +1.37% -0.52% 4435.64 ms +0.71% -0.62% 1.38%
type 21.15 ms +2.65% -5.58% 18.38 ms +4.84% -5.6% 15.07%
navigate 123.36 ms +11.58% -1.86% 112.69 ms +9.89% -2.62% 9.47%
loadPatterns 1303.28 ms +5.34% -2.88% 1213.76 ms +3.82% -6.42% 7.38%
loadPages 1037 ms +2.19% -0.85% 1016.55 ms +1.43% -1.81% 2.01%
wpTotal 504.33 ms +4.08% -6.58% 491.69 ms +3.61% -3.13% 2.57%
wpMemoryUsage 12.26 MB +0% -0% 12.22 MB +0% -0% 0.3%
wpDbQueries 43 +2.33% -0% 43 +2.33% -0% 0%

b0869a1 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

should update the URL from the last navigation if only varies in the URL fragment in /test/e2e/specs/interactivity/router-navigate.spec.ts, passed after 1 failed attempt.
Error: expect(locator).toHaveText(expected) failed

Locator:  getByTestId('title')
Expected: "Link 1"
Received: "Main"
Timeout:  5000ms

Call log:
  - Expect "toHaveText" getByTestId('title') with timeout 5000ms
  - waiting for getByTestId('title')
    14 × locator resolved to <h2 data-testid="title">Main</h2>
       - unexpected value "Main"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigate.spec.ts:160:25

b0869a1 Run

@manzoorwanijk

Copy link
Copy Markdown
Member

@manzoorwanijk

Copy link
Copy Markdown
Member

So the settings you need in your gitignored VS Code settings is this

	// Use TypeScript from the workspace instead of VS Code's built-in TypeScript version.
	"js/ts.tsdk.path": "tools/build-scripts/node_modules/@typescript/native/lib",
	// Use ESLint, Prettier and Stylelint from the respective paths.
	"eslint.nodePath": "tools/eslint/node_modules",
	"prettier.prettierPath": "packages/prettier-config/node_modules/prettier",
	"stylelint.stylelintPath": "tools/stylelint/node_modules/stylelint",

@ciampo ciampo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addition fails check-root-dependencies. Should we add a narrowly scoped exception for Prettier to that check?

@manzoorwanijk

manzoorwanijk commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

To be clear, I don't think we should add prettier to root package.json, the contributors instead need to update the VS Code settings as mentioned above.

@ciampo

ciampo commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Oh, I see. So we should close this PR, or at most tweak the docs to suggest the correct IDE settings?

@manzoorwanijk

Copy link
Copy Markdown
Member

Oh, I see. So we should close this PR, or at most tweak the docs to suggest the correct IDE settings?

Correct.

@jsnajdr

jsnajdr commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

We had the same conversation some time ago when discussing the TypeScript plugin issue. Why would we force everyone to do a custom bit of configuration when we can just have the tools and their config files in the default location where all plugins reasonably expect it? It's a degradation of developer experience without getting anything in return.

@manzoorwanijk

Copy link
Copy Markdown
Member

We had the same conversation some time ago when discussing the TypeScript plugin issue. Why would we force everyone to do a custom bit of configuration when we can just have the tools and their config files in the default location where all plugins reasonably expect it? It's a degradation of developer experience without getting anything in return.

I would argue that we should maintain that VS Code configuration which was blocked in #77913. There are downsides to adding dependencies to root, which were cleaned up via #75041.

@manzoorwanijk

Copy link
Copy Markdown
Member

IMHO, we have a good dedicated docs section about VS Code, which should suffice the integration

@jsnajdr

jsnajdr commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

@manzoorwanijk @ciampo How do you deal with the argument that repos should be zero-config for IDEs if possible? Open basically any project on GitHub, and the IDE knows instantly how to format, lint and typecheck files. All things that are done directly in the edited file view, with inline highlights... When regularly working with 5+ repos and often checking out new ones, you don't need to worry whether a particular repo has TypeScript in tools/build-scripts/node_modules/@typescript/native/lib or in another deeply nested folder that's likely to change sooner or later.

I'm quite suprised that we're ready to give up and dismiss such a self-evident benefit with such an ease.

Now I found out that the inline linting is now also broken, because there is no longer any node_modules/eslint 🙁

The check-root-dependencies would need to be ignored in this case. It is right in the common case, but not always, and has no escape hatch or allow-list.

@manzoorwanijk

manzoorwanijk commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

How do you deal with the argument that repos should be zero-config for IDEs if possible? Open basically any project on GitHub, and the IDE knows instantly how to format, lint and typecheck files.

That is exactly what #77913 initially tried to do - to have a better integration (not just prettier) as soon as you open the IDE.

@manzoorwanijk

Copy link
Copy Markdown
Member

As an exception, we can add a few deps like ESLint, Prettier, and TypeScript to the root just to satisfy the IDEs, but since we have packages that have those as dependencies which means they will end up using the root dependencies if their own copies get removed, affecting their consumers.

If we are fine, I would love to bring back the initial version of #77913, which uses the recommended settings for VS Code.

@manzoorwanijk

Copy link
Copy Markdown
Member

One strong argument for having that managed custom config is the typescript set up for VS Code. By default, VS Code doesn't enable Native TypeScript. So, you need to use "js/ts.experimental.useTsgo": true. Also, it needs the default typescript in node_modules, which we don't have because of the way we need to use TS v6 and v7. So, you anyway need to specify "js/ts.tsdk.path".

@jsnajdr

jsnajdr commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

I would love to bring back the initial version of #77913, which uses the recommended settings for VS Code.

OK, I remember that now, it wasn't just a docs update, but it provided the default config, too 🙂 That would satisfy my request to make it zero-config from the user perspective.

I'm for revisiting that PR. The arguments against were not very strong, and mostly cultural. WordPress tries to be IDE agnostic, a similar patch for .gitignore was rejected in Core 11 years ago, it may open a can of worms (it probably won't)... On the other hand, we added .claude and CLAUDE.md without any pushback, although the same arguments apply equally well.

we can add a few deps like ESLint, Prettier, and TypeScript to the root just to satisfy the IDEs, but since we have packages that have those as dependencies which means they will end up using the root dependencies

That looks like a good tradeoff to me, getting IDE zero-config by default, versus missing dependencies not being immediately detected.

@manzoorwanijk

Copy link
Copy Markdown
Member

I'm for revisiting that PR. The arguments against were not very strong, and mostly cultural. WordPress tries to be IDE agnostic, a similar patch for .gitignore was rejected in Core 11 years ago, it may open a can of worms (it probably won't)... On the other hand, we added .claude and CLAUDE.md without any pushback, although the same arguments apply equally well.

Yes, I will create a PR to bring it back.

That looks like a good tradeoff to me, getting IDE zero-config by default, versus missing dependencies not being immediately detected.

That still doesn't solve the typescript problem I mentioned above - #84017 (comment)

@manzoorwanijk

Copy link
Copy Markdown
Member

I have created #84025 to bring the managed VS Code settings back.

@aduth

aduth commented Oct 6, 2026

Copy link
Copy Markdown
Member

I ran into a few issues today that seem to track back to recent changes for isolated workspaces, even after #84025:

  1. I got some error about env: node: Bad CPU type in executable when loading the project in Cursor. Seems to be some conflict with nvm and Mise, probably using an old version of Node. cleared up by removing nvm. Still sketchy to see random scripts being run just by loading my editor.
  2. Format-on-save uses default Prettier settings. From what I can tell, it's because I have my own .vscode/settings.json, so the script here aborts copying the templated settings.dist.jsonc rather than override.

Flagging these largely as points of contributor friction, in support of the concerns raised by @jsnajdr .

Even now, with all of our documentation, I don't know what I'm supposed to do. "Install VS Code Settings" doesn't show up as a command. I assume I probably need to do something about removing and merging my own custom settings. It's all very unclear.

I'm not sure I follow what the problems are with this pull request, as-is?

Or maybe there's some other option, like simulating how IDEs will look for node_modules/prettier and making it a pointer to the right place, or something akin to pnpm's publicHoistPattern.

@manzoorwanijk

Copy link
Copy Markdown
Member
  1. I got some error about env: node: Bad CPU type in executable when loading the project in Cursor. Seems to be some conflict with nvm and Mise, probably using an old version of Node. cleared up by removing nvm. Still sketchy to see random scripts being run just by loading my editor.

That might be related to #84057 (comment)

Editor extensions look for these tools in the root node_modules, the same
as prettier. The versions match the workspaces that use them, so npm
links the same copies.
The extensions now find these tools in the root node_modules, so only the
TypeScript 7 path is still needed.
@manzoorwanijk

Copy link
Copy Markdown
Member

I'm not sure I follow what the problems are with this pull request, as-is?

The concern is only about the dependencies in root which make them available to our prettier and eslint packages, but I think having these 3 deps in root is a tradeoff which has benefits.

I have updated the PR to add the required deps to root.

@manzoorwanijk manzoorwanijk changed the title Add prettier to the root package.json Add prettier, eslint and stylelint to the root package.json Oct 7, 2026

@manzoorwanijk manzoorwanijk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us go ahead with this PR. Someone with privileged access will need to merge it without that failing required check which fails because of the newly added deps in root.

@jsnajdr
jsnajdr merged commit 4a2d8a3 into trunk Oct 7, 2026
84 of 86 checks passed
@jsnajdr
jsnajdr deleted the add/root-prettier-dep branch October 7, 2026 07:02
@jsnajdr

jsnajdr commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

I just merged this, bypassing the required rules, namely the root dependencies check.

@github-actions github-actions Bot added this to the Gutenberg 24.2 milestone Oct 7, 2026
@aduth

aduth commented Oct 7, 2026

Copy link
Copy Markdown
Member

Thanks all, I think this is a good pragmatic outcome to reduce friction, at least in the short-term 👍

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

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants