JSON doesn't support comments


JSON doesn't support comments.

So here's how I comment npm scripts in package.json. 😎

#javascript #npm

Many said “Use a Readme”.

Why I prefer inline comments:

1. It’s natural to read comments above the item being documented

2. Easily discoverable. Don’t need to find docs in a separate file.

3. More likely to stay updated

Yes, this is a hack.

But the benefit > cost.
Also, I don’t recommend commenting every script. Ideally many scripts are simple and well-named, so a comment isn’t necessary. My example is deiberately simple to convey the pattern. I use this approach for complex scripts, when a name alone isn’t sufficient.

View original on X