id: ux-async-onclick-no-disable
language: tsx
severity: error
message: async onClick on a <button> with no disabled state — double-submit / silent wait
note: '{"severity":"high","category":"convention","resolution":"Disable the trigger while the promise is in flight (disabled={pending}) and show an inline loading indicator. Prevents double-submit and ghost interactions (ANTI-SLOP UX §3/§12)."}'
rule:
  any:
    - all:
        - kind: jsx_opening_element
        - has: { field: name, regex: '^button$' }
        - has: { kind: jsx_attribute, regex: 'onClick=\{\s*async' }
        - not: { has: { kind: jsx_attribute, regex: '^disabled' } }
    - all:
        - kind: jsx_self_closing_element
        - has: { field: name, regex: '^button$' }
        - has: { kind: jsx_attribute, regex: 'onClick=\{\s*async' }
        - not: { has: { kind: jsx_attribute, regex: '^disabled' } }
