Eslint autofix on save for webstorm

Currently, I highlight all my code in a file and press alt-enter to run eslint --fix on webstorm. Is there any way, I can have that run every time I save the file or I close it?

5
5 comments

Please see https://youtrack.jetbrains.com/issue/WEB-24452#comment=27-1763733.
If you need to run eslint --fix on Save, set it up as a file watcher, and disable 'immediate synchronization' for this watcher, so that it's triggered on explicit Save/changing focus

-5

If someone else finds this useful or faces the same issue, the workaround is to trigger it on file save action:
Go to Settings -> Keymap -> type eslint - now double click on Fix ESLint Problems -> Add Keyboard Shortcut -> press CTRL + S. Confirm, it will ask about the other mappings to the given combination -> Choose "leave" and then Ok and exit.

-1

Hi Roman, actually better not to choose to "leave" the binding, it doesn't work here. I removed the existing CTRL+S binding, it's useless anyway because I save on frame deactivation.

2

Go to Settings -> Keymap -> type eslint - now double click on Fix ESLint Problems -> Add Keyboard Shortcut

This is a useful tip. I'd simply assign to an unused key. For windows alt + s is unused and its in the same area on keyboard close to ctrl + s

1

Please sign in to leave a comment.