source: frontend/node_modules/eslint-plugin-import/docs/rules/no-import-module-exports.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: 1.7 KB
Line 
1# import/no-import-module-exports
2
3🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
4
5<!-- end auto-generated rule header -->
6
7Reports the use of import declarations with CommonJS exports in any module
8except for the [main module](https://docs.npmjs.com/files/package.json#main).
9
10If you have multiple entry points or are using `js:next` this rule includes an
11`exceptions` option which you can use to exclude those files from the rule.
12
13## Options
14
15### `exceptions`
16
17 - An array of globs. The rule will be omitted from any file that matches a glob
18 in the options array. For example, the following setting will omit the rule
19 in the `some-file.js` file.
20
21```json
22"import/no-import-module-exports": ["error", {
23 "exceptions": ["**/*/some-file.js"]
24}]
25```
26
27## Rule Details
28
29### Fail
30
31```js
32import { stuff } from 'starwars'
33module.exports = thing
34
35import * as allThings from 'starwars'
36exports.bar = thing
37
38import thing from 'other-thing'
39exports.foo = bar
40
41import thing from 'starwars'
42const baz = module.exports = thing
43console.log(baz)
44```
45
46### Pass
47
48Given the following package.json:
49
50```json
51{
52 "main": "lib/index.js",
53}
54```
55
56```js
57import thing from 'other-thing'
58export default thing
59
60const thing = require('thing')
61module.exports = thing
62
63const thing = require('thing')
64exports.foo = bar
65
66import thing from 'otherthing'
67console.log(thing.module.exports)
68
69// in lib/index.js
70import foo from 'path';
71module.exports = foo;
72
73// in some-file.js
74// eslint import/no-import-module-exports: ["error", {"exceptions": ["**/*/some-file.js"]}]
75import foo from 'path';
76module.exports = foo;
77```
78
79### Further Reading
80
81 - [webpack issue #4039](https://github.com/webpack/webpack/issues/4039)
Note: See TracBrowser for help on using the repository browser.