LoginSignup
7
3

More than 5 years have passed since last update.

RubyMine の Prettier プラグインで自動フォーマットする

Last updated at Posted at 2018-10-02

image.png

環境

  • RubyMine 2018.3 EAP

目標

*.vue ファイルが保存されたら、Prettier で自動フォーマットされること。
※他のファイルタイプも同様の手順で設定できます

手順

File Watchers と Prettier のインストール

  • Preferences > Plugins
    • File Watchers で検索すると、Search Results に2つとも出てくるのでインストールしましょう。

image.png

File Watchers の設定

  • Preferences > Tools > File Watchers
    • + ボタンで設定を追加しましょう(未作成の場合)

image.png

  • Edit Watcher

    • 設定を下記の通り設定します(ファイルタイプが Vue.js Template の場合)
    項目 設定値
    File type Vue.js Template
    Scope Current File
    Program $ProjectFileDir$/node_modules/.bin/prettier
    Arguments --write $FilePathRelativeToProjectRoot$
    Output paths to refresh $FilePathRelativeToProjectRoot$
    Working directory $ProjectFileDir$
    • Advanced OptionsAuto-save edited files to trigger the watcher はオフにします。
    • ※プロジェクトルートの node_modules/.bin 配下に prettier が存在する前提です。
      • 無ければ npm install prettier --save-dev でインストールしましょう。

image.png

以上

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