oxc-project/oxc · warning · OxcDiagnostic
Unexpected hexadecimal digits in lowercase.
Error message
Unexpected hexadecimal digits in lowercase.
What it means
Lint diagnostic from oxlint's `unicorn/number-literal-case` rule. Unlike the prefix and exponent checks, hex digits are required to be UPPERCASE for readability, so `0xff` is flagged and `0xFF` is the canonical form. This variant fires when hexadecimal digits are lowercase while the prefix itself is already correct (`0x`).
Source
Thrown at crates/oxc_linter/src/rules/unicorn/number_literal_case.rs:22
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(
"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!(View on GitHub (pinned to e1e7af627c)
Solutions
- Uppercase the hex digits: `0xff0000` -> `0xFF0000`.
- Run `oxlint --fix` to rewrite all lowercase hex digits repo-wide.
- For generated files, exclude the path in `.oxlintrc.json` `ignorePatterns` instead of hand-editing.
- Disable the rule with `"unicorn/number-literal-case": "off"` if lowercase hex is a deliberate project convention.
Example fix
// before const RED = 0xff0000; const MASK = 0xdead_beef; // after const RED = 0xFF0000; const MASK = 0xDEAD_BEEF;
Defensive patterns
Strategy: validation
Validate before calling
// oxlint --fix src/constants/colors.ts // Verify no remaining lowercase-hex violations: // oxlint --deny-warnings unicorn/number-literal-case
Prevention
- Use uppercase hex digits everywhere (`0xFF`, `0xDEAD_BEEF`) even though CSS uses lowercase.
- Keep bitmasks/colors in one constants file that you lint-and-fix once.
- Automate with a pre-commit `oxlint --fix` run.
When it happens
Trigger: Hex literals with lowercase a-f digits: `const red = 0xff0000;`, `let mask = 0xdeadbeef;`. Triggered while oxlint scans files with the unicorn plugin enabled.
Common situations: Color constants, bitmask flags, and hashes are commonly written lowercase (CSS habit, `#ff0000`). Teams adopting oxlint's unicorn category see this on color/flag tables. Also appears in vendored or machine-generated code that was never normalized.
Related errors
- Unexpected number literal prefix in uppercase and hexadecima
- Don't use a zero fraction in the number.
- Don't use a dangling dot in the number.
- Unexpected number literal prefix in uppercase.
- Unexpected exponential notation in uppercase.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/3106b75aa548542c.
Report an issue: GitHub.