oxc-project/oxc · warning · OxcDiagnostic

Unexpected number literal prefix in uppercase.

Error message

Unexpected number literal prefix in uppercase.

What it means

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.

Source

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

use cow_utils::CowUtils;
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{AstNode, context::LintContext, rule::Rule};

fn uppercase_prefix(span: Span, prefix: &str) -> OxcDiagnostic {
    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(

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Change the literal prefix to lowercase: `0X1A` -> `0x1A` (keep hex digits uppercase).
  2. Run `oxlint --fix` (the rule ships an autofix) to rewrite all offending literals at once.
  3. If the style is intentional repo-wide, disable the rule: add `"unicorn/number-literal-case": "off"` to `.oxlintrc.json`.
  4. Add an inline suppression for one line: `// oxlint-disable-next-line unicorn/number-literal-case`.

Example fix

// before
const mask = 0XFF;
const big = 0B1010n;

// after
const mask = 0xFF;
const big = 0b1010n;
Defensive patterns

Strategy: validation

Validate before calling

// Before committing, run the linter with autofix on changed files:
// oxlint --fix src/
// CI gate (fails the build on violations):
// oxlint --deny-warnings src/

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


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