2 title: no-misleading-character-class
11 Unicode includes the characters which are made with multiple code points.
12 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 `❇️`.
14 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.
16 **A character with combining characters:**
18 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).
21 /^[Á]$/u.test("Á") //→ false
22 /^[❇️]$/u.test("❇️") //→ false
25 **A character with Emoji modifiers:**
28 /^[👶🏻]$/u.test("👶🏻") //→ false
29 /^[👶🏽]$/u.test("👶🏽") //→ false
32 **A pair of regional indicator symbols:**
35 /^[🇯🇵]$/u.test("🇯🇵") //→ false
38 **Characters that ZWJ joins:**
41 /^[👨👩👦]$/u.test("👨👩👦") //→ false
44 **A surrogate pair without Unicode flag:**
47 /^[👍]$/.test("👍") //→ false
49 // Surrogate pair is OK if with u flag.
50 /^[👍]$/u.test("👍") //→ true
55 This rule reports the regular expressions which include multiple code point characters in character class syntax.
57 Examples of **incorrect** code for this rule:
62 /*eslint no-misleading-character-class: error */
74 Examples of **correct** code for this rule:
79 /*eslint no-misleading-character-class: error */
89 You can turn this rule off if you don't want to check RegExp character class syntax for multiple code point characters.