oxc-project/oxc · error · OxcDiagnostic

Unexpected emoji modifier in character class.

Error message

Unexpected emoji modifier in character class.

What it means

Lint diagnostic from eslint/no-misleading-character-class (emoji_modifier_sequences): a regex character class contains an emoji modifier sequence (base + skin-tone modifier). Without the u flag such characters are treated as lone UTF-16 code units, so the class matches fragments of the intended emoji rather than the sequence.

Source

Thrown at crates/oxc_linter/src/rules/eslint/no_misleading_character_class.rs:48

    OxcDiagnostic::warn("Unexpected surrogate pair in character class.")
        .with_help("Use Unicode code point escapes (e.g., \\u{1F44D}) instead of surrogate pairs.")
        .with_label(span)
}

fn surrogate_pair_without_flag_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected surrogate pair in character class.")
        .with_help("Add the Unicode flag 'u'.")
        .with_label(span)
}

fn combining_class_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected combining class in character class.")
        .with_help("Replace the character with its normalized form (NFC) or use Unicode code point escapes instead of combining sequences.")
        .with_label(span)
}

fn emoji_modifiers_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected emoji modifier in character class.")
        .with_help("Use Unicode code point escapes (e.g., \\u{1F3FB} for the light skin tone modifier) instead of emoji modifier sequences in character classes.")
        .with_label(span)
}

fn regional_indicator_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected regional indicator in character class.")
        .with_help("Use Unicode code point escapes (e.g., \\u{1F1EF} for the regional indicator symbol for 'J') instead of regional indicator symbol pairs in character classes.")
        .with_label(span)
}

fn zwj_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected joined character sequence in character class.")
        .with_help("Use Unicode code point escapes (e.g., \\u{1F468}\\u200D\\u{1F469} for '👨‍👩') instead of zero-width joiner sequences in character classes.")
        .with_label(span)
}

#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Use Unicode code point escapes such as \u{1F3FB} for the modifier
  2. Add the u flag to the regex so modifiers are matched as complete code points
  3. Move the emoji sequence outside the character class if matching the full sequence
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/eslint/no_misleading_character_class.rs:48 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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