ESLint ignore specific rule for a specific directory

前端 未结 5 2172
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 02:35

Is it possible with ESLint to ignore one specific rule for an entire directory?

In my case, I would like to ignore import/prefer-default-export for a di

5条回答
  •  伪装坚强ぢ
    2020-12-08 02:41

    ESLint configuration (.eslintrc) files are hierarchical:

    ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem. This option is useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file.

    You can disable the import/prefer-default-export rule for the commonComponents directory by creating a .eslintrc file with the following content in that directory:

    {
        "rules": {
            "import/prefer-default-export": "off"
        }
    }
    

提交回复
热议问题