{"record":{"id":"969e4fd3ecaa37dc","repo":"oxc-project/oxc","slug":"use-uppercase-characters-for-the-value-of-the-esca","errorCode":null,"errorMessage":"Use uppercase characters for the value of the escape sequence.","messagePattern":"Use uppercase characters for the value of the escape sequence\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/unicorn/escape_case.rs","lineNumber":13,"sourceCode":"use std::str::Chars;\n\nuse oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode, context::LintContext, rule::Rule, utils::is_string_raw_tagged_template_expression,\n};\n\nfn escape_case_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Use uppercase characters for the value of the escape sequence.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct EscapeCase;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforces defining escape sequence values with uppercase characters rather than lowercase ones.\n    /// This promotes readability by making the escaped value more distinguishable from the identifier.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Using lowercase characters in escape sequences makes them less readable and harder to distinguish\n    /// from surrounding code. Most style guides recommend uppercase for consistency and clarity.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/escape_case.rs#L1-L31","documentation":"Diagnostic from oxlint's `unicorn/escape-case` rule. It requires uppercase hex digits in escape sequences: `\\xXX`, `\\uXXXX`, and `\\u{X...}` escapes in string literals, plus `\\cX` control escapes in regular expression literals. The scanner walks each string's raw text (skipping `String.raw`-tagged templates) and each regex literal; any lowercase a-f in the escape value is flagged, and the autofix uppercases the value in place.","triggerScenarios":"`const foo = \"\\xa9\";`, `\"\\ud834\"`, `\"\\u{1d306}\"`, or the regex `/\\ca/` — any escape sequence whose hex digits include lowercase characters in a non-raw string or regex literal.","commonSituations":"Hand-typed color/unicode escapes in older code; ANSI escape strings (`\\x1b` vs `\\x1B`); enabling the unicorn pedantic preset and normalizing a legacy codebase.","solutions":["Uppercase the hex digits: `\\xA9`, `\\uD834`, `\\u{1D306}`, `/\\cA/`.","Run `oxlint --fix` once to normalize every literal in the project.","Keep `String.raw` templates for text that must preserve raw escapes."],"exampleFix":"// before\nconst foo = \"\\xa9\";\n// after\nconst foo = \"\\xA9\";","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write hex escapes uppercase: `\\xA9`, `\\uD834`, `\\u{1D306}`, `/\\cA/`.","Run `oxlint --fix` once when enabling the rule to normalize all existing literals.","Keep raw escape sequences in `String.raw` tagged templates, which the rule skips."],"tags":["oxlint","lint","unicorn","strings","regex","style"],"backgroundTag":"escape-sequence-case","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"}