kuceb / eslint-plugin-json-format

Format and auto-fix your JSON using ESLint
MIT License
41 stars 3 forks source link

Format json-with-comments (jsonc) files #3

Open kuceb opened 5 years ago

kuceb commented 5 years ago

Currently, this package does not lint/format jsonc files.

I've looked into how vscode does jsonc parsing using https://github.com/Microsoft/node-jsonc-parser, which creates an AST, but haven't done the work to translate that into ESLint fixes.

This would be nice for:

Berkmann18 commented 4 years ago

Wouldn't it be more reasonable and easier to use JSON5 for this?

kuceb commented 4 years ago

@Berkmann18 I know JSON5 can parse jsonc, but can it format it? The problem isn't the parsing, it's the formatting

Berkmann18 commented 4 years ago

Ah! I see. AFAIK, the json5 package can do that (well kind of) the same way you'll format JSON data using JSON.stringify.

kuceb commented 4 years ago

@Berkmann18 the problem is you'd lose comments, which is what happens today if you use this plugin to formal jsonc

Berkmann18 commented 4 years ago

Oh, good point!