Skip to content

Files

Latest commit

 

History

History
27 lines (20 loc) · 643 Bytes

no-misleading-unicode-character.md

File metadata and controls

27 lines (20 loc) · 643 Bytes

Pattern: Misleading Unicode character

Issue: -

Description

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

Examples

/* eslint regexp/no-misleading-unicode-character: "error" */
/* ✓ GOOD */
var foo = /👍+/u;
var foo = /👨👩👦/;

/* ✗ BAD */
var foo = /👍+/;
var foo = /[🏴👨👩👦]/;