Shopify / theme-tools

Everything developer experience for Shopify themes
https://shopify.dev/docs/themes
MIT License
80 stars 24 forks source link

Investigate formatting of json/js/css in web version of extension #562

Open charlespwd opened 2 weeks ago

charlespwd commented 2 weeks ago

Describe the bug I think we're missing plugins because the {% schema %} tag wasn't getting reformatted in my demo of the extension running on https://github.dev. I think it has to do with the prettier/standalone import. I feel like we need to add the json/css/js plugins manually for it to work.

Breadcrumbs

Smintfy commented 2 weeks ago

Hello! I managed to make the formatting of the {% schema %} tag for the vscode browser extension works.

(see video > 0:06)

https://github.com/user-attachments/assets/c71b210a-f3fd-4c05-9708-888b1af018cd

It worked after I added thebabelPrettierPlugin from the prettier 'parser-babel' plugin.

import LiquidPrettierPlugin from '@shopify/prettier-plugin-liquid';
import babelPrettierPlugin from 'prettier/parser-babel';

export const vscodePrettierFormat: Format = async (textDocument) => {
    /* ... */
   return prettier.format(text, {
    parser: 'liquid-html',
    plugins: [
      LiquidPrettierPlugin as any,
      babelPrettierPlugin as any,
    ],
  });
};