LoginSignup
1
0

More than 1 year has passed since last update.

[VSCode]Vueコード整形ツールの設定をシングルクォーテーションにする

Posted at

VSCodeでVueのコード整形ツール(Prettier)の設定をシングルクォーテーションにしたい。

問題

古い記事では、以下のように書かれていることが多かった。

メニューから Code > Preference > Settings を開く。
検索バーで SingleQuote と検索して出てきたものをチェック。

スクリーンショット 2021-06-04 16.52.52.png

自分の環境ではこの設定を行なっても整形時にダブルクォーテーションのままだった。

解決策

Pritterはアップデートがあったらしく、共通の設定ファイルを利用せずにPritter専用ファイルから指定するよう変更されたらしい。

プロジェクトルートディレクトリに.prettierrcを作成して以下を記述する。

.prettierrc
{
  "singleQuote": true
}

これでフォーマッターのショートカット Shift+Option+F を押すと、シングルクォーテーションで整形されるようになった。

参考

https://stackoverflow.com/questions/59243558/vscode-not-formatting-ts-js-files-with-single-quotes
https://prettier.io/docs/en/configuration.html

1
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
1
0