# import/no-anonymous-default-export

> Disallow default exports that have no name

You can't search for a default export that has no name, and each importing file makes up its own name for it. An anonymous function or class also shows up without a useful name in stack traces and dev tools. Give the value a name first, then export it.

Functions, classes, arrow functions, objects, arrays, literals and `new` expressions are reported. The result of a call, as in `export default defineConfig({})`, is allowed by default.

{/* 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-anonymous-default-export" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"import/no-anonymous-default-export" = ["error", {
  allowAnonymousFunction = false,
  allowAnonymousClass = false,
  allowArrowFunction = false,
  allowObject = false,
  allowArray = false,
  allowLiteral = false,
  allowNew = false,
  allowCallExpression = true,
}]
```

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

## Examples

Reported:

{/* bad */}
```js
export default function () {
  return "ok";
}
```

{/* bad */}
```js
export default items => items.length;
```

{/* bad */}
```js
export default { port: 3000 };
```

Not reported:

{/* good */}
```js
export default function status() {
  return "ok";
}
```

{/* good */}
```js
const config = { port: 3000 };

export default config;
```

{/* good */}
```js
export default defineConfig({ port: 3000 });
```

## Options

| Option | Default | What it allows |
| --- | --- | --- |
| `allowAnonymousFunction` | `false` | `export default function () {}` |
| `allowAnonymousClass` | `false` | `export default class {}` |
| `allowArrowFunction` | `false` | `export default () => {}` |
| `allowObject` | `false` | `export default { port: 3000 }` |
| `allowArray` | `false` | `export default [1, 2]` |
| `allowLiteral` | `false` | `export default 42`, strings, template literals, regular expressions, `true`, `null` |
| `allowNew` | `false` | `export default new Server()` |
| `allowCallExpression` | `true` | `export default createServer()` |

{/* good {"options": [{"allowObject": true}]} */}
```js
export default { port: 3000 };
```

{/* bad {"options": [{"allowCallExpression": false}]} */}
```js
export default defineConfig({ port: 3000 });
```
