Strip comments before parsing JSON config files #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also contains minor tweaks to analyzeArgv() and adds comments to the JSON files under test/fixtures/analyzeArgv. Added a new "Development" section to README.md including instructions on configuring Vim, Visual Studio Code, and IntelliJ IDEA to recognize JSON comments.
From the function comment for the new stripJsonComments():
Replaces rather than removes characters so that any JSON.parse() errors line up with the original. Preserves all existing whitespace as is, including newlines, carriage returns, and horizontal tabs.
This function is necessary because the
jsdoc
command depends upon the extremely popular strip-json-comments npm. Otherwise analyzeArgs() would choke on config.json files containing comments.This implementation was inspired by strip-json-comments, but is a completely original implementation to avoid adding any dependencies. It may become its own separate package one day, likely scoped to avoid conflicts with strip-json-comments.