GitShow/Rich-Harris/periscopic
Rich-Harris

periscopic

Utility for analyzing scopes belonging to an ESTree-compliant AST

by Rich-Harris
Star on GitHubForknpm

JavaScript

108 stars10 forks10 contributorsQuiet · 2mo agoSince 2019MIT

Meet the team

See all 10 on GitHub →
Rich-Harris
Rich-Harris69 contributions
mrkishi
mrkishi6 contributions
tanhauhau
tanhauhau6 contributions
ChristianMurphy
ChristianMurphy3 contributions
benmccann
benmccann2 contributions
remcohaszing
remcohaszing2 contributions
milton-alvarenga
milton-alvarenga2 contributions
dependabot[bot]Bot
dependabot[bot]1 contribution

Recent PRs & issues

Quiet · 1 in progress · Last activity 2mo ago
See all on GitHub →
knightedcodemonkey
fix(analyze): restore scope after export-from declarations.OpenPR

fixes #30

knightedcodemonkey · 1mo ago
knightedcodemonkey
Scope is not restored after ExportNamedDeclaration with source, causing later top-level declarations to be recorded on the export child scopeOpenIssue

While using analyze in periscopic 4.0.3, the ExportNamedDeclaration path for re-exports creates a child scope and returns early. That early return skips the shared unwind step that restores current_scope to its parent. Result: declarations that come after a re-export at module top level are recorded on the export-created child scope instead of the root scope. Minimal reproduction Using acorn + periscopic: Expected Declarations after the re-export should belong to module root scope (or at least be discoverable from rootScope.find_owner). Actual Declarations after the re-export are attached to the export-created child scope, and rootScope.find_owner for those names returns null. Why this seems to happen In the ExportNamedDeclaration with source branch, current_scope is advanced to a new Scope and the branch returns before the shared unwind logic runs (the context.next + parent restore block). That leaves current_scope on the child for subsequent traversal. Impact Consumers that rely on exact ownership scope identity (not just upward lookup from the current active child) can misclassify bindings declared after re-exports. Potential fix Keep the no-descend behavior for re-export specifiers, but restore current_scope before returning in that branch (or refactor so that branch still executes the shared unwind step).

knightedcodemonkey · 1mo ago
remcohaszing
Add function to only expose only top-level declarationsOpenIssue

I have some use cases where I need to know the variables available in the body, but I’m not interested in any nested scopes. It would be nice if could take an option to skip checking nested scopes.

remcohaszing · 2y ago

Recent fixes

View closed PRs →
remcohaszing
handle ImportDefaultSpecifier nodesMergedPR

A default import declares a variable. Tests were added for various ESM node types.

remcohaszing · 2mo ago
remcohaszing
remove package-lock.jsonMergedPR

The package-lock.json file in the repo was outdated. Also the project now uses pnpm.

remcohaszing · 2mo ago
Rich-Harris
fix publish configMergedPR
Rich-Harris · 2mo ago
Structured data for AI agents

Repository: Rich-Harris/periscopic. Description: Utility for analyzing scopes belonging to an ESTree-compliant AST Stars: 108, Forks: 10. Primary language: JavaScript. License: MIT. Open PRs: 1, open issues: 4. Last activity: 2mo ago. Top contributors: Rich-Harris, mrkishi, tanhauhau, ChristianMurphy, benmccann, remcohaszing, milton-alvarenga, dependabot[bot], theoludwig, github-actions[bot].

·@ofershap

Replace github.com with gitshow.dev