Last 12 weeks · 0 commits
5 of 6 standards met
Astro Info If this issue only occurs in one browser, which browser is a problem? _No response_ Describe the Bug When a tag is placed inside a conditional expression in an .astro file (ternary or &&), Prettier fails to format the file and throws a parsing error. The code compiles and runs correctly in both dev and build; the issue appears to be in Prettier parsing. This might be related to being treated as a special Astro tag and not a normal JSX/HTML node when nested under expression containers. Reproduction 1. Create a new Astro project 2. Install and enable prettier + prettier-plugin-astro 3. Add the following to a .astro file 4. Run Prettier on the file (Format Document / CLI) What's the expected result? Prettier formats the file without errors, and preserves the script contents (or formats them consistently). Link to Minimal Reproducible Example Participation [ ] I am willing to submit a pull request for this issue.
Describe the Bug Here's a piece of code from recommended example starter: When running prettier against it the output is: Notice how only the javascript at the top has changed to single quotes and not the rest of the code. Steps to Reproduce 1. using template "A basic, helpful starter project" 2. add file to root 3. add following content to prettier: 5. The output you can find above.
Repository: withastro/prettier-plugin-astro. Description: Prettier plugin for Astro Stars: 588, Forks: 41. Primary language: TypeScript. Languages: TypeScript (92.8%), JavaScript (7.2%). Topics: astro, formatter, plugin, prettier. Latest release: v0.14.1 (1y ago). Open PRs: 3, open issues: 32. Last activity: 4mo ago. Community health: 87%. Top contributors: jasikpark, Princesseuh, dependabot[bot], github-actions[bot], antonyfaris, drwpow, alex-grover, delucis, nylexar-sudo, natemoo-re and others.
TypeScript
Describe the Bug Hi! Let me start by saying that I was not sure if this problem should be reported here or in Prettier's issue tracker. I decided to report it here because I only experience it in Astro files and Prettier might reject it on the grounds of not supporting Astro files. If the issue is on Prettier's side and not this project's, I hope you can help me figure out exactly what to report to Prettier. After upgrading from prettier 3.6.2 to 3.7.0, the following Astro code started throwing a syntax error when running prettier: The error is: The error only appears if the inline script tag is inside of . This code produces no error: The error persists in the newest Prettier version (3.7.4). Steps to Reproduce 1. Check out my reproduction repository (a basic Astro Starlight project) https://github.com/angelikatyborska/astro-prettier-inline-script 2. Install deps () 3. Run prettier () 4. There are unexpected syntax errors: The second error, in the mdx file, is interesting. If I get rid of the first error, the second error disappears too. It might be unrelated, or it might be a clue?
Describe the Bug I have "prettier-plugin-astro" installed only globally (via "npm install -g prettier-plugin-astro") instead of within the local package. same as #258 (closed but never solved :/) I want the plugin to be found and used in linux if globally installed. As it is needed for the CI plugin https://codeberg.org/woodpecker-plugins/prettier/issues/39#issuecomment-9719612 Steps to Reproduce 1. clone https://codeberg.org/koibtw/ebil.club 2. 3. exec to get the intended usage of the plugin (this will and run prettier in check mode 5. as the plugin e.g. environment should not alter the work dir we can not locally install the plugin witch would work:
Describe the Bug Consider following code formatter correctly keeps no space between tags because they’re inline elements. However, if we put these inside JSX-style expression in braces: formatter adds newlines between elements no matter how long line is or whether the elements are inline or block, ie. it behaves more like regular JSX and less like HTML. However, unlike in JSX, this has implications for browsers since this newsline will render like an extra space in browser, which is often undesirable. This is particularly troubling if you write a lot of conditional expressions () or iterating over arrays. Consider this example - you want to render a inline comma-separated list of items: This is going to render in broswer as "item 1 , item 2" instead of "item 1, item 2" Steps to Reproduce 1. 2. 3. 4. 5. Paste following example to 7. yields: