atlassian-labs / react-resource-router

Configuration driven routing solution for React SPAs that manages route matching, data fetching and progressive rendering
https://atlassian-labs.github.io/react-resource-router
Apache License 2.0
200 stars 28 forks source link

Add no-cycle eslint rule #247

Open nicholas-l opened 2 hours ago

nicholas-l commented 2 hours ago

We are trying to mock our imports of react-resource-router using snippet below, however due to the cyclic import of react-resource-router, we are getting a "Cannot read properties of undefined (reading 'ResourceDependencyError')". I believe this is due to the cyclic imports that means when Jest tries to import the actual module, and then when the submodules in react-resource-router imports the root index file, this file points to the Jest mock which has not been fully set up. This causes an property of undefined error.

jest.mock('react-resource-router', () => ({
   ...jest.requireActual('react-resource-router'),
   useRouter: jest.fn(),
});
changeset-bot[bot] commented 2 hours ago

⚠️ No Changeset found

Latest commit: 87bfb508a2352898e03b5b30926795678995a03c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR