pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/no-misleading-unicode-character |
disallow multi-code-point characters in character classes and quantifiers |
v1.2.0 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
🔧💡 This rule is automatically fixable by the --fix
CLI option and manually fixable by editor suggestions.
disallow multi-code-point characters in character classes and quantifiers
This rule reports misleading Unicode characters.
Some Unicode characters like '❇️', '🏳️🌈', and '👨👩👦' consist of multiple code points. This causes problems in character classes and around quantifiers. E.g.
> /^[❇️🏳️🌈]$/.test("🏳️🌈")
false
> /^👨👩👦{2,4}$/.test("👨👩👦👨👩👦")
false
This rule is inspired by the no-misleading-character-class rule.
/* eslint regexp/no-misleading-unicode-character: "error" */
/* ✓ GOOD */
var foo = /👍+/u;
var foo = /👨👩👦/;
/* ✗ BAD */
var foo = /👍+/;
var foo = /[❇️🏳️🌈👨👩👦]❤️/;
{
"regexp/no-unused-capturing-group": ["error", {
"fixable": true
}]
}
-
fixable: true | false
This option controls whether the rule is fixable. Defaults to
false
.This rule is not fixable by default. Misleading Unicode characters can typically be fixed automatically by assuming that users want to treat one displayed character as one regex character. However, this assumption is not useful in all languages, so this rule provides suggestions instead of fixes by default.
This rule was introduced in eslint-plugin-regexp v1.2.0