我有一个文件夹结构像
parentFolder > componentA
> componentB
> componentC
Run Code Online (Sandbox Code Playgroud)
每个组件都有一个 package.json,它定义了一个 yarn lint 命令(eslint "myFilter" --no-error-on-unmatched-pattern)。每个组件都有自己的 .eslintrc 和 .prettierrc
当我在 componentA/B/C 文件夹中并运行 yarn lint 时,它按预期工作。
由于每个组件文件夹中的所有 .eslintrc 都是相同的,我将文件移到 parentFolder 下并删除组件文件夹中的副本。当我调用 yarn lint 时,它使用了 parentFolder 中的 .eslintrc,但是,我收到一个错误。
哎呀!出了些问题!:(
ESLint:6.8.0。
ESLint 找不到要扩展的配置“prettier/@typescript-eslint”。请检查配置名称是否正确。
我将 .prettierrc 移动到父文件夹,但是,它找不到它。我该怎么办?谢谢
更新:我注意到如果我在父文件夹中的 package.json 上添加 prettier 并运行 yarn install,它可以工作。但是,我不知道这是否是正确的方法。
tho*_*rn̈ 48
prettier/@typescript-eslint已在v8.0.0 中删除eslint-config-prettier。只需从您的 ESLint 配置文件中删除它。现在唯一extends需要让 Prettier 和 ESLint 不冲突的条目是"prettier"(确保它是 中的最后一个extends)。
当我更新到 eslint-config-prettier 8.0.0 时,我遇到了同样的错误,我通过将 .eslintrc.js 更改为:
"plugins": ['@typescript-eslint'],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
Run Code Online (Sandbox Code Playgroud)
确保您的 package.json 包括:
@typescript-eslint/eslint-plugin
@typescript-eslint/parser
Run Code Online (Sandbox Code Playgroud)
您当然可以包含其他插件和其他扩展,您可以找到所有选项:https ://www.npmjs.com/package/@typescript-eslint/eslint-plugin
prettier/@typescript-eslint在eslint-config-prettierv8.0.0 中被移除
见https://github.com/prettier/eslint-config-prettier/issues/173
从 v8 开始,有更简单的配置。不幸的是,Internet 上仍有许多 How-To 提到旧的配置文件,这些文件现在都已消失。
| 归档时间: |
|
| 查看次数: |
16556 次 |
| 最近记录: |