{"record":{"id":"9b47a4234aadd380","repo":"oxc-project/oxc","slug":"unexpected-dangling-in-name","errorCode":null,"errorMessage":"Unexpected dangling '_' in '`{name}`'.","messagePattern":"Unexpected dangling '_' in '`(.+?)`'\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"info","filePath":"crates/oxc_linter/src/rules/eslint/no_underscore_dangle.rs","lineNumber":24,"sourceCode":"    ast::{\n        BindingIdentifier, Expression, FunctionType, PrivateFieldExpression, PropertyKey,\n        StaticMemberExpression,\n    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::NodeId;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode,\n    ast_util::variable_declaration_kind,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_underscore_dangle_diagnostic(span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Unexpected dangling '_' in '`{name}`'.\"))\n        .with_help(format!(\"Remove the dangling '_' or add `{name}` to the 'allow' configuration.\"))\n        .with_label(span)\n}\n\n#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoUnderscoreDangleConfig {\n    /// Whether to allow dangling underscores in members of the `super` object.\n    allow_after_super: bool,\n    /// Whether to allow dangling underscores in members of the `this.constructor` object.\n    allow_after_this_constructor: bool,\n    /// An array of variable names that are allowed to have dangling underscores.\n    allow: Vec<String>,\n    /// Whether to allow dangling underscores in members of the `this` object.\n    allow_after_this: bool,\n    /// Whether to allow dangling underscores in variable names assigned by array destructuring.\n    allow_in_array_destructuring: bool,\n    /// Whether to allow dangling underscores in variable names assigned by object destructuring.","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_underscore_dangle.rs#L6-L42","documentation":"`no-underscore-dangle` flags identifiers and member expressions with leading or trailing underscores (the \"dangling\" underscore), e.g. `this._internal`, `name_`. It reports the exact name in the message and suggests the `allow` config. The rule is highly configurable: `allow` (name list), `allowAfterThis`, `allowAfterSuper`, `allowAfterThisConstructor`, `allowInArrayDestructuring` / `allowInObjectDestructuring` (default true), `allowFunctionParams` (default true), `allowInUsingDeclarations`, plus `enforceInClassFields` / `enforceInMethodNames` to require underscores.","triggerScenarios":"Accessing private-by-convention members `obj._foo`, `this._cache`, naming variables `index_` or `_count` — reported unless covered by one of the allow options or listed in `allow`.","commonSituations":"Calling third-party/library APIs that expose underscore-prefixed methods; teams whose convention actually uses `_` for private fields (then the rule should be off or configured); destructuring `const { _internal } = obj;` after someone disabled the destructuring allowances.","solutions":["Rename your own identifier to drop the dangling underscore.","For library members you cannot rename, add the names to `allow` or enable `allowAfterThis` / `allowAfterSuper`.","If the team convention embraces underscore-privates, disable the rule instead of fighting it."],"exampleFix":"// before\nclass Store {\n  _cache = new Map();\n  get(key) {\n    return this._cache.get(key);\n  }\n}\n\n// after\nclass Store {\n  #cache = new Map(); // real private field\n  get(key) {\n    return this.#cache.get(key);\n  }\n}","handlingStrategy":"validation","validationCode":"# CI gate; tune config (allow, allowAfterThis, ...) instead of suppressing case by case\nnpx oxlint src/ # rules: { \"eslint/no-underscore-dangle\": [\"warn\", { \"allow\": [\"_internal\"] }] }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use real private class fields (#field) instead of underscore conventions.","Configure `allow` for third-party underscore APIs you must call.","Align the rule config with the team's actual naming convention before enabling."],"tags":["eslint","oxlint","no-underscore-dangle","style","naming-convention","identifiers"],"backgroundTag":"naming-convention-violation","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}