noMisleadingCharacterClass (since v1.5.0)
Diagnostic Category: lint/suspicious/noMisleadingCharacterClass
Sources:
- Same as: 
no-misleading-character-class 
Disallow characters made with multiple code points in character class syntax.
Unicode includes the characters which are made with multiple code points. e.g. Á, 🇯🇵, 👨👩👦.
A RegExp character class /[abc]/ cannot handle characters with multiple code points.
For example, the character ❇️ consists of two code points: ❇ (U+2747) and VARIATION SELECTOR-16 (U+FE0F).
If this character is in a RegExp character class, it will match to either ❇ or VARIATION SELECTOR-16 rather than ❇️.
This rule reports the regular expressions which include multiple code point characters in character class syntax.
Examples
Section titled ExamplesInvalid
Section titled Invalid/^[Á]$/u;code-block.js:1:1 lint/suspicious/noMisleadingCharacterClass ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Unexpected combined character in the character class.
  
  > 1 │ /^[Á]$/u;
      │ ^^^^^^^^
    2 │ 
  
/^[❇️]$/u;code-block.js:1:1 lint/suspicious/noMisleadingCharacterClass ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Unexpected combined character in the character class.
  
  > 1 │ /^[❇️]$/u;
      │ ^^^^^^^^
    2 │ 
  
/^[👶🏻]$/u;code-block.js:1:1 lint/suspicious/noMisleadingCharacterClass ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Unexpected modified Emoji in the character class. 
  
  > 1 │ /^[👶🏻]$/u;
      │ ^^^^^^^^^^^
    2 │ 
  
/^[🇯🇵]$/u;code-block.js:1:1 lint/suspicious/noMisleadingCharacterClass ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Regional indicator symbol characters should not be used in the character class.
  
  > 1 │ /^[🇯🇵]$/u;
      │ ^^^^^^^^^
    2 │ 
  
/^[👨👩👦]$/u;code-block.js:1:1 lint/suspicious/noMisleadingCharacterClass ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Unexpected joined character sequence in character class.
  
  > 1 │ /^[👨👩👦]$/u;
      │ ^^^^^^^^^^^^^
    2 │ 
  
/^[👍]$/; // surrogate pair without u flagcode-block.js:1:1 lint/suspicious/noMisleadingCharacterClass  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Unexpected surrogate pair in character class. Use the 'u' flag.
  
  > 1 │ /^[👍]$/; // surrogate pair without u flag
      │ ^^^^^^^^
    2 │ 
  
  ℹ Safe fix: Add unicode u flag to regex
  
    1 │ /^[👍]$/u;·//·surrogate·pair·without·u·flag
      │         +                                  
Valid
Section titled Valid/^[abc]$/;/^[👍]$/u;/^[\q{👶🏻}]$/v;