![](/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.