Skip to content

Commit 7bee061

Browse files
committed
chore: forbid rc deep imports
1 parent b57ecd0 commit 7bee061

4 files changed

Lines changed: 30 additions & 8 deletions

File tree

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
const base = require('@umijs/fabric/dist/eslint');
22

3+
const restrictedPackageDirectoryImports = [
4+
'@rc-component/*/es',
5+
'@rc-component/*/es/**',
6+
'@rc-component/*/lib',
7+
'@rc-component/*/lib/**',
8+
'rc-*/es',
9+
'rc-*/es/**',
10+
'rc-*/lib',
11+
'rc-*/lib/**',
12+
];
13+
314
module.exports = {
415
...base,
516
rules: {
617
...base.rules,
18+
'no-restricted-imports': [
19+
'error',
20+
{
21+
patterns: [
22+
{
23+
group: restrictedPackageDirectoryImports,
24+
message: 'Do not import package internals from es/lib. Import from the package root.',
25+
},
26+
],
27+
},
28+
],
729
'react/no-find-dom-node': 0,
830
'jsx-a11y/label-has-associated-control': 0,
931
'jsx-a11y/label-has-for': 0,

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"tsc": "tsc --noEmit"
3636
},
3737
"dependencies": {
38-
"@rc-component/util": "^1.3.0"
38+
"@rc-component/util": "^1.11.0"
3939
},
4040
"devDependencies": {
4141
"@rc-component/father-plugin": "^2.0.2",
@@ -45,10 +45,12 @@
4545
"@types/react": "^18.0.0",
4646
"@types/react-dom": "^18.0.0",
4747
"@types/warning": "^3.0.0",
48+
"@typescript-eslint/eslint-plugin": "^5.62.0",
49+
"@typescript-eslint/parser": "^5.62.0",
4850
"@umijs/fabric": "^4.0.0",
4951
"dumi": "^2.0.15",
5052
"eslint": "^8.54.0",
51-
"eslint-plugin-jest": "^28.2.0",
53+
"eslint-plugin-jest": "^27.9.0",
5254
"eslint-plugin-unicorn": "^52.0.0",
5355
"father": "^4.0.0",
5456
"rc-test": "^7.0.14",
@@ -57,7 +59,7 @@
5759
"typescript": "^5.0.2"
5860
},
5961
"peerDependencies": {
60-
"react": ">=16.9.0",
61-
"react-dom": ">=16.9.0"
62+
"react": ">=18.0.0",
63+
"react-dom": ">=18.0.0"
6264
}
6365
}

src/Immutable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { supportRef } from '@rc-component/util/lib/ref';
1+
import { supportRef } from '@rc-component/util';
22
import * as React from 'react';
33

44
export type CompareProps<T extends React.ComponentType<any>> = (

src/context.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import useEvent from '@rc-component/util/lib/hooks/useEvent';
2-
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
3-
import isEqual from '@rc-component/util/lib/isEqual';
1+
import { isEqual, useEvent, useLayoutEffect } from '@rc-component/util';
42
import * as React from 'react';
53
import { unstable_batchedUpdates } from 'react-dom';
64

0 commit comments

Comments
 (0)