Force one grapheme in the disjunction of string literals
ota-meshi opened this issue ยท comments
Motivation
It may be useful to be able to force the disjunction of string literals to use only strings that humans recognize as single characters.
Description
It is possible to use strings of two or more characters in the disjunction of string literals, but normal disjunction is also possible. (However, there are differences in the evaluation order.)
Forcing a single character to be used in the disjunction of string literals allows people to distinguish between uses.
I think it is better to implement the rule by using Intl.Segmenter
and allowing it if it is recognized as one grapheme.
Examples
/* โ GOOD */
var foo = /[\p{RGI_Emoji}--\q{๐ฆ๐จ|๐ฆ๐ฉ|๐ฆ๐ช|๐ฆ๐ซ|๐ฆ๐ฌ|๐ฆ๐ฎ|๐ฆ๐ฑ|๐ฆ๐ฒ|๐ฆ๐ด|๐ฆ๐ถ|๐ฆ๐ท|๐ฆ๐ธ|๐ฆ๐น|๐ฆ๐บ|๐ฆ๐ผ|๐ฆ๐ฝ|๐ฆ๐ฟ|๐ง๐ฆ|๐ง๐ง|๐ง๐ฉ|๐ง๐ช|๐ง๐ซ|๐ง๐ฌ|๐ง๐ญ|๐ง๐ฎ|๐ง๐ฏ}]/v
/* โ BAD */
var foo = /[\q{abc|def}]/v