blob: 0a92b7b5174747a73055f5d89d230ec12a07f150 [file] [log] [blame] [view]
Tim van der Lippefdbd42e2020-04-07 14:14:361# import/no-named-as-default
2
3Reports use of an exported name as the locally imported name of a default export.
4
5Rationale: using an exported name as the name of the default export is likely...
6
7- *misleading*: others familiar with `foo.js` probably expect the name to be `foo`
8- *a mistake*: only needed to import `bar` and forgot the brackets (the case that is prompting this)
9
10## Rule Details
11
12Given:
13```js
14// foo.js
15export default 'foo';
16export const bar = 'baz';
17```
18
19...this would be valid:
20```js
21import foo from './foo.js';
22```
23
24...and this would be reported:
25```js
26// message: Using exported name 'bar' as identifier for default export.
27import bar from './foo.js';
28```
29
30For post-ES2015 `export` extensions, this also prevents exporting the default from a referenced module as a name within that module, for the same reasons:
31
32```js
33// valid:
34export foo from './foo.js'
35
36// message: Using exported name 'bar' as identifier for default export.
37export bar from './foo.js';
38```
39
40## Further Reading
41
42- ECMAScript Proposal: [export ns from]
43- ECMAScript Proposal: [export default from]
44
45[export ns from]: https://github.com/leebyron/ecmascript-export-ns-from
46[export default from]: https://github.com/leebyron/ecmascript-export-default-from