---
title: "import/no-named-export"
description: "Disallow named exports, so that a module only has a default export"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "import"
aliases: ["import-x/no-named-export"]
kind: "suggestion"
category: "style"
default: "off"
fixable: "no"
typeAware: false
deprecated: false
---

Some projects want each file to export one thing, as its default export. This rule reports every other export: `export const`, `export function`, `export { name }`, `export * from` and, in TypeScript, `export type` and `export interface`.

`export { name as default }` is a default export, so it's allowed.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"import/no-named-export" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```js
export const taxRate = 0.2;

export function formatPrice(cents) {
  return `$${(cents / 100).toFixed(2)}`;
}
```

{/* bad {"count": 3} */}
```ts
export * from "./prices";
export type Price = number;
export interface Cart {
  total: Price;
}
```

Not reported:

{/* good */}
```js
export default function formatPrice(cents) {
  return `$${(cents / 100).toFixed(2)}`;
}
```

{/* good */}
```js
const formatPrice = cents => `$${(cents / 100).toFixed(2)}`;

export { formatPrice as default };
```

## When not to use it

This is the opposite of `import/no-default-export`. With both on, a module can't export anything.
