{"record":{"id":"02abbb848b2f8836","repo":"oxc-project/oxc","slug":"identifier-name-is-too-short-config-min","errorCode":null,"errorMessage":"Identifier name is too short (< {config_min}).","messagePattern":"Identifier name is too short \\(< (.+?)\\)\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/id_length.rs","lineNumber":25,"sourceCode":"use unicode_segmentation::UnicodeSegmentation;\n\nuse oxc_ast::AstKind;\nuse oxc_ast::ast::{\n    BindingIdentifier, BindingPattern, BindingProperty, IdentifierName, PrivateIdentifier,\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{ContentEq, GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::{AlwaysNever, deserialize_regex_vec},\n};\n\nfn id_length_is_too_short_diagnostic(span: Span, config_min: u64) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Identifier name is too short (< {config_min}).\")).with_label(span)\n}\n\nfn id_length_is_too_long_diagnostic(span: Span, config_max: u64) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Identifier name is too long (> {config_max}).\")).with_label(span)\n}\n\nconst DEFAULT_MAX_LENGTH: u64 = u64::MAX;\nconst DEFAULT_MIN_LENGTH: u64 = 2;\n\n#[derive(Debug, Clone, Default, Deserialize)]\npub struct IdLength(Box<IdLengthConfig>);\n\nimpl Deref for IdLength {\n    type Target = IdLengthConfig;\n\n    fn deref(&self) -> &Self::Target {\n        &self.0\n    }","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/oxc-project/oxc/blob/5b3e33548431073728dcf409f0844851804cae0a/crates/oxc_linter/src/rules/eslint/id_length.rs#L7-L43","documentation":"Reported by the `id-length` rule (ESLint id-length port) when an identifier's name has fewer characters than the configured (or default) minimum. The default configuration in oxc sets `min: 2` and `max: u64::MAX` (crates/oxc_linter/src/rules/eslint/id_length.rs:32-33), so with defaults only single-character names are flagged. It is a style rule aimed at self-documenting names.","triggerScenarios":"Declare or use identifiers of length < min: `let x = 1;`, `for (let i = 0; ...)` with the default min of 2, `const e = new Error()`; or raise the minimum via config `{ \"id-length\": [\"error\", { \"min\": 4 }] }` and keep short names like `err`. The check applies to variable, function, class, and parameter names (with exceptions options available).","commonSituations":"Enabling id-length in an existing repo where loop counters `i`, `j`, `k` and error variable `e` are everywhere; raising `min` beyond the team's actual habits; catching that `exceptions`/`exceptionPatterns` need entries for conventional short names (`x`/`y` in geometry code, `id`, `db`); refactoring generated or math-heavy code full of short symbols.","solutions":["Rename short identifiers to descriptive ones (`x` → `offsetX`, `i` → `rowIndex`) — the primary intent of the rule.","Add conventional short names to the rule's exceptions: `{ \"id-length\": [\"error\", { \"min\": 2, \"exceptions\": [\"x\", \"y\", \"_\"] }] }` (oxlint supports exceptions/exceptionPatterns like ESLint).","Lower `min` (e.g. to 1) or disable the rule if the codebase convention accepts single-character names in loops."],"exampleFix":"// before\nusers.forEach((u, i) => rows[i] = renderRow(u));\n\n// after\nusers.forEach((user, rowIndex) => rows[rowIndex] = renderRow(user));","handlingStrategy":"validation","validationCode":"// Encode your real convention once:\n// .oxlintrc.json -> \"id-length\": [\"error\", { \"min\": 2, \"exceptions\": [\"i\", \"j\", \"x\", \"y\", \"_\"] }]\n// oxlint runs in CI and fails before short names land.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add loop counters and coordinate names to `exceptions` immediately when enabling the rule; they are 90% of real hits.","Raise min gradually (1 → 2 → 3) rather than jumping, so the backlog of renames stays manageable.","For math/graphics code, prefer exceptionPatterns over renames — single letters x/y/z are the correct vocabulary there."],"tags":["eslint","oxlint","style","naming","identifier-length"],"backgroundTag":"naming-convention-lint","analyzedSha":"5b3e33548431073728dcf409f0844851804cae0a","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}