JS.BASE.NO.MISLEADING.CHARACTER.CLASS

Disallow characters which are made with multiple code points in character class syntax

Unicode includes the characters which are made with multiple code points. 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 ❇️.

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.

A character with combining characters

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).

A character with Emoji modifiers

A pair of regional indicator symbols

Characters that ZWJ joins

A surrogate pair without Unicode flag

Rule Details

This rule reports the regular expressions which include multiple code point characters in character class syntax.

When Not To Use It

You can turn this rule off if you don't want to check RegExp character class syntax for multiple code point characters.

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/