|
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:
1.2 KB
|
| Line | |
|---|
| 1 | # import/no-default-export
|
|---|
| 2 |
|
|---|
| 3 | <!-- end auto-generated rule header -->
|
|---|
| 4 |
|
|---|
| 5 | Prohibit default exports. Mostly an inverse of [`prefer-default-export`].
|
|---|
| 6 |
|
|---|
| 7 | [`prefer-default-export`]: ./prefer-default-export.md
|
|---|
| 8 |
|
|---|
| 9 | ## Rule Details
|
|---|
| 10 |
|
|---|
| 11 | The following patterns are considered warnings:
|
|---|
| 12 |
|
|---|
| 13 | ```javascript
|
|---|
| 14 | // bad1.js
|
|---|
| 15 |
|
|---|
| 16 | // There is a default export.
|
|---|
| 17 | export const foo = 'foo';
|
|---|
| 18 | const bar = 'bar';
|
|---|
| 19 | export default 'bar';
|
|---|
| 20 | ```
|
|---|
| 21 |
|
|---|
| 22 | ```javascript
|
|---|
| 23 | // bad2.js
|
|---|
| 24 |
|
|---|
| 25 | // There is a default export.
|
|---|
| 26 | const foo = 'foo';
|
|---|
| 27 | export { foo as default }
|
|---|
| 28 | ```
|
|---|
| 29 |
|
|---|
| 30 | The following patterns are not warnings:
|
|---|
| 31 |
|
|---|
| 32 | ```javascript
|
|---|
| 33 | // good1.js
|
|---|
| 34 |
|
|---|
| 35 | // There is only a single module export and it's a named export.
|
|---|
| 36 | export const foo = 'foo';
|
|---|
| 37 | ```
|
|---|
| 38 |
|
|---|
| 39 | ```javascript
|
|---|
| 40 | // good2.js
|
|---|
| 41 |
|
|---|
| 42 | // There is more than one named export in the module.
|
|---|
| 43 | export const foo = 'foo';
|
|---|
| 44 | export const bar = 'bar';
|
|---|
| 45 | ```
|
|---|
| 46 |
|
|---|
| 47 | ```javascript
|
|---|
| 48 | // good3.js
|
|---|
| 49 |
|
|---|
| 50 | // There is more than one named export in the module
|
|---|
| 51 | const foo = 'foo';
|
|---|
| 52 | const bar = 'bar';
|
|---|
| 53 | export { foo, bar }
|
|---|
| 54 | ```
|
|---|
| 55 |
|
|---|
| 56 | ```javascript
|
|---|
| 57 | // export-star.js
|
|---|
| 58 |
|
|---|
| 59 | // Any batch export will disable this rule. The remote module is not inspected.
|
|---|
| 60 | export * from './other-module'
|
|---|
| 61 | ```
|
|---|
| 62 |
|
|---|
| 63 | ## When Not To Use It
|
|---|
| 64 |
|
|---|
| 65 | If you don't care if default imports are used, or if you prefer default imports over named imports.
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.