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 · 4mo agoSince 2019v4.0.3MIT

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

Languages

View on GitHub →
JavaScript100%

Commit activity

Last 12 weeks · 0 commits

Full graph →

Community health

2 of 6 standards met

Community profile →
42
✓README✓License○Contributing○Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Quiet · 1 in progress · Last activity 4mo ago
See all on GitHub →
hi-ogawa
Named class expression bindings are reported as globalsOpenIssue

Have discovered a minor scope bug while testing the integrations on . Also brought up while integrating for Vite's static analysis in https://github.com/vitejs/vite/pull/22850. A following is a AI-assisted write-up: Periscopic 4.0.3 reports the binding identifier of a named as global, even when the class contains no references. It also does not create a scope for the class's self-binding, so references inside the class are reported as global instead of resolving to that binding. Reproduction: https://stackblitz.com/edit/stackblitz-starters-7wcyuezb?file=index.mjs The bare case contains no reference to . Its only identifier is the class name, which is a binding position. Periscopic nevertheless collects that identifier as a reference and reports it as global because there is no declaration owner. The method case contains an actual reference. JavaScript resolves it to the named class expression's inner binding, which is visible within the class and does not leak into the enclosing scope. Periscopic instead reports it as global because it creates no scope containing that binding.

hi-ogawa · 1mo ago
knightedcodemonkey
fix(analyze): restore scope after export-from declarations.OpenPR

fixes #30

knightedcodemonkey · 2mo 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 · 2mo 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 · 4mo ago
remcohaszing
remove package-lock.jsonMergedPR

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

remcohaszing · 4mo ago
Rich-Harris
fix publish configMergedPR
Rich-Harris · 4mo 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. Languages: JavaScript (100%). License: MIT. Latest release: v4.0.3 (4mo ago). Open PRs: 1, open issues: 5. Last activity: 4mo ago. Community health: 42%. Top contributors: Rich-Harris, mrkishi, tanhauhau, ChristianMurphy, benmccann, remcohaszing, milton-alvarenga, dependabot[bot], theoludwig, github-actions[bot].

·@ofershap

Replace github.com with gitshow.dev