Repository navigation
Automated Testing: Extend TypeScript requirement to all internal packages - #85774
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: 0 B Total Size: 8.61 MB
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change extending TypeScript authoring requirements to internal workspaces.
No open issues 🎉
What changed in this PR
Extends Gutenberg’s existing TypeScript authoring requirement to internal workspaces, using the root package.json workspace list so newly added workspaces are covered automatically.
Changes:
- Derives ESLint coverage and workspace exclusions from
workspaces, while preserving package-specific and runtime exceptions. - Adds suppressions for existing JavaScript files in newly covered workspaces.
- Updates contributor and ESLint documentation to explain the expanded requirement.
| File | Description |
|---|---|
| tools/eslint/suppressions.json | Records existing JavaScript violations in newly covered workspaces. |
| tools/eslint/README.md | Documents workspace-wide TypeScript enforcement. |
| tools/eslint/config.mjs | Derives rule scope from workspaces and exempts Storybook’s ESLint tooling. |
| docs/contributors/code/coding-guidelines.md | Clarifies TypeScript requirements for internal workspaces and repository scripts. |
Review effort: Balanced
cc46eeb to
b2984cc
Compare
ciampo
left a comment
There was a problem hiding this comment.
No further blocking comments 🚀
| - **`import-resolver.cjs`** — Custom import resolver that maps `@wordpress/*` package imports to source files (`src/`) instead of built files (`build-module/`), so linting works without a build step. | ||
| - **`lint-js.cjs`** — Wrapper around `wp-scripts lint-js` used by `npm run lint:js`. Streams ESLint output through, detects the "stale suppressions" hint, and formats `suppressions.json` after `--prune-suppressions` runs. | ||
| - **`rules/`**: local rules that only make sense in this repository, such as `use-typescript`, which `config.mjs` scopes to the `src` and `test` trees of every package with a `tsconfig.json`, to routes and to tools, so that new files there must be TypeScript. | ||
| - **`rules/`**: local rules that only make sense in this repository, such as `use-typescript`, which `config.mjs` scopes to the `src` and `test` trees of every package and workspace with a `tsconfig.json`, so that new files there must be TypeScript. |
There was a problem hiding this comment.
Internal workspaces are checked from their root, so the src/test wording understates the rule's scope. Could we reserve that wording for packages/?
There was a problem hiding this comment.
I updated the wording here in 4c2456f. I chose to simplify the phrasing to avoid referencing details about this rule, since the bullet point is more about rules/ containing custom lint rules applying specifically to the project, and not about the implementation details of our TypeScript enforcement rule.
b2984cc to
4c2456f
Compare
|
During rebase I had to add 5 more suppressions for issues added since the pull request was opened, which is a good indication that this is an ongoing problem to get ahead of. |
It's incidental which files we cover for TypeScript. The point of the bullet is about what `rules/` contains and how those apply specifically to the project.
4c2456f to
3530d2a
Compare
|
This was a good candidate for "Require PR update" but I missed adding it before auto-merge merged the pull request. Instead, I triggered a manual run of the "Required changes from trunk" workflow with |
What?
Updates the project's ESLint configuration to extend expectation of TypeScript authoring to all workspace packages listed in
package.jsonworkspaces.Builds on #84829
Related discussion: #85769 (comment)
Why?
Same rationale as in #84829. The expectation of TypeScript should extend to internal packages, since the required Node.js version supports erasable TypeScript syntax.
How?
Rather than opting in specific packages, the implementation here uses
workspacesas a source of truth, so that new packages added over time opt in to this behavior by default.Existing issues are added as suppressions to
suppressions.jsonto be fixed over time, as they were in #84829.Testing Instructions
npm run lint:jsshould pass.Use of AI Tools
Researched and implemented with Claude Code + Opus 5.5, with manual revisions to user-facing content in
coding-guidelines.mdand code comments.