Some browser APIs (eg., AudioContext
) require to be called after a user gesture, ie., must have the respective event handler in their call stack. This is generally difficult to ensure through unit testing alone.
Makes me wonder if there are any static analysis tools for Typescript or Javascript that would be able to enforce this? Basically, finding all possible stack traces leading up to a sensitive browser API. And then to make sure they all start at a user gesture's event handler.
Does something like that exist?
question from:
https://stackoverflow.com/questions/65838936/linter-for-stack-discipline-of-sensitive-browser-apis 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…