source: frontend/node_modules/eslint-plugin-import/docs/rules/no-named-as-default.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.4 KB
Line 
1# import/no-named-as-default
2
3⚠️ This rule _warns_ in the following configs: ☑️ `recommended`, 🚸 `warnings`.
4
5<!-- end auto-generated rule header -->
6
7Reports use of an exported name as the locally imported name of a default export.
8
9Rationale: using an exported name as the name of the default export is likely...
10
11 - _misleading_: others familiar with `foo.js` probably expect the name to be `foo`
12 - _a mistake_: only needed to import `bar` and forgot the brackets (the case that is prompting this)
13
14## Rule Details
15
16Given:
17
18```js
19// foo.js
20export default 'foo';
21export const bar = 'baz';
22```
23
24...this would be valid:
25
26```js
27import foo from './foo.js';
28```
29
30...and this would be reported:
31
32```js
33// message: Using exported name 'bar' as identifier for default export.
34import bar from './foo.js';
35```
36
37For post-ES2015 `export` extensions, this also prevents exporting the default from a referenced module as a name within that module, for the same reasons:
38
39```js
40// valid:
41export foo from './foo.js';
42
43// message: Using exported name 'bar' as identifier for default export.
44export bar from './foo.js';
45```
46
47## Further Reading
48
49 - ECMAScript Proposal: [export ns from]
50 - ECMAScript Proposal: [export default from]
51
52[export ns from]: https://github.com/leebyron/ecmascript-export-ns-from
53[export default from]: https://github.com/leebyron/ecmascript-export-default-from
Note: See TracBrowser for help on using the repository browser.