-
Notifications
You must be signed in to change notification settings - Fork 22
Webstorm configuration
Enabling linting errors/warnings in Webstorm
- In Webstorm go to File > Settings
- In the settings menu go to Languages & Frameworks > JavaScript > Code Quality Tools > ESLint
- Check Enable
- Browse the ESLint package by clicking the '...' Button
- Locate the current project root and go to node_modules > eslint
- Enable 'Automatic Search'
- Close the settings window by clicking 'Apply' and then 'OK'
Enabling linting errors/warnings in Webstorm
- In Webstorm go to File > Settings
- In the settings menu go to Languages & Frameworks > TypeScript > TSLint
- Check Enable
- Browse the TSLint package by clicking the '...' Button
- Locate the current project root and go to node_modules > tslint
- Enable 'Search for tslint.json'
- Close the settings window by clicking 'Apply' and then 'OK'
Enabling linting errors/warnings in Webstorm
- In Webstorm go to File > Settings
- In the settings menu go to Languages & Frameworks > Stylesheets > Stylelint
- Tick the enable checkbox and make sure the Node interpreter and Stylelint paths are resolved correctly.
Prettier is used for formatting the code. You can run yarn prettify
to format all your code but a better solution is to add an external tool that only format the file you are working in.
- In Webstorm go to File > Settings
- In the settings menu go to Tools > External Tools
- Click the '+' to add an external tool
- Fill in a name 'Prettify' for example
- In Tool Settings use the following settings:
-
Program: C:\Users<your user name>\AppData\Roaming\npm\prettier.cmd (This is only avialable when Prettier is installed globally. Use
npm install prettier -g
to install it globally) -
Parameters: --write --print-width 100 --tab-width 2 --single-quote --trailing-comma all
$FilePathRelativeToProjectRoot$ -
Working directory:
$ProjectFileDir$
-
Program: C:\Users<your user name>\AppData\Roaming\npm\prettier.cmd (This is only avialable when Prettier is installed globally. Use
- Click OK
- In the settings menu go to Keymap
- In the tree structure navigate to External Tools > External Tools > <Name used in step 4>
- Right click the item and select Add Keyboard Shortcut
- Press the desired keyboard shortcut (Ctrl + Alt + P for example). If the shortcut is already in use remove it before assigning it to the prettify external tool.
- Click OK
- Close the settings window by clicking 'Apply' and then 'OK'
ESlint/TSLint doesn't like trailing spaces and developers don't like to remove trailing spaces. Luckily Webstorm has a feature that can automatically remove trailing spaces on save.
- In Webstorm go to File > Settings
- In the settings menu go to Editor > General
- Select 'All' in the dropdown after 'Strip trailing spaces on Save':
- Disable 'Always keep trailing spaces on caret line'
- Close the settings window by clicking 'Apply' and then 'OK'
It can happen that webpack doesn't compiles or automatically updates/refreshes the website when a change to a file is made. This is caused by the 'safe write' setting of Webstorm so it's best to disable 'safe write'.
- In Webstorm go to File > Settings
- In the settings menu go to Appearance & Behavior > System Settings
- Disable 'Use "safe write" (save changes to a temporary file first)'
- Close the settings window by clicking 'Apply' and then 'OK'
Live templates are awesome and could save you a lot of time! There are a few sets available for download!
- Download the live template configuration files
- Paste the xml files in the template directory
- OSX:
users/{user}/Library/Preferences/{WebStormVersion}/templates/
- Windows:
{user}/.{WebStormVersion}/config/templates/
- OSX:
- Restart WebStorm and the new templates should be active
Note: if templates are not active after restart, go to Settings > Editor > Live Templates and enable the new template groups
Shortcut | Description |
---|---|
ce |
Console.error |
ci |
Console.info |
cl |
Console.log |
class |
Create a class |
interface |
Create a interface |
cm |
Console.log method |
cw |
Console.warn |
enum |
Create enum |
fn |
Private function |
for |
For loop |
method |
Create a method |
pfn |
Create a public function |
pm |
Private method |
prfn |
Protected function |
prm |
Protected method |
pum |
Public method |
qsa |
QuerySelectorAll |
qs |
QuerySelector |
qsaa |
QuerySelectorAll to Array |
Shortcut | Description |
---|---|
vco |
Create the computed object for a Vue component |
vdo |
Create the data object for a Vue component |
vmo |
Create the methods object for a Vue component |
vpo |
Create the props object for a Vue component |
vwo |
Create the watch object for a Vue component |
:c |
Add a scoped class reference |
:l |
Add a localized attribute |
Shortcut | Description |
---|---|
vsConfig |
Get the config manager |
vsGateway |
Get the gateway |