Skip to content

Commit 123ea7e

Browse files
authored
docs: update rule README
1 parent e4833d5 commit 123ea7e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

docs/rules/no-parent-barrel-import.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
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";
1416
export * 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

1922
export const X = T.X;
2023

@@ -32,7 +35,8 @@ export * from "./bar";
3235
export * 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

3741
export 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

0 commit comments

Comments
 (0)