Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prettier format issue #4390

Closed
1 task
mybigman opened this issue Aug 19, 2022 · 2 comments
Closed
1 task

prettier format issue #4390

mybigman opened this issue Aug 19, 2022 · 2 comments

Comments

@mybigman
Copy link

What version of astro are you using?

1.0.6

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

Prettier mangles the layout file.

This is on a fresh install.

Before

---
export interface Props {
  title: string;
}

const { title } = Astro.props as Props;
---

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <link rel="icon" type="image/x-icon" href="/favicon.ico" />
    <meta name="generator" content={Astro.generator} />
    <title>{title}</title>
  </head>
  <body>
    <slot />
  </body>
</html>
<style>
  :root {
    --font-size-base: clamp(1rem, 0.34vw + 0.91rem, 1.19rem);
    --font-size-lg: clamp(1.2rem, 0.7vw + 1.2rem, 1.5rem);
    --font-size-xl: clamp(2.44rem, 2.38vw + 1.85rem, 3.75rem);

    --color-text: hsl(12, 5%, 4%);
    --color-bg: hsl(10, 21%, 95%);
    --color-border: hsl(17, 24%, 90%);
  }

  html {
    font-family: system-ui, sans-serif;
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-bg);
  }

  body {
    margin: 0;
  }

  :global(h1) {
    font-size: var(--font-size-xl);
  }

  :global(h2) {
    font-size: var(--font-size-lg);
  }

  :global(code) {
    font-family: Menlo, Monaco, Lucida Console, Liberation Mono,
      DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace;
  }
</style>

After

---
export interface Props {
  title: string;
}

const { title } = Astro.props as Props;
---

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <link rel="icon" type="image/x-icon" href="/favicon.ico" />
    <meta name="generator" content={Astro.generator} />
    <title>{title}</title>
  </head>
  <body>
    <slot />
    <style>
      :root {
        --font-size-base: clamp(1rem, 0.34vw + 0.91rem, 1.19rem);
        --font-size-lg: clamp(1.2rem, 0.7vw + 1.2rem, 1.5rem);
        --font-size-xl: clamp(2.44rem, 2.38vw + 1.85rem, 3.75rem);

        --color-text: hsl(12, 5%, 4%);
        --color-bg: hsl(10, 21%, 95%);
        --color-border: hsl(17, 24%, 90%);
      }

      html {
        font-family: system-ui, sans-serif;
        font-size: var(--font-size-base);
        color: var(--color-text);
        background-color: var(--color-bg);
      }

      body {
        margin: 0;
      }

      :global(h1) {
        font-size: var(--font-size-xl);
      }

      :global(h2) {
        font-size: var(--font-size-lg);
      }

      :global(code) {
        font-family: Menlo, Monaco, Lucida Console, Liberation Mono,
          DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace;
      }
    </style>
  </body>
</html>

Link to Minimal Reproducible Example

Participation

  • I am willing to submit a pull request for this issue.
@bluwy
Copy link
Member

bluwy commented Aug 19, 2022

Looks like there are two issues here:

  1. We're using prettier-plugin-astro 0.3.0 where now it's already 0.5.0
  2. The repo use tabs for prettier.

I think we could bump to 0.5.0, re-format and call it a day. I'm not sure how we can enforce tabs for no2 though, unless we setup a default .prettierrc via the template/astro add (both which aren't implemented yet), or prettier 3 (?)

cc @Princesseuh

@Princesseuh
Copy link
Member

Princesseuh commented Aug 19, 2022

I think the issue they're talking about is more so that the style tag gets moved inside the body tag.

This is caused by a known issue inside the compiler at the moment withastro/compiler#318 and there's also an issue for this in the plugin's repo withastro/prettier-plugin-astro#260 so we can close this one

Thank you for filling this issue!

@Princesseuh Princesseuh closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants