我对级联 eslint 配置文件有几个问题:
- 我可以像
tsconfig.json
那样使用 eslint(在 typescript 中),我有一个根.eslintrc.yml
并且我可以将它扩展/级联到每个.eslintrc.yml
每个文件夹(项目)?我不确定这是否是文档所说的 here . - 如果我可以扩展根配置文件,它如何在
extends
选项的情况下工作,有时顺序很重要,例如eslint-config-prettier
如他们的 docs 所述.上面写着:
Make sure to put it last, so it gets the chance to override other configs.
- 如果我的理解正确,请纠正我,使用
plugins
选项时,顺序并不重要,但在extends
中,有时顺序很重要,就像我在问题 #2 中提到的那样。 - 如果
extends
选项中的顺序很重要,当我有像eslint-plugin-prettier
这样的扩展时,我如何确保它遵循顺序当我不使用级联时它应该是最后一个。例如:
如果我不使用级联,它应该像提到的那样here :
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"
关于visual-studio-code - 级联eslint配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62225824/