Add a rule for detecting static access inside of @spina-wrapped classes.
Review Request #14640 — Created Oct. 17, 2025 and updated — Latest diff uploaded
We discovered a confusing bug last night where accessing static members
within a class that was wrapped with the@spina
decorator would end up
getting members on the inner class rather than the wrapper. This caused
an issue with tests where the tests were setting a static attribute on
the wrapper, and the inner class had a different value.The fix is a surprising, unintuitive change to use
this.constructor
for any static accesses within the class itself. Because this is
something I'll immediately forget, I wanted to have an eslint rule to
detect this situation in the future.This change adds the new rule. It specifically only operates on classes
decorated with@spina
(at least for now). It will detect static member
accesses within member functions and static functions (although inside
static functions we can't do anything about it). It also includes a
fixer that will add thedeclare ['constructor']
line to the beginning
of the class (if it's not already present) and then replace said
accesses withthis.constructor
.
- Ran unit tests.
- Saw that this correctly flagged the issue, and that asking my LSP to
apply the fix worked correctly.