Linguist: Add `jsonc` (json with comments)

Created on 31 May 2018  路  4Comments  路  Source: github/linguist

Preliminary Steps

Please confirm you have...

Problem Description

Some files like VSCode settings, typescript.json, are json, but allow comments (similar to json5, but it doesn't allow any of the other features).

Up until now I marked those as json5 for correct highlighting, but recently prettier started formatting json5 in markdown as the "simplest version of json5", which for example included taking the quotes off the keys when they aren't necessary. This will give an invalid JSON with comments in the end. However there's not a correctly highlighting on GitHub for jsonc. So I'm suggesting it here.

URL of the affected repository:

https://github.com/prettier/prettier/issues/4611#issuecomment-393461346

Last modified on:

2018-05-31

Expected language:

Detected language:

Most helpful comment

@lildude I think it's worth adding a separate language entry for JSON with comments, because jsonc isn't an isolated case. ESLint supports comments in .eslintrc.json files, and the entire reason we added Sublime configs as a language was a workaround for how comments were being highlighted as errors.

Either we differentiate between "JSON" and "JSON with comments", or we switch to a more lenient grammar for highlighting JSON files (I'd be happy to hack one together, it'd barely take 10-25 minutes).

All 4 comments

@lildude I think it's worth adding a separate language entry for JSON with comments, because jsonc isn't an isolated case. ESLint supports comments in .eslintrc.json files, and the entire reason we added Sublime configs as a language was a workaround for how comments were being highlighted as errors.

Either we differentiate between "JSON" and "JSON with comments", or we switch to a more lenient grammar for highlighting JSON files (I'd be happy to hack one together, it'd barely take 10-25 minutes).

@Alhadis Go for it. Take your pick which you'd prefer to implement.

On it.

Gonna add it as "JSON with comments", because affecting the highlighting of existing JSON files could be hazardous for code review (an invalid JSON file could slip past a maintainer's notice if a less experienced contributor put a JS comment in JSON code, for example...)

2.5 hours later, I still can't get Bundler co-operating with my system. :sweat: Either I suck or Ruby seriously hates my guts.

Anyway, submitted as #4171. :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

etc0de picture etc0de  路  5Comments

Alhadis picture Alhadis  路  5Comments

BnSalahFahmi picture BnSalahFahmi  路  3Comments

haskellcamargo picture haskellcamargo  路  3Comments

RafaelPAndrade picture RafaelPAndrade  路  4Comments