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?

VSCode 拡張で使用される Prettier はデフォルトのバージョンを保持している件について

Last updated at Posted at 2025-06-27

はじめに

Visual Studio Code(VSCode) では拡張機能としての Prettier が作成されています。
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

ここで、package.json に prettier を書いていないのになぜVSCode 上で使用できるのか疑問になったので調査しました。

結論

VSCode 拡張機能における Prettier はデフォルトのバージョンを保持しているようです。
具体的には、VSCode 拡張機能で使用される Prettier は

  1. package.json にprettierが定義されている場合、ここに記載されたバージョンを使用
    1. package.json にprettierが定義されていなくても、グローバル環境にPrettier がインストールされている場合はこのバージョンを使用
  2. package.json にprettier定義されていない場合、VSCode 拡張機能で用意されたデフォルトのバージョンを使用
    1. 2025年6月25日時点のVSCode拡張機能のPrettier(11.0.0)では、フォーマットの際、バージョン2.8.8 が使用される

実際に試してみる

package.json にprettierが定義されている場合

以下画像のように package.json にprettierが定義されている場合、VSCode上でファイルにフォーマットをかけると、package.json に記載されたバージョンが使用されます。
(今回はv2系をprettierで使用していますが、v3系でも同様の結果になります)

image.png

package.json にprettierが定義されていない場合

以下画像のように package.json にprettierが定義されていない場合、VSCode 拡張機能で用意されたデフォルトのバージョンが使用されます。
調査時点で確認したVSCode拡張機能のPrettier(11.0.0)では、フォーマットの際、バージョン2.8.8 が使用されました。

image.png

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?