typescript - Eslint 'rxjs/operators' 应该列在项目的依赖中
问题描述
所以我的文件中有这个导入
import { catchError, finalize } from 'rxjs/operators';
当我运行 eslint 我得到这个错误:
error 'rxjs/operators' should be listed in the project's dependencies. Run 'npm i -S rxjs/operators' to add it import/no-extraneous-dependencies
我在 package.json 依赖项列表中有 rxjs,但似乎 eslint 认为 'rxjs/operators' 是另一个包。
在我的 eslintrc 文件中,我有这个规则:
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": ["**/*.test.ts", "**/*.test.tsx"]
}
],
解决方案
我遇到了同样的问题并修复了以下问题:通过 添加
...
"settings": {
"import/core-modules": ["rxjs/operators"]
},
...
在我的.eslintrc.json配置文件中。
推荐阅读
- c# - 为什么调试构建会导致多一个变量?
- rabbitmq - 将 Node-RED 连接到 RabbitMQ 优先级队列?
- ruby-on-rails - Rails SSE 不适用于 Unicorn 服务器
- angular -
不是离子 4 中的已知元素 - android - 任务 ':app:processDebugResources' 执行失败。> Android 资源链接失败
- laravel - 此请求目前无法通过 localhost 处理错误
- python - 使用 python-3 在 HTML 字符串中搜索类名
- google-bigquery - Big-Query 中非空值的“错误双值”错误
- mysql - 从表中执行查询并根据结果执行另一个查询?
- nginx - 通过 Nginx 更改代理的响应头