Skip to content

Commit

Permalink
Add no-cycle eslint rule (#247)
Browse files Browse the repository at this point in the history
* Enable no-cycle eslint rule

* Fix cyclic imports

* Change no-cycle to error

* Add changeset
  • Loading branch information
nicholas-l authored Nov 7, 2024
1 parent ea984a4 commit a627bb6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-points-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-resource-router": patch
---

Remove cyclic imports and add eslint rule to stop future issues
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = {
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
semi: 'off',
'import/no-cycle': 'error',
},
overrides: [
{
Expand Down
1 change: 1 addition & 0 deletions examples/routing-with-resources/about.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line import/no-cycle
import { homeRoute } from './routes';

import { Link, useQueryParam } from 'react-resource-router';
Expand Down
1 change: 1 addition & 0 deletions examples/routing-with-resources/home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';

// eslint-disable-next-line import/no-cycle
import { aboutRoute } from './routes';

import { Link } from 'react-resource-router';
Expand Down
1 change: 1 addition & 0 deletions examples/routing-with-resources/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-cycle */
import { About, aboutResource } from './about';
import { Home, homeResource } from './home';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RouterContext } from '../../../../../index';
import { type RouterContext } from '../../../../../index';
import {
ResourceStoreContext,
RouteResource,
Expand Down
8 changes: 5 additions & 3 deletions src/resources/controllers/use-resource/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { useCallback, useMemo } from 'react';
import { createHook } from 'react-sweet-state';

import { type RouterContext } from '../../../common/types';
import {
RouterContext,
RouterStore,
useRouterStoreActions,
} from '../../../controllers/router-store';
import {
type EntireRouterState,
type AllRouterActions,
} from '../../../index';
} from '../../../controllers/router-store/types';
import {
RouteResource,
RouteResourceResponse,
RouteResourceUpdater,
UseResourceHookResponse,
} from '../../index';
} from '../../common/types';
import { useResourceStore, useResourceStoreActions } from '../resource-store';

type UseResourceOptions = {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, RouterContext } from '../../index';
import type { Plugin, RouterContext } from '../../index';
import type {
ResourceStoreContext,
RouteResourceResponse,
Expand Down

0 comments on commit a627bb6

Please sign in to comment.