Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't emit prefer-w when both i and u flags are set #811

Open
tats-u opened this issue Mar 4, 2025 · 0 comments
Open

Don't emit prefer-w when both i and u flags are set #811

tats-u opened this issue Mar 4, 2025 · 0 comments

Comments

@tats-u
Copy link

tats-u commented Mar 4, 2025

Information:

  • ESLint version: 9.21.0
  • eslint-plugin-regexp version: 2.7.0

See https://github.com/fabian-hiller/valibot/blob/main/library/package.json and https://github.com/fabian-hiller/valibot/blob/main/pnpm-lock.yaml

Description

When both i and u flags are set, \w matches U+017F & U+212A, too. This plugin must not emit prefer-w on just [0-9a-z_] under that condition.

eslint/eslint#19474 (comment)

const ex1 = /^[0-9A-Z_]+$/iu;
const ex2 = /^\w+$/iu;

const str = "\u017f\u212a";

// ESLint expected: true / actual: false
console.log(ex1.test(str) === ex2.test(str));

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class_escape#w

If the regex is Unicode-aware and the i flag is set, it also matches other Unicode characters that get canonicalized to one of the characters above through case folding.

↑This makes U+017F and U+212A matches \w in iu flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant