Comments (7)
The prettier.documentSelectors
config should be **/*.astro
, with two asterisks before and an asterisk after, as documented here.
Your current config is targeting every file named literally .astro
at the root of your workspace (presumably no files)
from prettier-plugin-astro.
The
prettier.documentSelectors
config should be**/*.astro
, with two asterisks before and an asterisk after, as documented here.Your current config is targeting every file named literally
.astro
at the root of your workspace (presumably no files)
I changed it with two asterisks in .vscode/settings.json:
:
{
"eslint.validate": [
"javascript",
"javascriptreact",
"astro", // Enable .astro
"typescript", // Enable .ts
"typescriptreact" // Enable .tsx
],
"stylelint.validate": [
"css",
"html",
"vue",
"svelte",
"astro"
],
"prettier.documentSelectors": ["**/*.astro"]
}
![2023-12-27 14-48-44](https://private-user-images.githubusercontent.com/1038168/293076748-d44e14c4-d28b-4d6a-a8fb-b103281d0e21.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTAxNzk1OTEsIm5iZiI6MTcxMDE3OTI5MSwicGF0aCI6Ii8xMDM4MTY4LzI5MzA3Njc0OC1kNDRlMTRjNC1kMjhiLTRkNmEtYThmYi1iMTAzMjgxZDBlMjEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDMxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDAzMTFUMTc0ODExWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZGYzNTU1M2JkNGMzZGQxNWUxMzU4OWZkZTc2OGYxMjBkY2U3MTRlNzgzYzBlOWU1MTdmMzFlOTRkNzUyM2IzOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.TEJHkY3IUJZfHAJe4SaZI8pZnyxfmMAMl4SQzcsJrDo)
Prettier now is turned on, but still doesn't work :(
Every other file reads and complies rules from .editorconfig
, but not .astro files.
from prettier-plugin-astro.
Your config doesn't set the Prettier extension as the formatter for Astro files, make sure you're formatting with it:
"[astro]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
from prettier-plugin-astro.
Your config doesn't set the Prettier extension as the formatter for Astro files, make sure you're formatting with it:
"[astro]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }
Where should I do it?
FYI: this project worked totally fine until I updated it to the latest npm packages couple weeks ago. Every setting for Prettier worked perfectly.
from prettier-plugin-astro.
In your VS Code configuration. This is, again, all documented in the "Using in VS Code" section of the README: https://github.com/withastro/prettier-plugin-astro#using-in-vs-code
FYI: this project worked totally fine until I updated it to the latest npm packages couple weeks ago. Every setting for Prettier worked perfectly.
Nothing has changed related to Prettier in the last two months 😅 I do not know what you mean by what worked and doesn't work now. If you have a repo I can take a look at, I'd be happy to.
from prettier-plugin-astro.
I see. Thank you to sending me to this document again and again. :)
There is frase in here https://github.com/withastro/prettier-plugin-astro#using-in-vs-code:
Note If you're using [Astro's VS Code extension](https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode), Prettier and this plugin are already included. Only follow the guide below to format using Prettier's official extension.
I understood it like this: if you are using VS Code with Astro's VS Code extension, you don't need to do it, because it's already done. So I didn't do it :)
I changed my .vscode/settings.json
file:
{
"eslint.validate": [
"javascript",
"javascriptreact",
"astro", // Enable .astro
"typescript", // Enable .ts
"typescriptreact" // Enable .tsx
],
"stylelint.validate": [
"css",
"html",
"vue",
"svelte",
"astro"
],
"prettier.documentSelectors": ["**/*.astro"],
"[astro]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Now Prettier works. :) Thanks!
It's the magic that it worked before.
from prettier-plugin-astro.
Thank you, I'll update the sentence to be more clear, sorry for the inconvenience!
from prettier-plugin-astro.
Related Issues (20)
- 🐛 BUG: tabWidth not working HOT 4
- 🐛 BUG: Prettier not formatting on save in VSCODE using pnpm HOT 3
- 🐛 BUG: My css and scss files are being formatted, but not my astro files HOT 1
- 🐛 BUG: Error when destructuring with '?' in map loop HOT 3
- 🐛 BUG: Formatter is crashing due to prettier updates HOT 2
- 🐛 BUG: Prettier formatting silently fails when JSX conditionals return multiple elements HOT 1
- 🐛 BUG: Broken astro file parser HOT 2
- 🐛 BUG: Incorrect ordering of elements in formatting HOT 3
- 🐛 BUG: breaks the <tag> to separate lines HOT 8
- 🐛 BUG: Cannot handle HTML comments inside conditional blocks HOT 1
- 🐛 BUG: Syntax Highlighting Lost and Incorrect Rendering When Condensing Code Blocks HOT 5
- 🐛 BUG: <script> formatting broken in files containing multi-byte characters HOT 3
- 🐛 BUG: Adding components into head tag breaks the astro file layout (view transitions) HOT 1
- 🐛 BUG: Unexpected token, expected "}" for no reason HOT 4
- 🐛 BUG: Positioning of `<style>` tag is inconsistent depending on the element exported by a component HOT 1
- 🐛 BUG: ViewTransitions component breaks `head` tag on format HOT 1
- 🐛 BUG: HTML-style `prettier-ignore` comments do not work for script tags
- 🐛 BUG: If a specific test fails in a unit test, an unexplained `TypeError` is raised in the next test
- 🐛 BUG: prettier fails to find the plugin HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettier-plugin-astro.