Anna
Anna

Reputation: 3141

Stylelint fix in WebStorm

I configured stylelint in my WebStorm (2018.2.3) in Settings -> Languages and Frameworks -> Stylesheets -> Stylelint. And I have .stylelintrc in my root.

Right now stylelint successfully underlines errors in my css file. But is there a way to fix them also with WebStorm help (without running --fix command in console)?

Upvotes: 10

Views: 13180

Answers (3)

Taras Shevchenko
Taras Shevchenko

Reputation: 311

enter image description here

Ceate watcher (Settings > Tools > File Wathcers) with settings below:

Program                  -    $ProjectFileDir$\node_modules\.bin\stylelint
Arguments                -    $FilePath$ --fix
Outout path to refresh   -    $FilePath$
Working directory        -    $FileDir$

Upvotes: 1

Anna
Anna

Reputation: 3141

I created the external tool in Settings | Tools | External Tools, like this:

enter image description here

And then added the shortcut keymap for this command in here:

enter image description here

So now it fixes the whole file on the keymap press

Upvotes: 18

lena
lena

Reputation: 93738

Stylelint autofixes are not yet supported, please follow WEB-25069 for updates.

You can set up a file watcher to have stylelint --fix triggered in Save All:

enter image description here

Upvotes: 15

Related Questions