I have changed a few things in how I add comments to package.json. Here is an example of the new convention I am following:
{"@comment dependencies":["These are the comments for the `dependencies` section.","The name of the section being commented is included in the key after the `@comment` 'annotation' to ensure the keys are unique.","That is, using just \"@comment\" would not be sufficient if you need to add another comment at the same level.","Because JSON doesn't allow a multiline string or understand a line continuation operator, just use an array for each line of the comment.","Since this is embedded in JSON, the keys should be unique.","Otherwise JSON validators, such as ones built into IDE's, will complain.","Or some tools, such as running `npm install something --save`, will rewrite the `package.json` file but with duplicate keys removed.","The section below is an object with properties where each property matches the NPM package's name.","The comment about the package is the value of the property. This property may be a single string or an array of strings.",{"react":"Comment about this package."}],"dependencies":{...},"@comment scripts":{"build: [
"Thiscommentisaboutthebuildscript.Itmaybeastringoranyarrayofstrings.",
"Intheoldconvention,thecommentwaswithin`scripts`,nexttothescriptitappliedto.",
"Inthisnewconvention,itisinitsownsection.",
"Thiswasdonesothatthecommentsdon'tappearasascripttoatoolthatreadsthe`scripts`section."
],
"start": [
"Thiscommentisaboutthe`start`script.",
"Itiswrappedinanarraytoallowlineformatting.",
"",
"@option{number}--port-Theporttheservershouldlistenon."
],
},
"scripts": {
"build": "...",
"start": "...",
"test": "..."
}
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have changed a few things in how I add comments to package.json. Here is an example of the new convention I am following: