Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(playground): Add JSON support #3968

Merged
merged 6 commits into from
Dec 8, 2022
Merged

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Dec 6, 2022

Summary

This PR adds basic JSON support to the playground. It's not the deluxe version.

To use JSON, it's necessary to switch to the multifile mode and change the extension to json.

We should probably add a language dropdown in the future that lets you pick JavaScript, TypeScript, or JSON, similar to what Prettier has. I decided not to do this as part of this PR because it's mainly to unlock the development of the JSON formatter and not to promote the JSON formatting on the playground.

Test Plan

I tested the playground with a JSON, jS ,and TypeScript file

@MichaReiser MichaReiser marked this pull request as ready for review December 6, 2022 10:39
@MichaReiser MichaReiser requested review from leops, ematipico and a team as code owners December 6, 2022 10:39
@MichaReiser MichaReiser marked this pull request as draft December 6, 2022 10:39
@MichaReiser MichaReiser marked this pull request as ready for review December 6, 2022 10:42
@netlify
Copy link

netlify bot commented Dec 6, 2022

Deploy Preview for docs-rometools ready!

Name Link
🔨 Latest commit 9585f62
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/638f64fef46a900008511c57
😎 Deploy Preview https://deploy-preview-3968--docs-rometools.netlify.app/playground
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@MichaReiser MichaReiser marked this pull request as draft December 6, 2022 10:42
@@ -147,76 +138,6 @@ export function createPlaygroundSettingsSetter<
};
}

export function formatWithPrettier(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this to the prettierWorker to remove the prettier dependencies from the main bundle.

@MichaReiser MichaReiser added the A-Website Area: website and documentation label Dec 6, 2022
@MichaReiser MichaReiser marked this pull request as ready for review December 6, 2022 13:29
Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried to parse a JSON file, but prettier formatter emits an error

website/src/playground/workers/prettierWorker.ts Outdated Show resolved Hide resolved
@MichaReiser
Copy link
Contributor Author

I just tried to parse a JSON file, but prettier formatter emits an error

Thanks. Should now be fixed!

Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's some feedback:

  • prettier now handles JSON files;
  • if you create a .json file and tick TypeScript or JSX under "Source Type", the extension of the file changes;
  • from the previous step, if you untick the option, the file now has .js extension

@MichaReiser
Copy link
Contributor Author

Here's some feedback:

* prettier now handles JSON files;

* if you create a `.json` file and tick `TypeScript` or `JSX` under "Source Type", the extension of the file changes;

* from the previous step, if you untick the option, the file now has `.js` extension

These are good points. I'll create an issue for updating the playground to add proper support for different languages (hide language and formatter options that aren't relevant)

@MichaReiser MichaReiser merged commit 2988021 into main Dec 8, 2022
@MichaReiser MichaReiser deleted the playground/json-support branch December 8, 2022 13:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Website Area: website and documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants