![](/img/trans.png)
[英]Disable ESLint for webpack.config.js file on Visual Studio Code
[英]Cascading eslint config file
我对级联 eslint 配置文件有几个问题:
tsconfig.json
(在打字稿中)那样使用 eslint,我有一个根.eslintrc.yml
并且我可以将它扩展/级联到每个文件夹(项目)的每个.eslintrc.yml
吗? 我不确定这是否是这里的文档所说的。extends
选项的情况下如何工作,有时顺序很重要,例如在他们的文档中提到的eslint-config-prettier
的情况下。 那里说:确保把它放在最后,这样它就有机会覆盖其他配置。
plugins
选项,顺序并不重要,但在extends
时,有时顺序很重要,就像我在问题 #2 中提到的那样。extends
选项的顺序很重要,当我有像eslint-plugin-prettier
这样的扩展时,我如何确保它遵循顺序,当我不使用级联时它应该是最后一个。 例如:如果我不使用级联,它应该像这里提到的那样:
extends:
- "some-other-config-you-use"
- "prettier"
- "prettier/@typescript-eslint"
- "prettier/react"
如果我使用级联,我的设置将是这样的:
# root
root: true
parser: "@typescript-eslint/parser"
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/recommended"
- "prettier"
- "prettier/@typescript-eslint"
# sub-folder
env:
browser: true
extends:
- "plugins:react/recommended"
- "plugins:jsx-a11y/recommended"
- "prettier/react"
root: true
parser: "@typescript-eslint/parser"
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/recommended"
- “./path/your_other_config”
- "prettier"
- "prettier/@typescript-eslint"
与此相关,我在子目录中创建.eslintrc.js
文件后遇到了错误:
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config
解决方案是在根配置中指定ignorePatterns: ['.eslintrc.js'],
如此处所述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.