# unicorn/no-anonymous-default-export

> Require a name for a function or class that is the default export

A default export without a name gives you nothing to search for, and every file that imports it makes up its own name. Stack traces show it as `default` or `<anonymous>`.

The rule looks at functions and classes, in `export default` and in `module.exports =`. Other values, such as objects and numbers, aren't reported.

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

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

## Examples

Reported:

{/* bad */}
```js
export default function (user) {
  return `${user.first} ${user.last}`;
}
```

{/* bad */}
```js
export default (user) => `${user.first} ${user.last}`;
```

{/* bad */}
```js
module.exports = class {
  items = [];
};
```

Not reported:

{/* good */}
```js
export default function fullName(user) {
  return `${user.first} ${user.last}`;
}
```

An arrow function doesn't have a name. Give it one with a variable:

{/* good */}
```js
const fullName = (user) => `${user.first} ${user.last}`;

export default fullName;
```

{/* good */}
```js
module.exports = class Cart {
  items = [];
};
```
