only-export-name
Restrict exports to configured names.
Targeted pattern scope
This rule enforces an allow-list of export names.
It checks:
ExportDefaultDeclarationas namedefaultExportNamedDeclarationnames from specifiers, class/function declarations, and variable declaration identifiers
For export { local as publicName }, the rule validates publicName.
What this rule reports
This rule reports exports whose names are not included in names.
Why this rule exists
This rule is useful for defining strict module contracts (for example, default-only modules or curated public names).
❌ Incorrect
export const value = 1;
with default options (["default"]).
✅ Correct
export default 1;
or:
export const value = 1;
with options:
{
names: ["value"];
}
Behavior and migration notes
This rule reports only and does not provide an autofix.
Default allow-list is ['default'], so named exports are blocked unless
explicitly allowed.
Options
type Options = {
names?: string[];
};
Default:
{ "names": ["default"] }
Additional examples
// config: { names: ["createClient", "default"] }
export function createClient() {}
export default createClient;
// ✅ valid
export const version = "1.0.0";
// ❌ reported unless "version" is added to names
export { buildClient as client };
// checks "client" (exported name), not "buildClient"
ESLint flat config example
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/only-export-name": ["error", { names: ["value"] }],
},
},
];
When not to use it
Disable this rule if exported symbol names do not need to be constrained.
Package documentation
Rule catalog ID: R054
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.