How to make user friendly build error messages?

Hello, I had a question about build log errors and something I saw in this post :

Don’t name your build command build

Does this mean we shouldn’t be doing npm run build to do builds? I was wondering since I wanted to have an ESLint and Prettier check and fail if code is not formatted properly. It currently looks like this:

"build": "npm run format:check && gatsby build"

This currently works, but the message is buried inside the rest of the npm error logs and is not easy to find for someone new who is doing a pull request on my project and checking the log.

Is there a better way to pretty print error messages so that stand out? I have tried doing multi-line echo calls by doing something like this (simplified):

"format:check": "prettier --check || echo Have you formatted your code? Try running \n echo '   npm run format'"

This works for the most part, but the error message will appear during the initial call of the script, and a second time when it actually happens, and that can be confusing.

What is the best way to approach build log error messages?

@chris-tse, for the question about having a script in package.json named build, this is okay to do and it won’t cause a problem. The problem only occurs when there is a file (like a bash script) with the filename “build”.

A script named “build” in package.json will work correctly.

Regarding how best to pretty print error messages in this scenario, that I don’t know myself and I’m hoping someone else will have a good answer.