Rule Proposal: no-multi-code-point-character-in-character-class #10049
Labels
accepted
There is consensus among the team that this change meets the criteria for inclusion
archived due to age
This issue has been archived; please open a new issue for any further discussion
feature
This change adds a new feature to ESLint
needs bikeshedding
Minor details about this change need to be discussed
rule
Relates to ESLint's core rules
Please describe what the rule should do:
If RegExp character class has multi-code-point character, it causes unexpected behavior, even if you are using
u
flag.In above example, the
❇️
is made with two code points U+2747 and U+FE0F. JavaScript doesn't handle it as a character, so the character class matches to U+2747 or U+FE0F rather than the character. The U+FE00-FE0F is Variation Selectors.Another well-known case is ZWJ U+200D. ZWJ joins multiple code points to a character.
So, this rule prevents characters which are made with multiple code points in character class syntax.
What category of rule is this? (place an "X" next to just one item)
[X] Warns about a potential error
Provide 2-3 code examples that this rule will warn about:
Why should this rule be included in ESLint (instead of a plugin)?
This is not library specific matter and it's difficult to distinguish whether character class syntax handles the character as one character or not.
The text was updated successfully, but these errors were encountered: