source: frontend/node_modules/eslint-plugin-import/docs/rules/no-internal-modules.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[9af201e]1# import/no-internal-modules
2
3<!-- end auto-generated rule header -->
4
5Use this rule to prevent importing the submodules of other modules.
6
7## Rule Details
8
9This rule has two mutally exclusive options that are arrays of [minimatch/glob patterns](https://github.com/isaacs/node-glob#glob-primer) patterns:
10
11 - `allow` that include paths and import statements that can be imported with reaching.
12 - `forbid` that exclude paths and import statements that can be imported with reaching.
13
14### Examples
15
16Given the following folder structure:
17
18```pt
19my-project
20├── actions
21│ └── getUser.js
22│ └── updateUser.js
23├── reducer
24│ └── index.js
25│ └── user.js
26├── redux
27│ └── index.js
28│ └── configureStore.js
29└── app
30│ └── index.js
31│ └── settings.js
32└── entry.js
33```
34
35And the .eslintrc file:
36
37```json
38{
39 ...
40 "rules": {
41 "import/no-internal-modules": [ "error", {
42 "allow": [ "**/actions/*", "source-map-support/*" ],
43 } ]
44 }
45}
46```
47
48The following patterns are considered problems:
49
50```js
51/**
52 * in my-project/entry.js
53 */
54
55import { settings } from './app/index'; // Reaching to "./app/index" is not allowed
56import userReducer from './reducer/user'; // Reaching to "./reducer/user" is not allowed
57import configureStore from './redux/configureStore'; // Reaching to "./redux/configureStore" is not allowed
58
59export { settings } from './app/index'; // Reaching to "./app/index" is not allowed
60export * from './reducer/user'; // Reaching to "./reducer/user" is not allowed
61```
62
63The following patterns are NOT considered problems:
64
65```js
66/**
67 * in my-project/entry.js
68 */
69
70import 'source-map-support/register';
71import { settings } from '../app';
72import getUser from '../actions/getUser';
73
74export * from 'source-map-support/register';
75export { settings } from '../app';
76```
77
78Given the following folder structure:
79
80```pt
81my-project
82├── actions
83│ └── getUser.js
84│ └── updateUser.js
85├── reducer
86│ └── index.js
87│ └── user.js
88├── redux
89│ └── index.js
90│ └── configureStore.js
91└── app
92│ └── index.js
93│ └── settings.js
94└── entry.js
95```
96
97And the .eslintrc file:
98
99```json
100{
101 ...
102 "rules": {
103 "import/no-internal-modules": [ "error", {
104 "forbid": [ "**/actions/*", "source-map-support/*" ],
105 } ]
106 }
107}
108```
109
110The following patterns are considered problems:
111
112```js
113/**
114 * in my-project/entry.js
115 */
116
117import 'source-map-support/register';
118import getUser from '../actions/getUser';
119
120export * from 'source-map-support/register';
121export getUser from '../actions/getUser';
122```
123
124The following patterns are NOT considered problems:
125
126```js
127/**
128 * in my-project/entry.js
129 */
130
131import 'source-map-support';
132import { getUser } from '../actions';
133
134export * from 'source-map-support';
135export { getUser } from '../actions';
136```
Note: See TracBrowser for help on using the repository browser.