no-underscore-export
Disallow underscore-prefixed named exports.
Deprecated
- Lifecycle: Deprecated, frozen, and non-recommended.
- Deprecated since:
v3.0.0 - Available until:
v4.0.0 - Use instead: ESLint core
no-restricted-exports
Configure the replacement with restrictedNamedExportsPattern: "^_" to retain
this rule's underscore-prefix policy.
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: R060
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.