|
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.4 KB
|
| Line | |
|---|
| 1 | # import/no-named-export
|
|---|
| 2 |
|
|---|
| 3 | <!-- end auto-generated rule header -->
|
|---|
| 4 |
|
|---|
| 5 | Prohibit named exports. Mostly an inverse of [`no-default-export`].
|
|---|
| 6 |
|
|---|
| 7 | [`no-default-export`]: ./no-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 only a single module export and it's a named export.
|
|---|
| 17 | export const foo = 'foo';
|
|---|
| 18 | ```
|
|---|
| 19 |
|
|---|
| 20 | ```javascript
|
|---|
| 21 | // bad2.js
|
|---|
| 22 |
|
|---|
| 23 | // There is more than one named export in the module.
|
|---|
| 24 | export const foo = 'foo';
|
|---|
| 25 | export const bar = 'bar';
|
|---|
| 26 | ```
|
|---|
| 27 |
|
|---|
| 28 | ```javascript
|
|---|
| 29 | // bad3.js
|
|---|
| 30 |
|
|---|
| 31 | // There is more than one named export in the module.
|
|---|
| 32 | const foo = 'foo';
|
|---|
| 33 | const bar = 'bar';
|
|---|
| 34 | export { foo, bar }
|
|---|
| 35 | ```
|
|---|
| 36 |
|
|---|
| 37 | ```javascript
|
|---|
| 38 | // bad4.js
|
|---|
| 39 |
|
|---|
| 40 | // There is more than one named export in the module.
|
|---|
| 41 | export * from './other-module'
|
|---|
| 42 | ```
|
|---|
| 43 |
|
|---|
| 44 | ```javascript
|
|---|
| 45 | // bad5.js
|
|---|
| 46 |
|
|---|
| 47 | // There is a default and a named export.
|
|---|
| 48 | export const foo = 'foo';
|
|---|
| 49 | const bar = 'bar';
|
|---|
| 50 | export default 'bar';
|
|---|
| 51 | ```
|
|---|
| 52 |
|
|---|
| 53 | The following patterns are not warnings:
|
|---|
| 54 |
|
|---|
| 55 | ```javascript
|
|---|
| 56 | // good1.js
|
|---|
| 57 |
|
|---|
| 58 | // There is only a single module export and it's a default export.
|
|---|
| 59 | export default 'bar';
|
|---|
| 60 | ```
|
|---|
| 61 |
|
|---|
| 62 | ```javascript
|
|---|
| 63 | // good2.js
|
|---|
| 64 |
|
|---|
| 65 | // There is only a single module export and it's a default export.
|
|---|
| 66 | const foo = 'foo';
|
|---|
| 67 | export { foo as default }
|
|---|
| 68 | ```
|
|---|
| 69 |
|
|---|
| 70 | ```javascript
|
|---|
| 71 | // good3.js
|
|---|
| 72 |
|
|---|
| 73 | // There is only a single module export and it's a default export.
|
|---|
| 74 | export default from './other-module';
|
|---|
| 75 | ```
|
|---|
| 76 |
|
|---|
| 77 | ## When Not To Use It
|
|---|
| 78 |
|
|---|
| 79 | If you don't care if named imports are used, or if you prefer named imports over default imports.
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.