Files
opencode/script/ast-grep/gui-plugins/rules/no-module-state-tsx.yml

32 lines
1.1 KiB
YAML

id: gui-plugin-no-module-state-tsx
language: tsx
severity: error
message: GUI plugins keep state in ctx, Storage, or setup closures, never at module level.
note: Module state survives disable and reload and leaks across windows. Create it inside setup or a component.
files:
- "packages/gui-plugins/src/*/**/*.tsx"
rule:
all:
- any:
- pattern: let $A = $$$B
- pattern: let $A
- pattern: const $A = new Map($$$B)
- pattern: const $A = new Map<$$$T>($$$B)
- pattern: const $A = new Set($$$B)
- pattern: const $A = new Set<$$$T>($$$B)
- pattern: const $A = new WeakMap($$$B)
- pattern: const $A = new WeakMap<$$$T>($$$B)
- pattern: const $A = new WeakSet($$$B)
- pattern: const $A = new WeakSet<$$$T>($$$B)
- pattern: const $A = createStore($$$B)
- pattern: const $A = createStore<$$$T>($$$B)
- pattern: const $A = createSignal($$$B)
- pattern: const $A = createSignal<$$$T>($$$B)
- any:
- inside:
kind: program
- inside:
kind: export_statement
inside:
kind: program