Back to Biomejs

noRedundantDefaultExport

src/content/docs/linter/rules/no-redundant-default-export.mdx

latest3.2 KB
Original Source

import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.14` - Diagnostic Category: [`lint/nursery/noRedundantDefaultExport`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). ## How to configure ```json title="biome.json" { "linter": { "rules": { "nursery": { "noRedundantDefaultExport": "error" } } } }
## Description
Checks if a default export exports the same symbol as a named export.

This rule reports when a `default` export references the same identifier as a named export.
Re-exports are out of scope.

## Examples

### Invalid

```js
export const foo = 42;
export default foo;
<pre class="language-text"><code class="language-text">code-block.js:2:16 <a href="https://biomejs.dev/linter/rules/no-redundant-default-export">lint/nursery/noRedundantDefaultExport</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ <strong><span style="color: Orange;">⚠</span></strong> <span style="color: Orange;">Default export exports the same symbol as a named export.</span> <strong>1 │ </strong>export const foo = 42; <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong>export default foo; <strong> │ </strong> <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong> <strong>3 │ </strong> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Exporting the same identifier as both a named export and a default export is redundant.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Remove either the default export or the named export to avoid redundancy.</span> <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit </span><span style="color: lightgreen;"><a href="https://biomejs.dev/linter/#nursery">https://biomejs.dev/linter/#nursery</a></span><span style="color: lightgreen;"> for more information.</span> </code></pre>

Valid

js
export const foo = 42;
export default 42;
</TabItem> </Tabs>