Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(identifier): add ZWSP to is_irregular_whitespace #6662

Merged
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
13 changes: 6 additions & 7 deletions crates/oxc_syntax/src/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ const MMSP: char = '\u{205f}';

const IDEOGRAPHIC_SPACE: char = '\u{3000}';

// https://eslint.org/docs/latest/rules/no-irregular-whitespace#rule-details
#[rustfmt::skip]
pub fn is_irregular_whitespace(c: char) -> bool {
matches!(
c,
VT | FF | NBSP | ZWNBSP | NEL | OGHAM_SPACE_MARK | EN_QUAD
..ZWSP | NNBSP | MMSP | IDEOGRAPHIC_SPACE
matches!(c,
VT | FF | NBSP | ZWNBSP | NEL | OGHAM_SPACE_MARK
| EN_QUAD..=ZWSP | NNBSP | MMSP | IDEOGRAPHIC_SPACE
)
}

// https://github.com/microsoft/TypeScript/blob/b8e4ed8aeb0b228f544c5736908c31f136a9f7e3/src/compiler/scanner.ts#L556
// TODO: Unclear why we match `ZWSP` here, and not in `is_irregular_whitespace`.
// https://github.com/oxc-project/oxc/pull/6639
pub fn is_white_space_single_line(c: char) -> bool {
// Note: nextLine is in the Zs space, and should be considered to be a whitespace.
// It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript.
matches!(c, SP | TAB | ZWSP) || is_irregular_whitespace(c)
matches!(c, SP | TAB) || is_irregular_whitespace(c)
}

// 11.3 Line Terminators
Expand Down
Loading