blob: 8d99c35299db3bd26d34cd4d66eb459251172f82 [file] [log] [blame] [view]
Tim van der Lippefdbd42e2020-04-07 14:14:361# import/no-internal-modules
2
3Use this rule to prevent importing the submodules of other modules.
4
5## Rule Details
6
7This rule has one option, `allow` which is an array of [minimatch/glob patterns](https://github.com/isaacs/node-glob#glob-primer) patterns that whitelist paths and import statements that can be imported with reaching.
8
9### Examples
10
11Given the following folder structure:
12
13```
14my-project
15├── actions
16│ └── getUser.js
17│ └── updateUser.js
18├── reducer
19│ └── index.js
20│ └── user.js
21├── redux
22│ └── index.js
23│ └── configureStore.js
24└── app
25│ └── index.js
26│ └── settings.js
27└── entry.js
28```
29
30And the .eslintrc file:
31```
32{
33 ...
34 "rules": {
35 "import/no-internal-modules": [ "error", {
36 "allow": [ "**/actions/*", "source-map-support/*" ]
37 } ]
38 }
39}
40```
41
42The following patterns are considered problems:
43
44```js
45/**
46 * in my-project/entry.js
47 */
48
49import { settings } from './app/index'; // Reaching to "./app/index" is not allowed
50import userReducer from './reducer/user'; // Reaching to "./reducer/user" is not allowed
51import configureStore from './redux/configureStore'; // Reaching to "./redux/configureStore" is not allowed
52```
53
54The following patterns are NOT considered problems:
55
56```js
57/**
58 * in my-project/entry.js
59 */
60
61import 'source-map-support/register';
62import { settings } from '../app';
63import getUser from '../actions/getUser';
64```