FormidableLabs / FormidableLabs/runpkg

Handling non-js files with prettier

Open
#183 0 comments 0 reactions 0 assignees View on GitHub
bug improvement
Dominant language
JavaScript
Stars
307
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Relates to issue #176 (prettier enhancements)

Currently our prettier functionality only handles JS files as it always uses `babylon` (which should now be `babel`, I believe). Formatting for `json`, `typescript` and more just fails silently. I'm working on prettier enhancements which will address this issue. See below for an outline of how I'm tackling the issue. Open for discussion now and/or when my PR comes in.

Current plan:

1. Check current file extension and use that to set a valid non-custom [parser option](https://prettier.io/docs/en/options.html#parser) by updating the parser name and loading the necessary script on click (loaded from [this list of prettier parsers](https://unpkg.com/browse/prettier@1.13.0/))
2. *Less sure of this one*: Keep prettier and the babel/babylon parser loaded (but via 'async') in the head of `index.html` as they'll be used a lot.
3. Hide the prettier button if we're in a file with an extension that we cannot prettify
4. In addition to `formatting` and `done` state, add a `formatting failed` state to the prettier button (current state changes in a local branch on my machine. Relates to discussion in #176 )

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.