5

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"?

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)

1
  • I am trying to find something that works with react-native too, but maybe github.com/acrazing/dpdm can work with shellscript + husky, as this might throw and exit code when a circular dependency problem is found npx dpdm ./src/* --circular --exit-code circular:1 --warning false May 11, 2021 at 22:31

1 Answer 1

5

I currently use the dpdm lib to check for circular dependencies on the react-native project.

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:

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.