-
-
Notifications
You must be signed in to change notification settings - Fork 923
Description
Apply oxc_formatter for embedded JS/TS part inside of Prettier's default supported files. So, xxx should be any of html, vue, markdown and mdx.
Things like:
- Format consistency
oxfmt-ignorecomment andexperimentalSortImports
will be available.
TODOs
Vue
- vue:
<script>...</script>babel/typescriptw/__embeddedInHtml- No special handling
- vue:
<script generic="...">babel-tsw/__isEmbeddedTypescriptGenericParameters- Extract
type T<${value}> = any - Force
'forStringLiteral(singleQuote: trueis not enough) by__isInHtmlAttribute shouldHugJsExpressionw/__onHtmlBindingRoot?
- vue:
v-slot="..."/#default="..."babel(-ts)w/__isVueBindings- Extract
function _(${text}) {} - Force
'forStringLiteral(singleQuote: trueis not enough) by__isInHtmlAttribute
- vue:
v-for="... in ..."(LHS)babel(-ts)w/__isVueForBindingLeft+__isInHtmlAttribute+__embeddedInHtml- Extract
function _(${left}) {} - Add
(and)if multiple params - Force
'forStringLiteral(singleQuote: trueis not enough) by__isInHtmlAttribute
- Enable for
vue- Blocked by js-in-vue
- vue:
v-for="... in ..."(RHS)__(js|ts)_expression(= babel(-ts):isExpr)
- vue:
v-on="..."/@click="..."(EXPR)__(js|ts)_expression(= babel(-ts):isExpr)
- vue:
v-on="..."/@click="..."(STATEMENT)__vue_(ts_)event_binding(= babel(-ts))
- vue:
{{ ... }}__vue_(ts_)expression(= babel(-ts):isExpr)
- vue:
v-bind="..."/:class="..."__vue_(ts_)expression(= babel(-ts):isExpr)
- vue:
v-if="...",v-show="...", etc__(js/ts)_expression(= babel(-ts):isExpr)
HTML
- html:
<script>...</script>babel/typescriptw/__babelSourceType+__embeddedInHtml- No special handling
- html:
onclick="..."babelw/__isHtmlInlineEventHandler+__isInHtmlAttribute- Remove last
;if singleExpressionStatement - Force
'forStringLiteral(singleQuote: trueis not enough) by__isInHtmlAttribute
- Enable for
html- Blocked by js-in-html
Markdown/MDX
- markdown|mdx: code block
inferParser()->babel/typescript- Remove first and last
;if singleJSXElementinExpressionStatement
- mdx: import/export
babel- Do not support validation with
__onHtmlBindingRoot
- mdx: jsx
__(js|ts)_expression(= babel(-ts):isExpr)
- Enable for
markdown/mdx- Blocked by js(-in-(html|vue))-in-markdown
Svelte
- svelte:
<script>...</script>typescript/babel-ts- No special handling
- svelte:
{...}svelteExpressionParser/svelteTSExpressionParserw/_svelte_asFunction: undefined- Extract
ExpressionStatement:(${statement}\n)
- svelte:
{#snippet ...}svelteExpressionParser/svelteTSExpressionParserw/_svelte_asFunction: true- Extract
FunctionDeclaration:function ${statement} {}
Astro
- TODO: Research
NOTE
to_prettier_doc.rsimplementation is not complete- There are still some difference pure
oxc_formatterresult vs<script>in vue result - Convert Prettier
Doc->oxc_formatterIR is not enough, need to handle Printer's behaviors
- There are still some difference pure
- tsx-in-vue is NOT supported
- There is no signal to detect TSX or TS when called from Prettier
- Only options is
maybeJSXRe.test(sourceText), but makes all ts-in-vue path slow
- Force single quote for
__isInHtmlAttributecases are not yet implemented- Just set
QuoteStyle::Singlefor now - Strictly speaking, this is not enough since this options is just a preference
- Just set
- js-in-angular is out of scope for now
- May be possible to support
__ng_action,__ng_bindingand__ng_interpolation - But
__ng_directiveis not a valid JS/TS syntax at all
- May be possible to support
options.__embeddedInHtmlshould be handled for html-in-js-in-html?options.__babelSourceTypeshould be handled for js-in-html?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-formatterArea - FormatterArea - Formatter
Type
Fields
Give feedbackPriority
None yet
Start date
None yet
Target date
None yet
Effort
None yet