GithubHelp home page GithubHelp logo

Comments (7)

Princesseuh avatar Princesseuh commented on June 13, 2024

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.

teinett avatar teinett commented on June 13, 2024

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

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.

Princesseuh avatar Princesseuh commented on June 13, 2024

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.

teinett avatar teinett commented on June 13, 2024

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.

Princesseuh avatar Princesseuh commented on June 13, 2024

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.

teinett avatar teinett commented on June 13, 2024

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.

Princesseuh avatar Princesseuh commented on June 13, 2024

Thank you, I'll update the sentence to be more clear, sorry for the inconvenience!

from prettier-plugin-astro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.