How to fix just one rule using eslint

To fix the issues caused by just one rule, you need to combine --fix --rule with --no-eslintrc. Otherwise your rule will just be merged with your existing configuration and all fixable issues will be corrected. E.g.

$ eslint --no-eslintrc --fix --rule 'indent: [2, 2]'

Depending on your setup you’ll need to re-add mandatory settings from your ESLint configuration to the command line for the lint run to succeed. In my case I had to use

$ eslint --no-eslintrc --parser babel-eslint --fix --rule 'indent: [2, 2]'

Leave a Comment