File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
<!-- end auto-generated rule header -->
4
4
5
- Forbid a module from importing from parent barrel file. This often leads to runtime error ` Cannot read ... of undefined ` .
5
+ Forbid a module from importing from parent barrel file, as it often leads to runtime error ` Cannot read ... of undefined ` .
6
+
7
+ It resolves the missing circular import check from [ ` no-self-import ` ] , while being computationally cheap (see [ ` no-cycle ` ] ).
6
8
7
9
## Rule Details
8
10
@@ -14,7 +16,8 @@ export * from "./bar";
14
16
export * from " ./baz" ;
15
17
16
18
// foo/bar.ts (cannot read property `X` of undefined)
17
- import { T } from ' ..' ;
19
+ import { T } from ' @foo' ; // absolute
20
+ import { T } from ' ..' ; // relative
18
21
19
22
export const X = T .X ;
20
23
@@ -32,7 +35,8 @@ export * from "./bar";
32
35
export * from " ./baz" ;
33
36
34
37
// foo/bar.ts (relative import for code in `foo/`)
35
- import { T } from " ./baz" ;
38
+ import { T } from " @foo/baz" ; // absolute
39
+ import { T } from " ./baz" ; // relative
36
40
37
41
export const X = T .X ;
38
42
@@ -41,3 +45,11 @@ export enum T {
41
45
X = "..."
42
46
}
43
47
```
48
+
49
+ ## Further Reading
50
+
51
+ - [ Related Discussion] ( https://github.com/import-js/eslint-plugin-import/pull/2318#issuecomment-1027807460 )
52
+ - Rule to detect that module imports itself: [ ` no-self-import ` ] , [ ` no-cycle ` ]
53
+
54
+ [ `no-self-import` ] : ./no-self-import.md
55
+ [ `no-cycle` ] : ./no-cycle.md
You can’t perform that action at this time.
0 commit comments