---
url: /docs/guide/usage/linter/rules/unicorn/prefer-export-from.md
---

### What it does

When re-exporting from a module, it's unnecessary to import and then export.
It can be done in a single export…from declaration.
This rule encourages using direct re-export syntax (export ... from) instead of importing and then exporting.
It helps reduce boilerplate code and keeps the module scope clean by avoiding unnecessary local bindings.

### Why is this bad?

Separating re-exports into import and export statements is discouraged because it
unnecessarily pollutes the current module's scope and adds redundant boilerplate code.

### Examples

Examples of **incorrect** code for this rule:

```js
import defaultExport from "./foo.js";
export default defaultExport;
```

Examples of **correct** code for this rule:

```js
export { default } from "./foo.js";
```

Examples of **incorrect** code for this rule:

```js
import { named } from "./foo.js";
export { named };
```

Examples of **correct** code for this rule:

```js
export { named } from "./foo.js";
```

## Configuration

This rule accepts a configuration object with the following properties:

### checkUsedVariables

type: `boolean`

default: `true`

When false, if any import binding is used somewhere other than a re-export, all variables in the import declaration are ignored.

## How to use

## Version

This rule was added in v1.70.0.

## References
