Add a rule for detecting static access inside of @spina-wrapped classes.

Review Request #14640 — Created Oct. 17, 2025 and updated

Information

beanbag-eslint-plugin
master

Reviewers

We discovered a confusing bug 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. 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.constructor or this as appropriate.

  • Ran unit tests.
  • Saw that this correctly flagged the issue, and that asking my LSP to
    apply the fix worked correctly.
Summary ID
Add a rule for detecting static access inside of @spina-wrapped classes.
We discovered a confusing bug 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. 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.constructor` or `this` as appropriate. Testing Done: - Ran unit tests. - Saw that this correctly flagged the issue, and that asking my LSP to apply the fix worked correctly.
qmuowmxvvkztmqtsppskqtrpstqsoyll
Description From Last Updated

Can you add any necessary Version Added/Changed docs as appropriate in here, so we can better track changes?

chipx86chipx86

Use the function form of "use strict". Column: 1 Error code: W097

reviewbotreviewbot

'require' is not defined. Column: 24 Error code: W117

reviewbotreviewbot

'require' is not defined. Column: 14 Error code: W117

reviewbotreviewbot

'describe' is not defined. Column: 23 Error code: W117

reviewbotreviewbot

'it' is not defined. Column: 17 Error code: W117

reviewbotreviewbot

'require' is not defined. Column: 17 Error code: W117

reviewbotreviewbot

'describe' is not defined. Column: 1 Error code: W117

reviewbotreviewbot

There's a comment on the parent change here, but so it doesn't get lost in this: Blank line between bullet …

chipx86chipx86
Checks run (1 failed, 1 succeeded)
flake8 passed.
JSHint failed.

JSHint

david
david
david
david
maubin
  1. Ship It!
  2. 
      
david
maubin
  1. Ship It!
  2. 
      
chipx86
  1. Very nice change.

  2. Show all issues

    Can you add any necessary Version Added/Changed docs as appropriate in here, so we can better track changes?

  3. NEWS.md (Diff revision 5)
     
     
     
     
     
     
     
     
    Show all issues

    There's a comment on the parent change here, but so it doesn't get lost in this:

    1. Blank line between bullet points.
    2. Two blank lines before the next section header.
  4. 
      
david
Review request changed
Commits:
Summary ID
Add a rule for detecting static access inside of @spina-wrapped classes.
We discovered a confusing bug 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. 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.constructor` or `this` as appropriate. Testing Done: - Ran unit tests. - Saw that this correctly flagged the issue, and that asking my LSP to apply the fix worked correctly.
qxotmtlxowuzsvmxtoprplmnukvnzmxn
Add a rule for detecting static access inside of @spina-wrapped classes.
We discovered a confusing bug 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. 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.constructor` or `this` as appropriate. Testing Done: - Ran unit tests. - Saw that this correctly flagged the issue, and that asking my LSP to apply the fix worked correctly.
qmuowmxvvkztmqtsppskqtrpstqsoyll

Checks run (2 succeeded)

flake8 passed.
JSHint passed.