Add a rule for detecting static access inside of @spina-wrapped classes.
Review Request #14640 — Created Oct. 17, 2025 and updated
We discovered a confusing bug where accessing static members within a
class that was wrapped with the@spinadecorator 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. It also includes
a fixer that will add thedeclare ['constructor']line to the
beginning of the class (if it's needed and not already present) and then
replace said accesses withthis.constructororthisas appropriate.
- Ran unit tests.
- Saw that this correctly flagged the issue, and that asking my LSP to
apply the fix worked correctly.
| Summary | ID |
|---|---|
| qmuowmxvvkztmqtsppskqtrpstqsoyll |
| Description | From | Last Updated |
|---|---|---|
|
Can you add any necessary Version Added/Changed docs as appropriate in here, so we can better track changes? |
|
|
|
Use the function form of "use strict". Column: 1 Error code: W097 |
|
|
|
'require' is not defined. Column: 24 Error code: W117 |
|
|
|
'require' is not defined. Column: 14 Error code: W117 |
|
|
|
'describe' is not defined. Column: 23 Error code: W117 |
|
|
|
'it' is not defined. Column: 17 Error code: W117 |
|
|
|
'require' is not defined. Column: 17 Error code: W117 |
|
|
|
'describe' is not defined. Column: 1 Error code: W117 |
|
|
|
There's a comment on the parent change here, but so it doesn't get lost in this: Blank line between bullet … |
|
- Commits:
-
Summary ID qxotmtlxowuzsvmxtoprplmnukvnzmxn qxotmtlxowuzsvmxtoprplmnukvnzmxn
Checks run (2 succeeded)
- Change Summary:
-
Split into two rules so the static-method case can be a suggestion and the regular method case can be a problem.
- Commits:
-
Summary ID qxotmtlxowuzsvmxtoprplmnukvnzmxn qxotmtlxowuzsvmxtoprplmnukvnzmxn
Checks run (2 succeeded)
- Description:
-
We discovered a confusing bug last night where accessing static members
within a class that was wrapped with the @spinadecorator would end upgetting 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.constructorfor 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 the declare ['constructor']line to the beginning~ of the class (if it's not already present) and then replace said ~ accesses within member functions and static functions. It also includes ~ a fixer that will add the declare ['constructor']line to the~ beginning of the class (if it's needed and not already present) and then ~ replace said accesses with this.constructororthisas appropriate.- accesses with this.constructor. - Commits:
-
Summary ID qxotmtlxowuzsvmxtoprplmnukvnzmxn qxotmtlxowuzsvmxtoprplmnukvnzmxn
Checks run (2 succeeded)
- Description:
-
~ We discovered a confusing bug last night where accessing static members
~ within a class that was wrapped with the @spinadecorator 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. ~ We discovered a confusing bug where accessing static members within a
~ class that was wrapped with the @spinadecorator 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.constructorfor 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 memberaccesses within member functions and static functions. It also includes a fixer that will add the declare ['constructor']line to thebeginning of the class (if it's needed and not already present) and then replace said accesses with this.constructororthisas appropriate.
- Change Summary:
-
- Update for new plugin layout changes.
- Fix the fixer to detect surrounding indentation instead of assuming 4 spaces.
- Commits:
-
Summary ID qxotmtlxowuzsvmxtoprplmnukvnzmxn qxotmtlxowuzsvmxtoprplmnukvnzmxn