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 22
33<!-- end auto-generated rule header -->
44
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 ` ] ).
68
79## Rule Details
810
@@ -14,7 +16,8 @@ export * from "./bar";
1416export * from " ./baz" ;
1517
1618// foo/bar.ts (cannot read property `X` of undefined)
17- import { T } from ' ..' ;
19+ import { T } from ' @foo' ; // absolute
20+ import { T } from ' ..' ; // relative
1821
1922export const X = T .X ;
2023
@@ -32,7 +35,8 @@ export * from "./bar";
3235export * from " ./baz" ;
3336
3437// 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
3640
3741export const X = T .X ;
3842
@@ -41,3 +45,11 @@ export enum T {
4145 X = "..."
4246}
4347```
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