概要
いつも.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ファイルを保存してみて動いたら成功
終わりに
基本的にprettierの公式ドキュメントに書いてあることをやっただけですが、いつも忘れて調べてるので、備忘録として残しました。
公式ドキュメント