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: false positive about ES2018 RegExp enhancements (fixes #9893) #10062

Merged
merged 8 commits into from Mar 16, 2018

Conversation

mysticatea
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[X] Bug fix (template)

Fixes #9893.

What changes did you make? (Give an overview)

This PR fixes false positives/negatives about ES2018 RegExp enhancements.

  • no-control-regex ... it didn't work if the platform doesn't support ES2018 natively. And I fixed some tests such as `var regex = ${/\\\x1f\\x1e/}` since \\x1e is not a control character. It's four characters \ x 1 e, but the rule had reported it as a control character \x1e.
  • no-empty-character-class ... it didn't work a RegExp literal has s flag.
  • no-invalid-regexp ... This rule had super confusion. Native ES2018 support had changed the rule's behavior because the rule had depended on native RegExp constructor. The rule had depended on context.parserOptions and espree, so it was confusing if it uses a custom parser. RegExp has many differences on syntax between with u flag and without u flag, but the rule didn't recognize it. I remove the access to context.parserOptions, so the rule validates RegExp with the latest syntax always. I think allowConstructorFlags option is no longer necessary. If the rule ignores flags which change syntax such as u flag, the rule cannot validate RegExp syntax properly.
  • no-unexpected-multiline ... it didn't work a RegExp literal has s flag.
  • no-useless-escape ... it had some false positives about Named Capturing Groups and Unicode Property Escapes.
  • no-irregular-whitespace ... it had node.value instanceof RegExp, but it doesn't work intentionally because node.value can be null if the platform doesn't support ES2018 natively.

Is there anything you'd like reviewers to focus on?

  • Are there other rules which are related to ES2018 RegExp enhancements?
  • Because those are the same character, I'm not sure why the no-control-regex rule reports \x0A but doesn't report \n. The original implementation looks to intend to report invisible characters. I wonder if I should remove the check of escape sequences from the no-control-regexp rule.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Mar 6, 2018
@aladdin-add aladdin-add added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Mar 6, 2018
This was referenced Mar 22, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 13, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RegExp enhancements in ES2018
4 participants