Closed tobysmith568 closed 1 year ago
The lack of comments in JSON is truly annoying.
I'm not that familiar with JSON5. How much more does it bring in, beyond "JSON with comments"? I'd hate to see major-version breakages in Licensee because something happened down in the parser.
Yeah I appreciate the concern. I think this snippet from their readme sells it best:
Formally, the JSON5 Data Interchange Format is a superset of JSON (so valid JSON files will always be valid JSON5 files) that expands its syntax to include some productions from ECMAScript 5.1 (ES5). It's also a strict subset of ES5, so valid JSON5 files will always be valid ES5.
In practice it means your json files (when parsed with JSON5) can:
The package is for sure stable, and they're purposefully not adding in new features because they're specifically sticking to ES5. Other nice points:
Some sticking points of the json5 syntax:
.json
file extension then your IDE/Code editor will still lint the file with syntax errors if it contains JSON5 syntaxes - e.g. comments all get red underlines.
.json5
file extension. If the syntax errors in IDEs/Code editors bother people, they can:./.vscode/settings.json
file).json5
file extension (this would obviously require Licensee to look for both .licensee.json
and .licensee.json5
)Hmm. Why not define a licenses
script in package.json
like json5 < .licensee.json5 > .licensee.json && licensee
, then add .licensee.json
to .gitignore
?
While I appreciate that this would work, it's not quite the seamless experience I was hoping to achieve.
Perhaps it's just me, but whenever I experiment with a new tool I usually have a "Does their JSON parser support comments?" thought process - and it's always a nice win when it does.
Licensee does just one thing, and tries to do it well. I'm personally motivated to keep maintaining for that mission, but not to chase the latest in plushness or polish.
If other want to do what Licensee does, but integrate into other systems or experiment with user experiences, the package also exports a module.
Nothing should support json5, or any other format, until node natively supports it, even if it's better.
Hey :)
Would you be open to the idea of parsing the
.licensee.json
file using something like json5 so that the file can contain comments?After having a brief look over the repository, it seems that it could perhaps be a drop-in replacement on line 105 of /licensee with the only changes being:
const JSON5 = require('json5');
JSON.parse(data)
toJSON5.parse(data)
.Thanks for your consideration