2 title: no-misleading-character-class
10 Unicode includes the characters which are made with multiple code points.
11 RegExp character class syntax (`/[abc]/`) cannot handle characters which are made by multiple code points as a character; those characters will be dissolved to each code point. For example, `❇️` is made by `❇` (`U+2747`) and VARIATION SELECTOR-16 (`U+FE0F`). If this character is in RegExp character class, it will match to either `❇` (`U+2747`) or VARIATION SELECTOR-16 (`U+FE0F`) rather than `❇️`.
13 This rule reports the regular expressions which include multiple code point characters in character class syntax. This rule considers the following characters as multiple code point characters.
15 **A character with combining characters:**
17 The combining characters are characters which belong to one of `Mc`, `Me`, and `Mn` [Unicode general categories](http://www.unicode.org/L2/L1999/UnicodeData.html#General%20Category).
20 /^[Á]$/u.test("Á") //→ false
21 /^[❇️]$/u.test("❇️") //→ false
24 **A character with Emoji modifiers:**
27 /^[👶🏻]$/u.test("👶🏻") //→ false
28 /^[👶🏽]$/u.test("👶🏽") //→ false
31 **A pair of regional indicator symbols:**
34 /^[🇯🇵]$/u.test("🇯🇵") //→ false
37 **Characters that ZWJ joins:**
40 /^[👨👩👦]$/u.test("👨👩👦") //→ false
43 **A surrogate pair without Unicode flag:**
46 /^[👍]$/.test("👍") //→ false
48 // Surrogate pair is OK if with u flag.
49 /^[👍]$/u.test("👍") //→ true
54 This rule reports the regular expressions which include multiple code point characters in character class syntax.
56 Examples of **incorrect** code for this rule:
61 /*eslint no-misleading-character-class: error */
73 Examples of **correct** code for this rule:
78 /*eslint no-misleading-character-class: error */
88 You can turn this rule off if you don't want to check RegExp character class syntax for multiple code point characters.