Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint autofix ignore rule

I'm using ESLint in vscode with option "eslint.autoFixOnSave": true.

Basically, I want:

  1. Ignore 1 particular rule for fixing: prefer-const
  2. See all the warnings and errors highlighted in editor (including prefer-const)
like image 519
Alex Avatar asked Aug 01 '17 16:08

Alex


People also ask

How do you ignore the ESLint rule?

ESLint supports 2 mechanisms for ignoring rule violations in code: Using comments, which let you disable certain rules for a line or code block. Using the . eslintignore file.

How do I ignore files in ESLint?

You can tell ESLint to ignore specific files and directories using ignorePatterns in your config files. ignorePatterns patterns follow the same rules as . eslintignore .

How do I automatically fix ESLint errors?

If you have the ESLint extension installed you can use CTRL+SHIFT+P to open the Command Palette. Then search for ESLint: Fix all auto-fixable Problems and press ENTER (or RETURN ). You are free from counting indentation and checking for quotation marks and semicolons!

How do I run ESLint autofix?

To enable running eslint --fix on save for the current project, go to Preferences / Settings | Languages and Frameworks | JavaScript | Code Quality Tools | ESLint and tick the Run eslint --fix on save checkbox. By default, WebStorm will run ESLint to autofix . js, .


1 Answers

There seems to be a new plugin: eslint-plugin-no-autofix

{
  "plugins": ["no-autofix"],
  "rules": {
    "prefer-const": "off",
    "no-autofix/prefer-const": "warn",
  }
}
like image 109
Alex Avatar answered Sep 29 '22 04:09

Alex