简体   繁体   English

如何快速识别React-Native中的循环依赖

[英]How to quickly identify Circular dependencies in React-Native

In a React-Native project using NPM, is there a quick way to identify Dependency cycle problems (aka when lint gives out an error of "cycle dependency detected"?在使用 NPM 的 React-Native 项目中,有没有一种快速的方法来识别依赖循环问题(也就是当 lint 发出“检测到循环依赖”的错误时?

I am looking for something similar to this: https://spin.atomicobject.com/2018/06/25/circular-dependencies-javascript/ (Or simple to follow instructions on how to use that plugin under react/npm)我正在寻找类似的东西: https://spin.atomicobject.com/2018/06/25/circular-dependencies-javascript/ (或者简单地按照说明如何在 react/npm 下使用该插件)

I currently use the dpdm lib to check for circular dependencies on the react-native project.我目前使用dpdm lib 来检查 react-native 项目的循环依赖关系。

Example:例子:

npx dpdm ./src/* --circular --exit-code circular:1 --warning=false

With error:有错误:

✔ [718/718] Analyze done!
• Circular Dependencies
  01) src/services/index.ts -> src/services/Rating/index.ts

No error:没有错误:

✔ [719/719] Analyze done!
• Circular Dependencies
  ✅ Congratulations, no circular dependency were found in your project.

CircleCI script fails if any circular dependency is found:如果找到任何循环依赖项,CircleCI 脚本将失败:

check-circular-dependency:
executor:
  name: react-native/linux_js
  node_version: '14'
steps:
  - checkout-and-attach-workspace
  - run:
      name: Check for Circular dependency
      command: npx dpdm ./src/* --circular --exit-code circular:1 --warning=false --tree=false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM