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.