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?
Please sign in to leave a comment.
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 focusIf 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.
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.
This article helps me: https://medium.com/@netczuk/even-faster-code-formatting-using-eslint-22b80d061461
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