Commit 8fc99ee
[meta] Add ESLint rule for Node.js type stripping compatibility (#2951)
## Motivation for the change, related issues
Node.js type stripping (`--experimental-strip-types`) fails on
TypeScript syntax with runtime semantics. This caused runtime errors
like:
```
SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript parameter property is not supported
```
## Implementation details
Added the existing `@typescript-eslint/parameter-properties` ESLint rule
to prevent TypeScript parameter properties that are unsupported by
Node.js type stripping.
- **Parameter properties** — `constructor(private foo: string)` →
explicit property + assignment
Fixed existing violations:
- `blueprints-v1-handler.ts`, `blueprints-v2-handler.ts`,
`website-page.ts`, `code-editor.tsx` — converted parameter properties to
explicit declarations
## Testing Instructions (or ideally a Blueprint)
```bash
npm run lint
```
Verify the rule catches new violations:
```typescript
// Should error
class Foo {
constructor(private bar: string) {}
}
```
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
> Start a new PR to add an eslint rule – only allow TypeScript syntax
that's supported by Node.js type stripping (to prevent future errors
such as this):
>
> Version number df6471b7770cee7792040577 copied to clipboard
> Use Ctrl+C to stop the server
> node:internal/modules/run_main:123
> triggerUncaughtException(
> ^
>
>
file:///Users/mho/Work/projects/xdebug/wordpress-playground/packages/playground/blueprints/src/lib/v1/compile.ts:47
> export class InvalidBlueprintError extends Error {
> constructor(message: string, public readonly validationErrors?:
unknown) {
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
> super(message);
>
> SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript parameter
property is n
> 40 references
> Copilot said: Let me search for more specific ESLint
> Let me search for more specific ESLint configuration files in the
repository:Based on my research into the WordPress Playground
repository, I can see that:
>
> The repo already has a custom ESLint plugin at
packages/meta/src/eslint-plugin-playground-dev/ with one existing rule
(avoid-wordpress-builds-dependency)
> The root .eslintrc.json already has some Node.js type stripping
support with @typescript-eslint/consistent-type-imports rule enabled
> The error you referenced is about TypeScript parameter properties
(like public readonly validationErrors), which are not supported by
Node.js type stripping. A new ESLint rule should be added to prevent
this syntax.
>
> I'll create a PR that adds an ESLint rule to disallow TypeScript
syntax that's unsupported by Node.js type stripping, specifically:
>
> Parameter properties (constructor(public foo: string))
> Enums (which also aren't supported by type stripping)
> Namespaces
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: adamziel <205419+adamziel@users.noreply.github.com>1 parent 54138fb commit 8fc99ee
File tree
5 files changed
+22
-5
lines changed- packages/playground
- client/src
- website
- playwright
- src/components/site-manager/site-file-browser
5 files changed
+22
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
0 commit comments