Skip to content

Commit f8bc33b

Browse files
authored
feat: add README
1 parent cb926b1 commit f8bc33b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# import/no-parent-barrel-import
2+
3+
<!-- end auto-generated rule header -->
4+
5+
Forbid a module from importing from parent barrel file. This often leads to runtime error `Cannot read ... of undefined`.
6+
7+
## Rule Details
8+
9+
### Fail
10+
11+
```js
12+
// foo/index.ts
13+
export * from "./bar";
14+
export * from "./baz";
15+
16+
// foo/bar.ts (cannot read property `X` of undefined)
17+
import { T } from '..';
18+
19+
export const X = T.X;
20+
21+
// foo/baz.ts
22+
export enum T {
23+
X = "..."
24+
}
25+
```
26+
27+
### Pass
28+
29+
```js
30+
// foo/index.ts
31+
export * from "./bar";
32+
export * from "./baz";
33+
34+
// foo/bar.ts (relative import for code in `foo/`)
35+
import { T } from "./baz";
36+
37+
export const X = T.X;
38+
39+
// foo/baz.ts
40+
export enum T {
41+
X = "..."
42+
}
43+
```

0 commit comments

Comments
 (0)