File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
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
+ ```
You can’t perform that action at this time.
0 commit comments