From d18b8e48540abfacc5896819060cda87c1ec821f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 12:11:06 +0900 Subject: [PATCH 01/88] test(rsc): add test for `use server` binding and shadowing --- .../plugin-rsc/src/transforms/hoist.test.ts | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index 22742a470..e3291e4ed 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -463,4 +463,206 @@ export async function test() { " `) }) + + // TODO: should not bind + it('shadowing local over local', async () => { + const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + if (true) { + const value = 0; + return value; + } + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + } + + ;export async function $$hoist_0_action(value) { + "use server"; + if (true) { + const value = 0; + return value; + } + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + // ok: should bind + it('shadowing partial local over local', async () => { + const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + if (true) { + const value = 1; + return value; + } + return value; + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + } + + ;export async function $$hoist_0_action(value) { + "use server"; + if (true) { + const value = 1; + return value; + } + return value; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + // ok: should not bind + it('shadowing local over global', async () => { + const input = `\ +const value = 0; +function outer() { + async function action() { + "use server"; + if (true) { + const value = 1; + return value; + } + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "const value = 0; + function outer() { + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); + } + + ;export async function $$hoist_0_action() { + "use server"; + if (true) { + const value = 1; + return value; + } + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + // ok: should not bind + it('shadowing partial local over global', async () => { + const input = `\ +const value = 0; +function outer() { + async function action() { + "use server"; + if (true) { + const value = 1; + return value; + } + return value; + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "const value = 0; + function outer() { + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); + } + + ;export async function $$hoist_0_action() { + "use server"; + if (true) { + const value = 1; + return value; + } + return value; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + // TODO: should not bind + it('shadowing local over local over global', async () => { + const input = `\ +const value = 0; +function outer() { + const value = 0; + async function action() { + "use server"; + if (true) { + const value = 1; + return value; + } + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "const value = 0; + function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + } + + ;export async function $$hoist_0_action(value) { + "use server"; + if (true) { + const value = 1; + return value; + } + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + // ok: should bind + it('shadowing partial local over local over global', async () => { + const input = `\ +const value = 0; +function outer() { + const value = 0; + async function action() { + "use server"; + if (true) { + const value = 1; + return value; + } + return value; + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "const value = 0; + function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + } + + ;export async function $$hoist_0_action(value) { + "use server"; + if (true) { + const value = 1; + return value; + } + return value; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) }) From 6afa067e4a94e07c8b55bcc0254bc268a7a4c764 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 12:21:04 +0900 Subject: [PATCH 02/88] test: more --- .../plugin-rsc/src/transforms/hoist.test.ts | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index e3291e4ed..876d7711b 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -465,7 +465,7 @@ export async function test() { }) // TODO: should not bind - it('shadowing local over local', async () => { + it('shadowing local if over local', async () => { const input = `\ function outer() { const value = 0; @@ -496,6 +496,70 @@ function outer() { `) }) + // TODO: should not bind + it('shadowing local body over local', async () => { + const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + const value = 0; + return value; + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + } + + ;export async function $$hoist_0_action(value) { + "use server"; + const value = 0; + return value; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + // TODO: should not bind. + it('shadowing local body and if over local', async () => { + const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + if (true) { + const value = 0; + return value; + } + const value = 0; + return value; + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + } + + ;export async function $$hoist_0_action(value) { + "use server"; + if (true) { + const value = 0; + return value; + } + const value = 0; + return value; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + // ok: should bind it('shadowing partial local over local', async () => { const input = `\ From 7b186d34d7741ab90fdc25391dd4d0f8e74da5be Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 12:23:31 +0900 Subject: [PATCH 03/88] chore: task note --- .../2026-04-04-hoist-variable-shadowing.md | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md new file mode 100644 index 000000000..8f12f7bff --- /dev/null +++ b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md @@ -0,0 +1,139 @@ +# Hoist: Variable Shadowing Bug in `bindVars` Collection + +## Problem + +`transformHoistInlineDirective` in `src/transforms/hoist.ts` incorrectly binds variables +that are fully shadowed inside the server function by inner block-scoped declarations. + +### Failing cases (labeled `TODO` in `hoist.test.ts`) + +**`shadowing local body over local`** — simplest case, declaration directly in action's body + +```js +function outer() { + const value = 0 + async function action() { + 'use server' + const value = 0 // declared in action's own body + return value + } +} +``` + +Current output: `.bind(null, value)` — unnecessary, outer `value` is never used. + +**`shadowing local body and if over local`** — declaration in body + if-block, all paths covered + +```js +function outer() { + const value = 0 + async function action() { + 'use server' + if (true) { + const value = 0 + return value + } + const value = 0 + return value + } +} +``` + +Current output: `.bind(null, value)` — unnecessary, outer `value` is never used. + +**`shadowing local over local`** — declaration only inside an if-block + +```js +function outer() { + const value = 0 // outer local + async function action() { + 'use server' + if (true) { + const value = 0 // shadows in if-block only + return value + } + } +} +``` + +Current output: `.bind(null, value)` — unnecessary, outer `value` is never used. + +**`shadowing local over local over global`** + +```js +const value = 0 // global +function outer() { + const value = 0 // outer local + async function action() { + 'use server' + if (true) { + const value = 1 + return value + } + } +} +``` + +Current output: `.bind(null, value)` — captures outer local unnecessarily. + +## Root Cause + +The `bindVars` filter in `hoist.ts` (~line 85): + +```ts +const bindVars = [...scope.references].filter((ref) => { + if (ref === declName) return false + const owner = scope.find_owner(ref) + return owner && owner !== scope && owner !== analyzed.scope +}) +``` + +The core problem: **`analyzed.map.get(functionNode)` returns the scope for the function's +parameter list, not its body block.** In periscopic, `const`/`let` declarations in the +function body live in a child `BlockStatement` scope, separate from the param scope. + +So `scope` here is the _param scope_ of `action`, and: + +1. **`scope.references`** includes `"value"` (it is referenced in the body, not declared + among the params). + +2. **`scope.find_owner("value")`** walks upward from the param scope and finds `outer` — + it never looks downward into the body's block scope where `const value = 0` is declared. + +Result: even a `const value` declared directly in `action`'s own body causes unnecessary +binding, because the code is anchored to the wrong scope (params, not body). + +This makes the if-block cases a consequence of the same root issue — if the body-level +block scope is already invisible to `find_owner`, nested block scopes inside the body are +doubly so. + +## Correct Cases (labeled `ok` in `hoist.test.ts`) + +| Test | Behavior | Why correct | +| ------------------------------------------------ | -------- | ------------------------------------------------------------- | +| `shadowing partial local over local` | binds | `return value` after if-block uses outer local | +| `shadowing local over global` | no bind | no outer local; global filtered by `owner !== analyzed.scope` | +| `shadowing partial local over global` | no bind | `return value` uses global, no outer local | +| `shadowing local over local over global` | no bind | no outer local in `outer`; only global | +| `shadowing partial local over local over global` | binds | `return value` after if-block uses outer local | + +## Planned Fix + +Replace the periscopic-based analysis with a custom scope walk that resolves references +at the **identifier occurrence level** rather than at the **name level**. + +For each `Identifier` node encountered during the walk, determine which scope it resolves +to by checking both upward (outer function scopes) and downward (inner block scopes already +visited). A variable should be added to `bindVars` only if at least one of its reference +occurrences resolves to a scope that is an ancestor of `action` but not the module root. + +This approach also opens the door to a **single-pass implementation** (maintain a scope +stack during descent, classify each reference in-place) rather than the current two-pass +approach (periscopic analysis + estree-walker transform). + +### Note on pre-processing + +The current code mutates the AST before calling `analyze()` to strip re-exports +(`ExportAllDeclaration`, `ExportNamedDeclaration` without declaration) because they confuse +periscopic. A custom walker will need to handle or replicate this, or skip those node types +inline. From 9f92bbf16c1e16f38f21911e812562100b7cdd23 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 12:44:09 +0900 Subject: [PATCH 04/88] chore: more plan --- .../2026-04-04-hoist-variable-shadowing.md | 98 +++++++++++++++++-- 1 file changed, 88 insertions(+), 10 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md index 8f12f7bff..ac8334c79 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md @@ -117,23 +117,101 @@ doubly so. | `shadowing local over local over global` | no bind | no outer local in `outer`; only global | | `shadowing partial local over local over global` | binds | `return value` after if-block uses outer local | +## Reference Repos + +### oxc-walker (`~/code/others/oxc-walker`) + +The most directly relevant reference. Provides `getUndeclaredIdentifiersInFunction()` +which is conceptually exactly what `bindVars` collection needs. + +**Key design — two-pass with frozen scope:** + +1. First pass over the function node: build a scope tree, record all declarations + (respecting `var` hoisting vs `let`/`const` block scoping) +2. `freeze()` — locks scope data so hoisting decisions are final +3. Second pass: for each `Identifier` in a reference position, walk up the scope + hierarchy to find its owner; if undeclared within the function → free variable + +**API surface relevant to us:** + +- `walk(input: Program | Node, options)` — accepts a pre-parsed AST directly +- `ScopeTracker` — hierarchical scope tracking, exported standalone +- `getUndeclaredIdentifiersInFunction(node)` — finds names not declared within the + function, but does NOT distinguish module-level from outer-function-scope declarations. + Not directly usable: we need only the subset whose owner is between the action and + the module root (i.e. closure variables), not module-level globals. + +**Compatibility:** oxc-walker targets oxc-parser, which outputs ESTree-compatible AST — +the same format as Vite 8's `parseAstAsync` (which uses oxc-parser internally). So +`walk()` and `ScopeTracker` work directly on our existing AST without re-parsing. + +**Dependency note:** `ScopeTracker` itself has no runtime dependency on oxc-parser +(only `import type`). However, `walk.ts` has a static `import { parseSync } from +"oxc-parser"` at the top, so oxc-parser must be present in node_modules even if +`parseAndWalk` is never called. Since Vite 8 ships oxc-parser, it is available +transitively — but not a guaranteed public API surface. + +### Vite `ssrTransform.ts` (`~/code/others/vite/packages/vite/src/node/ssr/ssrTransform.ts`) + +Shows a working ESTree + `estree-walker` scope implementation (lines ~456–760). + +**Key patterns:** + +- `scopeMap: WeakMap>` — maps each scope node to its declared names +- `varKindStack` — tracks `var` vs `let`/`const` to determine whether to hoist to + function scope or stay in block scope +- `isInScope(name, parents)` — walks the parent stack upward to check shadowing +- `handlePattern()` — recursively extracts names from destructuring patterns + +Designed for SSR module rewriting (not free-variable extraction), but the scope-stack +mechanics are directly adaptable. Uses `estree-walker`, which is already a dependency +of `plugin-rsc`. + +### periscopic (`~/code/others/periscopic`) + +Current dependency. The bug is confirmed in its source: + +For `FunctionDeclaration`, periscopic calls `push(node, false)` to enter the function +scope, then records params in that scope. The function body's `BlockStatement` becomes +a separate **child** block scope. So `map.get(functionNode)` returns the **param scope**, +not the body scope. + +Consequence: `const`/`let` declared directly in the function body are in a child scope +invisible to `find_owner` when called from the param scope anchor. `find_owner` walks +upward and finds the outer function's declaration instead. + +**Plan:** drop periscopic as a dep entirely, but directly copy `extract_identifiers` and +`extract_names` into the codebase. They are small, correct, well-tested ESTree utilities +for extracting binding names from destructuring patterns — no need to rewrite them from +scratch when the source is a known-good reference. + ## Planned Fix Replace the periscopic-based analysis with a custom scope walk that resolves references at the **identifier occurrence level** rather than at the **name level**. -For each `Identifier` node encountered during the walk, determine which scope it resolves -to by checking both upward (outer function scopes) and downward (inner block scopes already -visited). A variable should be added to `bindVars` only if at least one of its reference -occurrences resolves to a scope that is an ancestor of `action` but not the module root. +Two options: + +**Option A — use `oxc-walker` directly** +Call `getUndeclaredIdentifiersInFunction` or use `ScopeTracker` + `walk` with the +pre-parsed AST. Least code, but adds a new dep and relies on oxc-parser being available +via Vite. + +**Option B — custom scope tracker with `estree-walker` (preferred)** +Implement a two-pass frozen-scope approach inspired by oxc-walker, using `estree-walker` +(already a dep). Tailored narrowly to the one task: find free variables of a server +function relative to the module root. No new deps. + +For each `Identifier` in a reference position, determine which scope it resolves to by +walking up the scope stack. A variable is added to `bindVars` only if at least one +reference occurrence resolves to a scope that is an ancestor of the action function but +not the module root. -This approach also opens the door to a **single-pass implementation** (maintain a scope -stack during descent, classify each reference in-place) rather than the current two-pass -approach (periscopic analysis + estree-walker transform). +This also opens the door to a **single-pass implementation** (maintain a scope stack +during descent, classify each reference in-place). ### Note on pre-processing The current code mutates the AST before calling `analyze()` to strip re-exports -(`ExportAllDeclaration`, `ExportNamedDeclaration` without declaration) because they confuse -periscopic. A custom walker will need to handle or replicate this, or skip those node types -inline. +(`ExportAllDeclaration`, `ExportNamedDeclaration` without declaration) because they +confuse periscopic. A custom walker can skip those node types inline instead. From 100c63c05fb6663dfa41003bc5bb7d4aabc578d0 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 12:54:32 +0900 Subject: [PATCH 05/88] wip: buildScopeTree --- packages/plugin-rsc/src/transforms/hoist.ts | 249 +++++++++++++++++++- 1 file changed, 248 insertions(+), 1 deletion(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index eb5bf15ba..3e193126f 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -1,5 +1,11 @@ import { tinyassert } from '@hiogawa/utils' -import type { Program, Literal } from 'estree' +import type { + Program, + Literal, + FunctionDeclaration, + FunctionExpression, + ArrowFunctionExpression, +} from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' import { analyze } from 'periscopic' @@ -190,3 +196,244 @@ export function findDirectives(ast: Program, directive: string): Literal[] { }) return nodes } + +// ── Custom scope analysis (prototype) ───────────────────────────────────────── +// Replacement for periscopic's analyze() to correctly handle variable shadowing. +// See docs/notes/2026-04-04-hoist-variable-shadowing.md + +type AnyFunctionNode = + | FunctionDeclaration + | FunctionExpression + | ArrowFunctionExpression + +function isFunctionNode(node: any): node is AnyFunctionNode { + return ( + node.type === 'FunctionDeclaration' || + node.type === 'FunctionExpression' || + node.type === 'ArrowFunctionExpression' + ) +} + +class OwnScope { + declarations = new Set() + + constructor( + public readonly parent: OwnScope | null, + public readonly isFunction: boolean, + ) {} + + findOwner(name: string): OwnScope | null { + if (this.declarations.has(name)) return this + return this.parent?.findOwner(name) ?? null + } + + nearestFunction(): OwnScope { + return this.isFunction ? this : this.parent!.nearestFunction() + } +} + +// First pass: walk the whole module and build a scope tree. +// Returns the module-level scope and a map from scope-creating nodes to their scopes. +function buildScopeTree(ast: Program): { + moduleScope: OwnScope + nodeToScope: WeakMap +} { + const moduleScope = new OwnScope(null, true) + const nodeToScope = new WeakMap() + nodeToScope.set(ast, moduleScope) + let current = moduleScope + + walk(ast, { + enter(node, parent) { + const n = node as any + const p = parent as any + + if (isFunctionNode(n)) { + // Hoist function declaration name to the enclosing function scope + if (n.type === 'FunctionDeclaration' && n.id) { + current.nearestFunction().declarations.add(n.id.name) + } + const scope = new OwnScope(current, true) + nodeToScope.set(node, scope) + current = scope + // Params belong to the function scope (not a separate block scope — this + // is the key fix over periscopic which separates params from body) + for (const param of n.params) { + for (const name of ownExtractNames(param)) { + scope.declarations.add(name) + } + } + // FunctionExpression name is scoped to its own body + if (n.type === 'FunctionExpression' && n.id) { + scope.declarations.add(n.id.name) + } + } else if (n.type === 'BlockStatement' && !isFunctionNode(p)) { + // Block scope — but skip the direct body BlockStatement of a function, + // which is already covered by the function's own scope above + const scope = new OwnScope(current, false) + nodeToScope.set(node, scope) + current = scope + } else if (n.type === 'CatchClause') { + const scope = new OwnScope(current, false) + nodeToScope.set(node, scope) + current = scope + if (n.param) { + for (const name of ownExtractNames(n.param)) { + scope.declarations.add(name) + } + } + } else if (n.type === 'VariableDeclaration') { + const target = n.kind === 'var' ? current.nearestFunction() : current + for (const decl of n.declarations) { + for (const name of ownExtractNames(decl.id)) { + target.declarations.add(name) + } + } + } else if (n.type === 'ClassDeclaration' && n.id) { + current.declarations.add(n.id.name) + } + }, + leave(node) { + const scope = nodeToScope.get(node) + if (scope && node !== ast) { + current = scope.parent! + } + }, + }) + + return { moduleScope, nodeToScope } +} + +// Second pass: walk the server function body and collect variables that resolve +// to a scope strictly between the function and the module root (i.e. closures). +function getOwnBindVars( + fn: AnyFunctionNode, + declName: string | false, + moduleScope: OwnScope, + nodeToScope: WeakMap, +): string[] { + const fnScope = nodeToScope.get(fn)! + const result = new Set() + let current = fnScope + + walk(fn.body as any, { + enter(node, parent) { + const n = node as any + const p = parent as any + + // Skip nested functions — they handle their own binding + if (isFunctionNode(n)) { + this.skip() + return + } + + const scope = nodeToScope.get(node) + if (scope) current = scope + + if ( + n.type === 'Identifier' && + n.name !== declName && + isReferenceId(n, p) + ) { + const owner = current.findOwner(n.name) + if (owner && isIntermediateScope(owner, fnScope, moduleScope)) { + result.add(n.name) + } + } + }, + leave(node) { + const scope = nodeToScope.get(node) + if (scope) current = scope.parent ?? fnScope + }, + }) + + return [...result] +} + +// Is `owner` strictly between `fnScope` and `moduleScope` in the ancestor chain? +function isIntermediateScope( + owner: OwnScope, + fnScope: OwnScope, + moduleScope: OwnScope, +): boolean { + if (owner === moduleScope) return false + let curr = fnScope.parent + while (curr) { + if (curr === owner) return true + curr = curr.parent + } + return false +} + +function isReferenceId(node: any, parent: any): boolean { + if (!parent) return true + switch (parent.type) { + case 'VariableDeclarator': + return parent.id !== node + case 'MemberExpression': + return parent.computed || parent.object === node + case 'Property': + return parent.computed || parent.value === node + case 'FunctionDeclaration': + case 'FunctionExpression': + case 'ClassDeclaration': + case 'ClassExpression': + return parent.id !== node + case 'AssignmentPattern': + return parent.right === node + case 'RestElement': + case 'ArrayPattern': + return false + case 'LabeledStatement': + case 'BreakStatement': + case 'ContinueStatement': + return false + case 'ImportSpecifier': + case 'ImportDefaultSpecifier': + case 'ImportNamespaceSpecifier': + case 'ExportSpecifier': + return false + default: + return true + } +} + +// Copied from periscopic — extract binding names from a pattern node +function ownExtractNames(param: any): string[] { + const names: string[] = [] + ownExtractIdentifiers(param, names) + return names +} + +function ownExtractIdentifiers(param: any, names: string[]): void { + switch (param.type) { + case 'Identifier': + names.push(param.name) + break + case 'MemberExpression': { + let obj = param + while (obj.type === 'MemberExpression') obj = obj.object + names.push(obj.name) + break + } + case 'ObjectPattern': + for (const prop of param.properties) { + ownExtractIdentifiers( + prop.type === 'RestElement' ? prop : prop.value, + names, + ) + } + break + case 'ArrayPattern': + for (const el of param.elements) { + if (el) ownExtractIdentifiers(el, names) + } + break + case 'RestElement': + ownExtractIdentifiers(param.argument, names) + break + case 'AssignmentPattern': + ownExtractIdentifiers(param.left, names) + break + } +} From c11c39d4eac464db83a9161617eacfef6d018734 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 13:00:00 +0900 Subject: [PATCH 06/88] wip: intergrate buildScopeTree --- .../plugin-rsc/src/transforms/hoist.test.ts | 24 ++--- packages/plugin-rsc/src/transforms/hoist.ts | 87 +++++++------------ 2 files changed, 44 insertions(+), 67 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index 876d7711b..8236470ba 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -464,7 +464,7 @@ export async function test() { `) }) - // TODO: should not bind + // ok: should not bind it('shadowing local if over local', async () => { const input = `\ function outer() { @@ -481,10 +481,10 @@ function outer() { expect(await testTransform(input)).toMatchInlineSnapshot(` "function outer() { const value = 0; - const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); } - ;export async function $$hoist_0_action(value) { + ;export async function $$hoist_0_action() { "use server"; if (true) { const value = 0; @@ -496,7 +496,7 @@ function outer() { `) }) - // TODO: should not bind + // ok: should not bind it('shadowing local body over local', async () => { const input = `\ function outer() { @@ -511,10 +511,10 @@ function outer() { expect(await testTransform(input)).toMatchInlineSnapshot(` "function outer() { const value = 0; - const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); } - ;export async function $$hoist_0_action(value) { + ;export async function $$hoist_0_action() { "use server"; const value = 0; return value; @@ -524,7 +524,7 @@ function outer() { `) }) - // TODO: should not bind. + // ok: should not bind it('shadowing local body and if over local', async () => { const input = `\ function outer() { @@ -543,10 +543,10 @@ function outer() { expect(await testTransform(input)).toMatchInlineSnapshot(` "function outer() { const value = 0; - const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); } - ;export async function $$hoist_0_action(value) { + ;export async function $$hoist_0_action() { "use server"; if (true) { const value = 0; @@ -660,7 +660,7 @@ function outer() { `) }) - // TODO: should not bind + // ok: should not bind it('shadowing local over local over global', async () => { const input = `\ const value = 0; @@ -679,10 +679,10 @@ function outer() { "const value = 0; function outer() { const value = 0; - const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); } - ;export async function $$hoist_0_action(value) { + ;export async function $$hoist_0_action() { "use server"; if (true) { const value = 1; diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 3e193126f..1b03fac9e 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -1,4 +1,3 @@ -import { tinyassert } from '@hiogawa/utils' import type { Program, Literal, @@ -8,7 +7,6 @@ import type { } from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' -import { analyze } from 'periscopic' export function transformHoistInlineDirective( input: string, @@ -43,19 +41,7 @@ export function transformHoistInlineDirective( ? exactRegex(options.directive) : options.directive - // re-export somehow confuses periscopic scopes so remove them before analysis - walk(ast, { - enter(node) { - if (node.type === 'ExportAllDeclaration') { - this.remove() - } - if (node.type === 'ExportNamedDeclaration' && !node.declaration) { - this.remove() - } - }, - }) - - const analyzed = analyze(ast) + const scopeTree = buildScopeTree(ast) const names: string[] = [] walk(ast, { @@ -77,8 +63,6 @@ export function transformHoistInlineDirective( ) } - const scope = analyzed.map.get(node) - tinyassert(scope) const declName = node.type === 'FunctionDeclaration' && node.id.name const originalName = declName || @@ -87,15 +71,7 @@ export function transformHoistInlineDirective( parent.id.name) || 'anonymous_server_function' - // bind variables which are neither global nor in own scope - const bindVars = [...scope.references].filter((ref) => { - // declared function itself is included as reference - if (ref === declName) { - return false - } - const owner = scope.find_owner(ref) - return owner && owner !== scope && owner !== analyzed.scope - }) + const bindVars = getBindVars(node, declName, scopeTree) let newParams = [ ...bindVars, ...node.params.map((n) => input.slice(n.start, n.end)), @@ -214,32 +190,34 @@ function isFunctionNode(node: any): node is AnyFunctionNode { ) } -class OwnScope { +class Scope { declarations = new Set() constructor( - public readonly parent: OwnScope | null, + public readonly parent: Scope | null, public readonly isFunction: boolean, ) {} - findOwner(name: string): OwnScope | null { + findOwner(name: string): Scope | null { if (this.declarations.has(name)) return this return this.parent?.findOwner(name) ?? null } - nearestFunction(): OwnScope { + nearestFunction(): Scope { return this.isFunction ? this : this.parent!.nearestFunction() } } +type ScopeTree = { + moduleScope: Scope + nodeToScope: WeakMap +} + // First pass: walk the whole module and build a scope tree. // Returns the module-level scope and a map from scope-creating nodes to their scopes. -function buildScopeTree(ast: Program): { - moduleScope: OwnScope - nodeToScope: WeakMap -} { - const moduleScope = new OwnScope(null, true) - const nodeToScope = new WeakMap() +function buildScopeTree(ast: Program): ScopeTree { + const moduleScope = new Scope(null, true) + const nodeToScope = new WeakMap() nodeToScope.set(ast, moduleScope) let current = moduleScope @@ -253,13 +231,13 @@ function buildScopeTree(ast: Program): { if (n.type === 'FunctionDeclaration' && n.id) { current.nearestFunction().declarations.add(n.id.name) } - const scope = new OwnScope(current, true) + const scope = new Scope(current, true) nodeToScope.set(node, scope) current = scope // Params belong to the function scope (not a separate block scope — this // is the key fix over periscopic which separates params from body) for (const param of n.params) { - for (const name of ownExtractNames(param)) { + for (const name of extractNames(param)) { scope.declarations.add(name) } } @@ -270,22 +248,22 @@ function buildScopeTree(ast: Program): { } else if (n.type === 'BlockStatement' && !isFunctionNode(p)) { // Block scope — but skip the direct body BlockStatement of a function, // which is already covered by the function's own scope above - const scope = new OwnScope(current, false) + const scope = new Scope(current, false) nodeToScope.set(node, scope) current = scope } else if (n.type === 'CatchClause') { - const scope = new OwnScope(current, false) + const scope = new Scope(current, false) nodeToScope.set(node, scope) current = scope if (n.param) { - for (const name of ownExtractNames(n.param)) { + for (const name of extractNames(n.param)) { scope.declarations.add(name) } } } else if (n.type === 'VariableDeclaration') { const target = n.kind === 'var' ? current.nearestFunction() : current for (const decl of n.declarations) { - for (const name of ownExtractNames(decl.id)) { + for (const name of extractNames(decl.id)) { target.declarations.add(name) } } @@ -306,11 +284,10 @@ function buildScopeTree(ast: Program): { // Second pass: walk the server function body and collect variables that resolve // to a scope strictly between the function and the module root (i.e. closures). -function getOwnBindVars( +function getBindVars( fn: AnyFunctionNode, declName: string | false, - moduleScope: OwnScope, - nodeToScope: WeakMap, + { moduleScope, nodeToScope }: ScopeTree, ): string[] { const fnScope = nodeToScope.get(fn)! const result = new Set() @@ -352,9 +329,9 @@ function getOwnBindVars( // Is `owner` strictly between `fnScope` and `moduleScope` in the ancestor chain? function isIntermediateScope( - owner: OwnScope, - fnScope: OwnScope, - moduleScope: OwnScope, + owner: Scope, + fnScope: Scope, + moduleScope: Scope, ): boolean { if (owner === moduleScope) return false let curr = fnScope.parent @@ -399,13 +376,13 @@ function isReferenceId(node: any, parent: any): boolean { } // Copied from periscopic — extract binding names from a pattern node -function ownExtractNames(param: any): string[] { +function extractNames(param: any): string[] { const names: string[] = [] - ownExtractIdentifiers(param, names) + extractIdentifiers(param, names) return names } -function ownExtractIdentifiers(param: any, names: string[]): void { +function extractIdentifiers(param: any, names: string[]): void { switch (param.type) { case 'Identifier': names.push(param.name) @@ -418,7 +395,7 @@ function ownExtractIdentifiers(param: any, names: string[]): void { } case 'ObjectPattern': for (const prop of param.properties) { - ownExtractIdentifiers( + extractIdentifiers( prop.type === 'RestElement' ? prop : prop.value, names, ) @@ -426,14 +403,14 @@ function ownExtractIdentifiers(param: any, names: string[]): void { break case 'ArrayPattern': for (const el of param.elements) { - if (el) ownExtractIdentifiers(el, names) + if (el) extractIdentifiers(el, names) } break case 'RestElement': - ownExtractIdentifiers(param.argument, names) + extractIdentifiers(param.argument, names) break case 'AssignmentPattern': - ownExtractIdentifiers(param.left, names) + extractIdentifiers(param.left, names) break } } From a580b42e4bbb8f467de27c43d6305bd7b59c9b87 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 13:09:21 +0900 Subject: [PATCH 07/88] chore: still planning --- .../2026-04-04-hoist-variable-shadowing.md | 181 ++++++------------ 1 file changed, 57 insertions(+), 124 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md index ac8334c79..e67e04f18 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md @@ -5,9 +5,9 @@ `transformHoistInlineDirective` in `src/transforms/hoist.ts` incorrectly binds variables that are fully shadowed inside the server function by inner block-scoped declarations. -### Failing cases (labeled `TODO` in `hoist.test.ts`) +### Failing cases (all fixed, were labeled `TODO` in `hoist.test.ts`) -**`shadowing local body over local`** — simplest case, declaration directly in action's body +**`shadowing local body over local`** — declaration directly in action's body ```js function outer() { @@ -20,9 +20,7 @@ function outer() { } ``` -Current output: `.bind(null, value)` — unnecessary, outer `value` is never used. - -**`shadowing local body and if over local`** — declaration in body + if-block, all paths covered +**`shadowing local body and if over local`** — declaration in body + if-block ```js function outer() { @@ -39,31 +37,27 @@ function outer() { } ``` -Current output: `.bind(null, value)` — unnecessary, outer `value` is never used. - **`shadowing local over local`** — declaration only inside an if-block ```js function outer() { - const value = 0 // outer local + const value = 0 async function action() { 'use server' if (true) { - const value = 0 // shadows in if-block only + const value = 0 return value } } } ``` -Current output: `.bind(null, value)` — unnecessary, outer `value` is never used. - **`shadowing local over local over global`** ```js -const value = 0 // global +const value = 0 function outer() { - const value = 0 // outer local + const value = 0 async function action() { 'use server' if (true) { @@ -74,144 +68,83 @@ function outer() { } ``` -Current output: `.bind(null, value)` — captures outer local unnecessarily. - -## Root Cause +## Root Cause (periscopic) -The `bindVars` filter in `hoist.ts` (~line 85): +The original periscopic-based code: ```ts +const scope = analyzed.map.get(node) // returns param scope, not body scope const bindVars = [...scope.references].filter((ref) => { - if (ref === declName) return false - const owner = scope.find_owner(ref) + const owner = scope.find_owner(ref) // name-string lookup walking upward return owner && owner !== scope && owner !== analyzed.scope }) ``` -The core problem: **`analyzed.map.get(functionNode)` returns the scope for the function's -parameter list, not its body block.** In periscopic, `const`/`let` declarations in the -function body live in a child `BlockStatement` scope, separate from the param scope. +Two layered problems: -So `scope` here is the _param scope_ of `action`, and: +1. **Wrong scope anchor:** `analyzed.map.get(functionNode)` returns the param scope. + Body-level `const`/`let` declarations live in a separate child `BlockStatement` scope + in periscopic's model. So `find_owner` is called from the wrong starting point. -1. **`scope.references`** includes `"value"` (it is referenced in the body, not declared - among the params). +2. **Name-based resolution:** `scope.references` is `Set` and `find_owner` takes + a string. There is no connection between a specific reference occurrence and the scope + that owns it — you can only ask "does ANY declaration of this name live outside?" not + "does THIS specific reference resolve outside?". Shadowing is invisible. -2. **`scope.find_owner("value")`** walks upward from the param scope and finds `outer` — - it never looks downward into the body's block scope where `const value = 0` is declared. +## Interim Fix (current state) -Result: even a `const value` declared directly in `action`'s own body causes unnecessary -binding, because the code is anchored to the wrong scope (params, not body). +Replaced periscopic's `analyze()` with a custom `buildScopeTree` + `getBindVars` that +correctly unifies function params and body into one scope. This fixes the param-scope +anchor problem and makes all TODO tests pass. -This makes the if-block cases a consequence of the same root issue — if the body-level -block scope is already invisible to `find_owner`, nested block scopes inside the body are -doubly so. +However, this is still the same **name-based design**: `Scope` holds +`declarations: Set`, and `findOwner(name: string)` walks up the chain by name. +The structural flaw remains — it works for the current test cases because +`buildScopeTree` now anchors correctly, but the abstraction is still wrong in principle. -## Correct Cases (labeled `ok` in `hoist.test.ts`) +## Target Design -| Test | Behavior | Why correct | -| ------------------------------------------------ | -------- | ------------------------------------------------------------- | -| `shadowing partial local over local` | binds | `return value` after if-block uses outer local | -| `shadowing local over global` | no bind | no outer local; global filtered by `owner !== analyzed.scope` | -| `shadowing partial local over global` | no bind | `return value` uses global, no outer local | -| `shadowing local over local over global` | no bind | no outer local in `outer`; only global | -| `shadowing partial local over local over global` | binds | `return value` after if-block uses outer local | +The correct fix is **reference-position resolution**: for each `Identifier` node +encountered in a reference position during the AST walk, determine which scope owns it +**at the point it appears** using the live scope stack at that moment. -## Reference Repos +This is fundamentally different from name-based lookup: -### oxc-walker (`~/code/others/oxc-walker`) +- When you enter a block that declares `value`, you push that scope onto the stack +- When you encounter a reference to `value`, you check the stack top-down +- Shadowing is handled naturally by stack order — inner declarations are found first +- No post-hoc name string matching detached from traversal position -The most directly relevant reference. Provides `getUndeclaredIdentifiersInFunction()` -which is conceptually exactly what `bindVars` collection needs. +Concretely: the scope stack itself during the walk IS the resolution context. Each +identifier reference is resolved inline, not by querying a pre-built map with a string. +`declarations: Set` + `findOwner(string)` should be replaced with a stack where +each frame knows which identifiers it introduces, resolved per occurrence. -**Key design — two-pass with frozen scope:** +## Reference Repos -1. First pass over the function node: build a scope tree, record all declarations - (respecting `var` hoisting vs `let`/`const` block scoping) -2. `freeze()` — locks scope data so hoisting decisions are final -3. Second pass: for each `Identifier` in a reference position, walk up the scope - hierarchy to find its owner; if undeclared within the function → free variable +### oxc-walker (`~/code/others/oxc-walker`) -**API surface relevant to us:** +**Key design — two-pass with frozen scope:** -- `walk(input: Program | Node, options)` — accepts a pre-parsed AST directly -- `ScopeTracker` — hierarchical scope tracking, exported standalone -- `getUndeclaredIdentifiersInFunction(node)` — finds names not declared within the - function, but does NOT distinguish module-level from outer-function-scope declarations. - Not directly usable: we need only the subset whose owner is between the action and - the module root (i.e. closure variables), not module-level globals. +1. First pass: build scope tree, record all declarations (hoisting, `var` vs `let`/`const`) +2. `freeze()` — locks scope data +3. Second pass: for each `Identifier` in reference position, walk up scope hierarchy -**Compatibility:** oxc-walker targets oxc-parser, which outputs ESTree-compatible AST — -the same format as Vite 8's `parseAstAsync` (which uses oxc-parser internally). So -`walk()` and `ScopeTracker` work directly on our existing AST without re-parsing. +`getUndeclaredIdentifiersInFunction` is close but not directly usable — it doesn't +distinguish module-level globals from outer-function-scope closures. We need only the +subset whose owner is strictly between the action and the module root. -**Dependency note:** `ScopeTracker` itself has no runtime dependency on oxc-parser -(only `import type`). However, `walk.ts` has a static `import { parseSync } from -"oxc-parser"` at the top, so oxc-parser must be present in node_modules even if -`parseAndWalk` is never called. Since Vite 8 ships oxc-parser, it is available -transitively — but not a guaranteed public API surface. +**Compatibility:** targets oxc-parser which outputs ESTree — same as Vite 8's +`parseAstAsync`. `walk()` accepts a pre-parsed AST directly. ### Vite `ssrTransform.ts` (`~/code/others/vite/packages/vite/src/node/ssr/ssrTransform.ts`) -Shows a working ESTree + `estree-walker` scope implementation (lines ~456–760). - -**Key patterns:** - -- `scopeMap: WeakMap>` — maps each scope node to its declared names -- `varKindStack` — tracks `var` vs `let`/`const` to determine whether to hoist to - function scope or stay in block scope -- `isInScope(name, parents)` — walks the parent stack upward to check shadowing -- `handlePattern()` — recursively extracts names from destructuring patterns - -Designed for SSR module rewriting (not free-variable extraction), but the scope-stack -mechanics are directly adaptable. Uses `estree-walker`, which is already a dependency -of `plugin-rsc`. +Working ESTree + `estree-walker` scope implementation (lines ~456–760). Uses a live scope +stack during the walk (`scopeMap`, `varKindStack`, `isInScope`) — closer to the target +design. `estree-walker` is already a dep of `plugin-rsc`. ### periscopic (`~/code/others/periscopic`) -Current dependency. The bug is confirmed in its source: - -For `FunctionDeclaration`, periscopic calls `push(node, false)` to enter the function -scope, then records params in that scope. The function body's `BlockStatement` becomes -a separate **child** block scope. So `map.get(functionNode)` returns the **param scope**, -not the body scope. - -Consequence: `const`/`let` declared directly in the function body are in a child scope -invisible to `find_owner` when called from the param scope anchor. `find_owner` walks -upward and finds the outer function's declaration instead. - -**Plan:** drop periscopic as a dep entirely, but directly copy `extract_identifiers` and -`extract_names` into the codebase. They are small, correct, well-tested ESTree utilities -for extracting binding names from destructuring patterns — no need to rewrite them from -scratch when the source is a known-good reference. - -## Planned Fix - -Replace the periscopic-based analysis with a custom scope walk that resolves references -at the **identifier occurrence level** rather than at the **name level**. - -Two options: - -**Option A — use `oxc-walker` directly** -Call `getUndeclaredIdentifiersInFunction` or use `ScopeTracker` + `walk` with the -pre-parsed AST. Least code, but adds a new dep and relies on oxc-parser being available -via Vite. - -**Option B — custom scope tracker with `estree-walker` (preferred)** -Implement a two-pass frozen-scope approach inspired by oxc-walker, using `estree-walker` -(already a dep). Tailored narrowly to the one task: find free variables of a server -function relative to the module root. No new deps. - -For each `Identifier` in a reference position, determine which scope it resolves to by -walking up the scope stack. A variable is added to `bindVars` only if at least one -reference occurrence resolves to a scope that is an ancestor of the action function but -not the module root. - -This also opens the door to a **single-pass implementation** (maintain a scope stack -during descent, classify each reference in-place). - -### Note on pre-processing - -The current code mutates the AST before calling `analyze()` to strip re-exports -(`ExportAllDeclaration`, `ExportNamedDeclaration` without declaration) because they -confuse periscopic. A custom walker can skip those node types inline instead. +Dropped as a dep. `extract_identifiers` / `extract_names` copied directly into the +codebase — small, correct, well-tested utilities for extracting binding names from +destructuring patterns. From 8182c606680715732d3eecc3464a45febb71669f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 13:18:48 +0900 Subject: [PATCH 08/88] wip: still bad --- packages/plugin-rsc/src/transforms/hoist.ts | 65 ++++++++++----------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 1b03fac9e..8c09bec44 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -198,18 +198,23 @@ class Scope { public readonly isFunction: boolean, ) {} - findOwner(name: string): Scope | null { - if (this.declarations.has(name)) return this - return this.parent?.findOwner(name) ?? null - } - nearestFunction(): Scope { return this.isFunction ? this : this.parent!.nearestFunction() } + + // Returns ordered chain from module root to this scope (inclusive) + chain(): Scope[] { + const result: Scope[] = [] + let curr: Scope | null = this + while (curr) { + result.unshift(curr) + curr = curr.parent + } + return result + } } type ScopeTree = { - moduleScope: Scope nodeToScope: WeakMap } @@ -220,6 +225,7 @@ function buildScopeTree(ast: Program): ScopeTree { const nodeToScope = new WeakMap() nodeToScope.set(ast, moduleScope) let current = moduleScope + // note: moduleScope stored under ast so chain() can walk up to it walk(ast, { enter(node, parent) { @@ -273,13 +279,13 @@ function buildScopeTree(ast: Program): ScopeTree { }, leave(node) { const scope = nodeToScope.get(node) - if (scope && node !== ast) { - current = scope.parent! + if (scope?.parent) { + current = scope.parent } }, }) - return { moduleScope, nodeToScope } + return { nodeToScope } } // Second pass: walk the server function body and collect variables that resolve @@ -287,11 +293,13 @@ function buildScopeTree(ast: Program): ScopeTree { function getBindVars( fn: AnyFunctionNode, declName: string | false, - { moduleScope, nodeToScope }: ScopeTree, + { nodeToScope }: ScopeTree, ): string[] { - const fnScope = nodeToScope.get(fn)! + // Build an ordered stack from module root down to fn: [module, ..., outer, fn] + // stack[0] = module scope, stack[fnIndex] = fn's own scope + const stack = nodeToScope.get(fn)!.chain() + const fnIndex = stack.length - 1 const result = new Set() - let current = fnScope walk(fn.body as any, { enter(node, parent) { @@ -305,43 +313,34 @@ function getBindVars( } const scope = nodeToScope.get(node) - if (scope) current = scope + if (scope) stack.push(scope) if ( n.type === 'Identifier' && n.name !== declName && isReferenceId(n, p) ) { - const owner = current.findOwner(n.name) - if (owner && isIntermediateScope(owner, fnScope, moduleScope)) { - result.add(n.name) + // Scan stack top-down (innermost first) to find which scope owns this name + for (let i = stack.length - 1; i >= 0; i--) { + if (stack[i]!.declarations.has(n.name)) { + // Bind only if owner is strictly between fn and module root + // i === 0: module scope → don't bind + // i < fnIndex: ancestor scope → bind + // i >= fnIndex: own/inner scope → don't bind + if (i > 0 && i < fnIndex) result.add(n.name) + break + } } } }, leave(node) { - const scope = nodeToScope.get(node) - if (scope) current = scope.parent ?? fnScope + if (nodeToScope.get(node)) stack.pop() }, }) return [...result] } -// Is `owner` strictly between `fnScope` and `moduleScope` in the ancestor chain? -function isIntermediateScope( - owner: Scope, - fnScope: Scope, - moduleScope: Scope, -): boolean { - if (owner === moduleScope) return false - let curr = fnScope.parent - while (curr) { - if (curr === owner) return true - curr = curr.parent - } - return false -} - function isReferenceId(node: any, parent: any): boolean { if (!parent) return true switch (parent.type) { From 6d0848411ae156e6e76b686e91f60cfbfe9d8650 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 13:25:39 +0900 Subject: [PATCH 09/88] chore: fix types --- packages/plugin-rsc/src/transforms/hoist.ts | 33 ++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 8c09bec44..be1188eb3 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -4,6 +4,8 @@ import type { FunctionDeclaration, FunctionExpression, ArrowFunctionExpression, + Pattern, + Node, } from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' @@ -182,7 +184,7 @@ type AnyFunctionNode = | FunctionExpression | ArrowFunctionExpression -function isFunctionNode(node: any): node is AnyFunctionNode { +function isFunctionNode(node: Node): node is AnyFunctionNode { return ( node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || @@ -215,22 +217,22 @@ class Scope { } type ScopeTree = { - nodeToScope: WeakMap + nodeToScope: WeakMap } // First pass: walk the whole module and build a scope tree. // Returns the module-level scope and a map from scope-creating nodes to their scopes. function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(null, true) - const nodeToScope = new WeakMap() + const nodeToScope = new WeakMap() nodeToScope.set(ast, moduleScope) let current = moduleScope // note: moduleScope stored under ast so chain() can walk up to it walk(ast, { enter(node, parent) { - const n = node as any - const p = parent as any + const n = node + const p = parent ?? undefined if (isFunctionNode(n)) { // Hoist function declaration name to the enclosing function scope @@ -251,7 +253,7 @@ function buildScopeTree(ast: Program): ScopeTree { if (n.type === 'FunctionExpression' && n.id) { scope.declarations.add(n.id.name) } - } else if (n.type === 'BlockStatement' && !isFunctionNode(p)) { + } else if (n.type === 'BlockStatement' && !(p && isFunctionNode(p))) { // Block scope — but skip the direct body BlockStatement of a function, // which is already covered by the function's own scope above const scope = new Scope(current, false) @@ -301,10 +303,10 @@ function getBindVars( const fnIndex = stack.length - 1 const result = new Set() - walk(fn.body as any, { + walk(fn.body, { enter(node, parent) { - const n = node as any - const p = parent as any + const n = node + const p = parent ?? undefined // Skip nested functions — they handle their own binding if (isFunctionNode(n)) { @@ -341,7 +343,7 @@ function getBindVars( return [...result] } -function isReferenceId(node: any, parent: any): boolean { +function isReferenceId(node: Node, parent?: Node): boolean { if (!parent) return true switch (parent.type) { case 'VariableDeclarator': @@ -375,20 +377,23 @@ function isReferenceId(node: any, parent: any): boolean { } // Copied from periscopic — extract binding names from a pattern node -function extractNames(param: any): string[] { +function extractNames(param: Pattern): string[] { const names: string[] = [] extractIdentifiers(param, names) return names } -function extractIdentifiers(param: any, names: string[]): void { +function extractIdentifiers(param: Pattern, names: string[]): void { switch (param.type) { case 'Identifier': names.push(param.name) break case 'MemberExpression': { - let obj = param - while (obj.type === 'MemberExpression') obj = obj.object + // TODO: review + let obj = param as any + while (obj.type === 'MemberExpression') { + obj = obj.object + } names.push(obj.name) break } From 7ff6f86f771b019cee6a8906c826777462af0b95 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 13:41:36 +0900 Subject: [PATCH 10/88] chore: still planning --- .../2026-04-04-hoist-variable-shadowing.md | 63 +++++++++++++++---- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md index e67e04f18..ee881853d 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md @@ -104,21 +104,60 @@ The structural flaw remains — it works for the current test cases because ## Target Design -The correct fix is **reference-position resolution**: for each `Identifier` node -encountered in a reference position during the AST walk, determine which scope owns it -**at the point it appears** using the live scope stack at that moment. +Frame the problem as: -This is fundamentally different from name-based lookup: +> Given `references: Identifier[]` (all reference-position identifiers inside a `use +server` function body), and a way to look up the declaring `Scope` for each one, bind +> exactly those whose declaring scope is neither the module root nor inside the function +> body itself. -- When you enter a block that declares `value`, you push that scope onto the stack -- When you encounter a reference to `value`, you check the stack top-down -- Shadowing is handled naturally by stack order — inner declarations are found first -- No post-hoc name string matching detached from traversal position +With this framing `getBindVars` is pure data lookup — no walk, no stack, no string +matching: -Concretely: the scope stack itself during the walk IS the resolution context. Each -identifier reference is resolved inline, not by querying a pre-built map with a string. -`declarations: Set` + `findOwner(string)` should be replaced with a stack where -each frame knows which identifiers it introduces, resolved per occurrence. +```ts +const fnScope = scopeTree.nodeScope.get(fn)! +const references = scopeTree.scopeToReferences.get(fnScope) ?? [] +const bindVars = [ + ...new Set( + references + .filter((id) => id.name !== declName) + .filter((id) => { + const scope = scopeTree.identifierScope.get(id) + return ( + scope !== undefined && + scope !== scopeTree.moduleScope && + isStrictAncestor(scope, fnScope) + ) // scope is in outer fn, not inside + }) + .map((id) => id.name), + ), +] +``` + +### Target types + +```ts +type Scope = { + readonly parent: Scope | null + // no declarations, no methods — purely an identity token with a parent link +} + +type ScopeTree = { + // each reference Identifier → the Scope that declared it (undefined = module-level) + readonly identifierScope: WeakMap + // each Scope → the direct reference Identifiers whose enclosing function scope is this + // (inverse of identifierScope, keyed by scope rather than by function node) + readonly scopeToReferences: WeakMap + // scope-creating AST node → its Scope (bridge from AST into Scope world) + readonly nodeScope: WeakMap + readonly moduleScope: Scope +} +``` + +`nodeScope` is the only entry point from AST nodes into `Scope`. After that, everything +is expressed purely in terms of `Scope` and `Identifier` — no AST node types, no strings. + +All the work is in `buildScopeTree` (one pass). `getBindVars` has no logic of its own. ## Reference Repos From c144d077388987effe475af63510ffff1726d249 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 14:01:36 +0900 Subject: [PATCH 11/88] wip: better take --- packages/plugin-rsc/src/transforms/hoist.ts | 208 +++++++++++--------- 1 file changed, 110 insertions(+), 98 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index be1188eb3..76d15fcaf 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -1,11 +1,12 @@ import type { Program, Literal, + Identifier, + Node, + Pattern, FunctionDeclaration, FunctionExpression, ArrowFunctionExpression, - Pattern, - Node, } from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' @@ -192,155 +193,166 @@ function isFunctionNode(node: Node): node is AnyFunctionNode { ) } +// Scope is an identity token with a parent link. +// declarations is an internal build-time detail used only within buildScopeTree. class Scope { - declarations = new Set() + readonly declarations = new Set() constructor( public readonly parent: Scope | null, - public readonly isFunction: boolean, + private readonly isFunction: boolean, ) {} nearestFunction(): Scope { return this.isFunction ? this : this.parent!.nearestFunction() } - - // Returns ordered chain from module root to this scope (inclusive) - chain(): Scope[] { - const result: Scope[] = [] - let curr: Scope | null = this - while (curr) { - result.unshift(curr) - curr = curr.parent - } - return result - } } type ScopeTree = { - nodeToScope: WeakMap + // each reference Identifier → the Scope that declared it (absent = module-level/global) + readonly identifierScope: WeakMap + // each function Scope → direct reference Identifiers within its body (not nested fns) + readonly scopeToReferences: WeakMap + // scope-creating AST node → its Scope (the only entry point from AST into Scope) + readonly nodeScope: WeakMap + readonly moduleScope: Scope } -// First pass: walk the whole module and build a scope tree. -// Returns the module-level scope and a map from scope-creating nodes to their scopes. function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(null, true) - const nodeToScope = new WeakMap() - nodeToScope.set(ast, moduleScope) + const nodeScope = new WeakMap() + const identifierScope = new WeakMap() + const scopeToReferences = new WeakMap() + + nodeScope.set(ast, moduleScope) + scopeToReferences.set(moduleScope, []) + + // ── Pass 1: collect all declarations into scope nodes ─────────────────── let current = moduleScope - // note: moduleScope stored under ast so chain() can walk up to it walk(ast, { enter(node, parent) { - const n = node - const p = parent ?? undefined - - if (isFunctionNode(n)) { + if (isFunctionNode(node)) { // Hoist function declaration name to the enclosing function scope - if (n.type === 'FunctionDeclaration' && n.id) { - current.nearestFunction().declarations.add(n.id.name) + if (node.type === 'FunctionDeclaration' && node.id) { + current.nearestFunction().declarations.add(node.id.name) } const scope = new Scope(current, true) - nodeToScope.set(node, scope) + nodeScope.set(node, scope) + scopeToReferences.set(scope, []) current = scope - // Params belong to the function scope (not a separate block scope — this - // is the key fix over periscopic which separates params from body) - for (const param of n.params) { - for (const name of extractNames(param)) { - scope.declarations.add(name) - } + // Params and body share one scope — the key fix over periscopic + for (const param of node.params) { + for (const name of extractNames(param)) scope.declarations.add(name) } - // FunctionExpression name is scoped to its own body - if (n.type === 'FunctionExpression' && n.id) { - scope.declarations.add(n.id.name) + if (node.type === 'FunctionExpression' && node.id) { + scope.declarations.add(node.id.name) } - } else if (n.type === 'BlockStatement' && !(p && isFunctionNode(p))) { - // Block scope — but skip the direct body BlockStatement of a function, - // which is already covered by the function's own scope above + } else if ( + node.type === 'BlockStatement' && + !(parent && isFunctionNode(parent)) + ) { const scope = new Scope(current, false) - nodeToScope.set(node, scope) + nodeScope.set(node, scope) current = scope - } else if (n.type === 'CatchClause') { + } else if (node.type === 'CatchClause') { const scope = new Scope(current, false) - nodeToScope.set(node, scope) + nodeScope.set(node, scope) current = scope - if (n.param) { - for (const name of extractNames(n.param)) { + if (node.param) { + for (const name of extractNames(node.param)) scope.declarations.add(name) - } } - } else if (n.type === 'VariableDeclaration') { - const target = n.kind === 'var' ? current.nearestFunction() : current - for (const decl of n.declarations) { - for (const name of extractNames(decl.id)) { + } else if (node.type === 'VariableDeclaration') { + const target = node.kind === 'var' ? current.nearestFunction() : current + for (const decl of node.declarations) { + for (const name of extractNames(decl.id)) target.declarations.add(name) - } } - } else if (n.type === 'ClassDeclaration' && n.id) { - current.declarations.add(n.id.name) + } else if (node.type === 'ClassDeclaration' && node.id) { + current.declarations.add(node.id.name) } }, leave(node) { - const scope = nodeToScope.get(node) - if (scope?.parent) { - current = scope.parent - } + const scope = nodeScope.get(node) + if (scope?.parent) current = scope.parent }, }) - return { nodeToScope } -} + // ── Pass 2: resolve each reference Identifier to its declaring Scope ──── + current = moduleScope + const fnStack: Scope[] = [moduleScope] -// Second pass: walk the server function body and collect variables that resolve -// to a scope strictly between the function and the module root (i.e. closures). -function getBindVars( - fn: AnyFunctionNode, - declName: string | false, - { nodeToScope }: ScopeTree, -): string[] { - // Build an ordered stack from module root down to fn: [module, ..., outer, fn] - // stack[0] = module scope, stack[fnIndex] = fn's own scope - const stack = nodeToScope.get(fn)!.chain() - const fnIndex = stack.length - 1 - const result = new Set() - - walk(fn.body, { + walk(ast, { enter(node, parent) { - const n = node - const p = parent ?? undefined - - // Skip nested functions — they handle their own binding - if (isFunctionNode(n)) { - this.skip() - return + const scope = nodeScope.get(node) + if (scope) { + current = scope + if (isFunctionNode(node)) fnStack.push(scope) } - const scope = nodeToScope.get(node) - if (scope) stack.push(scope) - if ( - n.type === 'Identifier' && - n.name !== declName && - isReferenceId(n, p) + node.type === 'Identifier' && + isReferenceId(node, parent ?? undefined) ) { - // Scan stack top-down (innermost first) to find which scope owns this name - for (let i = stack.length - 1; i >= 0; i--) { - if (stack[i]!.declarations.has(n.name)) { - // Bind only if owner is strictly between fn and module root - // i === 0: module scope → don't bind - // i < fnIndex: ancestor scope → bind - // i >= fnIndex: own/inner scope → don't bind - if (i > 0 && i < fnIndex) result.add(n.name) - break - } + // Scan up from current scope to find where this name is declared + let declaring: Scope | null = current + while (declaring && !declaring.declarations.has(node.name)) { + declaring = declaring.parent + } + // Record declaration scope (absent from map = module-level or undeclared) + if (declaring && declaring !== moduleScope) { + identifierScope.set(node, declaring) } + // Add to the direct references of the enclosing function scope + scopeToReferences.get(fnStack[fnStack.length - 1]!)!.push(node) } }, leave(node) { - if (nodeToScope.get(node)) stack.pop() + const scope = nodeScope.get(node) + if (scope?.parent) { + current = scope.parent + if (isFunctionNode(node)) fnStack.pop() + } }, }) - return [...result] + return { identifierScope, scopeToReferences, nodeScope, moduleScope } +} + +// getBindVars is pure data lookup — no walking, no string matching. +function getBindVars( + fn: AnyFunctionNode, + declName: string | false, + { identifierScope, scopeToReferences, nodeScope, moduleScope }: ScopeTree, +): string[] { + const fnScope = nodeScope.get(fn)! + const references = scopeToReferences.get(fnScope) ?? [] + return [ + ...new Set( + references + .filter((id) => id.name !== declName) + .filter((id) => { + const scope = identifierScope.get(id) + return ( + scope !== undefined && + scope !== moduleScope && + isStrictAncestor(scope, fnScope) + ) + }) + .map((id) => id.name), + ), + ] +} + +// Is `candidate` a strict ancestor of `scope` in the parent chain? +function isStrictAncestor(candidate: Scope, scope: Scope): boolean { + let curr = scope.parent + while (curr) { + if (curr === candidate) return true + curr = curr.parent + } + return false } function isReferenceId(node: Node, parent?: Node): boolean { From 8a009ebb4cbd88840ac5cb3f6eb3824905541ce8 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 14:27:26 +0900 Subject: [PATCH 12/88] wip: still planning --- .../2026-04-04-hoist-variable-shadowing.md | 168 +++++++++++++++++- packages/plugin-rsc/src/transforms/hoist.ts | 78 ++++++-- 2 files changed, 234 insertions(+), 12 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md index ee881853d..b4f64e271 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md @@ -159,6 +159,161 @@ is expressed purely in terms of `Scope` and `Identifier` — no AST node types, All the work is in `buildScopeTree` (one pass). `getBindVars` has no logic of its own. +## Design Smell in the Current Prototype + +The current custom implementation fixed the shadowing bug, but its internal shape still +has an avoidable smell: + +1. Pass 1 builds declarations and scopes. +2. Pass 2 walks the whole AST again. +3. Pass 2 decides whether each `Identifier` is a "real reference" with a generic syntax + classifier. + +That last step is the weak point. It re-derives AST-position meaning after the fact, +which forces helper logic like `isBindingIdentifier` to know about many ESTree edge +cases (`Property`, `MethodDefinition`, import/export specifiers, destructuring, etc.). +As soon as the helper needs parent/grandparent context, the abstraction is already +telling us it is too low-level. + +The problem is not "two passes" by itself. Two passes are fine if pass 1 establishes all +declarations first and pass 2 resolves reads against that frozen scope data. The smell is +"walk every `Identifier` in pass 2 and classify it generically". + +## Proposed New Shape + +Keep the good part: + +- pass 1 builds the scope tree and records declarations + +Replace the brittle part: + +- pass 2 should not walk every `Identifier` +- pass 2 should walk only expression/reference-bearing child positions +- pass 2 should resolve references immediately when visiting those positions + +In other words, instead of asking: + +> "given an arbitrary `Identifier`, is it a reference?" + +ask: + +> "for this AST node, which child nodes are read positions?" + +That moves the complexity from a global classifier to local per-node traversal rules, +which is easier to reason about and matches how closure capture actually works. + +### Sketch + +```ts +function buildScopeTree(ast: Program): ScopeTree { + // pass 1: create scopes, declare names, hoist `var` +} + +function collectReferences(ast: Program, scopeTree: ScopeTree): void { + // pass 2: walk only read/reference positions + // for each Identifier read: + // 1. resolve owner scope + // 2. store identifier -> owner scope + // 3. append identifier to enclosing function scope's references +} +``` + +`getBindVars` stays the same shape as the target design above: pure lookup over +`scopeToReferences` and `identifierScope`. + +## Why This Is Simpler + +### No global identifier classifier + +We can delete the "is this arbitrary `Identifier` a binding?" helper entirely, or reduce +it to a tiny internal helper if one case still wants it. + +### No grandparent hacks + +`Property` ambiguity goes away when traversal is explicit: + +- `ObjectExpression` + - visit `value` + - visit `key` only if `computed` +- `ObjectPattern` + - do not treat the pattern as a read; it belongs to declaration handling + +So object literals and object patterns are separated structurally, not inferred from an +identifier's ancestors. + +### Better fit for the actual question + +The hoist transform does not need a general-purpose "all identifiers in ESTree" oracle. +It needs: + +- declarations, scoped correctly +- reads inside the server function body +- owner scope for each read + +That is a narrower and more maintainable target. + +## Concrete Pass-2 Rules + +Pass 2 should be a reference visitor over expression positions, not a blind AST scan. +Representative rules: + +- `Identifier` + - record as a read only when reached through a read-position visitor +- `MemberExpression` + - always visit `object` + - visit `property` only if `computed` +- `Property` under `ObjectExpression` + - visit `value` + - visit `key` only if `computed` +- `CallExpression` / `NewExpression` + - visit `callee` + - visit all args +- `ReturnStatement` + - visit `argument` +- `BinaryExpression`, `LogicalExpression`, `UnaryExpression`, `UpdateExpression` + - visit operand expressions +- `ConditionalExpression` + - visit `test`, `consequent`, `alternate` +- `AssignmentExpression` + - visit `right` + - visit `left` only when it contains computed member accesses that read values +- `TemplateLiteral` + - visit all expressions +- `TaggedTemplateExpression` + - visit `tag` and all template expressions +- `AwaitExpression` / `YieldExpression` + - visit `argument` +- `ClassBody` + - for `PropertyDefinition`, visit `value` and `key` only if `computed` + - for `MethodDefinition`, visit `key` only if `computed`; method body is handled by its + own function scope + +This is not a full ESTree spec list yet. It is the shape we want: explicit read +positions, explicit declaration positions. + +## Migration Plan + +1. Keep the current `Scope` / `ScopeTree` data model. +2. Leave pass 1 mostly as-is, since it already fixes the original shadowing bug. +3. Replace the generic pass-2 `Identifier` walk with a dedicated reference visitor. +4. Delete `isBindingIdentifier` once pass 2 no longer depends on it. +5. Add focused tests for syntax that previously depended on classifier edge cases: + - class methods and fields + - object literal vs object pattern + - import/export specifiers + - destructured params + - computed keys + +## Decision + +Do not over-index on "one pass vs two passes". The better boundary is: + +- pass 1 answers "what names exist in which scopes?" +- pass 2 answers "which reads occur, and what do they resolve to?" + +That split is coherent. The current prototype's problem is that pass 2 still asks a more +primitive question than it really needs to. + ## Reference Repos ### oxc-walker (`~/code/others/oxc-walker`) @@ -176,6 +331,17 @@ subset whose owner is strictly between the action and the module root. **Compatibility:** targets oxc-parser which outputs ESTree — same as Vite 8's `parseAstAsync`. `walk()` accepts a pre-parsed AST directly. +**Relevant helper:** `src/scope-tracker.ts:isBindingIdentifier`. Our local +`isReferenceId` should stay aligned with its inverse. The concrete gaps found during the +comparison were: + +- `MethodDefinition` and `PropertyDefinition`: non-computed keys are bindings, not + references +- `ExportSpecifier`: `local` is a reference, `exported` is not + +The remaining differences (`RestElement`, `ArrayPattern`, import specifiers, explicit +param handling) are currently harmless for `getBindVars`. + ### Vite `ssrTransform.ts` (`~/code/others/vite/packages/vite/src/node/ssr/ssrTransform.ts`) Working ESTree + `estree-walker` scope implementation (lines ~456–760). Uses a live scope @@ -186,4 +352,4 @@ design. `estree-walker` is already a dep of `plugin-rsc`. Dropped as a dep. `extract_identifiers` / `extract_names` copied directly into the codebase — small, correct, well-tested utilities for extracting binding names from -destructuring patterns. +destructuring patterns. Source: `src/index.js`. diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 76d15fcaf..ffda0c489 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -282,9 +282,11 @@ function buildScopeTree(ast: Program): ScopeTree { // ── Pass 2: resolve each reference Identifier to its declaring Scope ──── current = moduleScope const fnStack: Scope[] = [moduleScope] + const ancestors: Node[] = [] walk(ast, { enter(node, parent) { + ancestors.push(node) const scope = nodeScope.get(node) if (scope) { current = scope @@ -293,7 +295,11 @@ function buildScopeTree(ast: Program): ScopeTree { if ( node.type === 'Identifier' && - isReferenceId(node, parent ?? undefined) + !isBindingIdentifier( + node, + parent ?? undefined, + ancestors[ancestors.length - 3], + ) ) { // Scan up from current scope to find where this name is declared let declaring: Scope | null = current @@ -309,6 +315,7 @@ function buildScopeTree(ast: Program): ScopeTree { } }, leave(node) { + ancestors.pop() const scope = nodeScope.get(node) if (scope?.parent) { current = scope.parent @@ -355,40 +362,89 @@ function isStrictAncestor(candidate: Scope, scope: Scope): boolean { return false } -function isReferenceId(node: Node, parent?: Node): boolean { - if (!parent) return true +// Binding-position check aligned with oxc-walker's `isBindingIdentifier` in +// `src/scope-tracker.ts`, with ESTree-specific handling for `ExportSpecifier` +// because only `local` is a reference there. +function isBindingIdentifier( + node: Identifier, + parent?: Node, + grandparent?: Node, +): boolean { + if (!parent) return false switch (parent.type) { case 'VariableDeclarator': - return parent.id !== node + return patternContainsIdentifier(parent.id, node) case 'MemberExpression': - return parent.computed || parent.object === node + return parent.property === node && !parent.computed case 'Property': - return parent.computed || parent.value === node + return ( + grandparent?.type === 'ObjectPattern' && + (parent.computed ? parent.key === node : parent.value === node) + ) case 'FunctionDeclaration': case 'FunctionExpression': + if (parent.id === node) return true + return parent.params.some((param) => + patternContainsIdentifier(param, node), + ) + case 'ArrowFunctionExpression': + return parent.params.some((param) => + patternContainsIdentifier(param, node), + ) case 'ClassDeclaration': case 'ClassExpression': - return parent.id !== node + return parent.id === node + case 'MethodDefinition': + case 'PropertyDefinition': + return parent.key === node && !parent.computed + case 'CatchClause': + return !!parent.param && patternContainsIdentifier(parent.param, node) case 'AssignmentPattern': - return parent.right === node + return patternContainsIdentifier(parent.left, node) case 'RestElement': + return patternContainsIdentifier(parent.argument, node) case 'ArrayPattern': - return false + return true case 'LabeledStatement': case 'BreakStatement': case 'ContinueStatement': return false case 'ImportSpecifier': + return parent.imported !== node case 'ImportDefaultSpecifier': case 'ImportNamespaceSpecifier': + return true case 'ExportSpecifier': return false default: - return true + return false + } +} + +function patternContainsIdentifier(pattern: Pattern, target: Node): boolean { + switch (pattern.type) { + case 'Identifier': + return pattern === target + case 'MemberExpression': + return pattern === target + case 'ObjectPattern': + return pattern.properties.some((prop) => + prop.type === 'RestElement' + ? patternContainsIdentifier(prop.argument, target) + : patternContainsIdentifier(prop.value, target), + ) + case 'ArrayPattern': + return pattern.elements.some( + (element) => element && patternContainsIdentifier(element, target), + ) + case 'RestElement': + return patternContainsIdentifier(pattern.argument, target) + case 'AssignmentPattern': + return patternContainsIdentifier(pattern.left, target) } } -// Copied from periscopic — extract binding names from a pattern node +// Copied from periscopic `extract_names` / `extract_identifiers` in `src/index.js`. function extractNames(param: Pattern): string[] { const names: string[] = [] extractIdentifiers(param, names) From cd3805ed9d09fb1b03997abc407bfa4d1a3df467 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 14:51:10 +0900 Subject: [PATCH 13/88] chore: null -> undefined --- packages/plugin-rsc/src/transforms/hoist.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index ffda0c489..65b3cf9e4 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -199,7 +199,7 @@ class Scope { readonly declarations = new Set() constructor( - public readonly parent: Scope | null, + public readonly parent: Scope | undefined, private readonly isFunction: boolean, ) {} @@ -219,7 +219,7 @@ type ScopeTree = { } function buildScopeTree(ast: Program): ScopeTree { - const moduleScope = new Scope(null, true) + const moduleScope = new Scope(undefined, true) const nodeScope = new WeakMap() const identifierScope = new WeakMap() const scopeToReferences = new WeakMap() @@ -302,7 +302,7 @@ function buildScopeTree(ast: Program): ScopeTree { ) ) { // Scan up from current scope to find where this name is declared - let declaring: Scope | null = current + let declaring: Scope | undefined = current while (declaring && !declaring.declarations.has(node.name)) { declaring = declaring.parent } From 089195e6767cfb523b9e42269cd0e8e0aa524cb7 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 14:55:27 +0900 Subject: [PATCH 14/88] refactor: align extractIdentifiers --- packages/plugin-rsc/src/transforms/hoist.ts | 35 +++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 65b3cf9e4..ba8feb577 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -210,7 +210,7 @@ class Scope { type ScopeTree = { // each reference Identifier → the Scope that declared it (absent = module-level/global) - readonly identifierScope: WeakMap + readonly referenceScope: WeakMap // each function Scope → direct reference Identifiers within its body (not nested fns) readonly scopeToReferences: WeakMap // scope-creating AST node → its Scope (the only entry point from AST into Scope) @@ -221,7 +221,7 @@ type ScopeTree = { function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(undefined, true) const nodeScope = new WeakMap() - const identifierScope = new WeakMap() + const referenceScope = new WeakMap() const scopeToReferences = new WeakMap() nodeScope.set(ast, moduleScope) @@ -308,7 +308,7 @@ function buildScopeTree(ast: Program): ScopeTree { } // Record declaration scope (absent from map = module-level or undeclared) if (declaring && declaring !== moduleScope) { - identifierScope.set(node, declaring) + referenceScope.set(node, declaring) } // Add to the direct references of the enclosing function scope scopeToReferences.get(fnStack[fnStack.length - 1]!)!.push(node) @@ -324,14 +324,14 @@ function buildScopeTree(ast: Program): ScopeTree { }, }) - return { identifierScope, scopeToReferences, nodeScope, moduleScope } + return { referenceScope, scopeToReferences, nodeScope, moduleScope } } // getBindVars is pure data lookup — no walking, no string matching. function getBindVars( fn: AnyFunctionNode, declName: string | false, - { identifierScope, scopeToReferences, nodeScope, moduleScope }: ScopeTree, + { referenceScope, scopeToReferences, nodeScope, moduleScope }: ScopeTree, ): string[] { const fnScope = nodeScope.get(fn)! const references = scopeToReferences.get(fnScope) ?? [] @@ -340,7 +340,7 @@ function getBindVars( references .filter((id) => id.name !== declName) .filter((id) => { - const scope = identifierScope.get(id) + const scope = referenceScope.get(id) return ( scope !== undefined && scope !== moduleScope && @@ -446,15 +446,17 @@ function patternContainsIdentifier(pattern: Pattern, target: Node): boolean { // Copied from periscopic `extract_names` / `extract_identifiers` in `src/index.js`. function extractNames(param: Pattern): string[] { - const names: string[] = [] - extractIdentifiers(param, names) - return names + const nodes = extractIdentifiers(param) + return nodes.map((n) => n.name) } -function extractIdentifiers(param: Pattern, names: string[]): void { +function extractIdentifiers( + param: Pattern, + nodes: Identifier[] = [], +): Identifier[] { switch (param.type) { case 'Identifier': - names.push(param.name) + nodes.push(param) break case 'MemberExpression': { // TODO: review @@ -462,27 +464,28 @@ function extractIdentifiers(param: Pattern, names: string[]): void { while (obj.type === 'MemberExpression') { obj = obj.object } - names.push(obj.name) + nodes.push(obj) break } case 'ObjectPattern': for (const prop of param.properties) { extractIdentifiers( prop.type === 'RestElement' ? prop : prop.value, - names, + nodes, ) } break case 'ArrayPattern': for (const el of param.elements) { - if (el) extractIdentifiers(el, names) + if (el) extractIdentifiers(el, nodes) } break case 'RestElement': - extractIdentifiers(param.argument, names) + extractIdentifiers(param.argument, nodes) break case 'AssignmentPattern': - extractIdentifiers(param.left, names) + extractIdentifiers(param.left, nodes) break } + return nodes } From 1b14260cd3b3fdc2041774e410f8f83802efd8e2 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 15:21:31 +0900 Subject: [PATCH 15/88] chore: nit braces --- packages/plugin-rsc/src/transforms/hoist.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index ba8feb577..bdcdb70a2 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -243,7 +243,9 @@ function buildScopeTree(ast: Program): ScopeTree { current = scope // Params and body share one scope — the key fix over periscopic for (const param of node.params) { - for (const name of extractNames(param)) scope.declarations.add(name) + for (const name of extractNames(param)) { + scope.declarations.add(name) + } } if (node.type === 'FunctionExpression' && node.id) { scope.declarations.add(node.id.name) @@ -260,14 +262,16 @@ function buildScopeTree(ast: Program): ScopeTree { nodeScope.set(node, scope) current = scope if (node.param) { - for (const name of extractNames(node.param)) + for (const name of extractNames(node.param)) { scope.declarations.add(name) + } } } else if (node.type === 'VariableDeclaration') { const target = node.kind === 'var' ? current.nearestFunction() : current for (const decl of node.declarations) { - for (const name of extractNames(decl.id)) + for (const name of extractNames(decl.id)) { target.declarations.add(name) + } } } else if (node.type === 'ClassDeclaration' && node.id) { current.declarations.add(node.id.name) @@ -477,7 +481,9 @@ function extractIdentifiers( break case 'ArrayPattern': for (const el of param.elements) { - if (el) extractIdentifiers(el, nodes) + if (el) { + extractIdentifiers(el, nodes) + } } break case 'RestElement': From c3a30cb136a168ecdc9dce545658e09ebae52890 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 15:23:45 +0900 Subject: [PATCH 16/88] wip: still smells though --- packages/plugin-rsc/src/transforms/hoist.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index bdcdb70a2..4a8a45ec5 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -231,7 +231,7 @@ function buildScopeTree(ast: Program): ScopeTree { let current = moduleScope walk(ast, { - enter(node, parent) { + enter(node) { if (isFunctionNode(node)) { // Hoist function declaration name to the enclosing function scope if (node.type === 'FunctionDeclaration' && node.id) { @@ -241,7 +241,6 @@ function buildScopeTree(ast: Program): ScopeTree { nodeScope.set(node, scope) scopeToReferences.set(scope, []) current = scope - // Params and body share one scope — the key fix over periscopic for (const param of node.params) { for (const name of extractNames(param)) { scope.declarations.add(name) @@ -250,10 +249,7 @@ function buildScopeTree(ast: Program): ScopeTree { if (node.type === 'FunctionExpression' && node.id) { scope.declarations.add(node.id.name) } - } else if ( - node.type === 'BlockStatement' && - !(parent && isFunctionNode(parent)) - ) { + } else if (node.type === 'BlockStatement') { const scope = new Scope(current, false) nodeScope.set(node, scope) current = scope From 64e4a7f3acceb27c1143700f16a8c9549845e276 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 15:26:48 +0900 Subject: [PATCH 17/88] wip --- .../plugin-rsc/src/transforms/hoist.test.ts | 29 +++++++++++++++++++ packages/plugin-rsc/src/transforms/hoist.ts | 8 +++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index 8236470ba..ae3b10a4a 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -729,4 +729,33 @@ function outer() { " `) }) + + it('deeper', async () => { + const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + if (true) { + return value; + } + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); + } + + ;export async function $$hoist_0_action(value) { + "use server"; + if (true) { + return value; + } + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) }) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 4a8a45ec5..c46bb0678 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -290,7 +290,9 @@ function buildScopeTree(ast: Program): ScopeTree { const scope = nodeScope.get(node) if (scope) { current = scope - if (isFunctionNode(node)) fnStack.push(scope) + if (isFunctionNode(node)) { + fnStack.push(scope) + } } if ( @@ -319,7 +321,9 @@ function buildScopeTree(ast: Program): ScopeTree { const scope = nodeScope.get(node) if (scope?.parent) { current = scope.parent - if (isFunctionNode(node)) fnStack.pop() + if (isFunctionNode(node)) { + fnStack.pop() + } } }, }) From 7c03a52296d3f77ad7273b4fcd944148a7a08fc2 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 15:36:12 +0900 Subject: [PATCH 18/88] test: var/function hoisting --- .../2026-04-04-hoist-variable-shadowing.md | 22 ++++++- .../plugin-rsc/src/transforms/hoist.test.ts | 62 +++++++++++++++++++ packages/plugin-rsc/src/transforms/hoist.ts | 6 ++ 3 files changed, 87 insertions(+), 3 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md index b4f64e271..8c3275153 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md @@ -157,7 +157,7 @@ type ScopeTree = { `nodeScope` is the only entry point from AST nodes into `Scope`. After that, everything is expressed purely in terms of `Scope` and `Identifier` — no AST node types, no strings. -All the work is in `buildScopeTree` (one pass). `getBindVars` has no logic of its own. +All the work is in `buildScopeTree` (two passes — see below). `getBindVars` has no logic of its own. ## Design Smell in the Current Prototype @@ -175,8 +175,24 @@ cases (`Property`, `MethodDefinition`, import/export specifiers, destructuring, As soon as the helper needs parent/grandparent context, the abstraction is already telling us it is too low-level. -The problem is not "two passes" by itself. Two passes are fine if pass 1 establishes all -declarations first and pass 2 resolves reads against that frozen scope data. The smell is +Two passes are **inherently required** by JavaScript's hoisting semantics. A `var` +declaration or function declaration may appear textually _after_ a reference to the same +name in the same function: + +```js +function action() { + console.log({ foo }) // reference — var foo not seen yet + { + var foo = 123 // hoisted to action's function scope + } +} +``` + +A single-pass resolver would see `foo` before `var foo` is recorded, scan upward, and +incorrectly attribute it to an outer binding. Pass 1 must collect all declarations first +so that pass 2 can resolve every reference against the complete, frozen scope picture. + +The problem is not "two passes" by itself — that is correct and necessary. The smell is "walk every `Identifier` in pass 2 and classify it generically". ## Proposed New Shape diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index ae3b10a4a..76d18170e 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -758,4 +758,66 @@ function outer() { " `) }) + + it('var hoisting', async () => { + const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + console.log({ value }) + { + var value = 1; + } + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); + } + + ;export async function $$hoist_0_action() { + "use server"; + console.log({ value }) + { + var value = 1; + } + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + it('function hoisting', async () => { + const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + console.log({ value }) + { + function value() {} + } + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); + } + + ;export async function $$hoist_0_action() { + "use server"; + console.log({ value }) + { + function value() {} + } + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) }) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index c46bb0678..db05df08f 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -227,6 +227,12 @@ function buildScopeTree(ast: Program): ScopeTree { nodeScope.set(ast, moduleScope) scopeToReferences.set(moduleScope, []) + // Two passes are required: `var` and function declarations are hoisted to + // the enclosing function scope regardless of where they appear in the source. + // A reference before its `var` declaration must still resolve to that local + // binding, not to an outer one. Pass 1 collects all declarations first so + // Pass 2 can resolve every reference against the complete scope picture. + // ── Pass 1: collect all declarations into scope nodes ─────────────────── let current = moduleScope From 379630a3ae1dfd0de5b2c769c859a39d6956da1f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 15:44:57 +0900 Subject: [PATCH 19/88] refactor: nit --- packages/plugin-rsc/src/transforms/hoist.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index db05df08f..77999f33a 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -337,23 +337,24 @@ function buildScopeTree(ast: Program): ScopeTree { return { referenceScope, scopeToReferences, nodeScope, moduleScope } } +// TODO: review // getBindVars is pure data lookup — no walking, no string matching. function getBindVars( fn: AnyFunctionNode, declName: string | false, - { referenceScope, scopeToReferences, nodeScope, moduleScope }: ScopeTree, + scopeTree: ScopeTree, ): string[] { - const fnScope = nodeScope.get(fn)! - const references = scopeToReferences.get(fnScope) ?? [] + const fnScope = scopeTree.nodeScope.get(fn)! + const references = scopeTree.scopeToReferences.get(fnScope) ?? [] return [ ...new Set( references .filter((id) => id.name !== declName) .filter((id) => { - const scope = referenceScope.get(id) + const scope = scopeTree.referenceScope.get(id) return ( scope !== undefined && - scope !== moduleScope && + scope !== scopeTree.moduleScope && isStrictAncestor(scope, fnScope) ) }) @@ -372,6 +373,7 @@ function isStrictAncestor(candidate: Scope, scope: Scope): boolean { return false } +// TODO: review // Binding-position check aligned with oxc-walker's `isBindingIdentifier` in // `src/scope-tracker.ts`, with ESTree-specific handling for `ExportSpecifier` // because only `local` is a reference there. @@ -460,6 +462,7 @@ function extractNames(param: Pattern): string[] { return nodes.map((n) => n.name) } +// TODO: review function extractIdentifiers( param: Pattern, nodes: Identifier[] = [], @@ -469,7 +472,6 @@ function extractIdentifiers( nodes.push(param) break case 'MemberExpression': { - // TODO: review let obj = param as any while (obj.type === 'MemberExpression') { obj = obj.object From 206f93a5df7a08d8a8d4ba3f50d5790b9ca1bb87 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:04:17 +0900 Subject: [PATCH 20/88] refactor: reduce slop --- packages/plugin-rsc/src/transforms/hoist.ts | 43 ++++++++++----------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 77999f33a..5ce7937e3 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -211,7 +211,7 @@ class Scope { type ScopeTree = { // each reference Identifier → the Scope that declared it (absent = module-level/global) readonly referenceScope: WeakMap - // each function Scope → direct reference Identifiers within its body (not nested fns) + // each function Scope → reference Identifiers accessed within its scope readonly scopeToReferences: WeakMap // scope-creating AST node → its Scope (the only entry point from AST into Scope) readonly nodeScope: WeakMap @@ -222,10 +222,6 @@ function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(undefined, true) const nodeScope = new WeakMap() const referenceScope = new WeakMap() - const scopeToReferences = new WeakMap() - - nodeScope.set(ast, moduleScope) - scopeToReferences.set(moduleScope, []) // Two passes are required: `var` and function declarations are hoisted to // the enclosing function scope regardless of where they appear in the source. @@ -235,9 +231,11 @@ function buildScopeTree(ast: Program): ScopeTree { // ── Pass 1: collect all declarations into scope nodes ─────────────────── let current = moduleScope + nodeScope.set(ast, moduleScope) walk(ast, { enter(node) { + // TODO: handle importDeclaration (though they can be treated as global) if (isFunctionNode(node)) { // Hoist function declaration name to the enclosing function scope if (node.type === 'FunctionDeclaration' && node.id) { @@ -245,7 +243,6 @@ function buildScopeTree(ast: Program): ScopeTree { } const scope = new Scope(current, true) nodeScope.set(node, scope) - scopeToReferences.set(scope, []) current = scope for (const param of node.params) { for (const name of extractNames(param)) { @@ -286,9 +283,8 @@ function buildScopeTree(ast: Program): ScopeTree { }) // ── Pass 2: resolve each reference Identifier to its declaring Scope ──── - current = moduleScope - const fnStack: Scope[] = [moduleScope] const ancestors: Node[] = [] + const scopeToReferences = new WeakMap() walk(ast, { enter(node, parent) { @@ -296,9 +292,7 @@ function buildScopeTree(ast: Program): ScopeTree { const scope = nodeScope.get(node) if (scope) { current = scope - if (isFunctionNode(node)) { - fnStack.push(scope) - } + scopeToReferences.set(current, []) } if ( @@ -310,31 +304,36 @@ function buildScopeTree(ast: Program): ScopeTree { ) ) { // Scan up from current scope to find where this name is declared - let declaring: Scope | undefined = current - while (declaring && !declaring.declarations.has(node.name)) { - declaring = declaring.parent + let declScope: Scope | undefined = current + while (declScope && !declScope.declarations.has(node.name)) { + declScope = declScope.parent } - // Record declaration scope (absent from map = module-level or undeclared) - if (declaring && declaring !== moduleScope) { - referenceScope.set(node, declaring) + // Record declaration scope + if (declScope) { + referenceScope.set(node, declScope) } // Add to the direct references of the enclosing function scope - scopeToReferences.get(fnStack[fnStack.length - 1]!)!.push(node) + scopeToReferences.get(current)!.push(node) } }, leave(node) { ancestors.pop() const scope = nodeScope.get(node) if (scope?.parent) { + // propagate references to parent scope + const references = scopeToReferences.get(current)! + scopeToReferences.get(scope.parent)!.push(...references) current = scope.parent - if (isFunctionNode(node)) { - fnStack.pop() - } } }, }) - return { referenceScope, scopeToReferences, nodeScope, moduleScope } + return { + referenceScope, + scopeToReferences, + nodeScope, + moduleScope, + } } // TODO: review From e98aa069fa80f31127e4dd90c5d8f6351e972b4c Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:08:27 +0900 Subject: [PATCH 21/88] refactor: rename --- packages/plugin-rsc/src/transforms/hoist.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 5ce7937e3..a1b133bf2 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -210,7 +210,7 @@ class Scope { type ScopeTree = { // each reference Identifier → the Scope that declared it (absent = module-level/global) - readonly referenceScope: WeakMap + readonly referenceToDeclaredScope: WeakMap // each function Scope → reference Identifiers accessed within its scope readonly scopeToReferences: WeakMap // scope-creating AST node → its Scope (the only entry point from AST into Scope) @@ -221,7 +221,7 @@ type ScopeTree = { function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(undefined, true) const nodeScope = new WeakMap() - const referenceScope = new WeakMap() + const referenceToDeclaredScope = new WeakMap() // Two passes are required: `var` and function declarations are hoisted to // the enclosing function scope regardless of where they appear in the source. @@ -310,9 +310,9 @@ function buildScopeTree(ast: Program): ScopeTree { } // Record declaration scope if (declScope) { - referenceScope.set(node, declScope) + referenceToDeclaredScope.set(node, declScope) } - // Add to the direct references of the enclosing function scope + // Add to the direct references of the current scope scopeToReferences.get(current)!.push(node) } }, @@ -329,7 +329,7 @@ function buildScopeTree(ast: Program): ScopeTree { }) return { - referenceScope, + referenceToDeclaredScope, scopeToReferences, nodeScope, moduleScope, @@ -350,7 +350,7 @@ function getBindVars( references .filter((id) => id.name !== declName) .filter((id) => { - const scope = scopeTree.referenceScope.get(id) + const scope = scopeTree.referenceToDeclaredScope.get(id) return ( scope !== undefined && scope !== scopeTree.moduleScope && From 37b77b3906f86d2f8291c6e75dc4072335be21c5 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:13:46 +0900 Subject: [PATCH 22/88] refactor: nit --- packages/plugin-rsc/src/transforms/hoist.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index a1b133bf2..48508969f 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -176,6 +176,7 @@ export function findDirectives(ast: Program, directive: string): Literal[] { return nodes } +// TODO: unit test // ── Custom scope analysis (prototype) ───────────────────────────────────────── // Replacement for periscopic's analyze() to correctly handle variable shadowing. // See docs/notes/2026-04-04-hoist-variable-shadowing.md @@ -352,7 +353,7 @@ function getBindVars( .filter((id) => { const scope = scopeTree.referenceToDeclaredScope.get(id) return ( - scope !== undefined && + scope && scope !== scopeTree.moduleScope && isStrictAncestor(scope, fnScope) ) From 47bf4e140144054cba0e5efe00548d578de9c95d Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:29:13 +0900 Subject: [PATCH 23/88] refactor: nit slop --- .../plugin-rsc/src/transforms/hoist.test.ts | 30 ++++++++++++++ packages/plugin-rsc/src/transforms/hoist.ts | 40 ++++++------------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index 76d18170e..113ff4ee1 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -820,4 +820,34 @@ function outer() { " `) }) + + // TODO: does next support this? + it('recursion', async () => { + const input = `\ +function outer() { + async function action() { + "use server"; + if (false) { + return action(); + } + return 0; + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, action); + } + + ;export async function $$hoist_0_action(action) { + "use server"; + if (false) { + return action(); + } + return 0; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) }) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 48508969f..c7ddf5144 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -74,7 +74,7 @@ export function transformHoistInlineDirective( parent.id.name) || 'anonymous_server_function' - const bindVars = getBindVars(node, declName, scopeTree) + const bindVars = getBindVars(node, scopeTree) let newParams = [ ...bindVars, ...node.params.map((n) => input.slice(n.start, n.end)), @@ -337,40 +337,26 @@ function buildScopeTree(ast: Program): ScopeTree { } } -// TODO: review -// getBindVars is pure data lookup — no walking, no string matching. -function getBindVars( - fn: AnyFunctionNode, - declName: string | false, - scopeTree: ScopeTree, -): string[] { +function getBindVars(fn: AnyFunctionNode, scopeTree: ScopeTree): string[] { const fnScope = scopeTree.nodeScope.get(fn)! + const ancestorScopes = getAncestorScopes(fnScope) const references = scopeTree.scopeToReferences.get(fnScope) ?? [] - return [ - ...new Set( - references - .filter((id) => id.name !== declName) - .filter((id) => { - const scope = scopeTree.referenceToDeclaredScope.get(id) - return ( - scope && - scope !== scopeTree.moduleScope && - isStrictAncestor(scope, fnScope) - ) - }) - .map((id) => id.name), - ), - ] + // bind variables that are the ones declared in ancestor scopes but not module global scope + const bindReferences = references.filter((id) => { + const scope = scopeTree.referenceToDeclaredScope.get(id) + return scope && scope !== scopeTree.moduleScope && ancestorScopes.has(scope) + }) + return [...new Set(bindReferences.map((id) => id.name))] } -// Is `candidate` a strict ancestor of `scope` in the parent chain? -function isStrictAncestor(candidate: Scope, scope: Scope): boolean { +function getAncestorScopes(scope: Scope): Set { + const ancestors = new Set() let curr = scope.parent while (curr) { - if (curr === candidate) return true + ancestors.add(curr) curr = curr.parent } - return false + return ancestors } // TODO: review From 1b914eb26c18229c216bf285406b98058deb8029 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:30:13 +0900 Subject: [PATCH 24/88] chore: nit --- packages/plugin-rsc/src/transforms/hoist.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index c7ddf5144..7ce5e5f23 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -279,7 +279,9 @@ function buildScopeTree(ast: Program): ScopeTree { }, leave(node) { const scope = nodeScope.get(node) - if (scope?.parent) current = scope.parent + if (scope?.parent) { + current = scope.parent + } }, }) From e5a23ecb800dac17cbd18615e8092ada052a9a39 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:33:14 +0900 Subject: [PATCH 25/88] chore: nit --- packages/plugin-rsc/src/transforms/hoist.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 7ce5e5f23..0754e8b32 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -242,6 +242,8 @@ function buildScopeTree(ast: Program): ScopeTree { if (node.type === 'FunctionDeclaration' && node.id) { current.nearestFunction().declarations.add(node.id.name) } + // Param scope is separate from the body scope (BlockStatement below creates its own). + // This matches the JS spec: params have their own environment, the body has another. const scope = new Scope(current, true) nodeScope.set(node, scope) current = scope @@ -253,6 +255,9 @@ function buildScopeTree(ast: Program): ScopeTree { if (node.type === 'FunctionExpression' && node.id) { scope.declarations.add(node.id.name) } + // TODO: ForStatement, ForInStatement, ForOfStatement, SwitchStatement also create + // block scopes for their init/left variables. Add them here for a complete general + // scope tracker. } else if (node.type === 'BlockStatement') { const scope = new Scope(current, false) nodeScope.set(node, scope) @@ -377,6 +382,9 @@ function isBindingIdentifier( case 'MemberExpression': return parent.property === node && !parent.computed case 'Property': + // TODO: bug — computed destructuring `{ [expr]: b }` is backwards: + // expr is incorrectly treated as binding, b is incorrectly treated as reference. + // Fix: `grandparent?.type === 'ObjectPattern' && parent.value === node` return ( grandparent?.type === 'ObjectPattern' && (parent.computed ? parent.key === node : parent.value === node) @@ -415,6 +423,9 @@ function isBindingIdentifier( case 'ImportNamespaceSpecifier': return true case 'ExportSpecifier': + // TODO: `local` is a reference, `exported` is not. Should be `parent.local !== node`. + // Functionally harmless for getBindVars (exports are module-level, filtered out), + // but semantically incorrect. return false default: return false From a161866914a233cb4f830b1506ff3ac783991aee Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:39:32 +0900 Subject: [PATCH 26/88] fix: more scope nodes --- packages/plugin-rsc/src/transforms/hoist.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 0754e8b32..cc7a4c3fb 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -255,9 +255,15 @@ function buildScopeTree(ast: Program): ScopeTree { if (node.type === 'FunctionExpression' && node.id) { scope.declarations.add(node.id.name) } - // TODO: ForStatement, ForInStatement, ForOfStatement, SwitchStatement also create - // block scopes for their init/left variables. Add them here for a complete general - // scope tracker. + } else if ( + node.type === 'ForStatement' || + node.type === 'ForInStatement' || + node.type === 'ForOfStatement' || + node.type === 'SwitchStatement' + ) { + const scope = new Scope(current, false) + nodeScope.set(node, scope) + current = scope } else if (node.type === 'BlockStatement') { const scope = new Scope(current, false) nodeScope.set(node, scope) From 6462a63c8655ed27f3db2fd8dc18224039addf73 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:44:22 +0900 Subject: [PATCH 27/88] fix(plugin-rsc): fix isBindingIdentifier for computed destructuring key and ExportSpecifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `{ [expr]: b }` — `expr` is now correctly treated as a reference (was incorrectly treated as a binding), `b` correctly as a binding - `ExportSpecifier` — `local` is now correctly treated as a reference, `exported` as a non-reference (was treating both as references) - Add test case for computed destructuring key captured from outer scope Co-Authored-By: Claude Sonnet 4.6 --- .../plugin-rsc/src/transforms/hoist.test.ts | 27 +++++++++++++++++++ packages/plugin-rsc/src/transforms/hoist.ts | 15 +++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index 113ff4ee1..c580b4237 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -850,4 +850,31 @@ function outer() { " `) }) + + it('computed destructuring key in body', async () => { + const input = `\ +function outer() { + const key = 'value' + async function action(data) { + "use server"; + const { [key]: val } = data + return val + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const key = 'value' + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, key); + } + + ;export async function $$hoist_0_action(key, data) { + "use server"; + const { [key]: val } = data + return val + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) }) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index cc7a4c3fb..50c924ad1 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -388,13 +388,9 @@ function isBindingIdentifier( case 'MemberExpression': return parent.property === node && !parent.computed case 'Property': - // TODO: bug — computed destructuring `{ [expr]: b }` is backwards: - // expr is incorrectly treated as binding, b is incorrectly treated as reference. - // Fix: `grandparent?.type === 'ObjectPattern' && parent.value === node` - return ( - grandparent?.type === 'ObjectPattern' && - (parent.computed ? parent.key === node : parent.value === node) - ) + // The value is always the binding in destructuring (both computed and non-computed). + // The key is never a binding — in computed form `{ [expr]: b }` it is a reference. + return grandparent?.type === 'ObjectPattern' && parent.value === node case 'FunctionDeclaration': case 'FunctionExpression': if (parent.id === node) return true @@ -429,10 +425,7 @@ function isBindingIdentifier( case 'ImportNamespaceSpecifier': return true case 'ExportSpecifier': - // TODO: `local` is a reference, `exported` is not. Should be `parent.local !== node`. - // Functionally harmless for getBindVars (exports are module-level, filtered out), - // but semantically incorrect. - return false + return parent.local !== node default: return false } From 90027fa90275ddacbafb422e1fdcebee3742edd9 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 16:57:00 +0900 Subject: [PATCH 28/88] fix: fix function hoisting in strict mode --- .../plugin-rsc/src/transforms/hoist.test.ts | 58 ++++++++++++++++++- packages/plugin-rsc/src/transforms/hoist.ts | 5 +- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index c580b4237..ede56fb1f 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -761,6 +761,33 @@ function outer() { it('var hoisting', async () => { const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + console.log({ value }) + var value = 1; + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); + } + + ;export async function $$hoist_0_action() { + "use server"; + console.log({ value }) + var value = 1; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + it('var hoisting block', async () => { + const input = `\ function outer() { const value = 0; async function action() { @@ -792,6 +819,33 @@ function outer() { it('function hoisting', async () => { const input = `\ +function outer() { + const value = 0; + async function action() { + "use server"; + console.log({ value }) + function value() {} + } +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + "function outer() { + const value = 0; + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); + } + + ;export async function $$hoist_0_action() { + "use server"; + console.log({ value }) + function value() {} + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_action, "name", { value: "action" }); + " + `) + }) + + it('function hoisting block', async () => { + const input = `\ function outer() { const value = 0; async function action() { @@ -806,10 +860,10 @@ function outer() { expect(await testTransform(input)).toMatchInlineSnapshot(` "function outer() { const value = 0; - const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action"); + const action = /* #__PURE__ */ $$register($$hoist_0_action, "", "$$hoist_0_action").bind(null, value); } - ;export async function $$hoist_0_action() { + ;export async function $$hoist_0_action(value) { "use server"; console.log({ value }) { diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 50c924ad1..d605eeaf3 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -238,9 +238,10 @@ function buildScopeTree(ast: Program): ScopeTree { enter(node) { // TODO: handle importDeclaration (though they can be treated as global) if (isFunctionNode(node)) { - // Hoist function declaration name to the enclosing function scope + // Declare the function name in the current scope (block or function). + // In strict mode (ES modules), block-level function declarations are block-scoped. if (node.type === 'FunctionDeclaration' && node.id) { - current.nearestFunction().declarations.add(node.id.name) + current.declarations.add(node.id.name) } // Param scope is separate from the body scope (BlockStatement below creates its own). // This matches the JS spec: params have their own environment, the body has another. From a1db3c670fc4f641698a08b618ccf8dc29a5bfdf Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 17:23:01 +0900 Subject: [PATCH 29/88] chore: still planning --- .../docs/notes/2026-04-04-scope-unit-tests.md | 109 ++++++++++++++++++ packages/plugin-rsc/src/transforms/hoist.ts | 10 ++ 2 files changed, 119 insertions(+) create mode 100644 packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md new file mode 100644 index 000000000..3ca27f10b --- /dev/null +++ b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md @@ -0,0 +1,109 @@ +# Task: Unit-test `buildScopeTree` in its own module + +## Goal + +Extract the custom scope analysis from `hoist.ts` into `src/transforms/scope.ts` and add +a comprehensive `scope.test.ts` that tests `buildScopeTree` (and `getBindVars`) directly, +independent of the hoist transform. + +This is step 5 of the migration plan in `2026-04-04-hoist-variable-shadowing.md`. + +## Steps + +1. Extract `scope.ts` from `hoist.ts` + - Move: `Scope`, `ScopeTree`, `buildScopeTree`, `getBindVars`, `getAncestorScopes`, + `isBindingIdentifier`, `patternContainsIdentifier`, `extractNames`, `extractIdentifiers` + - Export at minimum: `buildScopeTree`, `getBindVars`, `ScopeTree`, `Scope` + - `hoist.ts` imports from `./scope` + +2. Write `scope.test.ts` + + **Test helper:** + + ```ts + async function setup(code: string) { + const ast = await parseAstAsync(code) + const scopeTree = buildScopeTree(ast) + function refs(name: string): Identifier[] { + /* walk, collect by name */ + } + function fn(name: string): AnyFunctionNode { + /* walk, find by id.name */ + } + return { scopeTree, refs, fn, ast } + } + ``` + + **Test categories:** + + ### Scope structure + - Module scope has no parent + - Top-level function's scope parent is moduleScope + - Block scope parent is enclosing function scope (or block) + + ### Declaration placement (pass 1) + + | case | expected scope | + | ----------------------------------------------- | ----------------------------------- | + | `let`/`const` in block | block scope | + | `var` in nested block | nearest function scope | + | `var` in block inside nested function | that nested fn's scope | + | function declaration name | hoisted to enclosing function scope | + | function expression name (`function self() {}`) | its own scope | + | plain/rest/destructured params | function scope | + | catch param | catch scope | + | class declaration name | current scope | + + ### Reference resolution (pass 2) + + | code | assertion | + | -------------------------------------------- | -------------------------------------- | + | ref to module-level `const` | maps to moduleScope | + | ref to outer function's local | maps to outer fn scope | + | ref to same-function local | maps to fn own scope | + | ref shadowed in action body | maps to inner scope | + | ref to `var` declared later in same function | maps to fn scope (hoisting) | + | global ref (`console`) | absent from `referenceToDeclaredScope` | + + ### `isBindingIdentifier` edge cases — highest priority + + These are the cases that required parent/grandparent context and are most likely to + regress: + + | syntax | assertion | + | --------------------------------------------------------- | -------------------------------------------------- | + | `obj.prop` non-computed `MemberExpression` | `prop` NOT in referenceToDeclaredScope | + | `obj[expr]` computed | `expr` IS resolved | + | `{ key: val }` `ObjectExpression` | `key` NOT resolved; `val` IS resolved | + | `const { key: val } = obj` `ObjectPattern` | `val` is a binding (not a ref); `key` is not a ref | + | `const { [expr]: val } = obj` computed destructuring | `expr` IS a reference | + | `export { foo as bar }` `ExportSpecifier` | `foo` IS resolved; `bar` is NOT | + | `import { foo as bar }` `ImportSpecifier` | `bar` is binding; `foo` is not a ref | + | `class C { method() {} }` non-computed `MethodDefinition` | `method` NOT resolved | + | `class C { [expr]() {} }` computed method | `expr` IS resolved | + | `class C { field = val }` `PropertyDefinition` | `field` NOT resolved; `val` IS resolved | + | label in `break`/`continue` | NOT resolved | + + ### `scopeToReferences` propagation + - A function scope accumulates refs from its own body and all nested blocks + - An inner function's refs propagate up to the outer function's `scopeToReferences` + + ### `getBindVars` + + | scenario | expected | + | --------------------------------- | ------------ | + | ref to outer fn local | `['x']` | + | ref shadowed in action body | `[]` | + | ref shadowed only in nested block | `[]` | + | ref to module global | `[]` | + | ref to true global (`console`) | `[]` | + | multiple refs to same name | deduplicated | + | ref to param of outer function | `['param']` | + +3. Verify existing `hoist.test.ts` still passes after the extraction. + +## Non-goals + +- Do not change behaviour of `buildScopeTree` in this task. +- Do not implement the pass-2 refactor (replacing `isBindingIdentifier` with explicit + reference visitor) — that is a separate follow-up described in the migration plan. diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index d605eeaf3..a6700bd53 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -229,6 +229,16 @@ function buildScopeTree(ast: Program): ScopeTree { // A reference before its `var` declaration must still resolve to that local // binding, not to an outer one. Pass 1 collects all declarations first so // Pass 2 can resolve every reference against the complete scope picture. + // + // A single-pass alternative is possible: collect references as `{ scope, id }` + // pairs (Scope at visit time + Identifier node) during the walk, then in a + // post-walk loop call `scope.findOwner(id.name)` to populate + // `referenceToDeclaredScope` and `scopeToReferences` — by then all declarations + // are in the chain so `findOwner` sees the full picture. The returned `ScopeTree` + // shape would be identical; only when it gets filled changes (post-walk loop + // instead of a second full walk). The key constraint is that `findOwner` must be + // called post-walk, not inline during traversal. As long as that is internal to + // `buildScopeTree` and not leaked to callers, the API contract stays clean. // ── Pass 1: collect all declarations into scope nodes ─────────────────── let current = moduleScope From a7ebf932b8ae19856939ce2e20a6794197071c76 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 17:32:44 +0900 Subject: [PATCH 30/88] refactor: single ast walk + loop --- packages/plugin-rsc/src/transforms/hoist.ts | 100 ++++++++------------ 1 file changed, 39 insertions(+), 61 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index a6700bd53..27c95d9ce 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -223,29 +223,27 @@ function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(undefined, true) const nodeScope = new WeakMap() const referenceToDeclaredScope = new WeakMap() + const scopeToReferences = new WeakMap() - // Two passes are required: `var` and function declarations are hoisted to - // the enclosing function scope regardless of where they appear in the source. - // A reference before its `var` declaration must still resolve to that local - // binding, not to an outer one. Pass 1 collects all declarations first so - // Pass 2 can resolve every reference against the complete scope picture. - // - // A single-pass alternative is possible: collect references as `{ scope, id }` - // pairs (Scope at visit time + Identifier node) during the walk, then in a - // post-walk loop call `scope.findOwner(id.name)` to populate - // `referenceToDeclaredScope` and `scopeToReferences` — by then all declarations - // are in the chain so `findOwner` sees the full picture. The returned `ScopeTree` - // shape would be identical; only when it gets filled changes (post-walk loop - // instead of a second full walk). The key constraint is that `findOwner` must be - // called post-walk, not inline during traversal. As long as that is internal to - // `buildScopeTree` and not leaked to callers, the API contract stays clean. + // Inline resolution during the walk is wrong for `var`/function hoisting: a + // reference that appears before its `var` declaration would resolve to an outer + // binding rather than the locally-hoisted one. The fix is to defer resolution + // until after the walk, when all declarations are in the chain. We collect + // `{ id, visitScope }` pairs during the walk, then resolve them in a post-walk + // loop via `visitScope.findOwner(id.name)` — at that point the scope tree is + // complete and `findOwner` sees the correct picture. - // ── Pass 1: collect all declarations into scope nodes ─────────────────── + // ── Walk: collect declarations and raw reference pairs ─────────────────── let current = moduleScope nodeScope.set(ast, moduleScope) + scopeToReferences.set(moduleScope, []) + + const rawRefs: Array<{ id: Identifier; visitScope: Scope }> = [] + const ancestors: Node[] = [] walk(ast, { - enter(node) { + enter(node, parent) { + ancestors.push(node) // TODO: handle importDeclaration (though they can be treated as global) if (isFunctionNode(node)) { // Declare the function name in the current scope (block or function). @@ -257,6 +255,7 @@ function buildScopeTree(ast: Program): ScopeTree { // This matches the JS spec: params have their own environment, the body has another. const scope = new Scope(current, true) nodeScope.set(node, scope) + scopeToReferences.set(scope, []) current = scope for (const param of node.params) { for (const name of extractNames(param)) { @@ -270,18 +269,17 @@ function buildScopeTree(ast: Program): ScopeTree { node.type === 'ForStatement' || node.type === 'ForInStatement' || node.type === 'ForOfStatement' || - node.type === 'SwitchStatement' + node.type === 'SwitchStatement' || + node.type === 'BlockStatement' ) { const scope = new Scope(current, false) nodeScope.set(node, scope) - current = scope - } else if (node.type === 'BlockStatement') { - const scope = new Scope(current, false) - nodeScope.set(node, scope) + scopeToReferences.set(scope, []) current = scope } else if (node.type === 'CatchClause') { const scope = new Scope(current, false) nodeScope.set(node, scope) + scopeToReferences.set(scope, []) current = scope if (node.param) { for (const name of extractNames(node.param)) { @@ -298,28 +296,6 @@ function buildScopeTree(ast: Program): ScopeTree { } else if (node.type === 'ClassDeclaration' && node.id) { current.declarations.add(node.id.name) } - }, - leave(node) { - const scope = nodeScope.get(node) - if (scope?.parent) { - current = scope.parent - } - }, - }) - - // ── Pass 2: resolve each reference Identifier to its declaring Scope ──── - const ancestors: Node[] = [] - const scopeToReferences = new WeakMap() - - walk(ast, { - enter(node, parent) { - ancestors.push(node) - const scope = nodeScope.get(node) - if (scope) { - current = scope - scopeToReferences.set(current, []) - } - if ( node.type === 'Identifier' && !isBindingIdentifier( @@ -328,31 +304,33 @@ function buildScopeTree(ast: Program): ScopeTree { ancestors[ancestors.length - 3], ) ) { - // Scan up from current scope to find where this name is declared - let declScope: Scope | undefined = current - while (declScope && !declScope.declarations.has(node.name)) { - declScope = declScope.parent - } - // Record declaration scope - if (declScope) { - referenceToDeclaredScope.set(node, declScope) - } - // Add to the direct references of the current scope - scopeToReferences.get(current)!.push(node) + rawRefs.push({ id: node, visitScope: current }) } }, leave(node) { ancestors.pop() const scope = nodeScope.get(node) - if (scope?.parent) { - // propagate references to parent scope - const references = scopeToReferences.get(current)! - scopeToReferences.get(scope.parent)!.push(...references) - current = scope.parent - } + if (scope?.parent) current = scope.parent }, }) + // ── Post-walk fixup: resolve references against the complete scope tree ── + for (const { id, visitScope } of rawRefs) { + let declScope: Scope | undefined = visitScope + while (declScope && !declScope.declarations.has(id.name)) { + declScope = declScope.parent + } + if (declScope) { + referenceToDeclaredScope.set(id, declScope) + } + // Propagate reference up through all ancestor scopes + let s: Scope | undefined = visitScope + while (s) { + scopeToReferences.get(s)?.push(id) + s = s.parent + } + } + return { referenceToDeclaredScope, scopeToReferences, From 9e77cc3b38aa6022b76fce0593898913e8618f74 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 17:37:36 +0900 Subject: [PATCH 31/88] refactor: nit slop --- packages/plugin-rsc/src/transforms/hoist.ts | 28 +++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 27c95d9ce..a896ccd81 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -222,21 +222,18 @@ type ScopeTree = { function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(undefined, true) const nodeScope = new WeakMap() - const referenceToDeclaredScope = new WeakMap() - const scopeToReferences = new WeakMap() // Inline resolution during the walk is wrong for `var`/function hoisting: a // reference that appears before its `var` declaration would resolve to an outer // binding rather than the locally-hoisted one. The fix is to defer resolution // until after the walk, when all declarations are in the chain. We collect // `{ id, visitScope }` pairs during the walk, then resolve them in a post-walk - // loop via `visitScope.findOwner(id.name)` — at that point the scope tree is - // complete and `findOwner` sees the correct picture. + // loop by scanning up from `visitScope` — at that point the scope tree is + // complete and the scan sees the correct picture. // ── Walk: collect declarations and raw reference pairs ─────────────────── let current = moduleScope nodeScope.set(ast, moduleScope) - scopeToReferences.set(moduleScope, []) const rawRefs: Array<{ id: Identifier; visitScope: Scope }> = [] const ancestors: Node[] = [] @@ -255,7 +252,6 @@ function buildScopeTree(ast: Program): ScopeTree { // This matches the JS spec: params have their own environment, the body has another. const scope = new Scope(current, true) nodeScope.set(node, scope) - scopeToReferences.set(scope, []) current = scope for (const param of node.params) { for (const name of extractNames(param)) { @@ -274,12 +270,10 @@ function buildScopeTree(ast: Program): ScopeTree { ) { const scope = new Scope(current, false) nodeScope.set(node, scope) - scopeToReferences.set(scope, []) current = scope } else if (node.type === 'CatchClause') { const scope = new Scope(current, false) nodeScope.set(node, scope) - scopeToReferences.set(scope, []) current = scope if (node.param) { for (const name of extractNames(node.param)) { @@ -310,11 +304,16 @@ function buildScopeTree(ast: Program): ScopeTree { leave(node) { ancestors.pop() const scope = nodeScope.get(node) - if (scope?.parent) current = scope.parent + if (scope?.parent) { + current = scope.parent + } }, }) // ── Post-walk fixup: resolve references against the complete scope tree ── + const scopeToReferences = new WeakMap() + const referenceToDeclaredScope = new WeakMap() + for (const { id, visitScope } of rawRefs) { let declScope: Scope | undefined = visitScope while (declScope && !declScope.declarations.has(id.name)) { @@ -324,10 +323,13 @@ function buildScopeTree(ast: Program): ScopeTree { referenceToDeclaredScope.set(id, declScope) } // Propagate reference up through all ancestor scopes - let s: Scope | undefined = visitScope - while (s) { - scopeToReferences.get(s)?.push(id) - s = s.parent + let scope: Scope | undefined = visitScope + while (scope) { + if (!scopeToReferences.has(scope)) { + scopeToReferences.set(scope, []) + } + scopeToReferences.get(scope)!.push(id) + scope = scope.parent } } From 9b154446d73a4b5d815f36b441429a4aa5225a58 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 17:44:37 +0900 Subject: [PATCH 32/88] fix: track import too --- packages/plugin-rsc/src/transforms/hoist.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index a896ccd81..db2361e51 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -241,8 +241,11 @@ function buildScopeTree(ast: Program): ScopeTree { walk(ast, { enter(node, parent) { ancestors.push(node) - // TODO: handle importDeclaration (though they can be treated as global) - if (isFunctionNode(node)) { + if (node.type === 'ImportDeclaration') { + for (const spec of node.specifiers) { + current.declarations.add(spec.local.name) + } + } else if (isFunctionNode(node)) { // Declare the function name in the current scope (block or function). // In strict mode (ES modules), block-level function declarations are block-scoped. if (node.type === 'FunctionDeclaration' && node.id) { From 4ee5e3a4685aa276e8f49da6b0c59842ad5d2d22 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 17:54:11 +0900 Subject: [PATCH 33/88] chore: todo --- packages/plugin-rsc/src/transforms/hoist.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index db2361e51..a2e5f1f51 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -293,6 +293,15 @@ function buildScopeTree(ast: Program): ScopeTree { } else if (node.type === 'ClassDeclaration' && node.id) { current.declarations.add(node.id.name) } + // Collect reference identifiers for post-walk resolution. + // TODO: + // To extend to member-expression binding: instead of collecting just the + // Identifier, collect the outermost non-computed MemberExpression rooted at + // it (e.g. `x.y` in `x.y.z`) when one exists. The root + // Identifier is still used for `referenceToDeclaredScope`; the full node + // (Identifier | MemberExpression) goes into `scopeToReferences`. Then + // `getBindVars` inspects each entry — if it is a MemberExpression, extract + // the path key for binding instead of the bare name. if ( node.type === 'Identifier' && !isBindingIdentifier( From 9963908f99463b168303b512b62e22ed1dd9216d Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:03:40 +0900 Subject: [PATCH 34/88] refactor: replace periscopic --- packages/plugin-rsc/package.json | 1 - packages/plugin-rsc/src/transforms/cjs.ts | 8 +-- packages/plugin-rsc/src/transforms/hoist.ts | 57 ++----------------- .../plugin-rsc/src/transforms/proxy-export.ts | 5 +- packages/plugin-rsc/src/transforms/utils.ts | 49 +++++++++++++++- .../plugin-rsc/src/transforms/wrap-export.ts | 4 +- pnpm-lock.yaml | 17 ------ 7 files changed, 59 insertions(+), 82 deletions(-) diff --git a/packages/plugin-rsc/package.json b/packages/plugin-rsc/package.json index 0364e8f5f..e6bc6d189 100644 --- a/packages/plugin-rsc/package.json +++ b/packages/plugin-rsc/package.json @@ -43,7 +43,6 @@ "es-module-lexer": "^2.0.0", "estree-walker": "^3.0.3", "magic-string": "^0.30.21", - "periscopic": "^4.0.2", "srvx": "^0.11.13", "strip-literal": "^3.1.0", "turbo-stream": "^3.2.0", diff --git a/packages/plugin-rsc/src/transforms/cjs.ts b/packages/plugin-rsc/src/transforms/cjs.ts index 766ab13a0..f1fba9856 100644 --- a/packages/plugin-rsc/src/transforms/cjs.ts +++ b/packages/plugin-rsc/src/transforms/cjs.ts @@ -3,7 +3,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url' import type { Program, Node } from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' -import { analyze } from 'periscopic' +import { buildScopeTree } from './hoist' // TODO: // replacing require("xxx") into import("xxx") affects Vite's resolution. @@ -33,7 +33,7 @@ export function transformCjsToEsm( options: { id: string }, ): { output: MagicString } { const output = new MagicString(code) - const analyzed = analyze(ast) + const scopeTree = buildScopeTree(ast) const parentNodes: Node[] = [] const hoistedCodes: string[] = [] @@ -58,8 +58,8 @@ export function transformCjsToEsm( isTopLevel = false } // skip locally declared `require` - const scope = analyzed.map.get(parent) - if (scope && scope.declarations.has('require')) { + const scope = scopeTree.nodeScope.get(parent) + if (scope?.declarations.has('require')) { return } } diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index a2e5f1f51..b46ce1da0 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -10,6 +10,7 @@ import type { } from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' +import { extractNames } from './utils' export function transformHoistInlineDirective( input: string, @@ -177,8 +178,8 @@ export function findDirectives(ast: Program, directive: string): Literal[] { } // TODO: unit test -// ── Custom scope analysis (prototype) ───────────────────────────────────────── -// Replacement for periscopic's analyze() to correctly handle variable shadowing. +// ── Custom scope analysis ───────────────────────────────────────── +// Replacement for periscopic's analyze() to correctly handle variable shadowing // See docs/notes/2026-04-04-hoist-variable-shadowing.md type AnyFunctionNode = @@ -197,7 +198,7 @@ function isFunctionNode(node: Node): node is AnyFunctionNode { // Scope is an identity token with a parent link. // declarations is an internal build-time detail used only within buildScopeTree. class Scope { - readonly declarations = new Set() + readonly declarations: Set = new Set() constructor( public readonly parent: Scope | undefined, @@ -219,7 +220,7 @@ type ScopeTree = { readonly moduleScope: Scope } -function buildScopeTree(ast: Program): ScopeTree { +export function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(undefined, true) const nodeScope = new WeakMap() @@ -456,51 +457,3 @@ function patternContainsIdentifier(pattern: Pattern, target: Node): boolean { return patternContainsIdentifier(pattern.left, target) } } - -// Copied from periscopic `extract_names` / `extract_identifiers` in `src/index.js`. -function extractNames(param: Pattern): string[] { - const nodes = extractIdentifiers(param) - return nodes.map((n) => n.name) -} - -// TODO: review -function extractIdentifiers( - param: Pattern, - nodes: Identifier[] = [], -): Identifier[] { - switch (param.type) { - case 'Identifier': - nodes.push(param) - break - case 'MemberExpression': { - let obj = param as any - while (obj.type === 'MemberExpression') { - obj = obj.object - } - nodes.push(obj) - break - } - case 'ObjectPattern': - for (const prop of param.properties) { - extractIdentifiers( - prop.type === 'RestElement' ? prop : prop.value, - nodes, - ) - } - break - case 'ArrayPattern': - for (const el of param.elements) { - if (el) { - extractIdentifiers(el, nodes) - } - } - break - case 'RestElement': - extractIdentifiers(param.argument, nodes) - break - case 'AssignmentPattern': - extractIdentifiers(param.left, nodes) - break - } - return nodes -} diff --git a/packages/plugin-rsc/src/transforms/proxy-export.ts b/packages/plugin-rsc/src/transforms/proxy-export.ts index f08a05701..b382ef139 100644 --- a/packages/plugin-rsc/src/transforms/proxy-export.ts +++ b/packages/plugin-rsc/src/transforms/proxy-export.ts @@ -1,8 +1,7 @@ import { tinyassert } from '@hiogawa/utils' import type { Node, Program } from 'estree' import MagicString from 'magic-string' -import { extract_names } from 'periscopic' -import { hasDirective } from './utils' +import { extractNames, hasDirective } from './utils' export type TransformProxyExportOptions = { /** Required for source map and `keep` options */ @@ -112,7 +111,7 @@ export function transformProxyExport( } } const names = node.declaration.declarations.flatMap((decl) => - extract_names(decl.id), + extractNames(decl.id), ) createExport(node, names) } else { diff --git a/packages/plugin-rsc/src/transforms/utils.ts b/packages/plugin-rsc/src/transforms/utils.ts index aafcecbfc..daba28571 100644 --- a/packages/plugin-rsc/src/transforms/utils.ts +++ b/packages/plugin-rsc/src/transforms/utils.ts @@ -1,6 +1,5 @@ import { tinyassert } from '@hiogawa/utils' -import type { Program } from 'estree' -import { extract_names } from 'periscopic' +import type { Identifier, Pattern, Program } from 'estree' export function hasDirective( body: Program['body'], @@ -41,7 +40,7 @@ export function getExportNames( * export const foo = 1, bar = 2 */ for (const decl of node.declaration.declarations) { - exportNames.push(...extract_names(decl.id)) + exportNames.push(...extractNames(decl.id)) } } else { node.declaration satisfies never @@ -80,3 +79,47 @@ export function getExportNames( return { exportNames } } + +// Copied from periscopic `extract_names` / `extract_identifiers` in `src/index.js`. +export function extractNames(param: Pattern): string[] { + return extractIdentifiers(param).map((n) => n.name) +} + +export function extractIdentifiers( + param: Pattern, + nodes: Identifier[] = [], +): Identifier[] { + switch (param.type) { + case 'Identifier': + nodes.push(param) + break + case 'MemberExpression': { + let obj = param as any + while (obj.type === 'MemberExpression') { + obj = obj.object + } + nodes.push(obj) + break + } + case 'ObjectPattern': + for (const prop of param.properties) { + extractIdentifiers( + prop.type === 'RestElement' ? prop : prop.value, + nodes, + ) + } + break + case 'ArrayPattern': + for (const el of param.elements) { + if (el) extractIdentifiers(el, nodes) + } + break + case 'RestElement': + extractIdentifiers(param.argument, nodes) + break + case 'AssignmentPattern': + extractIdentifiers(param.left, nodes) + break + } + return nodes +} diff --git a/packages/plugin-rsc/src/transforms/wrap-export.ts b/packages/plugin-rsc/src/transforms/wrap-export.ts index 5c6cdcae4..a8b18f20c 100644 --- a/packages/plugin-rsc/src/transforms/wrap-export.ts +++ b/packages/plugin-rsc/src/transforms/wrap-export.ts @@ -1,7 +1,7 @@ import { tinyassert } from '@hiogawa/utils' import type { Node, Program } from 'estree' import MagicString from 'magic-string' -import { extract_names } from 'periscopic' +import { extractNames } from './utils' type ExportMeta = { declName?: string @@ -131,7 +131,7 @@ export function transformWrapExport( ) } const names = node.declaration.declarations.flatMap((decl) => - extract_names(decl.id), + extractNames(decl.id), ) // treat only simple single decl as function let isFunction = false diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d2431ccd8..8c97d5058 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -442,9 +442,6 @@ importers: magic-string: specifier: ^0.30.21 version: 0.30.21 - periscopic: - specifier: ^4.0.2 - version: 4.0.2 srvx: specifier: ^0.11.13 version: 0.11.13 @@ -3989,9 +3986,6 @@ packages: periscopic@3.1.0: resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==} - periscopic@4.0.2: - resolution: {integrity: sha512-sqpQDUy8vgB7ycLkendSKS6HnVz1Rneoc3Rc+ZBUCe2pbqlVuCC5vF52l0NJ1aiMg/r1qfYF9/myz8CZeI2rjA==} - picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -4815,9 +4809,6 @@ packages: youch@4.1.0-beta.10: resolution: {integrity: sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==} - zimmerframe@1.1.2: - resolution: {integrity: sha512-rAbqEGa8ovJy4pyBxZM70hg4pE6gDgaQ0Sl9M3enG3I0d6H4XSAM3GeNGLKnsBpuijUow064sf7ww1nutC5/3w==} - zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} @@ -7628,12 +7619,6 @@ snapshots: estree-walker: 3.0.3 is-reference: 3.0.2 - periscopic@4.0.2: - dependencies: - '@types/estree': 1.0.8 - is-reference: 3.0.2 - zimmerframe: 1.1.2 - picocolors@1.1.1: {} picomatch@4.0.3: {} @@ -8427,6 +8412,4 @@ snapshots: cookie: 1.0.2 youch-core: 0.3.3 - zimmerframe@1.1.2: {} - zwitch@2.0.4: {} From 45ebc392de43ac553ba98fc432226e73c89b8399 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:08:17 +0900 Subject: [PATCH 35/88] refactor: move code --- .../docs/notes/2026-04-04-scope-unit-tests.md | 252 ++++++++++------ packages/plugin-rsc/src/transforms/cjs.ts | 2 +- packages/plugin-rsc/src/transforms/hoist.ts | 284 +----------------- packages/plugin-rsc/src/transforms/scope.ts | 276 +++++++++++++++++ packages/plugin-rsc/src/transforms/utils.ts | 1 + 5 files changed, 442 insertions(+), 373 deletions(-) create mode 100644 packages/plugin-rsc/src/transforms/scope.ts diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md index 3ca27f10b..bd52e93b7 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md @@ -10,97 +10,167 @@ This is step 5 of the migration plan in `2026-04-04-hoist-variable-shadowing.md` ## Steps -1. Extract `scope.ts` from `hoist.ts` - - Move: `Scope`, `ScopeTree`, `buildScopeTree`, `getBindVars`, `getAncestorScopes`, - `isBindingIdentifier`, `patternContainsIdentifier`, `extractNames`, `extractIdentifiers` - - Export at minimum: `buildScopeTree`, `getBindVars`, `ScopeTree`, `Scope` - - `hoist.ts` imports from `./scope` - -2. Write `scope.test.ts` - - **Test helper:** - - ```ts - async function setup(code: string) { - const ast = await parseAstAsync(code) - const scopeTree = buildScopeTree(ast) - function refs(name: string): Identifier[] { - /* walk, collect by name */ - } - function fn(name: string): AnyFunctionNode { - /* walk, find by id.name */ - } - return { scopeTree, refs, fn, ast } - } - ``` - - **Test categories:** - - ### Scope structure - - Module scope has no parent - - Top-level function's scope parent is moduleScope - - Block scope parent is enclosing function scope (or block) - - ### Declaration placement (pass 1) - - | case | expected scope | - | ----------------------------------------------- | ----------------------------------- | - | `let`/`const` in block | block scope | - | `var` in nested block | nearest function scope | - | `var` in block inside nested function | that nested fn's scope | - | function declaration name | hoisted to enclosing function scope | - | function expression name (`function self() {}`) | its own scope | - | plain/rest/destructured params | function scope | - | catch param | catch scope | - | class declaration name | current scope | - - ### Reference resolution (pass 2) - - | code | assertion | - | -------------------------------------------- | -------------------------------------- | - | ref to module-level `const` | maps to moduleScope | - | ref to outer function's local | maps to outer fn scope | - | ref to same-function local | maps to fn own scope | - | ref shadowed in action body | maps to inner scope | - | ref to `var` declared later in same function | maps to fn scope (hoisting) | - | global ref (`console`) | absent from `referenceToDeclaredScope` | - - ### `isBindingIdentifier` edge cases — highest priority - - These are the cases that required parent/grandparent context and are most likely to - regress: - - | syntax | assertion | - | --------------------------------------------------------- | -------------------------------------------------- | - | `obj.prop` non-computed `MemberExpression` | `prop` NOT in referenceToDeclaredScope | - | `obj[expr]` computed | `expr` IS resolved | - | `{ key: val }` `ObjectExpression` | `key` NOT resolved; `val` IS resolved | - | `const { key: val } = obj` `ObjectPattern` | `val` is a binding (not a ref); `key` is not a ref | - | `const { [expr]: val } = obj` computed destructuring | `expr` IS a reference | - | `export { foo as bar }` `ExportSpecifier` | `foo` IS resolved; `bar` is NOT | - | `import { foo as bar }` `ImportSpecifier` | `bar` is binding; `foo` is not a ref | - | `class C { method() {} }` non-computed `MethodDefinition` | `method` NOT resolved | - | `class C { [expr]() {} }` computed method | `expr` IS resolved | - | `class C { field = val }` `PropertyDefinition` | `field` NOT resolved; `val` IS resolved | - | label in `break`/`continue` | NOT resolved | - - ### `scopeToReferences` propagation - - A function scope accumulates refs from its own body and all nested blocks - - An inner function's refs propagate up to the outer function's `scopeToReferences` - - ### `getBindVars` - - | scenario | expected | - | --------------------------------- | ------------ | - | ref to outer fn local | `['x']` | - | ref shadowed in action body | `[]` | - | ref shadowed only in nested block | `[]` | - | ref to module global | `[]` | - | ref to true global (`console`) | `[]` | - | multiple refs to same name | deduplicated | - | ref to param of outer function | `['param']` | - -3. Verify existing `hoist.test.ts` still passes after the extraction. +### 1. Extract `scope.ts` from `hoist.ts` + +- Move: `Scope`, `ScopeTree`, `buildScopeTree`, `getBindVars`, `getAncestorScopes`, + `isBindingIdentifier`, `patternContainsIdentifier`, `extractNames`, `extractIdentifiers` +- Export at minimum: `buildScopeTree`, `getBindVars`, `ScopeTree`, `Scope` +- `hoist.ts` imports from `./scope` + +### 2. File-based fixture tests in `scope.test.ts` + +Inspired by `oxc_semantic`'s approach: each fixture is a JS input file paired with a +snapshot file that captures a human-readable visualization of the scope tree. + +#### Directory layout + +``` +src/transforms/fixtures/scope/ + var-hoisting.js + var-hoisting.snap + shadowing-block.js + shadowing-block.snap + export-specifier.js + export-specifier.snap + ... +``` + +#### Test runner (auto-discovery) + +```ts +import { readdirSync } from 'node:fs' +import path from 'node:path' +import { parseAstAsync } from 'vite' +import { expect, it } from 'vitest' +import { buildScopeTree } from './scope' + +const fixtureDir = path.join(import.meta.dirname, 'fixtures/scope') + +for (const file of readdirSync(fixtureDir).filter((f) => f.endsWith('.js'))) { + it(file.replace('.js', ''), async () => { + const input = readFileSync(path.join(fixtureDir, file), 'utf-8') + const ast = await parseAstAsync(input) + const scopeTree = buildScopeTree(ast) + const snapshot = serializeScopeTree(ast, scopeTree) + await expect(snapshot).toMatchFileSnapshot( + path.join(fixtureDir, file.replace('.js', '.snap')), + ) + }) +} +``` + +#### Snapshot format + +Scope-tree-centric, analogous to `oxc_semantic`'s readable JSON. Each scope node lists +its declarations and the references resolved within it. References show the name and +which scope they resolve to (using a stable label derived from the scope-creating node). + +Example — `shadowing-block.js`: + +```js +function outer() { + const value = 0 + async function action() { + if (true) { + const value = 1 + return value + } + } +} +``` + +`shadowing-block.snap`: + +```json +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [ + { + "type": "Function:outer", + "declarations": ["value"], + "references": [], + "children": [ + { + "type": "Function:action", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": ["value"], + "references": [ + { + "name": "value", + "resolvedIn": "Function:action>BlockStatement>BlockStatement" + } + ], + "children": [] + } + ] + } + ] + } + ] + } + ] +} +``` + +The `resolvedIn` label is a stable path string built from the scope-creating node types +(and function names where available), not from internal numeric IDs. + +`getBindVars` for `action` can be shown separately in the fixture as a comment or in +a parallel `.bindvars.snap` file — TBD. + +#### Test categories (fixture files to create) + +**Scope structure** + +- `module-scope.js` — module scope has no parent; top-level fn parent is moduleScope + +**Declaration placement** + +- `let-const-block.js` — `let`/`const` stays in block scope +- `var-hoisting.js` — `var` in nested block hoists to nearest function scope +- `var-nested-fn.js` — `var` in nested function stays in that fn, not outer +- `fn-decl-hoisting.js` — function declaration name hoists to enclosing fn scope +- `fn-expr-name.js` — function expression name (`function self(){}`) is in its own scope +- `destructured-params.js` — plain/rest/destructured params are in function scope +- `catch-param.js` — catch param is in catch scope +- `class-decl.js` — class declaration name in current scope + +**Reference resolution** + +- `ref-module-local.js` — ref to module-level `const` maps to moduleScope +- `ref-outer-fn.js` — ref to outer function's local maps to outer fn scope +- `ref-same-fn.js` — ref to same-function local maps to fn own scope +- `shadowing-block.js` — ref shadowed in nested block resolves to inner scope +- `ref-var-hoisted.js` — ref to `var` declared later in same fn maps to fn scope +- `ref-global.js` — ref to global (`console`) absent from `referenceToDeclaredScope` + +**`isBindingIdentifier` edge cases — highest priority** + +- `member-expr.js` — `obj.prop`: `prop` NOT a ref; `obj[expr]`: `expr` IS a ref +- `object-expr-vs-pattern.js` — `{key: val}` in expr vs `const {key: val} = obj` +- `computed-destructuring.js` — `const {[expr]: val} = obj`: `expr` IS a ref +- `export-specifier.js` — `export {foo as bar}`: `foo` IS resolved, `bar` is NOT +- `import-specifier.js` — `import {foo as bar}`: `bar` is binding, `foo` is not a ref +- `method-definition.js` — non-computed method key NOT a ref; computed key IS +- `property-definition.js` — `class C { field = val }`: `field` NOT a ref, `val` IS +- `label.js` — label in `break`/`continue` NOT a ref + +**`scopeToReferences` propagation** + +- `propagation.js` — function scope accumulates refs from nested blocks and inner fns + +### 3. Verify `hoist.test.ts` still passes after the extraction ## Non-goals diff --git a/packages/plugin-rsc/src/transforms/cjs.ts b/packages/plugin-rsc/src/transforms/cjs.ts index f1fba9856..20cfb1193 100644 --- a/packages/plugin-rsc/src/transforms/cjs.ts +++ b/packages/plugin-rsc/src/transforms/cjs.ts @@ -3,7 +3,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url' import type { Program, Node } from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' -import { buildScopeTree } from './hoist' +import { buildScopeTree } from './scope' // TODO: // replacing require("xxx") into import("xxx") affects Vite's resolution. diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index b46ce1da0..89acb5c54 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -1,16 +1,7 @@ -import type { - Program, - Literal, - Identifier, - Node, - Pattern, - FunctionDeclaration, - FunctionExpression, - ArrowFunctionExpression, -} from 'estree' +import type { Program, Literal, Node } from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' -import { extractNames } from './utils' +import { buildScopeTree, getAncestorScopes, type ScopeTree } from './scope' export function transformHoistInlineDirective( input: string, @@ -177,184 +168,7 @@ export function findDirectives(ast: Program, directive: string): Literal[] { return nodes } -// TODO: unit test -// ── Custom scope analysis ───────────────────────────────────────── -// Replacement for periscopic's analyze() to correctly handle variable shadowing -// See docs/notes/2026-04-04-hoist-variable-shadowing.md - -type AnyFunctionNode = - | FunctionDeclaration - | FunctionExpression - | ArrowFunctionExpression - -function isFunctionNode(node: Node): node is AnyFunctionNode { - return ( - node.type === 'FunctionDeclaration' || - node.type === 'FunctionExpression' || - node.type === 'ArrowFunctionExpression' - ) -} - -// Scope is an identity token with a parent link. -// declarations is an internal build-time detail used only within buildScopeTree. -class Scope { - readonly declarations: Set = new Set() - - constructor( - public readonly parent: Scope | undefined, - private readonly isFunction: boolean, - ) {} - - nearestFunction(): Scope { - return this.isFunction ? this : this.parent!.nearestFunction() - } -} - -type ScopeTree = { - // each reference Identifier → the Scope that declared it (absent = module-level/global) - readonly referenceToDeclaredScope: WeakMap - // each function Scope → reference Identifiers accessed within its scope - readonly scopeToReferences: WeakMap - // scope-creating AST node → its Scope (the only entry point from AST into Scope) - readonly nodeScope: WeakMap - readonly moduleScope: Scope -} - -export function buildScopeTree(ast: Program): ScopeTree { - const moduleScope = new Scope(undefined, true) - const nodeScope = new WeakMap() - - // Inline resolution during the walk is wrong for `var`/function hoisting: a - // reference that appears before its `var` declaration would resolve to an outer - // binding rather than the locally-hoisted one. The fix is to defer resolution - // until after the walk, when all declarations are in the chain. We collect - // `{ id, visitScope }` pairs during the walk, then resolve them in a post-walk - // loop by scanning up from `visitScope` — at that point the scope tree is - // complete and the scan sees the correct picture. - - // ── Walk: collect declarations and raw reference pairs ─────────────────── - let current = moduleScope - nodeScope.set(ast, moduleScope) - - const rawRefs: Array<{ id: Identifier; visitScope: Scope }> = [] - const ancestors: Node[] = [] - - walk(ast, { - enter(node, parent) { - ancestors.push(node) - if (node.type === 'ImportDeclaration') { - for (const spec of node.specifiers) { - current.declarations.add(spec.local.name) - } - } else if (isFunctionNode(node)) { - // Declare the function name in the current scope (block or function). - // In strict mode (ES modules), block-level function declarations are block-scoped. - if (node.type === 'FunctionDeclaration' && node.id) { - current.declarations.add(node.id.name) - } - // Param scope is separate from the body scope (BlockStatement below creates its own). - // This matches the JS spec: params have their own environment, the body has another. - const scope = new Scope(current, true) - nodeScope.set(node, scope) - current = scope - for (const param of node.params) { - for (const name of extractNames(param)) { - scope.declarations.add(name) - } - } - if (node.type === 'FunctionExpression' && node.id) { - scope.declarations.add(node.id.name) - } - } else if ( - node.type === 'ForStatement' || - node.type === 'ForInStatement' || - node.type === 'ForOfStatement' || - node.type === 'SwitchStatement' || - node.type === 'BlockStatement' - ) { - const scope = new Scope(current, false) - nodeScope.set(node, scope) - current = scope - } else if (node.type === 'CatchClause') { - const scope = new Scope(current, false) - nodeScope.set(node, scope) - current = scope - if (node.param) { - for (const name of extractNames(node.param)) { - scope.declarations.add(name) - } - } - } else if (node.type === 'VariableDeclaration') { - const target = node.kind === 'var' ? current.nearestFunction() : current - for (const decl of node.declarations) { - for (const name of extractNames(decl.id)) { - target.declarations.add(name) - } - } - } else if (node.type === 'ClassDeclaration' && node.id) { - current.declarations.add(node.id.name) - } - // Collect reference identifiers for post-walk resolution. - // TODO: - // To extend to member-expression binding: instead of collecting just the - // Identifier, collect the outermost non-computed MemberExpression rooted at - // it (e.g. `x.y` in `x.y.z`) when one exists. The root - // Identifier is still used for `referenceToDeclaredScope`; the full node - // (Identifier | MemberExpression) goes into `scopeToReferences`. Then - // `getBindVars` inspects each entry — if it is a MemberExpression, extract - // the path key for binding instead of the bare name. - if ( - node.type === 'Identifier' && - !isBindingIdentifier( - node, - parent ?? undefined, - ancestors[ancestors.length - 3], - ) - ) { - rawRefs.push({ id: node, visitScope: current }) - } - }, - leave(node) { - ancestors.pop() - const scope = nodeScope.get(node) - if (scope?.parent) { - current = scope.parent - } - }, - }) - - // ── Post-walk fixup: resolve references against the complete scope tree ── - const scopeToReferences = new WeakMap() - const referenceToDeclaredScope = new WeakMap() - - for (const { id, visitScope } of rawRefs) { - let declScope: Scope | undefined = visitScope - while (declScope && !declScope.declarations.has(id.name)) { - declScope = declScope.parent - } - if (declScope) { - referenceToDeclaredScope.set(id, declScope) - } - // Propagate reference up through all ancestor scopes - let scope: Scope | undefined = visitScope - while (scope) { - if (!scopeToReferences.has(scope)) { - scopeToReferences.set(scope, []) - } - scopeToReferences.get(scope)!.push(id) - scope = scope.parent - } - } - - return { - referenceToDeclaredScope, - scopeToReferences, - nodeScope, - moduleScope, - } -} - -function getBindVars(fn: AnyFunctionNode, scopeTree: ScopeTree): string[] { +function getBindVars(fn: Node, scopeTree: ScopeTree): string[] { const fnScope = scopeTree.nodeScope.get(fn)! const ancestorScopes = getAncestorScopes(fnScope) const references = scopeTree.scopeToReferences.get(fnScope) ?? [] @@ -365,95 +179,3 @@ function getBindVars(fn: AnyFunctionNode, scopeTree: ScopeTree): string[] { }) return [...new Set(bindReferences.map((id) => id.name))] } - -function getAncestorScopes(scope: Scope): Set { - const ancestors = new Set() - let curr = scope.parent - while (curr) { - ancestors.add(curr) - curr = curr.parent - } - return ancestors -} - -// TODO: review -// Binding-position check aligned with oxc-walker's `isBindingIdentifier` in -// `src/scope-tracker.ts`, with ESTree-specific handling for `ExportSpecifier` -// because only `local` is a reference there. -function isBindingIdentifier( - node: Identifier, - parent?: Node, - grandparent?: Node, -): boolean { - if (!parent) return false - switch (parent.type) { - case 'VariableDeclarator': - return patternContainsIdentifier(parent.id, node) - case 'MemberExpression': - return parent.property === node && !parent.computed - case 'Property': - // The value is always the binding in destructuring (both computed and non-computed). - // The key is never a binding — in computed form `{ [expr]: b }` it is a reference. - return grandparent?.type === 'ObjectPattern' && parent.value === node - case 'FunctionDeclaration': - case 'FunctionExpression': - if (parent.id === node) return true - return parent.params.some((param) => - patternContainsIdentifier(param, node), - ) - case 'ArrowFunctionExpression': - return parent.params.some((param) => - patternContainsIdentifier(param, node), - ) - case 'ClassDeclaration': - case 'ClassExpression': - return parent.id === node - case 'MethodDefinition': - case 'PropertyDefinition': - return parent.key === node && !parent.computed - case 'CatchClause': - return !!parent.param && patternContainsIdentifier(parent.param, node) - case 'AssignmentPattern': - return patternContainsIdentifier(parent.left, node) - case 'RestElement': - return patternContainsIdentifier(parent.argument, node) - case 'ArrayPattern': - return true - case 'LabeledStatement': - case 'BreakStatement': - case 'ContinueStatement': - return false - case 'ImportSpecifier': - return parent.imported !== node - case 'ImportDefaultSpecifier': - case 'ImportNamespaceSpecifier': - return true - case 'ExportSpecifier': - return parent.local !== node - default: - return false - } -} - -function patternContainsIdentifier(pattern: Pattern, target: Node): boolean { - switch (pattern.type) { - case 'Identifier': - return pattern === target - case 'MemberExpression': - return pattern === target - case 'ObjectPattern': - return pattern.properties.some((prop) => - prop.type === 'RestElement' - ? patternContainsIdentifier(prop.argument, target) - : patternContainsIdentifier(prop.value, target), - ) - case 'ArrayPattern': - return pattern.elements.some( - (element) => element && patternContainsIdentifier(element, target), - ) - case 'RestElement': - return patternContainsIdentifier(pattern.argument, target) - case 'AssignmentPattern': - return patternContainsIdentifier(pattern.left, target) - } -} diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts new file mode 100644 index 000000000..a750cee25 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -0,0 +1,276 @@ +import type { + Program, + Identifier, + Node, + Pattern, + FunctionDeclaration, + FunctionExpression, + ArrowFunctionExpression, +} from 'estree' +import { walk } from 'estree-walker' +import { extractNames } from './utils' + +// TODO: unit test +// Replacement for periscopic to correctly handle variable shadowing + +class Scope { + readonly declarations: Set = new Set() + + constructor( + public readonly parent: Scope | undefined, + private readonly isFunction: boolean, + ) {} + + nearestFunction(): Scope { + return this.isFunction ? this : this.parent!.nearestFunction() + } +} + +export type ScopeTree = { + // each reference Identifier → the Scope that declared it (absent = module-level/global) + readonly referenceToDeclaredScope: WeakMap + // each function Scope → reference Identifiers accessed within its scope + readonly scopeToReferences: WeakMap + // scope-creating AST node → its Scope (the only entry point from AST into Scope) + readonly nodeScope: WeakMap + readonly moduleScope: Scope +} + +export function buildScopeTree(ast: Program): ScopeTree { + const moduleScope = new Scope(undefined, true) + const nodeScope = new WeakMap() + + // Inline resolution during the walk is wrong for `var`/function hoisting: a + // reference that appears before its `var` declaration would resolve to an outer + // binding rather than the locally-hoisted one. The fix is to defer resolution + // until after the walk, when all declarations are in the chain. We collect + // `{ id, visitScope }` pairs during the walk, then resolve them in a post-walk + // loop by scanning up from `visitScope` — at that point the scope tree is + // complete and the scan sees the correct picture. + + // ── Walk: collect declarations and raw reference pairs ─────────────────── + let current = moduleScope + nodeScope.set(ast, moduleScope) + + const rawRefs: Array<{ id: Identifier; visitScope: Scope }> = [] + const ancestors: Node[] = [] + + walk(ast, { + enter(node, parent) { + ancestors.push(node) + if (node.type === 'ImportDeclaration') { + for (const spec of node.specifiers) { + current.declarations.add(spec.local.name) + } + } else if (isFunctionNode(node)) { + // Declare the function name in the current scope (block or function). + // In strict mode (ES modules), block-level function declarations are block-scoped. + if (node.type === 'FunctionDeclaration' && node.id) { + current.declarations.add(node.id.name) + } + // Param scope is separate from the body scope (BlockStatement below creates its own). + // This matches the JS spec: params have their own environment, the body has another. + const scope = new Scope(current, true) + nodeScope.set(node, scope) + current = scope + for (const param of node.params) { + for (const name of extractNames(param)) { + scope.declarations.add(name) + } + } + if (node.type === 'FunctionExpression' && node.id) { + scope.declarations.add(node.id.name) + } + } else if ( + node.type === 'ForStatement' || + node.type === 'ForInStatement' || + node.type === 'ForOfStatement' || + node.type === 'SwitchStatement' || + node.type === 'BlockStatement' + ) { + const scope = new Scope(current, false) + nodeScope.set(node, scope) + current = scope + } else if (node.type === 'CatchClause') { + const scope = new Scope(current, false) + nodeScope.set(node, scope) + current = scope + if (node.param) { + for (const name of extractNames(node.param)) { + scope.declarations.add(name) + } + } + } else if (node.type === 'VariableDeclaration') { + const target = node.kind === 'var' ? current.nearestFunction() : current + for (const decl of node.declarations) { + for (const name of extractNames(decl.id)) { + target.declarations.add(name) + } + } + } else if (node.type === 'ClassDeclaration' && node.id) { + current.declarations.add(node.id.name) + } + // Collect reference identifiers for post-walk resolution. + // TODO: + // To extend to member-expression binding: instead of collecting just the + // Identifier, collect the outermost non-computed MemberExpression rooted at + // it (e.g. `x.y` in `x.y.z`) when one exists. The root + // Identifier is still used for `referenceToDeclaredScope`; the full node + // (Identifier | MemberExpression) goes into `scopeToReferences`. Then + // `getBindVars` inspects each entry — if it is a MemberExpression, extract + // the path key for binding instead of the bare name. + if ( + node.type === 'Identifier' && + !isBindingIdentifier( + node, + parent ?? undefined, + ancestors[ancestors.length - 3], + ) + ) { + rawRefs.push({ id: node, visitScope: current }) + } + }, + leave(node) { + ancestors.pop() + const scope = nodeScope.get(node) + if (scope?.parent) { + current = scope.parent + } + }, + }) + + // ── Post-walk fixup: resolve references against the complete scope tree ── + const scopeToReferences = new WeakMap() + const referenceToDeclaredScope = new WeakMap() + + for (const { id, visitScope } of rawRefs) { + let declScope: Scope | undefined = visitScope + while (declScope && !declScope.declarations.has(id.name)) { + declScope = declScope.parent + } + if (declScope) { + referenceToDeclaredScope.set(id, declScope) + } + // Propagate reference up through all ancestor scopes + let scope: Scope | undefined = visitScope + while (scope) { + if (!scopeToReferences.has(scope)) { + scopeToReferences.set(scope, []) + } + scopeToReferences.get(scope)!.push(id) + scope = scope.parent + } + } + + return { + referenceToDeclaredScope, + scopeToReferences, + nodeScope, + moduleScope, + } +} + +type AnyFunctionNode = + | FunctionDeclaration + | FunctionExpression + | ArrowFunctionExpression + +function isFunctionNode(node: Node): node is AnyFunctionNode { + return ( + node.type === 'FunctionDeclaration' || + node.type === 'FunctionExpression' || + node.type === 'ArrowFunctionExpression' + ) +} + +export function getAncestorScopes(scope: Scope): Set { + const ancestors = new Set() + let curr = scope.parent + while (curr) { + ancestors.add(curr) + curr = curr.parent + } + return ancestors +} + +// TODO: review +// Binding-position check aligned with oxc-walker's `isBindingIdentifier` in +// `src/scope-tracker.ts`, with ESTree-specific handling for `ExportSpecifier` +// because only `local` is a reference there. +function isBindingIdentifier( + node: Identifier, + parent?: Node, + grandparent?: Node, +): boolean { + if (!parent) return false + switch (parent.type) { + case 'VariableDeclarator': + return patternContainsIdentifier(parent.id, node) + case 'MemberExpression': + return parent.property === node && !parent.computed + case 'Property': + // The value is always the binding in destructuring (both computed and non-computed). + // The key is never a binding — in computed form `{ [expr]: b }` it is a reference. + return grandparent?.type === 'ObjectPattern' && parent.value === node + case 'FunctionDeclaration': + case 'FunctionExpression': + if (parent.id === node) return true + return parent.params.some((param) => + patternContainsIdentifier(param, node), + ) + case 'ArrowFunctionExpression': + return parent.params.some((param) => + patternContainsIdentifier(param, node), + ) + case 'ClassDeclaration': + case 'ClassExpression': + return parent.id === node + case 'MethodDefinition': + case 'PropertyDefinition': + return parent.key === node && !parent.computed + case 'CatchClause': + return !!parent.param && patternContainsIdentifier(parent.param, node) + case 'AssignmentPattern': + return patternContainsIdentifier(parent.left, node) + case 'RestElement': + return patternContainsIdentifier(parent.argument, node) + case 'ArrayPattern': + return true + case 'LabeledStatement': + case 'BreakStatement': + case 'ContinueStatement': + return false + case 'ImportSpecifier': + return parent.imported !== node + case 'ImportDefaultSpecifier': + case 'ImportNamespaceSpecifier': + return true + case 'ExportSpecifier': + return parent.local !== node + default: + return false + } +} + +function patternContainsIdentifier(pattern: Pattern, target: Node): boolean { + switch (pattern.type) { + case 'Identifier': + return pattern === target + case 'MemberExpression': + return pattern === target + case 'ObjectPattern': + return pattern.properties.some((prop) => + prop.type === 'RestElement' + ? patternContainsIdentifier(prop.argument, target) + : patternContainsIdentifier(prop.value, target), + ) + case 'ArrayPattern': + return pattern.elements.some( + (element) => element && patternContainsIdentifier(element, target), + ) + case 'RestElement': + return patternContainsIdentifier(pattern.argument, target) + case 'AssignmentPattern': + return patternContainsIdentifier(pattern.left, target) + } +} diff --git a/packages/plugin-rsc/src/transforms/utils.ts b/packages/plugin-rsc/src/transforms/utils.ts index daba28571..fe40c4cd9 100644 --- a/packages/plugin-rsc/src/transforms/utils.ts +++ b/packages/plugin-rsc/src/transforms/utils.ts @@ -85,6 +85,7 @@ export function extractNames(param: Pattern): string[] { return extractIdentifiers(param).map((n) => n.name) } +// TODO: review export function extractIdentifiers( param: Pattern, nodes: Identifier[] = [], From 003578ff57d2c719a3e3c26595fe493fe9585219 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:09:28 +0900 Subject: [PATCH 36/88] refactor: rename --- packages/plugin-rsc/src/transforms/scope.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index a750cee25..b79c15b47 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -21,8 +21,8 @@ class Scope { private readonly isFunction: boolean, ) {} - nearestFunction(): Scope { - return this.isFunction ? this : this.parent!.nearestFunction() + nearestFunctionScope(): Scope { + return this.isFunction ? this : this.parent!.nearestFunctionScope() } } @@ -101,7 +101,8 @@ export function buildScopeTree(ast: Program): ScopeTree { } } } else if (node.type === 'VariableDeclaration') { - const target = node.kind === 'var' ? current.nearestFunction() : current + const target = + node.kind === 'var' ? current.nearestFunctionScope() : current for (const decl of node.declarations) { for (const name of extractNames(decl.id)) { target.declarations.add(name) From f54dfc3ed6cfd44894635a9aa74bde986ef77b6c Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:12:34 +0900 Subject: [PATCH 37/88] refactor: move code --- packages/plugin-rsc/src/transforms/hoist.ts | 4 ++-- packages/plugin-rsc/src/transforms/scope.ts | 26 ++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/hoist.ts b/packages/plugin-rsc/src/transforms/hoist.ts index 89acb5c54..ad926d1b0 100644 --- a/packages/plugin-rsc/src/transforms/hoist.ts +++ b/packages/plugin-rsc/src/transforms/hoist.ts @@ -1,7 +1,7 @@ import type { Program, Literal, Node } from 'estree' import { walk } from 'estree-walker' import MagicString from 'magic-string' -import { buildScopeTree, getAncestorScopes, type ScopeTree } from './scope' +import { buildScopeTree, type ScopeTree } from './scope' export function transformHoistInlineDirective( input: string, @@ -170,7 +170,7 @@ export function findDirectives(ast: Program, directive: string): Literal[] { function getBindVars(fn: Node, scopeTree: ScopeTree): string[] { const fnScope = scopeTree.nodeScope.get(fn)! - const ancestorScopes = getAncestorScopes(fnScope) + const ancestorScopes = fnScope.getAncestorScopes() const references = scopeTree.scopeToReferences.get(fnScope) ?? [] // bind variables that are the ones declared in ancestor scopes but not module global scope const bindReferences = references.filter((id) => { diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index b79c15b47..864eead71 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -21,8 +21,18 @@ class Scope { private readonly isFunction: boolean, ) {} - nearestFunctionScope(): Scope { - return this.isFunction ? this : this.parent!.nearestFunctionScope() + getNearestFunctionScope(): Scope { + return this.isFunction ? this : this.parent!.getNearestFunctionScope() + } + + getAncestorScopes(): Set { + const ancestors = new Set() + let curr = this.parent + while (curr) { + ancestors.add(curr) + curr = curr.parent + } + return ancestors } } @@ -102,7 +112,7 @@ export function buildScopeTree(ast: Program): ScopeTree { } } else if (node.type === 'VariableDeclaration') { const target = - node.kind === 'var' ? current.nearestFunctionScope() : current + node.kind === 'var' ? current.getNearestFunctionScope() : current for (const decl of node.declarations) { for (const name of extractNames(decl.id)) { target.declarations.add(name) @@ -184,16 +194,6 @@ function isFunctionNode(node: Node): node is AnyFunctionNode { ) } -export function getAncestorScopes(scope: Scope): Set { - const ancestors = new Set() - let curr = scope.parent - while (curr) { - ancestors.add(curr) - curr = curr.parent - } - return ancestors -} - // TODO: review // Binding-position check aligned with oxc-walker's `isBindingIdentifier` in // `src/scope-tracker.ts`, with ESTree-specific handling for `ExportSpecifier` From 941f3d9e4107978ea430fbcedac0f4f0883cb326 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:13:23 +0900 Subject: [PATCH 38/88] chore: rename --- packages/plugin-rsc/src/transforms/scope.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 864eead71..b074c953b 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -62,7 +62,7 @@ export function buildScopeTree(ast: Program): ScopeTree { let current = moduleScope nodeScope.set(ast, moduleScope) - const rawRefs: Array<{ id: Identifier; visitScope: Scope }> = [] + const rawReferences: Array<{ id: Identifier; visitScope: Scope }> = [] const ancestors: Node[] = [] walk(ast, { @@ -138,7 +138,7 @@ export function buildScopeTree(ast: Program): ScopeTree { ancestors[ancestors.length - 3], ) ) { - rawRefs.push({ id: node, visitScope: current }) + rawReferences.push({ id: node, visitScope: current }) } }, leave(node) { @@ -154,7 +154,7 @@ export function buildScopeTree(ast: Program): ScopeTree { const scopeToReferences = new WeakMap() const referenceToDeclaredScope = new WeakMap() - for (const { id, visitScope } of rawRefs) { + for (const { id, visitScope } of rawReferences) { let declScope: Scope | undefined = visitScope while (declScope && !declScope.declarations.has(id.name)) { declScope = declScope.parent From d08504bad0eebf26fe11743091d285e5bdc74e94 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:38:08 +0900 Subject: [PATCH 39/88] test: add scope test --- .../docs/notes/2026-04-04-scope-unit-tests.md | 10 +- .../transforms/fixtures/scope/catch-param.js | 5 + .../fixtures/scope/catch-param.js.snap | 37 +++++ .../transforms/fixtures/scope/class-decl.js | 2 + .../fixtures/scope/class-decl.js.snap | 14 ++ .../fixtures/scope/computed-destructuring.js | 3 + .../scope/computed-destructuring.js.snap | 19 +++ .../fixtures/scope/destructured-params.js | 3 + .../scope/destructured-params.js.snap | 53 +++++++ .../fixtures/scope/export-specifier.js | 2 + .../fixtures/scope/export-specifier.js.snap | 13 ++ .../fixtures/scope/fn-decl-hoisting.js | 4 + .../fixtures/scope/fn-decl-hoisting.js.snap | 43 ++++++ .../transforms/fixtures/scope/fn-expr-name.js | 3 + .../fixtures/scope/fn-expr-name.js.snap | 29 ++++ .../fixtures/scope/import-specifier.js | 2 + .../fixtures/scope/import-specifier.js.snap | 17 +++ .../src/transforms/fixtures/scope/label.js | 6 + .../transforms/fixtures/scope/label.js.snap | 83 +++++++++++ .../fixtures/scope/let-const-block.js | 7 + .../fixtures/scope/let-const-block.js.snap | 41 ++++++ .../transforms/fixtures/scope/member-expr.js | 4 + .../fixtures/scope/member-expr.js.snap | 22 +++ .../fixtures/scope/method-definition.js | 5 + .../fixtures/scope/method-definition.js.snap | 41 ++++++ .../fixtures/scope/object-expr-vs-pattern.js | 4 + .../scope/object-expr-vs-pattern.js.snap | 28 ++++ .../transforms/fixtures/scope/propagation.js | 8 ++ .../fixtures/scope/propagation.js.snap | 55 ++++++++ .../fixtures/scope/property-definition.js | 4 + .../scope/property-definition.js.snap | 14 ++ .../transforms/fixtures/scope/ref-global.js | 3 + .../fixtures/scope/ref-global.js.snap | 27 ++++ .../transforms/fixtures/scope/ref-outer-fn.js | 6 + .../fixtures/scope/ref-outer-fn.js.snap | 44 ++++++ .../fixtures/scope/shadowing-block.js | 9 ++ .../fixtures/scope/shadowing-block.js.snap | 53 +++++++ .../transforms/fixtures/scope/var-hoisting.js | 6 + .../fixtures/scope/var-hoisting.js.snap | 36 +++++ .../fixtures/scope/var-nested-fn.js | 6 + .../fixtures/scope/var-nested-fn.js.snap | 45 ++++++ .../plugin-rsc/src/transforms/scope.test.ts | 131 ++++++++++++++++++ packages/plugin-rsc/src/transforms/scope.ts | 2 +- 43 files changed, 941 insertions(+), 8 deletions(-) create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/label.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap create mode 100644 packages/plugin-rsc/src/transforms/scope.test.ts diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md index bd52e93b7..74de9ffdb 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md @@ -10,12 +10,9 @@ This is step 5 of the migration plan in `2026-04-04-hoist-variable-shadowing.md` ## Steps -### 1. Extract `scope.ts` from `hoist.ts` +### 1. Extract `scope.ts` from `hoist.ts` ✅ -- Move: `Scope`, `ScopeTree`, `buildScopeTree`, `getBindVars`, `getAncestorScopes`, - `isBindingIdentifier`, `patternContainsIdentifier`, `extractNames`, `extractIdentifiers` -- Export at minimum: `buildScopeTree`, `getBindVars`, `ScopeTree`, `Scope` -- `hoist.ts` imports from `./scope` +Done. `src/transforms/scope.ts` exists; `hoist.ts` imports from it. ### 2. File-based fixture tests in `scope.test.ts` @@ -126,8 +123,7 @@ function outer() { The `resolvedIn` label is a stable path string built from the scope-creating node types (and function names where available), not from internal numeric IDs. -`getBindVars` for `action` can be shown separately in the fixture as a comment or in -a parallel `.bindvars.snap` file — TBD. +Note: `getBindVars` is a `hoist.ts` concern and is not tested here. #### Test categories (fixture files to create) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js new file mode 100644 index 000000000..2a2388386 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js @@ -0,0 +1,5 @@ +try { + throw 1 +} catch (e) { + console.log(e) +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap new file mode 100644 index 000000000..9ec85ac54 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap @@ -0,0 +1,37 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + }, + { + "type": "CatchClause", + "declarations": [ + "e" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "console", + "resolvedIn": null + }, + { + "name": "e", + "resolvedIn": "Program > CatchClause" + } + ], + "children": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js new file mode 100644 index 000000000..6d085d5f6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js @@ -0,0 +1,2 @@ +class Foo {} +const x = new Foo() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap new file mode 100644 index 000000000..06b7d51b2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "x" + ], + "references": [ + { + "name": "Foo", + "resolvedIn": "Program" + } + ], + "children": [] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js new file mode 100644 index 000000000..9f3558711 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js @@ -0,0 +1,3 @@ +const key = 'k' +const obj = {} +const { [key]: val } = obj diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap new file mode 100644 index 000000000..3a2338576 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap @@ -0,0 +1,19 @@ +{ + "type": "Program", + "declarations": [ + "key", + "obj", + "val" + ], + "references": [ + { + "name": "key", + "resolvedIn": "Program" + }, + { + "name": "obj", + "resolvedIn": "Program" + } + ], + "children": [] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js new file mode 100644 index 000000000..b14c20a8a --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js @@ -0,0 +1,3 @@ +function f({ a, b: [c, d] }, ...rest) { + return a + c + d + rest.length +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap new file mode 100644 index 000000000..11776095c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap @@ -0,0 +1,53 @@ +{ + "type": "Program", + "declarations": [ + "f" + ], + "references": [], + "children": [ + { + "type": "Function:f", + "declarations": [ + "a", + "c", + "d", + "rest" + ], + "references": [ + { + "name": "a", + "resolvedIn": "Program > Function:f" + }, + { + "name": "b", + "resolvedIn": null + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "resolvedIn": "Program > Function:f" + }, + { + "name": "c", + "resolvedIn": "Program > Function:f" + }, + { + "name": "d", + "resolvedIn": "Program > Function:f" + }, + { + "name": "rest", + "resolvedIn": "Program > Function:f" + } + ], + "children": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js new file mode 100644 index 000000000..f20f46ae2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js @@ -0,0 +1,2 @@ +const foo = 1 +export { foo as bar } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap new file mode 100644 index 000000000..0f3bbbaf2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [ + { + "name": "foo", + "resolvedIn": "Program" + } + ], + "children": [] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js new file mode 100644 index 000000000..8cf5ffb3c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js @@ -0,0 +1,4 @@ +function outer() { + foo() + function foo() {} +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap new file mode 100644 index 000000000..4f85662bd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap @@ -0,0 +1,43 @@ +{ + "type": "Program", + "declarations": [ + "outer" + ], + "references": [], + "children": [ + { + "type": "Function:outer", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "foo" + ], + "references": [ + { + "name": "foo", + "resolvedIn": "Program > Function:outer > BlockStatement" + } + ], + "children": [ + { + "type": "Function:foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js new file mode 100644 index 000000000..deeaa2aec --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js @@ -0,0 +1,3 @@ +const f = function self() { + return self +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap new file mode 100644 index 000000000..85a649f51 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "f" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression:self", + "declarations": [ + "self" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "self", + "resolvedIn": "Program > FunctionExpression:self" + } + ], + "children": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js new file mode 100644 index 000000000..c006ab330 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js @@ -0,0 +1,2 @@ +import { foo as bar } from './mod' +bar() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap new file mode 100644 index 000000000..6bde237a9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap @@ -0,0 +1,17 @@ +{ + "type": "Program", + "declarations": [ + "bar" + ], + "references": [ + { + "name": "foo", + "resolvedIn": null + }, + { + "name": "bar", + "resolvedIn": "Program" + } + ], + "children": [] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js new file mode 100644 index 000000000..16676f3b7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js @@ -0,0 +1,6 @@ +outer: for (let i = 0; i < 3; i++) { + inner: for (let j = 0; j < 3; j++) { + if (j === 1) break outer + if (i === 1) continue inner + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap new file mode 100644 index 000000000..09c33bb00 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap @@ -0,0 +1,83 @@ +{ + "type": "Program", + "declarations": [], + "references": [ + { + "name": "outer", + "resolvedIn": null + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [ + "i" + ], + "references": [ + { + "name": "i", + "resolvedIn": "Program > ForStatement" + }, + { + "name": "i", + "resolvedIn": "Program > ForStatement" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "inner", + "resolvedIn": null + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [ + "j" + ], + "references": [ + { + "name": "j", + "resolvedIn": "Program > ForStatement > BlockStatement > ForStatement" + }, + { + "name": "j", + "resolvedIn": "Program > ForStatement > BlockStatement > ForStatement" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "j", + "resolvedIn": "Program > ForStatement > BlockStatement > ForStatement" + }, + { + "name": "outer", + "resolvedIn": null + }, + { + "name": "i", + "resolvedIn": "Program > ForStatement" + }, + { + "name": "inner", + "resolvedIn": null + } + ], + "children": [] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js new file mode 100644 index 000000000..33ad80603 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js @@ -0,0 +1,7 @@ +function f() { + { + let x = 1 + const y = 2 + return x + y + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap new file mode 100644 index 000000000..083ef788f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap @@ -0,0 +1,41 @@ +{ + "type": "Program", + "declarations": [ + "f" + ], + "references": [], + "children": [ + { + "type": "Function:f", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "x", + "y" + ], + "references": [ + { + "name": "x", + "resolvedIn": "Program > Function:f > BlockStatement > BlockStatement" + }, + { + "name": "y", + "resolvedIn": "Program > Function:f > BlockStatement > BlockStatement" + } + ], + "children": [] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js new file mode 100644 index 000000000..393ff43af --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js @@ -0,0 +1,4 @@ +const obj = {} +const key = 'k' +obj.prop +obj[key] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap new file mode 100644 index 000000000..208b5c518 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "key", + "obj" + ], + "references": [ + { + "name": "obj", + "resolvedIn": "Program" + }, + { + "name": "obj", + "resolvedIn": "Program" + }, + { + "name": "key", + "resolvedIn": "Program" + } + ], + "children": [] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js new file mode 100644 index 000000000..c6a4818c2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js @@ -0,0 +1,5 @@ +const key = 'k' +class C { + method() {} + [key]() {} +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap new file mode 100644 index 000000000..bbd760255 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap @@ -0,0 +1,41 @@ +{ + "type": "Program", + "declarations": [ + "C", + "key" + ], + "references": [ + { + "name": "key", + "resolvedIn": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js new file mode 100644 index 000000000..e0cbdabfe --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js @@ -0,0 +1,4 @@ +const key = 'k' +const val = 1 +const obj = { key: val } +const { key: bound } = obj diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap new file mode 100644 index 000000000..ebafad7b7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap @@ -0,0 +1,28 @@ +{ + "type": "Program", + "declarations": [ + "bound", + "key", + "obj", + "val" + ], + "references": [ + { + "name": "key", + "resolvedIn": "Program" + }, + { + "name": "val", + "resolvedIn": "Program" + }, + { + "name": "key", + "resolvedIn": "Program" + }, + { + "name": "obj", + "resolvedIn": "Program" + } + ], + "children": [] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js new file mode 100644 index 000000000..e7b3bd13e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js @@ -0,0 +1,8 @@ +function outer() { + const x = 0 + function inner() { + const y = 1 + return x + y + } + return inner +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap new file mode 100644 index 000000000..ea0d1e2f8 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap @@ -0,0 +1,55 @@ +{ + "type": "Program", + "declarations": [ + "outer" + ], + "references": [], + "children": [ + { + "type": "Function:outer", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "inner", + "x" + ], + "references": [ + { + "name": "inner", + "resolvedIn": "Program > Function:outer > BlockStatement" + } + ], + "children": [ + { + "type": "Function:inner", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "y" + ], + "references": [ + { + "name": "x", + "resolvedIn": "Program > Function:outer > BlockStatement" + }, + { + "name": "y", + "resolvedIn": "Program > Function:outer > BlockStatement > Function:inner > BlockStatement" + } + ], + "children": [] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js new file mode 100644 index 000000000..938e34ae5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js @@ -0,0 +1,4 @@ +const val = 1 +class C { + field = val +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap new file mode 100644 index 000000000..b80456a6f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "C", + "val" + ], + "references": [ + { + "name": "val", + "resolvedIn": "Program" + } + ], + "children": [] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js new file mode 100644 index 000000000..bfe3872a8 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js @@ -0,0 +1,3 @@ +function f() { + console.log('hello') +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap new file mode 100644 index 000000000..4f2e09e03 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "f" + ], + "references": [], + "children": [ + { + "type": "Function:f", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "console", + "resolvedIn": null + } + ], + "children": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js new file mode 100644 index 000000000..149fda64c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js @@ -0,0 +1,6 @@ +function outer() { + const value = 0 + function inner() { + return value + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap new file mode 100644 index 000000000..e5425bc5a --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap @@ -0,0 +1,44 @@ +{ + "type": "Program", + "declarations": [ + "outer" + ], + "references": [], + "children": [ + { + "type": "Function:outer", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "inner", + "value" + ], + "references": [], + "children": [ + { + "type": "Function:inner", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "value", + "resolvedIn": "Program > Function:outer > BlockStatement" + } + ], + "children": [] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js new file mode 100644 index 000000000..9a98b4c95 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js @@ -0,0 +1,9 @@ +function outer() { + const value = 0 + function action() { + if (true) { + const value = 1 + return value + } + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap new file mode 100644 index 000000000..a0d618420 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap @@ -0,0 +1,53 @@ +{ + "type": "Program", + "declarations": [ + "outer" + ], + "references": [], + "children": [ + { + "type": "Function:outer", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "action", + "value" + ], + "references": [], + "children": [ + { + "type": "Function:action", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "value" + ], + "references": [ + { + "name": "value", + "resolvedIn": "Program > Function:outer > BlockStatement > Function:action > BlockStatement > BlockStatement" + } + ], + "children": [] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js new file mode 100644 index 000000000..ed135e0f0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js @@ -0,0 +1,6 @@ +function f() { + { + var x = 1 + } + return x +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap new file mode 100644 index 000000000..28859458e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap @@ -0,0 +1,36 @@ +{ + "type": "Program", + "declarations": [ + "f" + ], + "references": [], + "children": [ + { + "type": "Function:f", + "declarations": [ + "x" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "x", + "resolvedIn": "Program > Function:f" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js new file mode 100644 index 000000000..56bc7b4bb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js @@ -0,0 +1,6 @@ +function outer() { + function inner() { + var x = 1 + } + return x +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap new file mode 100644 index 000000000..107a384a9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap @@ -0,0 +1,45 @@ +{ + "type": "Program", + "declarations": [ + "outer" + ], + "references": [], + "children": [ + { + "type": "Function:outer", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "inner" + ], + "references": [ + { + "name": "x", + "resolvedIn": null + } + ], + "children": [ + { + "type": "Function:inner", + "declarations": [ + "x" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts new file mode 100644 index 000000000..287f0edc4 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -0,0 +1,131 @@ +import { readFileSync, readdirSync } from 'node:fs' +import path from 'node:path' +import type { Node, Program } from 'estree' +import { walk } from 'estree-walker' +import { parseAstAsync } from 'vite' +import { describe, expect, it } from 'vitest' +import { type Scope, type ScopeTree, buildScopeTree } from './scope' + +// TODO: import.meta.glob +const fixtureDir = new URL('./fixtures/scope', import.meta.url).pathname + +describe('buildScopeTree', () => { + const files = readdirSync(fixtureDir) + .filter((f) => f.endsWith('.js')) + .sort() + + for (const file of files) { + it(file.replace('.js', ''), async () => { + const input = readFileSync(path.join(fixtureDir, file), 'utf-8') + const ast = await parseAstAsync(input) + const scopeTree = buildScopeTree(ast) + const snapshot = serializeScopeTree(ast, scopeTree) + await expect(snapshot).toMatchFileSnapshot( + path.join(fixtureDir, file + '.snap'), + ) + }) + } +}) + +// TODO: review +// ── Serializer ──────────────────────────────────────────────────────────────── + +type SerializedScope = { + type: string + declarations: string[] + references: Array<{ name: string; resolvedIn: string | null }> + children: SerializedScope[] +} + +function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { + const { + nodeScope, + referenceToDeclaredScope, + scopeToReferences, + moduleScope, + } = scopeTree + + // Build scope → label and scope → direct children. + // Labels are disambiguated per parent (e.g. BlockStatement[2] for the second sibling). + const scopeLabel = new Map() + const scopeChildren = new Map() + const siblingCount = new Map>() + + scopeLabel.set(moduleScope, 'Program') + scopeChildren.set(moduleScope, []) + + walk(ast as Node, { + enter(node) { + const scope = nodeScope.get(node) + if (!scope || scope === moduleScope) return + + const parent = scope.parent! + const base = scopeNodeLabel(node) + + if (!siblingCount.has(parent)) siblingCount.set(parent, new Map()) + const counts = siblingCount.get(parent)! + const n = (counts.get(base) ?? 0) + 1 + counts.set(base, n) + + scopeLabel.set(scope, n === 1 ? base : `${base}[${n}]`) + + if (!scopeChildren.has(parent)) scopeChildren.set(parent, []) + scopeChildren.get(parent)!.push(scope) + scopeChildren.set(scope, []) + }, + }) + + // Stable path string for a scope, used as the resolvedIn value. + function fullPath(scope: Scope): string { + const parts: string[] = [] + let curr: Scope | undefined = scope + while (curr) { + parts.unshift(scopeLabel.get(curr) ?? '?') + curr = curr.parent + } + return parts.join(' > ') + } + + // Direct references for a scope = all propagated refs minus those in child scopes. + function directRefs(scope: Scope) { + const allRefs = scopeToReferences.get(scope) ?? [] + const childRefSet = new Set( + (scopeChildren.get(scope) ?? []).flatMap( + (c) => scopeToReferences.get(c) ?? [], + ), + ) + return allRefs.filter((id) => !childRefSet.has(id)) + } + + function buildNode(scope: Scope): SerializedScope { + const refs = directRefs(scope) + return { + type: scopeLabel.get(scope)!, + declarations: [...scope.declarations].sort(), + references: refs.map((id) => ({ + name: id.name, + resolvedIn: referenceToDeclaredScope.has(id) + ? fullPath(referenceToDeclaredScope.get(id)!) + : null, + })), + children: (scopeChildren.get(scope) ?? []).map(buildNode), + } + } + + return JSON.stringify(buildNode(moduleScope), null, 2) +} + +function scopeNodeLabel(node: Node): string { + switch (node.type) { + case 'FunctionDeclaration': + return node.id ? `Function:${node.id.name}` : 'Function' + case 'FunctionExpression': + return node.id + ? `FunctionExpression:${node.id.name}` + : 'FunctionExpression' + case 'ArrowFunctionExpression': + return 'ArrowFunction' + default: + return node.type + } +} diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index b074c953b..0518776b1 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -13,7 +13,7 @@ import { extractNames } from './utils' // TODO: unit test // Replacement for periscopic to correctly handle variable shadowing -class Scope { +export class Scope { readonly declarations: Set = new Set() constructor( From 44c967f8ef66bfa78364ec935124a5a6902e173a Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:43:15 +0900 Subject: [PATCH 40/88] test: use glob fixtures --- .../plugin-rsc/src/transforms/scope.test.ts | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 287f0edc4..fc6287e4e 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -1,4 +1,3 @@ -import { readFileSync, readdirSync } from 'node:fs' import path from 'node:path' import type { Node, Program } from 'estree' import { walk } from 'estree-walker' @@ -6,23 +5,15 @@ import { parseAstAsync } from 'vite' import { describe, expect, it } from 'vitest' import { type Scope, type ScopeTree, buildScopeTree } from './scope' -// TODO: import.meta.glob -const fixtureDir = new URL('./fixtures/scope', import.meta.url).pathname - -describe('buildScopeTree', () => { - const files = readdirSync(fixtureDir) - .filter((f) => f.endsWith('.js')) - .sort() - - for (const file of files) { - it(file.replace('.js', ''), async () => { - const input = readFileSync(path.join(fixtureDir, file), 'utf-8') +describe('fixtures', () => { + const fixtures = import.meta.glob('./fixtures/scope/*.js', { query: 'raw' }) + for (const [file, mod] of Object.entries(fixtures)) { + it(path.basename(file), async () => { + const input = ((await mod()) as any).default as string const ast = await parseAstAsync(input) const scopeTree = buildScopeTree(ast) const snapshot = serializeScopeTree(ast, scopeTree) - await expect(snapshot).toMatchFileSnapshot( - path.join(fixtureDir, file + '.snap'), - ) + await expect(snapshot).toMatchFileSnapshot(file + '.snap') }) } }) From 3bccb3dc181e38edc7c44e686b0b3940f4bc2db1 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:45:20 +0900 Subject: [PATCH 41/88] test: use .snap.json --- .oxfmtrc.json | 1 + .../scope/{catch-param.js.snap => catch-param.js.snap.json} | 0 .../scope/{class-decl.js.snap => class-decl.js.snap.json} | 0 ...estructuring.js.snap => computed-destructuring.js.snap.json} | 0 ...ructured-params.js.snap => destructured-params.js.snap.json} | 0 .../{export-specifier.js.snap => export-specifier.js.snap.json} | 0 .../{fn-decl-hoisting.js.snap => fn-decl-hoisting.js.snap.json} | 0 .../scope/{fn-expr-name.js.snap => fn-expr-name.js.snap.json} | 0 .../{import-specifier.js.snap => import-specifier.js.snap.json} | 0 .../fixtures/scope/{label.js.snap => label.js.snap.json} | 0 .../{let-const-block.js.snap => let-const-block.js.snap.json} | 0 .../scope/{member-expr.js.snap => member-expr.js.snap.json} | 0 ...method-definition.js.snap => method-definition.js.snap.json} | 0 ...r-vs-pattern.js.snap => object-expr-vs-pattern.js.snap.json} | 0 .../scope/{propagation.js.snap => propagation.js.snap.json} | 0 ...erty-definition.js.snap => property-definition.js.snap.json} | 0 .../scope/{ref-global.js.snap => ref-global.js.snap.json} | 0 .../scope/{ref-outer-fn.js.snap => ref-outer-fn.js.snap.json} | 0 .../{shadowing-block.js.snap => shadowing-block.js.snap.json} | 0 .../scope/{var-hoisting.js.snap => var-hoisting.js.snap.json} | 0 .../scope/{var-nested-fn.js.snap => var-nested-fn.js.snap.json} | 0 packages/plugin-rsc/src/transforms/scope.test.ts | 2 +- 22 files changed, 2 insertions(+), 1 deletion(-) rename packages/plugin-rsc/src/transforms/fixtures/scope/{catch-param.js.snap => catch-param.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{class-decl.js.snap => class-decl.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{computed-destructuring.js.snap => computed-destructuring.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{destructured-params.js.snap => destructured-params.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{export-specifier.js.snap => export-specifier.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{fn-decl-hoisting.js.snap => fn-decl-hoisting.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{fn-expr-name.js.snap => fn-expr-name.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{import-specifier.js.snap => import-specifier.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{label.js.snap => label.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{let-const-block.js.snap => let-const-block.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{member-expr.js.snap => member-expr.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{method-definition.js.snap => method-definition.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{object-expr-vs-pattern.js.snap => object-expr-vs-pattern.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{propagation.js.snap => propagation.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{property-definition.js.snap => property-definition.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{ref-global.js.snap => ref-global.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{ref-outer-fn.js.snap => ref-outer-fn.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{shadowing-block.js.snap => shadowing-block.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{var-hoisting.js.snap => var-hoisting.js.snap.json} (100%) rename packages/plugin-rsc/src/transforms/fixtures/scope/{var-nested-fn.js.snap => var-nested-fn.js.snap.json} (100%) diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 594e030b4..afb4926b4 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -9,6 +9,7 @@ "groups": [["builtin"], ["external"]] }, "ignorePatterns": [ + "*.snap.json", "packages/*/CHANGELOG.md", "playground-temp/", "dist/", diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json similarity index 100% rename from packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap rename to packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index fc6287e4e..a5aa2a849 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -13,7 +13,7 @@ describe('fixtures', () => { const ast = await parseAstAsync(input) const scopeTree = buildScopeTree(ast) const snapshot = serializeScopeTree(ast, scopeTree) - await expect(snapshot).toMatchFileSnapshot(file + '.snap') + await expect(snapshot).toMatchFileSnapshot(file + '.snap.json') }) } }) From 716cef57e68677ba7dffa67601fb6470d310ddec Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 18:58:43 +0900 Subject: [PATCH 42/88] test: tweak scope tree format --- .../fixtures/scope/destructured-params.js.snap.json | 12 ++++++------ .../fixtures/scope/fn-decl-hoisting.js.snap.json | 6 +++--- .../fixtures/scope/let-const-block.js.snap.json | 6 +++--- .../fixtures/scope/propagation.js.snap.json | 10 +++++----- .../fixtures/scope/ref-global.js.snap.json | 2 +- .../fixtures/scope/ref-outer-fn.js.snap.json | 6 +++--- .../fixtures/scope/shadowing-block.js.snap.json | 6 +++--- .../fixtures/scope/var-hoisting.js.snap.json | 4 ++-- .../fixtures/scope/var-nested-fn.js.snap.json | 4 ++-- packages/plugin-rsc/src/transforms/scope.test.ts | 6 ++---- 10 files changed, 30 insertions(+), 32 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json index 11776095c..8bc9562e4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:f", + "type": "FunctionDeclaration:f", "declarations": [ "a", "c", @@ -16,7 +16,7 @@ "references": [ { "name": "a", - "resolvedIn": "Program > Function:f" + "resolvedIn": "Program > FunctionDeclaration:f" }, { "name": "b", @@ -30,19 +30,19 @@ "references": [ { "name": "a", - "resolvedIn": "Program > Function:f" + "resolvedIn": "Program > FunctionDeclaration:f" }, { "name": "c", - "resolvedIn": "Program > Function:f" + "resolvedIn": "Program > FunctionDeclaration:f" }, { "name": "d", - "resolvedIn": "Program > Function:f" + "resolvedIn": "Program > FunctionDeclaration:f" }, { "name": "rest", - "resolvedIn": "Program > Function:f" + "resolvedIn": "Program > FunctionDeclaration:f" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json index 4f85662bd..e59ac434b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:outer", + "type": "FunctionDeclaration:outer", "declarations": [], "references": [], "children": [ @@ -18,12 +18,12 @@ "references": [ { "name": "foo", - "resolvedIn": "Program > Function:outer > BlockStatement" + "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement" } ], "children": [ { - "type": "Function:foo", + "type": "FunctionDeclaration:foo", "declarations": [], "references": [], "children": [ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json index 083ef788f..6c90a858a 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:f", + "type": "FunctionDeclaration:f", "declarations": [], "references": [], "children": [ @@ -24,11 +24,11 @@ "references": [ { "name": "x", - "resolvedIn": "Program > Function:f > BlockStatement > BlockStatement" + "resolvedIn": "Program > FunctionDeclaration:f > BlockStatement > BlockStatement" }, { "name": "y", - "resolvedIn": "Program > Function:f > BlockStatement > BlockStatement" + "resolvedIn": "Program > FunctionDeclaration:f > BlockStatement > BlockStatement" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json index ea0d1e2f8..0a2141bc5 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:outer", + "type": "FunctionDeclaration:outer", "declarations": [], "references": [], "children": [ @@ -19,12 +19,12 @@ "references": [ { "name": "inner", - "resolvedIn": "Program > Function:outer > BlockStatement" + "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement" } ], "children": [ { - "type": "Function:inner", + "type": "FunctionDeclaration:inner", "declarations": [], "references": [], "children": [ @@ -36,11 +36,11 @@ "references": [ { "name": "x", - "resolvedIn": "Program > Function:outer > BlockStatement" + "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement" }, { "name": "y", - "resolvedIn": "Program > Function:outer > BlockStatement > Function:inner > BlockStatement" + "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:inner > BlockStatement" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json index 4f2e09e03..b8c341502 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:f", + "type": "FunctionDeclaration:f", "declarations": [], "references": [], "children": [ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json index e5425bc5a..dcdc29618 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:outer", + "type": "FunctionDeclaration:outer", "declarations": [], "references": [], "children": [ @@ -19,7 +19,7 @@ "references": [], "children": [ { - "type": "Function:inner", + "type": "FunctionDeclaration:inner", "declarations": [], "references": [], "children": [ @@ -29,7 +29,7 @@ "references": [ { "name": "value", - "resolvedIn": "Program > Function:outer > BlockStatement" + "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json index a0d618420..54f0bbb2f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:outer", + "type": "FunctionDeclaration:outer", "declarations": [], "references": [], "children": [ @@ -19,7 +19,7 @@ "references": [], "children": [ { - "type": "Function:action", + "type": "FunctionDeclaration:action", "declarations": [], "references": [], "children": [ @@ -36,7 +36,7 @@ "references": [ { "name": "value", - "resolvedIn": "Program > Function:outer > BlockStatement > Function:action > BlockStatement > BlockStatement" + "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:action > BlockStatement > BlockStatement" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json index 28859458e..6f8ea46dd 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:f", + "type": "FunctionDeclaration:f", "declarations": [ "x" ], @@ -18,7 +18,7 @@ "references": [ { "name": "x", - "resolvedIn": "Program > Function:f" + "resolvedIn": "Program > FunctionDeclaration:f" } ], "children": [ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json index 107a384a9..9982b9aec 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json @@ -6,7 +6,7 @@ "references": [], "children": [ { - "type": "Function:outer", + "type": "FunctionDeclaration:outer", "declarations": [], "references": [], "children": [ @@ -23,7 +23,7 @@ ], "children": [ { - "type": "Function:inner", + "type": "FunctionDeclaration:inner", "declarations": [ "x" ], diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index a5aa2a849..8c63ee6c9 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -109,11 +109,9 @@ function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { function scopeNodeLabel(node: Node): string { switch (node.type) { case 'FunctionDeclaration': - return node.id ? `Function:${node.id.name}` : 'Function' + return `${node.type}:${node.id.name}` case 'FunctionExpression': - return node.id - ? `FunctionExpression:${node.id.name}` - : 'FunctionExpression' + return node.type + (node.id ? `:${node.id.name}` : '') case 'ArrowFunctionExpression': return 'ArrowFunction' default: From deb1077e1b4230539af125aab9e6182795946de3 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 19:02:58 +0900 Subject: [PATCH 43/88] refactor: WeakMap -> Map --- .../docs/notes/2026-04-04-scope-unit-tests.md | 138 ++++++++---------- packages/plugin-rsc/src/transforms/scope.ts | 12 +- 2 files changed, 64 insertions(+), 86 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md index 74de9ffdb..3e81dbada 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md @@ -3,8 +3,8 @@ ## Goal Extract the custom scope analysis from `hoist.ts` into `src/transforms/scope.ts` and add -a comprehensive `scope.test.ts` that tests `buildScopeTree` (and `getBindVars`) directly, -independent of the hoist transform. +a comprehensive `scope.test.ts` that tests `buildScopeTree` directly, independent of the +hoist transform. This is step 5 of the migration plan in `2026-04-04-hoist-variable-shadowing.md`. @@ -16,41 +16,48 @@ Done. `src/transforms/scope.ts` exists; `hoist.ts` imports from it. ### 2. File-based fixture tests in `scope.test.ts` -Inspired by `oxc_semantic`'s approach: each fixture is a JS input file paired with a -snapshot file that captures a human-readable visualization of the scope tree. +Modelled after `oxc_semantic`'s approach: fixture input files paired with snapshot files +capturing a human-readable visualization of the scope tree. -#### Directory layout +#### Fixture sources + +Two fixture directories: ``` -src/transforms/fixtures/scope/ - var-hoisting.js - var-hoisting.snap - shadowing-block.js - shadowing-block.snap - export-specifier.js - export-specifier.snap - ... +src/transforms/fixtures/scope/typescript-eslint/ ← copied from oxc_semantic's fixtures +src/transforms/fixtures/scope/ ← hand-crafted cases not covered above ``` -#### Test runner (auto-discovery) +**`typescript-eslint/`** is copied from: +`oxc/crates/oxc_semantic/tests/fixtures/typescript-eslint/` + +which in turn was copied from typescript-eslint's own scope-manager test suite. These +inputs are authoritative: written by people who know the spec, with variable names like +`unresolved` and `dontReference2` that encode the expected behavior in the code itself. + +Copy the whole directory (all 269 files). TypeScript files are transpiled to JS in the +test runner before being passed to `buildScopeTree` (see below). + +#### Test runner ```ts -import { readdirSync } from 'node:fs' -import path from 'node:path' +import { transformWithEsbuild } from 'vite' import { parseAstAsync } from 'vite' -import { expect, it } from 'vitest' -import { buildScopeTree } from './scope' -const fixtureDir = path.join(import.meta.dirname, 'fixtures/scope') - -for (const file of readdirSync(fixtureDir).filter((f) => f.endsWith('.js'))) { - it(file.replace('.js', ''), async () => { - const input = readFileSync(path.join(fixtureDir, file), 'utf-8') +// discover .js and .ts fixture files recursively +for (const file of globSync('**/*.{js,ts}', { cwd: fixtureDir })) { + it(file, async () => { + let input = readFileSync(path.join(fixtureDir, file), 'utf-8') + if (file.endsWith('.ts')) { + // strip TypeScript syntax; buildScopeTree only handles ESTree JS + const result = await transformWithEsbuild(input, file, { loader: 'ts' }) + input = result.code + } const ast = await parseAstAsync(input) const scopeTree = buildScopeTree(ast) const snapshot = serializeScopeTree(ast, scopeTree) await expect(snapshot).toMatchFileSnapshot( - path.join(fixtureDir, file.replace('.js', '.snap')), + path.join(fixtureDir, file + '.snap'), ) }) } @@ -58,16 +65,16 @@ for (const file of readdirSync(fixtureDir).filter((f) => f.endsWith('.js'))) { #### Snapshot format -Scope-tree-centric, analogous to `oxc_semantic`'s readable JSON. Each scope node lists -its declarations and the references resolved within it. References show the name and -which scope they resolve to (using a stable label derived from the scope-creating node). +Scope-tree-centric JSON. Each scope node lists its declarations and the direct +references resolved within it. References show the name and which scope they resolve +to via a stable path label (not numeric IDs). Example — `shadowing-block.js`: ```js function outer() { const value = 0 - async function action() { + function action() { if (true) { const value = 1 return value @@ -76,7 +83,7 @@ function outer() { } ``` -`shadowing-block.snap`: +`shadowing-block.js.snap`: ```json { @@ -86,29 +93,36 @@ function outer() { "children": [ { "type": "Function:outer", - "declarations": ["value"], + "declarations": [], "references": [], "children": [ { - "type": "Function:action", - "declarations": [], + "type": "BlockStatement", + "declarations": ["value"], "references": [], "children": [ { - "type": "BlockStatement", + "type": "Function:action", "declarations": [], "references": [], "children": [ { "type": "BlockStatement", - "declarations": ["value"], - "references": [ + "declarations": [], + "references": [], + "children": [ { - "name": "value", - "resolvedIn": "Function:action>BlockStatement>BlockStatement" + "type": "BlockStatement", + "declarations": ["value"], + "references": [ + { + "name": "value", + "resolvedIn": "Program > Function:outer > BlockStatement > Function:action > BlockStatement > BlockStatement" + } + ], + "children": [] } - ], - "children": [] + ] } ] } @@ -120,51 +134,15 @@ function outer() { } ``` -The `resolvedIn` label is a stable path string built from the scope-creating node types -(and function names where available), not from internal numeric IDs. - -Note: `getBindVars` is a `hoist.ts` concern and is not tested here. - -#### Test categories (fixture files to create) +The `resolvedIn` path is built from scope-creating node labels (function names where +available), disambiguated with `[2]` suffixes for same-type siblings. +`null` means the identifier is global (not declared anywhere in the file). -**Scope structure** +#### Hand-crafted fixtures (gaps not covered by typescript-eslint set) -- `module-scope.js` — module scope has no parent; top-level fn parent is moduleScope - -**Declaration placement** - -- `let-const-block.js` — `let`/`const` stays in block scope -- `var-hoisting.js` — `var` in nested block hoists to nearest function scope -- `var-nested-fn.js` — `var` in nested function stays in that fn, not outer -- `fn-decl-hoisting.js` — function declaration name hoists to enclosing fn scope -- `fn-expr-name.js` — function expression name (`function self(){}`) is in its own scope -- `destructured-params.js` — plain/rest/destructured params are in function scope -- `catch-param.js` — catch param is in catch scope -- `class-decl.js` — class declaration name in current scope - -**Reference resolution** - -- `ref-module-local.js` — ref to module-level `const` maps to moduleScope -- `ref-outer-fn.js` — ref to outer function's local maps to outer fn scope -- `ref-same-fn.js` — ref to same-function local maps to fn own scope -- `shadowing-block.js` — ref shadowed in nested block resolves to inner scope -- `ref-var-hoisted.js` — ref to `var` declared later in same fn maps to fn scope -- `ref-global.js` — ref to global (`console`) absent from `referenceToDeclaredScope` - -**`isBindingIdentifier` edge cases — highest priority** - -- `member-expr.js` — `obj.prop`: `prop` NOT a ref; `obj[expr]`: `expr` IS a ref -- `object-expr-vs-pattern.js` — `{key: val}` in expr vs `const {key: val} = obj` -- `computed-destructuring.js` — `const {[expr]: val} = obj`: `expr` IS a ref - `export-specifier.js` — `export {foo as bar}`: `foo` IS resolved, `bar` is NOT -- `import-specifier.js` — `import {foo as bar}`: `bar` is binding, `foo` is not a ref -- `method-definition.js` — non-computed method key NOT a ref; computed key IS -- `property-definition.js` — `class C { field = val }`: `field` NOT a ref, `val` IS - `label.js` — label in `break`/`continue` NOT a ref - -**`scopeToReferences` propagation** - -- `propagation.js` — function scope accumulates refs from nested blocks and inner fns +- `shadowing-block.js` — the motivating bug from the migration notes ### 3. Verify `hoist.test.ts` still passes after the extraction diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 0518776b1..8bb966f2c 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -38,17 +38,17 @@ export class Scope { export type ScopeTree = { // each reference Identifier → the Scope that declared it (absent = module-level/global) - readonly referenceToDeclaredScope: WeakMap + readonly referenceToDeclaredScope: Map // each function Scope → reference Identifiers accessed within its scope - readonly scopeToReferences: WeakMap + readonly scopeToReferences: Map // scope-creating AST node → its Scope (the only entry point from AST into Scope) - readonly nodeScope: WeakMap + readonly nodeScope: Map readonly moduleScope: Scope } export function buildScopeTree(ast: Program): ScopeTree { const moduleScope = new Scope(undefined, true) - const nodeScope = new WeakMap() + const nodeScope = new Map() // Inline resolution during the walk is wrong for `var`/function hoisting: a // reference that appears before its `var` declaration would resolve to an outer @@ -151,8 +151,8 @@ export function buildScopeTree(ast: Program): ScopeTree { }) // ── Post-walk fixup: resolve references against the complete scope tree ── - const scopeToReferences = new WeakMap() - const referenceToDeclaredScope = new WeakMap() + const scopeToReferences = new Map() + const referenceToDeclaredScope = new Map() for (const { id, visitScope } of rawReferences) { let declScope: Scope | undefined = visitScope From b3616689ef8f74984fae196dbb91bb9c1c1e1671 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 19:18:54 +0900 Subject: [PATCH 44/88] refactor: less slop --- .../plugin-rsc/src/transforms/scope.test.ts | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 8c63ee6c9..84dc176a0 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -1,6 +1,5 @@ import path from 'node:path' import type { Node, Program } from 'estree' -import { walk } from 'estree-walker' import { parseAstAsync } from 'vite' import { describe, expect, it } from 'vitest' import { type Scope, type ScopeTree, buildScopeTree } from './scope' @@ -36,52 +35,60 @@ function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { moduleScope, } = scopeTree + // TODO: class DefaultMap helper // Build scope → label and scope → direct children. // Labels are disambiguated per parent (e.g. BlockStatement[2] for the second sibling). - const scopeLabel = new Map() - const scopeChildren = new Map() + const scopeLabelMap = new Map() + const scopeChildrenMap = new Map() + const scopeNodeMap = new Map() const siblingCount = new Map>() - scopeLabel.set(moduleScope, 'Program') - scopeChildren.set(moduleScope, []) + scopeLabelMap.set(moduleScope, 'Program') + scopeChildrenMap.set(moduleScope, []) + scopeNodeMap.set(moduleScope, ast) - walk(ast as Node, { - enter(node) { - const scope = nodeScope.get(node) - if (!scope || scope === moduleScope) return + for (const [node, scope] of nodeScope.entries()) { + scopeNodeMap.set(scope, node) + const base = scopeNodeLabel(node) + if (!scope.parent) { + continue + } - const parent = scope.parent! - const base = scopeNodeLabel(node) + const parent = scope.parent - if (!siblingCount.has(parent)) siblingCount.set(parent, new Map()) - const counts = siblingCount.get(parent)! - const n = (counts.get(base) ?? 0) + 1 - counts.set(base, n) + if (!siblingCount.has(parent)) { + siblingCount.set(parent, new Map()) + } + const counts = siblingCount.get(parent)! + const n = (counts.get(base) ?? 0) + 1 + counts.set(base, n) - scopeLabel.set(scope, n === 1 ? base : `${base}[${n}]`) + scopeLabelMap.set(scope, n === 1 ? base : `${base}[${n}]`) + scopeNodeMap.set(scope, node) - if (!scopeChildren.has(parent)) scopeChildren.set(parent, []) - scopeChildren.get(parent)!.push(scope) - scopeChildren.set(scope, []) - }, - }) + if (!scopeChildrenMap.has(parent)) { + scopeChildrenMap.set(parent, []) + } + scopeChildrenMap.get(parent)!.push(scope) + scopeChildrenMap.set(scope, []) + } // Stable path string for a scope, used as the resolvedIn value. function fullPath(scope: Scope): string { const parts: string[] = [] let curr: Scope | undefined = scope while (curr) { - parts.unshift(scopeLabel.get(curr) ?? '?') + parts.unshift(scopeLabelMap.get(curr) ?? '?') curr = curr.parent } return parts.join(' > ') } // Direct references for a scope = all propagated refs minus those in child scopes. - function directRefs(scope: Scope) { + function directReferences(scope: Scope) { const allRefs = scopeToReferences.get(scope) ?? [] const childRefSet = new Set( - (scopeChildren.get(scope) ?? []).flatMap( + (scopeChildrenMap.get(scope) ?? []).flatMap( (c) => scopeToReferences.get(c) ?? [], ), ) @@ -89,9 +96,9 @@ function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { } function buildNode(scope: Scope): SerializedScope { - const refs = directRefs(scope) + const refs = directReferences(scope) return { - type: scopeLabel.get(scope)!, + type: scopeLabelMap.get(scope)!, declarations: [...scope.declarations].sort(), references: refs.map((id) => ({ name: id.name, @@ -99,7 +106,7 @@ function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { ? fullPath(referenceToDeclaredScope.get(id)!) : null, })), - children: (scopeChildren.get(scope) ?? []).map(buildNode), + children: (scopeChildrenMap.get(scope) ?? []).map(buildNode), } } From 114837aa9f7555079523759091da46aad75b1824 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 19:21:09 +0900 Subject: [PATCH 45/88] refactor: nit --- .../plugin-rsc/src/transforms/scope.test.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 84dc176a0..be8f516d5 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -1,5 +1,5 @@ import path from 'node:path' -import type { Node, Program } from 'estree' +import type { Node } from 'estree' import { parseAstAsync } from 'vite' import { describe, expect, it } from 'vitest' import { type Scope, type ScopeTree, buildScopeTree } from './scope' @@ -11,7 +11,7 @@ describe('fixtures', () => { const input = ((await mod()) as any).default as string const ast = await parseAstAsync(input) const scopeTree = buildScopeTree(ast) - const snapshot = serializeScopeTree(ast, scopeTree) + const snapshot = serializeScopeTree(scopeTree) await expect(snapshot).toMatchFileSnapshot(file + '.snap.json') }) } @@ -27,7 +27,7 @@ type SerializedScope = { children: SerializedScope[] } -function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { +function serializeScopeTree(scopeTree: ScopeTree): string { const { nodeScope, referenceToDeclaredScope, @@ -43,13 +43,13 @@ function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { const scopeNodeMap = new Map() const siblingCount = new Map>() - scopeLabelMap.set(moduleScope, 'Program') - scopeChildrenMap.set(moduleScope, []) - scopeNodeMap.set(moduleScope, ast) - for (const [node, scope] of nodeScope.entries()) { scopeNodeMap.set(scope, node) - const base = scopeNodeLabel(node) + scopeChildrenMap.set(scope, []) + + const base = toScopeNodeLabel(node) + scopeLabelMap.set(scope, base) + if (!scope.parent) { continue } @@ -70,7 +70,6 @@ function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { scopeChildrenMap.set(parent, []) } scopeChildrenMap.get(parent)!.push(scope) - scopeChildrenMap.set(scope, []) } // Stable path string for a scope, used as the resolvedIn value. @@ -113,7 +112,7 @@ function serializeScopeTree(ast: Program, scopeTree: ScopeTree): string { return JSON.stringify(buildNode(moduleScope), null, 2) } -function scopeNodeLabel(node: Node): string { +function toScopeNodeLabel(node: Node): string { switch (node.type) { case 'FunctionDeclaration': return `${node.type}:${node.id.name}` From 018eeb7b37943370172d475c8b7900df9fbcffc2 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 19:32:01 +0900 Subject: [PATCH 46/88] test: nit slop --- .../plugin-rsc/src/transforms/scope.test.ts | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index be8f516d5..450aa5a6d 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -1,5 +1,5 @@ import path from 'node:path' -import type { Node } from 'estree' +import type { Identifier, Node } from 'estree' import { parseAstAsync } from 'vite' import { describe, expect, it } from 'vitest' import { type Scope, type ScopeTree, buildScopeTree } from './scope' @@ -11,8 +11,10 @@ describe('fixtures', () => { const input = ((await mod()) as any).default as string const ast = await parseAstAsync(input) const scopeTree = buildScopeTree(ast) - const snapshot = serializeScopeTree(scopeTree) - await expect(snapshot).toMatchFileSnapshot(file + '.snap.json') + const serialized = serializeScopeTree(scopeTree) + await expect(JSON.stringify(serialized, null, 2)).toMatchFileSnapshot( + file + '.snap.json', + ) }) } }) @@ -27,7 +29,7 @@ type SerializedScope = { children: SerializedScope[] } -function serializeScopeTree(scopeTree: ScopeTree): string { +function serializeScopeTree(scopeTree: ScopeTree): SerializedScope { const { nodeScope, referenceToDeclaredScope, @@ -72,19 +74,8 @@ function serializeScopeTree(scopeTree: ScopeTree): string { scopeChildrenMap.get(parent)!.push(scope) } - // Stable path string for a scope, used as the resolvedIn value. - function fullPath(scope: Scope): string { - const parts: string[] = [] - let curr: Scope | undefined = scope - while (curr) { - parts.unshift(scopeLabelMap.get(curr) ?? '?') - curr = curr.parent - } - return parts.join(' > ') - } - // Direct references for a scope = all propagated refs minus those in child scopes. - function directReferences(scope: Scope) { + function getDirectReferences(scope: Scope) { const allRefs = scopeToReferences.get(scope) ?? [] const childRefSet = new Set( (scopeChildrenMap.get(scope) ?? []).flatMap( @@ -94,22 +85,30 @@ function serializeScopeTree(scopeTree: ScopeTree): string { return allRefs.filter((id) => !childRefSet.has(id)) } - function buildNode(scope: Scope): SerializedScope { - const refs = directReferences(scope) + function serializeReference(id: Identifier): string | null { + const declScope = referenceToDeclaredScope.get(id) + if (!declScope) { + return null + } + const paths = [declScope, ...declScope.getAncestorScopes()].reverse() + return paths.map((s) => scopeLabelMap.get(s)!).join(' > ') + } + + function serializeScope(scope: Scope): SerializedScope { return { type: scopeLabelMap.get(scope)!, declarations: [...scope.declarations].sort(), - references: refs.map((id) => ({ + references: getDirectReferences(scope).map((id) => ({ name: id.name, - resolvedIn: referenceToDeclaredScope.has(id) - ? fullPath(referenceToDeclaredScope.get(id)!) - : null, + resolvedIn: serializeReference(id), })), - children: (scopeChildrenMap.get(scope) ?? []).map(buildNode), + children: scopeChildrenMap + .get(scope)! + .map((child) => serializeScope(child)), } } - return JSON.stringify(buildNode(moduleScope), null, 2) + return serializeScope(moduleScope) } function toScopeNodeLabel(node: Node): string { From cb00f2a92b8ba6d4b72f755d9c76697b8efb8f16 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 19:38:29 +0900 Subject: [PATCH 47/88] refactor: nit slop --- .../plugin-rsc/src/transforms/scope.test.ts | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 450aa5a6d..2dd87c52b 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -19,7 +19,6 @@ describe('fixtures', () => { } }) -// TODO: review // ── Serializer ──────────────────────────────────────────────────────────────── type SerializedScope = { @@ -37,50 +36,36 @@ function serializeScopeTree(scopeTree: ScopeTree): SerializedScope { moduleScope, } = scopeTree - // TODO: class DefaultMap helper // Build scope → label and scope → direct children. // Labels are disambiguated per parent (e.g. BlockStatement[2] for the second sibling). const scopeLabelMap = new Map() - const scopeChildrenMap = new Map() - const scopeNodeMap = new Map() - const siblingCount = new Map>() + const scopeChildrenMap = new DefaultMap(() => []) + const siblingCount = new DefaultMap>( + () => new DefaultMap(() => 0), + ) for (const [node, scope] of nodeScope.entries()) { - scopeNodeMap.set(scope, node) - scopeChildrenMap.set(scope, []) - const base = toScopeNodeLabel(node) scopeLabelMap.set(scope, base) - + scopeChildrenMap.set(scope, []) if (!scope.parent) { continue } - const parent = scope.parent - - if (!siblingCount.has(parent)) { - siblingCount.set(parent, new Map()) - } - const counts = siblingCount.get(parent)! - const n = (counts.get(base) ?? 0) + 1 + const counts = siblingCount.get(parent) + const n = counts.get(base) + 1 counts.set(base, n) - scopeLabelMap.set(scope, n === 1 ? base : `${base}[${n}]`) - scopeNodeMap.set(scope, node) - - if (!scopeChildrenMap.has(parent)) { - scopeChildrenMap.set(parent, []) - } - scopeChildrenMap.get(parent)!.push(scope) + scopeChildrenMap.get(parent).push(scope) } // Direct references for a scope = all propagated refs minus those in child scopes. function getDirectReferences(scope: Scope) { const allRefs = scopeToReferences.get(scope) ?? [] const childRefSet = new Set( - (scopeChildrenMap.get(scope) ?? []).flatMap( - (c) => scopeToReferences.get(c) ?? [], - ), + scopeChildrenMap + .get(scope) + .flatMap((c) => scopeToReferences.get(c) ?? []), ) return allRefs.filter((id) => !childRefSet.has(id)) } @@ -123,3 +108,19 @@ function toScopeNodeLabel(node: Node): string { return node.type } } + +class DefaultMap extends Map { + constructor(private readonly init: (key: K) => V) { + super() + } + + override get(key: K): V { + let value = super.get(key) + if (value !== undefined) { + return value + } + value = this.init(key) + this.set(key, value) + return value + } +} From 1ce77841b2b381af8bc30131d5a53fedd5501354 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 19:46:06 +0900 Subject: [PATCH 48/88] chore: done TODO --- packages/plugin-rsc/src/transforms/scope.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 8bb966f2c..58f43140e 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -10,7 +10,6 @@ import type { import { walk } from 'estree-walker' import { extractNames } from './utils' -// TODO: unit test // Replacement for periscopic to correctly handle variable shadowing export class Scope { From b69dd9a852f18c1d3b1651aa721510dc16208438 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 20:01:19 +0900 Subject: [PATCH 49/88] docs(plugin-rsc): clarify extractIdentifiers intent Co-authored-by: Codex --- packages/plugin-rsc/src/transforms/utils.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/utils.ts b/packages/plugin-rsc/src/transforms/utils.ts index fe40c4cd9..7230d4a34 100644 --- a/packages/plugin-rsc/src/transforms/utils.ts +++ b/packages/plugin-rsc/src/transforms/utils.ts @@ -80,12 +80,24 @@ export function getExportNames( return { exportNames } } -// Copied from periscopic `extract_names` / `extract_identifiers` in `src/index.js`. +// Copied from periscopic `extract_names` / `extract_identifiers` export function extractNames(param: Pattern): string[] { return extractIdentifiers(param).map((n) => n.name) } -// TODO: review +// Copied from periscopic and intentionally broader than this repo's current +// declaration-oriented use cases. +// +// ESTree's `Pattern` type also covers assignment targets, where +// `MemberExpression` can appear (for example `({ x: obj.y } = value)`), so this +// helper preserves periscopic's behavior of reducing `a.b.c` to the base +// identifier `a`. +// +// In this repo, current callers use it only for declaration/binding positions +// (`VariableDeclarator.id`, function params, catch params), where +// `MemberExpression` should not appear for valid input. That branch is kept for +// compatibility with the original helper rather than because current +// declaration use cases require it. export function extractIdentifiers( param: Pattern, nodes: Identifier[] = [], From 07a17ed5bda85b6a87152c710cb2f8ced0446034 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 20:05:19 +0900 Subject: [PATCH 50/88] chore: nit slop comment --- packages/plugin-rsc/src/transforms/scope.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 58f43140e..3c6ee3c5e 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -36,11 +36,11 @@ export class Scope { } export type ScopeTree = { - // each reference Identifier → the Scope that declared it (absent = module-level/global) + // each reference Identifier → the Scope that declared it (absent = undeclared i.e. assume global) readonly referenceToDeclaredScope: Map // each function Scope → reference Identifiers accessed within its scope readonly scopeToReferences: Map - // scope-creating AST node → its Scope (the only entry point from AST into Scope) + // scope-creating AST node → its Scope readonly nodeScope: Map readonly moduleScope: Scope } From 8d93c97546ee63b6acf33074fde974a6fa749fde Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 20:29:00 +0900 Subject: [PATCH 51/88] chore: todo slop --- packages/plugin-rsc/src/transforms/scope.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 2dd87c52b..e0a421375 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -4,6 +4,10 @@ import { parseAstAsync } from 'vite' import { describe, expect, it } from 'vitest' import { type Scope, type ScopeTree, buildScopeTree } from './scope' +// TODO: +// - review fixture +// - reuse hoist.test.ts input + describe('fixtures', () => { const fixtures = import.meta.glob('./fixtures/scope/*.js', { query: 'raw' }) for (const [file, mod] of Object.entries(fixtures)) { From 21dbd43fd463047131984aa2520f429a8cc76826 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 20:58:41 +0900 Subject: [PATCH 52/88] feat(plugin-rsc): add scope fixture review helper Co-authored-by: Codex --- packages/plugin-rsc/package.json | 1 + .../scripts/review-scope-fixtures.mjs | 178 ++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 packages/plugin-rsc/scripts/review-scope-fixtures.mjs diff --git a/packages/plugin-rsc/package.json b/packages/plugin-rsc/package.json index e6bc6d189..6ca4b97bd 100644 --- a/packages/plugin-rsc/package.json +++ b/packages/plugin-rsc/package.json @@ -30,6 +30,7 @@ }, "scripts": { "test": "vitest", + "review-scope-fixtures": "node ./scripts/review-scope-fixtures.mjs", "test-e2e": "playwright test --project=chromium", "test-e2e-ci": "playwright test", "tsc": "tsc -b ./tsconfig.json ./e2e/tsconfig.json ./examples/*/tsconfig.json", diff --git a/packages/plugin-rsc/scripts/review-scope-fixtures.mjs b/packages/plugin-rsc/scripts/review-scope-fixtures.mjs new file mode 100644 index 000000000..1b60cade7 --- /dev/null +++ b/packages/plugin-rsc/scripts/review-scope-fixtures.mjs @@ -0,0 +1,178 @@ +import fs from 'node:fs' +import path from 'node:path' +import { parseArgs as parseNodeArgs } from 'node:util' + +const scriptDir = path.dirname(new URL(import.meta.url).pathname) +const packageDir = path.resolve(scriptDir, '..') +const fixtureDir = path.join(packageDir, 'src/transforms/fixtures/scope') + +main() + +function main() { + const { values, positionals } = parseNodeArgs({ + args: process.argv.slice(2), + allowPositionals: true, + options: { + output: { + type: 'string', + short: 'o', + }, + help: { + type: 'boolean', + short: 'h', + }, + }, + strict: true, + }) + + if (values.help) { + printHelp() + process.exit(0) + } + + const filters = positionals + const output = values.output + const fixtures = collectFixtures(fixtureDir, filters) + + if (fixtures.length === 0) { + const detail = + filters.length === 0 + ? 'No fixtures found.' + : `No fixtures matched: ${filters.join(', ')}` + console.error(detail) + process.exit(1) + } + + const markdown = renderMarkdown(fixtures, filters) + + if (output) { + fs.writeFileSync(output, markdown) + console.error(`Wrote ${fixtures.length} fixture review(s) to ${output}`) + } else { + process.stdout.write(markdown) + } +} + +function printHelp() { + console.log(`Usage: review-scope-fixtures [filters...] [options] + +Build a Markdown review packet for scope fixtures. + +Positional arguments: + filters Substring filters matched against relative path or basename + +Options: + -o, --output Write to a specific file + -h, --help Show this help + +Examples: + pnpm review:scope-fixtures | code - + pnpm review:scope-fixtures shadowing import | code - + pnpm review:scope-fixtures var-hoisting --output /tmp/scope-review.md +`) +} + +function fail(message) { + console.error(message) + process.exit(1) +} + +function collectFixtures(rootDir, filters) { + return walk(rootDir) + .filter((file) => file.endsWith('.js')) + .map((sourceFile) => { + const relativePath = path.relative(rootDir, sourceFile) + return { + sourceFile, + snapshotFile: sourceFile + '.snap.json', + relativePath, + fixtureName: path.basename(sourceFile, '.js'), + } + }) + .filter((entry) => matchesFilters(entry, filters)) + .map((entry) => { + if (!fs.existsSync(entry.snapshotFile)) { + fail( + `Missing snapshot for ${entry.relativePath}: ${path.relative(packageDir, entry.snapshotFile)}`, + ) + } + + const source = fs.readFileSync(entry.sourceFile, 'utf8').trimEnd() + const snapshot = formatJson(fs.readFileSync(entry.snapshotFile, 'utf8')) + return { ...entry, source, snapshot } + }) + .sort((a, b) => a.relativePath.localeCompare(b.relativePath)) +} + +function walk(dir) { + const entries = fs.readdirSync(dir, { withFileTypes: true }) + const files = [] + for (const entry of entries) { + const fullPath = path.join(dir, entry.name) + if (entry.isDirectory()) { + files.push(...walk(fullPath)) + } else if (entry.isFile()) { + files.push(fullPath) + } + } + return files +} + +function matchesFilters(entry, filters) { + if (filters.length === 0) { + return true + } + const haystacks = [entry.relativePath, entry.fixtureName].map((text) => + text.toLowerCase(), + ) + return filters.some((filter) => { + const needle = filter.toLowerCase() + return haystacks.some((text) => text.includes(needle)) + }) +} + +function formatJson(text) { + return JSON.stringify(JSON.parse(text), null, 2) +} + +function renderMarkdown(fixtures, filters) { + const lines = [ + '# Scope Fixture Review', + '', + `Generated: ${new Date().toISOString()}`, + '', + `Fixtures: ${fixtures.length}`, + ] + + if (filters.length > 0) { + lines.push(`Filters: ${filters.join(', ')}`) + } + + lines.push('', '## Contents', '') + + for (const fixture of fixtures) { + lines.push(`- \`${fixture.relativePath}\``) + } + + for (const fixture of fixtures) { + lines.push( + '', + `## ${fixture.relativePath}`, + '', + `Source: \`${path.relative(packageDir, fixture.sourceFile)}\``, + '', + '```js', + fixture.source, + '```', + '', + `Snapshot: \`${path.relative(packageDir, fixture.snapshotFile)}\``, + '', + '```json', + fixture.snapshot, + '```', + ) + } + + lines.push('') + return lines.join('\n') +} From 220b3f1e17581e72a644fc5a7a2bb4c36a6cdc8f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 21:03:43 +0900 Subject: [PATCH 53/88] refactor(plugin-rsc): rewrite scope review helper in ts Co-authored-by: Codex --- packages/plugin-rsc/package.json | 2 +- ...-fixtures.mjs => review-scope-fixtures.ts} | 53 ++++++++----------- 2 files changed, 24 insertions(+), 31 deletions(-) rename packages/plugin-rsc/scripts/{review-scope-fixtures.mjs => review-scope-fixtures.ts} (80%) diff --git a/packages/plugin-rsc/package.json b/packages/plugin-rsc/package.json index 6ca4b97bd..a47c41b1b 100644 --- a/packages/plugin-rsc/package.json +++ b/packages/plugin-rsc/package.json @@ -30,7 +30,7 @@ }, "scripts": { "test": "vitest", - "review-scope-fixtures": "node ./scripts/review-scope-fixtures.mjs", + "review-scope-fixtures": "node ./scripts/review-scope-fixtures.ts", "test-e2e": "playwright test --project=chromium", "test-e2e-ci": "playwright test", "tsc": "tsc -b ./tsconfig.json ./e2e/tsconfig.json ./examples/*/tsconfig.json", diff --git a/packages/plugin-rsc/scripts/review-scope-fixtures.mjs b/packages/plugin-rsc/scripts/review-scope-fixtures.ts similarity index 80% rename from packages/plugin-rsc/scripts/review-scope-fixtures.mjs rename to packages/plugin-rsc/scripts/review-scope-fixtures.ts index 1b60cade7..c05a3b5af 100644 --- a/packages/plugin-rsc/scripts/review-scope-fixtures.mjs +++ b/packages/plugin-rsc/scripts/review-scope-fixtures.ts @@ -2,13 +2,24 @@ import fs from 'node:fs' import path from 'node:path' import { parseArgs as parseNodeArgs } from 'node:util' +type Fixture = { + sourceFile: string + snapshotFile: string + relativePath: string + fixtureName: string + source: string + snapshot: string +} + +type FixtureEntry = Omit + const scriptDir = path.dirname(new URL(import.meta.url).pathname) const packageDir = path.resolve(scriptDir, '..') const fixtureDir = path.join(packageDir, 'src/transforms/fixtures/scope') main() -function main() { +function main(): void { const { values, positionals } = parseNodeArgs({ args: process.argv.slice(2), allowPositionals: true, @@ -53,7 +64,7 @@ function main() { } } -function printHelp() { +function printHelp(): void { console.log(`Usage: review-scope-fixtures [filters...] [options] Build a Markdown review packet for scope fixtures. @@ -72,16 +83,16 @@ Examples: `) } -function fail(message) { +function fail(message: string): never { console.error(message) process.exit(1) } -function collectFixtures(rootDir, filters) { - return walk(rootDir) - .filter((file) => file.endsWith('.js')) - .map((sourceFile) => { - const relativePath = path.relative(rootDir, sourceFile) +function collectFixtures(rootDir: string, filters: string[]): Fixture[] { + return fs + .globSync('*.js', { cwd: rootDir }) + .map((relativePath): FixtureEntry => { + const sourceFile = path.join(rootDir, relativePath) return { sourceFile, snapshotFile: sourceFile + '.snap.json', @@ -90,7 +101,7 @@ function collectFixtures(rootDir, filters) { } }) .filter((entry) => matchesFilters(entry, filters)) - .map((entry) => { + .map((entry): Fixture => { if (!fs.existsSync(entry.snapshotFile)) { fail( `Missing snapshot for ${entry.relativePath}: ${path.relative(packageDir, entry.snapshotFile)}`, @@ -98,27 +109,13 @@ function collectFixtures(rootDir, filters) { } const source = fs.readFileSync(entry.sourceFile, 'utf8').trimEnd() - const snapshot = formatJson(fs.readFileSync(entry.snapshotFile, 'utf8')) + const snapshot = fs.readFileSync(entry.snapshotFile, 'utf8') return { ...entry, source, snapshot } }) .sort((a, b) => a.relativePath.localeCompare(b.relativePath)) } -function walk(dir) { - const entries = fs.readdirSync(dir, { withFileTypes: true }) - const files = [] - for (const entry of entries) { - const fullPath = path.join(dir, entry.name) - if (entry.isDirectory()) { - files.push(...walk(fullPath)) - } else if (entry.isFile()) { - files.push(fullPath) - } - } - return files -} - -function matchesFilters(entry, filters) { +function matchesFilters(entry: FixtureEntry, filters: string[]): boolean { if (filters.length === 0) { return true } @@ -131,11 +128,7 @@ function matchesFilters(entry, filters) { }) } -function formatJson(text) { - return JSON.stringify(JSON.parse(text), null, 2) -} - -function renderMarkdown(fixtures, filters) { +function renderMarkdown(fixtures: Fixture[], filters: string[]): string { const lines = [ '# Scope Fixture Review', '', From 40807f5784bdaa3e1f3e7e6e4c150a2ff1860857 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 21:08:58 +0900 Subject: [PATCH 54/88] test: tweak SerializedScope --- .../fixtures/scope/catch-param.js.snap.json | 4 ++-- .../fixtures/scope/class-decl.js.snap.json | 2 +- .../scope/computed-destructuring.js.snap.json | 4 ++-- .../scope/destructured-params.js.snap.json | 12 +++++------ .../scope/export-specifier.js.snap.json | 2 +- .../scope/fn-decl-hoisting.js.snap.json | 2 +- .../fixtures/scope/fn-expr-name.js.snap.json | 2 +- .../scope/import-specifier.js.snap.json | 4 ++-- .../fixtures/scope/label.js.snap.json | 20 +++++++++---------- .../scope/let-const-block.js.snap.json | 4 ++-- .../fixtures/scope/member-expr.js.snap.json | 6 +++--- .../scope/method-definition.js.snap.json | 2 +- .../scope/object-expr-vs-pattern.js.snap.json | 8 ++++---- .../fixtures/scope/propagation.js.snap.json | 6 +++--- .../scope/property-definition.js.snap.json | 2 +- .../fixtures/scope/ref-global.js.snap.json | 2 +- .../fixtures/scope/ref-outer-fn.js.snap.json | 2 +- .../scope/shadowing-block.js.snap.json | 2 +- .../fixtures/scope/var-hoisting.js.snap.json | 2 +- .../fixtures/scope/var-nested-fn.js.snap.json | 2 +- .../plugin-rsc/src/transforms/scope.test.ts | 10 +++++----- 21 files changed, 50 insertions(+), 50 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json index 9ec85ac54..6409c0e8a 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json @@ -22,11 +22,11 @@ "references": [ { "name": "console", - "resolvedIn": null + "declaredAt": null }, { "name": "e", - "resolvedIn": "Program > CatchClause" + "declaredAt": "Program > CatchClause" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json index 06b7d51b2..cb3b9b22e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json @@ -7,7 +7,7 @@ "references": [ { "name": "Foo", - "resolvedIn": "Program" + "declaredAt": "Program" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json index 3a2338576..63db16795 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json @@ -8,11 +8,11 @@ "references": [ { "name": "key", - "resolvedIn": "Program" + "declaredAt": "Program" }, { "name": "obj", - "resolvedIn": "Program" + "declaredAt": "Program" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json index 8bc9562e4..22042bbb9 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json @@ -16,11 +16,11 @@ "references": [ { "name": "a", - "resolvedIn": "Program > FunctionDeclaration:f" + "declaredAt": "Program > FunctionDeclaration:f" }, { "name": "b", - "resolvedIn": null + "declaredAt": null } ], "children": [ @@ -30,19 +30,19 @@ "references": [ { "name": "a", - "resolvedIn": "Program > FunctionDeclaration:f" + "declaredAt": "Program > FunctionDeclaration:f" }, { "name": "c", - "resolvedIn": "Program > FunctionDeclaration:f" + "declaredAt": "Program > FunctionDeclaration:f" }, { "name": "d", - "resolvedIn": "Program > FunctionDeclaration:f" + "declaredAt": "Program > FunctionDeclaration:f" }, { "name": "rest", - "resolvedIn": "Program > FunctionDeclaration:f" + "declaredAt": "Program > FunctionDeclaration:f" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json index 0f3bbbaf2..ddba21d6e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json @@ -6,7 +6,7 @@ "references": [ { "name": "foo", - "resolvedIn": "Program" + "declaredAt": "Program" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json index e59ac434b..4f08eacd3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json @@ -18,7 +18,7 @@ "references": [ { "name": "foo", - "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement" } ], "children": [ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json index 85a649f51..71c232396 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json @@ -18,7 +18,7 @@ "references": [ { "name": "self", - "resolvedIn": "Program > FunctionExpression:self" + "declaredAt": "Program > FunctionExpression:self" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json index 6bde237a9..a8a593e63 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json @@ -6,11 +6,11 @@ "references": [ { "name": "foo", - "resolvedIn": null + "declaredAt": null }, { "name": "bar", - "resolvedIn": "Program" + "declaredAt": "Program" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json index 09c33bb00..9873ce793 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json @@ -4,7 +4,7 @@ "references": [ { "name": "outer", - "resolvedIn": null + "declaredAt": null } ], "children": [ @@ -16,11 +16,11 @@ "references": [ { "name": "i", - "resolvedIn": "Program > ForStatement" + "declaredAt": "Program > ForStatement" }, { "name": "i", - "resolvedIn": "Program > ForStatement" + "declaredAt": "Program > ForStatement" } ], "children": [ @@ -30,7 +30,7 @@ "references": [ { "name": "inner", - "resolvedIn": null + "declaredAt": null } ], "children": [ @@ -42,11 +42,11 @@ "references": [ { "name": "j", - "resolvedIn": "Program > ForStatement > BlockStatement > ForStatement" + "declaredAt": "Program > ForStatement > BlockStatement > ForStatement" }, { "name": "j", - "resolvedIn": "Program > ForStatement > BlockStatement > ForStatement" + "declaredAt": "Program > ForStatement > BlockStatement > ForStatement" } ], "children": [ @@ -56,19 +56,19 @@ "references": [ { "name": "j", - "resolvedIn": "Program > ForStatement > BlockStatement > ForStatement" + "declaredAt": "Program > ForStatement > BlockStatement > ForStatement" }, { "name": "outer", - "resolvedIn": null + "declaredAt": null }, { "name": "i", - "resolvedIn": "Program > ForStatement" + "declaredAt": "Program > ForStatement" }, { "name": "inner", - "resolvedIn": null + "declaredAt": null } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json index 6c90a858a..de01b6db5 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json @@ -24,11 +24,11 @@ "references": [ { "name": "x", - "resolvedIn": "Program > FunctionDeclaration:f > BlockStatement > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:f > BlockStatement > BlockStatement" }, { "name": "y", - "resolvedIn": "Program > FunctionDeclaration:f > BlockStatement > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:f > BlockStatement > BlockStatement" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json index 208b5c518..fed70643a 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json @@ -7,15 +7,15 @@ "references": [ { "name": "obj", - "resolvedIn": "Program" + "declaredAt": "Program" }, { "name": "obj", - "resolvedIn": "Program" + "declaredAt": "Program" }, { "name": "key", - "resolvedIn": "Program" + "declaredAt": "Program" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json index bbd760255..287c193a2 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json @@ -7,7 +7,7 @@ "references": [ { "name": "key", - "resolvedIn": "Program" + "declaredAt": "Program" } ], "children": [ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json index ebafad7b7..714003cc3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json @@ -9,19 +9,19 @@ "references": [ { "name": "key", - "resolvedIn": "Program" + "declaredAt": "Program" }, { "name": "val", - "resolvedIn": "Program" + "declaredAt": "Program" }, { "name": "key", - "resolvedIn": "Program" + "declaredAt": "Program" }, { "name": "obj", - "resolvedIn": "Program" + "declaredAt": "Program" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json index 0a2141bc5..c857df727 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json @@ -19,7 +19,7 @@ "references": [ { "name": "inner", - "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement" } ], "children": [ @@ -36,11 +36,11 @@ "references": [ { "name": "x", - "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement" }, { "name": "y", - "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:inner > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:inner > BlockStatement" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json index b80456a6f..53a1acdda 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json @@ -7,7 +7,7 @@ "references": [ { "name": "val", - "resolvedIn": "Program" + "declaredAt": "Program" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json index b8c341502..cc494f155 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json @@ -16,7 +16,7 @@ "references": [ { "name": "console", - "resolvedIn": null + "declaredAt": null } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json index dcdc29618..ae19a82d3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json @@ -29,7 +29,7 @@ "references": [ { "name": "value", - "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json index 54f0bbb2f..d19dcae30 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json @@ -36,7 +36,7 @@ "references": [ { "name": "value", - "resolvedIn": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:action > BlockStatement > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:action > BlockStatement > BlockStatement" } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json index 6f8ea46dd..de2d901b2 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json @@ -18,7 +18,7 @@ "references": [ { "name": "x", - "resolvedIn": "Program > FunctionDeclaration:f" + "declaredAt": "Program > FunctionDeclaration:f" } ], "children": [ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json index 9982b9aec..d809a7dd1 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json @@ -18,7 +18,7 @@ "references": [ { "name": "x", - "resolvedIn": null + "declaredAt": null } ], "children": [ diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index e0a421375..4c1b28450 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -28,7 +28,7 @@ describe('fixtures', () => { type SerializedScope = { type: string declarations: string[] - references: Array<{ name: string; resolvedIn: string | null }> + references: { name: string; declaredAt: string | null }[] children: SerializedScope[] } @@ -74,13 +74,13 @@ function serializeScopeTree(scopeTree: ScopeTree): SerializedScope { return allRefs.filter((id) => !childRefSet.has(id)) } - function serializeReference(id: Identifier): string | null { + function serializeDeclaredPath(id: Identifier): string | null { const declScope = referenceToDeclaredScope.get(id) if (!declScope) { return null } - const paths = [declScope, ...declScope.getAncestorScopes()].reverse() - return paths.map((s) => scopeLabelMap.get(s)!).join(' > ') + const scopes = [declScope, ...declScope.getAncestorScopes()].reverse() + return scopes.map((s) => scopeLabelMap.get(s)!).join(' > ') } function serializeScope(scope: Scope): SerializedScope { @@ -89,7 +89,7 @@ function serializeScopeTree(scopeTree: ScopeTree): SerializedScope { declarations: [...scope.declarations].sort(), references: getDirectReferences(scope).map((id) => ({ name: id.name, - resolvedIn: serializeReference(id), + declaredAt: serializeDeclaredPath(id), })), children: scopeChildrenMap .get(scope)! From 9a385740d9d4ecaf1f25badd3d67dcf4a822373f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 21:22:05 +0900 Subject: [PATCH 55/88] chore: todo --- packages/plugin-rsc/src/transforms/scope.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 4c1b28450..ca06dd935 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -6,6 +6,7 @@ import { type Scope, type ScopeTree, buildScopeTree } from './scope' // TODO: // - review fixture +// - use single markdown as snaphsot? (cf. review-scope-fixtures.ts) // - reuse hoist.test.ts input describe('fixtures', () => { From 6ea923a738f3cc6826b3246c4278d333f24187cf Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 21:33:58 +0900 Subject: [PATCH 56/88] wip: codex fixed something --- .../scope/destructured-params.js.snap.json | 11 +--------- .../scope/import-specifier.js.snap.json | 4 ---- .../fixtures/scope/label.js.snap.json | 22 ++----------------- .../scope/object-expr-vs-pattern.js.snap.json | 8 ------- .../fixtures/scope/object-shorthand.js | 2 ++ .../scope/object-shorthand.js.snap.json | 14 ++++++++++++ packages/plugin-rsc/src/transforms/scope.ts | 21 +++++++++++++----- 7 files changed, 35 insertions(+), 47 deletions(-) create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json index 22042bbb9..12b568764 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json @@ -13,16 +13,7 @@ "d", "rest" ], - "references": [ - { - "name": "a", - "declaredAt": "Program > FunctionDeclaration:f" - }, - { - "name": "b", - "declaredAt": null - } - ], + "references": [], "children": [ { "type": "BlockStatement", diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json index a8a593e63..72ee25f55 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json @@ -4,10 +4,6 @@ "bar" ], "references": [ - { - "name": "foo", - "declaredAt": null - }, { "name": "bar", "declaredAt": "Program" diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json index 9873ce793..e876dc887 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json @@ -1,12 +1,7 @@ { "type": "Program", "declarations": [], - "references": [ - { - "name": "outer", - "declaredAt": null - } - ], + "references": [], "children": [ { "type": "ForStatement", @@ -27,12 +22,7 @@ { "type": "BlockStatement", "declarations": [], - "references": [ - { - "name": "inner", - "declaredAt": null - } - ], + "references": [], "children": [ { "type": "ForStatement", @@ -58,17 +48,9 @@ "name": "j", "declaredAt": "Program > ForStatement > BlockStatement > ForStatement" }, - { - "name": "outer", - "declaredAt": null - }, { "name": "i", "declaredAt": "Program > ForStatement" - }, - { - "name": "inner", - "declaredAt": null } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json index 714003cc3..c93364fd0 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json @@ -7,18 +7,10 @@ "val" ], "references": [ - { - "name": "key", - "declaredAt": "Program" - }, { "name": "val", "declaredAt": "Program" }, - { - "name": "key", - "declaredAt": "Program" - }, { "name": "obj", "declaredAt": "Program" diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js b/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js new file mode 100644 index 000000000..7e93eefdb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js @@ -0,0 +1,2 @@ +const key = 1 +const obj = { key } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js.snap.json new file mode 100644 index 000000000..1b5ddbacc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js.snap.json @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "key", + "obj" + ], + "references": [ + { + "name": "key", + "declaredAt": "Program" + } + ], + "children": [] +} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 3c6ee3c5e..313e87344 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -62,6 +62,7 @@ export function buildScopeTree(ast: Program): ScopeTree { nodeScope.set(ast, moduleScope) const rawReferences: Array<{ id: Identifier; visitScope: Scope }> = [] + const seenReferences = new Set() const ancestors: Node[] = [] walk(ast, { @@ -131,12 +132,14 @@ export function buildScopeTree(ast: Program): ScopeTree { // the path key for binding instead of the bare name. if ( node.type === 'Identifier' && + !seenReferences.has(node) && !isBindingIdentifier( node, parent ?? undefined, ancestors[ancestors.length - 3], ) ) { + seenReferences.add(node) rawReferences.push({ id: node, visitScope: current }) } }, @@ -209,9 +212,17 @@ function isBindingIdentifier( case 'MemberExpression': return parent.property === node && !parent.computed case 'Property': - // The value is always the binding in destructuring (both computed and non-computed). - // The key is never a binding — in computed form `{ [expr]: b }` it is a reference. - return grandparent?.type === 'ObjectPattern' && parent.value === node + if (grandparent?.type === 'ObjectPattern') { + // In destructuring, the value side is always a binding pattern. + // Non-computed keys are syntax-only property names, while computed keys are references. + if (parent.value === node) return true + return parent.key === node && !parent.computed + } + if (grandparent?.type === 'ObjectExpression') { + // In object literals, non-computed keys are syntax-only property names. + return parent.key === node && !parent.computed + } + return false case 'FunctionDeclaration': case 'FunctionExpression': if (parent.id === node) return true @@ -239,9 +250,9 @@ function isBindingIdentifier( case 'LabeledStatement': case 'BreakStatement': case 'ContinueStatement': - return false + return true case 'ImportSpecifier': - return parent.imported !== node + return true case 'ImportDefaultSpecifier': case 'ImportNamespaceSpecifier': return true From e6d7f71ca70f67f463515773ed8efdd2c73b44b1 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 21:34:07 +0900 Subject: [PATCH 57/88] Revert "wip: codex fixed something" This reverts commit 6ea923a738f3cc6826b3246c4278d333f24187cf. --- .../scope/destructured-params.js.snap.json | 11 +++++++++- .../scope/import-specifier.js.snap.json | 4 ++++ .../fixtures/scope/label.js.snap.json | 22 +++++++++++++++++-- .../scope/object-expr-vs-pattern.js.snap.json | 8 +++++++ .../fixtures/scope/object-shorthand.js | 2 -- .../scope/object-shorthand.js.snap.json | 14 ------------ packages/plugin-rsc/src/transforms/scope.ts | 21 +++++------------- 7 files changed, 47 insertions(+), 35 deletions(-) delete mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js delete mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json index 12b568764..22042bbb9 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json @@ -13,7 +13,16 @@ "d", "rest" ], - "references": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionDeclaration:f" + }, + { + "name": "b", + "declaredAt": null + } + ], "children": [ { "type": "BlockStatement", diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json index 72ee25f55..a8a593e63 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json @@ -4,6 +4,10 @@ "bar" ], "references": [ + { + "name": "foo", + "declaredAt": null + }, { "name": "bar", "declaredAt": "Program" diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json index e876dc887..9873ce793 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json @@ -1,7 +1,12 @@ { "type": "Program", "declarations": [], - "references": [], + "references": [ + { + "name": "outer", + "declaredAt": null + } + ], "children": [ { "type": "ForStatement", @@ -22,7 +27,12 @@ { "type": "BlockStatement", "declarations": [], - "references": [], + "references": [ + { + "name": "inner", + "declaredAt": null + } + ], "children": [ { "type": "ForStatement", @@ -48,9 +58,17 @@ "name": "j", "declaredAt": "Program > ForStatement > BlockStatement > ForStatement" }, + { + "name": "outer", + "declaredAt": null + }, { "name": "i", "declaredAt": "Program > ForStatement" + }, + { + "name": "inner", + "declaredAt": null } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json index c93364fd0..714003cc3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json @@ -7,10 +7,18 @@ "val" ], "references": [ + { + "name": "key", + "declaredAt": "Program" + }, { "name": "val", "declaredAt": "Program" }, + { + "name": "key", + "declaredAt": "Program" + }, { "name": "obj", "declaredAt": "Program" diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js b/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js deleted file mode 100644 index 7e93eefdb..000000000 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js +++ /dev/null @@ -1,2 +0,0 @@ -const key = 1 -const obj = { key } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js.snap.json deleted file mode 100644 index 1b5ddbacc..000000000 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/object-shorthand.js.snap.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "Program", - "declarations": [ - "key", - "obj" - ], - "references": [ - { - "name": "key", - "declaredAt": "Program" - } - ], - "children": [] -} \ No newline at end of file diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 313e87344..3c6ee3c5e 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -62,7 +62,6 @@ export function buildScopeTree(ast: Program): ScopeTree { nodeScope.set(ast, moduleScope) const rawReferences: Array<{ id: Identifier; visitScope: Scope }> = [] - const seenReferences = new Set() const ancestors: Node[] = [] walk(ast, { @@ -132,14 +131,12 @@ export function buildScopeTree(ast: Program): ScopeTree { // the path key for binding instead of the bare name. if ( node.type === 'Identifier' && - !seenReferences.has(node) && !isBindingIdentifier( node, parent ?? undefined, ancestors[ancestors.length - 3], ) ) { - seenReferences.add(node) rawReferences.push({ id: node, visitScope: current }) } }, @@ -212,17 +209,9 @@ function isBindingIdentifier( case 'MemberExpression': return parent.property === node && !parent.computed case 'Property': - if (grandparent?.type === 'ObjectPattern') { - // In destructuring, the value side is always a binding pattern. - // Non-computed keys are syntax-only property names, while computed keys are references. - if (parent.value === node) return true - return parent.key === node && !parent.computed - } - if (grandparent?.type === 'ObjectExpression') { - // In object literals, non-computed keys are syntax-only property names. - return parent.key === node && !parent.computed - } - return false + // The value is always the binding in destructuring (both computed and non-computed). + // The key is never a binding — in computed form `{ [expr]: b }` it is a reference. + return grandparent?.type === 'ObjectPattern' && parent.value === node case 'FunctionDeclaration': case 'FunctionExpression': if (parent.id === node) return true @@ -250,9 +239,9 @@ function isBindingIdentifier( case 'LabeledStatement': case 'BreakStatement': case 'ContinueStatement': - return true + return false case 'ImportSpecifier': - return true + return parent.imported !== node case 'ImportDefaultSpecifier': case 'ImportNamespaceSpecifier': return true From 2aa5b1b57fc4831af55bda4742248fa707fe0633 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 21:50:12 +0900 Subject: [PATCH 58/88] fix: port isReferenceIdentifier from vite ssr transform --- .../scope/destructured-params.js.snap.json | 6 +- .../scope/import-specifier.js.snap.json | 4 +- .../fixtures/scope/label.js.snap.json | 22 +-- .../scope/object-expr-vs-pattern.js.snap.json | 8 - packages/plugin-rsc/src/transforms/scope.ts | 146 ++++++++++++------ 5 files changed, 100 insertions(+), 86 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json index 22042bbb9..08b8f79d6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json @@ -15,12 +15,8 @@ ], "references": [ { - "name": "a", + "name": "rest", "declaredAt": "Program > FunctionDeclaration:f" - }, - { - "name": "b", - "declaredAt": null } ], "children": [ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json index a8a593e63..39d0b630c 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json @@ -5,8 +5,8 @@ ], "references": [ { - "name": "foo", - "declaredAt": null + "name": "bar", + "declaredAt": "Program" }, { "name": "bar", diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json index 9873ce793..e876dc887 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json @@ -1,12 +1,7 @@ { "type": "Program", "declarations": [], - "references": [ - { - "name": "outer", - "declaredAt": null - } - ], + "references": [], "children": [ { "type": "ForStatement", @@ -27,12 +22,7 @@ { "type": "BlockStatement", "declarations": [], - "references": [ - { - "name": "inner", - "declaredAt": null - } - ], + "references": [], "children": [ { "type": "ForStatement", @@ -58,17 +48,9 @@ "name": "j", "declaredAt": "Program > ForStatement > BlockStatement > ForStatement" }, - { - "name": "outer", - "declaredAt": null - }, { "name": "i", "declaredAt": "Program > ForStatement" - }, - { - "name": "inner", - "declaredAt": null } ], "children": [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json index 714003cc3..c93364fd0 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json @@ -7,18 +7,10 @@ "val" ], "references": [ - { - "name": "key", - "declaredAt": "Program" - }, { "name": "val", "declaredAt": "Program" }, - { - "name": "key", - "declaredAt": "Program" - }, { "name": "obj", "declaredAt": "Program" diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 3c6ee3c5e..b0f40bd9c 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -131,7 +131,7 @@ export function buildScopeTree(ast: Program): ScopeTree { // the path key for binding instead of the bare name. if ( node.type === 'Identifier' && - !isBindingIdentifier( + isReferenceIdentifier( node, parent ?? undefined, ancestors[ancestors.length - 3], @@ -193,63 +193,107 @@ function isFunctionNode(node: Node): node is AnyFunctionNode { ) } -// TODO: review -// Binding-position check aligned with oxc-walker's `isBindingIdentifier` in -// `src/scope-tracker.ts`, with ESTree-specific handling for `ExportSpecifier` -// because only `local` is a reference there. -function isBindingIdentifier( +// Positive reference classifier modeled after Vite SSR's `isRefIdentifier`, +// adapted for this ESTree-only scope walk. This is easier to audit than a +// negated binding check because many identifier positions are syntax-only names +// rather than bindings or references. +function isReferenceIdentifier( node: Identifier, parent?: Node, grandparent?: Node, ): boolean { - if (!parent) return false - switch (parent.type) { - case 'VariableDeclarator': - return patternContainsIdentifier(parent.id, node) - case 'MemberExpression': - return parent.property === node && !parent.computed - case 'Property': - // The value is always the binding in destructuring (both computed and non-computed). - // The key is never a binding — in computed form `{ [expr]: b }` it is a reference. - return grandparent?.type === 'ObjectPattern' && parent.value === node - case 'FunctionDeclaration': - case 'FunctionExpression': - if (parent.id === node) return true - return parent.params.some((param) => - patternContainsIdentifier(param, node), - ) - case 'ArrowFunctionExpression': - return parent.params.some((param) => - patternContainsIdentifier(param, node), - ) - case 'ClassDeclaration': - case 'ClassExpression': - return parent.id === node - case 'MethodDefinition': - case 'PropertyDefinition': - return parent.key === node && !parent.computed - case 'CatchClause': - return !!parent.param && patternContainsIdentifier(parent.param, node) - case 'AssignmentPattern': - return patternContainsIdentifier(parent.left, node) - case 'RestElement': - return patternContainsIdentifier(parent.argument, node) - case 'ArrayPattern': - return true - case 'LabeledStatement': - case 'BreakStatement': - case 'ContinueStatement': + if (!parent) return true + + // declaration id + if ( + parent.type === 'CatchClause' || + ((parent.type === 'VariableDeclarator' || + parent.type === 'ClassDeclaration' || + parent.type === 'ClassExpression') && + parent.id === node) + ) { + return false + } + + if (isFunctionNode(parent)) { + // function declaration/expression id + if ('id' in parent && parent.id === node) { return false - case 'ImportSpecifier': - return parent.imported !== node - case 'ImportDefaultSpecifier': - case 'ImportNamespaceSpecifier': - return true - case 'ExportSpecifier': - return parent.local !== node - default: + } + // params list + if (parent.params.some((param) => patternContainsIdentifier(param, node))) { return false + } + } + + // class method / class field name + if ( + (parent.type === 'MethodDefinition' || + parent.type === 'PropertyDefinition') && + parent.key === node && + !parent.computed + ) { + return false + } + + // property key + if (isStaticPropertyKey(node, parent)) { + return false + } + + // Unlike Vite SSR, this walk does not pre-mark pattern nodes in a WeakSet, + // so we use the ESTree grandparent shape directly to recognize object patterns. + // object destructuring pattern + if ( + parent.type === 'Property' && + grandparent?.type === 'ObjectPattern' && + parent.value === node + ) { + return false + } + + // non-assignment array destructuring pattern + if (parent.type === 'ArrayPattern') { + return false + } + + // member expression property + if ( + parent.type === 'MemberExpression' && + parent.property === node && + !parent.computed + ) { + return false } + + // Unlike Vite SSR, this walk does not skip ImportDeclaration up front, so + // import specifier syntax has to be filtered here as well. + // import/export specifier syntax names + if ( + parent.type === 'ImportSpecifier' || + parent.type === 'ImportDefaultSpecifier' || + parent.type === 'ImportNamespaceSpecifier' || + parent.type === 'ExportSpecifier' + ) { + return parent.local === node + } + + // Explicitly handled here because these labels showed up as false positives in + // the scope fixtures; Vite SSR's helper does not need this branch. + // label identifiers + if ( + parent.type === 'LabeledStatement' || + parent.type === 'BreakStatement' || + parent.type === 'ContinueStatement' + ) { + return false + } + + return true +} + +function isStaticPropertyKey(node: Node, parent?: Node): boolean { + return parent?.type === 'Property' && parent.key === node && !parent.computed } function patternContainsIdentifier(pattern: Pattern, target: Node): boolean { From 81264c716ff2c5221d1b4009454092e77ac58969 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 21:55:01 +0900 Subject: [PATCH 59/88] chore: todo --- packages/plugin-rsc/src/transforms/scope.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index b0f40bd9c..f7fd92a11 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -193,6 +193,7 @@ function isFunctionNode(node: Node): node is AnyFunctionNode { ) } +// TODO: review slop // Positive reference classifier modeled after Vite SSR's `isRefIdentifier`, // adapted for this ESTree-only scope walk. This is easier to audit than a // negated binding check because many identifier positions are syntax-only names From d1a79cea1ee0c791a204c9d93f2ce215235a766b Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 21:59:33 +0900 Subject: [PATCH 60/88] fix: fix rest arguments as reference --- .../fixtures/scope/destructured-params.js.snap.json | 7 +------ packages/plugin-rsc/src/transforms/scope.ts | 7 +++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json index 08b8f79d6..12b568764 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json @@ -13,12 +13,7 @@ "d", "rest" ], - "references": [ - { - "name": "rest", - "declaredAt": "Program > FunctionDeclaration:f" - } - ], + "references": [], "children": [ { "type": "BlockStatement", diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index f7fd92a11..1032d65fd 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -258,6 +258,13 @@ function isReferenceIdentifier( return false } + // Unlike Vite SSR, this walk sees rest-pattern identifiers directly here, so + // the binding position must be filtered in the classifier. + // rest element binding + if (parent.type === 'RestElement' && parent.argument === node) { + return false + } + // member expression property if ( parent.type === 'MemberExpression' && From f071db6938ed9aca5a6445dd60f8be1f6d8a3e64 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:00:17 +0900 Subject: [PATCH 61/88] test: ensure new line in snapshot --- .../src/transforms/fixtures/scope/catch-param.js.snap.json | 2 +- .../src/transforms/fixtures/scope/class-decl.js.snap.json | 2 +- .../fixtures/scope/computed-destructuring.js.snap.json | 2 +- .../fixtures/scope/destructured-params.js.snap.json | 2 +- .../transforms/fixtures/scope/export-specifier.js.snap.json | 2 +- .../transforms/fixtures/scope/fn-decl-hoisting.js.snap.json | 2 +- .../src/transforms/fixtures/scope/fn-expr-name.js.snap.json | 2 +- .../transforms/fixtures/scope/import-specifier.js.snap.json | 2 +- .../src/transforms/fixtures/scope/label.js.snap.json | 2 +- .../transforms/fixtures/scope/let-const-block.js.snap.json | 2 +- .../src/transforms/fixtures/scope/member-expr.js.snap.json | 2 +- .../fixtures/scope/method-definition.js.snap.json | 2 +- .../fixtures/scope/object-expr-vs-pattern.js.snap.json | 2 +- .../src/transforms/fixtures/scope/propagation.js.snap.json | 2 +- .../fixtures/scope/property-definition.js.snap.json | 2 +- .../src/transforms/fixtures/scope/ref-global.js.snap.json | 2 +- .../src/transforms/fixtures/scope/ref-outer-fn.js.snap.json | 2 +- .../transforms/fixtures/scope/shadowing-block.js.snap.json | 2 +- .../src/transforms/fixtures/scope/var-hoisting.js.snap.json | 2 +- .../transforms/fixtures/scope/var-nested-fn.js.snap.json | 2 +- packages/plugin-rsc/src/transforms/scope.test.ts | 6 +++--- 21 files changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json index 6409c0e8a..a58d08a13 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/catch-param.js.snap.json @@ -34,4 +34,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json index cb3b9b22e..798c85ce9 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl.js.snap.json @@ -11,4 +11,4 @@ } ], "children": [] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json index 63db16795..18cd0b69e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/computed-destructuring.js.snap.json @@ -16,4 +16,4 @@ } ], "children": [] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json index 12b568764..e34d07b8e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructured-params.js.snap.json @@ -41,4 +41,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json index ddba21d6e..e4bbd8673 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/export-specifier.js.snap.json @@ -10,4 +10,4 @@ } ], "children": [] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json index 4f08eacd3..667a14bc1 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-decl-hoisting.js.snap.json @@ -40,4 +40,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json index 71c232396..6e838ea96 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/fn-expr-name.js.snap.json @@ -26,4 +26,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json index 39d0b630c..5b3671752 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json @@ -14,4 +14,4 @@ } ], "children": [] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json index e876dc887..adc010776 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/label.js.snap.json @@ -62,4 +62,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json index de01b6db5..c0530f4ce 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/let-const-block.js.snap.json @@ -38,4 +38,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json index fed70643a..d58dbdba8 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/member-expr.js.snap.json @@ -19,4 +19,4 @@ } ], "children": [] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json index 287c193a2..6d8c24331 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/method-definition.js.snap.json @@ -38,4 +38,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json index c93364fd0..1c3ba48cd 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/object-expr-vs-pattern.js.snap.json @@ -17,4 +17,4 @@ } ], "children": [] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json index c857df727..6d50446cf 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/propagation.js.snap.json @@ -52,4 +52,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json index 53a1acdda..5502e65c2 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/property-definition.js.snap.json @@ -11,4 +11,4 @@ } ], "children": [] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json index cc494f155..4cb25fec3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-global.js.snap.json @@ -24,4 +24,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json index ae19a82d3..987de0275 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/ref-outer-fn.js.snap.json @@ -41,4 +41,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json index d19dcae30..f87118215 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/shadowing-block.js.snap.json @@ -50,4 +50,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json index de2d901b2..82deff7b3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-hoisting.js.snap.json @@ -33,4 +33,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json index d809a7dd1..97ea5e090 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/var-nested-fn.js.snap.json @@ -42,4 +42,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index ca06dd935..759f3ecc5 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -17,9 +17,9 @@ describe('fixtures', () => { const ast = await parseAstAsync(input) const scopeTree = buildScopeTree(ast) const serialized = serializeScopeTree(scopeTree) - await expect(JSON.stringify(serialized, null, 2)).toMatchFileSnapshot( - file + '.snap.json', - ) + await expect( + JSON.stringify(serialized, null, 2) + '\n', + ).toMatchFileSnapshot(file + '.snap.json') }) } }) From f0eef778cba8495db68877a4e00b4cc951d1cc23 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:04:47 +0900 Subject: [PATCH 62/88] fix: fix import specifier as reference --- .../fixtures/scope/import-specifier.js.snap.json | 4 ---- packages/plugin-rsc/src/transforms/scope.ts | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json index 5b3671752..0dd886823 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-specifier.js.snap.json @@ -4,10 +4,6 @@ "bar" ], "references": [ - { - "name": "bar", - "declaredAt": "Program" - }, { "name": "bar", "declaredAt": "Program" diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 1032d65fd..af4c80d66 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -280,9 +280,12 @@ function isReferenceIdentifier( if ( parent.type === 'ImportSpecifier' || parent.type === 'ImportDefaultSpecifier' || - parent.type === 'ImportNamespaceSpecifier' || - parent.type === 'ExportSpecifier' + parent.type === 'ImportNamespaceSpecifier' ) { + return false + } + + if (parent.type === 'ExportSpecifier') { return parent.local === node } From ec94642979cbcc3edba348c2f518dfdf49bdf0ee Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:10:05 +0900 Subject: [PATCH 63/88] chore: todo --- packages/plugin-rsc/src/transforms/scope.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 759f3ecc5..95bf563af 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -5,9 +5,7 @@ import { describe, expect, it } from 'vitest' import { type Scope, type ScopeTree, buildScopeTree } from './scope' // TODO: -// - review fixture -// - use single markdown as snaphsot? (cf. review-scope-fixtures.ts) -// - reuse hoist.test.ts input +// - use single markdown as snaphsot? (cf. review-scope-fixtures.ts) describe('fixtures', () => { const fixtures = import.meta.glob('./fixtures/scope/*.js', { query: 'raw' }) From f9ea9309408e95b92cd79320fa7b8ea69f486fc4 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:24:20 +0900 Subject: [PATCH 64/88] test(plugin-rsc): extend scope assignment coverage Co-authored-by: Codex --- .../scope/array-destructuring-assignment.js | 3 + ...rray-destructuring-assignment.js.snap.json | 18 +++++ .../src/transforms/fixtures/scope/assign.js | 2 + .../fixtures/scope/assign.js.snap.json | 13 ++++ .../scope/destructuring-assignment.js | 3 + .../destructuring-assignment.js.snap.json | 18 +++++ .../fixtures/scope/param-defaults.js | 3 + .../scope/param-defaults.js.snap.json | 39 +++++++++++ .../plugin-rsc/src/transforms/hoist.test.ts | 68 ++++++++++++++++++- packages/plugin-rsc/src/transforms/scope.ts | 31 ++++++--- 10 files changed, 187 insertions(+), 11 deletions(-) create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/array-destructuring-assignment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/array-destructuring-assignment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/assign.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/assign.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/destructuring-assignment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/destructuring-assignment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/param-defaults.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/param-defaults.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/array-destructuring-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/array-destructuring-assignment.js new file mode 100644 index 000000000..d387220d9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/array-destructuring-assignment.js @@ -0,0 +1,3 @@ +let a +const arr = [] +;[a] = arr diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/array-destructuring-assignment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/array-destructuring-assignment.js.snap.json new file mode 100644 index 000000000..b6f755dad --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/array-destructuring-assignment.js.snap.json @@ -0,0 +1,18 @@ +{ + "type": "Program", + "declarations": [ + "a", + "arr" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + }, + { + "name": "arr", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/assign.js b/packages/plugin-rsc/src/transforms/fixtures/scope/assign.js new file mode 100644 index 000000000..d738e537e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/assign.js @@ -0,0 +1,2 @@ +let a = 0 +a = 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/assign.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/assign.js.snap.json new file mode 100644 index 000000000..942fe4195 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/assign.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "a" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructuring-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/destructuring-assignment.js new file mode 100644 index 000000000..6a6d64a19 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructuring-assignment.js @@ -0,0 +1,3 @@ +let bound +const obj = {} +;({ key: bound } = obj) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/destructuring-assignment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/destructuring-assignment.js.snap.json new file mode 100644 index 000000000..1ead3baee --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/destructuring-assignment.js.snap.json @@ -0,0 +1,18 @@ +{ + "type": "Program", + "declarations": [ + "bound", + "obj" + ], + "references": [ + { + "name": "bound", + "declaredAt": "Program" + }, + { + "name": "obj", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/param-defaults.js b/packages/plugin-rsc/src/transforms/fixtures/scope/param-defaults.js new file mode 100644 index 000000000..371b92f7b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/param-defaults.js @@ -0,0 +1,3 @@ +function f(a = ext, b = a) { + return b +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/param-defaults.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/param-defaults.js.snap.json new file mode 100644 index 000000000..1421a7b34 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/param-defaults.js.snap.json @@ -0,0 +1,39 @@ +{ + "type": "Program", + "declarations": [ + "f" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:f", + "declarations": [ + "a", + "b" + ], + "references": [ + { + "name": "ext", + "declaredAt": null + }, + { + "name": "a", + "declaredAt": "Program > FunctionDeclaration:f" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "b", + "declaredAt": "Program > FunctionDeclaration:f" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/hoist.test.ts b/packages/plugin-rsc/src/transforms/hoist.test.ts index ede56fb1f..2fac98e43 100644 --- a/packages/plugin-rsc/src/transforms/hoist.test.ts +++ b/packages/plugin-rsc/src/transforms/hoist.test.ts @@ -875,7 +875,7 @@ function outer() { `) }) - // TODO: does next support this? + // TODO: check next.js it('recursion', async () => { const input = `\ function outer() { @@ -931,4 +931,70 @@ function outer() { " `) }) + + // TODO: check next.js + it('assignment', async () => { + const input = ` +function Counter() { + let local = 0; + + async function updateLocal() { + "use server"; + local = 1; + } + + return "something"; +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + " + function Counter() { + let local = 0; + + const updateLocal = /* #__PURE__ */ $$register($$hoist_0_updateLocal, "", "$$hoist_0_updateLocal").bind(null, local); + + return "something"; + } + + ;export async function $$hoist_0_updateLocal(local) { + "use server"; + local = 1; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_updateLocal, "name", { value: "updateLocal" }); + " + `) + }) + + // TODO + it('increment', async () => { + const input = ` +function Counter() { + let local = 0; + + async function updateLocal() { + "use server"; + local++; + } + + return "something"; +} +` + expect(await testTransform(input)).toMatchInlineSnapshot(` + " + function Counter() { + let local = 0; + + const updateLocal = /* #__PURE__ */ $$register($$hoist_0_updateLocal, "", "$$hoist_0_updateLocal").bind(null, local); + + return "something"; + } + + ;export async function $$hoist_0_updateLocal(local) { + "use server"; + local++; + }; + /* #__PURE__ */ Object.defineProperty($$hoist_0_updateLocal, "name", { value: "updateLocal" }); + " + `) + }) }) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index af4c80d66..f54cb1d4d 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -134,7 +134,7 @@ export function buildScopeTree(ast: Program): ScopeTree { isReferenceIdentifier( node, parent ?? undefined, - ancestors[ancestors.length - 3], + ancestors.slice(0, -1).reverse(), ) ) { rawReferences.push({ id: node, visitScope: current }) @@ -201,9 +201,10 @@ function isFunctionNode(node: Node): node is AnyFunctionNode { function isReferenceIdentifier( node: Identifier, parent?: Node, - grandparent?: Node, + parentStack: Node[] = [], ): boolean { if (!parent) return true + const grandparent = parentStack[1] // declaration id if ( @@ -243,26 +244,32 @@ function isReferenceIdentifier( } // Unlike Vite SSR, this walk does not pre-mark pattern nodes in a WeakSet, - // so we use the ESTree grandparent shape directly to recognize object patterns. + // so we use the ESTree parent stack directly to recognize object patterns. // object destructuring pattern if ( parent.type === 'Property' && grandparent?.type === 'ObjectPattern' && parent.value === node ) { - return false + return isInDestructuringAssignment(parentStack) } - // non-assignment array destructuring pattern + // array destructuring pattern if (parent.type === 'ArrayPattern') { - return false + return isInDestructuringAssignment(parentStack) } - // Unlike Vite SSR, this walk sees rest-pattern identifiers directly here, so - // the binding position must be filtered in the classifier. - // rest element binding + // Unlike Vite SSR, this walk sees rest-pattern identifiers directly here. + // Treat rest targets like other destructuring-assignment targets for consistency + // with plain assignment targets. if (parent.type === 'RestElement' && parent.argument === node) { - return false + return isInDestructuringAssignment(parentStack) + } + + // parameter / pattern defaults bind on the left, but destructuring assignment + // targets are treated as references to stay coherent with plain assignment. + if (parent.type === 'AssignmentPattern' && parent.left === node) { + return isInDestructuringAssignment(parentStack) } // member expression property @@ -307,6 +314,10 @@ function isStaticPropertyKey(node: Node, parent?: Node): boolean { return parent?.type === 'Property' && parent.key === node && !parent.computed } +function isInDestructuringAssignment(parentStack: Node[]): boolean { + return parentStack.some((node) => node.type === 'AssignmentExpression') +} + function patternContainsIdentifier(pattern: Pattern, target: Node): boolean { switch (pattern.type) { case 'Identifier': From e97a20ec20273a1a6978fbd550a970f3810fb5bf Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:29:07 +0900 Subject: [PATCH 65/88] chore: this is slop --- packages/plugin-rsc/package.json | 1 + .../scripts/extract-hoist-scope-fixtures.ts | 149 ++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 packages/plugin-rsc/scripts/extract-hoist-scope-fixtures.ts diff --git a/packages/plugin-rsc/package.json b/packages/plugin-rsc/package.json index a47c41b1b..a04ff596c 100644 --- a/packages/plugin-rsc/package.json +++ b/packages/plugin-rsc/package.json @@ -30,6 +30,7 @@ }, "scripts": { "test": "vitest", + "extract-hoist-scope-fixtures": "node ./scripts/extract-hoist-scope-fixtures.ts", "review-scope-fixtures": "node ./scripts/review-scope-fixtures.ts", "test-e2e": "playwright test --project=chromium", "test-e2e-ci": "playwright test", diff --git a/packages/plugin-rsc/scripts/extract-hoist-scope-fixtures.ts b/packages/plugin-rsc/scripts/extract-hoist-scope-fixtures.ts new file mode 100644 index 000000000..1d5cd03ba --- /dev/null +++ b/packages/plugin-rsc/scripts/extract-hoist-scope-fixtures.ts @@ -0,0 +1,149 @@ +import fs from 'node:fs' +import path from 'node:path' +import { parseArgs as parseNodeArgs } from 'node:util' + +const scriptDir = path.dirname(new URL(import.meta.url).pathname) +const packageDir = path.resolve(scriptDir, '..') +const defaultInputFile = path.join(packageDir, 'src/transforms/hoist.test.ts') +const defaultOutputDir = path.join(packageDir, 'src/transforms/fixtures/scope') + +main() + +function main(): void { + const { values } = parseNodeArgs({ + args: process.argv.slice(2), + options: { + input: { + type: 'string', + short: 'i', + }, + outDir: { + type: 'string', + short: 'o', + }, + prefix: { + type: 'string', + }, + force: { + type: 'boolean', + short: 'f', + }, + help: { + type: 'boolean', + short: 'h', + }, + }, + strict: true, + }) + + if (values.help) { + printHelp() + process.exit(0) + } + + const inputFile = path.resolve(values.input ?? defaultInputFile) + const outDir = path.resolve(values.outDir ?? defaultOutputDir) + const prefix = values.prefix ?? 'hoist-' + const force = values.force ?? false + + const source = fs.readFileSync(inputFile, 'utf8') + const fixtures = extractFixtures(source) + + if (fixtures.length === 0) { + fail(`No inline inputs found in ${path.relative(packageDir, inputFile)}`) + } + + fs.mkdirSync(outDir, { recursive: true }) + + const usedNames = new Set(fs.globSync('*.js', { cwd: outDir })) + const writtenFiles: string[] = [] + + for (const fixture of fixtures) { + const basename = dedupeName( + `${prefix}${slugify(fixture.testName)}.js`, + usedNames, + ) + const targetFile = path.join(outDir, basename) + + if (!force && fs.existsSync(targetFile)) { + fail( + `Refusing to overwrite existing fixture: ${path.relative(packageDir, targetFile)}. Re-run with --force to overwrite.`, + ) + } + + fs.writeFileSync(targetFile, normalizeFixtureSource(fixture.input)) + writtenFiles.push(targetFile) + usedNames.add(basename) + } + + for (const file of writtenFiles) { + console.log(path.relative(packageDir, file)) + } + + console.error(`Extracted ${writtenFiles.length} fixture(s)`) +} + +function printHelp(): void { + console.log(`Usage: extract-hoist-scope-fixtures [options] + +Extract \`const input = \\\`...\\\`\` blocks from hoist.test.ts into scope fixtures. + +Options: + -i, --input Source test file + -o, --outDir Fixture output directory + --prefix Prefix for emitted fixture names (default: hoist-) + -f, --force Overwrite existing generated fixture files + -h, --help Show this help + +Examples: + pnpm extract-hoist-scope-fixtures + pnpm extract-hoist-scope-fixtures --prefix hoist-case- +`) +} + +function fail(message: string): never { + console.error(message) + process.exit(1) +} + +function extractFixtures( + source: string, +): Array<{ testName: string; input: string }> { + const fixtures: Array<{ testName: string; input: string }> = [] + const pattern = + /it\('([^']+)',[\s\S]*?\{\s*const input = `([\s\S]*?)`[\s\S]*?\}\)/g + + for (const match of source.matchAll(pattern)) { + const [, testName, input] = match + fixtures.push({ testName, input }) + } + + return fixtures +} + +function slugify(value: string): string { + return value + .toLowerCase() + .replace(/[^a-z0-9]+/g, '-') + .replace(/^-+|-+$/g, '') +} + +function dedupeName(candidate: string, usedNames: Set): string { + if (!usedNames.has(candidate)) { + return candidate + } + + const ext = path.extname(candidate) + const stem = candidate.slice(0, -ext.length) + + for (let index = 2; ; index++) { + const nextCandidate = `${stem}-${index}${ext}` + if (!usedNames.has(nextCandidate)) { + return nextCandidate + } + } +} + +function normalizeFixtureSource(input: string): string { + return input.replace(/^\n/, '').trimEnd() + '\n' +} From f064b1da7ee88d6b68577ea4d348ac577011e077 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:29:16 +0900 Subject: [PATCH 66/88] Revert "chore: this is slop" This reverts commit e97a20ec20273a1a6978fbd550a970f3810fb5bf. --- packages/plugin-rsc/package.json | 1 - .../scripts/extract-hoist-scope-fixtures.ts | 149 ------------------ 2 files changed, 150 deletions(-) delete mode 100644 packages/plugin-rsc/scripts/extract-hoist-scope-fixtures.ts diff --git a/packages/plugin-rsc/package.json b/packages/plugin-rsc/package.json index a04ff596c..a47c41b1b 100644 --- a/packages/plugin-rsc/package.json +++ b/packages/plugin-rsc/package.json @@ -30,7 +30,6 @@ }, "scripts": { "test": "vitest", - "extract-hoist-scope-fixtures": "node ./scripts/extract-hoist-scope-fixtures.ts", "review-scope-fixtures": "node ./scripts/review-scope-fixtures.ts", "test-e2e": "playwright test --project=chromium", "test-e2e-ci": "playwright test", diff --git a/packages/plugin-rsc/scripts/extract-hoist-scope-fixtures.ts b/packages/plugin-rsc/scripts/extract-hoist-scope-fixtures.ts deleted file mode 100644 index 1d5cd03ba..000000000 --- a/packages/plugin-rsc/scripts/extract-hoist-scope-fixtures.ts +++ /dev/null @@ -1,149 +0,0 @@ -import fs from 'node:fs' -import path from 'node:path' -import { parseArgs as parseNodeArgs } from 'node:util' - -const scriptDir = path.dirname(new URL(import.meta.url).pathname) -const packageDir = path.resolve(scriptDir, '..') -const defaultInputFile = path.join(packageDir, 'src/transforms/hoist.test.ts') -const defaultOutputDir = path.join(packageDir, 'src/transforms/fixtures/scope') - -main() - -function main(): void { - const { values } = parseNodeArgs({ - args: process.argv.slice(2), - options: { - input: { - type: 'string', - short: 'i', - }, - outDir: { - type: 'string', - short: 'o', - }, - prefix: { - type: 'string', - }, - force: { - type: 'boolean', - short: 'f', - }, - help: { - type: 'boolean', - short: 'h', - }, - }, - strict: true, - }) - - if (values.help) { - printHelp() - process.exit(0) - } - - const inputFile = path.resolve(values.input ?? defaultInputFile) - const outDir = path.resolve(values.outDir ?? defaultOutputDir) - const prefix = values.prefix ?? 'hoist-' - const force = values.force ?? false - - const source = fs.readFileSync(inputFile, 'utf8') - const fixtures = extractFixtures(source) - - if (fixtures.length === 0) { - fail(`No inline inputs found in ${path.relative(packageDir, inputFile)}`) - } - - fs.mkdirSync(outDir, { recursive: true }) - - const usedNames = new Set(fs.globSync('*.js', { cwd: outDir })) - const writtenFiles: string[] = [] - - for (const fixture of fixtures) { - const basename = dedupeName( - `${prefix}${slugify(fixture.testName)}.js`, - usedNames, - ) - const targetFile = path.join(outDir, basename) - - if (!force && fs.existsSync(targetFile)) { - fail( - `Refusing to overwrite existing fixture: ${path.relative(packageDir, targetFile)}. Re-run with --force to overwrite.`, - ) - } - - fs.writeFileSync(targetFile, normalizeFixtureSource(fixture.input)) - writtenFiles.push(targetFile) - usedNames.add(basename) - } - - for (const file of writtenFiles) { - console.log(path.relative(packageDir, file)) - } - - console.error(`Extracted ${writtenFiles.length} fixture(s)`) -} - -function printHelp(): void { - console.log(`Usage: extract-hoist-scope-fixtures [options] - -Extract \`const input = \\\`...\\\`\` blocks from hoist.test.ts into scope fixtures. - -Options: - -i, --input Source test file - -o, --outDir Fixture output directory - --prefix Prefix for emitted fixture names (default: hoist-) - -f, --force Overwrite existing generated fixture files - -h, --help Show this help - -Examples: - pnpm extract-hoist-scope-fixtures - pnpm extract-hoist-scope-fixtures --prefix hoist-case- -`) -} - -function fail(message: string): never { - console.error(message) - process.exit(1) -} - -function extractFixtures( - source: string, -): Array<{ testName: string; input: string }> { - const fixtures: Array<{ testName: string; input: string }> = [] - const pattern = - /it\('([^']+)',[\s\S]*?\{\s*const input = `([\s\S]*?)`[\s\S]*?\}\)/g - - for (const match of source.matchAll(pattern)) { - const [, testName, input] = match - fixtures.push({ testName, input }) - } - - return fixtures -} - -function slugify(value: string): string { - return value - .toLowerCase() - .replace(/[^a-z0-9]+/g, '-') - .replace(/^-+|-+$/g, '') -} - -function dedupeName(candidate: string, usedNames: Set): string { - if (!usedNames.has(candidate)) { - return candidate - } - - const ext = path.extname(candidate) - const stem = candidate.slice(0, -ext.length) - - for (let index = 2; ; index++) { - const nextCandidate = `${stem}-${index}${ext}` - if (!usedNames.has(nextCandidate)) { - return nextCandidate - } - } -} - -function normalizeFixtureSource(input: string): string { - return input.replace(/^\n/, '').trimEnd() + '\n' -} From e29f15e8115e09ef8b2d5460f229bf5da1f6c879 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:44:20 +0900 Subject: [PATCH 67/88] test: import typescript-eslint fixtures --- .../docs/notes/2026-04-04-scope-unit-tests.md | 30 +++--- packages/plugin-rsc/package.json | 1 - packages/plugin-rsc/scripts/README.md | 52 ++++++++++ ...import-typescript-eslint-scope-fixtures.ts | 99 +++++++++++++++++++ .../scripts/review-scope-fixtures.ts | 2 +- .../plugin-rsc/src/transforms/scope.test.ts | 4 +- 6 files changed, 170 insertions(+), 18 deletions(-) create mode 100644 packages/plugin-rsc/scripts/README.md create mode 100644 packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md index 3e81dbada..a8eef33e3 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md @@ -29,30 +29,30 @@ src/transforms/fixtures/scope/ ← hand-crafted cases not co ``` **`typescript-eslint/`** is copied from: -`oxc/crates/oxc_semantic/tests/fixtures/typescript-eslint/` +`https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/scope-manager/tests/fixtures` -which in turn was copied from typescript-eslint's own scope-manager test suite. These -inputs are authoritative: written by people who know the spec, with variable names like -`unresolved` and `dontReference2` that encode the expected behavior in the code itself. +These inputs are authoritative: written by people who know the spec, with variable names +like `unresolved` and `dontReference2` that encode the expected behavior in the code itself. -Copy the whole directory (all 269 files). TypeScript files are transpiled to JS in the -test runner before being passed to `buildScopeTree` (see below). +Historical note: `oxc` also mirrors this fixture corpus in +`crates/oxc_semantic/tests/fixtures/typescript-eslint/`. The introducing commit there is +`48724a0d44c7d10da97f3c0cb714890e965c4ab8` (`chore(semantic): copy tests from +typescript-eslint’s scope-manager (#3990)`), which cites +`https://github.com/typescript-eslint/typescript-eslint/tree/a5b652da1ebb09ecbca8f4b032bf05ebc0e03dc9/packages/scope-manager/tests/fixtures`. + +The checked-in subtree is **pre-transpiled JS**, not TS/TSX. The source of truth is the +local `typescript-eslint` checkout. The reproducible import/update workflow lives in +`packages/plugin-rsc/scripts/README.md`. #### Test runner ```ts -import { transformWithEsbuild } from 'vite' import { parseAstAsync } from 'vite' -// discover .js and .ts fixture files recursively -for (const file of globSync('**/*.{js,ts}', { cwd: fixtureDir })) { +// discover pre-transpiled .js fixture files recursively +for (const file of globSync('**/*.js', { cwd: fixtureDir })) { it(file, async () => { - let input = readFileSync(path.join(fixtureDir, file), 'utf-8') - if (file.endsWith('.ts')) { - // strip TypeScript syntax; buildScopeTree only handles ESTree JS - const result = await transformWithEsbuild(input, file, { loader: 'ts' }) - input = result.code - } + const input = readFileSync(path.join(fixtureDir, file), 'utf-8') const ast = await parseAstAsync(input) const scopeTree = buildScopeTree(ast) const snapshot = serializeScopeTree(ast, scopeTree) diff --git a/packages/plugin-rsc/package.json b/packages/plugin-rsc/package.json index a47c41b1b..e6bc6d189 100644 --- a/packages/plugin-rsc/package.json +++ b/packages/plugin-rsc/package.json @@ -30,7 +30,6 @@ }, "scripts": { "test": "vitest", - "review-scope-fixtures": "node ./scripts/review-scope-fixtures.ts", "test-e2e": "playwright test --project=chromium", "test-e2e-ci": "playwright test", "tsc": "tsc -b ./tsconfig.json ./e2e/tsconfig.json ./examples/*/tsconfig.json", diff --git a/packages/plugin-rsc/scripts/README.md b/packages/plugin-rsc/scripts/README.md new file mode 100644 index 000000000..9866e0fe1 --- /dev/null +++ b/packages/plugin-rsc/scripts/README.md @@ -0,0 +1,52 @@ +# Scripts + +## `import-typescript-eslint-scope-fixtures.ts` + +Regenerates the checked-in pre-transpiled JS fixture subtree at +`src/transforms/fixtures/scope/typescript-eslint/` from a local +`typescript-eslint` checkout. + +Default source: + +```bash +/home/hiroshi/code/others/typescript-eslint/packages/scope-manager/tests/fixtures +``` + +Usage: + +```bash +cd packages/plugin-rsc +node ./scripts/import-typescript-eslint-scope-fixtures.ts +pnpm test -- scope.test.ts --update +``` + +Override the source directory when needed: + +```bash +cd packages/plugin-rsc +node ./scripts/import-typescript-eslint-scope-fixtures.ts \ + --source /path/to/typescript-eslint/packages/scope-manager/tests/fixtures +pnpm test -- scope.test.ts --update +``` + +Notes: + +- The checked-in subtree is JS-only for stable fixture inputs in this repo. +- The transpile step uses Vite's TS/TSX transform with + `experimentalDecorators: true` and `useDefineForClassFields: false`. +- `oxc` also mirrors this corpus in + `crates/oxc_semantic/tests/fixtures/typescript-eslint/`, but the canonical + upstream source is `typescript-eslint`. + +## `review-scope-fixtures.ts` + +Builds a Markdown review packet for scope fixtures. + +Usage: + +```bash +cd packages/plugin-rsc +node ./scripts/review-scope-fixtures.ts | code - +node ./scripts/review-scope-fixtures.ts shadowing import | code - +node ./scripts/review-scope-fixtures.ts var-hoisting --output /tmp/scope-review.md +``` diff --git a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts new file mode 100644 index 000000000..9b4941660 --- /dev/null +++ b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts @@ -0,0 +1,99 @@ +import fs from 'node:fs' +import path from 'node:path' +import { parseArgs as parseNodeArgs } from 'node:util' +import { transformWithEsbuild } from 'vite' + +const defaultSourceDir = + '/home/hiroshi/code/others/typescript-eslint/packages/scope-manager/tests/fixtures' + +const scriptDir = path.dirname(new URL(import.meta.url).pathname) +const packageDir = path.resolve(scriptDir, '..') +const outputDir = path.join( + packageDir, + 'src/transforms/fixtures/scope/typescript-eslint', +) + +main().catch((error: unknown) => { + console.error(error) + process.exit(1) +}) + +async function main(): Promise { + const { values } = parseNodeArgs({ + args: process.argv.slice(2), + options: { + source: { + type: 'string', + short: 's', + }, + help: { + type: 'boolean', + short: 'h', + }, + }, + strict: true, + }) + + if (values.help) { + printHelp() + return + } + + const sourceDir = values.source ?? defaultSourceDir + if (!fs.existsSync(sourceDir)) { + throw new Error( + `Fixture source directory does not exist: ${sourceDir}\n` + + 'Pass --source to point at a local typescript-eslint scope-manager fixture checkout.', + ) + } + + fs.rmSync(outputDir, { recursive: true, force: true }) + + const inputFiles = fs.globSync('**/*.{ts,tsx}', { cwd: sourceDir }).sort() + for (const relativePath of inputFiles) { + const inputPath = path.join(sourceDir, relativePath) + const outputPath = path.join( + outputDir, + relativePath.replace(/\.(ts|tsx)$/, '.js'), + ) + + fs.mkdirSync(path.dirname(outputPath), { recursive: true }) + + const input = fs.readFileSync(inputPath, 'utf8') + const loader = relativePath.endsWith('.tsx') ? 'tsx' : 'ts' + const result = await transformWithEsbuild(input, relativePath, { + loader, + target: 'esnext', + format: 'esm', + tsconfigRaw: { + compilerOptions: { + experimentalDecorators: true, + useDefineForClassFields: false, + }, + }, + }) + fs.writeFileSync(outputPath, result.code) + } + + console.error( + `Imported ${inputFiles.length} fixture(s) from ${sourceDir} into ${outputDir}`, + ) +} + +function printHelp(): void { + console.log(`Usage: import-typescript-eslint-scope-fixtures [options] + +Transpile the local typescript-eslint scope-manager fixtures into checked-in JS +fixtures under src/transforms/fixtures/scope/typescript-eslint. + +Options: + -s, --source Source fixture directory + -h, --help Show this help + +Default source: + ${defaultSourceDir} + +After import, regenerate snapshots with: + cd packages/plugin-rsc && pnpm test -- scope.test.ts --update +`) +} diff --git a/packages/plugin-rsc/scripts/review-scope-fixtures.ts b/packages/plugin-rsc/scripts/review-scope-fixtures.ts index c05a3b5af..eb9f45b38 100644 --- a/packages/plugin-rsc/scripts/review-scope-fixtures.ts +++ b/packages/plugin-rsc/scripts/review-scope-fixtures.ts @@ -90,7 +90,7 @@ function fail(message: string): never { function collectFixtures(rootDir: string, filters: string[]): Fixture[] { return fs - .globSync('*.js', { cwd: rootDir }) + .globSync('**/*.js', { cwd: rootDir }) .map((relativePath): FixtureEntry => { const sourceFile = path.join(rootDir, relativePath) return { diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 95bf563af..d79270a3f 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -8,7 +8,9 @@ import { type Scope, type ScopeTree, buildScopeTree } from './scope' // - use single markdown as snaphsot? (cf. review-scope-fixtures.ts) describe('fixtures', () => { - const fixtures = import.meta.glob('./fixtures/scope/*.js', { query: 'raw' }) + const fixtures = import.meta.glob('./fixtures/scope/**/*.js', { + query: 'raw', + }) for (const [file, mod] of Object.entries(fixtures)) { it(path.basename(file), async () => { const input = ((await mod()) as any).default as string From 73fe300dd61a4eda57eb286076145eec64f45904 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:47:31 +0900 Subject: [PATCH 68/88] test: fix import --- packages/plugin-rsc/scripts/README.md | 2 +- ...import-typescript-eslint-scope-fixtures.ts | 35 ++++++++++++------- packages/plugin-rsc/tsconfig.json | 2 +- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/packages/plugin-rsc/scripts/README.md b/packages/plugin-rsc/scripts/README.md index 9866e0fe1..f4086410a 100644 --- a/packages/plugin-rsc/scripts/README.md +++ b/packages/plugin-rsc/scripts/README.md @@ -32,7 +32,7 @@ pnpm test -- scope.test.ts --update Notes: - The checked-in subtree is JS-only for stable fixture inputs in this repo. -- The transpile step uses Vite's TS/TSX transform with +- The transpile step uses TypeScript `transpileModule` with `experimentalDecorators: true` and `useDefineForClassFields: false`. - `oxc` also mirrors this corpus in `crates/oxc_semantic/tests/fixtures/typescript-eslint/`, but the canonical diff --git a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts index 9b4941660..5e6182794 100644 --- a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts +++ b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts @@ -1,7 +1,7 @@ import fs from 'node:fs' import path from 'node:path' import { parseArgs as parseNodeArgs } from 'node:util' -import { transformWithEsbuild } from 'vite' +import ts from 'typescript' const defaultSourceDir = '/home/hiroshi/code/others/typescript-eslint/packages/scope-manager/tests/fixtures' @@ -60,19 +60,30 @@ async function main(): Promise { fs.mkdirSync(path.dirname(outputPath), { recursive: true }) const input = fs.readFileSync(inputPath, 'utf8') - const loader = relativePath.endsWith('.tsx') ? 'tsx' : 'ts' - const result = await transformWithEsbuild(input, relativePath, { - loader, - target: 'esnext', - format: 'esm', - tsconfigRaw: { - compilerOptions: { - experimentalDecorators: true, - useDefineForClassFields: false, - }, + const result = ts.transpileModule(input, { + fileName: relativePath, + compilerOptions: { + target: ts.ScriptTarget.ESNext, + module: ts.ModuleKind.ESNext, + jsx: ts.JsxEmit.Preserve, + experimentalDecorators: true, + useDefineForClassFields: false, }, + reportDiagnostics: true, + transformers: undefined, }) - fs.writeFileSync(outputPath, result.code) + if (result.diagnostics?.length) { + const message = ts.formatDiagnosticsWithColorAndContext( + result.diagnostics, + { + getCanonicalFileName: (fileName) => fileName, + getCurrentDirectory: () => packageDir, + getNewLine: () => '\n', + }, + ) + throw new Error(`Failed to transpile fixture ${relativePath}\n${message}`) + } + fs.writeFileSync(outputPath, result.outputText) } console.error( diff --git a/packages/plugin-rsc/tsconfig.json b/packages/plugin-rsc/tsconfig.json index e4cfe71d1..17f837694 100644 --- a/packages/plugin-rsc/tsconfig.json +++ b/packages/plugin-rsc/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "./tsconfig.base.json", - "include": ["src", "*.ts", "types"], + "include": ["src", "*.ts", "types", "scripts"], "compilerOptions": { "noPropertyAccessFromIndexSignature": false, "noImplicitReturns": false, From a600f6b02464d89e5b1d45f22a451ced3263330c Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 22:51:24 +0900 Subject: [PATCH 69/88] test(plugin-rsc): import typescript-eslint scope fixtures Co-authored-by: Codex --- ...import-typescript-eslint-scope-fixtures.ts | 2 +- .../block/inherited-scope.js | 4 + .../block/inherited-scope.js.snap.json | 20 + .../scope/typescript-eslint/block/scope.js | 6 + .../block/scope.js.snap.json | 26 ++ .../call-expression/call-expression.js | 4 + .../call-expression.js.snap.json | 40 ++ .../call-expression/type-parameters1.js | 1 + .../type-parameters1.js.snap.json | 11 + .../call-expression/type-parameters2.js | 2 + .../type-parameters2.js.snap.json | 13 + .../catch/destructuring-array.js | 2 + .../catch/destructuring-array.js.snap.json | 31 ++ .../catch/destructuring-object.js | 2 + .../catch/destructuring-object.js.snap.json | 32 ++ .../catch/inherited-scope.js | 5 + .../catch/inherited-scope.js.snap.json | 35 ++ .../scope/typescript-eslint/catch/scope.js | 7 + .../catch/scope.js.snap.json | 47 +++ .../declaration/abstract-accessor-property.js | 1 + .../abstract-accessor-property.js.snap.json | 8 + .../class/declaration/abstract-property.js | 1 + .../abstract-property.js.snap.json | 8 + .../class/declaration/abstract.js | 1 + .../class/declaration/abstract.js.snap.json | 8 + .../accessor-property-type-annotation.js | 1 + ...ssor-property-type-annotation.js.snap.json | 8 + .../class/declaration/accessor-property.js | 8 + .../accessor-property.js.snap.json | 34 ++ .../class/declaration/computed-member.js | 9 + .../declaration/computed-member.js.snap.json | 56 +++ .../class/declaration/extends-generic.js | 2 + .../declaration/extends-generic.js.snap.json | 14 + .../class/declaration/extends.js | 2 + .../class/declaration/extends.js.snap.json | 14 + .../class/declaration/generic-ref-extends.js | 1 + .../generic-ref-extends.js.snap.json | 13 + .../declaration/generic-ref-implements.js | 1 + .../generic-ref-implements.js.snap.json | 8 + .../class/declaration/generic.js | 1 + .../class/declaration/generic.js.snap.json | 8 + .../class/declaration/implements-generic.js | 1 + .../implements-generic.js.snap.json | 8 + .../class/declaration/implements.js | 1 + .../class/declaration/implements.js.snap.json | 8 + .../class/declaration/index-signature.js | 1 + .../declaration/index-signature.js.snap.json | 8 + .../class/declaration/method-param-default.js | 10 + .../method-param-default.js.snap.json | 49 +++ .../class/declaration/method.js | 7 + .../class/declaration/method.js.snap.json | 50 +++ .../class/declaration/new.js | 2 + .../class/declaration/new.js.snap.json | 13 + .../class/declaration/parameter-properties.js | 13 + .../parameter-properties.js.snap.json | 74 ++++ .../class/declaration/private-identifier.js | 6 + .../private-identifier.js.snap.json | 22 ++ .../declaration/properties-type-annotation.js | 1 + .../properties-type-annotation.js.snap.json | 8 + .../class/declaration/properties.js | 8 + .../class/declaration/properties.js.snap.json | 34 ++ .../class/declaration/static-block.js | 3 + .../declaration/static-block.js.snap.json | 8 + .../class/declaration/static-external-ref.js | 6 + .../static-external-ref.js.snap.json | 28 ++ .../declaration/static-with-constructor.js | 8 + .../static-with-constructor.js.snap.json | 41 ++ .../class/declaration/type-reference.js | 2 + .../declaration/type-reference.js.snap.json | 14 + .../class/expression/computed-member.js | 9 + .../expression/computed-member.js.snap.json | 56 +++ .../class/expression/extends.js | 2 + .../class/expression/extends.js.snap.json | 14 + .../class/expression/method.js | 7 + .../class/expression/method.js.snap.json | 50 +++ .../typescript-eslint/class/expression/new.js | 2 + .../class/expression/new.js.snap.json | 13 + .../class/expression/parameter-properties.js | 13 + .../parameter-properties.js.snap.json | 74 ++++ .../class/expression/private-identifier.js | 6 + .../private-identifier.js.snap.json | 22 ++ .../class/expression/properties.js | 8 + .../class/expression/properties.js.snap.json | 34 ++ .../class/expression/self-reference-super.js | 3 + .../self-reference-super.js.snap.json | 13 + .../typescript-eslint/decorators/accessor.js | 28 ++ .../decorators/accessor.js.snap.json | 280 ++++++++++++++ .../class-deco-with-object-param.js | 31 ++ .../class-deco-with-object-param.js.snap.json | 230 ++++++++++++ .../decorators/class-property.js | 22 ++ .../decorators/class-property.js.snap.json | 240 ++++++++++++ .../typescript-eslint/decorators/class.js | 22 ++ .../decorators/class.js.snap.json | 244 ++++++++++++ .../typescript-eslint/decorators/method.js | 24 ++ .../decorators/method.js.snap.json | 253 +++++++++++++ .../decorators/parameter-property.js | 34 ++ .../parameter-property.js.snap.json | 332 ++++++++++++++++ .../typescript-eslint/decorators/parameter.js | 43 +++ .../decorators/parameter.js.snap.json | 354 ++++++++++++++++++ .../decorators/typeof-this.js | 24 ++ .../decorators/typeof-this.js.snap.json | 259 +++++++++++++ .../destructuring/array-assignment.js | 3 + .../array-assignment.js.snap.json | 23 ++ .../typescript-eslint/destructuring/array.js | 1 + .../destructuring/array.js.snap.json | 19 + .../destructuring/object-assignment.js | 6 + .../object-assignment.js.snap.json | 25 ++ .../typescript-eslint/destructuring/object.js | 6 + .../destructuring/object.js.snap.json | 19 + .../scope/typescript-eslint/export/all.js | 3 + .../typescript-eslint/export/all.js.snap.json | 11 + .../typescript-eslint/export/default-type.js | 3 + .../export/default-type.js.snap.json | 13 + .../typescript-eslint/export/default1.js | 2 + .../export/default1.js.snap.json | 22 ++ .../typescript-eslint/export/default2.js | 3 + .../export/default2.js.snap.json | 13 + .../typescript-eslint/export/default3.js | 2 + .../export/default3.js.snap.json | 6 + .../typescript-eslint/export/default4.js | 2 + .../export/default4.js.snap.json | 20 + .../scope/typescript-eslint/export/equals1.js | 3 + .../export/equals1.js.snap.json | 8 + .../scope/typescript-eslint/export/equals2.js | 2 + .../export/equals2.js.snap.json | 6 + .../typescript-eslint/export/equals3-type.js | 1 + .../export/equals3-type.js.snap.json | 6 + .../typescript-eslint/export/equals4-type.js | 1 + .../export/equals4-type.js.snap.json | 6 + .../typescript-eslint/export/named-dual.js | 2 + .../export/named-dual.js.snap.json | 13 + .../typescript-eslint/export/named-source1.js | 2 + .../export/named-source1.js.snap.json | 11 + .../typescript-eslint/export/named-source2.js | 2 + .../export/named-source2.js.snap.json | 11 + .../typescript-eslint/export/named-type1.js | 2 + .../export/named-type1.js.snap.json | 6 + .../scope/typescript-eslint/export/named1.js | 2 + .../export/named1.js.snap.json | 8 + .../typescript-eslint/export/named2-type.js | 2 + .../export/named2-type.js.snap.json | 6 + .../scope/typescript-eslint/export/named2.js | 3 + .../export/named2.js.snap.json | 13 + .../typescript-eslint/export/named3-type.js | 2 + .../export/named3-type.js.snap.json | 6 + .../scope/typescript-eslint/export/named3.js | 3 + .../export/named3.js.snap.json | 13 + .../typescript-eslint/export/type-inline.js | 3 + .../export/type-inline.js.snap.json | 8 + .../scope/typescript-eslint/export/type.js | 3 + .../export/type.js.snap.json | 8 + .../readable-ref-body-shadow.js | 5 + .../readable-ref-body-shadow.js.snap.json | 32 ++ .../default-params/readable-ref-const.js | 2 + .../readable-ref-const.js.snap.json | 30 ++ .../arrow/default-params/readable-ref-let.js | 2 + .../readable-ref-let.js.snap.json | 30 ++ .../readable-ref-nested-body-shadow.js | 8 + ...adable-ref-nested-body-shadow.js.snap.json | 45 +++ .../default-params/readable-ref-nested.js | 6 + .../readable-ref-nested.js.snap.json | 43 +++ .../readable-ref-param-shadow.js | 3 + .../readable-ref-param-shadow.js.snap.json | 31 ++ .../default-params/readable-ref-partial.js | 2 + .../readable-ref-partial.js.snap.json | 30 ++ .../arrow/default-params/writable-ref.js | 1 + .../default-params/writable-ref.js.snap.json | 25 ++ .../functions/arrow/inherited-scope.js | 4 + .../arrow/inherited-scope.js.snap.json | 27 ++ .../functions/arrow/no-body.js | 1 + .../functions/arrow/no-body.js.snap.json | 20 + .../functions/arrow/params.js | 5 + .../functions/arrow/params.js.snap.json | 50 +++ .../functions/arrow/scope.js | 6 + .../functions/arrow/scope.js.snap.json | 37 ++ .../arrow/type-parameters/body-reference.js | 3 + .../body-reference.js.snap.json | 24 ++ .../arrow/type-parameters/param-reference.js | 1 + .../param-reference.js.snap.json | 24 ++ .../type-parameters/return-value-reference.js | 1 + .../return-value-reference.js.snap.json | 22 ++ .../type-parameters/type-param-reference.js | 1 + .../type-param-reference.js.snap.json | 22 ++ .../type-parameter-declaration.js | 1 + .../type-parameter-declaration.js.snap.json | 22 ++ .../arrow/type-predicate-asserts1.js | 1 + .../type-predicate-asserts1.js.snap.json | 24 ++ .../arrow/type-predicate-asserts2.js | 1 + .../type-predicate-asserts2.js.snap.json | 24 ++ .../functions/arrow/type-predicate1.js | 3 + .../arrow/type-predicate1.js.snap.json | 29 ++ .../functions/arrow/type-predicate2.js | 3 + .../arrow/type-predicate2.js.snap.json | 29 ++ .../readable-ref-body-shadow.js | 5 + .../readable-ref-body-shadow.js.snap.json | 32 ++ .../default-params/readable-ref-const.js | 2 + .../readable-ref-const.js.snap.json | 30 ++ .../default-params/readable-ref-let.js | 2 + .../readable-ref-let.js.snap.json | 30 ++ .../readable-ref-nested-body-shadow.js | 8 + ...adable-ref-nested-body-shadow.js.snap.json | 45 +++ .../default-params/readable-ref-nested.js | 6 + .../readable-ref-nested.js.snap.json | 43 +++ .../readable-ref-param-shadow.js | 3 + .../readable-ref-param-shadow.js.snap.json | 31 ++ .../default-params/readable-ref-partial.js | 2 + .../readable-ref-partial.js.snap.json | 30 ++ .../default-params/writable-ref.js | 1 + .../default-params/writable-ref.js.snap.json | 25 ++ .../function-declaration/inherited-scope.js | 4 + .../inherited-scope.js.snap.json | 28 ++ .../name-shadowed-in-body.js | 4 + .../name-shadowed-in-body.js.snap.json | 30 ++ .../function-declaration/overload.js | 3 + .../overload.js.snap.json | 30 ++ .../functions/function-declaration/params.js | 5 + .../function-declaration/params.js.snap.json | 51 +++ .../functions/function-declaration/scope.js | 6 + .../function-declaration/scope.js.snap.json | 37 ++ .../type-parameters/body-reference.js | 3 + .../body-reference.js.snap.json | 24 ++ .../type-parameters/param-reference.js | 1 + .../param-reference.js.snap.json | 24 ++ .../type-parameters/return-value-reference.js | 1 + .../return-value-reference.js.snap.json | 22 ++ .../type-parameters/type-param-reference.js | 1 + .../type-param-reference.js.snap.json | 22 ++ .../type-parameter-declaration.js | 1 + .../type-parameter-declaration.js.snap.json | 22 ++ .../type-predicate-asserts1.js | 1 + .../type-predicate-asserts1.js.snap.json | 24 ++ .../type-predicate-asserts2.js | 1 + .../type-predicate-asserts2.js.snap.json | 24 ++ .../function-declaration/type-predicate1.js | 3 + .../type-predicate1.js.snap.json | 29 ++ .../function-declaration/type-predicate2.js | 3 + .../type-predicate2.js.snap.json | 29 ++ .../function-expression/anonymous.js | 1 + .../anonymous.js.snap.json | 22 ++ .../readable-ref-body-shadow.js | 5 + .../readable-ref-body-shadow.js.snap.json | 32 ++ .../default-params/readable-ref-const.js | 2 + .../readable-ref-const.js.snap.json | 30 ++ .../default-params/readable-ref-let.js | 2 + .../readable-ref-let.js.snap.json | 30 ++ .../readable-ref-nested-body-shadow.js | 8 + ...adable-ref-nested-body-shadow.js.snap.json | 45 +++ .../default-params/readable-ref-nested.js | 6 + .../readable-ref-nested.js.snap.json | 43 +++ .../readable-ref-param-shadow.js | 3 + .../readable-ref-param-shadow.js.snap.json | 31 ++ .../default-params/readable-ref-partial.js | 2 + .../readable-ref-partial.js.snap.json | 30 ++ .../default-params/writable-ref.js | 1 + .../default-params/writable-ref.js.snap.json | 25 ++ .../function-expression/inherited-scope.js | 4 + .../inherited-scope.js.snap.json | 28 ++ .../functions/function-expression/params.js | 5 + .../function-expression/params.js.snap.json | 51 +++ .../functions/function-expression/scope.js | 6 + .../function-expression/scope.js.snap.json | 37 ++ .../type-parameters/body-reference.js | 3 + .../body-reference.js.snap.json | 24 ++ .../type-parameters/param-reference.js | 1 + .../param-reference.js.snap.json | 24 ++ .../type-parameters/return-value-reference.js | 1 + .../return-value-reference.js.snap.json | 22 ++ .../type-parameters/type-param-reference.js | 1 + .../type-param-reference.js.snap.json | 22 ++ .../type-parameter-declaration.js | 1 + .../type-parameter-declaration.js.snap.json | 22 ++ .../type-predicate-asserts1.js | 1 + .../type-predicate-asserts1.js.snap.json | 24 ++ .../type-predicate-asserts2.js | 1 + .../type-predicate-asserts2.js.snap.json | 24 ++ .../function-expression/type-predicate1.js | 3 + .../type-predicate1.js.snap.json | 29 ++ .../function-expression/type-predicate2.js | 3 + .../type-predicate2.js.snap.json | 29 ++ .../global-resolution/module/class.js | 3 + .../module/class.js.snap.json | 13 + .../global-resolution/module/function.js | 3 + .../module/function.js.snap.json | 27 ++ .../module/variable-decl-const.js | 3 + .../module/variable-decl-const.js.snap.json | 27 ++ .../module/variable-decl-let.js | 3 + .../module/variable-decl-let.js.snap.json | 27 ++ .../module/variable-decl-var.js | 3 + .../module/variable-decl-var.js.snap.json | 27 ++ .../global-resolution/script/class.js | 3 + .../script/class.js.snap.json | 13 + .../global-resolution/script/function.js | 3 + .../script/function.js.snap.json | 27 ++ .../script/variable-decl-const.js | 3 + .../script/variable-decl-const.js.snap.json | 27 ++ .../script/variable-decl-let.js | 3 + .../script/variable-decl-let.js.snap.json | 27 ++ .../script/variable-decl-var.js | 3 + .../script/variable-decl-var.js.snap.json | 27 ++ .../typescript-eslint/implicit/implicit1.js | 1 + .../implicit/implicit1.js.snap.json | 13 + .../scope/typescript-eslint/import/default.js | 3 + .../import/default.js.snap.json | 13 + .../scope/typescript-eslint/import/equals1.js | 3 + .../import/equals1.js.snap.json | 11 + .../scope/typescript-eslint/import/equals2.js | 3 + .../import/equals2.js.snap.json | 14 + .../typescript-eslint/import/named-alias.js | 3 + .../import/named-alias.js.snap.json | 13 + .../scope/typescript-eslint/import/named.js | 3 + .../import/named.js.snap.json | 13 + .../typescript-eslint/import/namespace.js | 3 + .../import/namespace.js.snap.json | 13 + .../import/type-default-value.js | 2 + .../import/type-default-value.js.snap.json | 6 + .../typescript-eslint/import/type-default.js | 3 + .../import/type-default.js.snap.json | 13 + .../import/type-inline-value.js | 2 + .../import/type-inline-value.js.snap.json | 6 + .../typescript-eslint/import/type-inline.js | 3 + .../import/type-inline.js.snap.json | 13 + .../import/type-named-value.js | 2 + .../import/type-named-value.js.snap.json | 6 + .../typescript-eslint/import/type-named.js | 3 + .../import/type-named.js.snap.json | 13 + .../type-arguments1.js | 7 + .../type-arguments1.js.snap.json | 33 ++ .../type-arguments2.js | 4 + .../type-arguments2.js.snap.json | 35 ++ .../typescript-eslint/jsx/attribute-spread.js | 3 + .../jsx/attribute-spread.js.snap.json | 22 ++ .../scope/typescript-eslint/jsx/attribute.js | 4 + .../jsx/attribute.js.snap.json | 23 ++ .../scope/typescript-eslint/jsx/children.js | 3 + .../jsx/children.js.snap.json | 22 ++ .../jsx/component-intrinsic-name.js | 3 + .../jsx/component-intrinsic-name.js.snap.json | 28 ++ .../jsx/component-namespaced1.js | 6 + .../jsx/component-namespaced1.js.snap.json | 33 ++ .../jsx/component-namespaced2.js | 6 + .../jsx/component-namespaced2.js.snap.json | 33 ++ .../scope/typescript-eslint/jsx/component.js | 3 + .../jsx/component.js.snap.json | 32 ++ .../jsx/factory/default-jsxFragmentName.js | 4 + .../default-jsxFragmentName.js.snap.json | 19 + .../jsx/factory/default-jsxPragma-fragment.js | 4 + .../default-jsxPragma-fragment.js.snap.json | 19 + .../jsx/factory/default-jsxPragma.js | 4 + .../factory/default-jsxPragma.js.snap.json | 18 + .../jsx/factory/jsxFragmentName.js | 5 + .../jsx/factory/jsxFragmentName.js.snap.json | 19 + .../jsx/factory/jsxPragma-jsxFragmentName.js | 6 + .../jsxPragma-jsxFragmentName.js.snap.json | 19 + .../jsx/factory/jsxPragma.js | 5 + .../jsx/factory/jsxPragma.js.snap.json | 18 + .../jsx/fragment-children.js | 3 + .../jsx/fragment-children.js.snap.json | 23 ++ .../scope/typescript-eslint/jsx/fragment.js | 2 + .../jsx/fragment.js.snap.json | 18 + .../jsx/generic-type-param.js | 2 + .../jsx/generic-type-param.js.snap.json | 17 + .../jsx/namespaced-attribute.js | 8 + .../jsx/namespaced-attribute.js.snap.json | 54 +++ .../scope/typescript-eslint/jsx/text.js | 3 + .../typescript-eslint/jsx/text.js.snap.json | 19 + .../jsx/this-jsxidentifier.js | 12 + .../jsx/this-jsxidentifier.js.snap.json | 65 ++++ .../member-expression/member-expression.js | 6 + .../member-expression.js.snap.json | 29 ++ .../new-expression/new-expression.js | 3 + .../new-expression.js.snap.json | 18 + .../new-expression/type-parameters1.js | 1 + .../type-parameters1.js.snap.json | 11 + .../new-expression/type-parameters2.js | 2 + .../type-parameters2.js.snap.json | 13 + .../typescript-eslint/ts-enum/external-ref.js | 5 + .../ts-enum/external-ref.js.snap.json | 46 +++ .../ts-enum/literal-member-ref.js | 5 + .../ts-enum/literal-member-ref.js.snap.json | 50 +++ .../ts-enum/literal-member.js | 4 + .../ts-enum/literal-member.js.snap.json | 42 +++ .../typescript-eslint/ts-enum/member-ref.js | 5 + .../ts-enum/member-ref.js.snap.json | 50 +++ .../scope/typescript-eslint/ts-enum/scope.js | 5 + .../ts-enum/scope.js.snap.json | 47 +++ .../typescript-eslint/ts-enum/self-ref.js | 5 + .../ts-enum/self-ref.js.snap.json | 50 +++ .../declaration-merging/class-namespace.js | 5 + .../class-namespace.js.snap.json | 43 +++ .../declaration-merging/function-namespace.js | 5 + .../function-namespace.js.snap.json | 56 +++ .../declaration-merging/namespace-variable.js | 2 + .../namespace-variable.js.snap.json | 14 + .../ts-module/external-ref.js | 5 + .../ts-module/external-ref.js.snap.json | 42 +++ .../ts-module/global-augmentation.js | 1 + .../global-augmentation.js.snap.json | 6 + .../typescript-eslint/ts-module/import.js | 1 + .../ts-module/import.js.snap.json | 6 + .../ts-module/name-shadowed-in-body.js | 5 + .../name-shadowed-in-body.js.snap.json | 43 +++ .../typescript-eslint/ts-module/namespace.js | 7 + .../ts-module/namespace.js.snap.json | 51 +++ .../ts-module/nested-namespace-alias.js | 8 + .../nested-namespace-alias.js.snap.json | 70 ++++ .../typescript-eslint/ts-module/scope.js | 5 + .../ts-module/scope.js.snap.json | 40 ++ .../typescript-eslint/ts-module/self-ref.js | 5 + .../ts-module/self-ref.js.snap.json | 42 +++ .../parameter-array-destructure.js | 1 + .../parameter-array-destructure.js.snap.json | 24 ++ .../type-annotation/parameter-default.js | 1 + .../parameter-default.js.snap.json | 24 ++ .../parameter-object-destructure.js | 1 + .../parameter-object-destructure.js.snap.json | 24 ++ .../type-annotation/parameter-rest.js | 1 + .../parameter-rest.js.snap.json | 24 ++ .../type-annotation/parameter.js | 1 + .../type-annotation/parameter.js.snap.json | 24 ++ .../variable-array-destructure.js | 1 + .../variable-array-destructure.js.snap.json | 8 + .../type-annotation/variable-const.js | 1 + .../variable-const.js.snap.json | 8 + .../type-annotation/variable-let.js | 1 + .../type-annotation/variable-let.js.snap.json | 8 + .../variable-object-destructure.js | 1 + .../variable-object-destructure.js.snap.json | 8 + .../type-annotation/variable-var.js | 1 + .../type-annotation/variable-var.js.snap.json | 8 + .../type-assertion/angle-bracket.js | 2 + .../type-assertion/angle-bracket.js.snap.json | 13 + .../typescript-eslint/type-assertion/as.js | 2 + .../type-assertion/as.js.snap.json | 13 + .../assignment/angle-bracket-assignment.js | 2 + .../angle-bracket-assignment.js.snap.json | 13 + .../assignment/as-assignment.js | 2 + .../assignment/as-assignment.js.snap.json | 13 + .../assignment/non-null-assignment.js | 2 + .../non-null-assignment.js.snap.json | 13 + .../increment/angle-bracket-increment.js | 2 + .../angle-bracket-increment.js.snap.json | 13 + .../type-assertion/increment/as-increment.js | 2 + .../increment/as-increment.js.snap.json | 13 + .../increment/non-null-increment.js | 2 + .../increment/non-null-increment.js.snap.json | 13 + .../type-assertion/satisfies.js | 2 + .../type-assertion/satisfies.js.snap.json | 13 + .../type-declaration/conditional-nested.js | 0 .../conditional-nested.js.snap.json | 6 + .../type-declaration/conditional1.js | 0 .../conditional1.js.snap.json | 6 + .../type-declaration/conditional2.js | 0 .../conditional2.js.snap.json | 6 + .../type-declaration/conditional3.js | 0 .../conditional3.js.snap.json | 6 + .../type-declaration/conditional4.js | 0 .../conditional4.js.snap.json | 6 + .../type-declaration/conditional5.js | 0 .../conditional5.js.snap.json | 6 + .../type-declaration/dual-type-value.js | 2 + .../dual-type-value.js.snap.json | 14 + .../function/constructor-generics1.js | 0 .../constructor-generics1.js.snap.json | 6 + .../function/constructor-generics2.js | 0 .../constructor-generics2.js.snap.json | 6 + .../type-declaration/function/constructor.js | 0 .../function/constructor.js.snap.json | 6 + .../function/function-generics1.js | 0 .../function/function-generics1.js.snap.json | 6 + .../function/function-generics2.js | 0 .../function/function-generics2.js.snap.json | 6 + .../type-declaration/function/function1.js | 0 .../function/function1.js.snap.json | 6 + .../type-declaration/function/function2.js | 1 + .../function/function2.js.snap.json | 8 + .../function/params/array-pattern.js | 0 .../params/array-pattern.js.snap.json | 6 + .../function/params/object-pattern.js | 0 .../params/object-pattern.js.snap.json | 6 + .../function/params/rest-element.js | 0 .../function/params/rest-element.js.snap.json | 6 + .../import-type-with-qualifier.js | 0 .../import-type-with-qualifier.js.snap.json | 6 + .../import-type-with-type-params.js | 0 .../import-type-with-type-params.js.snap.json | 6 + .../type-declaration/import-type.js | 0 .../type-declaration/import-type.js.snap.json | 6 + .../type-declaration/index-access1.js | 0 .../index-access1.js.snap.json | 6 + .../type-declaration/index-access2.js | 0 .../index-access2.js.snap.json | 6 + .../type-declaration/index-access3.js | 1 + .../index-access3.js.snap.json | 8 + .../type-declaration/infer-type-constraint.js | 0 .../infer-type-constraint.js.snap.json | 6 + .../type-declaration/interface-heritage1.js | 0 .../interface-heritage1.js.snap.json | 6 + .../type-declaration/interface-heritage2.js | 0 .../interface-heritage2.js.snap.json | 6 + .../type-declaration/interface1.js | 0 .../type-declaration/interface1.js.snap.json | 6 + .../type-declaration/interface2.js | 0 .../type-declaration/interface2.js.snap.json | 6 + .../type-declaration/literal-type1.js | 0 .../literal-type1.js.snap.json | 6 + .../type-declaration/literal-type2.js | 0 .../literal-type2.js.snap.json | 6 + .../type-declaration/literal-type3.js | 0 .../literal-type3.js.snap.json | 6 + .../mapped-named-literal-no-references.js | 0 ...d-named-literal-no-references.js.snap.json | 6 + .../mapped-named-literal-referenced.js | 0 ...pped-named-literal-referenced.js.snap.json | 6 + .../type-declaration/mapped-named.js | 0 .../mapped-named.js.snap.json | 6 + .../type-declaration/mapped.js | 0 .../type-declaration/mapped.js.snap.json | 6 + .../type-declaration/qualified-name.js | 0 .../qualified-name.js.snap.json | 6 + .../signatures/call-generics.js | 0 .../signatures/call-generics.js.snap.json | 6 + .../type-declaration/signatures/call.js | 0 .../signatures/call.js.snap.json | 6 + .../signatures/construct-generics.js | 0 .../construct-generics.js.snap.json | 6 + .../type-declaration/signatures/construct.js | 0 .../signatures/construct.js.snap.json | 6 + .../type-declaration/signatures/index-sig.js | 0 .../signatures/index-sig.js.snap.json | 6 + .../signatures/method-computed-name.js | 1 + .../method-computed-name.js.snap.json | 8 + .../signatures/method-computed-name2.js | 4 + .../method-computed-name2.js.snap.json | 42 +++ .../signatures/method-generics.js | 0 .../signatures/method-generics.js.snap.json | 6 + .../type-declaration/signatures/method.js | 0 .../signatures/method.js.snap.json | 6 + .../signatures/property-computed-name.js | 1 + .../property-computed-name.js.snap.json | 8 + .../signatures/property-computed-name2.js | 4 + .../property-computed-name2.js.snap.json | 42 +++ .../type-declaration/signatures/property.js | 0 .../signatures/property.js.snap.json | 6 + .../type-declaration/tuple-labelled-rest.js | 0 .../tuple-labelled-rest.js.snap.json | 6 + .../type-declaration/tuple-labelled.js | 0 .../tuple-labelled.js.snap.json | 6 + .../type-declaration/tuple-rest.js | 0 .../type-declaration/tuple-rest.js.snap.json | 6 + .../type-declaration/tuple.js | 0 .../type-declaration/tuple.js.snap.json | 6 + .../interface/body-reference.js | 0 .../interface/body-reference.js.snap.json | 6 + .../interface/extends-reference.js | 0 .../interface/extends-reference.js.snap.json | 6 + .../interface/type-param-reference.js | 0 .../type-param-reference.js.snap.json | 6 + .../type-parameter-declaration-extends.js | 0 ...parameter-declaration-extends.js.snap.json | 6 + .../interface/type-parameter-declaration.js | 0 .../type-parameter-declaration.js.snap.json | 6 + .../type-parameters/tagged-template.js | 2 + .../tagged-template.js.snap.json | 30 ++ .../type-decl/body-reference.js | 0 .../type-decl/body-reference.js.snap.json | 6 + .../type-decl/type-param-reference.js | 0 .../type-param-reference.js.snap.json | 6 + .../type-parameter-declaration-extends.js | 0 ...parameter-declaration-extends.js.snap.json | 6 + .../type-decl/type-parameter-declaration.js | 0 .../type-parameter-declaration.js.snap.json | 6 + .../type-declaration/type-query-qualified.js | 1 + .../type-query-qualified.js.snap.json | 8 + .../type-query-with-parameters.js | 4 + .../type-query-with-parameters.js.snap.json | 29 ++ .../type-declaration/type-query.js | 1 + .../type-declaration/type-query.js.snap.json | 8 + .../type-declaration/type1.js | 0 .../type-declaration/type1.js.snap.json | 6 + .../type-declaration/type2.js | 0 .../type-declaration/type2.js.snap.json | 6 + .../type-declaration/type3.js | 0 .../type-declaration/type3.js.snap.json | 6 + .../typeof-import-type-with-qualifier.js | 0 ...of-import-type-with-qualifier.js.snap.json | 6 + .../plugin-rsc/src/transforms/scope.test.ts | 4 +- 586 files changed, 8993 insertions(+), 2 deletions(-) create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/global-augmentation.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/global-augmentation.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/import.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/import.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional-nested.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional-nested.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional3.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional3.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional4.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional4.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional5.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional5.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/array-pattern.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/array-pattern.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/object-pattern.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/object-pattern.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/rest-element.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/rest-element.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-qualifier.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-qualifier.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-type-params.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-type-params.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/infer-type-constraint.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/infer-type-constraint.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type3.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type3.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-no-references.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-no-references.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-referenced.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-referenced.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/qualified-name.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/qualified-name.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call-generics.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call-generics.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct-generics.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct-generics.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/index-sig.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/index-sig.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-generics.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-generics.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled-rest.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled-rest.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-rest.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-rest.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/body-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/body-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-param-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-param-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration-extends.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration-extends.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/body-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/body-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-param-reference.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-param-reference.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type1.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type1.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type2.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type2.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type3.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type3.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/typeof-import-type-with-qualifier.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/typeof-import-type-with-qualifier.js.snap.json diff --git a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts index 5e6182794..755dd8237 100644 --- a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts +++ b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts @@ -65,7 +65,7 @@ async function main(): Promise { compilerOptions: { target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.ESNext, - jsx: ts.JsxEmit.Preserve, + jsx: ts.JsxEmit.ReactJSX, experimentalDecorators: true, useDefineForClassFields: false, }, diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js new file mode 100644 index 000000000..323afb03d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js @@ -0,0 +1,4 @@ +const a = 1 +{ + a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js.snap.json new file mode 100644 index 000000000..450b3bbb7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js.snap.json @@ -0,0 +1,20 @@ +{ + "type": "Program", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js new file mode 100644 index 000000000..ae99601bb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js @@ -0,0 +1,6 @@ +{ + let i = 20 + let j = 1 + i +} +j diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js.snap.json new file mode 100644 index 000000000..6570e7248 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js.snap.json @@ -0,0 +1,26 @@ +{ + "type": "Program", + "declarations": [], + "references": [ + { + "name": "j", + "declaredAt": null + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "i", + "j" + ], + "references": [ + { + "name": "i", + "declaredAt": "Program > BlockStatement" + } + ], + "children": [] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js new file mode 100644 index 000000000..4e873fcb2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js @@ -0,0 +1,4 @@ +const foo = () => {} +const a = 1 +foo(a) +foo?.(a) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js.snap.json new file mode 100644 index 000000000..136b590a1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js.snap.json @@ -0,0 +1,40 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [ + { + "name": "foo", + "declaredAt": "Program" + }, + { + "name": "a", + "declaredAt": "Program" + }, + { + "name": "foo", + "declaredAt": "Program" + }, + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js new file mode 100644 index 000000000..eb28ef440 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js @@ -0,0 +1 @@ +foo() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js.snap.json new file mode 100644 index 000000000..f7dad41f9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js.snap.json @@ -0,0 +1,11 @@ +{ + "type": "Program", + "declarations": [], + "references": [ + { + "name": "foo", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js new file mode 100644 index 000000000..1b7e86768 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js @@ -0,0 +1,2 @@ +const T = 1 +foo() // should not resolve to value diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js.snap.json new file mode 100644 index 000000000..0a6aac5fe --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "T" + ], + "references": [ + { + "name": "foo", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js new file mode 100644 index 000000000..07a7fb3d0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js @@ -0,0 +1,2 @@ +try { +} catch ([a, [b], c = 1, ...d]) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js.snap.json new file mode 100644 index 000000000..dcacff70c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js.snap.json @@ -0,0 +1,31 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + }, + { + "type": "CatchClause", + "declarations": [ + "a", + "b", + "c", + "d" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js new file mode 100644 index 000000000..8873ba210 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js @@ -0,0 +1,2 @@ +try { +} catch ({ a, x: b, y: { c }, d = 1, ...e }) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js.snap.json new file mode 100644 index 000000000..37ffa1326 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js.snap.json @@ -0,0 +1,32 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + }, + { + "type": "CatchClause", + "declarations": [ + "a", + "b", + "c", + "d", + "e" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js new file mode 100644 index 000000000..f041d40c5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js @@ -0,0 +1,5 @@ +const a = 1 +try { +} catch (e) { + a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js.snap.json new file mode 100644 index 000000000..e9970c177 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js.snap.json @@ -0,0 +1,35 @@ +{ + "type": "Program", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + }, + { + "type": "CatchClause", + "declarations": [ + "e" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js new file mode 100644 index 000000000..1cd0412dc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js @@ -0,0 +1,7 @@ +try { +} catch (e) { + e + let a = 1 +} +const unresolved = e +const dontReference2 = a diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js.snap.json new file mode 100644 index 000000000..9c16ce970 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js.snap.json @@ -0,0 +1,47 @@ +{ + "type": "Program", + "declarations": [ + "dontReference2", + "unresolved" + ], + "references": [ + { + "name": "e", + "declaredAt": null + }, + { + "name": "a", + "declaredAt": null + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + }, + { + "type": "CatchClause", + "declarations": [ + "e" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "a" + ], + "references": [ + { + "name": "e", + "declaredAt": "Program > CatchClause" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js new file mode 100644 index 000000000..4e6a6de65 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js @@ -0,0 +1 @@ +class Foo {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js.snap.json new file mode 100644 index 000000000..bae86bc58 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js new file mode 100644 index 000000000..4e6a6de65 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js @@ -0,0 +1 @@ +class Foo {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js.snap.json new file mode 100644 index 000000000..bae86bc58 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js new file mode 100644 index 000000000..a869c2849 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js @@ -0,0 +1 @@ +class A {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js.snap.json new file mode 100644 index 000000000..91d17a9e2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "A" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js new file mode 100644 index 000000000..a869c2849 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js @@ -0,0 +1 @@ +class A {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js.snap.json new file mode 100644 index 000000000..91d17a9e2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "A" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js new file mode 100644 index 000000000..5c4cbf5f0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js @@ -0,0 +1,8 @@ +const x = 1 +class A { + constructor() { + this.prop1 = 1 + this.prop2 = x + } +} +const unresolved = prop1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js.snap.json new file mode 100644 index 000000000..9f7173c9b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js.snap.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "declarations": [ + "A", + "unresolved", + "x" + ], + "references": [ + { + "name": "prop1", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js new file mode 100644 index 000000000..76c82270d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js @@ -0,0 +1,9 @@ +var _a +const outer1 = 'a' +const outer2 = 'b' +class A { + constructor() { + this[_a] = 1 + } + [((_a = outer1), outer2)]() {} +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js.snap.json new file mode 100644 index 000000000..c66443fdb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js.snap.json @@ -0,0 +1,56 @@ +{ + "type": "Program", + "declarations": [ + "A", + "_a", + "outer1", + "outer2" + ], + "references": [ + { + "name": "_a", + "declaredAt": "Program" + }, + { + "name": "outer1", + "declaredAt": "Program" + }, + { + "name": "outer2", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "_a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js new file mode 100644 index 000000000..a16946fd6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js @@ -0,0 +1,2 @@ +class A {} +class B extends A {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js.snap.json new file mode 100644 index 000000000..dfd30670f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js.snap.json @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "A", + "B" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js new file mode 100644 index 000000000..a16946fd6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js @@ -0,0 +1,2 @@ +class A {} +class B extends A {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js.snap.json new file mode 100644 index 000000000..dfd30670f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js.snap.json @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "A", + "B" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js new file mode 100644 index 000000000..dcde0c7bf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js @@ -0,0 +1 @@ +class Foo extends Bar {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js.snap.json new file mode 100644 index 000000000..cbaf1f1ee --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Bar", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js new file mode 100644 index 000000000..4e6a6de65 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js @@ -0,0 +1 @@ +class Foo {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js.snap.json new file mode 100644 index 000000000..bae86bc58 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js new file mode 100644 index 000000000..4e6a6de65 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js @@ -0,0 +1 @@ +class Foo {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js.snap.json new file mode 100644 index 000000000..bae86bc58 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js new file mode 100644 index 000000000..3a43d09b4 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js @@ -0,0 +1 @@ +class B {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js.snap.json new file mode 100644 index 000000000..cf5fb0075 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "B" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js new file mode 100644 index 000000000..3a43d09b4 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js @@ -0,0 +1 @@ +class B {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js.snap.json new file mode 100644 index 000000000..cf5fb0075 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "B" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js new file mode 100644 index 000000000..4e6a6de65 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js @@ -0,0 +1 @@ +class Foo {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js.snap.json new file mode 100644 index 000000000..bae86bc58 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js new file mode 100644 index 000000000..491bf19b1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js @@ -0,0 +1,10 @@ +// https://github.com/typescript-eslint/typescript-eslint/issues/2941 +class A { + constructor(printName) { + this.printName = printName + } + openPort(printerName = this.printerName) { + this.tscOcx.ActiveXopenport(printerName) + return this + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js.snap.json new file mode 100644 index 000000000..4b5e695be --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js.snap.json @@ -0,0 +1,49 @@ +{ + "type": "Program", + "declarations": [ + "A" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "printName" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "printName", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [ + "printerName" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "printerName", + "declaredAt": "Program > FunctionExpression[2]" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js new file mode 100644 index 000000000..ceb749075 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js @@ -0,0 +1,7 @@ +class A { + method(a, [b], { c }, d = 1, e = a, f) { + a + } +} +const unresolved1 = f +const unresolved2 = method diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js.snap.json new file mode 100644 index 000000000..63dd94893 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js.snap.json @@ -0,0 +1,50 @@ +{ + "type": "Program", + "declarations": [ + "A", + "unresolved1", + "unresolved2" + ], + "references": [ + { + "name": "f", + "declaredAt": null + }, + { + "name": "method", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "a", + "b", + "c", + "d", + "e", + "f" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js new file mode 100644 index 000000000..1ec3cc66b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js @@ -0,0 +1,2 @@ +class A {} +new A() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js.snap.json new file mode 100644 index 000000000..cbeafe6bf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "A" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js new file mode 100644 index 000000000..ddd9ad121 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js @@ -0,0 +1,13 @@ +const outer = 1 +class A { + constructor(a, b = 1, c = a, d = outer, e, f) { + this.a = a + this.b = b + this.c = c + this.d = d + this.e = e + this.f = f + a + } +} +const unresovled = e diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js.snap.json new file mode 100644 index 000000000..49b4909af --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js.snap.json @@ -0,0 +1,74 @@ +{ + "type": "Program", + "declarations": [ + "A", + "outer", + "unresovled" + ], + "references": [ + { + "name": "e", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "a", + "b", + "c", + "d", + "e", + "f" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "outer", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "b", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "e", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "f", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js new file mode 100644 index 000000000..444b1862d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js @@ -0,0 +1,6 @@ +class Foo { + #bar + constructor() { + this.#bar = 1 + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js.snap.json new file mode 100644 index 000000000..08cba24c1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js new file mode 100644 index 000000000..a869c2849 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js @@ -0,0 +1 @@ +class A {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js.snap.json new file mode 100644 index 000000000..91d17a9e2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "A" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js new file mode 100644 index 000000000..5c4cbf5f0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js @@ -0,0 +1,8 @@ +const x = 1 +class A { + constructor() { + this.prop1 = 1 + this.prop2 = x + } +} +const unresolved = prop1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js.snap.json new file mode 100644 index 000000000..9f7173c9b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js.snap.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "declarations": [ + "A", + "unresolved", + "x" + ], + "references": [ + { + "name": "prop1", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js new file mode 100644 index 000000000..93b92f6cf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js @@ -0,0 +1,3 @@ +class A { + static {} +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js.snap.json new file mode 100644 index 000000000..91d17a9e2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "A" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js new file mode 100644 index 000000000..99870b8d6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js @@ -0,0 +1,6 @@ +function f() {} +class A { + static { + f() + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js.snap.json new file mode 100644 index 000000000..44f702b57 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js.snap.json @@ -0,0 +1,28 @@ +{ + "type": "Program", + "declarations": [ + "A", + "f" + ], + "references": [ + { + "name": "f", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:f", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js new file mode 100644 index 000000000..da6395ddd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js @@ -0,0 +1,8 @@ +// https://github.com/typescript-eslint/typescript-eslint/issues/5577 +function f() {} +class A { + static {} + constructor() { + f() + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js.snap.json new file mode 100644 index 000000000..f405ff24d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js.snap.json @@ -0,0 +1,41 @@ +{ + "type": "Program", + "declarations": [ + "A", + "f" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:f", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "f", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js new file mode 100644 index 000000000..a6eac7190 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js @@ -0,0 +1,2 @@ +class A {} +const v = A diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js.snap.json new file mode 100644 index 000000000..0bc7e6d2c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js.snap.json @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "A", + "v" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js new file mode 100644 index 000000000..a0391181f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js @@ -0,0 +1,9 @@ +var _a +const outer1 = 'a' +const outer2 = 'b' +const A = class { + constructor() { + this[_a] = 1 + } + [((_a = outer1), outer2)]() {} +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js.snap.json new file mode 100644 index 000000000..c66443fdb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js.snap.json @@ -0,0 +1,56 @@ +{ + "type": "Program", + "declarations": [ + "A", + "_a", + "outer1", + "outer2" + ], + "references": [ + { + "name": "_a", + "declaredAt": "Program" + }, + { + "name": "outer1", + "declaredAt": "Program" + }, + { + "name": "outer2", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "_a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js new file mode 100644 index 000000000..7e7ad6043 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js @@ -0,0 +1,2 @@ +class A {} +const B = class extends A {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js.snap.json new file mode 100644 index 000000000..dfd30670f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js.snap.json @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "A", + "B" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js new file mode 100644 index 000000000..5d8cea7ec --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js @@ -0,0 +1,7 @@ +const A = class { + method(a, [b], { c }, d = 1, e = a, f) { + a + } +} +const unresolved1 = f +const unresolved2 = method diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js.snap.json new file mode 100644 index 000000000..63dd94893 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js.snap.json @@ -0,0 +1,50 @@ +{ + "type": "Program", + "declarations": [ + "A", + "unresolved1", + "unresolved2" + ], + "references": [ + { + "name": "f", + "declaredAt": null + }, + { + "name": "method", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "a", + "b", + "c", + "d", + "e", + "f" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js new file mode 100644 index 000000000..69ef25f54 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js @@ -0,0 +1,2 @@ +const A = class {} +new A() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js.snap.json new file mode 100644 index 000000000..cbeafe6bf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "A" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js new file mode 100644 index 000000000..21461869b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js @@ -0,0 +1,13 @@ +const outer = 1 +const A = class { + constructor(a, b = 1, c = a, d = outer, e, f) { + this.a = a + this.b = b + this.c = c + this.d = d + this.e = e + this.f = f + a + } +} +const unresovled = e diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js.snap.json new file mode 100644 index 000000000..49b4909af --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js.snap.json @@ -0,0 +1,74 @@ +{ + "type": "Program", + "declarations": [ + "A", + "outer", + "unresovled" + ], + "references": [ + { + "name": "e", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "a", + "b", + "c", + "d", + "e", + "f" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "outer", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "b", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "e", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "f", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js new file mode 100644 index 000000000..99825a5a2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js @@ -0,0 +1,6 @@ +const Foo = class { + #bar + constructor() { + this.#bar = 1 + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js.snap.json new file mode 100644 index 000000000..08cba24c1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js new file mode 100644 index 000000000..af6375fbf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js @@ -0,0 +1,8 @@ +const x = 1 +const A = class { + constructor() { + this.prop1 = 1 + this.prop2 = x + } +} +const unresolved = prop diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js.snap.json new file mode 100644 index 000000000..047501b5c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js.snap.json @@ -0,0 +1,34 @@ +{ + "type": "Program", + "declarations": [ + "A", + "unresolved", + "x" + ], + "references": [ + { + "name": "prop", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js new file mode 100644 index 000000000..0e424fe88 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js @@ -0,0 +1,3 @@ +const A = class A + // this A references the class A, not the variable A + extends A {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js.snap.json new file mode 100644 index 000000000..cbeafe6bf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "A" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js new file mode 100644 index 000000000..0a67dcd26 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js @@ -0,0 +1,28 @@ +var __decorate = + (this && this.__decorate) || + function (decorators, target, key, desc) { + var c = arguments.length, + r = + c < 3 + ? target + : desc === null + ? (desc = Object.getOwnPropertyDescriptor(target, key)) + : desc, + d + if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') + r = Reflect.decorate(decorators, target, key, desc) + else + for (var i = decorators.length - 1; i >= 0; i--) + if ((d = decorators[i])) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r + return (c > 3 && r && Object.defineProperty(target, key, r), r) + } +function decorator() {} +class Foo { + get foo() { + return 1 + } + set bar(value) {} +} +__decorate([decorator], Foo.prototype, 'foo', null) +__decorate([decorator], Foo.prototype, 'bar', null) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js.snap.json new file mode 100644 index 000000000..ad86862e5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js.snap.json @@ -0,0 +1,280 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "__decorate", + "decorator" + ], + "references": [ + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "c", + "d", + "decorators", + "desc", + "i", + "key", + "r", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arguments", + "declaredAt": null + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [], + "references": [ + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + }, + { + "type": "FunctionDeclaration:decorator", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[3]", + "declarations": [ + "value" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js new file mode 100644 index 000000000..237c90943 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js @@ -0,0 +1,31 @@ +// https://github.com/typescript-eslint/typescript-eslint/issues/2942 +var __decorate = + (this && this.__decorate) || + function (decorators, target, key, desc) { + var c = arguments.length, + r = + c < 3 + ? target + : desc === null + ? (desc = Object.getOwnPropertyDescriptor(target, key)) + : desc, + d + if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') + r = Reflect.decorate(decorators, target, key, desc) + else + for (var i = decorators.length - 1; i >= 0; i--) + if ((d = decorators[i])) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r + return (c > 3 && r && Object.defineProperty(target, key, r), r) + } +let Foo = class Foo {} +Foo = __decorate( + [ + deco({ + components: { + val: true, + }, + }), + ], + Foo, +) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js.snap.json new file mode 100644 index 000000000..67e087fe6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js.snap.json @@ -0,0 +1,230 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "__decorate" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "deco", + "declaredAt": null + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "c", + "d", + "decorators", + "desc", + "i", + "key", + "r", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arguments", + "declaredAt": null + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [], + "references": [ + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js new file mode 100644 index 000000000..d9b868026 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js @@ -0,0 +1,22 @@ +var __decorate = + (this && this.__decorate) || + function (decorators, target, key, desc) { + var c = arguments.length, + r = + c < 3 + ? target + : desc === null + ? (desc = Object.getOwnPropertyDescriptor(target, key)) + : desc, + d + if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') + r = Reflect.decorate(decorators, target, key, desc) + else + for (var i = decorators.length - 1; i >= 0; i--) + if ((d = decorators[i])) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r + return (c > 3 && r && Object.defineProperty(target, key, r), r) + } +function decorator() {} +class Foo {} +__decorate([decorator], Foo.prototype, 'foo', void 0) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js.snap.json new file mode 100644 index 000000000..aa0f85797 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js.snap.json @@ -0,0 +1,240 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "__decorate", + "decorator" + ], + "references": [ + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "c", + "d", + "decorators", + "desc", + "i", + "key", + "r", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arguments", + "declaredAt": null + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [], + "references": [ + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + }, + { + "type": "FunctionDeclaration:decorator", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js new file mode 100644 index 000000000..f9987c8af --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js @@ -0,0 +1,22 @@ +var __decorate = + (this && this.__decorate) || + function (decorators, target, key, desc) { + var c = arguments.length, + r = + c < 3 + ? target + : desc === null + ? (desc = Object.getOwnPropertyDescriptor(target, key)) + : desc, + d + if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') + r = Reflect.decorate(decorators, target, key, desc) + else + for (var i = decorators.length - 1; i >= 0; i--) + if ((d = decorators[i])) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r + return (c > 3 && r && Object.defineProperty(target, key, r), r) + } +function decorator() {} +let Foo = class Foo {} +Foo = __decorate([decorator], Foo) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js.snap.json new file mode 100644 index 000000000..7d60027bf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js.snap.json @@ -0,0 +1,244 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "__decorate", + "decorator" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "c", + "d", + "decorators", + "desc", + "i", + "key", + "r", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arguments", + "declaredAt": null + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [], + "references": [ + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + }, + { + "type": "FunctionDeclaration:decorator", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js new file mode 100644 index 000000000..211147e2d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js @@ -0,0 +1,24 @@ +var __decorate = + (this && this.__decorate) || + function (decorators, target, key, desc) { + var c = arguments.length, + r = + c < 3 + ? target + : desc === null + ? (desc = Object.getOwnPropertyDescriptor(target, key)) + : desc, + d + if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') + r = Reflect.decorate(decorators, target, key, desc) + else + for (var i = decorators.length - 1; i >= 0; i--) + if ((d = decorators[i])) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r + return (c > 3 && r && Object.defineProperty(target, key, r), r) + } +function decorator() {} +class Foo { + foo() {} +} +__decorate([decorator], Foo.prototype, 'foo', null) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js.snap.json new file mode 100644 index 000000000..8e0bb9d07 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js.snap.json @@ -0,0 +1,253 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "__decorate", + "decorator" + ], + "references": [ + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "c", + "d", + "decorators", + "desc", + "i", + "key", + "r", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arguments", + "declaredAt": null + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [], + "references": [ + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + }, + { + "type": "FunctionDeclaration:decorator", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js new file mode 100644 index 000000000..6e8cdcf27 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js @@ -0,0 +1,34 @@ +var __decorate = + (this && this.__decorate) || + function (decorators, target, key, desc) { + var c = arguments.length, + r = + c < 3 + ? target + : desc === null + ? (desc = Object.getOwnPropertyDescriptor(target, key)) + : desc, + d + if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') + r = Reflect.decorate(decorators, target, key, desc) + else + for (var i = decorators.length - 1; i >= 0; i--) + if ((d = decorators[i])) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r + return (c > 3 && r && Object.defineProperty(target, key, r), r) + } +var __param = + (this && this.__param) || + function (paramIndex, decorator) { + return function (target, key) { + decorator(target, key, paramIndex) + } + } +function decorator() {} +let Foo = class Foo { + constructor(a, b = 1) { + this.a = a + this.b = b + } +} +Foo = __decorate([__param(0, decorator), __param(1, decorator)], Foo) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js.snap.json new file mode 100644 index 000000000..59afe51c7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js.snap.json @@ -0,0 +1,332 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "__decorate", + "__param", + "decorator" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "__param", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "__param", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "c", + "d", + "decorators", + "desc", + "i", + "key", + "r", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arguments", + "declaredAt": null + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [], + "references": [ + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [ + "decorator", + "paramIndex" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "key", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "decorator", + "declaredAt": "Program > FunctionExpression[2]" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression[2] > BlockStatement > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression[2] > BlockStatement > FunctionExpression" + }, + { + "name": "paramIndex", + "declaredAt": "Program > FunctionExpression[2]" + } + ], + "children": [] + } + ] + } + ] + } + ] + }, + { + "type": "FunctionDeclaration:decorator", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[3]", + "declarations": [ + "a", + "b" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression[3]" + }, + { + "name": "b", + "declaredAt": "Program > FunctionExpression[3]" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js new file mode 100644 index 000000000..3f4b05c19 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js @@ -0,0 +1,43 @@ +var __decorate = + (this && this.__decorate) || + function (decorators, target, key, desc) { + var c = arguments.length, + r = + c < 3 + ? target + : desc === null + ? (desc = Object.getOwnPropertyDescriptor(target, key)) + : desc, + d + if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') + r = Reflect.decorate(decorators, target, key, desc) + else + for (var i = decorators.length - 1; i >= 0; i--) + if ((d = decorators[i])) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r + return (c > 3 && r && Object.defineProperty(target, key, r), r) + } +var __param = + (this && this.__param) || + function (paramIndex, decorator) { + return function (target, key) { + decorator(target, key, paramIndex) + } + } +function decorator() {} +class A { + foo(a, [b], { c }, d = 1, decorator, decorator) {} +} +__decorate( + [ + __param(0, decorator), + __param(1, decorator), + __param(2, decorator), + __param(3, decorator), + __param(4, decorator), + __param(5, d), + ], + A.prototype, + 'foo', + null, +) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js.snap.json new file mode 100644 index 000000000..31e6649a4 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js.snap.json @@ -0,0 +1,354 @@ +{ + "type": "Program", + "declarations": [ + "A", + "__decorate", + "__param", + "decorator" + ], + "references": [ + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "__param", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "__param", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "__param", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "__param", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "__param", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "__param", + "declaredAt": "Program" + }, + { + "name": "d", + "declaredAt": null + }, + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "c", + "d", + "decorators", + "desc", + "i", + "key", + "r", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arguments", + "declaredAt": null + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [], + "references": [ + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [ + "decorator", + "paramIndex" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "key", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "decorator", + "declaredAt": "Program > FunctionExpression[2]" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression[2] > BlockStatement > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression[2] > BlockStatement > FunctionExpression" + }, + { + "name": "paramIndex", + "declaredAt": "Program > FunctionExpression[2]" + } + ], + "children": [] + } + ] + } + ] + } + ] + }, + { + "type": "FunctionDeclaration:decorator", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[3]", + "declarations": [ + "a", + "b", + "c", + "d", + "decorator" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js new file mode 100644 index 000000000..02fa2c1d4 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js @@ -0,0 +1,24 @@ +var __decorate = + (this && this.__decorate) || + function (decorators, target, key, desc) { + var c = arguments.length, + r = + c < 3 + ? target + : desc === null + ? (desc = Object.getOwnPropertyDescriptor(target, key)) + : desc, + d + if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') + r = Reflect.decorate(decorators, target, key, desc) + else + for (var i = decorators.length - 1; i >= 0; i--) + if ((d = decorators[i])) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r + return (c > 3 && r && Object.defineProperty(target, key, r), r) + } +function decorator() {} +let Foo = class Foo { + bar(baz) {} +} +Foo = __decorate([decorator], Foo) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js.snap.json new file mode 100644 index 000000000..f7ac7eb95 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js.snap.json @@ -0,0 +1,259 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "__decorate", + "decorator" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "__decorate", + "declaredAt": "Program" + }, + { + "name": "decorator", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "c", + "d", + "decorators", + "desc", + "i", + "key", + "r", + "target" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arguments", + "declaredAt": null + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Reflect", + "declaredAt": null + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "desc", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Object", + "declaredAt": null + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "ForStatement", + "declarations": [], + "references": [ + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "decorators", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "i", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "c", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "d", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "target", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "key", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "r", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + }, + { + "type": "FunctionDeclaration:decorator", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [ + "baz" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js new file mode 100644 index 000000000..b944a8d36 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js @@ -0,0 +1,3 @@ +const obj = {} +let b, c +;[obj.a, b, [c]] = [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js.snap.json new file mode 100644 index 000000000..ba9465be5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js.snap.json @@ -0,0 +1,23 @@ +{ + "type": "Program", + "declarations": [ + "b", + "c", + "obj" + ], + "references": [ + { + "name": "obj", + "declaredAt": "Program" + }, + { + "name": "b", + "declaredAt": "Program" + }, + { + "name": "c", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js new file mode 100644 index 000000000..8536aa772 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js @@ -0,0 +1 @@ +const [a, b, c, d = 1, [e], [f] = g, ...rest] = [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js.snap.json new file mode 100644 index 000000000..f8818040b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js.snap.json @@ -0,0 +1,19 @@ +{ + "type": "Program", + "declarations": [ + "a", + "b", + "c", + "d", + "e", + "f", + "rest" + ], + "references": [ + { + "name": "g", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js new file mode 100644 index 000000000..2c942a87c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js @@ -0,0 +1,6 @@ +const obj = {} +;({ + shorthand, + key: value, + hello: { world: obj.a }, +} = object) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js.snap.json new file mode 100644 index 000000000..ba166ae60 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js.snap.json @@ -0,0 +1,25 @@ +{ + "type": "Program", + "declarations": [ + "obj" + ], + "references": [ + { + "name": "shorthand", + "declaredAt": null + }, + { + "name": "value", + "declaredAt": null + }, + { + "name": "obj", + "declaredAt": "Program" + }, + { + "name": "object", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js new file mode 100644 index 000000000..2311cfa00 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js @@ -0,0 +1,6 @@ +const { + shorthand, + key: value, + hello: { world }, + array: [a, b, c, d], +} = object diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js.snap.json new file mode 100644 index 000000000..8578eb6ba --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js.snap.json @@ -0,0 +1,19 @@ +{ + "type": "Program", + "declarations": [ + "a", + "b", + "c", + "d", + "shorthand", + "value", + "world" + ], + "references": [ + { + "name": "object", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js new file mode 100644 index 000000000..114b4e0df --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js @@ -0,0 +1,3 @@ +//// @sourceType = module +export * from 'foo' +export * as bar from 'foo' diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js.snap.json new file mode 100644 index 000000000..c2bf84840 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js.snap.json @@ -0,0 +1,11 @@ +{ + "type": "Program", + "declarations": [], + "references": [ + { + "name": "bar", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js new file mode 100644 index 000000000..141602344 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const T = 1 // unreferenced +export default T diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js.snap.json new file mode 100644 index 000000000..31b6fb6bf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "T" + ], + "references": [ + { + "name": "T", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js new file mode 100644 index 000000000..90a382f86 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export default function f() {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js.snap.json new file mode 100644 index 000000000..3c616f0ce --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "f" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:f", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js new file mode 100644 index 000000000..d0264e6ba --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const a = 1 +export default a diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js.snap.json new file mode 100644 index 000000000..942fe4195 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "a" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js new file mode 100644 index 000000000..a3e655494 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export default 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js new file mode 100644 index 000000000..88b7416a3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export default function () {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js.snap.json new file mode 100644 index 000000000..ced604c0c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js.snap.json @@ -0,0 +1,20 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [ + { + "type": "FunctionDeclaration", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js new file mode 100644 index 000000000..a58f4e869 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const x = 1 +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js new file mode 100644 index 000000000..7d557b8b6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js new file mode 100644 index 000000000..336ce12bb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js @@ -0,0 +1 @@ +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js new file mode 100644 index 000000000..336ce12bb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js @@ -0,0 +1 @@ +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js new file mode 100644 index 000000000..70a39188e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js @@ -0,0 +1,2 @@ +const T = 1 +export { T } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js.snap.json new file mode 100644 index 000000000..31b6fb6bf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "T" + ], + "references": [ + { + "name": "T", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js new file mode 100644 index 000000000..28686f354 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export { x } from 'foo' diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js.snap.json new file mode 100644 index 000000000..393f571ea --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js.snap.json @@ -0,0 +1,11 @@ +{ + "type": "Program", + "declarations": [], + "references": [ + { + "name": "x", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js new file mode 100644 index 000000000..e761a257b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export { v as x } from 'foo' diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js.snap.json new file mode 100644 index 000000000..df2af3e13 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js.snap.json @@ -0,0 +1,11 @@ +{ + "type": "Program", + "declarations": [], + "references": [ + { + "name": "v", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js new file mode 100644 index 000000000..7d557b8b6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js new file mode 100644 index 000000000..4d017d783 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export const x = 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js new file mode 100644 index 000000000..7d557b8b6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js new file mode 100644 index 000000000..b27af8dce --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const a = 1 +export { a } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js.snap.json new file mode 100644 index 000000000..942fe4195 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "a" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js new file mode 100644 index 000000000..7d557b8b6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js new file mode 100644 index 000000000..7b72f6476 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const v = 1 +export { v as x } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js.snap.json new file mode 100644 index 000000000..20cab1f82 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "v" + ], + "references": [ + { + "name": "v", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js new file mode 100644 index 000000000..d990beba1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const T = 1 // unreferenced +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js.snap.json new file mode 100644 index 000000000..4a4b769d5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "T" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js new file mode 100644 index 000000000..d990beba1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const T = 1 // unreferenced +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js.snap.json new file mode 100644 index 000000000..4a4b769d5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "T" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js new file mode 100644 index 000000000..5b114aab0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js @@ -0,0 +1,5 @@ +let a +// the default param value is resolved to the outer scope +let foo = (b = a) => { + let a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js.snap.json new file mode 100644 index 000000000..8a03fe757 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js.snap.json @@ -0,0 +1,32 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "a" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js new file mode 100644 index 000000000..ac1ac6a07 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js @@ -0,0 +1,2 @@ +const a = 0 +let foo = (b = a) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js.snap.json new file mode 100644 index 000000000..41a73c0bb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js new file mode 100644 index 000000000..0f9aa2cc0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js @@ -0,0 +1,2 @@ +let a +let foo = (b = a) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js.snap.json new file mode 100644 index 000000000..41a73c0bb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js new file mode 100644 index 000000000..797f7c598 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js @@ -0,0 +1,8 @@ +let a +let foo = ( + b = function () { + a + }, +) => { + let a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js.snap.json new file mode 100644 index 000000000..8122a466f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js.snap.json @@ -0,0 +1,45 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "b" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + }, + { + "type": "BlockStatement", + "declarations": [ + "a" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js new file mode 100644 index 000000000..e33fd0e2b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js @@ -0,0 +1,6 @@ +let a +let foo = ( + b = function () { + return a + }, +) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js.snap.json new file mode 100644 index 000000000..0879f3409 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js.snap.json @@ -0,0 +1,43 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "b" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + }, + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js new file mode 100644 index 000000000..f7a054970 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js @@ -0,0 +1,3 @@ +let a +// the default param value is resolved to the parameter +let foo = (b = a, a) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js.snap.json new file mode 100644 index 000000000..f80cc3308 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js.snap.json @@ -0,0 +1,31 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "a", + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > ArrowFunction" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js new file mode 100644 index 000000000..2904a4a5b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js @@ -0,0 +1,2 @@ +let a +let foo = (b = a.c) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js.snap.json new file mode 100644 index 000000000..41a73c0bb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js new file mode 100644 index 000000000..5c1b057f3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js @@ -0,0 +1 @@ +let foo = (a, b = 0) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js.snap.json new file mode 100644 index 000000000..711ef93dd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js.snap.json @@ -0,0 +1,25 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "a", + "b" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js new file mode 100644 index 000000000..878aa1aa3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js @@ -0,0 +1,4 @@ +const parentScoped = 1 +;() => { + parentScoped + 1 +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js.snap.json new file mode 100644 index 000000000..1ee5c56cd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "parentScoped" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "parentScoped", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js new file mode 100644 index 000000000..6297dfbd7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js @@ -0,0 +1 @@ +;(a) => a diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js.snap.json new file mode 100644 index 000000000..e48c6db43 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js.snap.json @@ -0,0 +1,20 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "a" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > ArrowFunction" + } + ], + "children": [] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js new file mode 100644 index 000000000..7ef766a65 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js @@ -0,0 +1,5 @@ +const outer = 1 +;(a, [b], { c }, d = 1, e = a, f = outer, g) => { + a +} +const unresolved = g diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js.snap.json new file mode 100644 index 000000000..a82edf5e1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js.snap.json @@ -0,0 +1,50 @@ +{ + "type": "Program", + "declarations": [ + "outer", + "unresolved" + ], + "references": [ + { + "name": "g", + "declaredAt": null + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > ArrowFunction" + }, + { + "name": "outer", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > ArrowFunction" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js new file mode 100644 index 000000000..5f758fa3f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js @@ -0,0 +1,6 @@ +const arrow = () => { + let i = 0 + var j = 20 + i +} +const unresolved = j diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js.snap.json new file mode 100644 index 000000000..7c73aa937 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js.snap.json @@ -0,0 +1,37 @@ +{ + "type": "Program", + "declarations": [ + "arrow", + "unresolved" + ], + "references": [ + { + "name": "j", + "declaredAt": null + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "j" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "i" + ], + "references": [ + { + "name": "i", + "declaredAt": "Program > ArrowFunction > BlockStatement" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js new file mode 100644 index 000000000..63160c8fe --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js @@ -0,0 +1,3 @@ +const foo = () => { + let x +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js.snap.json new file mode 100644 index 000000000..f36ba72b7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "x" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js new file mode 100644 index 000000000..34dbf9dcc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js @@ -0,0 +1 @@ +const foo = (a) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js.snap.json new file mode 100644 index 000000000..bd0bb3dba --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js new file mode 100644 index 000000000..ca3076a93 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js @@ -0,0 +1 @@ +const foo = () => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js.snap.json new file mode 100644 index 000000000..71937a22c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js new file mode 100644 index 000000000..ca3076a93 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js @@ -0,0 +1 @@ +const foo = () => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js.snap.json new file mode 100644 index 000000000..71937a22c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js new file mode 100644 index 000000000..ca3076a93 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js @@ -0,0 +1 @@ +const foo = () => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js.snap.json new file mode 100644 index 000000000..71937a22c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js new file mode 100644 index 000000000..415f5fd99 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js @@ -0,0 +1 @@ +const foo = (arg) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js.snap.json new file mode 100644 index 000000000..eee1ad421 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js new file mode 100644 index 000000000..415f5fd99 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js @@ -0,0 +1 @@ +const foo = (arg) => {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js.snap.json new file mode 100644 index 000000000..eee1ad421 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js new file mode 100644 index 000000000..642e0666b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js @@ -0,0 +1,3 @@ +const foo = (arg) => { + return typeof arg === 'string' +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js.snap.json new file mode 100644 index 000000000..a337d1442 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js.snap.json @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arg", + "declaredAt": "Program > ArrowFunction" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js new file mode 100644 index 000000000..642e0666b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js @@ -0,0 +1,3 @@ +const foo = (arg) => { + return typeof arg === 'string' +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js.snap.json new file mode 100644 index 000000000..a337d1442 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js.snap.json @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arg", + "declaredAt": "Program > ArrowFunction" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js new file mode 100644 index 000000000..9d5a44510 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js @@ -0,0 +1,5 @@ +let a +// the default param value is resolved to the outer scope +function foo(b = a) { + let a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js.snap.json new file mode 100644 index 000000000..477a0dfd0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js.snap.json @@ -0,0 +1,32 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "a" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js new file mode 100644 index 000000000..4b20dd288 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js @@ -0,0 +1,2 @@ +const a = 0 +function foo(b = a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js.snap.json new file mode 100644 index 000000000..38d8a2da7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js new file mode 100644 index 000000000..36b5b7267 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js @@ -0,0 +1,2 @@ +let a +function foo(b = a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js.snap.json new file mode 100644 index 000000000..38d8a2da7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js new file mode 100644 index 000000000..dafa68cca --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js @@ -0,0 +1,8 @@ +let a +function foo( + b = function () { + a + }, +) { + let a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js.snap.json new file mode 100644 index 000000000..adb89868d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js.snap.json @@ -0,0 +1,45 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "b" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + }, + { + "type": "BlockStatement", + "declarations": [ + "a" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js new file mode 100644 index 000000000..3e09fe643 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js @@ -0,0 +1,6 @@ +let a +function foo( + b = function () { + return a + }, +) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js.snap.json new file mode 100644 index 000000000..f75a760d7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js.snap.json @@ -0,0 +1,43 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "b" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + }, + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js new file mode 100644 index 000000000..f5faaeef8 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js @@ -0,0 +1,3 @@ +let a +// the default param value is resolved to the parameter +function foo(b = a, a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js.snap.json new file mode 100644 index 000000000..dd625a1a7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js.snap.json @@ -0,0 +1,31 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a", + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionDeclaration:foo" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js new file mode 100644 index 000000000..efd40a37c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js @@ -0,0 +1,2 @@ +let a +function foo(b = a.c) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js.snap.json new file mode 100644 index 000000000..38d8a2da7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js new file mode 100644 index 000000000..ca81afa12 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js @@ -0,0 +1 @@ +function foo(a, b = 0) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js.snap.json new file mode 100644 index 000000000..97cba679b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js.snap.json @@ -0,0 +1,25 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a", + "b" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js new file mode 100644 index 000000000..edc56dcc7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js @@ -0,0 +1,4 @@ +const parentScoped = 1 +function foo() { + parentScoped + 1 +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js.snap.json new file mode 100644 index 000000000..c497794b3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js.snap.json @@ -0,0 +1,28 @@ +{ + "type": "Program", + "declarations": [ + "foo", + "parentScoped" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "parentScoped", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js new file mode 100644 index 000000000..ae61fc0f0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js @@ -0,0 +1,4 @@ +function Foo() { + const Foo = 1 +} +const usage = Foo diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js.snap.json new file mode 100644 index 000000000..030de67c4 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "usage" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:Foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "Foo" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js new file mode 100644 index 000000000..d0e98917d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js @@ -0,0 +1,3 @@ +function foo(a, b) { + a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js.snap.json new file mode 100644 index 000000000..613b9ae0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a", + "b" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionDeclaration:foo" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js new file mode 100644 index 000000000..1cea9b240 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js @@ -0,0 +1,5 @@ +const outer = 1 +function foo(a, [b], { c }, d = 1, e = a, f = outer, g) { + a +} +const unresolved = g diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js.snap.json new file mode 100644 index 000000000..30252592e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js.snap.json @@ -0,0 +1,51 @@ +{ + "type": "Program", + "declarations": [ + "foo", + "outer", + "unresolved" + ], + "references": [ + { + "name": "g", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionDeclaration:foo" + }, + { + "name": "outer", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionDeclaration:foo" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js new file mode 100644 index 000000000..d8a3800ee --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js @@ -0,0 +1,6 @@ +function foo() { + let i = 0 + var j = 20 + i +} +const unresolved = j diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js.snap.json new file mode 100644 index 000000000..0f4f0f8d9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js.snap.json @@ -0,0 +1,37 @@ +{ + "type": "Program", + "declarations": [ + "foo", + "unresolved" + ], + "references": [ + { + "name": "j", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "j" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "i" + ], + "references": [ + { + "name": "i", + "declaredAt": "Program > FunctionDeclaration:foo > BlockStatement" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js new file mode 100644 index 000000000..6443d2e8e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js @@ -0,0 +1,3 @@ +function foo() { + let x +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js.snap.json new file mode 100644 index 000000000..a06b0b4e1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "x" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js new file mode 100644 index 000000000..ef1dd099d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js @@ -0,0 +1 @@ +function foo(a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js.snap.json new file mode 100644 index 000000000..8c438e1f5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js new file mode 100644 index 000000000..b0400ee9b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js @@ -0,0 +1 @@ +function foo() {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js.snap.json new file mode 100644 index 000000000..d3ec2eb74 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js new file mode 100644 index 000000000..b0400ee9b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js @@ -0,0 +1 @@ +function foo() {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js.snap.json new file mode 100644 index 000000000..d3ec2eb74 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js new file mode 100644 index 000000000..b0400ee9b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js @@ -0,0 +1 @@ +function foo() {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js.snap.json new file mode 100644 index 000000000..d3ec2eb74 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js new file mode 100644 index 000000000..95cb35807 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js @@ -0,0 +1 @@ +function foo(arg) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js.snap.json new file mode 100644 index 000000000..9d413c994 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js new file mode 100644 index 000000000..95cb35807 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js @@ -0,0 +1 @@ +function foo(arg) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js.snap.json new file mode 100644 index 000000000..9d413c994 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js new file mode 100644 index 000000000..c8fcb944f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js @@ -0,0 +1,3 @@ +function foo(arg) { + return typeof arg === 'string' +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js.snap.json new file mode 100644 index 000000000..b89814370 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js.snap.json @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arg", + "declaredAt": "Program > FunctionDeclaration:foo" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js new file mode 100644 index 000000000..c8fcb944f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js @@ -0,0 +1,3 @@ +function foo(arg) { + return typeof arg === 'string' +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js.snap.json new file mode 100644 index 000000000..b89814370 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js.snap.json @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arg", + "declaredAt": "Program > FunctionDeclaration:foo" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js new file mode 100644 index 000000000..afbed624a --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js @@ -0,0 +1 @@ +const foo = function () {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js.snap.json new file mode 100644 index 000000000..becd50173 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js new file mode 100644 index 000000000..94b00926b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js @@ -0,0 +1,5 @@ +let a +// the default param value is resolved to the outer scope +let foo = function (b = a) { + let a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js.snap.json new file mode 100644 index 000000000..3c83223b7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js.snap.json @@ -0,0 +1,32 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "a" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js new file mode 100644 index 000000000..f40cb111e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js @@ -0,0 +1,2 @@ +const a = 0 +let foo = function (b = a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js.snap.json new file mode 100644 index 000000000..202cca1af --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js new file mode 100644 index 000000000..344970b23 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js @@ -0,0 +1,2 @@ +let a +let foo = function (b = a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js.snap.json new file mode 100644 index 000000000..202cca1af --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js new file mode 100644 index 000000000..c046c9254 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js @@ -0,0 +1,8 @@ +let a +let foo = function ( + b = function () { + a + }, +) { + let a +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js.snap.json new file mode 100644 index 000000000..a74e66e39 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js.snap.json @@ -0,0 +1,45 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "b" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + }, + { + "type": "BlockStatement", + "declarations": [ + "a" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js new file mode 100644 index 000000000..8752e1bde --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js @@ -0,0 +1,6 @@ +let a +let foo = function ( + b = function () { + return a + }, +) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js.snap.json new file mode 100644 index 000000000..5e415597d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js.snap.json @@ -0,0 +1,43 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "b" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + }, + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js new file mode 100644 index 000000000..56c650805 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js @@ -0,0 +1,3 @@ +let a +// the default param value is resolved to the parameter +let foo = function (b = a, a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js.snap.json new file mode 100644 index 000000000..f3838d97c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js.snap.json @@ -0,0 +1,31 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "a", + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js new file mode 100644 index 000000000..4ef5cf9ca --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js @@ -0,0 +1,2 @@ +let a +let foo = function (b = a.c) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js.snap.json new file mode 100644 index 000000000..202cca1af --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "a", + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "b" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js new file mode 100644 index 000000000..a572ada6d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js @@ -0,0 +1 @@ +let foo = function (a, b = 0) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js.snap.json new file mode 100644 index 000000000..56294d853 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js.snap.json @@ -0,0 +1,25 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "a", + "b" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js new file mode 100644 index 000000000..a6143e7e7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js @@ -0,0 +1,4 @@ +const parentScoped = 1 +const foo = function () { + parentScoped + 1 +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js.snap.json new file mode 100644 index 000000000..3006fb199 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js.snap.json @@ -0,0 +1,28 @@ +{ + "type": "Program", + "declarations": [ + "foo", + "parentScoped" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "parentScoped", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js new file mode 100644 index 000000000..a26057613 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js @@ -0,0 +1,5 @@ +const outer = 1 +const foo = function (a, [b], { c }, d = 1, e = a, f = outer, g) { + a +} +const unresolved = g diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js.snap.json new file mode 100644 index 000000000..87c99fdfc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js.snap.json @@ -0,0 +1,51 @@ +{ + "type": "Program", + "declarations": [ + "foo", + "outer", + "unresolved" + ], + "references": [ + { + "name": "g", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "outer", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js new file mode 100644 index 000000000..6506b2715 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js @@ -0,0 +1,6 @@ +const foo = function () { + let i = 0 + var j = 20 + i +} +const unresolved = j diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js.snap.json new file mode 100644 index 000000000..715f8c04f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js.snap.json @@ -0,0 +1,37 @@ +{ + "type": "Program", + "declarations": [ + "foo", + "unresolved" + ], + "references": [ + { + "name": "j", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "j" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "i" + ], + "references": [ + { + "name": "i", + "declaredAt": "Program > FunctionExpression > BlockStatement" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js new file mode 100644 index 000000000..041ac325e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js @@ -0,0 +1,3 @@ +const foo = function () { + let x +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js.snap.json new file mode 100644 index 000000000..cb6a6de52 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "x" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js new file mode 100644 index 000000000..a5d6f0e4b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js @@ -0,0 +1 @@ +const foo = function (a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js.snap.json new file mode 100644 index 000000000..4a396499e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js new file mode 100644 index 000000000..afbed624a --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js @@ -0,0 +1 @@ +const foo = function () {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js.snap.json new file mode 100644 index 000000000..becd50173 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js new file mode 100644 index 000000000..afbed624a --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js @@ -0,0 +1 @@ +const foo = function () {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js.snap.json new file mode 100644 index 000000000..becd50173 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js new file mode 100644 index 000000000..afbed624a --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js @@ -0,0 +1 @@ +const foo = function () {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js.snap.json new file mode 100644 index 000000000..becd50173 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js new file mode 100644 index 000000000..f3c92620c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js @@ -0,0 +1 @@ +const foo = function (arg) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js.snap.json new file mode 100644 index 000000000..c0605c864 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js new file mode 100644 index 000000000..f3c92620c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js @@ -0,0 +1 @@ +const foo = function (arg) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js.snap.json new file mode 100644 index 000000000..c0605c864 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js new file mode 100644 index 000000000..553f5c012 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js @@ -0,0 +1,3 @@ +const foo = function (arg) { + return typeof arg === 'string' +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js.snap.json new file mode 100644 index 000000000..45dc9ec32 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js.snap.json @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arg", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js new file mode 100644 index 000000000..553f5c012 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js @@ -0,0 +1,3 @@ +const foo = function (arg) { + return typeof arg === 'string' +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js.snap.json new file mode 100644 index 000000000..45dc9ec32 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js.snap.json @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "arg", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js new file mode 100644 index 000000000..a0c53a48b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js @@ -0,0 +1,3 @@ +//// @sourceType = module +class Foo {} +new Foo() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js.snap.json new file mode 100644 index 000000000..33a3907d9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js new file mode 100644 index 000000000..46bedea68 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js @@ -0,0 +1,3 @@ +//// @sourceType = module +function top() {} +top() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js.snap.json new file mode 100644 index 000000000..97cbefe8c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "top" + ], + "references": [ + { + "name": "top", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:top", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js new file mode 100644 index 000000000..30aeead21 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const top = () => {} +top() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js.snap.json new file mode 100644 index 000000000..f65d12ebc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "top" + ], + "references": [ + { + "name": "top", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js new file mode 100644 index 000000000..4f5adab17 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js @@ -0,0 +1,3 @@ +//// @sourceType = module +let top = () => {} +top() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js.snap.json new file mode 100644 index 000000000..f65d12ebc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "top" + ], + "references": [ + { + "name": "top", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js new file mode 100644 index 000000000..2bac25ca5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js @@ -0,0 +1,3 @@ +//// @sourceType = module +var top = () => {} +top() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js.snap.json new file mode 100644 index 000000000..f65d12ebc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "top" + ], + "references": [ + { + "name": "top", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js new file mode 100644 index 000000000..735e2600b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js @@ -0,0 +1,3 @@ +//// @sourceType = script +class Foo {} +new Foo() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js.snap.json new file mode 100644 index 000000000..33a3907d9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js new file mode 100644 index 000000000..075d9a3a5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js @@ -0,0 +1,3 @@ +//// @sourceType = script +function top() {} +top() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js.snap.json new file mode 100644 index 000000000..97cbefe8c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "top" + ], + "references": [ + { + "name": "top", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:top", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js new file mode 100644 index 000000000..f04faa893 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js @@ -0,0 +1,3 @@ +//// @sourceType = script +const top = () => {} +top() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js.snap.json new file mode 100644 index 000000000..f65d12ebc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "top" + ], + "references": [ + { + "name": "top", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js new file mode 100644 index 000000000..9c6b1424c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js @@ -0,0 +1,3 @@ +//// @sourceType = script +let top = () => {} +top() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js.snap.json new file mode 100644 index 000000000..f65d12ebc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "top" + ], + "references": [ + { + "name": "top", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js new file mode 100644 index 000000000..69f036d85 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js @@ -0,0 +1,3 @@ +//// @sourceType = script +var top = () => {} +top() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js.snap.json new file mode 100644 index 000000000..f65d12ebc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "top" + ], + "references": [ + { + "name": "top", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js new file mode 100644 index 000000000..dd4b5e4f7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js @@ -0,0 +1 @@ +const x = y diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js.snap.json new file mode 100644 index 000000000..9e1c4f342 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "y", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js new file mode 100644 index 000000000..290df9d57 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js @@ -0,0 +1,3 @@ +//// @sourceType = module +import v from 'foo' +v diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js.snap.json new file mode 100644 index 000000000..20cab1f82 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "v" + ], + "references": [ + { + "name": "v", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js new file mode 100644 index 000000000..bcaf0ba3d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js @@ -0,0 +1,3 @@ +//// @sourceType = module +foo +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js.snap.json new file mode 100644 index 000000000..f7dad41f9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js.snap.json @@ -0,0 +1,11 @@ +{ + "type": "Program", + "declarations": [], + "references": [ + { + "name": "foo", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js new file mode 100644 index 000000000..a90405952 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const x = 1 +var foo = x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js.snap.json new file mode 100644 index 000000000..baec643cf --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js.snap.json @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "foo", + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js new file mode 100644 index 000000000..9687053be --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js @@ -0,0 +1,3 @@ +//// @sourceType = module +import { v as t } from 'foo' +t diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js.snap.json new file mode 100644 index 000000000..cef8ada21 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "t" + ], + "references": [ + { + "name": "t", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js new file mode 100644 index 000000000..972213f9f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js @@ -0,0 +1,3 @@ +//// @sourceType = module +import { v } from 'foo' +v diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js.snap.json new file mode 100644 index 000000000..20cab1f82 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "v" + ], + "references": [ + { + "name": "v", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js new file mode 100644 index 000000000..32a3c7e5d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js @@ -0,0 +1,3 @@ +//// @sourceType = module +import * as v from 'foo' +v diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js.snap.json new file mode 100644 index 000000000..20cab1f82 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "v" + ], + "references": [ + { + "name": "v", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js new file mode 100644 index 000000000..7d557b8b6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js new file mode 100644 index 000000000..b9a556e85 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const unresolved = T +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js.snap.json new file mode 100644 index 000000000..f9a4188d8 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "unresolved" + ], + "references": [ + { + "name": "T", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js new file mode 100644 index 000000000..7d557b8b6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js new file mode 100644 index 000000000..b9a556e85 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const unresolved = T +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js.snap.json new file mode 100644 index 000000000..f9a4188d8 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "unresolved" + ], + "references": [ + { + "name": "T", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js new file mode 100644 index 000000000..7d557b8b6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js @@ -0,0 +1,2 @@ +//// @sourceType = module +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js new file mode 100644 index 000000000..b9a556e85 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js @@ -0,0 +1,3 @@ +//// @sourceType = module +const unresolved = T +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js.snap.json new file mode 100644 index 000000000..f9a4188d8 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "unresolved" + ], + "references": [ + { + "name": "T", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js new file mode 100644 index 000000000..207263078 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js @@ -0,0 +1,7 @@ +class Foo {} +class Bar { + constructor() { + this.foo = Foo + } +} +new Bar() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js.snap.json new file mode 100644 index 000000000..0e3881a71 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js.snap.json @@ -0,0 +1,33 @@ +{ + "type": "Program", + "declarations": [ + "Bar", + "Foo" + ], + "references": [ + { + "name": "Bar", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js new file mode 100644 index 000000000..809ff86a0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js @@ -0,0 +1,4 @@ +function makeBox(value) { + return { value } +} +const makeStringBox = makeBox diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js.snap.json new file mode 100644 index 000000000..10750ae2a --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js.snap.json @@ -0,0 +1,35 @@ +{ + "type": "Program", + "declarations": [ + "makeBox", + "makeStringBox" + ], + "references": [ + { + "name": "makeBox", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:makeBox", + "declarations": [ + "value" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "value", + "declaredAt": "Program > FunctionDeclaration:makeBox" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js new file mode 100644 index 000000000..fe73d34f1 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js @@ -0,0 +1,3 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +const x = {} +_jsx(Foo, { ...x }) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js.snap.json new file mode 100644 index 000000000..13e374114 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "_jsx", + "x" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": null + }, + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js new file mode 100644 index 000000000..28820d595 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js @@ -0,0 +1,4 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +const x = 1 +const attr = 2 // should be unreferenced +_jsx(Foo, { attr: x }) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js.snap.json new file mode 100644 index 000000000..4841c6c26 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js.snap.json @@ -0,0 +1,23 @@ +{ + "type": "Program", + "declarations": [ + "_jsx", + "attr", + "x" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": null + }, + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js new file mode 100644 index 000000000..99e2b547f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js @@ -0,0 +1,3 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +const child = 1 +_jsx(Foo, { children: child }) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js.snap.json new file mode 100644 index 000000000..ca06b6f5d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "_jsx", + "child" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": null + }, + { + "name": "child", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js new file mode 100644 index 000000000..7e61429b5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js @@ -0,0 +1,3 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +function div() {} // should not be referenced +_jsx('div', {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js.snap.json new file mode 100644 index 000000000..cf39c1fa7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js.snap.json @@ -0,0 +1,28 @@ +{ + "type": "Program", + "declarations": [ + "_jsx", + "div" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:div", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js new file mode 100644 index 000000000..ff6298527 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js @@ -0,0 +1,6 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +const X = { + Foo() {}, +} +const Foo = 1 // should be unreferenced +_jsx(X.Foo, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js.snap.json new file mode 100644 index 000000000..66df04f1e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js.snap.json @@ -0,0 +1,33 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "X", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "X", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js new file mode 100644 index 000000000..ea0160c58 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js @@ -0,0 +1,6 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +const x = { + Foo() {}, +} +const Foo = 1 // should be unreferenced +_jsx(x.Foo, {}) // lower cased namespaces should still create a reference diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js.snap.json new file mode 100644 index 000000000..0110947f0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js.snap.json @@ -0,0 +1,33 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "_jsx", + "x" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js new file mode 100644 index 000000000..6d141f398 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js @@ -0,0 +1,3 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +function Foo() {} +_jsx(Foo, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js.snap.json new file mode 100644 index 000000000..2b0527a8d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js.snap.json @@ -0,0 +1,32 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:Foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js new file mode 100644 index 000000000..c3c53abdd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js @@ -0,0 +1,4 @@ +//// @sourceType = 'module' +import React from 'react' +import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' +_jsx(_Fragment, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js.snap.json new file mode 100644 index 000000000..48fc414b3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js.snap.json @@ -0,0 +1,19 @@ +{ + "type": "Program", + "declarations": [ + "React", + "_Fragment", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "_Fragment", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js new file mode 100644 index 000000000..c3c53abdd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js @@ -0,0 +1,4 @@ +//// @sourceType = 'module' +import React from 'react' +import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' +_jsx(_Fragment, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js.snap.json new file mode 100644 index 000000000..48fc414b3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js.snap.json @@ -0,0 +1,19 @@ +{ + "type": "Program", + "declarations": [ + "React", + "_Fragment", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "_Fragment", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js new file mode 100644 index 000000000..d2c6d70c0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js @@ -0,0 +1,4 @@ +//// @sourceType = 'module' +import React from 'react' +import { jsx as _jsx } from 'react/jsx-runtime' +_jsx(Foo, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js.snap.json new file mode 100644 index 000000000..d47d81d34 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js.snap.json @@ -0,0 +1,18 @@ +{ + "type": "Program", + "declarations": [ + "React", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js new file mode 100644 index 000000000..d8ede37b2 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js @@ -0,0 +1,5 @@ +//// @sourceType = 'module' +//// @jsxFragmentName = 'Fragment' +import React from 'react' // should be unreferenced +import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' +_jsx(_Fragment, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js.snap.json new file mode 100644 index 000000000..48fc414b3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js.snap.json @@ -0,0 +1,19 @@ +{ + "type": "Program", + "declarations": [ + "React", + "_Fragment", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "_Fragment", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js new file mode 100644 index 000000000..f6e0d9794 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js @@ -0,0 +1,6 @@ +//// @sourceType = 'module' +//// @jsxPragma = 'h' +//// @jsxFragmentName = 'Fragment' +import React from 'react' // should be unreferenced +import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' +_jsx(_Fragment, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js.snap.json new file mode 100644 index 000000000..48fc414b3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js.snap.json @@ -0,0 +1,19 @@ +{ + "type": "Program", + "declarations": [ + "React", + "_Fragment", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "_Fragment", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js new file mode 100644 index 000000000..61c98a9df --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js @@ -0,0 +1,5 @@ +//// @sourceType = 'module' +//// @jsxPragma = 'h' +import React from 'react' // should be unreferenced +import { jsx as _jsx } from 'react/jsx-runtime' +_jsx(Foo, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js.snap.json new file mode 100644 index 000000000..d47d81d34 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js.snap.json @@ -0,0 +1,18 @@ +{ + "type": "Program", + "declarations": [ + "React", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js new file mode 100644 index 000000000..4e6206acd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js @@ -0,0 +1,3 @@ +import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' +const child = 1 +_jsx(_Fragment, { children: child }) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js.snap.json new file mode 100644 index 000000000..f9e8454ff --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js.snap.json @@ -0,0 +1,23 @@ +{ + "type": "Program", + "declarations": [ + "_Fragment", + "_jsx", + "child" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "_Fragment", + "declaredAt": "Program" + }, + { + "name": "child", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js new file mode 100644 index 000000000..b3fecc4e9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js @@ -0,0 +1,2 @@ +import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' +_jsx(_Fragment, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js.snap.json new file mode 100644 index 000000000..8af8dbd47 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js.snap.json @@ -0,0 +1,18 @@ +{ + "type": "Program", + "declarations": [ + "_Fragment", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "_Fragment", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js new file mode 100644 index 000000000..e2a7553ff --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js @@ -0,0 +1,2 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +_jsx(Foo, {}) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js.snap.json new file mode 100644 index 000000000..df2306009 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js.snap.json @@ -0,0 +1,17 @@ +{ + "type": "Program", + "declarations": [ + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js new file mode 100644 index 000000000..dfb39635b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js @@ -0,0 +1,8 @@ +import * as React from 'react' +import { jsx as _jsx } from 'react/jsx-runtime' +// Both of these are equivalent: +const x = _jsx(Foo, { 'a:b': 'hello' }) +const y = _jsx(Foo, { 'a:b': 'hello' }) +function Foo(props) { + return _jsx('div', { children: props['a:b'] }) +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js.snap.json new file mode 100644 index 000000000..a1d66c6e3 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js.snap.json @@ -0,0 +1,54 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "React", + "_jsx", + "x", + "y" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:Foo", + "declarations": [ + "props" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "props", + "declaredAt": "Program > FunctionDeclaration:Foo" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js new file mode 100644 index 000000000..0f3e0598e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js @@ -0,0 +1,3 @@ +import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' +const Foo = 1 // should be unreferenced +_jsx(_Fragment, { children: 'Foo' }) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js.snap.json new file mode 100644 index 000000000..7b071664f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js.snap.json @@ -0,0 +1,19 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "_Fragment", + "_jsx" + ], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "_Fragment", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js new file mode 100644 index 000000000..a87091dd9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js @@ -0,0 +1,12 @@ +import { jsx as _jsx } from 'react/jsx-runtime' +class Foo { + constructor() { + this.Div = { + Element: () => _jsx('div', {}), + } + } + method() { + _jsx(this.foo, {}) + _jsx(Div.Element, {})(_jsx(this, {})) + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js.snap.json new file mode 100644 index 000000000..eaff33948 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js.snap.json @@ -0,0 +1,65 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "_jsx" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [ + { + "type": "ArrowFunction", + "declarations": [], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] + }, + { + "type": "FunctionExpression[2]", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "_jsx", + "declaredAt": "Program" + }, + { + "name": "Div", + "declaredAt": null + }, + { + "name": "_jsx", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js new file mode 100644 index 000000000..907178baa --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js @@ -0,0 +1,6 @@ +const x = {} +x.a +x.a.b.c.d +x['a'] +x?.a.b.c +x?.['a'] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js.snap.json new file mode 100644 index 000000000..51d60c6c7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js.snap.json @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + }, + { + "name": "x", + "declaredAt": "Program" + }, + { + "name": "x", + "declaredAt": "Program" + }, + { + "name": "x", + "declaredAt": "Program" + }, + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js new file mode 100644 index 000000000..83d9064d9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js @@ -0,0 +1,3 @@ +class Foo {} +const a = 1 +new Foo(a) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js.snap.json new file mode 100644 index 000000000..a7af778bc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js.snap.json @@ -0,0 +1,18 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "a" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "a", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js new file mode 100644 index 000000000..ff2007e45 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js @@ -0,0 +1 @@ +new Foo() diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js.snap.json new file mode 100644 index 000000000..1b8775793 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js.snap.json @@ -0,0 +1,11 @@ +{ + "type": "Program", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js new file mode 100644 index 000000000..01a1cf5ad --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js @@ -0,0 +1,2 @@ +const T = 1 +new Foo() // should not resolve to value diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js.snap.json new file mode 100644 index 000000000..ed28dc095 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "T" + ], + "references": [ + { + "name": "Foo", + "declaredAt": null + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js new file mode 100644 index 000000000..04544d174 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo) { + Foo[(Foo['a'] = 1)] = 'a' +})(Foo || (Foo = {})) +Foo.a diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js.snap.json new file mode 100644 index 000000000..bff2f2528 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js.snap.json @@ -0,0 +1,46 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js new file mode 100644 index 000000000..1cf42df97 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo) { + Foo[(Foo['a'] = 1)] = 'a' + Foo[(Foo['b'] = 1)] = 'b' +})(Foo || (Foo = {})) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js.snap.json new file mode 100644 index 000000000..524ba043c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js.snap.json @@ -0,0 +1,50 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js new file mode 100644 index 000000000..f87f67dc9 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js @@ -0,0 +1,4 @@ +var Foo +;(function (Foo) { + Foo[(Foo['a'] = 1)] = 'a' +})(Foo || (Foo = {})) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js.snap.json new file mode 100644 index 000000000..6f3ceb795 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js.snap.json @@ -0,0 +1,42 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js new file mode 100644 index 000000000..1cf42df97 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo) { + Foo[(Foo['a'] = 1)] = 'a' + Foo[(Foo['b'] = 1)] = 'b' +})(Foo || (Foo = {})) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js.snap.json new file mode 100644 index 000000000..524ba043c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js.snap.json @@ -0,0 +1,50 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js new file mode 100644 index 000000000..cf7d73523 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo) { + Foo[(Foo['a'] = 0)] = 'a' +})(Foo || (Foo = {})) +const unresolved = a diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js.snap.json new file mode 100644 index 000000000..20efa3aa5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js.snap.json @@ -0,0 +1,47 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "unresolved" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "a", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js new file mode 100644 index 000000000..1cf42df97 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo) { + Foo[(Foo['a'] = 1)] = 'a' + Foo[(Foo['b'] = 1)] = 'b' +})(Foo || (Foo = {})) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js.snap.json new file mode 100644 index 000000000..524ba043c --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js.snap.json @@ -0,0 +1,50 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js new file mode 100644 index 000000000..7e8224762 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js @@ -0,0 +1,5 @@ +class Foo {} +;(function (Foo) { + Foo.x = 1 +})(Foo || (Foo = {})) +const usage = Foo diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js.snap.json new file mode 100644 index 000000000..8fb8af2ed --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js.snap.json @@ -0,0 +1,43 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "usage" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js new file mode 100644 index 000000000..b20d2edaa --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js @@ -0,0 +1,5 @@ +function Foo() {} +;(function (Foo) { + Foo.x = 1 +})(Foo || (Foo = {})) +const usage = Foo diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js.snap.json new file mode 100644 index 000000000..4f72d799f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js.snap.json @@ -0,0 +1,56 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "usage" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:Foo", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + }, + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js new file mode 100644 index 000000000..abb6e05cc --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js @@ -0,0 +1,2 @@ +const Foo = 1 +const usage = Foo diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js.snap.json new file mode 100644 index 000000000..baf771c0b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js.snap.json @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "usage" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js new file mode 100644 index 000000000..f1ef9c6f8 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo) { + Foo.x = 1 +})(Foo || (Foo = {})) +Foo.x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js.snap.json new file mode 100644 index 000000000..4ed6df404 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js.snap.json @@ -0,0 +1,42 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/global-augmentation.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/global-augmentation.js new file mode 100644 index 000000000..af10d5310 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/global-augmentation.js @@ -0,0 +1 @@ +//// @sourceType = module diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/global-augmentation.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/global-augmentation.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/global-augmentation.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/import.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/import.js new file mode 100644 index 000000000..af10d5310 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/import.js @@ -0,0 +1 @@ +//// @sourceType = module diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/import.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/import.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/import.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js new file mode 100644 index 000000000..fa86764a6 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo_1) { + Foo_1.Foo = 1 +})(Foo || (Foo = {})) +const usage = Foo diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js.snap.json new file mode 100644 index 000000000..46443b4e7 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js.snap.json @@ -0,0 +1,43 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "usage" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo_1" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo_1", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js new file mode 100644 index 000000000..a7df4d765 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js @@ -0,0 +1,7 @@ +var Foo +;(function (Foo) { + Foo.x = 1 + Foo.x +})(Foo || (Foo = {})) +const unresolved = x +Foo.x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js.snap.json new file mode 100644 index 000000000..5aa3a6c58 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js.snap.json @@ -0,0 +1,51 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "unresolved" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "x", + "declaredAt": null + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js new file mode 100644 index 000000000..ca541ec2a --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js @@ -0,0 +1,8 @@ +export var A +;(function (A) { + let X + ;(function (X) { + X.Y = 1 + })((X = A.X || (A.X = {}))) +})(A || (A = {})) +const X = 23 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js.snap.json new file mode 100644 index 000000000..a96247d04 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js.snap.json @@ -0,0 +1,70 @@ +{ + "type": "Program", + "declarations": [ + "A", + "X" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program" + }, + { + "name": "A", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "A" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "X" + ], + "references": [ + { + "name": "X", + "declaredAt": "Program > FunctionExpression > BlockStatement" + }, + { + "name": "A", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "A", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "X" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "X", + "declaredAt": "Program > FunctionExpression > BlockStatement > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js new file mode 100644 index 000000000..52e93dffd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo) { + const x = 1 +})(Foo || (Foo = {})) +const unresolved = x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js.snap.json new file mode 100644 index 000000000..12c89bd6b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js.snap.json @@ -0,0 +1,40 @@ +{ + "type": "Program", + "declarations": [ + "Foo", + "unresolved" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "x", + "declaredAt": null + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "x" + ], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js new file mode 100644 index 000000000..0840cd003 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js @@ -0,0 +1,5 @@ +var Foo +;(function (Foo) { + Foo.x = 1 + Foo.x +})(Foo || (Foo = {})) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js.snap.json new file mode 100644 index 000000000..6f3ceb795 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js.snap.json @@ -0,0 +1,42 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js new file mode 100644 index 000000000..7c9de26db --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js @@ -0,0 +1 @@ +function foo([a]) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js.snap.json new file mode 100644 index 000000000..8c438e1f5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js new file mode 100644 index 000000000..05d6345c8 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js @@ -0,0 +1 @@ +function foo(a = 1) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js.snap.json new file mode 100644 index 000000000..8c438e1f5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js new file mode 100644 index 000000000..8686d5c2d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js @@ -0,0 +1 @@ +function foo({ a }) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js.snap.json new file mode 100644 index 000000000..8c438e1f5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js new file mode 100644 index 000000000..9a3f7f00b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js @@ -0,0 +1 @@ +function foo(...a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js.snap.json new file mode 100644 index 000000000..8c438e1f5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js new file mode 100644 index 000000000..ef1dd099d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js @@ -0,0 +1 @@ +function foo(a) {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js.snap.json new file mode 100644 index 000000000..8c438e1f5 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js.snap.json @@ -0,0 +1,24 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "a" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js new file mode 100644 index 000000000..268646627 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js @@ -0,0 +1 @@ +const [x] = [] diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js new file mode 100644 index 000000000..3b6bb8a11 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js @@ -0,0 +1 @@ +const x = 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js new file mode 100644 index 000000000..d29e51d21 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js @@ -0,0 +1 @@ +let x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js new file mode 100644 index 000000000..3ada65d60 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js @@ -0,0 +1 @@ +const { x } = {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js new file mode 100644 index 000000000..2660e277b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js @@ -0,0 +1 @@ +var x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js new file mode 100644 index 000000000..bae16dfec --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js @@ -0,0 +1,2 @@ +const x = 1 +x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js new file mode 100644 index 000000000..bae16dfec --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js @@ -0,0 +1,2 @@ +const x = 1 +x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js new file mode 100644 index 000000000..1c27a6483 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js @@ -0,0 +1,2 @@ +let x = 1 +x += 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js new file mode 100644 index 000000000..1c27a6483 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js @@ -0,0 +1,2 @@ +let x = 1 +x += 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js new file mode 100644 index 000000000..1c27a6483 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js @@ -0,0 +1,2 @@ +let x = 1 +x += 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js new file mode 100644 index 000000000..6703e1bcb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js @@ -0,0 +1,2 @@ +let x = 1 +x++ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js new file mode 100644 index 000000000..6703e1bcb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js @@ -0,0 +1,2 @@ +let x = 1 +x++ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js new file mode 100644 index 000000000..6703e1bcb --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js @@ -0,0 +1,2 @@ +let x = 1 +x++ diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js new file mode 100644 index 000000000..bae16dfec --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js @@ -0,0 +1,2 @@ +const x = 1 +x diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js.snap.json new file mode 100644 index 000000000..b533a0e0d --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [ + { + "name": "x", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional-nested.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional-nested.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional-nested.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional-nested.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional-nested.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional2.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional3.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional3.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional3.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional3.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional4.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional4.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional4.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional4.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional4.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional5.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional5.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional5.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional5.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/conditional5.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js new file mode 100644 index 000000000..612c6daae --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js @@ -0,0 +1,2 @@ +const dual = 1 +const reference2 = dual diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js.snap.json new file mode 100644 index 000000000..445a7a49f --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js.snap.json @@ -0,0 +1,14 @@ +{ + "type": "Program", + "declarations": [ + "dual", + "reference2" + ], + "references": [ + { + "name": "dual", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics2.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor-generics2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/constructor.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics2.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function-generics2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js new file mode 100644 index 000000000..e8d52b14b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js @@ -0,0 +1 @@ +const arg = 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js.snap.json new file mode 100644 index 000000000..287d4d53e --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "arg" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/array-pattern.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/array-pattern.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/array-pattern.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/array-pattern.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/array-pattern.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/object-pattern.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/object-pattern.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/object-pattern.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/object-pattern.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/object-pattern.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/rest-element.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/rest-element.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/rest-element.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/rest-element.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/params/rest-element.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-qualifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-qualifier.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-qualifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-qualifier.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-qualifier.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-type-params.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-type-params.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-type-params.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-type-params.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type-with-type-params.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/import-type.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access2.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js new file mode 100644 index 000000000..0bc65e4cd --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js @@ -0,0 +1 @@ +const k = 'a' diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js.snap.json new file mode 100644 index 000000000..682f6e2e4 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "k" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/infer-type-constraint.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/infer-type-constraint.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/infer-type-constraint.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/infer-type-constraint.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/infer-type-constraint.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage2.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface-heritage2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface2.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/interface2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type2.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type3.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type3.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type3.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/literal-type3.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-no-references.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-no-references.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-no-references.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-no-references.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-no-references.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-referenced.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-referenced.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-referenced.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-referenced.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named-literal-referenced.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped-named.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/mapped.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/qualified-name.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/qualified-name.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/qualified-name.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/qualified-name.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/qualified-name.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call-generics.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call-generics.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call-generics.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call-generics.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call-generics.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/call.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct-generics.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct-generics.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct-generics.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct-generics.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct-generics.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/construct.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/index-sig.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/index-sig.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/index-sig.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/index-sig.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/index-sig.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js new file mode 100644 index 000000000..ad03c2dce --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js @@ -0,0 +1 @@ +const x = 'b' diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js new file mode 100644 index 000000000..f08314925 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js @@ -0,0 +1,4 @@ +var Foo +;(function (Foo) { + Foo[(Foo['a'] = 0)] = 'a' +})(Foo || (Foo = {})) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js.snap.json new file mode 100644 index 000000000..6f3ceb795 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js.snap.json @@ -0,0 +1,42 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-generics.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-generics.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-generics.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-generics.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-generics.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js new file mode 100644 index 000000000..ad03c2dce --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js @@ -0,0 +1 @@ +const x = 'b' diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js new file mode 100644 index 000000000..f08314925 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js @@ -0,0 +1,4 @@ +var Foo +;(function (Foo) { + Foo[(Foo['a'] = 0)] = 'a' +})(Foo || (Foo = {})) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js.snap.json new file mode 100644 index 000000000..6f3ceb795 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js.snap.json @@ -0,0 +1,42 @@ +{ + "type": "Program", + "declarations": [ + "Foo" + ], + "references": [ + { + "name": "Foo", + "declaredAt": "Program" + }, + { + "name": "Foo", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionExpression", + "declarations": [ + "Foo" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + }, + { + "name": "Foo", + "declaredAt": "Program > FunctionExpression" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled-rest.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled-rest.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled-rest.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled-rest.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled-rest.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-labelled.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-rest.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-rest.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-rest.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-rest.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple-rest.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/tuple.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/body-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/body-reference.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/body-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/body-reference.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/body-reference.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/extends-reference.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-param-reference.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-param-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-param-reference.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-param-reference.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration-extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration-extends.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration-extends.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration-extends.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration-extends.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/interface/type-parameter-declaration.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js new file mode 100644 index 000000000..274331248 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js @@ -0,0 +1,2 @@ +function div(arg) {} +const StyledPayment = div`` diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js.snap.json new file mode 100644 index 000000000..002ea5f54 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js.snap.json @@ -0,0 +1,30 @@ +{ + "type": "Program", + "declarations": [ + "StyledPayment", + "div" + ], + "references": [ + { + "name": "div", + "declaredAt": "Program" + } + ], + "children": [ + { + "type": "FunctionDeclaration:div", + "declarations": [ + "arg" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/body-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/body-reference.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/body-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/body-reference.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/body-reference.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-param-reference.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-param-reference.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-param-reference.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-param-reference.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/type-decl/type-parameter-declaration.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js new file mode 100644 index 000000000..708308ed0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js @@ -0,0 +1 @@ +const x = { y: { z: 1 } } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js new file mode 100644 index 000000000..8120c86c0 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js @@ -0,0 +1,4 @@ +function foo(y) { + return { y } +} +export {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js.snap.json new file mode 100644 index 000000000..82e048e49 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js.snap.json @@ -0,0 +1,29 @@ +{ + "type": "Program", + "declarations": [ + "foo" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:foo", + "declarations": [ + "y" + ], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "y", + "declaredAt": "Program > FunctionDeclaration:foo" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js new file mode 100644 index 000000000..3b6bb8a11 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js @@ -0,0 +1 @@ +const x = 1 diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js.snap.json new file mode 100644 index 000000000..266f19e90 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js.snap.json @@ -0,0 +1,8 @@ +{ + "type": "Program", + "declarations": [ + "x" + ], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type1.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type1.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type1.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type1.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type2.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type2.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type2.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type2.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type3.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type3.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type3.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type3.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/typeof-import-type-with-qualifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/typeof-import-type-with-qualifier.js new file mode 100644 index 000000000..e69de29bb diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/typeof-import-type-with-qualifier.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/typeof-import-type-with-qualifier.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/typeof-import-type-with-qualifier.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index d79270a3f..6fa99a6ec 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -104,7 +104,9 @@ function serializeScopeTree(scopeTree: ScopeTree): SerializedScope { function toScopeNodeLabel(node: Node): string { switch (node.type) { case 'FunctionDeclaration': - return `${node.type}:${node.id.name}` + // ESTree typing says `id` is present here, but the parser can still produce + // `export default function () {}` as a FunctionDeclaration with `id: null`. + return node.type + (node.id ? `:${node.id.name}` : '') case 'FunctionExpression': return node.type + (node.id ? `:${node.id.name}` : '') case 'ArrowFunctionExpression': From c6cbf9069e5da24a1236ebf1bc515a05d7489afe Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 23:12:52 +0900 Subject: [PATCH 70/88] fix(plugin-rsc): handle named class expression self-binding Co-authored-by: Codex --- .../self-reference-super.js.snap.json | 19 +++++++--- .../class-deco-with-object-param.js.snap.json | 8 ++++ .../decorators/class.js.snap.json | 8 ++++ .../parameter-property.js.snap.json | 37 ++++++++++++------- .../decorators/typeof-this.js.snap.json | 19 +++++++--- .../plugin-rsc/src/transforms/scope.test.ts | 4 ++ packages/plugin-rsc/src/transforms/scope.ts | 11 +++++- 7 files changed, 80 insertions(+), 26 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js.snap.json index cbeafe6bf..57f9830f4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js.snap.json @@ -3,11 +3,20 @@ "declarations": [ "A" ], - "references": [ + "references": [], + "children": [ { - "name": "A", - "declaredAt": "Program" + "type": "ClassExpression:A", + "declarations": [ + "A" + ], + "references": [ + { + "name": "A", + "declaredAt": "Program > ClassExpression:A" + } + ], + "children": [] } - ], - "children": [] + ] } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js.snap.json index 67e087fe6..4f8fcdde7 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js.snap.json @@ -225,6 +225,14 @@ ] } ] + }, + { + "type": "ClassExpression:Foo", + "declarations": [ + "Foo" + ], + "references": [], + "children": [] } ] } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js.snap.json index 7d60027bf..0a856dbbd 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js.snap.json @@ -239,6 +239,14 @@ "children": [] } ] + }, + { + "type": "ClassExpression:Foo", + "declarations": [ + "Foo" + ], + "references": [], + "children": [] } ] } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js.snap.json index 59afe51c7..5e5399926 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js.snap.json @@ -304,27 +304,36 @@ ] }, { - "type": "FunctionExpression[3]", + "type": "ClassExpression:Foo", "declarations": [ - "a", - "b" + "Foo" ], "references": [], "children": [ { - "type": "BlockStatement", - "declarations": [], - "references": [ - { - "name": "a", - "declaredAt": "Program > FunctionExpression[3]" - }, + "type": "FunctionExpression", + "declarations": [ + "a", + "b" + ], + "references": [], + "children": [ { - "name": "b", - "declaredAt": "Program > FunctionExpression[3]" + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "a", + "declaredAt": "Program > ClassExpression:Foo > FunctionExpression" + }, + { + "name": "b", + "declaredAt": "Program > ClassExpression:Foo > FunctionExpression" + } + ], + "children": [] } - ], - "children": [] + ] } ] } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js.snap.json index f7ac7eb95..c55a60d99 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js.snap.json +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js.snap.json @@ -241,17 +241,26 @@ ] }, { - "type": "FunctionExpression[2]", + "type": "ClassExpression:Foo", "declarations": [ - "baz" + "Foo" ], "references": [], "children": [ { - "type": "BlockStatement", - "declarations": [], + "type": "FunctionExpression", + "declarations": [ + "baz" + ], "references": [], - "children": [] + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [], + "children": [] + } + ] } ] } diff --git a/packages/plugin-rsc/src/transforms/scope.test.ts b/packages/plugin-rsc/src/transforms/scope.test.ts index 6fa99a6ec..7207772d5 100644 --- a/packages/plugin-rsc/src/transforms/scope.test.ts +++ b/packages/plugin-rsc/src/transforms/scope.test.ts @@ -109,6 +109,10 @@ function toScopeNodeLabel(node: Node): string { return node.type + (node.id ? `:${node.id.name}` : '') case 'FunctionExpression': return node.type + (node.id ? `:${node.id.name}` : '') + case 'ClassDeclaration': + return node.type + (node.id ? `:${node.id.name}` : '') + case 'ClassExpression': + return node.type + (node.id ? `:${node.id.name}` : '') case 'ArrowFunctionExpression': return 'ArrowFunction' default: diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index f54cb1d4d..17a627ead 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -90,6 +90,15 @@ export function buildScopeTree(ast: Program): ScopeTree { if (node.type === 'FunctionExpression' && node.id) { scope.declarations.add(node.id.name) } + } else if (node.type === 'ClassDeclaration' && node.id) { + current.declarations.add(node.id.name) + } else if (node.type === 'ClassExpression' && node.id) { + // Named class expressions have an inner self-binding visible from the + // heritage clause and the class body, similar to named function expressions. + const scope = new Scope(current, false) + scope.declarations.add(node.id.name) + nodeScope.set(node, scope) + current = scope } else if ( node.type === 'ForStatement' || node.type === 'ForInStatement' || @@ -117,8 +126,6 @@ export function buildScopeTree(ast: Program): ScopeTree { target.declarations.add(name) } } - } else if (node.type === 'ClassDeclaration' && node.id) { - current.declarations.add(node.id.name) } // Collect reference identifiers for post-walk resolution. // TODO: From 16cd5c007b213e32ab7f1a532fe03aee6201db2f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 23:13:36 +0900 Subject: [PATCH 71/88] chore: readme --- packages/plugin-rsc/scripts/README.md | 77 +++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/packages/plugin-rsc/scripts/README.md b/packages/plugin-rsc/scripts/README.md index f4086410a..e332948bd 100644 --- a/packages/plugin-rsc/scripts/README.md +++ b/packages/plugin-rsc/scripts/README.md @@ -50,3 +50,80 @@ node ./scripts/review-scope-fixtures.ts | code - node ./scripts/review-scope-fixtures.ts shadowing import | code - node ./scripts/review-scope-fixtures.ts var-hoisting --output /tmp/scope-review.md ``` + +## Review Workflow + +The imported `typescript-eslint` corpus is too large to review file-by-file in one pass. +The practical workflow is: + +1. Regenerate the pre-transpiled JS fixture subtree. + +```bash +cd packages/plugin-rsc +node ./scripts/import-typescript-eslint-scope-fixtures.ts +pnpm test -- scope.test.ts --update +``` + +2. Build review packets for targeted categories instead of the entire corpus. + +```bash +cd packages/plugin-rsc +node ./scripts/review-scope-fixtures.ts typescript-eslint/destructuring --output /tmp/destructuring.md +node ./scripts/review-scope-fixtures.ts typescript-eslint/import typescript-eslint/export --output /tmp/module-syntax.md +node ./scripts/review-scope-fixtures.ts typescript-eslint/class typescript-eslint/jsx --output /tmp/class-jsx.md +``` + +3. Sample by category, not exhaustively. + +Recommended categories: + +- `destructuring/` +- `import/` +- `export/` +- `catch/` +- `functions/` +- `class/` +- `jsx/` +- `decorators/` + +4. Review in parallel. + +When using subagents, split the audit by independent category groups and ask each +subagent to report only suspicious cases. A good split is: + +- `destructuring/`, `import/`, `export/`, `catch/` +- `class/`, `decorators/`, `jsx/` +- `functions/`, `global-resolution/`, `block/`, `call-expression/`, `member-expression/`, `new-expression/`, `implicit/` + +Each reviewer should compare: + +- original intent of the upstream fixture category +- transpiled JS fixture content +- generated `*.snap.json` + +and report only: + +- likely scope-analysis bugs +- fixtures whose TS -> JS lowering destroyed the original signal + +5. Prefer findings-driven follow-up. + +High-value follow-up is not “review every imported file”, but: + +- fix concrete scope-analysis bugs exposed by imported fixtures +- document or prune low-signal imported fixtures whose semantics are erased by transpilation + +## Current Caveats + +The import is intentionally JS-only, but some TS-specific fixtures lose value after +transpilation. Known weak-signal areas: + +- `decorators/`: helper injection like `__decorate` / `__param` can dominate the snapshot +- some `jsx/factory/` cases: JSX pragma semantics collapse to `_jsx(...)` runtime helper calls +- some `functions/arrow/` TS-only cases: type predicates, `asserts`, and type parameters can erase to identical JS + +Known likely real bug discovered during sampling: + +- `typescript-eslint/class/expression/self-reference-super.js` + `const A = class A extends A {}` appears to resolve `extends A` to the outer + `const A` instead of the inner class name From a9f21cf42f1e3ca65af88693e540677b37fd411d Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 23:17:07 +0900 Subject: [PATCH 72/88] chore: ignore fixtures format --- .oxfmtrc.json | 1 + .../block/inherited-scope.js | 4 +- .../scope/typescript-eslint/block/scope.js | 8 +-- .../call-expression/call-expression.js | 8 +-- .../call-expression/type-parameters1.js | 2 +- .../call-expression/type-parameters2.js | 4 +- .../catch/destructuring-array.js | 3 +- .../catch/destructuring-object.js | 3 +- .../catch/inherited-scope.js | 7 +-- .../scope/typescript-eslint/catch/scope.js | 11 ++-- .../declaration/abstract-accessor-property.js | 3 +- .../class/declaration/abstract-property.js | 3 +- .../class/declaration/abstract.js | 3 +- .../accessor-property-type-annotation.js | 3 +- .../class/declaration/accessor-property.js | 12 ++--- .../class/declaration/computed-member.js | 14 ++--- .../class/declaration/extends-generic.js | 6 ++- .../class/declaration/extends.js | 6 ++- .../class/declaration/generic-ref-extends.js | 3 +- .../declaration/generic-ref-implements.js | 3 +- .../class/declaration/generic.js | 3 +- .../class/declaration/implements-generic.js | 3 +- .../class/declaration/implements.js | 3 +- .../class/declaration/index-signature.js | 3 +- .../class/declaration/method-param-default.js | 14 ++--- .../class/declaration/method.js | 10 ++-- .../class/declaration/new.js | 5 +- .../class/declaration/parameter-properties.js | 22 ++++---- .../class/declaration/private-identifier.js | 8 +-- .../declaration/properties-type-annotation.js | 3 +- .../class/declaration/properties.js | 12 ++--- .../class/declaration/static-block.js | 2 +- .../class/declaration/static-external-ref.js | 8 +-- .../declaration/static-with-constructor.js | 10 ++-- .../class/declaration/type-reference.js | 5 +- .../class/expression/computed-member.js | 16 +++--- .../class/expression/extends.js | 6 ++- .../class/expression/method.js | 12 ++--- .../typescript-eslint/class/expression/new.js | 5 +- .../class/expression/parameter-properties.js | 24 ++++----- .../class/expression/private-identifier.js | 10 ++-- .../class/expression/properties.js | 14 ++--- .../class/expression/self-reference-super.js | 5 +- .../typescript-eslint/decorators/accessor.js | 43 ++++++--------- .../class-deco-with-object-param.js | 43 +++++---------- .../decorators/class-property.js | 34 +++++------- .../typescript-eslint/decorators/class.js | 34 +++++------- .../typescript-eslint/decorators/method.js | 33 ++++-------- .../decorators/parameter-property.js | 52 +++++++------------ .../typescript-eslint/decorators/parameter.js | 50 +++++------------- .../decorators/typeof-this.js | 35 +++++-------- .../destructuring/array-assignment.js | 6 +-- .../typescript-eslint/destructuring/array.js | 2 +- .../destructuring/object-assignment.js | 12 ++--- .../typescript-eslint/destructuring/object.js | 7 +-- .../scope/typescript-eslint/export/all.js | 4 +- .../typescript-eslint/export/default-type.js | 4 +- .../typescript-eslint/export/default1.js | 2 +- .../typescript-eslint/export/default2.js | 4 +- .../typescript-eslint/export/default3.js | 2 +- .../typescript-eslint/export/default4.js | 2 +- .../scope/typescript-eslint/export/equals1.js | 4 +- .../scope/typescript-eslint/export/equals2.js | 2 +- .../typescript-eslint/export/equals3-type.js | 2 +- .../typescript-eslint/export/equals4-type.js | 2 +- .../typescript-eslint/export/named-dual.js | 4 +- .../typescript-eslint/export/named-source1.js | 2 +- .../typescript-eslint/export/named-source2.js | 2 +- .../typescript-eslint/export/named-type1.js | 2 +- .../scope/typescript-eslint/export/named1.js | 2 +- .../typescript-eslint/export/named2-type.js | 2 +- .../scope/typescript-eslint/export/named2.js | 4 +- .../typescript-eslint/export/named3-type.js | 2 +- .../scope/typescript-eslint/export/named3.js | 4 +- .../typescript-eslint/export/type-inline.js | 4 +- .../scope/typescript-eslint/export/type.js | 4 +- .../readable-ref-body-shadow.js | 6 +-- .../default-params/readable-ref-const.js | 4 +- .../arrow/default-params/readable-ref-let.js | 4 +- .../readable-ref-nested-body-shadow.js | 14 +++-- .../default-params/readable-ref-nested.js | 10 ++-- .../readable-ref-param-shadow.js | 4 +- .../default-params/readable-ref-partial.js | 4 +- .../arrow/default-params/writable-ref.js | 2 +- .../functions/arrow/inherited-scope.js | 8 +-- .../functions/arrow/no-body.js | 2 +- .../functions/arrow/params.js | 10 ++-- .../functions/arrow/scope.js | 10 ++-- .../arrow/type-parameters/body-reference.js | 4 +- .../arrow/type-parameters/param-reference.js | 2 +- .../type-parameters/return-value-reference.js | 2 +- .../type-parameters/type-param-reference.js | 2 +- .../type-parameter-declaration.js | 2 +- .../arrow/type-predicate-asserts1.js | 2 +- .../arrow/type-predicate-asserts2.js | 2 +- .../functions/arrow/type-predicate1.js | 4 +- .../functions/arrow/type-predicate2.js | 4 +- .../readable-ref-body-shadow.js | 4 +- .../default-params/readable-ref-const.js | 4 +- .../default-params/readable-ref-let.js | 4 +- .../readable-ref-nested-body-shadow.js | 12 ++--- .../default-params/readable-ref-nested.js | 10 ++-- .../readable-ref-param-shadow.js | 4 +- .../default-params/readable-ref-partial.js | 4 +- .../default-params/writable-ref.js | 2 +- .../function-declaration/inherited-scope.js | 4 +- .../name-shadowed-in-body.js | 4 +- .../function-declaration/overload.js | 2 +- .../functions/function-declaration/params.js | 6 +-- .../functions/function-declaration/scope.js | 8 +-- .../type-parameters/body-reference.js | 2 +- .../type-parameters/param-reference.js | 2 +- .../type-parameters/return-value-reference.js | 2 +- .../type-parameters/type-param-reference.js | 2 +- .../type-parameter-declaration.js | 2 +- .../type-predicate-asserts1.js | 2 +- .../type-predicate-asserts2.js | 2 +- .../function-declaration/type-predicate1.js | 2 +- .../function-declaration/type-predicate2.js | 2 +- .../function-expression/anonymous.js | 2 +- .../readable-ref-body-shadow.js | 6 +-- .../default-params/readable-ref-const.js | 4 +- .../default-params/readable-ref-let.js | 4 +- .../readable-ref-nested-body-shadow.js | 14 +++-- .../default-params/readable-ref-nested.js | 10 ++-- .../readable-ref-param-shadow.js | 4 +- .../default-params/readable-ref-partial.js | 4 +- .../default-params/writable-ref.js | 2 +- .../function-expression/inherited-scope.js | 6 +-- .../functions/function-expression/params.js | 8 +-- .../functions/function-expression/scope.js | 10 ++-- .../type-parameters/body-reference.js | 4 +- .../type-parameters/param-reference.js | 2 +- .../type-parameters/return-value-reference.js | 2 +- .../type-parameters/type-param-reference.js | 2 +- .../type-parameter-declaration.js | 2 +- .../type-predicate-asserts1.js | 2 +- .../type-predicate-asserts2.js | 2 +- .../function-expression/type-predicate1.js | 4 +- .../function-expression/type-predicate2.js | 4 +- .../global-resolution/module/class.js | 5 +- .../global-resolution/module/function.js | 4 +- .../module/variable-decl-const.js | 4 +- .../module/variable-decl-let.js | 4 +- .../module/variable-decl-var.js | 4 +- .../global-resolution/script/class.js | 5 +- .../global-resolution/script/function.js | 4 +- .../script/variable-decl-const.js | 4 +- .../script/variable-decl-let.js | 4 +- .../script/variable-decl-var.js | 4 +- .../typescript-eslint/implicit/implicit1.js | 2 +- .../scope/typescript-eslint/import/default.js | 4 +- .../scope/typescript-eslint/import/equals1.js | 4 +- .../scope/typescript-eslint/import/equals2.js | 4 +- .../typescript-eslint/import/named-alias.js | 4 +- .../scope/typescript-eslint/import/named.js | 4 +- .../typescript-eslint/import/namespace.js | 4 +- .../import/type-default-value.js | 2 +- .../typescript-eslint/import/type-default.js | 4 +- .../import/type-inline-value.js | 2 +- .../typescript-eslint/import/type-inline.js | 4 +- .../import/type-named-value.js | 2 +- .../typescript-eslint/import/type-named.js | 4 +- .../type-arguments1.js | 11 ++-- .../type-arguments2.js | 4 +- .../typescript-eslint/jsx/attribute-spread.js | 6 +-- .../scope/typescript-eslint/jsx/attribute.js | 8 +-- .../scope/typescript-eslint/jsx/children.js | 6 +-- .../jsx/component-intrinsic-name.js | 6 +-- .../jsx/component-namespaced1.js | 10 ++-- .../jsx/component-namespaced2.js | 10 ++-- .../scope/typescript-eslint/jsx/component.js | 6 +-- .../jsx/factory/default-jsxFragmentName.js | 6 +-- .../jsx/factory/default-jsxPragma-fragment.js | 6 +-- .../jsx/factory/default-jsxPragma.js | 6 +-- .../jsx/factory/jsxFragmentName.js | 6 +-- .../jsx/factory/jsxPragma-jsxFragmentName.js | 6 +-- .../jsx/factory/jsxPragma.js | 6 +-- .../jsx/fragment-children.js | 6 +-- .../scope/typescript-eslint/jsx/fragment.js | 4 +- .../jsx/generic-type-param.js | 4 +- .../jsx/namespaced-attribute.js | 10 ++-- .../scope/typescript-eslint/jsx/text.js | 6 +-- .../jsx/this-jsxidentifier.js | 18 +++---- .../member-expression/member-expression.js | 12 ++--- .../new-expression/new-expression.js | 7 +-- .../new-expression/type-parameters1.js | 2 +- .../new-expression/type-parameters2.js | 4 +- .../typescript-eslint/ts-enum/external-ref.js | 10 ++-- .../ts-enum/literal-member-ref.js | 10 ++-- .../ts-enum/literal-member.js | 8 +-- .../typescript-eslint/ts-enum/member-ref.js | 10 ++-- .../scope/typescript-eslint/ts-enum/scope.js | 10 ++-- .../typescript-eslint/ts-enum/self-ref.js | 10 ++-- .../declaration-merging/class-namespace.js | 11 ++-- .../declaration-merging/function-namespace.js | 10 ++-- .../declaration-merging/namespace-variable.js | 4 +- .../ts-module/external-ref.js | 10 ++-- .../ts-module/name-shadowed-in-body.js | 10 ++-- .../typescript-eslint/ts-module/namespace.js | 14 ++--- .../ts-module/nested-namespace-alias.js | 16 +++--- .../typescript-eslint/ts-module/scope.js | 10 ++-- .../typescript-eslint/ts-module/self-ref.js | 10 ++-- .../parameter-array-destructure.js | 2 +- .../type-annotation/parameter-default.js | 2 +- .../parameter-object-destructure.js | 2 +- .../type-annotation/parameter-rest.js | 2 +- .../type-annotation/parameter.js | 2 +- .../variable-array-destructure.js | 2 +- .../type-annotation/variable-const.js | 2 +- .../type-annotation/variable-let.js | 2 +- .../variable-object-destructure.js | 2 +- .../type-annotation/variable-var.js | 2 +- .../type-assertion/angle-bracket.js | 4 +- .../typescript-eslint/type-assertion/as.js | 4 +- .../assignment/angle-bracket-assignment.js | 4 +- .../assignment/as-assignment.js | 4 +- .../assignment/non-null-assignment.js | 4 +- .../increment/angle-bracket-increment.js | 4 +- .../type-assertion/increment/as-increment.js | 4 +- .../increment/non-null-increment.js | 4 +- .../type-assertion/satisfies.js | 4 +- .../type-declaration/dual-type-value.js | 4 +- .../type-declaration/function/function2.js | 2 +- .../type-declaration/index-access3.js | 2 +- .../signatures/method-computed-name.js | 2 +- .../signatures/method-computed-name2.js | 8 +-- .../signatures/property-computed-name.js | 2 +- .../signatures/property-computed-name2.js | 8 +-- .../type-parameters/tagged-template.js | 4 +- .../type-declaration/type-query-qualified.js | 2 +- .../type-query-with-parameters.js | 4 +- .../type-declaration/type-query.js | 2 +- 233 files changed, 715 insertions(+), 803 deletions(-) diff --git a/.oxfmtrc.json b/.oxfmtrc.json index afb4926b4..9fa524588 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -10,6 +10,7 @@ }, "ignorePatterns": [ "*.snap.json", + "typescript-eslint/", "packages/*/CHANGELOG.md", "playground-temp/", "dist/", diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js index 323afb03d..ca02c6b27 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/inherited-scope.js @@ -1,4 +1,4 @@ -const a = 1 +const a = 1; { - a + a; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js index ae99601bb..75974801a 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/block/scope.js @@ -1,6 +1,6 @@ { - let i = 20 - let j = 1 - i + let i = 20; + let j = 1; + i; } -j +j; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js index 4e873fcb2..6aa85a9a3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/call-expression.js @@ -1,4 +1,4 @@ -const foo = () => {} -const a = 1 -foo(a) -foo?.(a) +const foo = () => { }; +const a = 1; +foo(a); +foo?.(a); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js index eb28ef440..a280f9a5c 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters1.js @@ -1 +1 @@ -foo() +foo(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js index 1b7e86768..9d75ca758 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/call-expression/type-parameters2.js @@ -1,2 +1,2 @@ -const T = 1 -foo() // should not resolve to value +const T = 1; +foo(); // should not resolve to value diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js index 07a7fb3d0..75d6a233e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-array.js @@ -1,2 +1,3 @@ try { -} catch ([a, [b], c = 1, ...d]) {} +} +catch ([a, [b], c = 1, ...d]) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js index 8873ba210..2a95b184e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/destructuring-object.js @@ -1,2 +1,3 @@ try { -} catch ({ a, x: b, y: { c }, d = 1, ...e }) {} +} +catch ({ a, x: b, y: { c }, d = 1, ...e }) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js index f041d40c5..923759c18 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/inherited-scope.js @@ -1,5 +1,6 @@ -const a = 1 +const a = 1; try { -} catch (e) { - a +} +catch (e) { + a; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js index 1cd0412dc..2874fcb17 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/catch/scope.js @@ -1,7 +1,8 @@ try { -} catch (e) { - e - let a = 1 } -const unresolved = e -const dontReference2 = a +catch (e) { + e; + let a = 1; +} +const unresolved = e; +const dontReference2 = a; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js index 4e6a6de65..f230fa0f4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-accessor-property.js @@ -1 +1,2 @@ -class Foo {} +class Foo { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js index 4e6a6de65..f230fa0f4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract-property.js @@ -1 +1,2 @@ -class Foo {} +class Foo { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js index a869c2849..2e2439c32 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/abstract.js @@ -1 +1,2 @@ -class A {} +class A { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js index a869c2849..2e2439c32 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property-type-annotation.js @@ -1 +1,2 @@ -class A {} +class A { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js index 5c4cbf5f0..1b7a70c6b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/accessor-property.js @@ -1,8 +1,8 @@ -const x = 1 +const x = 1; class A { - constructor() { - this.prop1 = 1 - this.prop2 = x - } + constructor() { + this.prop1 = 1; + this.prop2 = x; + } } -const unresolved = prop1 +const unresolved = prop1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js index 76c82270d..420e53dbe 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/computed-member.js @@ -1,9 +1,9 @@ -var _a -const outer1 = 'a' -const outer2 = 'b' +var _a; +const outer1 = 'a'; +const outer2 = 'b'; class A { - constructor() { - this[_a] = 1 - } - [((_a = outer1), outer2)]() {} + constructor() { + this[_a] = 1; + } + [(_a = outer1, outer2)]() { } } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js index a16946fd6..1d2ce7774 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends-generic.js @@ -1,2 +1,4 @@ -class A {} -class B extends A {} +class A { +} +class B extends A { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js index a16946fd6..1d2ce7774 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/extends.js @@ -1,2 +1,4 @@ -class A {} -class B extends A {} +class A { +} +class B extends A { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js index dcde0c7bf..cc0572404 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-extends.js @@ -1 +1,2 @@ -class Foo extends Bar {} +class Foo extends Bar { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js index 4e6a6de65..f230fa0f4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic-ref-implements.js @@ -1 +1,2 @@ -class Foo {} +class Foo { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js index 4e6a6de65..f230fa0f4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/generic.js @@ -1 +1,2 @@ -class Foo {} +class Foo { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js index 3a43d09b4..7d95eb649 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements-generic.js @@ -1 +1,2 @@ -class B {} +class B { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js index 3a43d09b4..7d95eb649 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/implements.js @@ -1 +1,2 @@ -class B {} +class B { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js index 4e6a6de65..f230fa0f4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/index-signature.js @@ -1 +1,2 @@ -class Foo {} +class Foo { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js index 491bf19b1..aee6cabc5 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method-param-default.js @@ -1,10 +1,10 @@ // https://github.com/typescript-eslint/typescript-eslint/issues/2941 class A { - constructor(printName) { - this.printName = printName - } - openPort(printerName = this.printerName) { - this.tscOcx.ActiveXopenport(printerName) - return this - } + constructor(printName) { + this.printName = printName; + } + openPort(printerName = this.printerName) { + this.tscOcx.ActiveXopenport(printerName); + return this; + } } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js index ceb749075..3b6da42b3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/method.js @@ -1,7 +1,7 @@ class A { - method(a, [b], { c }, d = 1, e = a, f) { - a - } + method(a, [b], { c }, d = 1, e = a, f) { + a; + } } -const unresolved1 = f -const unresolved2 = method +const unresolved1 = f; +const unresolved2 = method; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js index 1ec3cc66b..65cd49d00 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/new.js @@ -1,2 +1,3 @@ -class A {} -new A() +class A { +} +new A(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js index ddd9ad121..6a32e003d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/parameter-properties.js @@ -1,13 +1,13 @@ -const outer = 1 +const outer = 1; class A { - constructor(a, b = 1, c = a, d = outer, e, f) { - this.a = a - this.b = b - this.c = c - this.d = d - this.e = e - this.f = f - a - } + constructor(a, b = 1, c = a, d = outer, e, f) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.e = e; + this.f = f; + a; + } } -const unresovled = e +const unresovled = e; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js index 444b1862d..4f477efef 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/private-identifier.js @@ -1,6 +1,6 @@ class Foo { - #bar - constructor() { - this.#bar = 1 - } + #bar; + constructor() { + this.#bar = 1; + } } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js index a869c2849..2e2439c32 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties-type-annotation.js @@ -1 +1,2 @@ -class A {} +class A { +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js index 5c4cbf5f0..1b7a70c6b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/properties.js @@ -1,8 +1,8 @@ -const x = 1 +const x = 1; class A { - constructor() { - this.prop1 = 1 - this.prop2 = x - } + constructor() { + this.prop1 = 1; + this.prop2 = x; + } } -const unresolved = prop1 +const unresolved = prop1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js index 93b92f6cf..b043d4bfd 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-block.js @@ -1,3 +1,3 @@ class A { - static {} + static { } } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js index 99870b8d6..2cb63cbad 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-external-ref.js @@ -1,6 +1,6 @@ -function f() {} +function f() { } class A { - static { - f() - } + static { + f(); + } } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js index da6395ddd..edcc44834 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/static-with-constructor.js @@ -1,8 +1,8 @@ // https://github.com/typescript-eslint/typescript-eslint/issues/5577 -function f() {} +function f() { } class A { - static {} - constructor() { - f() - } + static { } + constructor() { + f(); + } } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js index a6eac7190..73bf9cca3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/declaration/type-reference.js @@ -1,2 +1,3 @@ -class A {} -const v = A +class A { +} +const v = A; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js index a0391181f..e0a74f88c 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/computed-member.js @@ -1,9 +1,9 @@ -var _a -const outer1 = 'a' -const outer2 = 'b' +var _a; +const outer1 = 'a'; +const outer2 = 'b'; const A = class { - constructor() { - this[_a] = 1 - } - [((_a = outer1), outer2)]() {} -} + constructor() { + this[_a] = 1; + } + [(_a = outer1, outer2)]() { } +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js index 7e7ad6043..1ac6ac049 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/extends.js @@ -1,2 +1,4 @@ -class A {} -const B = class extends A {} +class A { +} +const B = class extends A { +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js index 5d8cea7ec..868cd46dc 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/method.js @@ -1,7 +1,7 @@ const A = class { - method(a, [b], { c }, d = 1, e = a, f) { - a - } -} -const unresolved1 = f -const unresolved2 = method + method(a, [b], { c }, d = 1, e = a, f) { + a; + } +}; +const unresolved1 = f; +const unresolved2 = method; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js index 69ef25f54..a1761bd1d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/new.js @@ -1,2 +1,3 @@ -const A = class {} -new A() +const A = class { +}; +new A(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js index 21461869b..1824fbcad 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/parameter-properties.js @@ -1,13 +1,13 @@ -const outer = 1 +const outer = 1; const A = class { - constructor(a, b = 1, c = a, d = outer, e, f) { - this.a = a - this.b = b - this.c = c - this.d = d - this.e = e - this.f = f - a - } -} -const unresovled = e + constructor(a, b = 1, c = a, d = outer, e, f) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.e = e; + this.f = f; + a; + } +}; +const unresovled = e; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js index 99825a5a2..c61c3ca21 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/private-identifier.js @@ -1,6 +1,6 @@ const Foo = class { - #bar - constructor() { - this.#bar = 1 - } -} + #bar; + constructor() { + this.#bar = 1; + } +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js index af6375fbf..b63a8dd0f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/properties.js @@ -1,8 +1,8 @@ -const x = 1 +const x = 1; const A = class { - constructor() { - this.prop1 = 1 - this.prop2 = x - } -} -const unresolved = prop + constructor() { + this.prop1 = 1; + this.prop2 = x; + } +}; +const unresolved = prop; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js index 0e424fe88..a83e4f7b1 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/class/expression/self-reference-super.js @@ -1,3 +1,4 @@ const A = class A - // this A references the class A, not the variable A - extends A {} +// this A references the class A, not the variable A + extends A { +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js index 0a67dcd26..5d58913da 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/accessor.js @@ -1,28 +1,19 @@ -var __decorate = - (this && this.__decorate) || - function (decorators, target, key, desc) { - var c = arguments.length, - r = - c < 3 - ? target - : desc === null - ? (desc = Object.getOwnPropertyDescriptor(target, key)) - : desc, - d - if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') - r = Reflect.decorate(decorators, target, key, desc) - else - for (var i = decorators.length - 1; i >= 0; i--) - if ((d = decorators[i])) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r - return (c > 3 && r && Object.defineProperty(target, key, r), r) - } -function decorator() {} +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +function decorator() { } class Foo { - get foo() { - return 1 - } - set bar(value) {} + get foo() { + return 1; + } + set bar(value) { } } -__decorate([decorator], Foo.prototype, 'foo', null) -__decorate([decorator], Foo.prototype, 'bar', null) +__decorate([ + decorator +], Foo.prototype, "foo", null); +__decorate([ + decorator +], Foo.prototype, "bar", null); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js index 237c90943..360172f93 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-deco-with-object-param.js @@ -1,31 +1,16 @@ // https://github.com/typescript-eslint/typescript-eslint/issues/2942 -var __decorate = - (this && this.__decorate) || - function (decorators, target, key, desc) { - var c = arguments.length, - r = - c < 3 - ? target - : desc === null - ? (desc = Object.getOwnPropertyDescriptor(target, key)) - : desc, - d - if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') - r = Reflect.decorate(decorators, target, key, desc) - else - for (var i = decorators.length - 1; i >= 0; i--) - if ((d = decorators[i])) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r - return (c > 3 && r && Object.defineProperty(target, key, r), r) - } -let Foo = class Foo {} -Foo = __decorate( - [ +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +let Foo = class Foo { +}; +Foo = __decorate([ deco({ - components: { - val: true, - }, - }), - ], - Foo, -) + components: { + val: true, + }, + }) +], Foo); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js index d9b868026..91884a9b1 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class-property.js @@ -1,22 +1,12 @@ -var __decorate = - (this && this.__decorate) || - function (decorators, target, key, desc) { - var c = arguments.length, - r = - c < 3 - ? target - : desc === null - ? (desc = Object.getOwnPropertyDescriptor(target, key)) - : desc, - d - if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') - r = Reflect.decorate(decorators, target, key, desc) - else - for (var i = decorators.length - 1; i >= 0; i--) - if ((d = decorators[i])) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r - return (c > 3 && r && Object.defineProperty(target, key, r), r) - } -function decorator() {} -class Foo {} -__decorate([decorator], Foo.prototype, 'foo', void 0) +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +function decorator() { } +class Foo { +} +__decorate([ + decorator +], Foo.prototype, "foo", void 0); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js index f9987c8af..5756f1ef2 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/class.js @@ -1,22 +1,12 @@ -var __decorate = - (this && this.__decorate) || - function (decorators, target, key, desc) { - var c = arguments.length, - r = - c < 3 - ? target - : desc === null - ? (desc = Object.getOwnPropertyDescriptor(target, key)) - : desc, - d - if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') - r = Reflect.decorate(decorators, target, key, desc) - else - for (var i = decorators.length - 1; i >= 0; i--) - if ((d = decorators[i])) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r - return (c > 3 && r && Object.defineProperty(target, key, r), r) - } -function decorator() {} -let Foo = class Foo {} -Foo = __decorate([decorator], Foo) +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +function decorator() { } +let Foo = class Foo { +}; +Foo = __decorate([ + decorator +], Foo); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js index 211147e2d..366d4f624 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/method.js @@ -1,24 +1,13 @@ -var __decorate = - (this && this.__decorate) || - function (decorators, target, key, desc) { - var c = arguments.length, - r = - c < 3 - ? target - : desc === null - ? (desc = Object.getOwnPropertyDescriptor(target, key)) - : desc, - d - if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') - r = Reflect.decorate(decorators, target, key, desc) - else - for (var i = decorators.length - 1; i >= 0; i--) - if ((d = decorators[i])) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r - return (c > 3 && r && Object.defineProperty(target, key, r), r) - } -function decorator() {} +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +function decorator() { } class Foo { - foo() {} + foo() { } } -__decorate([decorator], Foo.prototype, 'foo', null) +__decorate([ + decorator +], Foo.prototype, "foo", null); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js index 6e8cdcf27..d0d097a09 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter-property.js @@ -1,34 +1,20 @@ -var __decorate = - (this && this.__decorate) || - function (decorators, target, key, desc) { - var c = arguments.length, - r = - c < 3 - ? target - : desc === null - ? (desc = Object.getOwnPropertyDescriptor(target, key)) - : desc, - d - if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') - r = Reflect.decorate(decorators, target, key, desc) - else - for (var i = decorators.length - 1; i >= 0; i--) - if ((d = decorators[i])) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r - return (c > 3 && r && Object.defineProperty(target, key, r), r) - } -var __param = - (this && this.__param) || - function (paramIndex, decorator) { - return function (target, key) { - decorator(target, key, paramIndex) - } - } -function decorator() {} +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +function decorator() { } let Foo = class Foo { - constructor(a, b = 1) { - this.a = a - this.b = b - } -} -Foo = __decorate([__param(0, decorator), __param(1, decorator)], Foo) + constructor(a, b = 1) { + this.a = a; + this.b = b; + } +}; +Foo = __decorate([ + __param(0, decorator), + __param(1, decorator) +], Foo); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js index 3f4b05c19..22a580ff7 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/parameter.js @@ -1,43 +1,21 @@ -var __decorate = - (this && this.__decorate) || - function (decorators, target, key, desc) { - var c = arguments.length, - r = - c < 3 - ? target - : desc === null - ? (desc = Object.getOwnPropertyDescriptor(target, key)) - : desc, - d - if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') - r = Reflect.decorate(decorators, target, key, desc) - else - for (var i = decorators.length - 1; i >= 0; i--) - if ((d = decorators[i])) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r - return (c > 3 && r && Object.defineProperty(target, key, r), r) - } -var __param = - (this && this.__param) || - function (paramIndex, decorator) { - return function (target, key) { - decorator(target, key, paramIndex) - } - } -function decorator() {} +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +function decorator() { } class A { - foo(a, [b], { c }, d = 1, decorator, decorator) {} + foo(a, [b], { c }, d = 1, decorator, decorator) { } } -__decorate( - [ +__decorate([ __param(0, decorator), __param(1, decorator), __param(2, decorator), __param(3, decorator), __param(4, decorator), - __param(5, d), - ], - A.prototype, - 'foo', - null, -) + __param(5, d) +], A.prototype, "foo", null); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js index 02fa2c1d4..59f131be3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/decorators/typeof-this.js @@ -1,24 +1,13 @@ -var __decorate = - (this && this.__decorate) || - function (decorators, target, key, desc) { - var c = arguments.length, - r = - c < 3 - ? target - : desc === null - ? (desc = Object.getOwnPropertyDescriptor(target, key)) - : desc, - d - if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') - r = Reflect.decorate(decorators, target, key, desc) - else - for (var i = decorators.length - 1; i >= 0; i--) - if ((d = decorators[i])) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r - return (c > 3 && r && Object.defineProperty(target, key, r), r) - } -function decorator() {} +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +function decorator() { } let Foo = class Foo { - bar(baz) {} -} -Foo = __decorate([decorator], Foo) + bar(baz) { } +}; +Foo = __decorate([ + decorator +], Foo); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js index b944a8d36..a0fb37e1e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array-assignment.js @@ -1,3 +1,3 @@ -const obj = {} -let b, c -;[obj.a, b, [c]] = [] +const obj = {}; +let b, c; +[obj.a, b, [c]] = []; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js index 8536aa772..86f9cf690 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/array.js @@ -1 +1 @@ -const [a, b, c, d = 1, [e], [f] = g, ...rest] = [] +const [a, b, c, d = 1, [e], [f] = g, ...rest] = []; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js index 2c942a87c..dbfbfe75f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object-assignment.js @@ -1,6 +1,6 @@ -const obj = {} -;({ - shorthand, - key: value, - hello: { world: obj.a }, -} = object) +const obj = {}; +({ + shorthand, + key: value, + hello: { world: obj.a }, +} = object); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js index 2311cfa00..4e56dc72c 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/destructuring/object.js @@ -1,6 +1 @@ -const { - shorthand, - key: value, - hello: { world }, - array: [a, b, c, d], -} = object +const { shorthand, key: value, hello: { world }, array: [a, b, c, d], } = object; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js index 114b4e0df..43a75cae0 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/all.js @@ -1,3 +1,3 @@ //// @sourceType = module -export * from 'foo' -export * as bar from 'foo' +export * from 'foo'; +export * as bar from 'foo'; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js index 141602344..c5b2574d5 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default-type.js @@ -1,3 +1,3 @@ //// @sourceType = module -const T = 1 // unreferenced -export default T +const T = 1; // unreferenced +export default T; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js index 90a382f86..8bf196ed6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default1.js @@ -1,2 +1,2 @@ //// @sourceType = module -export default function f() {} +export default function f() { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js index d0264e6ba..2c21f0716 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default2.js @@ -1,3 +1,3 @@ //// @sourceType = module -const a = 1 -export default a +const a = 1; +export default a; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js index a3e655494..821dbfd12 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default3.js @@ -1,2 +1,2 @@ //// @sourceType = module -export default 1 +export default 1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js index 88b7416a3..9a030f478 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/default4.js @@ -1,2 +1,2 @@ //// @sourceType = module -export default function () {} +export default function () { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js index a58f4e869..49c03efc1 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals1.js @@ -1,3 +1,3 @@ //// @sourceType = module -const x = 1 -export {} +const x = 1; +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js index 7d557b8b6..89f94bfae 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals2.js @@ -1,2 +1,2 @@ //// @sourceType = module -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js index 336ce12bb..cb0ff5c3b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals3-type.js @@ -1 +1 @@ -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js index 336ce12bb..cb0ff5c3b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/equals4-type.js @@ -1 +1 @@ -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js index 70a39188e..130c4d668 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-dual.js @@ -1,2 +1,2 @@ -const T = 1 -export { T } +const T = 1; +export { T }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js index 28686f354..a01e7aed4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source1.js @@ -1,2 +1,2 @@ //// @sourceType = module -export { x } from 'foo' +export { x } from 'foo'; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js index e761a257b..913fb9e40 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-source2.js @@ -1,2 +1,2 @@ //// @sourceType = module -export { v as x } from 'foo' +export { v as x } from 'foo'; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js index 7d557b8b6..89f94bfae 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named-type1.js @@ -1,2 +1,2 @@ //// @sourceType = module -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js index 4d017d783..34e29b11a 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named1.js @@ -1,2 +1,2 @@ //// @sourceType = module -export const x = 1 +export const x = 1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js index 7d557b8b6..89f94bfae 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2-type.js @@ -1,2 +1,2 @@ //// @sourceType = module -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js index b27af8dce..4f8a5492f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named2.js @@ -1,3 +1,3 @@ //// @sourceType = module -const a = 1 -export { a } +const a = 1; +export { a }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js index 7d557b8b6..89f94bfae 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3-type.js @@ -1,2 +1,2 @@ //// @sourceType = module -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js index 7b72f6476..1fea45890 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/named3.js @@ -1,3 +1,3 @@ //// @sourceType = module -const v = 1 -export { v as x } +const v = 1; +export { v as x }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js index d990beba1..34ff9b484 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type-inline.js @@ -1,3 +1,3 @@ //// @sourceType = module -const T = 1 // unreferenced -export {} +const T = 1; // unreferenced +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js index d990beba1..34ff9b484 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/export/type.js @@ -1,3 +1,3 @@ //// @sourceType = module -const T = 1 // unreferenced -export {} +const T = 1; // unreferenced +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js index 5b114aab0..c1b437731 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-body-shadow.js @@ -1,5 +1,5 @@ -let a +let a; // the default param value is resolved to the outer scope let foo = (b = a) => { - let a -} + let a; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js index ac1ac6a07..67fd9a51c 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-const.js @@ -1,2 +1,2 @@ -const a = 0 -let foo = (b = a) => {} +const a = 0; +let foo = (b = a) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js index 0f9aa2cc0..c91b75870 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-let.js @@ -1,2 +1,2 @@ -let a -let foo = (b = a) => {} +let a; +let foo = (b = a) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js index 797f7c598..aeefa10b6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested-body-shadow.js @@ -1,8 +1,6 @@ -let a -let foo = ( - b = function () { - a - }, -) => { - let a -} +let a; +let foo = (b = function () { + a; +}) => { + let a; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js index e33fd0e2b..ab231bd70 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-nested.js @@ -1,6 +1,4 @@ -let a -let foo = ( - b = function () { - return a - }, -) => {} +let a; +let foo = (b = function () { + return a; +}) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js index f7a054970..50290bd03 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-param-shadow.js @@ -1,3 +1,3 @@ -let a +let a; // the default param value is resolved to the parameter -let foo = (b = a, a) => {} +let foo = (b = a, a) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js index 2904a4a5b..10cf659ea 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/readable-ref-partial.js @@ -1,2 +1,2 @@ -let a -let foo = (b = a.c) => {} +let a; +let foo = (b = a.c) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js index 5c1b057f3..1d821a01b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/default-params/writable-ref.js @@ -1 +1 @@ -let foo = (a, b = 0) => {} +let foo = (a, b = 0) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js index 878aa1aa3..4cc80bdba 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/inherited-scope.js @@ -1,4 +1,4 @@ -const parentScoped = 1 -;() => { - parentScoped + 1 -} +const parentScoped = 1; +() => { + parentScoped + 1; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js index 6297dfbd7..d24dce0d8 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/no-body.js @@ -1 +1 @@ -;(a) => a +a => a; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js index 7ef766a65..db4a4b58f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/params.js @@ -1,5 +1,5 @@ -const outer = 1 -;(a, [b], { c }, d = 1, e = a, f = outer, g) => { - a -} -const unresolved = g +const outer = 1; +(a, [b], { c }, d = 1, e = a, f = outer, g) => { + a; +}; +const unresolved = g; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js index 5f758fa3f..b3ac01ad0 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/scope.js @@ -1,6 +1,6 @@ const arrow = () => { - let i = 0 - var j = 20 - i -} -const unresolved = j + let i = 0; + var j = 20; + i; +}; +const unresolved = j; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js index 63160c8fe..845f6c130 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/body-reference.js @@ -1,3 +1,3 @@ const foo = () => { - let x -} + let x; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js index 34dbf9dcc..e71d31fff 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/param-reference.js @@ -1 +1 @@ -const foo = (a) => {} +const foo = (a) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js index ca3076a93..711242b2e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/return-value-reference.js @@ -1 +1 @@ -const foo = () => {} +const foo = () => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js index ca3076a93..711242b2e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-param-reference.js @@ -1 +1 @@ -const foo = () => {} +const foo = () => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js index ca3076a93..711242b2e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-parameters/type-parameter-declaration.js @@ -1 +1 @@ -const foo = () => {} +const foo = () => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js index 415f5fd99..ed880c59f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts1.js @@ -1 +1 @@ -const foo = (arg) => {} +const foo = (arg) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js index 415f5fd99..ed880c59f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate-asserts2.js @@ -1 +1 @@ -const foo = (arg) => {} +const foo = (arg) => { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js index 642e0666b..e40a5bb4e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate1.js @@ -1,3 +1,3 @@ const foo = (arg) => { - return typeof arg === 'string' -} + return typeof arg === 'string'; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js index 642e0666b..e40a5bb4e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/arrow/type-predicate2.js @@ -1,3 +1,3 @@ const foo = (arg) => { - return typeof arg === 'string' -} + return typeof arg === 'string'; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js index 9d5a44510..87dffad27 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-body-shadow.js @@ -1,5 +1,5 @@ -let a +let a; // the default param value is resolved to the outer scope function foo(b = a) { - let a + let a; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js index 4b20dd288..def360de5 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-const.js @@ -1,2 +1,2 @@ -const a = 0 -function foo(b = a) {} +const a = 0; +function foo(b = a) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js index 36b5b7267..5820a5f70 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-let.js @@ -1,2 +1,2 @@ -let a -function foo(b = a) {} +let a; +function foo(b = a) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js index dafa68cca..fc7edfc0b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested-body-shadow.js @@ -1,8 +1,6 @@ -let a -function foo( - b = function () { - a - }, -) { - let a +let a; +function foo(b = function () { + a; +}) { + let a; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js index 3e09fe643..b3038a410 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-nested.js @@ -1,6 +1,4 @@ -let a -function foo( - b = function () { - return a - }, -) {} +let a; +function foo(b = function () { + return a; +}) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js index f5faaeef8..761ac2558 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-param-shadow.js @@ -1,3 +1,3 @@ -let a +let a; // the default param value is resolved to the parameter -function foo(b = a, a) {} +function foo(b = a, a) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js index efd40a37c..4c3f5b9bd 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/readable-ref-partial.js @@ -1,2 +1,2 @@ -let a -function foo(b = a.c) {} +let a; +function foo(b = a.c) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js index ca81afa12..b283075b2 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/default-params/writable-ref.js @@ -1 +1 @@ -function foo(a, b = 0) {} +function foo(a, b = 0) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js index edc56dcc7..99656fb7c 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/inherited-scope.js @@ -1,4 +1,4 @@ -const parentScoped = 1 +const parentScoped = 1; function foo() { - parentScoped + 1 + parentScoped + 1; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js index ae61fc0f0..c76d9d45d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/name-shadowed-in-body.js @@ -1,4 +1,4 @@ function Foo() { - const Foo = 1 + const Foo = 1; } -const usage = Foo +const usage = Foo; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js index d0e98917d..119ae0a4c 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/overload.js @@ -1,3 +1,3 @@ function foo(a, b) { - a + a; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js index 1cea9b240..70e410dfb 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/params.js @@ -1,5 +1,5 @@ -const outer = 1 +const outer = 1; function foo(a, [b], { c }, d = 1, e = a, f = outer, g) { - a + a; } -const unresolved = g +const unresolved = g; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js index d8a3800ee..eca804b22 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/scope.js @@ -1,6 +1,6 @@ function foo() { - let i = 0 - var j = 20 - i + let i = 0; + var j = 20; + i; } -const unresolved = j +const unresolved = j; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js index 6443d2e8e..99ecd9047 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/body-reference.js @@ -1,3 +1,3 @@ function foo() { - let x + let x; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js index ef1dd099d..a4cc7fc4b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/param-reference.js @@ -1 +1 @@ -function foo(a) {} +function foo(a) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js index b0400ee9b..e2312a2d6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/return-value-reference.js @@ -1 +1 @@ -function foo() {} +function foo() { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js index b0400ee9b..e2312a2d6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-param-reference.js @@ -1 +1 @@ -function foo() {} +function foo() { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js index b0400ee9b..e2312a2d6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-parameters/type-parameter-declaration.js @@ -1 +1 @@ -function foo() {} +function foo() { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js index 95cb35807..d0ca48a11 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts1.js @@ -1 +1 @@ -function foo(arg) {} +function foo(arg) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js index 95cb35807..d0ca48a11 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate-asserts2.js @@ -1 +1 @@ -function foo(arg) {} +function foo(arg) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js index c8fcb944f..1c688fe3d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate1.js @@ -1,3 +1,3 @@ function foo(arg) { - return typeof arg === 'string' + return typeof arg === 'string'; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js index c8fcb944f..1c688fe3d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-declaration/type-predicate2.js @@ -1,3 +1,3 @@ function foo(arg) { - return typeof arg === 'string' + return typeof arg === 'string'; } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js index afbed624a..373a21406 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/anonymous.js @@ -1 +1 @@ -const foo = function () {} +const foo = function () { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js index 94b00926b..3159efb93 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-body-shadow.js @@ -1,5 +1,5 @@ -let a +let a; // the default param value is resolved to the outer scope let foo = function (b = a) { - let a -} + let a; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js index f40cb111e..8fb3821a6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-const.js @@ -1,2 +1,2 @@ -const a = 0 -let foo = function (b = a) {} +const a = 0; +let foo = function (b = a) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js index 344970b23..a9dbcb4b5 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-let.js @@ -1,2 +1,2 @@ -let a -let foo = function (b = a) {} +let a; +let foo = function (b = a) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js index c046c9254..ccc838e43 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested-body-shadow.js @@ -1,8 +1,6 @@ -let a -let foo = function ( - b = function () { - a - }, -) { - let a -} +let a; +let foo = function (b = function () { + a; +}) { + let a; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js index 8752e1bde..1324261b0 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-nested.js @@ -1,6 +1,4 @@ -let a -let foo = function ( - b = function () { - return a - }, -) {} +let a; +let foo = function (b = function () { + return a; +}) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js index 56c650805..3a2644730 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-param-shadow.js @@ -1,3 +1,3 @@ -let a +let a; // the default param value is resolved to the parameter -let foo = function (b = a, a) {} +let foo = function (b = a, a) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js index 4ef5cf9ca..d96d99a33 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/readable-ref-partial.js @@ -1,2 +1,2 @@ -let a -let foo = function (b = a.c) {} +let a; +let foo = function (b = a.c) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js index a572ada6d..91c821269 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/default-params/writable-ref.js @@ -1 +1 @@ -let foo = function (a, b = 0) {} +let foo = function (a, b = 0) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js index a6143e7e7..362a9cda0 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/inherited-scope.js @@ -1,4 +1,4 @@ -const parentScoped = 1 +const parentScoped = 1; const foo = function () { - parentScoped + 1 -} + parentScoped + 1; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js index a26057613..8f755fd0b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/params.js @@ -1,5 +1,5 @@ -const outer = 1 +const outer = 1; const foo = function (a, [b], { c }, d = 1, e = a, f = outer, g) { - a -} -const unresolved = g + a; +}; +const unresolved = g; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js index 6506b2715..f02b67650 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/scope.js @@ -1,6 +1,6 @@ const foo = function () { - let i = 0 - var j = 20 - i -} -const unresolved = j + let i = 0; + var j = 20; + i; +}; +const unresolved = j; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js index 041ac325e..9d1252703 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/body-reference.js @@ -1,3 +1,3 @@ const foo = function () { - let x -} + let x; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js index a5d6f0e4b..b00057650 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/param-reference.js @@ -1 +1 @@ -const foo = function (a) {} +const foo = function (a) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js index afbed624a..373a21406 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/return-value-reference.js @@ -1 +1 @@ -const foo = function () {} +const foo = function () { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js index afbed624a..373a21406 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-param-reference.js @@ -1 +1 @@ -const foo = function () {} +const foo = function () { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js index afbed624a..373a21406 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-parameters/type-parameter-declaration.js @@ -1 +1 @@ -const foo = function () {} +const foo = function () { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js index f3c92620c..f06b75661 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts1.js @@ -1 +1 @@ -const foo = function (arg) {} +const foo = function (arg) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js index f3c92620c..f06b75661 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate-asserts2.js @@ -1 +1 @@ -const foo = function (arg) {} +const foo = function (arg) { }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js index 553f5c012..4ca49ea49 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate1.js @@ -1,3 +1,3 @@ const foo = function (arg) { - return typeof arg === 'string' -} + return typeof arg === 'string'; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js index 553f5c012..4ca49ea49 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/functions/function-expression/type-predicate2.js @@ -1,3 +1,3 @@ const foo = function (arg) { - return typeof arg === 'string' -} + return typeof arg === 'string'; +}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js index a0c53a48b..2f4d8e619 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/class.js @@ -1,3 +1,4 @@ //// @sourceType = module -class Foo {} -new Foo() +class Foo { +} +new Foo(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js index 46bedea68..106a0edd3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/function.js @@ -1,3 +1,3 @@ //// @sourceType = module -function top() {} -top() +function top() { } +top(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js index 30aeead21..e5ff6af2e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-const.js @@ -1,3 +1,3 @@ //// @sourceType = module -const top = () => {} -top() +const top = () => { }; +top(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js index 4f5adab17..cf14e6e6f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-let.js @@ -1,3 +1,3 @@ //// @sourceType = module -let top = () => {} -top() +let top = () => { }; +top(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js index 2bac25ca5..36eb940c3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/module/variable-decl-var.js @@ -1,3 +1,3 @@ //// @sourceType = module -var top = () => {} -top() +var top = () => { }; +top(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js index 735e2600b..3f7bde671 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/class.js @@ -1,3 +1,4 @@ //// @sourceType = script -class Foo {} -new Foo() +class Foo { +} +new Foo(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js index 075d9a3a5..b7249be29 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/function.js @@ -1,3 +1,3 @@ //// @sourceType = script -function top() {} -top() +function top() { } +top(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js index f04faa893..a540fe4ba 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-const.js @@ -1,3 +1,3 @@ //// @sourceType = script -const top = () => {} -top() +const top = () => { }; +top(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js index 9c6b1424c..925c1b9f8 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-let.js @@ -1,3 +1,3 @@ //// @sourceType = script -let top = () => {} -top() +let top = () => { }; +top(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js index 69f036d85..cf024bd7f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/global-resolution/script/variable-decl-var.js @@ -1,3 +1,3 @@ //// @sourceType = script -var top = () => {} -top() +var top = () => { }; +top(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js index dd4b5e4f7..89a08efd8 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/implicit/implicit1.js @@ -1 +1 @@ -const x = y +const x = y; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js index 290df9d57..d5997be91 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/default.js @@ -1,3 +1,3 @@ //// @sourceType = module -import v from 'foo' -v +import v from 'foo'; +v; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js index bcaf0ba3d..b38efea52 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals1.js @@ -1,3 +1,3 @@ //// @sourceType = module -foo -export {} +foo; +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js index a90405952..c1deccbdb 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/equals2.js @@ -1,3 +1,3 @@ //// @sourceType = module -const x = 1 -var foo = x +const x = 1; +var foo = x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js index 9687053be..3271e375e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named-alias.js @@ -1,3 +1,3 @@ //// @sourceType = module -import { v as t } from 'foo' -t +import { v as t } from 'foo'; +t; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js index 972213f9f..10dfc8a70 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/named.js @@ -1,3 +1,3 @@ //// @sourceType = module -import { v } from 'foo' -v +import { v } from 'foo'; +v; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js index 32a3c7e5d..0c855b606 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/namespace.js @@ -1,3 +1,3 @@ //// @sourceType = module -import * as v from 'foo' -v +import * as v from 'foo'; +v; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js index 7d557b8b6..89f94bfae 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default-value.js @@ -1,2 +1,2 @@ //// @sourceType = module -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js index b9a556e85..15c86c392 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-default.js @@ -1,3 +1,3 @@ //// @sourceType = module -const unresolved = T -export {} +const unresolved = T; +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js index 7d557b8b6..89f94bfae 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline-value.js @@ -1,2 +1,2 @@ //// @sourceType = module -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js index b9a556e85..15c86c392 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-inline.js @@ -1,3 +1,3 @@ //// @sourceType = module -const unresolved = T -export {} +const unresolved = T; +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js index 7d557b8b6..89f94bfae 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named-value.js @@ -1,2 +1,2 @@ //// @sourceType = module -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js index b9a556e85..15c86c392 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/import/type-named.js @@ -1,3 +1,3 @@ //// @sourceType = module -const unresolved = T -export {} +const unresolved = T; +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js index 207263078..f5cb89dc1 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments1.js @@ -1,7 +1,8 @@ -class Foo {} +class Foo { +} class Bar { - constructor() { - this.foo = Foo - } + constructor() { + this.foo = (Foo); + } } -new Bar() +new Bar(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js index 809ff86a0..58112b736 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/instantiation-expressions/type-arguments2.js @@ -1,4 +1,4 @@ function makeBox(value) { - return { value } + return { value }; } -const makeStringBox = makeBox +const makeStringBox = (makeBox); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js index fe73d34f1..e885d85b2 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute-spread.js @@ -1,3 +1,3 @@ -import { jsx as _jsx } from 'react/jsx-runtime' -const x = {} -_jsx(Foo, { ...x }) +import { jsx as _jsx } from "react/jsx-runtime"; +const x = {}; +_jsx(Foo, { ...x }); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js index 28820d595..f0f30446b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/attribute.js @@ -1,4 +1,4 @@ -import { jsx as _jsx } from 'react/jsx-runtime' -const x = 1 -const attr = 2 // should be unreferenced -_jsx(Foo, { attr: x }) +import { jsx as _jsx } from "react/jsx-runtime"; +const x = 1; +const attr = 2; // should be unreferenced +_jsx(Foo, { attr: x }); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js index 99e2b547f..f23dbd967 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/children.js @@ -1,3 +1,3 @@ -import { jsx as _jsx } from 'react/jsx-runtime' -const child = 1 -_jsx(Foo, { children: child }) +import { jsx as _jsx } from "react/jsx-runtime"; +const child = 1; +_jsx(Foo, { children: child }); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js index 7e61429b5..c266d55b5 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-intrinsic-name.js @@ -1,3 +1,3 @@ -import { jsx as _jsx } from 'react/jsx-runtime' -function div() {} // should not be referenced -_jsx('div', {}) +import { jsx as _jsx } from "react/jsx-runtime"; +function div() { } // should not be referenced +_jsx("div", {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js index ff6298527..c2583279d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced1.js @@ -1,6 +1,6 @@ -import { jsx as _jsx } from 'react/jsx-runtime' +import { jsx as _jsx } from "react/jsx-runtime"; const X = { - Foo() {}, -} -const Foo = 1 // should be unreferenced -_jsx(X.Foo, {}) + Foo() { }, +}; +const Foo = 1; // should be unreferenced +_jsx(X.Foo, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js index ea0160c58..36819cd92 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component-namespaced2.js @@ -1,6 +1,6 @@ -import { jsx as _jsx } from 'react/jsx-runtime' +import { jsx as _jsx } from "react/jsx-runtime"; const x = { - Foo() {}, -} -const Foo = 1 // should be unreferenced -_jsx(x.Foo, {}) // lower cased namespaces should still create a reference + Foo() { }, +}; +const Foo = 1; // should be unreferenced +_jsx(x.Foo, {}); // lower cased namespaces should still create a reference diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js index 6d141f398..4fb40d3fa 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/component.js @@ -1,3 +1,3 @@ -import { jsx as _jsx } from 'react/jsx-runtime' -function Foo() {} -_jsx(Foo, {}) +import { jsx as _jsx } from "react/jsx-runtime"; +function Foo() { } +_jsx(Foo, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js index c3c53abdd..a70097545 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxFragmentName.js @@ -1,4 +1,4 @@ +import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; //// @sourceType = 'module' -import React from 'react' -import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' -_jsx(_Fragment, {}) +import React from 'react'; +_jsx(_Fragment, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js index c3c53abdd..a70097545 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma-fragment.js @@ -1,4 +1,4 @@ +import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; //// @sourceType = 'module' -import React from 'react' -import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' -_jsx(_Fragment, {}) +import React from 'react'; +_jsx(_Fragment, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js index d2c6d70c0..120557012 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/default-jsxPragma.js @@ -1,4 +1,4 @@ +import { jsx as _jsx } from "react/jsx-runtime"; //// @sourceType = 'module' -import React from 'react' -import { jsx as _jsx } from 'react/jsx-runtime' -_jsx(Foo, {}) +import React from 'react'; +_jsx(Foo, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js index d8ede37b2..0b5105b91 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxFragmentName.js @@ -1,5 +1,5 @@ +import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; //// @sourceType = 'module' //// @jsxFragmentName = 'Fragment' -import React from 'react' // should be unreferenced -import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' -_jsx(_Fragment, {}) +import React from 'react'; // should be unreferenced +_jsx(_Fragment, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js index f6e0d9794..5521dc383 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma-jsxFragmentName.js @@ -1,6 +1,6 @@ +import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; //// @sourceType = 'module' //// @jsxPragma = 'h' //// @jsxFragmentName = 'Fragment' -import React from 'react' // should be unreferenced -import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' -_jsx(_Fragment, {}) +import React from 'react'; // should be unreferenced +_jsx(_Fragment, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js index 61c98a9df..50a6c4163 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/factory/jsxPragma.js @@ -1,5 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; //// @sourceType = 'module' //// @jsxPragma = 'h' -import React from 'react' // should be unreferenced -import { jsx as _jsx } from 'react/jsx-runtime' -_jsx(Foo, {}) +import React from 'react'; // should be unreferenced +_jsx(Foo, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js index 4e6206acd..48438b78e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment-children.js @@ -1,3 +1,3 @@ -import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' -const child = 1 -_jsx(_Fragment, { children: child }) +import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; +const child = 1; +_jsx(_Fragment, { children: child }); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js index b3fecc4e9..1df8c5f09 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/fragment.js @@ -1,2 +1,2 @@ -import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' -_jsx(_Fragment, {}) +import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; +_jsx(_Fragment, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js index e2a7553ff..e344cf6fa 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/generic-type-param.js @@ -1,2 +1,2 @@ -import { jsx as _jsx } from 'react/jsx-runtime' -_jsx(Foo, {}) +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx(Foo, {}); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js index dfb39635b..c661cf448 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/namespaced-attribute.js @@ -1,8 +1,8 @@ -import * as React from 'react' -import { jsx as _jsx } from 'react/jsx-runtime' +import { jsx as _jsx } from "react/jsx-runtime"; +import * as React from 'react'; // Both of these are equivalent: -const x = _jsx(Foo, { 'a:b': 'hello' }) -const y = _jsx(Foo, { 'a:b': 'hello' }) +const x = _jsx(Foo, { "a:b": "hello" }); +const y = _jsx(Foo, { "a:b": "hello" }); function Foo(props) { - return _jsx('div', { children: props['a:b'] }) + return _jsx("div", { children: props['a:b'] }); } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js index 0f3e0598e..38adecfc6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/text.js @@ -1,3 +1,3 @@ -import { Fragment as _Fragment, jsx as _jsx } from 'react/jsx-runtime' -const Foo = 1 // should be unreferenced -_jsx(_Fragment, { children: 'Foo' }) +import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; +const Foo = 1; // should be unreferenced +_jsx(_Fragment, { children: "Foo" }); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js index a87091dd9..502ab3f89 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/jsx/this-jsxidentifier.js @@ -1,12 +1,12 @@ -import { jsx as _jsx } from 'react/jsx-runtime' +import { jsx as _jsx } from "react/jsx-runtime"; class Foo { - constructor() { - this.Div = { - Element: () => _jsx('div', {}), + constructor() { + this.Div = { + Element: () => _jsx("div", {}), + }; + } + method() { + _jsx(this.foo, {}); + (_jsx(Div.Element, {}))(_jsx(this, {})); } - } - method() { - _jsx(this.foo, {}) - _jsx(Div.Element, {})(_jsx(this, {})) - } } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js index 907178baa..4051c2082 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/member-expression/member-expression.js @@ -1,6 +1,6 @@ -const x = {} -x.a -x.a.b.c.d -x['a'] -x?.a.b.c -x?.['a'] +const x = {}; +x.a; +x.a.b.c.d; +x['a']; +x?.a.b.c; +x?.['a']; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js index 83d9064d9..3e9dee8fc 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/new-expression.js @@ -1,3 +1,4 @@ -class Foo {} -const a = 1 -new Foo(a) +class Foo { +} +const a = 1; +new Foo(a); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js index ff2007e45..ac22183e8 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters1.js @@ -1 +1 @@ -new Foo() +new Foo(); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js index 01a1cf5ad..aa27364d8 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/new-expression/type-parameters2.js @@ -1,2 +1,2 @@ -const T = 1 -new Foo() // should not resolve to value +const T = 1; +new Foo(); // should not resolve to value diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js index 04544d174..2cc324fb7 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/external-ref.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo) { - Foo[(Foo['a'] = 1)] = 'a' -})(Foo || (Foo = {})) -Foo.a +var Foo; +(function (Foo) { + Foo[Foo["a"] = 1] = "a"; +})(Foo || (Foo = {})); +Foo.a; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js index 1cf42df97..93c461cb3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member-ref.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo) { - Foo[(Foo['a'] = 1)] = 'a' - Foo[(Foo['b'] = 1)] = 'b' -})(Foo || (Foo = {})) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 1] = "a"; + Foo[Foo["b"] = 1] = "b"; +})(Foo || (Foo = {})); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js index f87f67dc9..3c7064b26 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/literal-member.js @@ -1,4 +1,4 @@ -var Foo -;(function (Foo) { - Foo[(Foo['a'] = 1)] = 'a' -})(Foo || (Foo = {})) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 1] = "a"; +})(Foo || (Foo = {})); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js index 1cf42df97..93c461cb3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/member-ref.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo) { - Foo[(Foo['a'] = 1)] = 'a' - Foo[(Foo['b'] = 1)] = 'b' -})(Foo || (Foo = {})) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 1] = "a"; + Foo[Foo["b"] = 1] = "b"; +})(Foo || (Foo = {})); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js index cf7d73523..9292f93b4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/scope.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo) { - Foo[(Foo['a'] = 0)] = 'a' -})(Foo || (Foo = {})) -const unresolved = a +var Foo; +(function (Foo) { + Foo[Foo["a"] = 0] = "a"; +})(Foo || (Foo = {})); +const unresolved = a; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js index 1cf42df97..93c461cb3 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-enum/self-ref.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo) { - Foo[(Foo['a'] = 1)] = 'a' - Foo[(Foo['b'] = 1)] = 'b' -})(Foo || (Foo = {})) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 1] = "a"; + Foo[Foo["b"] = 1] = "b"; +})(Foo || (Foo = {})); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js index 7e8224762..d2b1f9430 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/class-namespace.js @@ -1,5 +1,6 @@ -class Foo {} -;(function (Foo) { - Foo.x = 1 -})(Foo || (Foo = {})) -const usage = Foo +class Foo { +} +(function (Foo) { + Foo.x = 1; +})(Foo || (Foo = {})); +const usage = Foo; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js index b20d2edaa..cdfff0ec6 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/function-namespace.js @@ -1,5 +1,5 @@ -function Foo() {} -;(function (Foo) { - Foo.x = 1 -})(Foo || (Foo = {})) -const usage = Foo +function Foo() { } +(function (Foo) { + Foo.x = 1; +})(Foo || (Foo = {})); +const usage = Foo; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js index abb6e05cc..a566d2b19 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/declaration-merging/namespace-variable.js @@ -1,2 +1,2 @@ -const Foo = 1 -const usage = Foo +const Foo = 1; +const usage = Foo; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js index f1ef9c6f8..d82b6d3c1 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/external-ref.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo) { - Foo.x = 1 -})(Foo || (Foo = {})) -Foo.x +var Foo; +(function (Foo) { + Foo.x = 1; +})(Foo || (Foo = {})); +Foo.x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js index fa86764a6..59d752b7e 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/name-shadowed-in-body.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo_1) { - Foo_1.Foo = 1 -})(Foo || (Foo = {})) -const usage = Foo +var Foo; +(function (Foo_1) { + Foo_1.Foo = 1; +})(Foo || (Foo = {})); +const usage = Foo; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js index a7df4d765..48ec9763a 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/namespace.js @@ -1,7 +1,7 @@ -var Foo -;(function (Foo) { - Foo.x = 1 - Foo.x -})(Foo || (Foo = {})) -const unresolved = x -Foo.x +var Foo; +(function (Foo) { + Foo.x = 1; + Foo.x; +})(Foo || (Foo = {})); +const unresolved = x; +Foo.x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js index ca541ec2a..060980be7 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/nested-namespace-alias.js @@ -1,8 +1,8 @@ -export var A -;(function (A) { - let X - ;(function (X) { - X.Y = 1 - })((X = A.X || (A.X = {}))) -})(A || (A = {})) -const X = 23 +export var A; +(function (A) { + let X; + (function (X) { + X.Y = 1; + })(X = A.X || (A.X = {})); +})(A || (A = {})); +const X = 23; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js index 52e93dffd..7b16268a1 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/scope.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo) { - const x = 1 -})(Foo || (Foo = {})) -const unresolved = x +var Foo; +(function (Foo) { + const x = 1; +})(Foo || (Foo = {})); +const unresolved = x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js index 0840cd003..f5d071d55 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/ts-module/self-ref.js @@ -1,5 +1,5 @@ -var Foo -;(function (Foo) { - Foo.x = 1 - Foo.x -})(Foo || (Foo = {})) +var Foo; +(function (Foo) { + Foo.x = 1; + Foo.x; +})(Foo || (Foo = {})); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js index 7c9de26db..61f037f51 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-array-destructure.js @@ -1 +1 @@ -function foo([a]) {} +function foo([a]) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js index 05d6345c8..7540c0d39 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-default.js @@ -1 +1 @@ -function foo(a = 1) {} +function foo(a = 1) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js index 8686d5c2d..df2a48f1f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-object-destructure.js @@ -1 +1 @@ -function foo({ a }) {} +function foo({ a }) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js index 9a3f7f00b..09a5402c7 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter-rest.js @@ -1 +1 @@ -function foo(...a) {} +function foo(...a) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js index ef1dd099d..a4cc7fc4b 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/parameter.js @@ -1 +1 @@ -function foo(a) {} +function foo(a) { } diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js index 268646627..e8483fadf 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-array-destructure.js @@ -1 +1 @@ -const [x] = [] +const [x] = []; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js index 3b6bb8a11..943c458c7 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-const.js @@ -1 +1 @@ -const x = 1 +const x = 1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js index d29e51d21..2756c24c4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-let.js @@ -1 +1 @@ -let x +let x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js index 3ada65d60..d7cb93de4 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-object-destructure.js @@ -1 +1 @@ -const { x } = {} +const { x } = {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js index 2660e277b..96f6d3a3f 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-annotation/variable-var.js @@ -1 +1 @@ -var x +var x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js index bae16dfec..67a65d961 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/angle-bracket.js @@ -1,2 +1,2 @@ -const x = 1 -x +const x = 1; +x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js index bae16dfec..67a65d961 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/as.js @@ -1,2 +1,2 @@ -const x = 1 -x +const x = 1; +x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js index 1c27a6483..32770881d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/angle-bracket-assignment.js @@ -1,2 +1,2 @@ -let x = 1 -x += 1 +let x = 1; +x += 1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js index 1c27a6483..32770881d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/as-assignment.js @@ -1,2 +1,2 @@ -let x = 1 -x += 1 +let x = 1; +x += 1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js index 1c27a6483..32770881d 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/assignment/non-null-assignment.js @@ -1,2 +1,2 @@ -let x = 1 -x += 1 +let x = 1; +x += 1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js index 6703e1bcb..3c7d487eb 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/angle-bracket-increment.js @@ -1,2 +1,2 @@ -let x = 1 -x++ +let x = 1; +x++; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js index 6703e1bcb..3c7d487eb 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/as-increment.js @@ -1,2 +1,2 @@ -let x = 1 -x++ +let x = 1; +x++; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js index 6703e1bcb..3c7d487eb 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/increment/non-null-increment.js @@ -1,2 +1,2 @@ -let x = 1 -x++ +let x = 1; +x++; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js index bae16dfec..67a65d961 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-assertion/satisfies.js @@ -1,2 +1,2 @@ -const x = 1 -x +const x = 1; +x; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js index 612c6daae..7ed3d445c 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/dual-type-value.js @@ -1,2 +1,2 @@ -const dual = 1 -const reference2 = dual +const dual = 1; +const reference2 = dual; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js index e8d52b14b..800ffc2d8 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/function/function2.js @@ -1 +1 @@ -const arg = 1 +const arg = 1; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js index 0bc65e4cd..6f2abd859 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/index-access3.js @@ -1 +1 @@ -const k = 'a' +const k = 'a'; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js index ad03c2dce..eba059f77 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name.js @@ -1 +1 @@ -const x = 'b' +const x = 'b'; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js index f08314925..9d3396dce 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/method-computed-name2.js @@ -1,4 +1,4 @@ -var Foo -;(function (Foo) { - Foo[(Foo['a'] = 0)] = 'a' -})(Foo || (Foo = {})) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 0] = "a"; +})(Foo || (Foo = {})); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js index ad03c2dce..eba059f77 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name.js @@ -1 +1 @@ -const x = 'b' +const x = 'b'; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js index f08314925..9d3396dce 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/signatures/property-computed-name2.js @@ -1,4 +1,4 @@ -var Foo -;(function (Foo) { - Foo[(Foo['a'] = 0)] = 'a' -})(Foo || (Foo = {})) +var Foo; +(function (Foo) { + Foo[Foo["a"] = 0] = "a"; +})(Foo || (Foo = {})); diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js index 274331248..d799f9e86 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-parameters/tagged-template.js @@ -1,2 +1,2 @@ -function div(arg) {} -const StyledPayment = div`` +function div(arg) { } +const StyledPayment = div ``; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js index 708308ed0..7ad627805 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-qualified.js @@ -1 +1 @@ -const x = { y: { z: 1 } } +const x = { y: { z: 1 } }; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js index 8120c86c0..97337fde9 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query-with-parameters.js @@ -1,4 +1,4 @@ function foo(y) { - return { y } + return { y }; } -export {} +export {}; diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js index 3b6bb8a11..943c458c7 100644 --- a/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/typescript-eslint/type-declaration/type-query.js @@ -1 +1 @@ -const x = 1 +const x = 1; From 2ecf6078229fbb789c33ff6549cf92476efe9780 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 4 Apr 2026 23:26:10 +0900 Subject: [PATCH 73/88] test(plugin-rsc): add local class self-reference fixtures Co-authored-by: Codex --- .../fixtures/scope/class-decl-self-extends.js | 1 + .../class-decl-self-extends.js.snap.json | 13 +++++++ .../fixtures/scope/class-decl-self.js | 5 +++ .../scope/class-decl-self.js.snap.json | 27 ++++++++++++++ .../fixtures/scope/class-expr-self-extends.js | 1 + .../class-expr-self-extends.js.snap.json | 22 ++++++++++++ .../fixtures/scope/class-expr-self.js | 5 +++ .../scope/class-expr-self.js.snap.json | 36 +++++++++++++++++++ 8 files changed, 110 insertions(+) create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self-extends.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self-extends.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self-extends.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self-extends.js.snap.json create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self-extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self-extends.js new file mode 100644 index 000000000..a6891e2be --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self-extends.js @@ -0,0 +1 @@ +class Self extends Self {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self-extends.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self-extends.js.snap.json new file mode 100644 index 000000000..224b86467 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self-extends.js.snap.json @@ -0,0 +1,13 @@ +{ + "type": "Program", + "declarations": [ + "Self" + ], + "references": [ + { + "name": "Self", + "declaredAt": "Program" + } + ], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self.js b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self.js new file mode 100644 index 000000000..f87144852 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self.js @@ -0,0 +1,5 @@ +class Self { + method() { + return Self + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self.js.snap.json new file mode 100644 index 000000000..c3c61c1f4 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-decl-self.js.snap.json @@ -0,0 +1,27 @@ +{ + "type": "Program", + "declarations": [ + "Self" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Self", + "declaredAt": "Program" + } + ], + "children": [] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self-extends.js b/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self-extends.js new file mode 100644 index 000000000..0ca0751ea --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self-extends.js @@ -0,0 +1 @@ +const C = class Self extends Self {} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self-extends.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self-extends.js.snap.json new file mode 100644 index 000000000..f9b631bae --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self-extends.js.snap.json @@ -0,0 +1,22 @@ +{ + "type": "Program", + "declarations": [ + "C" + ], + "references": [], + "children": [ + { + "type": "ClassExpression:Self", + "declarations": [ + "Self" + ], + "references": [ + { + "name": "Self", + "declaredAt": "Program > ClassExpression:Self" + } + ], + "children": [] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self.js b/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self.js new file mode 100644 index 000000000..4969ee030 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self.js @@ -0,0 +1,5 @@ +const C = class Self { + method() { + return Self + } +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self.js.snap.json new file mode 100644 index 000000000..d79f71944 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/class-expr-self.js.snap.json @@ -0,0 +1,36 @@ +{ + "type": "Program", + "declarations": [ + "C" + ], + "references": [], + "children": [ + { + "type": "ClassExpression:Self", + "declarations": [ + "Self" + ], + "references": [], + "children": [ + { + "type": "FunctionExpression", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "Self", + "declaredAt": "Program > ClassExpression:Self" + } + ], + "children": [] + } + ] + } + ] + } + ] +} From f72f3d4a3e13083cec1ad23594c106709a525ddb Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 08:50:18 +0900 Subject: [PATCH 74/88] refactor: nit --- packages/plugin-rsc/src/transforms/scope.ts | 25 +++++++-------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 17a627ead..3e59885b2 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -65,7 +65,7 @@ export function buildScopeTree(ast: Program): ScopeTree { const ancestors: Node[] = [] walk(ast, { - enter(node, parent) { + enter(node) { ancestors.push(node) if (node.type === 'ImportDeclaration') { for (const spec of node.specifiers) { @@ -138,11 +138,7 @@ export function buildScopeTree(ast: Program): ScopeTree { // the path key for binding instead of the bare name. if ( node.type === 'Identifier' && - isReferenceIdentifier( - node, - parent ?? undefined, - ancestors.slice(0, -1).reverse(), - ) + isReferenceIdentifier(node, ancestors.slice(0, -1).reverse()) ) { rawReferences.push({ id: node, visitScope: current }) } @@ -157,7 +153,9 @@ export function buildScopeTree(ast: Program): ScopeTree { }) // ── Post-walk fixup: resolve references against the complete scope tree ── - const scopeToReferences = new Map() + const scopeToReferences = new Map( + [...nodeScope.values()].map((scope) => [scope, []]), + ) const referenceToDeclaredScope = new Map() for (const { id, visitScope } of rawReferences) { @@ -171,9 +169,6 @@ export function buildScopeTree(ast: Program): ScopeTree { // Propagate reference up through all ancestor scopes let scope: Scope | undefined = visitScope while (scope) { - if (!scopeToReferences.has(scope)) { - scopeToReferences.set(scope, []) - } scopeToReferences.get(scope)!.push(id) scope = scope.parent } @@ -205,13 +200,9 @@ function isFunctionNode(node: Node): node is AnyFunctionNode { // adapted for this ESTree-only scope walk. This is easier to audit than a // negated binding check because many identifier positions are syntax-only names // rather than bindings or references. -function isReferenceIdentifier( - node: Identifier, - parent?: Node, - parentStack: Node[] = [], -): boolean { +function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { + const parent = parentStack[0] if (!parent) return true - const grandparent = parentStack[1] // declaration id if ( @@ -255,7 +246,7 @@ function isReferenceIdentifier( // object destructuring pattern if ( parent.type === 'Property' && - grandparent?.type === 'ObjectPattern' && + parentStack[1]?.type === 'ObjectPattern' && parent.value === node ) { return isInDestructuringAssignment(parentStack) From f6f1035f1225bb28c327b3aa25733940945e0e9c Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 09:09:35 +0900 Subject: [PATCH 75/88] chore: more comment for human --- packages/plugin-rsc/src/transforms/scope.ts | 26 +++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 3e59885b2..04bf4590a 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -205,6 +205,7 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { if (!parent) return true // declaration id + // disregard the `x` in `let x = y`, `class X {}`, or `catch (x) {}` if ( parent.type === 'CatchClause' || ((parent.type === 'VariableDeclarator' || @@ -217,16 +218,21 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { if (isFunctionNode(parent)) { // function declaration/expression id + // disregard the `f` in `function f() {}` or `(function f() {})` if ('id' in parent && parent.id === node) { return false } + // params list + // disregard the `x` in `function f(x) {}` and nested binding patterns if (parent.params.some((param) => patternContainsIdentifier(param, node))) { return false } } // class method / class field name + // disregard the `foo` in `class { foo() {} }` or `class { foo = bar }`, + // but keep it in `class { [foo]() {} }` or `class { [foo] = bar }` if ( (parent.type === 'MethodDefinition' || parent.type === 'PropertyDefinition') && @@ -237,13 +243,15 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { } // property key + // disregard the `foo` in `{ foo: bar }`, but keep it in `{ [foo]: bar }` if (isStaticPropertyKey(node, parent)) { return false } // Unlike Vite SSR, this walk does not pre-mark pattern nodes in a WeakSet, // so we use the ESTree parent stack directly to recognize object patterns. - // object destructuring pattern + // disregard the `bar` in `({ foo: bar } = obj)`, but keep it as a binding in + // `const { foo: bar } = obj` if ( parent.type === 'Property' && parentStack[1]?.type === 'ObjectPattern' && @@ -253,24 +261,27 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { } // array destructuring pattern + // disregard the `x` in `[x] = value`, but keep it as a binding in + // `const [x] = value` if (parent.type === 'ArrayPattern') { return isInDestructuringAssignment(parentStack) } // Unlike Vite SSR, this walk sees rest-pattern identifiers directly here. - // Treat rest targets like other destructuring-assignment targets for consistency - // with plain assignment targets. + // Disregard the `rest` in `({ ...rest } = value)` or `[...rest] = value`, + // but keep it as a binding in declarations or params. if (parent.type === 'RestElement' && parent.argument === node) { return isInDestructuringAssignment(parentStack) } - // parameter / pattern defaults bind on the left, but destructuring assignment - // targets are treated as references to stay coherent with plain assignment. + // disregard the `x` in `({ x = y } = obj)` or `([x = y] = arr)`, but keep it + // as a binding in `function f(x = y) {}` or `const { x = y } = obj` if (parent.type === 'AssignmentPattern' && parent.left === node) { return isInDestructuringAssignment(parentStack) } // member expression property + // disregard the `bar` in `foo.bar`, but keep it in `foo[bar]` if ( parent.type === 'MemberExpression' && parent.property === node && @@ -282,6 +293,8 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { // Unlike Vite SSR, this walk does not skip ImportDeclaration up front, so // import specifier syntax has to be filtered here as well. // import/export specifier syntax names + // disregard the `foo`/`bar` in `import foo from 'x'`, `import * as foo from 'x'`, + // or `import { foo as bar } from 'x'` if ( parent.type === 'ImportSpecifier' || parent.type === 'ImportDefaultSpecifier' || @@ -290,6 +303,7 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { return false } + // disregard the `bar` in `export { foo as bar }`, but keep the local `foo` if (parent.type === 'ExportSpecifier') { return parent.local === node } @@ -297,6 +311,8 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { // Explicitly handled here because these labels showed up as false positives in // the scope fixtures; Vite SSR's helper does not need this branch. // label identifiers + // disregard the `label` in `label: for (;;) {}`, `break label`, or + // `continue label` if ( parent.type === 'LabeledStatement' || parent.type === 'BreakStatement' || From a6bcca0379e3c22ec7282a71195b70d04621a0b7 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 09:14:07 +0900 Subject: [PATCH 76/88] refactor: de-slop --- packages/plugin-rsc/src/transforms/scope.ts | 28 ++------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 04bf4590a..1c8195018 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -2,7 +2,6 @@ import type { Program, Identifier, Node, - Pattern, FunctionDeclaration, FunctionExpression, ArrowFunctionExpression, @@ -224,8 +223,8 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { } // params list - // disregard the `x` in `function f(x) {}` and nested binding patterns - if (parent.params.some((param) => patternContainsIdentifier(param, node))) { + // disregard the `x` in `function f(x) {}` + if (parent.params.includes(node)) { return false } } @@ -331,26 +330,3 @@ function isStaticPropertyKey(node: Node, parent?: Node): boolean { function isInDestructuringAssignment(parentStack: Node[]): boolean { return parentStack.some((node) => node.type === 'AssignmentExpression') } - -function patternContainsIdentifier(pattern: Pattern, target: Node): boolean { - switch (pattern.type) { - case 'Identifier': - return pattern === target - case 'MemberExpression': - return pattern === target - case 'ObjectPattern': - return pattern.properties.some((prop) => - prop.type === 'RestElement' - ? patternContainsIdentifier(prop.argument, target) - : patternContainsIdentifier(prop.value, target), - ) - case 'ArrayPattern': - return pattern.elements.some( - (element) => element && patternContainsIdentifier(element, target), - ) - case 'RestElement': - return patternContainsIdentifier(pattern.argument, target) - case 'AssignmentPattern': - return patternContainsIdentifier(pattern.left, target) - } -} From fb56a35273ed082112b8e5607bf008f3b7217e0e Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 09:18:53 +0900 Subject: [PATCH 77/88] refactor: de-slop --- packages/plugin-rsc/src/transforms/scope.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 1c8195018..92460595a 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -229,24 +229,19 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { } } - // class method / class field name - // disregard the `foo` in `class { foo() {} }` or `class { foo = bar }`, - // but keep it in `class { [foo]() {} }` or `class { [foo] = bar }` + // property key / class method / class field name + // disregard the `foo` in `{ foo: bar }`, `class { foo() {} }` or `class { foo = bar }`, + // but keep it in `{ [foo]: bar }``, `class { [foo]() {} }` or `class { [foo] = bar }`. if ( (parent.type === 'MethodDefinition' || - parent.type === 'PropertyDefinition') && + parent.type === 'PropertyDefinition' || + parent.type === 'Property') && parent.key === node && !parent.computed ) { return false } - // property key - // disregard the `foo` in `{ foo: bar }`, but keep it in `{ [foo]: bar }` - if (isStaticPropertyKey(node, parent)) { - return false - } - // Unlike Vite SSR, this walk does not pre-mark pattern nodes in a WeakSet, // so we use the ESTree parent stack directly to recognize object patterns. // disregard the `bar` in `({ foo: bar } = obj)`, but keep it as a binding in @@ -323,10 +318,6 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { return true } -function isStaticPropertyKey(node: Node, parent?: Node): boolean { - return parent?.type === 'Property' && parent.key === node && !parent.computed -} - function isInDestructuringAssignment(parentStack: Node[]): boolean { return parentStack.some((node) => node.type === 'AssignmentExpression') } From a23b1f6b4705cfdad84fb767f0dd73c9e62f0dc4 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 09:24:44 +0900 Subject: [PATCH 78/88] chore: move code for human --- packages/plugin-rsc/src/transforms/scope.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 92460595a..81eddfb6c 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -242,6 +242,16 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { return false } + // member expression property + // disregard the `bar` in `foo.bar`, but keep it in `foo[bar]` + if ( + parent.type === 'MemberExpression' && + parent.property === node && + !parent.computed + ) { + return false + } + // Unlike Vite SSR, this walk does not pre-mark pattern nodes in a WeakSet, // so we use the ESTree parent stack directly to recognize object patterns. // disregard the `bar` in `({ foo: bar } = obj)`, but keep it as a binding in @@ -274,16 +284,6 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { return isInDestructuringAssignment(parentStack) } - // member expression property - // disregard the `bar` in `foo.bar`, but keep it in `foo[bar]` - if ( - parent.type === 'MemberExpression' && - parent.property === node && - !parent.computed - ) { - return false - } - // Unlike Vite SSR, this walk does not skip ImportDeclaration up front, so // import specifier syntax has to be filtered here as well. // import/export specifier syntax names From 0309e2bc18888364ded890d538e43370b0fd4b00 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 09:50:19 +0900 Subject: [PATCH 79/88] chore: more comment --- packages/plugin-rsc/src/transforms/scope.ts | 32 +++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 81eddfb6c..4183bb66d 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -254,8 +254,8 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { // Unlike Vite SSR, this walk does not pre-mark pattern nodes in a WeakSet, // so we use the ESTree parent stack directly to recognize object patterns. - // disregard the `bar` in `({ foo: bar } = obj)`, but keep it as a binding in - // `const { foo: bar } = obj` + // disregard the `bar` in `const { foo: bar } = obj`, but keep it as a + // reference in `({ foo: bar } = obj)` if ( parent.type === 'Property' && parentStack[1]?.type === 'ObjectPattern' && @@ -265,21 +265,21 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { } // array destructuring pattern - // disregard the `x` in `[x] = value`, but keep it as a binding in - // `const [x] = value` + // disregard the `x` in `const [x] = value`, but keep it as a reference in + // `([x] = value)` if (parent.type === 'ArrayPattern') { return isInDestructuringAssignment(parentStack) } // Unlike Vite SSR, this walk sees rest-pattern identifiers directly here. - // Disregard the `rest` in `({ ...rest } = value)` or `[...rest] = value`, - // but keep it as a binding in declarations or params. + // disregard the `rest` in declarations or params, but keep it as a reference + // in `({ ...rest } = value)` or `([...rest] = value)` if (parent.type === 'RestElement' && parent.argument === node) { return isInDestructuringAssignment(parentStack) } - // disregard the `x` in `({ x = y } = obj)` or `([x = y] = arr)`, but keep it - // as a binding in `function f(x = y) {}` or `const { x = y } = obj` + // disregard the `x` in `function f(x = y) {}` or `const { x = y } = obj`, + // but keep it as a reference in `({ x = y } = obj)` or `([x = y] = arr)` if (parent.type === 'AssignmentPattern' && parent.left === node) { return isInDestructuringAssignment(parentStack) } @@ -319,5 +319,21 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { } function isInDestructuringAssignment(parentStack: Node[]): boolean { + // `ObjectPattern` / `ArrayPattern` alone is ambiguous: the same immediate + // parent shape appears in declarations, params, and assignment targets. + // + // Treat as references: + // - `x` in `[x] = value` + // - `x` in `({ x } = value)` + // - `x` in `({ a: [x] } = value)` + // + // Do not treat as references: + // - `x` in `const [x] = value` + // - `x` in `const { x } = value` + // - `x` in `function f([x]) {}` + // - `x` in `function f({ x }) {}` + // + // The distinction only appears higher in the ancestor chain, where assignment + // targets are owned by an `AssignmentExpression`. return parentStack.some((node) => node.type === 'AssignmentExpression') } From 1160c58249333a43455318b12cdb87d267c0bca4 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:03:49 +0900 Subject: [PATCH 80/88] chore: more comment --- packages/plugin-rsc/src/transforms/scope.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 4183bb66d..473ee92c7 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -258,8 +258,8 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { // reference in `({ foo: bar } = obj)` if ( parent.type === 'Property' && - parentStack[1]?.type === 'ObjectPattern' && - parent.value === node + parent.value === node && + parentStack[1]?.type === 'ObjectPattern' ) { return isInDestructuringAssignment(parentStack) } @@ -278,6 +278,9 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { return isInDestructuringAssignment(parentStack) } + // Unlike Vite SSR, this walk classifies pattern/default nodes here instead of + // relying on `handlePattern`, `setIsNodeInPattern`, and the separate param + // traversal to classify them during traversal. // disregard the `x` in `function f(x = y) {}` or `const { x = y } = obj`, // but keep it as a reference in `({ x = y } = obj)` or `([x = y] = arr)` if (parent.type === 'AssignmentPattern' && parent.left === node) { From f45172a9ca0f046f9a18e0fdd0f2f5dce8647dd8 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:07:15 +0900 Subject: [PATCH 81/88] fix(rsc): refine scope reference classification comments Co-authored-by: Codex --- .../plugin-rsc/src/transforms/fixtures/scope/import-meta.js | 1 + .../src/transforms/fixtures/scope/import-meta.js.snap.json | 6 ++++++ packages/plugin-rsc/src/transforms/scope.ts | 6 ++++++ 3 files changed, 13 insertions(+) create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/import-meta.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/import-meta.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-meta.js b/packages/plugin-rsc/src/transforms/fixtures/scope/import-meta.js new file mode 100644 index 000000000..e9552628b --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-meta.js @@ -0,0 +1 @@ +import.meta.env.DEV diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/import-meta.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/import-meta.js.snap.json new file mode 100644 index 000000000..377029499 --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/import-meta.js.snap.json @@ -0,0 +1,6 @@ +{ + "type": "Program", + "declarations": [], + "references": [], + "children": [] +} diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 473ee92c7..483e181c8 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -252,6 +252,12 @@ function isReferenceIdentifier(node: Identifier, parentStack: Node[]): boolean { return false } + // meta property + // disregard the `import`/`meta` in `import.meta` + if (parent.type === 'MetaProperty') { + return false + } + // Unlike Vite SSR, this walk does not pre-mark pattern nodes in a WeakSet, // so we use the ESTree parent stack directly to recognize object patterns. // disregard the `bar` in `const { foo: bar } = obj`, but keep it as a From ab433784f6ac9acafb205e6150dc72232770a861 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:09:56 +0900 Subject: [PATCH 82/88] docs(plugin-rsc): scope manager prior art research MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Survey of 8 prior art scope analyzers (periscopic, vite-ssr, eslint-scope, babel-traverse, oxc_semantic, oxc-walker, next.js, typescript-eslint) compared against our custom buildScopeTree. Documents data models, scope types, resolution strategies, and bugs found in both ours and theirs — including the default-param + var hoisting spec violation in our implementation. Co-Authored-By: Claude Sonnet 4.6 --- .../2026-04-05-scope-manager-research.md | 189 ++++++++++++++ .../scope-manager-research/babel-traverse.md | 242 ++++++++++++++++++ .../scope-manager-research/eslint-scope.md | 192 ++++++++++++++ .../notes/scope-manager-research/nextjs.md | 165 ++++++++++++ .../scope-manager-research/oxc-walker.md | 209 +++++++++++++++ .../docs/notes/scope-manager-research/oxc.md | 222 ++++++++++++++++ .../scope-manager-research/periscopic.md | 162 ++++++++++++ .../typescript-eslint.md | 186 ++++++++++++++ .../notes/scope-manager-research/vite-ssr.md | 135 ++++++++++ 9 files changed, 1702 insertions(+) create mode 100644 packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md create mode 100644 packages/plugin-rsc/docs/notes/scope-manager-research/babel-traverse.md create mode 100644 packages/plugin-rsc/docs/notes/scope-manager-research/eslint-scope.md create mode 100644 packages/plugin-rsc/docs/notes/scope-manager-research/nextjs.md create mode 100644 packages/plugin-rsc/docs/notes/scope-manager-research/oxc-walker.md create mode 100644 packages/plugin-rsc/docs/notes/scope-manager-research/oxc.md create mode 100644 packages/plugin-rsc/docs/notes/scope-manager-research/periscopic.md create mode 100644 packages/plugin-rsc/docs/notes/scope-manager-research/typescript-eslint.md create mode 100644 packages/plugin-rsc/docs/notes/scope-manager-research/vite-ssr.md diff --git a/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md b/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md new file mode 100644 index 000000000..9c9c37cfe --- /dev/null +++ b/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md @@ -0,0 +1,189 @@ +# Scope Manager Design Research + +## Goal + +Survey how prior-art JS/TS toolchains implement scope analysis, compare against our custom `buildScopeTree` in `src/transforms/scope.ts`, and extract design lessons that could inform a future refactor (especially the pass-2 reference-visitor proposed in `2026-04-04-hoist-variable-shadowing.md`). + +## Context + +We rolled our own scope analyzer because our use case is narrow: + +- ESTree input (Vite's `parseAstAsync` / oxc-parser) +- Module scope only (no global, no TypeScript types) +- Output needed: for each `use server` function, which outer-scope identifiers does it close over? (`getBindVars` in `hoist.ts`) + +No existing library fit exactly: periscopic had a shadowing bug (wrong scope anchor + name-string resolution), typescript-eslint is TS-AST-only and far heavier than needed, and eslint-scope targets a superset of concerns. + +## Prior Arts + +Each document below covers one implementation: data model, scope types, resolution strategy, and a diff against our approach. + +- [typescript-eslint scope-manager](scope-manager-research/typescript-eslint.md) +- [periscopic](scope-manager-research/periscopic.md) +- [vite ssr transform](scope-manager-research/vite-ssr.md) +- [eslint-scope](scope-manager-research/eslint-scope.md) +- [babel traverse](scope-manager-research/babel-traverse.md) +- [oxc_semantic](scope-manager-research/oxc.md) +- [oxc-walker](scope-manager-research/oxc-walker.md) +- [next.js server action transform](scope-manager-research/nextjs.md) + +## Bugs and gaps found in our implementation + +Discovered by comparing against prior arts. Add test fixtures and fix separately. + +### Bug: default parameter + `var` hoisting (spec violation) + +Discovered via eslint-scope's `__isValidResolution` guard. + +```js +function outer() { + const y = 'outer' + async function action() { + 'use server' + function inner(x = y) { + // which `y` does this resolve to? + var y = 'inner' // hoisted to inner's function scope + } + } +} +``` + +Our post-walk resolver adds `var y` to `inner`'s function scope (via `getNearestFunctionScope()`). When resolving the `y` reference in the default param, `visitScope` is also the function scope, so we immediately find `y` there and return it as the declaring scope. + +Per spec, when a function has non-simple parameters (defaults/destructuring/rest), default param expressions cannot see `var` declarations in the function body — they are in separate environments. The correct resolution is `outer`'s `y`. + +**Practical impact for `getBindVars`:** we would fail to include `outer.y` as a closure variable for `action`, producing a server action that doesn't bind `y` at the call site even though the runtime would capture `outer.y`. + +**Fix direction:** after resolving a reference, if the reference position is a default parameter expression and the resolved scope is the same function scope, re-resolve from the function scope's parent instead. This is what eslint-scope does via a source-position range check (`ref.identifier.range[0] < bodyStart && variable.defs[].range[0] >= bodyStart`). + +### Gap: `for`-loop scope created unconditionally + +eslint-scope and oxc_semantic only create a block scope for `for`/`for-in`/`for-of` loops when the init/left uses `let`/`const`. We create a scope for all for-loops regardless. + +For `for (var i = 0; ...)`, our for-loop scope is empty (since `var i` hoists out), so this causes no wrong results — just a spurious empty scope node in the tree. Low priority. + +### Gap: no `StaticBlock` scope + +`class Foo { static { const x = 1 } }` — the static block creates its own scope in all prior arts (eslint-scope, oxc_semantic, vite-ssr). We don't handle it. Unlikely to matter for `use server` since class instance methods are rejected, but `static` initializers could theoretically contain a server action in future. + +## Bugs found in prior arts + +### oxc-walker: computed member expression misclassified as binding + +`isBindingIdentifier` checks `parent.type === "MemberExpression"` with no guard on `computed`: + +```ts +case "MemberExpression": + return parent.property === node // no !parent.computed check +``` + +This means `obj[bar]` — `bar` is classified as a **binding** (not a reference), so it would never appear in `getUndeclaredIdentifiersInFunction`'s output even if `bar` is an outer-scope variable. Our implementation correctly gates on `!parent.computed`. + +### periscopic: named class expression name leaks to outer scope + +`(class Foo {})` creates no inner scope, so `Foo` is added directly to the current scope's `declarations`. Any outer-scope reference to `Foo` after the expression would resolve to the class, which is incorrect — per spec, `Foo` is only visible inside the class body. + +### periscopic: spurious scope for re-export declarations + +`export { x } from './y'` creates a block scope (`Scope(block=true)`) containing the specifier identifiers as declarations. The re-exported names are not actually declared in this module, so they should not appear in any scope's declarations. + +### vite-ssr: no `switch` scope + +`let`/`const` declared inside a `switch` body are not scoped to the `switch` — they use whatever enclosing block scope exists. In practice this is usually correct (the `switch` body is often already inside a `BlockStatement` function body), but `let` at the top level of a switch case leaks to the enclosing function scope in vite-ssr's model. + +### Next.js: function parameters assumed used (documented TODO) + +From `server_actions.rs` line 340: + +```rust +// TODO: For the current implementation, we don't track if an +// argument ident is actually referenced in the function body. +// Instead, we go with the easy route and assume defined ones are used. +``` + +A server action function parameter that is never referenced in the body is still included in the encrypted closure arg list, adding unnecessary payload size. + +## Comparison table + +> TODO — fill in once individual documents are complete. + +| | periscopic | vite-ssr | eslint-scope | babel-traverse | oxc_semantic | oxc-walker | next.js | typescript-eslint | **ours** | +| ---------------------- | ----------------- | ---------------- | --------------------------- | -------------- | ------------ | ------------ | ------- | --------------------------- | ----------------------- | +| AST format | ESTree | ESTree | ESTree | Babel AST | oxc AST | ESTree (oxc) | ? | TSESTree | ESTree | +| Language | JS | TS | JS | JS | Rust | TS | ? | TS | TS | +| Variable object | no | no | yes | yes (Binding) | yes (Symbol) | no | ? | yes | no | +| Read/write flag | no | no | yes | yes | yes | no | ? | yes | no | +| Resolution timing | single-pass (bug) | two-pass | close-time | close-time | ? | two-pass | ? | close-time | post-walk | +| Refs aggregated upward | no | no | no (through[]) | no | no | no | ? | no (through[]) | yes (scopeToReferences) | +| `var` hoisting | buggy | yes | yes | yes | yes | yes | ? | yes | yes | +| Named fn-expr scope | name in fn scope | name in fn scope | FunctionExpressionNameScope | ? | ? | ? | ? | FunctionExpressionNameScope | name in fn scope | +| Class scope | none | named-expr only | ClassScope (always) | ? | ? | ? | ? | ClassScope (always) | named-expr only | +| TypeScript support | no | no | no | yes | yes | partial | ? | yes | no | + +## Related notes + +- [`2026-04-04-hoist-variable-shadowing.md`](2026-04-04-hoist-variable-shadowing.md) — the shadowing bug that motivated the custom implementation and the proposed pass-2 refactor +- [`2026-04-04-scope-unit-tests.md`](2026-04-04-scope-unit-tests.md) — fixture test plan + +## Subagent prompts + +Each prior art was researched by an Explore subagent. Prompts are recorded here for reproducibility. + +### Standard template (all except next.js) + +Replace `{LOCATION}`, `{FRAMING_NOTE}`, and `{EXTRA_QUESTIONS}` per the addendum table below. + +``` +Read and summarize the scope analysis implementation in {LOCATION}. +I need a thorough technical comparison against a custom ESTree scope analyzer. +{FRAMING_NOTE} +Key questions to answer: +1. What is the Scope data model? (fields, types) +2. How are declarations stored? (Set of names, or richer objects?) +3. How are references stored? (Set, or per-Identifier?) +4. How does reference resolution work? (single-pass or two-pass? when does resolution happen relative to declarations?) +5. What scope-creating AST nodes get their own Scope? (functions, blocks, catch, for-loops, classes, named fn expressions?) +6. How does it handle `var` hoisting? +7. How does it handle named function expressions (e.g. `(function f() {})` — does `f` go in the outer scope or the function scope)? +8. How does it handle class scopes? +9. What is the public API surface? +10. What are the known limitations / design trade-offs? +{EXTRA_QUESTIONS} +Please return raw findings — exact field names, code snippets, file paths with line numbers. +I'll write the comparison doc myself. +``` + +**Addendum per prior art:** + +| Prior art | `{LOCATION}` | `{FRAMING_NOTE}` | `{EXTRA_QUESTIONS}` | +| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| periscopic | `~/code/others/periscopic/` — please read all relevant source files | _(omit)_ | `11. What do extract_names / extract_identifiers do?` | +| vite-ssr | `~/code/others/vite/packages/vite/src/node/ssr/ssrTransform.ts` — the scope-related code is approximately lines 456–760 but check the actual line range yourself | _(omit)_ | `11. Is there a Scope class or is it ad-hoc maps/stacks?` `12. What is the purpose of this scope analysis within ssrTransform — what question is it answering?` `13. The file uses estree-walker — check what version/API it uses.` | +| eslint-scope | `~/code/others/eslint-js/packages/eslint-scope/` | _(omit)_ | `11. What is the Variable data model? (defs, references, identifiers)` `12. What is the Reference data model? (identifier, resolved, flag, from)` `13. List all ScopeType variants.` `14. Is there a FunctionExpressionNameScope?` | +| babel-traverse | `~/code/others/babel/packages/babel-traverse/src/scope/` | _(omit)_ | `11. What is the Binding data model? (identifier, path, scope, kind, references, referencePaths, constantViolations)` `12. Is resolution lazy or eager (crawl-on-demand)?` `13. List the public scope query API (getBinding(), hasBinding(), etc.)` | +| oxc_semantic | `~/code/others/oxc/crates/oxc_semantic/src/` | `This is Rust code — focus on the data model and algorithm, not language-specific syntax.` | `11. How are symbols stored? (arena IDs, string interning, etc.)` `12. What is the entry point from the compiler pipeline?` `13. What are the design trade-offs vs JS implementations?` | +| oxc-walker | `~/code/others/oxc-walker/src/scope-tracker.ts` (and any related files) | _(omit)_ | `11. What is isBindingIdentifier — what positions does it exclude?` `12. What is the public API surface (getUndeclaredIdentifiersInFunction or similar)?` | + +--- + +### next.js (different structure — file discovery first) + +``` +Find and summarize the scope analysis / reference tracking used in Next.js's +server action transform. The repo is at `~/code/others/next.js/`. + +First, locate the relevant files — likely somewhere under `packages/next/src/` +involving "server action", "use server", or similar. Check both SWC transform +wrappers and any JS/TS-side analysis. + +Key questions to answer: +1. Does Next.js implement its own scope analysis, or delegate to a library (e.g. babel-traverse, swc)? +2. If custom: what is the data model? what are the scope-creating nodes? how are references resolved? +3. If delegated: which library, which API, and what question is it asking? +4. What specific problem is the scope analysis solving — finding closure variables, rewriting bindings, etc.? +5. How does it handle `var` hoisting, named function expressions, class scopes? +6. What are the known limitations or edge cases handled specially? + +Please return raw findings — exact file paths with line numbers, function names, code snippets. +I'll write the comparison doc myself. +``` diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/babel-traverse.md b/packages/plugin-rsc/docs/notes/scope-manager-research/babel-traverse.md new file mode 100644 index 000000000..7374c2c7b --- /dev/null +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/babel-traverse.md @@ -0,0 +1,242 @@ +# scope.ts vs Babel traverse Scope: comparison + +**Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) +**Prior art:** `~/code/others/babel/packages/babel-traverse/src/scope/` + +Babel's `Scope` is the most feature-rich JS-side scope implementation in this survey. It is tightly coupled to `NodePath` (Babel's AST cursor with parent tracking), which enables capabilities like AST mutation, identifier renaming, and constant-violation tracking that a read-only scope analyzer cannot provide. + +--- + +## Data model + +### Ours + +```ts +Scope (class) + declarations: Set + parent: Scope | undefined + isFunction: boolean + +ScopeTree + referenceToDeclaredScope: Map + scopeToReferences: Map + nodeScope: Map + moduleScope: Scope +``` + +### Babel + +```ts +Scope + uid: number // unique instance id + path: NodePath // path to scope-creating node + block: t.Scopable // AST node + bindings: { [name: string]: Binding } // declarations in this scope + references: { [name: string]: true } // names referenced here + globals: { [name: string]: t.Identifier } // undeclared identifiers + uids: { [name: string]: boolean } // generated unique ids + data: { [key: string|symbol]: unknown } // arbitrary plugin storage + labels: Map> + +Binding + identifier: t.Identifier // the declaration identifier node + scope: Scope // owning scope + path: NodePath // path to the binding site + kind: BindingKind // "var" | "let" | "const" | "module" | + // "hoisted" | "param" | "local" | "unknown" + constant: boolean // false if ever reassigned + constantViolations: NodePath[] // paths where binding is written after init + referenced: boolean // has been used at least once + references: number // reference count + referencePaths: NodePath[] // path to each reference site + hasValue: boolean // for constant propagation + value: any +``` + +**Key difference:** Babel is `Binding`-centric and `NodePath`-centric — every reference is stored as a `NodePath` (not just an `Identifier` node), giving full AST ancestry context. Our model stores `Identifier` nodes; Babel stores `NodePath` objects which additionally carry parent, grandparent, scope, and mutation APIs. + +--- + +## BindingKind + +Babel distinguishes 8 declaration kinds, which map to JS semantics: + +| Kind | When used | +| ----------- | ----------------------------------------------------------------------- | +| `"var"` | `var` declarator | +| `"let"` | `let` declarator, catch clause param, class declaration id | +| `"const"` | `const`/`using` declarator | +| `"module"` | import specifier | +| `"hoisted"` | function declaration id (hoisted to function scope) | +| `"param"` | function parameter | +| `"local"` | function expression id, class expression id (self-binding, scope-local) | +| `"unknown"` | export specifier | + +--- + +## Scope types created + +Babel defines a `Scopable` union of all scope-creating node types. Notably broader than ours: + +| Node | Ours | Babel | +| ------------------------------------------------------------------ | ----------------------- | ------------------------------------------------- | +| Program | moduleScope | Scope | +| FunctionDeclaration / FunctionExpression / ArrowFunctionExpression | Scope(isFunction=true) | Scope | +| ObjectMethod / ClassMethod / ClassPrivateMethod | not handled | Scope | +| BlockStatement | Scope(isFunction=false) | Scope | +| CatchClause | Scope(isFunction=false) | Scope | +| ForStatement / ForInStatement / ForOfStatement | Scope(isFunction=false) | Scope | +| DoWhileStatement / WhileStatement | not handled | Scope | +| SwitchStatement | Scope(isFunction=false) | Scope | +| ClassDeclaration / ClassExpression | named-expr only | Scope | +| StaticBlock | not handled | Scope | +| TSModuleBlock | not handled | Scope | +| Pattern (fn params) | handled inside fn scope | Scope (when direct child of Function/CatchClause) | + +Notably, Babel does NOT create a separate `FunctionExpressionNameScope` — the function expression name is a `"local"` binding inside the function's own scope, same as our implementation. + +--- + +## Named function expressions and class expressions + +Both put the self-reference name into the node's **own scope** as kind `"local"`: + +```js +;(function f() {})( + // f → kind:"local" in the function scope + class Foo {}, +) // Foo → kind:"local" in the class scope +``` + +This matches our implementation and differs from eslint-scope / typescript-eslint which use a separate `FunctionExpressionNameScope`. + +--- + +## Class scopes + +Class declarations get a `Scope`, but their name binding has an unusual aliasing behavior: + +```ts +// ClassDeclaration id is registered as kind "let" in the PARENT scope +// Inside the class scope, the name is set as an alias to the parent binding: +path.scope.bindings[name] = path.scope.parent.getBinding(name) +``` + +So `Foo` in `class Foo {}` appears in both scopes but the class scope entry is just a pointer to the parent scope's `Binding` object — not a new `Binding`. Class expressions use `"local"` and do create an independent binding inside the class scope. + +--- + +## Resolution: lazy crawl on demand + +Babel uses **lazy initialization** — a scope is only crawled when first accessed: + +```ts +init() → crawl() // called from path.setScope() on first visit +``` + +The `crawl()` algorithm is two-phase: + +**Phase 1 (declaration collection):** Traverse the scope's subtree with `collectorVisitor`. Declarations are registered immediately as `Binding` objects. `var` and function declarations are hoisted to the nearest function/program scope via `getFunctionParent()`. + +**Phase 2 (reference resolution):** After the traversal, iterate `state.references` and call `scope.getBinding(name)` for each — this walks up the parent chain. Resolved references are added to `binding.referencePaths`; unresolved go to `programParent.globals`. + +```ts +for (const ref of state.references) { + const binding = ref.scope.getBinding(ref.node.name) + if (binding) { + binding.reference(ref) // adds NodePath to binding.referencePaths + } else { + programParent.addGlobal(ref.node) + } +} +``` + +This is structurally the same two-phase approach as ours (collect declarations → resolve references). The key difference is timing: Babel crawls lazily when a scope is first touched during traversal, not at the end of a full tree walk. + +--- + +## `var` hoisting + +`var` declarations are explicitly hoisted to `getFunctionParent() || getProgramParent()` during collection: + +```ts +// non-block-scoped declarations: +const parent = path.scope.getFunctionParent() || path.scope.getProgramParent() +parent.registerDeclaration(path) + +// var in for-loop: +const parentScope = scope.getFunctionParent() || scope.getProgramParent() +parentScope.registerBinding('var', declar) +``` + +This is equivalent to our `getNearestFunctionScope()` call. + +--- + +## `var` in loops marked non-constant + +A `var` (or `hoisted`) binding declared inside a loop is automatically marked as non-constant: + +```ts +if ((kind === 'var' || kind === 'hoisted') && isDeclaredInLoop(path)) { + this.reassign(path) // constant = false, path added to constantViolations +} +``` + +Our implementation doesn't track constancy at all. + +--- + +## Public API (scope queries) + +```ts +// Binding lookup (walks parent chain) +scope.getBinding(name): Binding | undefined +scope.getOwnBinding(name): Binding | undefined +scope.hasBinding(name, opts?): boolean +scope.hasOwnBinding(name): boolean +scope.parentHasBinding(name, opts?): boolean + +// Scope hierarchy +scope.getProgramParent(): Scope +scope.getFunctionParent(): Scope | null +scope.getBlockParent(): Scope + +// Binding mutation +scope.registerBinding(kind, path): void +scope.removeBinding(name): void +scope.moveBindingTo(name, scope): void +scope.rename(oldName, newName?): void // AST-aware rename across all references +scope.push({ id, init?, kind? }): void // inject new variable into scope + +// UID generation +scope.generateUid(name?): string +scope.generateUidIdentifier(name?): t.Identifier + +// Plugin data +scope.setData(key, val): void +scope.getData(key): any +``` + +The `rename()` API is particularly powerful — it traverses the scope subtree and rewrites all reference sites, skipping nested scopes that shadow the binding. + +--- + +## What Babel has that we don't + +- **`Binding` with `referencePaths`** — every reference is a `NodePath` with full mutation capabilities. +- **`constantViolations`** — tracks exactly where a binding is written after initialization. +- **`constant` flag** — derived fact useful for optimization (constant folding, inlining). +- **`binding.kind`** — 8 declaration kinds including `"hoisted"`, `"local"`, `"module"`. +- **`scope.rename()`** — AST-aware identifier renaming across all reference sites. +- **`scope.generateUid()`** — unique identifier generation that avoids collisions. +- **`scope.push()`** — inject new variable declarations into a scope. +- **Lazy crawl** — scopes only analyzed when needed, not upfront. +- **Plugin data store** (`scope.setData/getData`) — shared state across visitors. +- **`DoWhileStatement`/`WhileStatement` scopes.** + +## What we have that Babel doesn't + +- **`scopeToReferences` aggregation** — O(1) "all refs inside scope X" without a walk. +- **ESTree input** — Babel operates on its own AST format, not ESTree. Our implementation works directly with Vite's `parseAstAsync` output. +- **Simplicity** — ~300 lines, no NodePath coupling, no mutation API, no lazy crawl machinery. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/eslint-scope.md b/packages/plugin-rsc/docs/notes/scope-manager-research/eslint-scope.md new file mode 100644 index 000000000..0eb57a08f --- /dev/null +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/eslint-scope.md @@ -0,0 +1,192 @@ +# scope.ts vs eslint-scope: comparison + +**Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) +**Prior art:** `~/code/others/eslint-js/packages/eslint-scope/` + +eslint-scope is the original ECMA-262 scope analyzer for ESTree ASTs that typescript-eslint was built on top of. The interface it defines (`ScopeManager`, `Scope`, `Variable`, `Reference`) became the standard that all subsequent JS scope tools reference. + +--- + +## Data model + +### Ours + +```ts +Scope (class) + declarations: Set + parent: Scope | undefined + isFunction: boolean + +ScopeTree + referenceToDeclaredScope: Map + scopeToReferences: Map + nodeScope: Map + moduleScope: Scope +``` + +### eslint-scope + +```js +Scope + type: string // one of 12 ScopeType variants + block: ESTree.Node // the AST node that created this scope + upper: Scope | null // parent scope + childScopes: Scope[] + isStrict: boolean + variables: Variable[] // declarations in this scope + set: Map // name → Variable + references: Reference[] // references created in this scope + through: Reference[] // unresolved refs delegated to parent + variableScope: Scope // nearest function/global/module scope (for var) + functionExpressionScope: boolean // true only for FunctionExpressionNameScope + dynamic: boolean // true for global/with scopes + directCallToEvalScope: boolean + thisFound: boolean + +Variable + name: string + scope: Scope + identifiers: ESTree.Identifier[] // all declaration nodes + references: Reference[] // all uses + defs: Definition[] // where declared (with kind/node/parent) + +Reference + identifier: ESTree.Identifier // the specific identifier node + from: Scope // scope where the reference appears + resolved: Variable | null // null = global/undeclared + flag: READ=1 | WRITE=2 | RW=3 + writeExpr?: ESTree.Expression // rhs if write + init?: boolean // is this an initializer write + +Definition + type: string // CatchClause | Parameter | FunctionName | ClassName | Variable | ImportBinding + name: ESTree.Identifier + node: ESTree.Node // enclosing declaration node + parent?: ESTree.Node // statement node + kind?: "var" | "let" | "const" +``` + +**Key difference:** eslint-scope is Variable-centric — a `Variable` groups all declaration sites (`defs`, `identifiers`) and all use sites (`references`) for one name. Our model has no `Variable` objects; we map each `Identifier` directly to the `Scope` that declares it. + +--- + +## Scope types + +All 12 `ScopeType` variants: + +| Type | Node | Notes | +| ---------------------------- | ------------------------------------------------------------------ | ------------------------------------------------- | +| `"global"` | Program | root scope | +| `"module"` | Program | in ES module context, child of global | +| `"function"` | FunctionDeclaration / FunctionExpression / ArrowFunctionExpression | | +| `"function-expression-name"` | FunctionExpression (named) | contains only the fn name | +| `"block"` | BlockStatement | ES6+ only | +| `"catch"` | CatchClause | | +| `"with"` | WithStatement | | +| `"for"` | For/ForIn/ForOf | only when init/left has `let`/`const` (not `var`) | +| `"switch"` | SwitchStatement | ES6+ | +| `"class"` | ClassDeclaration / ClassExpression | always created | +| `"class-field-initializer"` | PropertyDefinition value | each field initializer has own scope | +| `"class-static-block"` | StaticBlock | | + +Notable: `for` scope only created for `let`/`const` loops — a `var` for-loop does not get a ForScope. Our implementation creates a scope for all for-loops. + +--- + +## FunctionExpressionNameScope + +Yes — same as typescript-eslint, which inherited this design. A named function expression creates **two** scopes: + +``` +outer scope +└── FunctionExpressionNameScope ← contains only: f (type "function-expression-name") + └── FunctionScope ← contains: params, var declarations +``` + +```js +// (function f() {}) creates: +// 1. FunctionExpressionNameScope { variables: [Variable{name:"f"}] } +// 2. FunctionScope { variables: [params...] } +``` + +Our implementation puts `f` directly into the function scope. Functionally equivalent for resolution but different structural shape. + +--- + +## Class scopes + +A `ClassScope` is created for every class (declaration and expression). The class name is declared **twice**: once in the outer scope (for declarations), and once inside the `ClassScope` (self-reference): + +```js +class Foo extends Base {} +// outer scope ← Foo defined here (ClassDeclaration) +// └── ClassScope ← Foo also defined here (inner self-reference) +``` + +Each class field initializer additionally gets its own `ClassFieldInitializerScope`. + +--- + +## Reference resolution: close-time bubble-up + +1. During the walk, `scope.__referencing(identifier)` adds a `Reference` to `scope.__left`. +2. When a scope closes, `scope.__close()` iterates `__left` and tries to resolve each ref via `scope.__resolve()` — a direct lookup in `scope.set`. +3. Unresolved refs are passed to the parent via `scope.__delegateToUpperScope(ref)`, which adds them to the parent's `through[]` and `__left`. +4. This repeats up the chain until reaching GlobalScope, where unresolved refs become implicit globals. + +Because declarations are registered during the walk (before close), all local declarations are visible when `__close()` runs — this correctly handles `var` hoisting and function declarations within the same scope. + +Our post-walk loop achieves the same result differently: we collect `{ id, visitScope }` pairs during the walk and resolve them all in one pass after the walk is complete. + +**Default parameter edge case:** eslint-scope has special logic in `FunctionScope.__isValidResolution()` that prevents references in default parameter expressions from resolving to variables declared in the function body (references at position < body start cannot resolve to declarations at position >= body start). Our implementation doesn't handle this. + +--- + +## `var` hoisting + +`var` declarations are registered directly into `scope.variableScope` (the nearest function/global/module scope) rather than the current block scope: + +```js +// in referencer.js: +const variableTargetScope = + node.kind === 'var' + ? this.currentScope().variableScope // hoist + : this.currentScope() // let/const stay local +``` + +`variableScope` is set at scope construction time — for function/global/module scopes it points to self; for block scopes it points upward to the nearest function scope. This is equivalent to our `getNearestFunctionScope()`. + +--- + +## Public API + +```js +analyze(tree, options) → ScopeManager + +ScopeManager + .scopes: Scope[] + .globalScope: GlobalScope + .acquire(node, inner?): Scope | null // scope for a node + .release(node, inner?): Scope | null // parent scope of a node + .getDeclaredVariables(node): Variable[] // variables declared by a node +``` + +--- + +## What eslint-scope has that we don't + +- `Variable` objects linking all defs and all uses for one name. +- `Reference` read/write flag and `writeExpr` — knows if an identifier is being written. +- `Definition` kind — `var` vs `let` vs `const` vs param vs import vs class name. +- `through[]` — explicit unresolved-reference chain per scope. +- `FunctionExpressionNameScope` — separate scope for function expression name. +- `ClassScope` for every class, `ClassFieldInitializerScope`, `ClassStaticBlockScope`. +- Default-parameter forward-reference guard. +- `with` scope, strict-mode detection. +- `eval()` dynamic scope propagation. + +## What we have that eslint-scope doesn't + +- `scopeToReferences` aggregation — O(1) "all refs inside scope X". +- Simpler data model — no Variable/Definition/Reference class hierarchy. +- Named class expression scope (self-binding correctly isolated without a full ClassScope). diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/nextjs.md b/packages/plugin-rsc/docs/notes/scope-manager-research/nextjs.md new file mode 100644 index 000000000..2dadcc47d --- /dev/null +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/nextjs.md @@ -0,0 +1,165 @@ +# scope.ts vs Next.js server action transform: comparison + +**Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) +**Prior art:** `~/code/others/next.js/crates/next-custom-transforms/src/transforms/server_actions.rs` + +--- + +## How it works + +Next.js implements its own **minimal, purpose-built** scope analysis in Rust as part of its SWC custom transform — not delegating to babel-traverse or SWC's generic scope APIs. The transform is embedded directly inside the server action visitor rather than extracted as a reusable module. + +**Problem being solved:** Identify which outer-scope variables a `'use server'` function closes over so they can be serialized (encrypted) and passed as bound arguments at the call site. + +```js +// input +export function Page() { + const api_key = 'secret' + async function action() { + 'use server' + console.log(api_key) + } +} + +// output (simplified) +export const $$RSC_SERVER_ACTION_0 = async function action( + $$ACTION_CLOSURE_BOUND, +) { + const [$$ACTION_ARG_0] = await decryptActionBoundArgs( + '...', + $$ACTION_CLOSURE_BOUND, + ) + console.log($$ACTION_ARG_0) +} +export function Page() { + const api_key = 'secret' + var action = $$RSC_SERVER_ACTION_0.bind( + null, + encryptActionBoundArgs('...', api_key), + ) +} +``` + +This is the same problem as our `getBindVars` — find the closure variables — but implemented at the SWC/Rust layer. + +--- + +## Data model + +### Ours + +``` +Scope (class, JS) + declarations: Set + parent: Scope | undefined + isFunction: boolean + +ScopeTree + referenceToDeclaredScope: Map + scopeToReferences: Map + nodeScope: Map + moduleScope: Scope +``` + +### Next.js + +No `Scope` class. The visitor carries two flat Vecs as mutable state: + +```rust +// on the ServerActions visitor struct (lines 249–250) +names: Vec // reference identifiers collected in current fn body +declared_idents: Vec // declarations collected in current fn body + +// Name = a base identifier + optional member access chain +struct NamePart { prop: Atom, is_member: bool, optional: bool } +struct Name(Id, Vec) +// e.g. `foo.bar?.baz` → Name(foo_id, [.bar, ?.baz]) +// e.g. `x` → Name(x_id, []) +``` + +`Id` is SWC's `(Symbol, SyntaxContext)` pair — the `SyntaxContext` encodes hygiene marks so two bindings named `x` in different scopes are distinguishable without a scope tree. + +There is no scope tree, no parent chain, no node→scope map. The entire analysis is a single function body at a time. + +--- + +## Scope types + +Only **function boundaries** are modeled. Block scopes, catch scopes, class scopes — none of these create a new tracking context: + +| Situation | Next.js | Ours | +| ------------------------------ | ----------------------------------------- | ---------------------------------------- | +| `function f() {}` / `() => {}` | new `declared_idents` snapshot | `Scope(isFunction=true)` | +| `{ }` BlockStatement | not modeled | `Scope(isFunction=false)` | +| `for` / `for…in` / `for…of` | not modeled | `Scope(isFunction=false)` | +| `catch (e)` | not modeled | `Scope(isFunction=false)` | +| `class {}` | not modeled (rejected for `'use server'`) | `Scope(isFunction=false)` for named expr | + +Not modeling block scopes is fine for the specific goal: `var` declarations hoist to function scope anyway, and `let`/`const` inside the server action body should still be treated as "local" (not bound). The filter step (`retain_names_from_declared_idents`) handles this because it keeps only names matching the **outer** function's `declared_idents`. + +--- + +## Resolution strategy + +### Next.js: two-phase, flat, per-function-body + +**Phase 1 (declarations):** While visiting the function body, `visit_mut_param` and `collect_decl_idents_in_stmt` push bindings into `declared_idents`. No tree built — just a flat Vec. + +**Phase 2 (filter):** `retain_names_from_declared_idents` cross-references `names` against the **caller's** `declared_idents` snapshot — keeping only references whose base `Id` matches a declaration from the outer function scope. + +```rust +current_declared_idents + .iter() + .any(|ident| ident.to_id() == name.0) // Id comparison, hygiene-aware +``` + +Shadowing is handled implicitly by SWC's hygiene system: if the inner function re-declares `x`, the inner `x` and outer `x` have different `SyntaxContext` values, so they never match as the same `Id`. + +### Ours: post-walk, full scope tree + +We build a complete scope tree first, then resolve every `Identifier` reference against it. This gives us the answer for any scope, not just the outermost function boundary. + +--- + +## Member access chains (`Name`) + +The `Name` type is a notable addition over our approach. Instead of tracking only the base `Identifier`, Next.js tracks the full member access path: + +```js +async function action() { + 'use server' + console.log(config.api.key) // → Name(config_id, [.api, .key]) +} +``` + +This allows the bound arg to be `config.api.key` (a property read) rather than just `config` (the whole object). The deduplication step then collapses `config` + `config.api.key` → `config` when both appear. + +Our `getBindVars` only tracks the base identifier name, binding the full object even if only one property is used. The `TODO` comment in `scope.ts` acknowledges this as a future extension. + +--- + +## `var` hoisting + +Not explicitly modeled. SWC's parser handles the AST normalization, and the flat declaration collection (`collect_decl_idents_in_stmt`) picks up `var` declarations wherever they appear in the function body — the same effect as hoisting, without needing a two-pass approach. + +--- + +## Known limitations (from source comments) + +- `TODO` at line 340: parameters are assumed used if declared, not checked for actual reference. +- No block scope modeling means `let`/`const` declared in an inner block are not distinguished from outer ones (over-captures in edge cases). +- Only `foo.bar.baz` member chains; no computed properties (`foo[bar]`) or method calls in the bound expression. +- Class instance methods rejected outright — only static methods and top-level functions may have `'use server'`. + +--- + +## What Next.js has that we don't + +- **Member access chain tracking** (`Name` type) — can bind `config.api.key` instead of the whole `config` object. +- **Hygiene-aware Id comparison** — SWC's `SyntaxContext` handles shadowing without needing a scope tree at all. + +## What we have that Next.js doesn't + +- **Full scope tree** — works for any nesting depth, any query (not just "what does this one function close over?"). +- **Block scope modeling** — correct `let`/`const` shadowing within the action body. +- **Language:** JS/TS — no Rust/SWC dependency; works with any ESTree parser. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/oxc-walker.md b/packages/plugin-rsc/docs/notes/scope-manager-research/oxc-walker.md new file mode 100644 index 000000000..ce98a2afb --- /dev/null +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/oxc-walker.md @@ -0,0 +1,209 @@ +# scope.ts vs oxc-walker: comparison + +**Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) +**Prior art:** `~/code/others/oxc-walker/src/scope-tracker.ts` + +oxc-walker is a small TS utility that pairs an AST walker with an optional `ScopeTracker`. It is the most directly comparable prior art to our implementation in terms of scope (pun intended) — both are lightweight, ESTree-compatible, and purpose-built rather than general-purpose compiler infrastructure. + +--- + +## Data model + +### Ours + +```ts +Scope (class) + declarations: Set + parent: Scope | undefined + isFunction: boolean + +ScopeTree + referenceToDeclaredScope: Map + scopeToReferences: Map + nodeScope: Map + moduleScope: Scope +``` + +### oxc-walker + +No `Scope` class. Scopes are keyed by string indices; the tracker is a flat map: + +```ts +scopes: Map> + +// Scope key format: hierarchical dot-separated indices +// root: "" +// first child: "0" +// second child at depth 2: "0-1" +// Built from a depth-first traversal index stack + +// Current scope tracked as: +scopeIndexStack: number[] // e.g. [0, 1, 2] +scopeIndexKey: string // e.g. "0-1" (all but last = current scope key) +``` + +Declarations are **richer objects**, not just strings: + +```ts +type ScopeTrackerNode = + | ScopeTrackerVariable // VariableDeclaration binding — has variableNode + | ScopeTrackerFunctionParam // function parameter — has fnNode + | ScopeTrackerFunction // function declaration/expression id + | ScopeTrackerIdentifier // class name or other identifier + | ScopeTrackerImport // import specifier — has importNode + | ScopeTrackerCatchParam // catch clause parameter — has catchNode + +// All share a BaseNode with: +scope: string // scope key where declared +node: T // original AST node +start: number // source position +end: number +``` + +**Key difference:** oxc-walker uses string-keyed scope indices rather than object references with parent links. To walk up the scope chain you decompose the key string (split on `"-"`, drop the last segment). There is no scope parent pointer. + +--- + +## Scope types created (entries in `scopes` map) + +| Situation | oxc-walker | Ours | +| --------------------------------- | ------------------------------------------------ | ---------------------------------------- | +| Program | `""` root scope | `moduleScope` | +| `function f() {}` | scope for params (name declared in parent scope) | `Scope(isFunction=true)` | +| Named fn expr `(function f() {})` | **two scopes**: outer for name, inner for params | `Scope(isFunction=true)` with `f` inside | +| `() => {}` | scope for params | `Scope(isFunction=true)` | +| `{ }` BlockStatement | scope | `Scope(isFunction=false)` | +| `for` / `for…in` / `for…of` | scope | `Scope(isFunction=false)` | +| `catch (e)` | scope | `Scope(isFunction=false)` | +| Named class expr `(class Foo {})` | scope for name (same pattern as NFE) | `Scope(isFunction=false)` with `Foo` | +| Class declaration | no scope; name declared in parent scope | no scope | +| `switch` | not handled | `Scope(isFunction=false)` | +| Class static block | scope | not handled | + +**Named function expression: two scopes.** This is similar to eslint-scope's `FunctionExpressionNameScope` pattern but implemented as two separate entries in the flat scope map rather than two linked Scope objects: + +``` +"" → (outer scope) +"0" → { f: ScopeTrackerFunction } ← function name scope +"0-0" → { param: ScopeTrackerFunctionParam, ... } ← params scope +"0-0-0"→ (body BlockStatement scope) +``` + +Our implementation puts `f` into the function scope directly (no separate wrapper scope). + +--- + +## Reference detection: `isBindingIdentifier` + +oxc-walker exports `isBindingIdentifier(node, parent)` — a positive classifier that returns `true` when an `Identifier` is a **declaration** (binding position). Anything returning `false` is a reference. This is the inverse of our `isReferenceIdentifier`. + +Positions classified as bindings (excluded from references): + +| Parent | Binding position | +| ---------------------------------------- | ----------------------------------------------- | +| FunctionDeclaration / FunctionExpression | `id`, each identifier in `params` patterns | +| ArrowFunctionExpression | each identifier in `params` patterns (no `id`) | +| ClassDeclaration / ClassExpression | `id` | +| VariableDeclarator | all identifiers in `id` pattern | +| CatchClause | all identifiers in `param` pattern | +| MethodDefinition | `key` | +| PropertyDefinition | `key` | +| Property | `key` when `key !== value` (i.e. not shorthand) | +| MemberExpression | `property` (always — computed or not) | + +This is close to but not identical to our `isReferenceIdentifier`. Key differences noted in `2026-04-04-hoist-variable-shadowing.md`: + +- oxc-walker classifies `MethodDefinition` and `PropertyDefinition` keys as bindings (we do too). +- oxc-walker classifies `MemberExpression.property` as a binding regardless of `computed` — ours only excludes it when `!computed`. This means `obj[bar]` would be mis-classified by oxc-walker (computed properties are references, not bindings). + +Wait — re-reading the source: `parent.property === node` with no `computed` check. This looks like a bug in oxc-walker for computed member expressions, or they assume oxc-parser normalizes this differently. + +--- + +## Resolution strategy + +**No pre-built reference→scope map.** References are not stored at all — the tracker only stores declarations. To check if an identifier is in scope, callers use: + +```ts +scopeTracker.isDeclared(name) // walks up scope key hierarchy +scopeTracker.getDeclaration(name) // same, returns the ScopeTrackerNode +``` + +`isDeclared` reconstructs the ancestor chain by decomposing the key string: + +```ts +const indices = this.scopeIndexKey.split('-').map(Number) +for (let i = indices.length; i >= 0; i--) { + if (this.scopes.get(indices.slice(0, i).join('-'))?.has(name)) return true +} +``` + +For full undeclared-identifier analysis, callers must run **two passes** using `getUndeclaredIdentifiersInFunction`: + +1. Walk with `ScopeTracker` to collect all declarations. +2. Call `scopeTracker.freeze()` to lock declarations. +3. Walk again; for each non-binding `Identifier` call `scopeTracker.isDeclared(name)`. + +This matches our two-phase approach in principle, though we do both phases in a single walk + post-walk loop. + +--- + +## `var` hoisting + +**Not implemented.** `var` declarations are stored in the scope where they textually appear, not hoisted to the nearest function scope. This is documented as a known limitation — the scope model "doesn't mirror JavaScript's scoping 1:1". For the intended use case (finding undeclared identifiers via `getUndeclaredIdentifiersInFunction`) this is sufficient because the question is only "is this name declared anywhere inside this function?" not "which scope owns it." + +--- + +## Public API + +```ts +// Query (during or after walk) +scopeTracker.isDeclared(name: string): boolean +scopeTracker.getDeclaration(name: string): ScopeTrackerNode | null +scopeTracker.getCurrentScope(): string +scopeTracker.isCurrentScopeUnder(scope: string): boolean + +// Lifecycle +scopeTracker.freeze(): void // lock after first pass, reset for second pass + +// Standalone utilities +isBindingIdentifier(node, parent): boolean +getUndeclaredIdentifiersInFunction(fn): string[] + +// Integration with walker +walk(node, { scopeTracker, enter, leave }) +``` + +`getUndeclaredIdentifiersInFunction` is the highest-level API and the closest equivalent to our `getBindVars` — it returns the names of all identifiers referenced but not declared inside a function. The difference: it returns names (`string[]`) not `Identifier` nodes, and doesn't distinguish outer-scope closures from globals (both are "undeclared inside the function"). + +--- + +## Scope deletion by default + +Scopes are deleted from the map when exited unless `preserveExitedScopes: true`: + +```ts +if (!this.options.preserveExitedScopes) { + this.scopes.delete(this.scopeIndexKey) +} +``` + +This means single-pass use only reads the current scope chain. Two-pass analysis requires `preserveExitedScopes: true` so that the frozen declaration map survives into the second walk. + +--- + +## What oxc-walker has that we don't + +- **`ScopeTrackerNode` typed declarations** — knows if a name came from a `var`, param, import, catch, or function declaration. +- **`getUndeclaredIdentifiersInFunction`** high-level utility. +- **`freeze()` / two-pass pattern** — explicit API for multi-pass analysis. +- **Walker integration** — scope tracking is coupled directly into the walk API, so callers don't need to build the scope tree separately. + +## What we have that oxc-walker doesn't + +- **`var` hoisting** — correctly models `var` semantics. +- **`switch` scope.** +- **Per-`Identifier` reference map** (`referenceToDeclaredScope`) — answers "which exact scope declared this specific reference?" not just "is this name declared somewhere?". +- **`scopeToReferences` aggregation** — O(1) "all refs inside scope X". +- **Object parent links** — scope chain is a linked list of `Scope` objects, not a string key decomposition. +- **Distinguishes outer-scope closures from globals** — our `getBindVars` can filter to only bindings from scopes between the server function and the module root. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/oxc.md b/packages/plugin-rsc/docs/notes/scope-manager-research/oxc.md new file mode 100644 index 000000000..a2b5ffc14 --- /dev/null +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/oxc.md @@ -0,0 +1,222 @@ +# scope.ts vs oxc_semantic: comparison + +**Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) +**Prior art:** `~/code/others/oxc/crates/oxc_semantic/src/` (Rust) + +oxc_semantic is the full semantic analysis pass of the oxc compiler — the heaviest implementation in this survey. It is designed as production compiler infrastructure, not a library for external callers. + +--- + +## Data model + +### Ours + +```ts +Scope (class) + declarations: Set + parent: Scope | undefined + isFunction: boolean + +ScopeTree + referenceToDeclaredScope: Map + scopeToReferences: Map + nodeScope: Map + moduleScope: Scope +``` + +### oxc_semantic + +**Struct-of-Arrays (SoA) layout** — all symbols stored in parallel arrays indexed by `SymbolId` (u32), all scopes in parallel arrays indexed by `ScopeId` (u32), all references by `ReferenceId` (u32). No heap-allocated objects per symbol/scope/reference. + +```rust +// Core output (Scoping / ScopingInner) + +// Symbols — parallel arrays indexed by SymbolId +symbol_spans: Vec // source position +symbol_flags: Vec // var/let/const/class/fn/import/TS variants… +symbol_scope_ids: Vec // declaring scope +symbol_declarations: Vec // declaring AST node + +symbol_names: ArenaVec // string-interned names (arena allocator) +resolved_references: ArenaVec> // per-symbol reference lists +symbol_redeclarations: FxHashMap> // lazy, only if redeclared + +// Scopes — parallel arrays indexed by ScopeId +parent_ids: Vec> +node_ids: Vec +flags: Vec +bindings: IndexVec> // name → SymbolId per scope + +// References +// per-node reference struct: +Reference { + node_id: NodeId // the IdentifierReference AST node + symbol_id: Option // resolved target; None = unresolved + scope_id: ScopeId // scope where the reference appears + flags: ReferenceFlags // Read | Write | Type | ValueAsType | Namespace +} +root_unresolved_references: ArenaIdentHashMap> // globals +``` + +**Key point:** there are no `Scope` objects or `Symbol` objects on the heap. A "scope" is just an index into several parallel arrays. This is the largest architectural difference from every JS implementation in this survey. + +--- + +## Symbol flags + +`SymbolFlags` covers all JS + TypeScript declaration kinds: + +``` +FunctionScopedVariable | BlockScopedVariable | ConstVariable +Class | Function | CatchVariable +Import | TypeImport +TypeAlias | Interface | RegularEnum | ConstEnum | EnumMember +TypeParameter | NamespaceModule | ValueModule | Ambient +``` + +Composite: `Variable = FunctionScopedVariable | BlockScopedVariable | ConstVariable`, `BlockScoped = BlockScopedVariable | ConstVariable | Class`, etc. + +Ours has none of this — `Set` treats all declaration kinds identically. + +--- + +## Scope types created + +| Situation | oxc_semantic | Ours | +| -------------------------------------------------------------- | ------------------------------------------- | ------------------------- | +| `Program` | `ScopeFlags::Top` | `moduleScope` | +| `function f() {}` / `() => {}` | `ScopeFlags::Function` | `Scope(isFunction=true)` | +| Arrow fn | `ScopeFlags::Function \| Arrow` | `Scope(isFunction=true)` | +| `{ }` BlockStatement | `ScopeFlags::empty()` | `Scope(isFunction=false)` | +| `for` / `for…in` / `for…of` | `ScopeFlags::empty()` | `Scope(isFunction=false)` | +| `catch (e)` | `ScopeFlags::CatchClause` | `Scope(isFunction=false)` | +| `switch` | not created (no separate scope) | `Scope(isFunction=false)` | +| `class {}` | `ScopeFlags::StrictMode` (always one scope) | named-expr only | +| `class {}` static block | `ScopeFlags::ClassStaticBlock` | not handled | +| `with (x) {}` | `ScopeFlags::With` | not handled | +| TypeScript: namespace, interface, type param, conditional type | dedicated flags | not handled | + +**switch** is absent in oxc_semantic (same gap as vite-ssr, opposite of ours). + +--- + +## Named function expressions + +Name binds in the **function's own scope**, same as ours: + +``` +outer scope +└── function scope ← 'f' declared here, same scope as params + └── body +``` + +The function scope is entered before the name is bound (`enter_scope` → `func.bind(self)`), so `f` cannot be seen from the outer scope. If a parameter also named `f` exists, the parameter shadows it — this redeclaration is detected and handled explicitly. + +--- + +## Class scopes + +oxc_semantic creates **one `ClassScope`** for every class (declaration or expression), always: + +```js +class Foo extends Base {} +``` + +``` +outer scope ← Foo declared here (class declaration) +└── ClassScope (StrictMode) ← Foo also declared here (self-reference) +``` + +Named class expression: name binds inside the class scope (not in the outer scope). Anonymous class expression: still creates the `ClassScope`, just no name binding. + +This matches typescript-eslint's `ClassScope` behavior. Our implementation only creates a scope for named class expressions. + +--- + +## Reference resolution + +### Strategy: walk-up with checkpoint-based early resolution + +**Normal resolution** happens in a post-walk pass (`resolve_all_references`): after the entire AST is visited, each unresolved reference walks up the scope chain via `scope_parent_id()` until it finds a `bindings` entry with the matching name. + +**Early (checkpoint) resolution** fires at specific points during the walk to handle forward-reference constraints: + +- After function parameters are visited (before the body) — prevents params from binding to body declarations +- After catch parameters — prevents the catch param from binding to the catch body + +The checkpoint mechanism saves the current position in the flat unresolved-references list; everything before the checkpoint is resolved against the current scope chain, leaving the rest for later. + +This is more nuanced than our single post-walk pass, which resolves everything at once (sufficient because we never need the checkpoint separation). + +### Walk-up vs bubble-up + +typescript-eslint and eslint-scope use a **bubble-up** strategy: each scope maintains a `through[]` / `leftToResolve[]` queue; on scope close, unresolved refs are pushed to the parent. This is N scope-exit operations. + +oxc_semantic uses a **walk-up** strategy: one flat list of unresolved references, each resolved by walking the scope chain at the end. Better cache locality, no per-scope-exit work. + +Our approach is also walk-up (post-walk flat loop), same principle. + +--- + +## `var` hoisting + +Handled during the walk via an explicit hoisting tracker: + +1. When a `var` declaration is encountered, walk up the scope chain collecting block scopes. +2. Stop at the first scope with `flags.is_var()` (Top / Function / ClassStaticBlock / TsModuleBlock). +3. Check for redeclaration in all intermediate scopes via both `bindings` and a side-table `hoisting_variables: FxHashMap>`. +4. Bind the symbol in the target scope. +5. If the binding was temporarily placed in an intermediate scope, move it (`move_binding`). + +The separate `hoisting_variables` side-table is needed so that redeclaration checks during the walk can see hoisted vars even before they've been moved to their final scope. + +Our approach is simpler: at declaration time, call `getNearestFunctionScope()` and add directly to that scope. No side-table needed because we only store names (strings), not node references. + +--- + +## Public API + +```rust +SemanticBuilder::new() + .with_check_syntax_error(bool) + .with_cfg(bool) + .build(&program) + → SemanticBuilderReturn { semantic, errors } + +// Query APIs on Scoping: +scoping.symbol_name(id) // &str +scoping.symbol_flags(id) // SymbolFlags +scoping.symbol_scope_id(id) // ScopeId +scoping.symbol_declaration(id) // NodeId +scoping.get_resolved_references(id) // Iterator<&Reference> +scoping.symbol_is_mutated(id) // bool +scoping.symbol_is_unused(id) // bool +scoping.root_unresolved_references() // globals + +scoping.scope_flags(id) // ScopeFlags +scoping.scope_parent_id(id) // Option +scoping.scope_ancestors(id) // Iterator +scoping.find_binding(scope, name) // Option (walks up) +scoping.get_binding(scope, name) // Option (this scope only) +scoping.iter_bindings_in(scope) // Iterator +``` + +--- + +## What oxc_semantic has that we don't + +- **SoA / arena memory model** — compiler-grade performance, no per-symbol heap allocation. +- **SymbolFlags** — full declaration-kind information (var/let/const/class/fn/import/TS variants). +- **ReferenceFlags** — Read/Write/Type per reference. +- **Redeclaration tracking** — knows when a name is declared more than once and stores all sites. +- **`symbol_is_mutated` / `symbol_is_unused`** — derived facts useful for linting/optimization. +- **TypeScript type-space** — separate type vs value reference tracking. +- **ClassScope always** (not just named expressions), ClassStaticBlock scope. +- **`with` scope**, strict-mode propagation, direct-eval propagation. +- **Checkpoint early resolution** — correct forward-reference semantics for params. + +## What we have that oxc_semantic doesn't + +- **`scopeToReferences` aggregation** — O(1) "all refs inside scope X" without a walk. oxc_semantic has `get_resolved_references(symbol_id)` (per symbol) but no pre-aggregated per-scope list of all references. +- **JS/TS implementation** — works with any ESTree parser; no Rust toolchain required. +- **Simplicity** — ~300 lines vs ~4000+ lines across multiple files. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/periscopic.md b/packages/plugin-rsc/docs/notes/scope-manager-research/periscopic.md new file mode 100644 index 000000000..270421b70 --- /dev/null +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/periscopic.md @@ -0,0 +1,162 @@ +# scope.ts vs periscopic: comparison + +**Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) +**Prior art:** `~/code/others/periscopic/src/index.js` + +--- + +## Data model + +### Ours + +``` +Scope + declarations: Set + parent: Scope | undefined + isFunction: boolean + +ScopeTree + referenceToDeclaredScope: Map + scopeToReferences: Map + nodeScope: Map + moduleScope: Scope +``` + +### periscopic + +``` +Scope + parent: Scope | null + block: boolean // true = block scope, false = function scope + declarations: Map // name → declaring AST node + initialised_declarations: Set // subset of declarations that have an initializer + references: Set // names referenced here OR in any child scope + +analyze(ast) → { map, scope, globals } + map: WeakMap // scope-creating node → Scope + scope: Scope // root scope + globals: Map // name → Identifier node, for names with no declaration +``` + +**Key difference:** periscopic stores the declaring AST node in `declarations` (richer than our `Set`), but references are only `Set` — no link back to individual `Identifier` nodes. Once you ask "is `foo` referenced?" you get yes/no but cannot identify which `Identifier` nodes produced that answer. This is what makes shadowing invisible (see below). + +--- + +## Scope types created + +| Situation | periscopic | Ours | +| ------------------------------------------------ | ------------------------------------- | ------------------------------------ | +| `function f() {}` / `function() {}` / `() => {}` | `Scope(block=false)` | `Scope(isFunction=true)` | +| Named fn expr `(function f() {})` | `f` added to the function's own scope | same | +| `class Foo {}` (declaration) | no scope | no scope | +| `(class Foo {})` (named expression) | no scope | `Scope(isFunction=false)` with `Foo` | +| `{ }` BlockStatement | `Scope(block=true)` | `Scope(isFunction=false)` | +| `for (…)` / `for…in` / `for…of` | `Scope(block=true)` | `Scope(isFunction=false)` | +| `switch (…)` | `Scope(block=true)` | `Scope(isFunction=false)` | +| `catch (e)` | `Scope(block=true)` | `Scope(isFunction=false)` | +| `export { x } from './y'` | `Scope(block=true)` ← unnecessary | no scope | + +Notable gap: periscopic creates no scope for named class expressions, so the self-binding name `Foo` in `(class Foo {})` leaks to the outer scope. Our implementation fixes this. + +--- + +## Reference detection + +periscopic delegates to the [`is-reference`](https://github.com/nicolo-ribaudo/is-reference) package to decide whether an `Identifier` is a reference. This is equivalent to our `isReferenceIdentifier()` function. Neither implementation re-implements this from scratch — ours is modeled after Vite SSR's `isRefIdentifier`, which is in turn derived from the same lineage. + +--- + +## Reference resolution strategy + +### periscopic: post-walk, name-string resolution + +1. Walk collects `[scope, Identifier]` pairs into a temporary array. +2. After the walk, for each pair call `scope.find_owner(name)` — a name-string lookup walking up the parent chain. +3. Unresolved names go into `globals`. + +`find_owner` is a string-based chain walk: + +```js +find_owner(name) { + if (this.declarations.has(name)) return this; + return this.parent && this.parent.find_owner(name); +} +``` + +This looks correct, but the **scope anchor** used for the lookup is wrong in practice (see shadowing bug below). + +### Ours: post-walk, Identifier-node resolution + +Same two-phase structure, but we store the `Identifier` node itself and resolve against the complete scope tree after the walk. This gives us per-Identifier granularity instead of per-name. + +--- + +## The shadowing bug + +This is why periscopic was dropped as a dependency (see `2026-04-04-hoist-variable-shadowing.md`). + +The original caller did: + +```ts +const scope = analyzed.map.get(functionNode) // returns param scope +const bindVars = [...scope.references].filter((ref) => { + const owner = scope.find_owner(ref) // name-string lookup + return owner && owner !== scope && owner !== analyzed.scope +}) +``` + +Two layered problems: + +**1. Wrong scope anchor.** `analyzed.map.get(functionNode)` returns the scope for the function node itself, which in periscopic's model is the param scope. The function body (`BlockStatement`) is a child scope of this. `let`/`const` declarations inside the body live in that child scope. So when `find_owner` walks up from the param scope it skips the body-scope declarations, and a body-level `const value` becomes invisible — the lookup walks past it and finds the outer `value` instead. + +**2. Name-based references.** `scope.references` is `Set`. There is no way to ask "does this specific reference occurrence resolve inside or outside?" — only "does any declaration of this name exist outside?" A body-scope shadowing declaration is invisible because the reference string `"value"` matches whether it is resolved locally or not. + +Together: a `const value` declared inside the server function body would not prevent the outer `value` from being bound, because (a) the anchor scope didn't see the inner declaration, and (b) even if it had, the string-based check couldn't distinguish "this reference resolves to the inner `value`" from "this reference resolves to the outer `value`". + +--- + +## `var` hoisting + +periscopic handles `var` hoisting by recursively delegating to the parent scope from within `add_declaration`: + +```js +if (node.kind === 'var' && this.block && this.parent) { + this.parent.add_declaration(node) +} +``` + +A `var` in a block scope propagates upward until it lands in a non-block (function) scope. This is correct. + +Our implementation does the same, but at walk time rather than at declaration-adding time: + +```ts +const target = node.kind === 'var' ? current.getNearestFunctionScope() : current +``` + +--- + +## `extract_names` / `extract_identifiers` + +periscopic exports these two utilities. We copied them directly into our codebase (`src/transforms/utils.ts`) rather than keeping the periscopic dependency. They recursively extract leaf binding names from destructuring patterns: + +- `Identifier` → push the name +- `ObjectPattern` → recurse into property values and rest +- `ArrayPattern` → recurse into elements +- `RestElement` → recurse into argument +- `AssignmentPattern` → recurse into left (the binding, not the default) + +These are still used by our `buildScopeTree` for param and destructuring declaration handling. + +--- + +## What periscopic has that we don't + +- `declarations` maps names to the declaring AST node (not just a string set) — useful if callers need to distinguish declaration kind or locate the declaration site. +- `globals` map — explicit set of undeclared names with the referencing `Identifier` node. +- `initialised_declarations` — subset of declarations that had an initializer. + +## What we have that periscopic doesn't + +- Per-`Identifier` reference tracking (not per-name) — makes shadowing correctly visible. +- Named class expression scope (self-binding `Foo` in `(class Foo {})`). +- `scopeToReferences` aggregation — O(1) "all references inside scope X". diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/typescript-eslint.md b/packages/plugin-rsc/docs/notes/scope-manager-research/typescript-eslint.md new file mode 100644 index 000000000..9bca7805d --- /dev/null +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/typescript-eslint.md @@ -0,0 +1,186 @@ +# scope.ts vs typescript-eslint scope-manager: comparison + +**Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) +**Prior art:** `~/code/others/typescript-eslint/packages/scope-manager/` + +--- + +## Data model + +### Ours + +``` +Scope + declarations: Set // names declared here + parent: Scope | undefined + isFunction: boolean // whether this is a function boundary + +ScopeTree + referenceToDeclaredScope: Map // ref id → declaring scope (null = global) + scopeToReferences: Map // scope → all ref ids (propagated upward) + nodeScope: Map // AST node → its scope + moduleScope: Scope +``` + +### typescript-eslint + +``` +ScopeBase + type: ScopeType enum // 18 distinct types + variables: Variable[] // Variables declared here + set: Map // name → Variable + references: Reference[] // References created in THIS scope + through: Reference[] // Unresolved refs delegated to upper scope + childScopes: Scope[] + upper: Scope | null + block: TSESTree.Node // the AST node that created this scope + variableScope: VariableScope // nearest function/module/global scope (for var hoisting) + +Variable + name: string + defs: Definition[] // where it was declared (includes kind: var/let/const/param/...) + references: Reference[] // all uses of this variable + identifiers: Identifier[] // declaration sites + scope: Scope // declaring scope + +Reference + identifier: Identifier + from: Scope // scope where the reference appears + resolved: Variable | null // null = global/undeclared + flag: ReferenceFlag // Read | Write | ReadWrite + writeExpr: Node | null // the rhs in an assignment + init: boolean // initializer write +``` + +**Key difference:** typescript-eslint is _Variable-centric_: each name gets a `Variable` object linking all its definition sites and use sites. Ours is _Identifier-centric_: each reference `Identifier` node maps to a `Scope`; we never build a `Variable` object grouping all uses of the same name. + +--- + +## Scope types created + +| Situation | Ours | typescript-eslint | +| ---------------------------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------- | +| Program / module | `Scope(undefined, isFunction=true)` (moduleScope) | `GlobalScope` + `ModuleScope` | +| `function f() {}` / `function() {}` / `() => {}` | `Scope(parent, isFunction=true)` | `FunctionScope` | +| Named function expression `(function f() {})` | function name added to the function's own scope | **`FunctionExpressionNameScope`** wrapping the `FunctionScope` | +| `class Foo {}` (declaration) | no extra scope | `ClassScope` with `Foo` defined inside | +| `(class Foo {})` (named expression) | `Scope(parent, isFunction=false)` with `Foo` declared | `ClassScope` with `Foo` defined inside | +| `(class {})` (anonymous expression) | no scope | `ClassScope` (still created) | +| `{ }` BlockStatement | `Scope(parent, isFunction=false)` | `BlockScope` | +| `for (…) {}` / `for…in` / `for…of` | `Scope(parent, isFunction=false)` | `ForScope` | +| `switch (…) {}` | `Scope(parent, isFunction=false)` | `SwitchScope` | +| `catch (e) {}` | `Scope(parent, isFunction=false)` | `CatchScope` | +| TypeScript-specific (enum, namespace, conditional type, …) | not supported | many extra scope types | + +### Notable divergence 1 — FunctionExpressionNameScope + +typescript-eslint inserts a **separate wrapper scope** for the name of a named function expression: + +``` +outer scope + └─ FunctionExpressionNameScope ← contains: f + └─ FunctionScope ← contains: params, var declarations +``` + +Source: [`FunctionExpressionNameScope.ts`](~/code/others/typescript-eslint/packages/scope-manager/src/scope/FunctionExpressionNameScope.ts) + +Our implementation adds the function expression name directly into the function scope: + +``` +outer scope + └─ FunctionScope ← contains: f (the name), params, var declarations +``` + +Source: [scope.ts#L89-L91](../../../src/transforms/scope.ts#L89) + +**Practical effect:** In both cases, `f` is not visible in the outer scope. The self-recursive name is accessible inside the body. The difference only shows when introspecting the scope tree structure (e.g., ESLint rules that walk `scope.variables`). + +### Notable divergence 2 — ClassScope + +typescript-eslint creates a `ClassScope` for EVERY class (declaration and expression), always: + +```js +class Foo extends Base {} +``` + +``` +outer scope ← Foo defined here (for declarations) + └─ ClassScope ← Foo defined here again (inner self-reference for heritage + body) +``` + +Source: [`ClassVisitor.ts#L50-L63`](~/code/others/typescript-eslint/packages/scope-manager/src/referencer/ClassVisitor.ts#L50) + +Our implementation only creates a scope for **named class expressions** (the self-binding case), not for class declarations or anonymous class expressions: + +```js +const x = class Foo {} // ← creates Scope containing 'Foo' +class Foo {} // ← no extra scope; 'Foo' goes into current scope +``` + +Source: [scope.ts#L92-L100](../../../src/transforms/scope.ts#L92) + +**Practical effect:** References to `Foo` from within a class declaration's heritage (`extends Foo {}`) resolve to the outer binding in our implementation. typescript-eslint would resolve them to the inner `ClassScope` binding. For the RSC use case this distinction doesn't matter because we're looking for free variable bindings, not inner self-references. + +--- + +## Reference resolution strategy + +### Ours: post-walk deferred resolution + +1. Walk collects `{ id: Identifier, visitScope: Scope }` pairs without resolving. +2. After the walk (when all declarations are known), loop through raw refs and walk up the scope chain to find the declaring scope. + +**Why:** Avoids `var`/function hoisting bugs. A reference before its `var` declaration in the same function would incorrectly resolve to an outer scope if resolved eagerly. + +Source: [scope.ts#L51-L57](../../../src/transforms/scope.ts#L51) + +### typescript-eslint: close-time resolution + +1. During the walk each scope accumulates `leftToResolve: Reference[]`. +2. When a scope closes, it calls `close(scopeManager)` which tries to resolve each ref. +3. Unresolved refs are pushed to `through[]` and delegated to the upper scope via `delegateToUpperScope()`. + +Source: [`ScopeBase.ts#close`](~/code/others/typescript-eslint/packages/scope-manager/src/scope/ScopeBase.ts) + +Both strategies resolve at "scope exit" time (when all local declarations are visible), so they handle hoisting correctly. The difference is organizational: ours is a single post-walk pass; typescript-eslint resolves incrementally per scope. + +--- + +## Reference propagation + +### Ours: push to ALL ancestor scopes + +Every reference is added to `scopeToReferences` for its `visitScope` AND all ancestors up to the root. This makes it easy to ask "what identifiers are referenced inside scope X?" in O(1) at query time. + +Source: [scope.ts#L169-L173](../../../src/transforms/scope.ts#L169) + +### typescript-eslint: through[] chain + +Unresolved references bubble up via `through[]`. To find all refs accessible from a scope you'd need to walk `scope.through` recursively — there's no pre-aggregated list like our `scopeToReferences`. + +--- + +## `isReferenceIdentifier` / reference classification + +We implement this ourselves in [scope.ts#L202](../../../src/transforms/scope.ts#L202), modeled after Vite SSR's `isRefIdentifier`. typescript-eslint delegates this to `PatternVisitor` and `Referencer`, which drive the walk and explicitly call `scope.referenceValue()` / `scope.referenceType()` only at reference positions — they never need a negative filter because they control which nodes trigger a reference call. + +**Comment in our code:** `// TODO: review slop` — the positive-classifier approach is easier to audit but needs ongoing care as new node types are added. + +--- + +## What typescript-eslint provides that we don't + +1. **Read/Write flag on references** — knows if `x` is being read or written (or both). +2. **Definition kind** — `var` vs `let` vs `const` vs param vs import vs class name vs function name. +3. **`through[]`** — explicit "unresolved references" list per scope. +4. **TypeScript type-only references** — `ReferenceTypeFlag` distinguishes value vs type references. +5. **`ClassFieldInitializerScope` / `ClassStaticBlockScope`** — fine-grained scoping inside class bodies. +6. **`declaredVariables`** — `WeakMap` lets you go from any AST node back to what it declares. + +--- + +## What we have that typescript-eslint doesn't + +1. **`scopeToReferences` aggregation** — O(1) "all refs inside this scope" without recursion. +2. **Simpler model** — no Variable/Definition/Reference class hierarchy, just `Map`. +3. **Works on plain ESTree** — no TypeScript AST dependency. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/vite-ssr.md b/packages/plugin-rsc/docs/notes/scope-manager-research/vite-ssr.md new file mode 100644 index 000000000..7884e9368 --- /dev/null +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/vite-ssr.md @@ -0,0 +1,135 @@ +# scope.ts vs Vite SSR transform: comparison + +**Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) +**Prior art:** `~/code/others/vite/packages/vite/src/node/ssr/ssrTransform.ts` (~L456–776) + +--- + +## Purpose + +The scope analysis in `ssrTransform.ts` is not a general-purpose scope library — it answers one specific question: which identifiers are free variables that reference an imported binding, so that the transform can rewrite them (e.g. `foo` → `__import_x__.foo`). This is a narrower goal than ours (`getBindVars` finds outer-scope closures for `use server` functions), but the underlying machinery is similar. + +--- + +## Data model + +### Ours + +``` +Scope (class) + declarations: Set + parent: Scope | undefined + isFunction: boolean + +ScopeTree + referenceToDeclaredScope: Map + scopeToReferences: Map + nodeScope: Map + moduleScope: Scope +``` + +### Vite SSR + +No `Scope` class — entirely ad-hoc with module-level data structures: + +```ts +const parentStack: ESTree.Node[] // DFS ancestor stack +const varKindStack: ESTree.VariableDeclaration['kind'][] // current var kind context +const scopeMap: WeakMap> // scope node → declared names +const identifiers: [id: ESTree.Identifier, stack: ESTree.Node[]][] // deferred reference list +``` + +`scopeMap` maps each scope-creating AST node directly to a `Set` of declared names — no `Scope` objects, no parent links. Scope hierarchy is reconstructed on demand by walking `parentStack`. + +--- + +## Scope types created (entries in `scopeMap`) + +| Situation | Vite SSR | Ours | +| ------------------------------------------------ | ----------------------------------------------- | ------------------------------------ | +| Program (module root) | `scopeMap.set(Program, ...)` | `moduleScope` | +| `function f() {}` / `function() {}` / `() => {}` | `scopeMap.set(fn, ...)` | `Scope(isFunction=true)` | +| Named fn expr `(function f() {})` | name added to the **function's own** scope node | same | +| `function f() {}` name | added to **parent** scope node | same | +| `class Foo {}` name | added to **parent** scope node | same | +| Named class expr `(class Foo {})` | name added to **class's own** scope node | `Scope(isFunction=false)` with `Foo` | +| `{ }` BlockStatement | `scopeMap.set(block, ...)` | `Scope(isFunction=false)` | +| `for` / `for…in` / `for…of` | `scopeMap.set(for, ...)` | `Scope(isFunction=false)` | +| `catch (e)` | `scopeMap.set(catch, ...)` | `Scope(isFunction=false)` | +| `class {}` static block | `scopeMap.set(staticBlock, ...)` | not handled | +| `switch` | not handled (no entry in `blockNodeTypeRE`) | `Scope(isFunction=false)` | + +Named class expression handling is the same as ours: the self-binding name is visible only inside the class. switch scopes diverge: Vite SSR skips them, we create one. + +--- + +## Resolution strategy + +### Vite SSR: two-phase, but eagerly filtered during walk + +**Phase 1 (DFS enter/leave):** Builds `scopeMap` with all declarations. References are identified by `isRefIdentifier()` and filtered by `isInScope()` during this pass — but only stored into `identifiers[]`, not resolved yet. + +**Phase 2 (sequential):** Processes `identifiers[]` in order. Re-checks `isInScope()` with the stored parent stack snapshot. + +```ts +identifiers.forEach(([node, stack]) => { + if (!isInScope(node.name, stack)) onIdentifier(node, stack[0], stack) +}) +``` + +`isInScope` walks the stored `parentStack` looking for a `scopeMap` entry that contains the name: + +```ts +function isInScope(name: string, parents: ESTree.Node[]) { + return parents.some((node) => scopeMap.get(node)?.has(name)) +} +``` + +Because phase 1 finishes before phase 2 begins, all declarations (including hoisted `var` and function declarations) are already in `scopeMap` when references are resolved. This is the same two-phase approach as ours, though expressed differently (we store `visitScope` reference; they store a `parentStack` snapshot). + +### Ours: post-walk, Identifier → declaring Scope + +We store `{ id: Identifier, visitScope: Scope }` and resolve by walking up the `Scope` parent chain. The outcome is the same but we produce a `Map` linking each ref to its declaring scope, whereas Vite SSR only produces a boolean "is this in scope or not". + +--- + +## `var` hoisting + +Vite SSR uses `varKindStack` to track whether the current declaration is `var`, then passes `isVar` to `findParentScope`: + +```ts +function findParentScope(parentStack, isVar = false) { + return parentStack.find(isVar ? isFunction : isBlock) +} +``` + +- `var` → finds nearest function scope (by `isFunction` regex match) +- `let`/`const` → finds nearest block scope (by `isBlock` regex match) + +Our implementation uses `getNearestFunctionScope()` for `var`, or stays at `current` for `let`/`const` — same logic, different expression. + +--- + +## Reference detection: `isRefIdentifier` + +Both implementations have an `isRefIdentifier` / `isReferenceIdentifier` function that filters out syntax-only identifier positions. Vite SSR's version is the direct inspiration for ours. Key differences: + +- Vite SSR pre-marks pattern nodes in a `WeakSet` during declaration handling, making pattern vs. expression distinction available at reference-check time without needing grandparent context. +- Our implementation uses the `parentStack` directly (grandparent lookups) instead of a pre-mark WeakSet. +- Vite SSR skips `ImportDeclaration` subtrees entirely with `this.skip()` so import specifier identifiers never reach the reference check. We handle them explicitly in `isReferenceIdentifier`. + +--- + +## What Vite SSR has that we don't + +- `StaticBlock` scope (class static initializers). +- Regex-based `isFunction` match catches generator and async variants (`GeneratorFunctionExpression`, `AsyncFunctionDeclaration`, etc.) generically without enumerating them. +- Pre-marked WeakSet for patterns — cleaner than grandparent-stack checks. + +## What we have that Vite SSR doesn't + +- `Scope` objects with parent links — enables walking the scope hierarchy without needing a `parentStack` snapshot. +- Per-`Identifier` → declaring `Scope` map — answers "where exactly does this ref resolve?" not just "is it in scope?". +- `scopeToReferences` aggregation — O(1) "all refs inside scope X". +- Named class expression scope (self-binding correctly isolated). +- `switch` scope. From 7e8d5e53d00bd160862d03ffa805324e6d0c2df8 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:21:26 +0900 Subject: [PATCH 83/88] test(rsc): cover param default var hoisting gap Co-authored-by: Codex --- .../scope/param-default-var-hoisting.js | 8 +++ .../param-default-var-hoisting.js.snap.json | 57 +++++++++++++++++++ packages/plugin-rsc/src/transforms/scope.ts | 4 ++ 3 files changed, 69 insertions(+) create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/param-default-var-hoisting.js create mode 100644 packages/plugin-rsc/src/transforms/fixtures/scope/param-default-var-hoisting.js.snap.json diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/param-default-var-hoisting.js b/packages/plugin-rsc/src/transforms/fixtures/scope/param-default-var-hoisting.js new file mode 100644 index 000000000..93d93b3be --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/param-default-var-hoisting.js @@ -0,0 +1,8 @@ +function outer() { + const y = 'outer' + function inner(x = y) { + var y = 'inner' + return x + } + return inner +} diff --git a/packages/plugin-rsc/src/transforms/fixtures/scope/param-default-var-hoisting.js.snap.json b/packages/plugin-rsc/src/transforms/fixtures/scope/param-default-var-hoisting.js.snap.json new file mode 100644 index 000000000..faf6896ad --- /dev/null +++ b/packages/plugin-rsc/src/transforms/fixtures/scope/param-default-var-hoisting.js.snap.json @@ -0,0 +1,57 @@ +{ + "type": "Program", + "declarations": [ + "outer" + ], + "references": [], + "children": [ + { + "type": "FunctionDeclaration:outer", + "declarations": [], + "references": [], + "children": [ + { + "type": "BlockStatement", + "declarations": [ + "inner", + "y" + ], + "references": [ + { + "name": "inner", + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement" + } + ], + "children": [ + { + "type": "FunctionDeclaration:inner", + "declarations": [ + "x", + "y" + ], + "references": [ + { + "name": "y", + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:inner" + } + ], + "children": [ + { + "type": "BlockStatement", + "declarations": [], + "references": [ + { + "name": "x", + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:inner" + } + ], + "children": [] + } + ] + } + ] + } + ] + } + ] +} diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 483e181c8..6e595a73a 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -158,6 +158,10 @@ export function buildScopeTree(ast: Program): ScopeTree { const referenceToDeclaredScope = new Map() for (const { id, visitScope } of rawReferences) { + // TODO: default param expressions should not resolve to `var` declarations + // from the same function body. We currently start lookup at `visitScope`, + // so `function f(x = y) { var y }` incorrectly resolves `y` to `f`'s own + // function scope instead of continuing to the parent scope. let declScope: Scope | undefined = visitScope while (declScope && !declScope.declarations.has(id.name)) { declScope = declScope.parent From 1bd96389f0075c7b6f341738196b092838334aa4 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:24:34 +0900 Subject: [PATCH 84/88] docs(plugin-rsc): replace local paths with GitHub URLs in research notes Co-Authored-By: Claude Sonnet 4.6 --- .../notes/2026-04-05-scope-manager-research.md | 18 +++++++++--------- .../scope-manager-research/babel-traverse.md | 2 +- .../scope-manager-research/eslint-scope.md | 2 +- .../notes/scope-manager-research/nextjs.md | 2 +- .../notes/scope-manager-research/oxc-walker.md | 2 +- .../docs/notes/scope-manager-research/oxc.md | 2 +- .../notes/scope-manager-research/periscopic.md | 2 +- .../typescript-eslint.md | 8 ++++---- .../notes/scope-manager-research/vite-ssr.md | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md b/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md index 9c9c37cfe..b9327852c 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md +++ b/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md @@ -155,14 +155,14 @@ I'll write the comparison doc myself. **Addendum per prior art:** -| Prior art | `{LOCATION}` | `{FRAMING_NOTE}` | `{EXTRA_QUESTIONS}` | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| periscopic | `~/code/others/periscopic/` — please read all relevant source files | _(omit)_ | `11. What do extract_names / extract_identifiers do?` | -| vite-ssr | `~/code/others/vite/packages/vite/src/node/ssr/ssrTransform.ts` — the scope-related code is approximately lines 456–760 but check the actual line range yourself | _(omit)_ | `11. Is there a Scope class or is it ad-hoc maps/stacks?` `12. What is the purpose of this scope analysis within ssrTransform — what question is it answering?` `13. The file uses estree-walker — check what version/API it uses.` | -| eslint-scope | `~/code/others/eslint-js/packages/eslint-scope/` | _(omit)_ | `11. What is the Variable data model? (defs, references, identifiers)` `12. What is the Reference data model? (identifier, resolved, flag, from)` `13. List all ScopeType variants.` `14. Is there a FunctionExpressionNameScope?` | -| babel-traverse | `~/code/others/babel/packages/babel-traverse/src/scope/` | _(omit)_ | `11. What is the Binding data model? (identifier, path, scope, kind, references, referencePaths, constantViolations)` `12. Is resolution lazy or eager (crawl-on-demand)?` `13. List the public scope query API (getBinding(), hasBinding(), etc.)` | -| oxc_semantic | `~/code/others/oxc/crates/oxc_semantic/src/` | `This is Rust code — focus on the data model and algorithm, not language-specific syntax.` | `11. How are symbols stored? (arena IDs, string interning, etc.)` `12. What is the entry point from the compiler pipeline?` `13. What are the design trade-offs vs JS implementations?` | -| oxc-walker | `~/code/others/oxc-walker/src/scope-tracker.ts` (and any related files) | _(omit)_ | `11. What is isBindingIdentifier — what positions does it exclude?` `12. What is the public API surface (getUndeclaredIdentifiersInFunction or similar)?` | +| Prior art | GitHub | `{LOCATION}` (local clone) | `{FRAMING_NOTE}` | `{EXTRA_QUESTIONS}` | +| -------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| periscopic | [Rich-Harris/periscopic](https://github.com/Rich-Harris/periscopic) | `~/code/others/periscopic/` — please read all relevant source files | _(omit)_ | `11. What do extract_names / extract_identifiers do?` | +| vite-ssr | [vitejs/vite](https://github.com/vitejs/vite) | `~/code/others/vite/packages/vite/src/node/ssr/ssrTransform.ts` — the scope-related code is approximately lines 456–760 but check the actual line range yourself | _(omit)_ | `11. Is there a Scope class or is it ad-hoc maps/stacks?` `12. What is the purpose of this scope analysis within ssrTransform — what question is it answering?` `13. The file uses estree-walker — check what version/API it uses.` | +| eslint-scope | [eslint/js](https://github.com/eslint/js) | `~/code/others/eslint-js/packages/eslint-scope/` | _(omit)_ | `11. What is the Variable data model? (defs, references, identifiers)` `12. What is the Reference data model? (identifier, resolved, flag, from)` `13. List all ScopeType variants.` `14. Is there a FunctionExpressionNameScope?` | +| babel-traverse | [babel/babel](https://github.com/babel/babel) | `~/code/others/babel/packages/babel-traverse/src/scope/` | _(omit)_ | `11. What is the Binding data model? (identifier, path, scope, kind, references, referencePaths, constantViolations)` `12. Is resolution lazy or eager (crawl-on-demand)?` `13. List the public scope query API (getBinding(), hasBinding(), etc.)` | +| oxc_semantic | [oxc-project/oxc](https://github.com/oxc-project/oxc) | `~/code/others/oxc/crates/oxc_semantic/src/` | `This is Rust code — focus on the data model and algorithm, not language-specific syntax.` | `11. How are symbols stored? (arena IDs, string interning, etc.)` `12. What is the entry point from the compiler pipeline?` `13. What are the design trade-offs vs JS implementations?` | +| oxc-walker | [oxc-project/oxc-walker](https://github.com/oxc-project/oxc-walker) | `~/code/others/oxc-walker/src/scope-tracker.ts` (and any related files) | _(omit)_ | `11. What is isBindingIdentifier — what positions does it exclude?` `12. What is the public API surface (getUndeclaredIdentifiersInFunction or similar)?` | --- @@ -170,7 +170,7 @@ I'll write the comparison doc myself. ``` Find and summarize the scope analysis / reference tracking used in Next.js's -server action transform. The repo is at `~/code/others/next.js/`. +server action transform. Repo: https://github.com/vercel/next.js (cloned at `~/code/others/next.js/`). First, locate the relevant files — likely somewhere under `packages/next/src/` involving "server action", "use server", or similar. Check both SWC transform diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/babel-traverse.md b/packages/plugin-rsc/docs/notes/scope-manager-research/babel-traverse.md index 7374c2c7b..ba36a2e8c 100644 --- a/packages/plugin-rsc/docs/notes/scope-manager-research/babel-traverse.md +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/babel-traverse.md @@ -1,7 +1,7 @@ # scope.ts vs Babel traverse Scope: comparison **Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) -**Prior art:** `~/code/others/babel/packages/babel-traverse/src/scope/` +**Prior art:** [github.com/babel/babel](https://github.com/babel/babel) — `packages/babel-traverse/src/scope/` Babel's `Scope` is the most feature-rich JS-side scope implementation in this survey. It is tightly coupled to `NodePath` (Babel's AST cursor with parent tracking), which enables capabilities like AST mutation, identifier renaming, and constant-violation tracking that a read-only scope analyzer cannot provide. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/eslint-scope.md b/packages/plugin-rsc/docs/notes/scope-manager-research/eslint-scope.md index 0eb57a08f..964a2d4c3 100644 --- a/packages/plugin-rsc/docs/notes/scope-manager-research/eslint-scope.md +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/eslint-scope.md @@ -1,7 +1,7 @@ # scope.ts vs eslint-scope: comparison **Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) -**Prior art:** `~/code/others/eslint-js/packages/eslint-scope/` +**Prior art:** [github.com/eslint/js](https://github.com/eslint/js) — `packages/eslint-scope/` eslint-scope is the original ECMA-262 scope analyzer for ESTree ASTs that typescript-eslint was built on top of. The interface it defines (`ScopeManager`, `Scope`, `Variable`, `Reference`) became the standard that all subsequent JS scope tools reference. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/nextjs.md b/packages/plugin-rsc/docs/notes/scope-manager-research/nextjs.md index 2dadcc47d..ea53feb61 100644 --- a/packages/plugin-rsc/docs/notes/scope-manager-research/nextjs.md +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/nextjs.md @@ -1,7 +1,7 @@ # scope.ts vs Next.js server action transform: comparison **Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) -**Prior art:** `~/code/others/next.js/crates/next-custom-transforms/src/transforms/server_actions.rs` +**Prior art:** [github.com/vercel/next.js](https://github.com/vercel/next.js) — `crates/next-custom-transforms/src/transforms/server_actions.rs` --- diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/oxc-walker.md b/packages/plugin-rsc/docs/notes/scope-manager-research/oxc-walker.md index ce98a2afb..249db3e83 100644 --- a/packages/plugin-rsc/docs/notes/scope-manager-research/oxc-walker.md +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/oxc-walker.md @@ -1,7 +1,7 @@ # scope.ts vs oxc-walker: comparison **Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) -**Prior art:** `~/code/others/oxc-walker/src/scope-tracker.ts` +**Prior art:** [github.com/oxc-project/oxc-walker](https://github.com/oxc-project/oxc-walker) — `src/scope-tracker.ts` oxc-walker is a small TS utility that pairs an AST walker with an optional `ScopeTracker`. It is the most directly comparable prior art to our implementation in terms of scope (pun intended) — both are lightweight, ESTree-compatible, and purpose-built rather than general-purpose compiler infrastructure. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/oxc.md b/packages/plugin-rsc/docs/notes/scope-manager-research/oxc.md index a2b5ffc14..3811e5d02 100644 --- a/packages/plugin-rsc/docs/notes/scope-manager-research/oxc.md +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/oxc.md @@ -1,7 +1,7 @@ # scope.ts vs oxc_semantic: comparison **Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) -**Prior art:** `~/code/others/oxc/crates/oxc_semantic/src/` (Rust) +**Prior art:** [github.com/oxc-project/oxc](https://github.com/oxc-project/oxc) — `crates/oxc_semantic/src/` (Rust) oxc_semantic is the full semantic analysis pass of the oxc compiler — the heaviest implementation in this survey. It is designed as production compiler infrastructure, not a library for external callers. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/periscopic.md b/packages/plugin-rsc/docs/notes/scope-manager-research/periscopic.md index 270421b70..3cf53f301 100644 --- a/packages/plugin-rsc/docs/notes/scope-manager-research/periscopic.md +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/periscopic.md @@ -1,7 +1,7 @@ # scope.ts vs periscopic: comparison **Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) -**Prior art:** `~/code/others/periscopic/src/index.js` +**Prior art:** [github.com/Rich-Harris/periscopic](https://github.com/Rich-Harris/periscopic) — `src/index.js` --- diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/typescript-eslint.md b/packages/plugin-rsc/docs/notes/scope-manager-research/typescript-eslint.md index 9bca7805d..e2fdbeb4c 100644 --- a/packages/plugin-rsc/docs/notes/scope-manager-research/typescript-eslint.md +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/typescript-eslint.md @@ -1,7 +1,7 @@ # scope.ts vs typescript-eslint scope-manager: comparison **Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) -**Prior art:** `~/code/others/typescript-eslint/packages/scope-manager/` +**Prior art:** [github.com/typescript-eslint/typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) — `packages/scope-manager/` --- @@ -82,7 +82,7 @@ outer scope └─ FunctionScope ← contains: params, var declarations ``` -Source: [`FunctionExpressionNameScope.ts`](~/code/others/typescript-eslint/packages/scope-manager/src/scope/FunctionExpressionNameScope.ts) +Source: [`FunctionExpressionNameScope.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/scope-manager/src/scope/FunctionExpressionNameScope.ts) Our implementation adds the function expression name directly into the function scope: @@ -108,7 +108,7 @@ outer scope ← Foo defined here (for declarations) └─ ClassScope ← Foo defined here again (inner self-reference for heritage + body) ``` -Source: [`ClassVisitor.ts#L50-L63`](~/code/others/typescript-eslint/packages/scope-manager/src/referencer/ClassVisitor.ts#L50) +Source: [`ClassVisitor.ts#L50-L63`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/scope-manager/src/referencer/ClassVisitor.ts#L50) Our implementation only creates a scope for **named class expressions** (the self-binding case), not for class declarations or anonymous class expressions: @@ -140,7 +140,7 @@ Source: [scope.ts#L51-L57](../../../src/transforms/scope.ts#L51) 2. When a scope closes, it calls `close(scopeManager)` which tries to resolve each ref. 3. Unresolved refs are pushed to `through[]` and delegated to the upper scope via `delegateToUpperScope()`. -Source: [`ScopeBase.ts#close`](~/code/others/typescript-eslint/packages/scope-manager/src/scope/ScopeBase.ts) +Source: [`ScopeBase.ts#close`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/scope-manager/src/scope/ScopeBase.ts) Both strategies resolve at "scope exit" time (when all local declarations are visible), so they handle hoisting correctly. The difference is organizational: ours is a single post-walk pass; typescript-eslint resolves incrementally per scope. diff --git a/packages/plugin-rsc/docs/notes/scope-manager-research/vite-ssr.md b/packages/plugin-rsc/docs/notes/scope-manager-research/vite-ssr.md index 7884e9368..14381af7d 100644 --- a/packages/plugin-rsc/docs/notes/scope-manager-research/vite-ssr.md +++ b/packages/plugin-rsc/docs/notes/scope-manager-research/vite-ssr.md @@ -1,7 +1,7 @@ # scope.ts vs Vite SSR transform: comparison **Our impl:** [src/transforms/scope.ts](../../../src/transforms/scope.ts) -**Prior art:** `~/code/others/vite/packages/vite/src/node/ssr/ssrTransform.ts` (~L456–776) +**Prior art:** [github.com/vitejs/vite](https://github.com/vitejs/vite) — `packages/vite/src/node/ssr/ssrTransform.ts` (~L456–776) --- From 5252fb17047ddc83f1c2fcad9e625f54a316302c Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:28:52 +0900 Subject: [PATCH 85/88] fix(plugin-rsc): remove hard-coded fixture path Co-authored-by: Codex --- packages/plugin-rsc/scripts/README.md | 15 ++++++- ...import-typescript-eslint-scope-fixtures.ts | 40 ++++++++++++++----- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/packages/plugin-rsc/scripts/README.md b/packages/plugin-rsc/scripts/README.md index e332948bd..cc9fe3108 100644 --- a/packages/plugin-rsc/scripts/README.md +++ b/packages/plugin-rsc/scripts/README.md @@ -6,10 +6,12 @@ Regenerates the checked-in pre-transpiled JS fixture subtree at `src/transforms/fixtures/scope/typescript-eslint/` from a local `typescript-eslint` checkout. -Default source: +Source resolution order: ```bash -/home/hiroshi/code/others/typescript-eslint/packages/scope-manager/tests/fixtures +1. --source /path/to/typescript-eslint/packages/scope-manager/tests/fixtures +2. TYPESCRIPT_ESLINT_SCOPE_FIXTURES_DIR +3. ../typescript-eslint/packages/scope-manager/tests/fixtures ``` Usage: @@ -29,6 +31,15 @@ node ./scripts/import-typescript-eslint-scope-fixtures.ts \ pnpm test -- scope.test.ts --update ``` +Or set an environment variable: + +```bash +cd packages/plugin-rsc +TYPESCRIPT_ESLINT_SCOPE_FIXTURES_DIR=/path/to/typescript-eslint/packages/scope-manager/tests/fixtures \ + node ./scripts/import-typescript-eslint-scope-fixtures.ts +pnpm test -- scope.test.ts --update +``` + Notes: - The checked-in subtree is JS-only for stable fixture inputs in this repo. diff --git a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts index 755dd8237..2e2b01e0d 100644 --- a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts +++ b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts @@ -3,11 +3,20 @@ import path from 'node:path' import { parseArgs as parseNodeArgs } from 'node:util' import ts from 'typescript' -const defaultSourceDir = - '/home/hiroshi/code/others/typescript-eslint/packages/scope-manager/tests/fixtures' - const scriptDir = path.dirname(new URL(import.meta.url).pathname) const packageDir = path.resolve(scriptDir, '..') +const repoRoot = path.resolve(packageDir, '..', '..') +const siblingSourceHint = + '../typescript-eslint/packages/scope-manager/tests/fixtures' +const siblingSourceDir = path.resolve( + repoRoot, + '..', + 'typescript-eslint', + 'packages', + 'scope-manager', + 'tests', + 'fixtures', +) const outputDir = path.join( packageDir, 'src/transforms/fixtures/scope/typescript-eslint', @@ -39,11 +48,12 @@ async function main(): Promise { return } - const sourceDir = values.source ?? defaultSourceDir - if (!fs.existsSync(sourceDir)) { + const sourceDir = resolveSourceDir(values.source) + if (!sourceDir) { throw new Error( - `Fixture source directory does not exist: ${sourceDir}\n` + - 'Pass --source to point at a local typescript-eslint scope-manager fixture checkout.', + 'Fixture source directory is not configured.\n' + + 'Pass --source , set TYPESCRIPT_ESLINT_SCOPE_FIXTURES_DIR, or place a sibling\n' + + `typescript-eslint checkout at ${siblingSourceHint}`, ) } @@ -91,6 +101,16 @@ async function main(): Promise { ) } +function resolveSourceDir(cliSourceDir?: string): string | undefined { + const candidates = [ + cliSourceDir, + process.env['TYPESCRIPT_ESLINT_SCOPE_FIXTURES_DIR'], + siblingSourceDir, + ].filter((value): value is string => Boolean(value)) + + return candidates.find((candidate) => fs.existsSync(candidate)) +} + function printHelp(): void { console.log(`Usage: import-typescript-eslint-scope-fixtures [options] @@ -101,8 +121,10 @@ Options: -s, --source Source fixture directory -h, --help Show this help -Default source: - ${defaultSourceDir} +Source resolution order: + 1. --source + 2. TYPESCRIPT_ESLINT_SCOPE_FIXTURES_DIR + 3. sibling checkout at ${siblingSourceHint} After import, regenerate snapshots with: cd packages/plugin-rsc && pnpm test -- scope.test.ts --update From 3aaba5c97749255ad0d8178a210121d0119643b8 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:35:57 +0900 Subject: [PATCH 86/88] docs(rsc): refresh scope analysis notes Co-authored-by: Codex --- .../2026-04-04-hoist-variable-shadowing.md | 233 ++++++++++-------- .../docs/notes/2026-04-04-scope-unit-tests.md | 15 +- 2 files changed, 143 insertions(+), 105 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md index 8c3275153..6de64044f 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-hoist-variable-shadowing.md @@ -91,18 +91,110 @@ Two layered problems: that owns it — you can only ask "does ANY declaration of this name live outside?" not "does THIS specific reference resolve outside?". Shadowing is invisible. -## Interim Fix (current state) +## Current State -Replaced periscopic's `analyze()` with a custom `buildScopeTree` + `getBindVars` that -correctly unifies function params and body into one scope. This fixes the param-scope -anchor problem and makes all TODO tests pass. +Periscopic is gone. `hoist.ts` now uses a custom `buildScopeTree` + `getBindVars` +pipeline that records concrete reference identifiers and resolves each one to its +declaring `Scope`. -However, this is still the same **name-based design**: `Scope` holds -`declarations: Set`, and `findOwner(name: string)` walks up the chain by name. -The structural flaw remains — it works for the current test cases because -`buildScopeTree` now anchors correctly, but the abstraction is still wrong in principle. +This fixed the original shadowing bug. The current `ScopeTree` shape is: -## Target Design +```ts +type ScopeTree = { + readonly referenceToDeclaredScope: Map + readonly scopeToReferences: Map + readonly nodeScope: Map + readonly moduleScope: Scope +} +``` + +This is no longer the old periscopic-style name-only design. Resolution is per +identifier occurrence, not `findOwner(name: string)`. + +What is still true: + +- declarations are still stored as `Set` on each `Scope` +- reference collection still walks every `Identifier` and classifies it with + `isReferenceIdentifier(...)` +- the implementation still has known edge cases, notably default-parameter + resolution against hoisted `var` declarations in the same function body + +## Current Algorithm + +`buildScopeTree` is a two-phase algorithm: + +1. Walk the AST once to create scopes, collect declarations, and record raw + `{ id, visitScope }` reference candidates. +2. After the walk, resolve each recorded identifier by scanning upward from + `visitScope`, then propagate that identifier to `scopeToReferences` for the + visit scope and all ancestors. + +This is why the original shadowing bug is fixed now: resolution is per identifier +occurrence, and it happens only after all hoisted declarations are known. + +The main implementation trade-off is elsewhere: phase 1 still records candidates by +walking every `Identifier` and asking `isReferenceIdentifier(...)` whether that syntax +position is a real read. + +## Current Limits + +The remaining problems are no longer the original periscopic ones. + +### 1. Generic identifier classification is still brittle + +The current implementation fixes the shadowing bug, but pass 1 still asks a low-level +question: + +> given an arbitrary `Identifier`, is it a reference? + +That forces `isReferenceIdentifier` to know about many ESTree edge cases: + +- `Property`, `MethodDefinition`, `PropertyDefinition` +- import/export specifiers +- destructuring vs object literals +- parameter defaults +- `import.meta` +- labels + +As soon as the helper needs parent/grandparent context, the abstraction is already +showing strain. + +### 2. Some scope/visibility edge cases still need explicit fixups + +The current code has at least one confirmed semantic gap: + +- default parameter expressions incorrectly resolve to hoisted `var` declarations in the + same function body (`param-default-var-hoisting.js`) + +There are also lower-priority modeling gaps noted elsewhere: + +- unconditional `for` / `for-in` / `for-of` scopes +- no `StaticBlock` scope + +## Why Two Phases Still Make Sense + +Two phases are still the right high-level structure because JavaScript hoisting requires +resolution against a complete scope picture. + +Example: + +```js +function action() { + console.log({ foo }) + { + var foo = 123 + } +} +``` + +If lookup happened eagerly, `foo` would be seen before the hoisted declaration was +registered and could be misresolved to an outer scope. Deferring resolution until after +declaration collection avoids that class of bug. + +So the problem is not "two passes". The problem is specifically that the current first +pass still discovers reads by blind identifier classification. + +## Practical Direction Frame the problem as: @@ -122,7 +214,7 @@ const bindVars = [ references .filter((id) => id.name !== declName) .filter((id) => { - const scope = scopeTree.identifierScope.get(id) + const scope = scopeTree.referenceToDeclaredScope.get(id) return ( scope !== undefined && scope !== scopeTree.moduleScope && @@ -134,89 +226,39 @@ const bindVars = [ ] ``` -### Target types - -```ts -type Scope = { - readonly parent: Scope | null - // no declarations, no methods — purely an identity token with a parent link -} - -type ScopeTree = { - // each reference Identifier → the Scope that declared it (undefined = module-level) - readonly identifierScope: WeakMap - // each Scope → the direct reference Identifiers whose enclosing function scope is this - // (inverse of identifierScope, keyed by scope rather than by function node) - readonly scopeToReferences: WeakMap - // scope-creating AST node → its Scope (bridge from AST into Scope world) - readonly nodeScope: WeakMap - readonly moduleScope: Scope -} -``` - -`nodeScope` is the only entry point from AST nodes into `Scope`. After that, everything -is expressed purely in terms of `Scope` and `Identifier` — no AST node types, no strings. - -All the work is in `buildScopeTree` (two passes — see below). `getBindVars` has no logic of its own. - -## Design Smell in the Current Prototype - -The current custom implementation fixed the shadowing bug, but its internal shape still -has an avoidable smell: +This uses the current `ScopeTree` shape shown above. `nodeScope` is the entry point from +AST nodes into `Scope`; after that, `getBindVars` can stay as pure lookup over +`referenceToDeclaredScope` and `scopeToReferences`. -1. Pass 1 builds declarations and scopes. -2. Pass 2 walks the whole AST again. -3. Pass 2 decides whether each `Identifier` is a "real reference" with a generic syntax - classifier. - -That last step is the weak point. It re-derives AST-position meaning after the fact, -which forces helper logic like `isBindingIdentifier` to know about many ESTree edge -cases (`Property`, `MethodDefinition`, import/export specifiers, destructuring, etc.). -As soon as the helper needs parent/grandparent context, the abstraction is already -telling us it is too low-level. - -Two passes are **inherently required** by JavaScript's hoisting semantics. A `var` -declaration or function declaration may appear textually _after_ a reference to the same -name in the same function: - -```js -function action() { - console.log({ foo }) // reference — var foo not seen yet - { - var foo = 123 // hoisted to action's function scope - } -} -``` - -A single-pass resolver would see `foo` before `var foo` is recorded, scan upward, and -incorrectly attribute it to an outer binding. Pass 1 must collect all declarations first -so that pass 2 can resolve every reference against the complete, frozen scope picture. +Keep the good part: -The problem is not "two passes" by itself — that is correct and necessary. The smell is -"walk every `Identifier` in pass 2 and classify it generically". +- declarations are collected before resolution +- references are resolved per identifier occurrence, not by name string -## Proposed New Shape +The practical maintenance goal is: -Keep the good part: +- keep the current two-phase `buildScopeTree` shape +- keep `isReferenceIdentifier` close to Vite SSR's `isRefIdentifier` +- document local divergences explicitly when ESTree-walker / fixture coverage requires them +- add fixtures for concrete edge cases instead of jumping to a larger architectural rewrite -- pass 1 builds the scope tree and records declarations +This keeps the implementation easy to compare against a well-known upstream reference, +which is currently more valuable than pursuing a larger refactor. -Replace the brittle part: +## Alternative, Probably Overkill -- pass 2 should not walk every `Identifier` -- pass 2 should walk only expression/reference-bearing child positions -- pass 2 should resolve references immediately when visiting those positions +An alternative design would avoid the global identifier classifier entirely. -In other words, instead of asking: +Instead of asking: > "given an arbitrary `Identifier`, is it a reference?" -ask: +it would ask: > "for this AST node, which child nodes are read positions?" -That moves the complexity from a global classifier to local per-node traversal rules, -which is easier to reason about and matches how closure capture actually works. +That may be cleaner in the abstract, but it is a meaningfully larger refactor and is +not the recommended next step right now. ### Sketch @@ -234,10 +276,10 @@ function collectReferences(ast: Program, scopeTree: ScopeTree): void { } ``` -`getBindVars` stays the same shape as the target design above: pure lookup over -`scopeToReferences` and `identifierScope`. +`getBindVars` would stay the same shape as the current design above: pure lookup over +`scopeToReferences` and `referenceToDeclaredScope`. -## Why This Is Simpler +## Why This Might Be Simpler ### No global identifier classifier @@ -268,7 +310,7 @@ It needs: That is a narrower and more maintainable target. -## Concrete Pass-2 Rules +## If We Ever Do It Pass 2 should be a reference visitor over expression positions, not a blind AST scan. Representative rules: @@ -307,19 +349,6 @@ Representative rules: This is not a full ESTree spec list yet. It is the shape we want: explicit read positions, explicit declaration positions. -## Migration Plan - -1. Keep the current `Scope` / `ScopeTree` data model. -2. Leave pass 1 mostly as-is, since it already fixes the original shadowing bug. -3. Replace the generic pass-2 `Identifier` walk with a dedicated reference visitor. -4. Delete `isBindingIdentifier` once pass 2 no longer depends on it. -5. Add focused tests for syntax that previously depended on classifier edge cases: - - class methods and fields - - object literal vs object pattern - - import/export specifiers - - destructured params - - computed keys - ## Decision Do not over-index on "one pass vs two passes". The better boundary is: @@ -327,8 +356,14 @@ Do not over-index on "one pass vs two passes". The better boundary is: - pass 1 answers "what names exist in which scopes?" - pass 2 answers "which reads occur, and what do they resolve to?" -That split is coherent. The current prototype's problem is that pass 2 still asks a more -primitive question than it really needs to. +That split is coherent. The current implementation's weak point is not the existence of +two phases, but the number of syntax edge cases handled by `isReferenceIdentifier`. + +For now, the preferred approach is pragmatic: + +- stay aligned with Vite SSR's reference classifier where possible +- make local divergences explicit in comments and fixtures +- fix concrete semantic bugs without expanding the design surface unnecessarily ## Reference Repos @@ -348,7 +383,7 @@ subset whose owner is strictly between the action and the module root. `parseAstAsync`. `walk()` accepts a pre-parsed AST directly. **Relevant helper:** `src/scope-tracker.ts:isBindingIdentifier`. Our local -`isReferenceId` should stay aligned with its inverse. The concrete gaps found during the +`isReferenceIdentifier` should stay aligned with its inverse. The concrete gaps found during the comparison were: - `MethodDefinition` and `PropertyDefinition`: non-computed keys are bindings, not diff --git a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md index a8eef33e3..65c3efb3f 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md +++ b/packages/plugin-rsc/docs/notes/2026-04-04-scope-unit-tests.md @@ -83,7 +83,7 @@ function outer() { } ``` -`shadowing-block.js.snap`: +`shadowing-block.js.snap.json`: ```json { @@ -92,7 +92,7 @@ function outer() { "references": [], "children": [ { - "type": "Function:outer", + "type": "FunctionDeclaration:outer", "declarations": [], "references": [], "children": [ @@ -102,7 +102,7 @@ function outer() { "references": [], "children": [ { - "type": "Function:action", + "type": "FunctionDeclaration:action", "declarations": [], "references": [], "children": [ @@ -117,7 +117,7 @@ function outer() { "references": [ { "name": "value", - "resolvedIn": "Program > Function:outer > BlockStatement > Function:action > BlockStatement > BlockStatement" + "declaredAt": "Program > FunctionDeclaration:outer > BlockStatement > FunctionDeclaration:action > BlockStatement > BlockStatement" } ], "children": [] @@ -134,7 +134,7 @@ function outer() { } ``` -The `resolvedIn` path is built from scope-creating node labels (function names where +The `declaredAt` path is built from scope-creating node labels (function names where available), disambiguated with `[2]` suffixes for same-type siblings. `null` means the identifier is global (not declared anywhere in the file). @@ -143,11 +143,14 @@ available), disambiguated with `[2]` suffixes for same-type siblings. - `export-specifier.js` — `export {foo as bar}`: `foo` IS resolved, `bar` is NOT - `label.js` — label in `break`/`continue` NOT a ref - `shadowing-block.js` — the motivating bug from the migration notes +- `import-meta.js` — `import` / `meta` in `import.meta` are NOT refs +- `param-default-var-hoisting.js` — documents the current default-param + hoisted-`var` + misresolution as a known gap ### 3. Verify `hoist.test.ts` still passes after the extraction ## Non-goals - Do not change behaviour of `buildScopeTree` in this task. -- Do not implement the pass-2 refactor (replacing `isBindingIdentifier` with explicit +- Do not implement the pass-2 refactor (replacing `isReferenceIdentifier` with explicit reference visitor) — that is a separate follow-up described in the migration plan. From 1f9cc70991242053b07f2ff296d1963321d948eb Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:38:08 +0900 Subject: [PATCH 87/88] chore: reviewed slop --- packages/plugin-rsc/src/transforms/scope.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/plugin-rsc/src/transforms/scope.ts b/packages/plugin-rsc/src/transforms/scope.ts index 6e595a73a..9f57de21d 100644 --- a/packages/plugin-rsc/src/transforms/scope.ts +++ b/packages/plugin-rsc/src/transforms/scope.ts @@ -198,7 +198,6 @@ function isFunctionNode(node: Node): node is AnyFunctionNode { ) } -// TODO: review slop // Positive reference classifier modeled after Vite SSR's `isRefIdentifier`, // adapted for this ESTree-only scope walk. This is easier to audit than a // negated binding check because many identifier positions are syntax-only names From a8a11d2eb7f66315491df7c5a5e928e299b7b54e Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sun, 5 Apr 2026 10:42:02 +0900 Subject: [PATCH 88/88] docs(plugin-rsc): fill in comparison table in scope manager research note Co-Authored-By: Claude Sonnet 4.6 --- .../2026-04-05-scope-manager-research.md | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md b/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md index b9327852c..fd81ad842 100644 --- a/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md +++ b/packages/plugin-rsc/docs/notes/2026-04-05-scope-manager-research.md @@ -105,20 +105,18 @@ A server action function parameter that is never referenced in the body is still ## Comparison table -> TODO — fill in once individual documents are complete. - -| | periscopic | vite-ssr | eslint-scope | babel-traverse | oxc_semantic | oxc-walker | next.js | typescript-eslint | **ours** | -| ---------------------- | ----------------- | ---------------- | --------------------------- | -------------- | ------------ | ------------ | ------- | --------------------------- | ----------------------- | -| AST format | ESTree | ESTree | ESTree | Babel AST | oxc AST | ESTree (oxc) | ? | TSESTree | ESTree | -| Language | JS | TS | JS | JS | Rust | TS | ? | TS | TS | -| Variable object | no | no | yes | yes (Binding) | yes (Symbol) | no | ? | yes | no | -| Read/write flag | no | no | yes | yes | yes | no | ? | yes | no | -| Resolution timing | single-pass (bug) | two-pass | close-time | close-time | ? | two-pass | ? | close-time | post-walk | -| Refs aggregated upward | no | no | no (through[]) | no | no | no | ? | no (through[]) | yes (scopeToReferences) | -| `var` hoisting | buggy | yes | yes | yes | yes | yes | ? | yes | yes | -| Named fn-expr scope | name in fn scope | name in fn scope | FunctionExpressionNameScope | ? | ? | ? | ? | FunctionExpressionNameScope | name in fn scope | -| Class scope | none | named-expr only | ClassScope (always) | ? | ? | ? | ? | ClassScope (always) | named-expr only | -| TypeScript support | no | no | no | yes | yes | partial | ? | yes | no | +| | periscopic | vite-ssr | eslint-scope | babel-traverse | oxc_semantic | oxc-walker | next.js | typescript-eslint | **ours** | +| ---------------------- | ----------------- | ---------------- | --------------------------- | ------------------- | -------------------- | --------------------- | ----------------- | --------------------------- | ----------------------- | +| AST format | ESTree | ESTree | ESTree | Babel AST | oxc AST | ESTree (oxc) | SWC AST | TSESTree | ESTree | +| Language | JS | TS | JS | JS | Rust | TS | Rust | TS | TS | +| Variable object | no | no | yes | yes (Binding) | yes (Symbol, SoA) | no | no | yes | no | +| Read/write flag | no | no | yes | yes | yes (ReferenceFlags) | no | no | yes | no | +| Resolution timing | single-pass (bug) | two-pass | close-time | close-time (lazy) | post-walk | two-pass | two-phase flat | close-time | post-walk | +| Refs aggregated upward | no | no | no (through[]) | no | no | no | no | no (through[]) | yes (scopeToReferences) | +| `var` hoisting | buggy | yes | yes | yes | yes | no (documented gap) | implicit (SWC) | yes | yes | +| Named fn-expr scope | name in fn scope | name in fn scope | FunctionExpressionNameScope | name in fn scope | name in fn scope | two scopes (outer+fn) | N/A (SWC hygiene) | FunctionExpressionNameScope | name in fn scope | +| Class scope | none | named-expr only | ClassScope (always) | ClassScope (always) | ClassScope (always) | scope for name only | not modeled | ClassScope (always) | named-expr only | +| TypeScript support | no | no | no | yes (Babel plugins) | yes | partial | yes (SWC) | yes | no | ## Related notes