jslicense / licensee.js

check dependency licenses against rules
https://www.npmjs.com/package/licensee
Apache License 2.0
185 stars 23 forks source link

Comments in the .license.json file #89

Closed tobysmith568 closed 1 year ago

tobysmith568 commented 1 year ago

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:

Thanks for your consideration

kemitchell commented 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.

tobysmith568 commented 1 year ago

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:

kemitchell commented 1 year ago

Hmm. Why not define a licenses script in package.json like json5 < .licensee.json5 > .licensee.json && licensee, then add .licensee.json to .gitignore?

tobysmith568 commented 1 year ago

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.

kemitchell commented 1 year ago

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.

ljharb commented 1 year ago

Nothing should support json5, or any other format, until node natively supports it, even if it's better.