Skip to content

Automated Testing: Enforce .tsx for all new React files#80123

Open
aduth wants to merge 1 commit into
trunkfrom
update/eslint-use-suppress-require-tsx
Open

Automated Testing: Enforce .tsx for all new React files#80123
aduth wants to merge 1 commit into
trunkfrom
update/eslint-use-suppress-require-tsx

Conversation

@aduth

@aduth aduth commented Jul 10, 2026

Copy link
Copy Markdown
Member

What?

Updates ESLint rules to allow enforce react/jsx-filename-extension consistently and limit extensions to only allow .tsx files. Suppresses existing issues through bulk suppressions feature.

Why?

Following these premises that we agree in principle that we want to work toward:

  • All JavaScript source code should be written as TypeScript
  • All files containing JSX should use a file extension indicating that they contain JSX

This rule provides partial coverage covering React/JSX files, which is better than nothing. It stops the addition of new files (example).

How?

  • Configured ESLint rule through project-wide tools/eslint/config.mjs
  • Ran npm run lint:js -- --suppress-all to register existing issues in tools/eslint/suppressions.json

Testing Instructions

npm run lint:js passes.

For bonus points, try adding a new .js or .jsx file containing JSX syntax and verify that npm run lint:js fails.

Use of AI Tools

No AI was used.

@aduth aduth requested review from mirka and youknowriad July 10, 2026 18:28
@aduth aduth requested a review from manzoorwanijk as a code owner July 10, 2026 18:28
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

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: aduth <aduth@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@aduth aduth added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Jul 10, 2026
@aduth aduth requested a review from adamsilverstein July 10, 2026 18:29
@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.69 MB

compressed-size-action

@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.

Looks good.

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.

This file scares the hell out of me. I had set myself as the code owner for tools/* to keep an eye on it, but this file results in my inbox being slammed with emails because this file seems to be changed more often 😄

@aduth aduth Jul 10, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is definitely a stress-test of the suppressions feature, given how this touches so many files. But as far as I can understand, it's the entire purpose of the feature, and is designed to support exactly the kind of large-scale "we want this rule but have lots of existing issues" cases like this one. I would definitely encourage adding an exclusion pattern for that code-ownership of yours 😅

I've also got a lot of other ideas for things we could do here that would likely be similar in scale, like converting our "strict" config (which is the same idea as suppressions is solving) and widening dependency-group never rule to apply everywhere (🌶️ ).

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.

Excluding this file in #80125

@github-actions

Copy link
Copy Markdown

Flaky tests detected in a2334a5.
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.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29114692474
📝 Reported issues:

@t-hamano

Copy link
Copy Markdown
Contributor

What do you think about scheduling the release of this PR for 7.1 Beta1 or later? Final development for Beta1 is currently in full swing, and merging this PR now would force them to switch to TypeScript. Forcing a conversion to TypeScript as an additional task might place a burden on them.

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

Labels

[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants