Skip to content

Commit a627bb6

Browse files
authored
Add no-cycle eslint rule (#247)
* Enable no-cycle eslint rule * Fix cyclic imports * Change no-cycle to error * Add changeset
1 parent ea984a4 commit a627bb6

File tree

8 files changed

+16
-5
lines changed

8 files changed

+16
-5
lines changed

.changeset/angry-points-live.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-resource-router": patch
3+
---
4+
5+
Remove cyclic imports and add eslint rule to stop future issues

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = {
4545
'react-hooks/exhaustive-deps': 'warn',
4646
'react-hooks/rules-of-hooks': 'error',
4747
semi: 'off',
48+
'import/no-cycle': 'error',
4849
},
4950
overrides: [
5051
{

examples/routing-with-resources/about.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22

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

56
import { Link, useQueryParam } from 'react-resource-router';

examples/routing-with-resources/home.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22

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

56
import { Link } from 'react-resource-router';

examples/routing-with-resources/routes.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-cycle */
12
import { About, aboutResource } from './about';
23
import { Home, homeResource } from './home';
34

src/resources/controllers/resource-store/utils/get-resources-for-next-location/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RouterContext } from '../../../../../index';
1+
import { type RouterContext } from '../../../../../index';
22
import {
33
ResourceStoreContext,
44
RouteResource,

src/resources/controllers/use-resource/index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { useCallback, useMemo } from 'react';
22
import { createHook } from 'react-sweet-state';
33

4+
import { type RouterContext } from '../../../common/types';
45
import {
5-
RouterContext,
66
RouterStore,
77
useRouterStoreActions,
8+
} from '../../../controllers/router-store';
9+
import {
810
type EntireRouterState,
911
type AllRouterActions,
10-
} from '../../../index';
12+
} from '../../../controllers/router-store/types';
1113
import {
1214
RouteResource,
1315
RouteResourceResponse,
1416
RouteResourceUpdater,
1517
UseResourceHookResponse,
16-
} from '../../index';
18+
} from '../../common/types';
1719
import { useResourceStore, useResourceStoreActions } from '../resource-store';
1820

1921
type UseResourceOptions = {

src/resources/plugin/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Plugin, RouterContext } from '../../index';
1+
import type { Plugin, RouterContext } from '../../index';
22
import type {
33
ResourceStoreContext,
44
RouteResourceResponse,

0 commit comments

Comments
 (0)