You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the json preprocessor returning an empty string, one can't combine this plugin with eslint-plugin-prettier (prettier only gets an empty string to optimize) for JSON files.
To me it seems like the issue is, that eslint expects us to provide valid JavaScript. One way to circumvent that is by transforming the JSON code to valid JavaScript, for example by returning ['JSON.stringify(%0)\n'.replace('%0', text)] instead. This way prettier would also be able to run over JSON files via eslint.
This is obviously just a hack and also depends on the prettier config in use, but I would propose adding an optional setting to this plugin, which enables a placeholder for JSON->JS conversion. I could also submit a PR.
Due to the json preprocessor returning an empty string, one can't combine this plugin with eslint-plugin-prettier (prettier only gets an empty string to optimize) for JSON files.
To me it seems like the issue is, that eslint expects us to provide valid JavaScript. One way to circumvent that is by transforming the JSON code to valid JavaScript, for example by returning
['JSON.stringify(%0)\n'.replace('%0', text)]
instead. This way prettier would also be able to run over JSON files via eslint.This is obviously just a hack and also depends on the prettier config in use, but I would propose adding an optional setting to this plugin, which enables a placeholder for JSON->JS conversion. I could also submit a PR.
Update: For further discussion I started PR #39.
The text was updated successfully, but these errors were encountered: