如何解决将 .eslintrc 重定位到父级后,ESLint 找不到配置“prettier/@typescript-eslint”
我有一个类似的文件夹结构
parentFolder > componentA
> componentB
> componentC
每个组件都有一个 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/@typescript-eslint
在 eslint-config-prettier
v8.0.0 中已成为 removed。只需从您的 ESLint 配置文件中删除它。现在,为了使 Prettier 和 ESLint 不发生冲突,extends
中唯一需要的条目是 "prettier"
(确保它是 extends
中的最后一个)。
当我更新到 eslint-config-prettier 8.0.0 时遇到了同样的错误,我通过将 .eslintrc.js 更改为:
Traceback (most recent call last):
File "mode.py",line 10,in <module>
libm = ctypes.cdll.LoadLibrary(r'/usr/lib/x86_64-linux-gnu/libm.so')
File "/anaconda/envs/phat/lib/python3.6/ctypes/__init__.py",line 426,in LoadLibrary
return self._dlltype(name)
File "/anaconda/envs/phat/lib/python3.6/ctypes/__init__.py",line 348,in __init__
self._handle = _dlopen(self._name,mode)
OSError: /usr/lib/x86_64-linux-gnu/libm.so: invalid ELF header
确保您的 package.json 包含:
"plugins": ['@typescript-eslint'],"extends": ["eslint:recommended","plugin:@typescript-eslint/recommended"]
您当然可以包含其他插件和其他扩展,您可以找到所有选项:https://www.npmjs.com/package/@typescript-eslint/eslint-plugin
,prettier/@typescript-eslint
已在 eslint-config-prettier
v8.0.0
见https://github.com/prettier/eslint-config-prettier/issues/173
从 v8 开始,有更简单的配置。不幸的是,互联网上仍有许多 How-To 提到旧的配置文件,这些文件现已全部消失。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。