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 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 the declare ['constructor'] line to the beginning
of the class (if it's not already present) and then replace said
accesses with this.constructor.

  • 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 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 the `declare ['constructor']` line to the beginning of the class (if it's not already present) and then replace said accesses with `this.constructor`. Testing Done: - Ran unit tests. - Saw that this correctly flagged the issue, and that asking my LSP to apply the fix worked correctly.
qxotmtlxowuzsvmxtoprplmnukvnzmxn
Description From Last Updated

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
Checks run (1 failed, 1 succeeded)
flake8 passed.
JSHint failed.

JSHint

david
Review request changed
Commits:
Summary ID
Add a rule for detecting static access inside of @spina-wrapped classes.
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 the `declare ['constructor']` line to the beginning of the class (if it's not already present) and then replace said accesses with `this.constructor`. 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 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 the `declare ['constructor']` line to the beginning of the class (if it's not already present) and then replace said accesses with `this.constructor`. Testing Done: - Ran unit tests. - Saw that this correctly flagged the issue, and that asking my LSP to apply the fix worked correctly.
qxotmtlxowuzsvmxtoprplmnukvnzmxn

Checks run (2 succeeded)

flake8 passed.
JSHint passed.