zabumba
zabumba

Reputation: 12412

How to configure ESlint to fix indent 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?

Upvotes: 12

Views: 13698

Answers (2)

IanVS
IanVS

Reputation: 3775

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.

Upvotes: 1

remix23
remix23

Reputation: 2994

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

Upvotes: 10

Related Questions