0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

.astroファイルでprettierが動かない時の備忘録

Posted at

概要

いつも.astroファイルでprettierがエラーになるので備忘録としてメモします。

エラー内容

.astroファイルを保存した時、prettierがきかない

対策

インストールする
npm i --save-dev prettier prettier-plugin-astro
ファイル追加する .prettier.mjs
// .prettierrc.mjs
/** @type {import("prettier").Config} */
export default {
  plugins: ['prettier-plugin-astro'],
  overrides: [
    {
      files: '*.astro',
      options: {
        parser: 'astro',
      },
    },
  ],
};

ここまでやり、プロジェクト内の適当な.astroファイルを保存してみて動いたら成功 :ok_hand:

終わりに

基本的にprettierの公式ドキュメントに書いてあることをやっただけですが、いつも忘れて調べてるので、備忘録として残しました。

公式ドキュメント

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?