benjamn / benjamn/ast-types

Warn if new properties are added to PathVisitor Context instances by visit methods

Open
#52 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

Every `PathVisitor` instance has a class `visitor.Context` such that `Object.getPrototypeOf(visitor.Context.prototype) === visitor`, and the value of `this` within visitor methods is an instance of this `Context` class.

This means that any properties accidentally added to `this` during the visitor method will be thrown away (or become inaccessible) from other visitor methods, probably indicating a bug.

It should be easy to warn about this by checking `Object.keys(context)` after calling the visitor method in `context.invokeVisitorMethod`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.