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?
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?
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.
If you want to use your normal .eslintrc file to keep your configuration (parser, plugins, rule config, etc), you can use eslint-nibble with the --rule= indent
flag. This will respect your normal configuration, but only show you errors from that rule, and give you the option to fix only those, if the rule is auto-fixable.
Disclaimer: I'm the creator of eslint-nibble.
© 2022 - 2024 — McMap. All rights reserved.