Skip to main content

sort-export-specifiers

Enforce alphabetical sorting of named export specifiers.

Targeted pattern scopeโ€‹

This rule inspects ExportNamedDeclaration nodes that have at least two ExportSpecifier entries.

Specifiers are sorted alphabetically by exported name.

What this rule reportsโ€‹

This rule reports named export declarations whose specifier order is not alphabetical.

It includes an autofix that rewrites the specifier segment.

Why this rule existsโ€‹

Alphabetical export lists are easier to scan and reduce merge conflict noise.

โŒ Incorrectโ€‹

export { zebra, alpha };

โœ… Correctโ€‹

export { alpha, zebra };

Behavior and migration notesโ€‹

This rule is fixable.

Because the fixer rewrites text in the specifier range, review --fix changes carefully when using alias exports or complex formatting.

Optionsโ€‹

This rule has no options.

Additional examplesโ€‹

export { C, A, B };
// โŒ reported, auto-fixed to A, B, C

export { A, B, C };
// โœ… valid

ESLint flat config exampleโ€‹

import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/sort-export-specifiers": "error",
},
},
];

When not to use itโ€‹

Disable this rule if export ordering is intentionally semantic rather than alphabetical.

Package documentationโ€‹

Rule catalog ID: R069

Further readingโ€‹

Adoption resourcesโ€‹

  • Start at warning level in CI, then move to error after cleanup.
  • Use focused codemods/autofix batches per package or directory.