source: frontend/node_modules/eslint-plugin-import/docs/rules/default.md

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

Fix frontend appearance

  • Property mode set to 100644
File size: 2.0 KB
Line 
1# import/default
2
3💼 This rule is enabled in the following configs: ❗ `errors`, ☑️ `recommended`.
4
5<!-- end auto-generated rule header -->
6
7If a default import is requested, this rule will report if there is no default
8export in the imported module.
9
10For [ES7], reports if a default is named and exported but is not found in the
11referenced module.
12
13Note: for packages, the plugin will find exported names
14from [`jsnext:main`], if present in `package.json`.
15Redux's npm module includes this key, and thereby is lintable, for example.
16
17A module path that is [ignored] or not [unambiguously an ES module] will not be reported when imported.
18
19[ignored]: ../README.md#importignore
20[unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar
21
22## Rule Details
23
24Given:
25
26```js
27// ./foo.js
28export default function () { return 42 }
29
30// ./bar.js
31export function bar() { return null }
32
33// ./baz.js
34module.exports = function () { /* ... */ }
35
36// node_modules/some-module/index.js
37exports.sharedFunction = function shared() { /* ... */ }
38```
39
40The following is considered valid:
41
42```js
43import foo from './foo'
44
45// assuming 'node_modules' are ignored (true by default)
46import someModule from 'some-module'
47```
48
49...and the following cases are reported:
50
51```js
52import bar from './bar' // no default export found in ./bar
53import baz from './baz' // no default export found in ./baz
54```
55
56## When Not To Use It
57
58If you are using CommonJS and/or modifying the exported namespace of any module at
59runtime, you will likely see false positives with this rule.
60
61This rule currently does not interpret `module.exports = ...` as a `default` export,
62either, so such a situation will be reported in the importing module.
63
64## Further Reading
65
66 - Lee Byron's [ES7] export proposal
67 - [`import/ignore`] setting
68 - [`jsnext:main`] (Rollup)
69
70[ES7]: https://github.com/leebyron/ecmascript-more-export-from
71[`import/ignore`]: ../../README.md#importignore
72[`jsnext:main`]: https://github.com/rollup/rollup/wiki/jsnext:main
Note: See TracBrowser for help on using the repository browser.