3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VS Codeで*.js, *.ts, *.jsx, *.tsxのみにデフォルトフォーマッタとしてPrettierを設定する

Posted at

デフォルトフォーマッタや自動フォーマッティングの設定を言語ごとに変えたいときがある。
VS Codeで特定の拡張子のみに適用したい設定は、settings.jsonに記述する。

今回はjs, ts, jsx, tsxのファイルのみでPrettierをデフォルトフォーマッタとして設定し、自動フォーマッティングを有効にする場合の書き方を記す。

command+shift+Pでsettings.jsonを開き、下記を追記する。

{
"[javascript]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascriptreact]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?