{"record":{"id":"adf8c73be6fbd62f","repo":"oxc-project/oxc","slug":"unexpected-number-literal-prefix-in-uppercase","errorCode":null,"errorMessage":"Unexpected number literal prefix in uppercase.","messagePattern":"Unexpected number literal prefix in uppercase\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/unicorn/number_literal_case.rs","lineNumber":10,"sourceCode":"use cow_utils::CowUtils;\nuse oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn uppercase_prefix(span: Span, prefix: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected number literal prefix in uppercase.\")\n        .with_help(format!(\"Use lowercase for the number literal prefix `{prefix}`.\"))\n        .with_label(span)\n}\n\nfn uppercase_exponential_notation(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected exponential notation in uppercase.\")\n        .with_help(\"Use lowercase for `e` in exponential notations.\")\n        .with_label(span)\n}\n\nfn lowercase_hexadecimal_digits(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected hexadecimal digits in lowercase.\")\n        .with_help(\"Use uppercase for hexadecimal digits.\")\n        .with_label(span)\n}\n\nfn uppercase_prefix_and_lowercase_hexadecimal_digits(span: Span, prefix: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/number_literal_case.rs#L1-L28","documentation":"This is a lint diagnostic from oxlint's `unicorn/number-literal-case` rule (ported from ESLint plugin unicorn). The rule enforces a consistent number literal style: lowercase base prefixes (`0x`, `0b`, `0o`), lowercase `e` in exponents, and uppercase hex digits. This specific variant fires when a numeric literal uses an uppercase prefix such as `0X1A` or `0B101n` instead of the lowercase form.","triggerScenarios":"Any parsed Numeric or BigInt literal whose base prefix letters are uppercase, e.g. `const mask = 0XFF;`, `let b = 0B1010;`, `const big = 0O777n;`. Fires during `oxlint` runs on .js/.ts/.jsx/.tsx files when the unicorn plugin and this rule are enabled (it is on in the `unicorn` category).","commonSituations":"Code generated by tools or transpilers that emit uppercase prefixes, hand-written code copied from older specs/docs that used `0X`, or enabling the stricter oxlint unicorn category (e.g. migrating from default oxlint config to `\"categories\": {\"unicorn\": \"error\"}`). Often appears in bulk when a repo adopts oxlint for the first time.","solutions":["Change the literal prefix to lowercase: `0X1A` -> `0x1A` (keep hex digits uppercase).","Run `oxlint --fix` (the rule ships an autofix) to rewrite all offending literals at once.","If the style is intentional repo-wide, disable the rule: add `\"unicorn/number-literal-case\": \"off\"` to `.oxlintrc.json`.","Add an inline suppression for one line: `// oxlint-disable-next-line unicorn/number-literal-case`."],"exampleFix":"// before\nconst mask = 0XFF;\nconst big = 0B1010n;\n\n// after\nconst mask = 0xFF;\nconst big = 0b1010n;","handlingStrategy":"validation","validationCode":"// Before committing, run the linter with autofix on changed files:\n// oxlint --fix src/\n// CI gate (fails the build on violations):\n// oxlint --deny-warnings src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `oxlint --fix` in a pre-commit hook so literal casing is normalized automatically.","Configure your editor's format-on-save with oxlint's LSP so `0X` prefixes are flagged as you type.","Keep generated/vendored code out of lint with `ignorePatterns` in `.oxlintrc.json`."],"tags":["oxlint","unicorn","style","numeric-literal","autofix"],"backgroundTag":"lint-rule-violation","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}