oxc-project/oxc · warning · OxcDiagnostic

Unexpected number literal prefix in uppercase and hexadecima

Error message

Unexpected number literal prefix in uppercase and hexadecimal digits in lowercase.

What it means

Lint diagnostic from oxlint's `unicorn/number-literal-case` rule; the combined variant. A single literal breaks both halves of the canonical style at once: the base prefix is uppercase (`0X`) AND the hexadecimal digits are lowercase (`ff`). The canonical form is `0xFF` — lowercase prefix, uppercase digits.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/number_literal_case.rs:28

    OxcDiagnostic::warn("Unexpected number literal prefix in uppercase.")
        .with_help(format!("Use lowercase for the number literal prefix `{prefix}`."))
        .with_label(span)
}

fn uppercase_exponential_notation(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected exponential notation in uppercase.")
        .with_help("Use lowercase for `e` in exponential notations.")
        .with_label(span)
}

fn lowercase_hexadecimal_digits(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected hexadecimal digits in lowercase.")
        .with_help("Use uppercase for hexadecimal digits.")
        .with_label(span)
}

fn uppercase_prefix_and_lowercase_hexadecimal_digits(span: Span, prefix: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(
        "Unexpected number literal prefix in uppercase and hexadecimal digits in lowercase.",
    )
    .with_help(format!(
        "Use lowercase for the number literal prefix `{prefix}` and uppercase for hexadecimal digits."
    ))
    .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct NumberLiteralCase;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// This rule enforces proper case for numeric literals.
    ///
    /// ### Why is this bad?
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Rewrite the literal as `0xFF` (lowercase prefix, uppercase digits).
  2. Run `oxlint --fix` and review the diff, since both prefix and digits change.
  3. Suppress the line with `// oxlint-disable-next-line unicorn/number-literal-case` for literals that must remain byte-identical (e.g. test fixtures).
  4. Disable the rule in `.oxlintrc.json` if the project intentionally keeps another style.

Example fix

// before
const magic = 0Xff;

// after
const magic = 0xFF;
Defensive patterns

Strategy: validation

Validate before calling

// oxlint --fix .
// Fail CI on any number-literal-case violation:
// oxlint --deny-warnings --filter unicorn/number-literal-case .

Prevention

When it happens

Trigger: Hex literals like `0Xff`, `0Xab_cd`, or bigint variants `0Xffn` — uppercase prefix with lowercase a-f digits. Reported during oxlint runs with the unicorn plugin active.

Common situations: Typical when code is transcribed from datasheets or older documentation that wrote hex as `0Xff`. Because two violations coexist in one literal, autofix output may change more characters than expected — review diffs on generated constant tables.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/de034fda705a6210. Report an issue: GitHub.