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

fix: SyntaxError message for v flag with RegExpValidator#validatePattern #110

Merged
merged 3 commits into from Jul 24, 2023

Conversation

ota-meshi
Copy link
Member

@ota-meshi ota-meshi requested review from mdjermanovic and a team July 23, 2023 12:30
@ota-meshi ota-meshi requested a review from a team July 23, 2023 12:41
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as far as I can tell. Just left one question.

throw new RegExpSyntaxError(
source,
{ unicode, unicodeSets },
sourceEnd + 1 /* `/` */,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this example:

const validator = new RegExpValidator();

validator.validatePattern("abcd", 0, 2, { unicode: true, unicodeSets: true });

It throws error with an index that doesn't seem to point to the / in the whole source:

{
    "message": "Invalid regular expression: /abcd/uv: Invalid regular expression flags"
    "index": 3
}

Is that okay? (I guess 5 would be wrong as out-of-range for the parsed part of the pattern).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for checking this PR!

Hmm. I think it's probably a pre-existing bug.

For example, the following case also returns the wrong pattern.

validator.validatePattern("[A]", 0, 2, { unicode: true, unicodeSets: false });
{
    "message": "Invalid regular expression: /[A]/u: Unterminated character class",
    "index": 2,
}

I think it's a bug that doesn't occur via ESLint, so I think it can be addressed in another PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I posted an issue #112.

@ota-meshi
Copy link
Member Author

Thank you for the review!
I think the new problem will be fixed another time. So I'm merging this PR.

@ota-meshi ota-meshi merged commit 96989df into main Jul 24, 2023
14 checks passed
@ota-meshi ota-meshi deleted the fix-error-message branch July 24, 2023 14:00
@github-actions
Copy link

🎉 This PR is included in version 4.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants