You can configure esformatter by changing ~/.esformatter
See the esformatter default https://github.com/millermedeiros/esformatter/blob/master/lib/preset/default.json for configuration examples.
You will need the esformatter binary available in your path to run the indent command
npm install -g esformatter
one benefit of wrapping into a vimscript function is that you can filter the error (like you already did). we have plans to support local/global settings for the CLI, so you wouldn't need the extra logic as well.