Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,17 @@ impl<'ast> Visit<'ast> for CharacterSequenceCollector<'ast> {
self.sequences.push(std::mem::take(&mut self.current_seq));
self.current_seq.push(&range.max);
}
CharacterClassContents::ClassStringDisjunction(_) => {


CharacterClassContents::ClassStringDisjunction(_) // \q{...}
| CharacterClassContents::UnicodePropertyEscape(_) // \p{...}
| CharacterClassContents::NestedCharacterClass(_) // [[]] nested character class
| CharacterClassContents::CharacterClassEscape(_) // \d, \w, etc.
=> {
if !self.current_seq.is_empty() {
self.sequences.push(std::mem::take(&mut self.current_seq));
}
}
_ => {}
}
}

Expand Down Expand Up @@ -449,6 +454,8 @@ fn test() {
r#"RegExp(`[\uD83D\uDC4D]`) // Backslash + "uD83D" + Backslash + "uDC4D""#,
Some(serde_json::json!([{ "allowEscape": true }])),
),
// https://github.com/oxc-project/oxc/issues/19090
(r"/[\u200c\u200d\p{ID_Continue}.]/u", None),
];

let fail = vec![
Expand Down Expand Up @@ -638,6 +645,9 @@ fn test() {
// r#"const pattern = "[\x41\u0301]"; RegExp(pattern);"#,
// Some(serde_json::json!([{ "allowEscape": true }])),
// ),
// https://github.com/oxc-project/oxc/issues/19090 -- without u flag it should fail
// this should not be a `UnicodePropertyEscape`
(r"/[\u200c\u200d\p{ID_Continue}.]/", None),
];

Tester::new(NoMisleadingCharacterClass::NAME, NoMisleadingCharacterClass::PLUGIN, pass, fail)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: crates/oxc_linter/src/tester.rs
---

⚠ eslint(no-misleading-character-class): Unexpected surrogate pair in character class.
╭─[no_misleading_character_class.tsx:1:10]
1 │ var r = /[👍]/
Expand Down Expand Up @@ -775,3 +774,9 @@ source: crates/oxc_linter/src/tester.rs
1 │ RegExp(`[\👍]`) // Backslash + U+D83D + U+DC4D
· ─────
╰────

⚠ eslint(no-misleading-character-class): Unexpected joined character sequence in character class.
╭─[no_misleading_character_class.tsx:1:2]
1 │ /[\u200c\u200d\p{ID_Continue}.]/
· ──────────────────────────────
╰────
Loading