Pass this function as a default argument to throw an error when the argument is undefined
const required = require('required-argument');
function myFunc(a = required()){
// do stuff
}
myFunc(); // Error: Missing argument in function "myfunc"
I'm experimenting with parsing the code to let you know which argument is missing but it's still not perfect yet. If you have any ideas on how to implement that or any other things you'd like to add please open an issue or PR.
Inspired by Six nifty ES6 tricks by @rauschma