* chore(deps): upgrade prettier to v1.8.2 * chore: setup lint-docs script * docs: add `<!-- prettier-ignore -->`s * docs: format docs * Revert "docs: format docs" This reverts commit 6dba903987dddc498cb589ca311905f25b6aee53. * chore(prettierrc): set `--no-prose-wrap` * docs: format docs * Revert "docs: format docs" This reverts commit 139bd744b6921916be8fac4fa3bab83bae5d12df. * docs: tweak * docs: format docs * chore: rename .prettierrc * chore: rename back to .prettierrc * chore: split out third-party * refactor: fix linting * chore: do not split out third-party on website
51 lines
2.2 KiB
Markdown
51 lines
2.2 KiB
Markdown
---
|
||
id: webstorm
|
||
title: Webstorm Setup
|
||
---
|
||
|
||
## Configure External Tool
|
||
|
||
https://blog.jetbrains.com/webstorm/2016/08/using-external-tools/
|
||
|
||
Go to _File | Settings | Tools | External Tools_ for Windows and Linux or _WebStorm | Preferences | Tools | External Tools_ for OS X and click **+** to add a new tool. Let’s name it **Prettier**.
|
||
|
||
* **Program** set `prettier`
|
||
|
||
> If on the other hand you have `prettier` installed locally, replace the **Program** with `$ProjectFileDir$/node_modules/.bin/prettier` (on OS X and Linux) or `$ProjectFileDir$\node_modules\.bin\prettier.cmd` (on Windows).
|
||
|
||
* **Parameters** set `--write [other opts] $FilePathRelativeToProjectRoot$`
|
||
* **Working directory** set `$ProjectFileDir$`
|
||
|
||

|
||
|
||
### Process directories
|
||
|
||
* Clone the External tool created above and name it `Prettier Directories`
|
||
* **Parameters** set `--write [other opts] $FileDirRelativeToProjectRoot$/**/{*.js,*.jsx}`
|
||
|
||
## Usage
|
||
|
||
* Cmd-Shift-A on OS X or Ctrl+Shift+A on Windows and Linux
|
||
* Type: 'prettier' and hit enter
|
||
|
||
### Configure Keymap
|
||
|
||
Now when you setup **External Tool** I guess you want to add hotkey for it. Go to _File | Settings | Keymap_ for Windows and Linux _WebStorm | Preferences | Keymap_ and type external tool name in search box.
|
||
|
||
See [this documentation](https://www.jetbrains.com/help/webstorm/configuring-keyboard-shortcuts.html) about configuring keyboard shortcuts.
|
||
|
||
## Using File Watcher
|
||
|
||
To automatically format using `prettier` on save, you can use a file watcher.
|
||
|
||
Go to _File | Settings | Tools | File Watchers_ for Windows and Linux or _WebStorm | Preferences | Tools | File Watchers_ for OS X and click **+** to add a new tool. Let’s name it **Prettier**.
|
||
|
||
* **File Type**: JavaScript
|
||
* **Scope**: Current File
|
||
* **Program** set the full path to a `prettier` executable, such as `/Users/developer/repo/jest/node_modules/.bin/prettier` (on OS X and Linux) or `C:/\Users\developer\repo\jest\node_modules\.bin\prettier.cmd` (on Windows).
|
||
* **Arguments** set `--write [other opts] $FilePath$`
|
||
* **Working directory** set `$ProjectFileDir$`
|
||
* **Immediate file synchronization**: Uncheck to reformat on Save only (otherwise code will jump around while you type).
|
||
|
||

|