Skip to content

Commit 669b239

Browse files
Fixed minor mistake in message of no-misleading-unicode-character (#664)
* Fixed minor mistake in message of `no-misleading-unicode-character` * Create nine-pets-tan.md
1 parent 882beb3 commit 669b239

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.changeset/nine-pets-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-regexp": patch
3+
---
4+
5+
Fixed minor mistake in message of `no-misleading-unicode-character`

lib/rules/no-misleading-unicode-character.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ export default createRule("no-misleading-unicode-character", {
276276
messageId: "characterClass",
277277
data: {
278278
graphemes,
279-
unit: flags.unicode ? "code points" : "char codes",
279+
unit:
280+
flags.unicode || flags.unicodeSets
281+
? "code points"
282+
: "char codes",
280283
uFlag: uFlag ? " Use the `u` flag." : "",
281284
},
282285
...makeFix(

tests/lib/rules/no-misleading-unicode-character.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ tester.run("no-misleading-unicode-character", rule as any, {
292292
options: [{ fixable: true }],
293293
errors: [{ messageId: "characterClass" }],
294294
},
295+
{
296+
code: String.raw`/[👶🏻👨‍👩‍👦]/v`,
297+
output: String.raw`/[\q{👶🏻|👨‍👩‍👦}]/v`,
298+
options: [{ fixable: true }],
299+
errors: [
300+
"The character(s) '👶🏻', '👨‍👩‍👦' are all represented using multiple code points.",
301+
],
302+
},
295303
{
296304
code: String.raw`/[👶🏻&👨‍👩‍👦]/v`,
297305
output: String.raw`/[\q{👶🏻|👨‍👩‍👦}&]/v`,

0 commit comments

Comments
 (0)