|
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-mutable-exports
|
|---|
| 2 |
|
|---|
| 3 | <!-- end auto-generated rule header -->
|
|---|
| 4 |
|
|---|
| 5 | Forbids the use of mutable exports with `var` or `let`.
|
|---|
| 6 |
|
|---|
| 7 | ## Rule Details
|
|---|
| 8 |
|
|---|
| 9 | Valid:
|
|---|
| 10 |
|
|---|
| 11 | ```js
|
|---|
| 12 | export const count = 1
|
|---|
| 13 | export function getCount() {}
|
|---|
| 14 | export class Counter {}
|
|---|
| 15 | ```
|
|---|
| 16 |
|
|---|
| 17 | ...whereas here exports will be reported:
|
|---|
| 18 |
|
|---|
| 19 | ```js
|
|---|
| 20 | export let count = 2
|
|---|
| 21 | export var count = 3
|
|---|
| 22 |
|
|---|
| 23 | let count = 4
|
|---|
| 24 | export { count } // reported here
|
|---|
| 25 | ```
|
|---|
| 26 |
|
|---|
| 27 | ## Functions/Classes
|
|---|
| 28 |
|
|---|
| 29 | Note that exported function/class declaration identifiers may be reassigned,
|
|---|
| 30 | but are not flagged by this rule at this time. They may be in the future, if a
|
|---|
| 31 | reassignment is detected, i.e.
|
|---|
| 32 |
|
|---|
| 33 | ```js
|
|---|
| 34 | // possible future behavior!
|
|---|
| 35 | export class Counter {} // reported here: exported class is reassigned on line [x].
|
|---|
| 36 | Counter = KitchenSink // not reported here unless you enable no-class-assign
|
|---|
| 37 |
|
|---|
| 38 | // this pre-declaration reassignment is valid on account of function hoisting
|
|---|
| 39 | getCount = function getDuke() {} // not reported here without no-func-assign
|
|---|
| 40 | export function getCount() {} // reported here: exported function is reassigned on line [x].
|
|---|
| 41 | ```
|
|---|
| 42 |
|
|---|
| 43 | To prevent general reassignment of these identifiers, exported or not, you may
|
|---|
| 44 | want to enable the following core ESLint rules:
|
|---|
| 45 |
|
|---|
| 46 | - [no-func-assign]
|
|---|
| 47 | - [no-class-assign]
|
|---|
| 48 |
|
|---|
| 49 | [no-func-assign]: https://eslint.org/docs/rules/no-func-assign
|
|---|
| 50 | [no-class-assign]: https://eslint.org/docs/rules/no-class-assign
|
|---|
| 51 |
|
|---|
| 52 | ## When Not To Use It
|
|---|
| 53 |
|
|---|
| 54 | If your environment correctly implements mutable export bindings.
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.