When I save a file, I would like to run eslint, and have it fix any issues that eslint can fix.
I know this can be accomplished using the command line by running applying the --fix
argument.
I also know that Intellij-IDEA has integration with Eslint directly; however, Intellij-IDEA uses stdin for it's integration which means you can't pass --fix
as an argument.
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.
ESLint is an open source project that helps you find and fix problems with your JavaScript code. It doesn't matter if you're writing JavaScript in the browser or on the server, with or without a framework, ESLint can help your code live its best life.
With automatic configuration, WebStorm uses the ESLint package from the project node_modules folder and the . eslintrc. * configuration file from the folder where the current file is stored.
create a javascript project. install eslint as an extension in your VS Code Editor. Install eslint as a global package using npm. initialize eslint in your javascript project.
With a few quick steps you can setup a file watcher that will run eslint --fix on the files you save.
Step by step:
Preferences > Tools > File Watchers
and create a new File WatcherFile type: JavaScript
$ProjectFileDir$/apps/web/src/
and included all of it's contents recursively.$ProjectFileDir$/apps/web/node_modules/eslint/bin/eslint.js
--fix $FileName$
$FileDir$
.Name, and save the File Watcher. Then, edit a JavaScript file in the directory you scoped and watch many of your errors and warnings go away! Thanks Eslint!
Note: If you find Intellij-IDEA asking if you want to load file changes without you saving know (which gets annoying) it's because the IDE is saving in the background. You can uncheck Immediate file synchronization
to have a better editing experience.
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