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

Applying fix for regexp/optimal-quantifier-concatenation break the regex logic #736

Open
Eugeno opened this issue Apr 23, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Eugeno
Copy link
Contributor

Eugeno commented Apr 23, 2024

Information:

  • ESLint version: 8.57.0
  • eslint-plugin-regexp version: 2.5.0

Description
Current regex is /^(?!.*(?=.*-)(?=.*,)).*$/ (disallow usage of both comma and dash).

/^(?!.*(?=.*-)(?=.*,)).*$/.test('1,2-3'); // false ✓

I got 3 errors here, one of them: '.*' can be removed because it is already included by '.*'.(regexp/optimal-quantifier-concatenation).
After applying the fix:

/^(?!.*(?=-)(?=.*,)).*$/.test('1,2-3'); // true ✗

Further autofixes give the same false positive result:

/^(?!.*(?=-).+,).*$/.test('1,2-3'); // true ✗
@RunDevelopment RunDevelopment added the bug Something isn't working label Apr 23, 2024
@RunDevelopment
Copy link
Collaborator

Very good fine. Thanks for reporting.

The transformation:

/^(?!.*(?=.*-)(?=.*,)).*$/;
// to
/^(?!.*(?=-)(?=.*,)).*$/;

Is indeed incorrect. I think I messed one of its conditions, so this shouldn't be too hard to fix.

@RunDevelopment RunDevelopment self-assigned this Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants