I am linting old NodeJS code and I want to clear out all indent issues before I start fixing the rest.
How do I configure ESlint to only show and fix the indent
issues only?
You can set up ESLint to run auto-fix every time you press CTRL+S (or COMMAND+S ). For ESLint to work correctly on file same, you must change the Visual Studio Code preferences. Go to File > Preferences > Settings (or Code > Preferences > Settings).
The ./node_modules/. bin/eslint section of the command is the path to ESLint in your project. Using the --init flag activates ESLint for your project. Activating or initializing ESLint will create an ESLint configuration file that will allow you to customize how ESLint works with your project.
By using eslint in the command line with the proper options:
node node_modules/eslint/bin/eslint --fix --parser babel-eslint --ext js --no-eslintrc --rule 'indent: [1,4,{SwitchCase: 1}]' src/
Change these options according to your requirements
--fix
to auto fix.
--parser babel-eslint
the parser from my eslint.rc.
--ext js
to lint only js files.
--no-eslintrc
otherwise all rules from your eslintrc will be executed.
--rule 'indent: [1,4,{SwitchCase: 1}]'
the rule you want to execute (you can copy paste it from your eslint.rc, it has to be single quoted (the double quotes from the original json were removed).
src/
the target folder.
eslint documentation
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