close

export

Added in v0.9.4

Configuration

PresetConfigured Value
✅ importPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, importPlugin } from '@rslint/core';

export default defineConfig([
  importPlugin.configs.recommended,
  {
    rules: {
      'import/export': 'error',
    },
  },
]);

Rule Details

Reports duplicate named or default exports, including conflicts introduced by export *. Every conflicting occurrence is reported because the rule cannot determine which export was intended.

This rule is enabled in importPlugin.configs.recommended.

Examples of incorrect code for this rule:

export default class MyClass {}
export default makeClass;
export const foo = function () {};

function bar() {}
export { bar as foo };

Examples of correct code for this rule:

export const foo = "foo";
export const bar = "bar";
export const Foo = 1;
export type Foo = number;

export function parse(value: string): string;
export function parse(value: number): string;
export function parse(value: string | number): string {
  return String(value);
}

The rule checks each TypeScript namespace or ambient module declaration separately. It permits function overload signatures and namespace merging with functions, classes, and enums, following upstream behavior.

A star re-export also reports when its target has no named exports. Default exports are excluded from export *. Unresolved, ignored, and non-ES modules are skipped.

Options

This rule has no options. It does not provide automatic fixes or suggestions.

Differences from upstream

Diagnostics for invalid dependency syntax can differ from ESLint. For example, if dependency.js contains return; export {};, then export * from "./dependency.js" reports "No named exports found" in Rslint, while ESLint's default configuration reports a parse error. Check and fix the dependency's syntax before investigating missing exports.

Original Documentation