Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 864
Anna Avatar asked Jan 22 '19 08:01

Anna


People also ask

How do I enable Stylelint in Webstorm?

Activate and configure Stylelint To activate Stylelint, open the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Languages & Frameworks | Style Sheets | Stylelint, and select the Enable checkbox.

How to use stylelint 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.

How do I use stylelint to fix the current file?

Stylelint can automatically fix detected problems in the current file in unambiguous cases using the Stylelint Auto Fix functionality. To apply Auto Fix, click Stylelint: Fix current file in the popup. Alternatively, press Alt+Enter and select Stylelint: Fix current file from the list.

How do I enable ESLint --fix in WebStorm?

To enable running eslint --fix on save for the current project, go to Preferences / Settings | Languages and Frameworks | JavaScript | Code Quality Tools | ESLint and tick the Run eslint --fix on save checkbox. By default, WebStorm will run ESLint to autofix .js, .ts, .jsx, .tsx, .html, and .vue files.

How to fix errors in NPX stylelint?

Had the errors reported to my terminal and run npx stylelint src/scss/_file.scss --fix Try npx stylelint --fix style.css (note the --fix is before the CSS files path).


2 Answers

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

like image 41
lena Avatar answered Oct 26 '22 12:10

lena


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

like image 166
Anna Avatar answered Oct 26 '22 12:10

Anna