Skip to content

Bug: no-misleading-character-class suggests to add u flag when it's already there #17537

@fasttime

Description

@fasttime

Environment

Node version: v20.4.0
npm version: v9.7.2
Local ESLint version: v8.48.0 (Currently used)
Global ESLint version: Not found
Operating System: win32 10.0.19045

What parser are you using?

Default (Espree)

What did you do?

Configuration
{
    "parserOptions": {
        "ecmaVersion": "latest"
    }
}
/*eslint no-misleading-character-class: "error"*/

new RegExp("[\\ud83d\\u{dc4d}]", "u");

What did you expect to happen?

No suggestions.

What actually happened?

I'm getting this suggestion:

Add unicode 'u' flag to regex.

But the flag is already set.

Link to Minimal Reproducible Example

https://eslint.org/play/#eyJ0ZXh0IjoiLyplc2xpbnQgbm8tbWlzbGVhZGluZy1jaGFyYWN0ZXItY2xhc3M6IFwiZXJyb3JcIiovXG5cbm5ldyBSZWdFeHAoXCJbXFxcXHVkODNkXFxcXHV7ZGM0ZH1dXCIsIFwidVwiKTtcbiIsIm9wdGlvbnMiOnsiZW52Ijp7ImVzNiI6dHJ1ZX0sInJ1bGVzIjp7fSwicGFyc2VyT3B0aW9ucyI6eyJlY21hRmVhdHVyZXMiOnt9LCJlY21hVmVyc2lvbiI6ImxhdGVzdCIsInNvdXJjZVR5cGUiOiJzY3JpcHQifX19

Participation

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

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyrepro:yesIssues with a reproducible exampleruleRelates to ESLint's core rules

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions