The problem is running, possibly untrusted, code in isolation from the host in a convenient way. "Convenient way" is, of course, very subjective: in my case, it is doing as much as possible from the IDE (IntelliJ Idea). As a result, this means sandboxing graphical applications, and I'm not aware of a way to run a graphical application in a Linux container on MacOS.
IntelliJ has access to all downloaded packages (to provide autocompletion, etc.) and run npm/yarn/whatever's scripts/actions. This IDE has a lot of customized support for specific tools, which I find valuable, and wrapping everything in a shell script delegating work to a container means losing this support. At the same time, running IntelliJ as a native application, I'm able to open an embedded terminal and enumerate files in my home folder (with exceptions, like Documents and Downloads, but I'm not able to isolate projects from each other). I'm trying to keep all fancy stuff but isolate different projects from the host and each other.
As for yarn: npm is only an example. The same problem affects almost every package manager. NodeJS ecosystem is convenient here because nearly everybody has heard of some malicious JS package.