prettier-plugin-astro icon indicating copy to clipboard operation
prettier-plugin-astro copied to clipboard

🐛 BUG: [error] No parser could be inferred for file

Open daelmaak opened this issue 5 months ago • 1 comments

Describe the Bug

I realize this one is very similar to https://github.com/withastro/prettier-plugin-astro/issues/97 but none of the suggested solutions work for me. I use the suggested config

// .prettierrc.mjs
/** @type {import("prettier").Config} */
export default {
  plugins: ['prettier-plugin-astro'],
  overrides: [
    {
      files: '*.astro',
      options: {
        parser: 'astro',
      },
    },
  ],
};

and VSCode configuration

{
  "prettier.documentSelectors": ["**/*.astro"],
  "[astro]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

and the formatting doesn't work both when doing it directly in VSCode

["INFO" - 6:22:27 PM] File Info: { "ignored": false, "inferredParser": null } ["WARN" - 6:22:27 PM] Parser not inferred, trying VS Code language. ["ERROR" - 6:22:27 PM] Failed to resolve a parser, skipping file. If you registered a custom file extension, be sure to configure the parser.

and from command line with prettier --write **/*.astro src

prettier --write **/*.astro src [error] No parser could be inferred for file: src/components/about-experience.astro

I'm using prettier 3.3.3 and your plugin 0.14.1. My project is private but is directly based on https://astro.build/themes/details/aria/

Steps to Reproduce

Try to add prettier to https://github.com/ccbikai/astro-aria and make it format *.astro files, it won't work.

daelmaak avatar Sep 05 '24 16:09 daelmaak