You have to have some expectations and understandings of what the PKGBUILD for the package should be doing and look for something out of the ordinary. The upstream repo will usually have packaging instructions in its readme or wiki which should be reflected in the PKGBUILD.
In the case of the last incident, the attacker was adding npm as a dependency so they could execute npm install atomic-lockfile, which was the actual attack. That was a huge red flag because most of the packages had nothing to do with JavaScript.