oxc-project/oxc · error · OxcDiagnostic
Unexpected joined character sequence in character class.
Error message
Unexpected joined character sequence in character class.
What it means
Lint diagnostic from eslint/no-misleading-character-class (zwj_sequences): a character class contains characters joined by ZWJ (U+200D), such as family or rainbow-flag emoji. A character class matches only the individual atoms, never the joined sequence as a whole, so the regex silently fails to match the intended emoji.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_misleading_character_class.rs:60
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)]
pub struct NoMisleadingCharacterClass {
/// When set to `true`, the rule allows any grouping of code points
/// inside a character class as long as they are written using escape sequences.
///
/// Examples of **incorrect** code for this rule with `{ "allowEscape": true }`:
/// ```javascript
/// /[\uD83D]/; // backslash can be omitted
/// new RegExp("[\ud83d" + "\udc4d]");
/// ```
///
/// Examples of **correct** code for this rule with `{ "allowEscape": true }`:
/// ```javascriptView on GitHub (pinned to e1e7af627c)
Solutions
- Use Unicode code point escapes (e.g. \u{1F468}\u{200D}\u{1F469}) for the full joined sequence
- Move the ZWJ sequence out of the character class into the pattern
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/eslint/no_misleading_character_class.rs:60 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/4ad7e6ebb92563d0.
Report an issue: GitHub.