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
- Rewrite the literal as `0xFF` (lowercase prefix, uppercase digits).
- Run `oxlint --fix` and review the diff, since both prefix and digits change.
- Suppress the line with `// oxlint-disable-next-line unicorn/number-literal-case` for literals that must remain byte-identical (e.g. test fixtures).
- 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
- Normalize numeric literal style once repo-wide with `oxlint --fix`, then keep it enforced in CI with `--deny-warnings`.
- Exclude test fixtures that must preserve byte-exact literals via `ignorePatterns`.
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
- Unexpected number literal prefix in uppercase.
- Unexpected exponential notation in uppercase.
- Unexpected hexadecimal digits in lowercase.
- Don't use a zero fraction in the number.
- Don't use a dangling dot in the number.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/de034fda705a6210.
Report an issue: GitHub.