I am trying to create a custom file watcher in WebStorm that will auto fix ESLint errors on save. In Settings > Tools > File Watchers
I created a new file watcher with the following settings:
Any
All places
/home/user/Projects/todo-app/eslint-autofix.sh
/home/user/Projects/todo-app
eslint-autofix.sh:
#!/usr/bin/env bash ./node_modules/.bin/eslint --fix
Then I made an ESLint error and pressed Ctrl + S to save. The following error pops up:
/home/user/Projects/todo-app/eslint-autofix.sh /usr/bin/env: ‘node’: No such file or directory
How to fix this error?
Fix problems automatically on saveOpen the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Languages & Frameworks | JavaScript | Code Quality Tools | ESLint, and select the Run eslint --fix on save checkbox.
If you have the ESLint extension installed you can use CTRL+SHIFT+P to open the Command Palette. Then search for ESLint: Fix all auto-fixable Problems and press ENTER (or RETURN ).
WebStorm lets you automatically fix some of the issues reported by TSLint. To fix a specific error, place the cursor at the highlighted code, press Alt+Enter , and then select TSLint: fix current error from the list. To fix all the issues detected in the file, choose TSLint: fix current file.
According to this article, settings should be as the following:
On WebStorm 2020.1.1
, there is a checkbox called Run eslint --fix on save
.
Also see:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With