-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace relaxed-json
with strip-json-comments
#3910
Comments
In general, I'm a bit confused about this file: addons-linter/src/parsers/json.js Line 30 in 872132e
Why is esprima being used before RJSON at all? It seems that the whole Or perhaps it should use |
Side note: both |
RelaxedJSON is not used for parsing, but only as an attempt to get useful error messages. We can use For manifest.json and The linter also lints arbitrary JSON files:
Perhaps we can disable JSON parsing for non-standard JSON files (i.e. not used by the extension framework in a special way). That would also resolve #3680 |
This issue has been automatically marked as stale because it has not had recent activity. If you think this bug should stay open, please comment on the issue with further details. Thank you for your contributions. |
So I suggest replacing esprima and RJSON in favor of a combination of:
They're both light, dependency-free and more focused, whereas the other two: |
So it turns out this is really simple: export const RJSON = {
parse(jsonString) {
return JSON.parse(stripJsonComments(jsonString));
},
}; That's all that's needed… except that RJSON can detect duplicate keys and addons-linter specifically tests for them. I don't know of a way to detect duplicate keys other than by parsing the JSON file manually (e.g via something like relaxed-json). I also tried Either the duplicate detection is dropped, or we cannot drop relaxed-json :( The unfortunate part is that relaxed-json hasn't seen updates in 5 years and it has a few heavy old deps |
The MDN documentation mentions that:
But RJSON is a bit more than that: https://github.com/phadej/relaxed-json#relaxed-json
Given this and that
relaxed-json
has a few CLI-related dependencies, I'd suggest swapping it out for the more appropriate strip-json-comments, which has no dependencies.Related:
┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: