question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: no-misleading-character-class triggers on seemingly-OK code

See original GitHub issue

Environment

Node version: 16.9.1 npm version: 7.21.1 Local ESLint version: 7.32.0 Global ESLint version: (none) Operating System: Windows 10

What parser are you using?

Default (Espree)

What did you do?

Configuration

Just using eslint:recommended. This can be demoed on eslint.org

/[\u00B7\u0300-\u036F]/u.test("");

What did you expect to happen?

No error, if I am understanding https://eslint.org/docs/rules/no-misleading-character-class correctly. Those docs imply the error will trigger when I include in my source text a multi-code-point character, which I have not done; I’ve only used Unicode escapes.

What actually happened?

4:3   error  Unexpected combined character in character class  no-misleading-character-class

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

For context, I am trying to reproduce https://www.w3.org/TR/REC-xml/#NT-NameStartChar as a RegExp. The #xB7 | [#x0300-#x036F] part of the grammar is what maps to my [\u00B7\u0300-\u036F] character class.

It’s possible that this is a doc issue, as I’m actually doing something dangerous or unusual, and so the error should trigger? But if I am, it’s not clear at all from the docs what I’m doing that’s bad.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Sep 29, 2021

Marking as accepted because there is agreement on adding a new option for this.

1reaction
domeniccommented, Sep 19, 2021

Thanks for the research! Hmm.

It would be nice if there were a version of this rule that did what the documentation currently says, which is prevent actually-misleading cases where the result appears as a signal grapheme. That is, taking an example from the doc: I think /^[❇️]$/u is indeed misleading because it looks like one character. But /^[\u2747\uFE0F]$/u is, in my opinion, not misleading, because it’s pretty clear that there are two possible code points, of which only one will be matched. (This is despite the fact that the two regexps are equivalent semantically.)

In other words, it would be good to have a mode for this rule that exempts escape sequences.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-misleading-character-class - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
regexp/no-misleading-unicode-character
This rule reports misleading Unicode characters. Some Unicode characters like '❇️', '🏳️‍ ', and ' ‍ ‍ ' consist...
Read more >
Bug descriptions — spotbugs 4.7.3 documentation
Object.equals() because it does not check for null being passed as the argument. All equals() methods should return false if passed a null...
Read more >
Input System doesn't trigger anything anymore - Unity Forum
Today, I want to continue my code, but my character doesn't move anymore, Actions are not triggered (even if inputs are detected in ......
Read more >
pcre2pattern specification
If also causes upper/lower casing operations to use Unicode properties for characters with code points greater than 127, even when UTF is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found