summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_transport_contracts.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_transport_contracts.py')
-rw-r--r--packages/meshbay-hub/tests/test_transport_contracts.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/meshbay-hub/tests/test_transport_contracts.py b/packages/meshbay-hub/tests/test_transport_contracts.py
index fb92fcd..8d975d7 100644
--- a/packages/meshbay-hub/tests/test_transport_contracts.py
+++ b/packages/meshbay-hub/tests/test_transport_contracts.py
@@ -187,8 +187,14 @@ def test_no_setter_survives_the_state_it_belonged_to(app):
# to their object, not to this component.
called = set(re.findall(r"(?<![.\w])(set[A-Z]\w*)\s*\(", app))
builtin = {"setTimeout", "setInterval"}
+ # A `setX` that is a plain function of this module is not an orphan setter:
+ # `setAuth` writes the session to localStorage and has no `useState` behind
+ # it by design. Without this the rule reports every such helper, and a rule
+ # that cries wolf is one someone eventually silences.
+ defined = set(re.findall(r"^(?:async\s+)?function\s+(set[A-Z]\w*)\s*\(", app, re.M))
+ defined |= set(re.findall(r"^\s*const\s+(set[A-Z]\w*)\s*=", app, re.M))
- orphans = sorted(called - declared - imported - builtin)
+ orphans = sorted(called - declared - imported - builtin - defined)
assert not orphans, (
f"setter(s) called with no useState behind them: {orphans} — "
"each one is a ReferenceError the moment that code path runs")