ESLint忽略特定目录的特定规则 [英] ESLint ignore specific rule for a specific directory
问题描述
ESLint是否可以忽略整个目录的一条特定规则?
对于我来说,我想忽略 import /首选
commonComponents
ESLint会自动在文件目录中查找它们,以以及在连续的父目录中一直到文件系统的根目录。如果您希望为项目的不同部分进行不同的配置,或者希望其他人能够直接使用ESLint而不需要记住传递配置文件,则此选项很有用。
您可以为 commonComponents $ c $禁用
import / prefer-default-export
规则c>目录,方法是创建一个 .eslintrc
文件,该文件在该目录中包含以下内容:
{
规则:{
import / prefer-default-export: off
}
}
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 directory named commonComponents
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"
}
}
这篇关于ESLint忽略特定目录的特定规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!