no-underscore-export
Disallow underscore-prefixed named exports.
Targeted pattern scopeโ
This rule reports underscore-prefixed identifiers exported via named export declarations.
It targets:
- exported function declarations,
- exported
declare functiondeclarations, - exported variable declarator identifiers.
What this rule reportsโ
This rule reports exported declarations whose identifier starts with _.
Why this rule existsโ
Underscore prefixes are often used for non-public/internal symbols. This rule prevents exposing those symbols as part of named exports.
โ Incorrectโ
export const _x = 1;
export function _f() {}
โ Correctโ
export const x = 1;
export function f() {}
Behavior and migration notesโ
This rule reports only and does not provide an autofix.
Migration is usually renaming exported symbols or keeping underscore-prefixed values unexported.
Optionsโ
This rule has no options.
Additional examplesโ
const _internal = 1;
export { _internal };
// โ
currently not reported by this rule's selector coverage
export const _apiToken = "x";
// โ reported
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-underscore-export": "error",
},
},
];
When not to use itโ
Disable this rule if underscore-prefixed exports are part of your public API conventions.
Package documentationโ
Rule catalog ID: R044
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.