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

Parsing unicode regexes can cause strange behavior in Node 4 #8020

Closed
not-an-aardvark opened this issue Feb 3, 2017 · 0 comments · Fixed by renovatebot/renovate#111 · May be fixed by iamhunter/teammates#4
Closed

Parsing unicode regexes can cause strange behavior in Node 4 #8020

not-an-aardvark opened this issue Feb 3, 2017 · 0 comments · Fixed by renovatebot/renovate#111 · May be fixed by iamhunter/teammates#4
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

Comments

@not-an-aardvark
Copy link
Member

Tell us about your environment

  • ESLint Version: master
  • Node Version: 4.7.3
  • npm Version: 2.15.11

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

parserOptions:
  ecmaVersion: 6
rules:
  eqeqeq: [error, always, {'null': never}]

What did you do? Please include the actual source code causing the issue.

foo === /abc/u;

What did you expect to happen?

No errors

What actually happened? Please include the actual, raw output from ESLint.

1:5  error  Expected '==' and instead saw '==='  eqeqeq

This is happening because the node.value property of the regex literal node is null in Node 4, because unicode regular expressions don't exist in that version. As a result, the rule assumes that the node is a null literal.

The rule can be updated to check the regex property of the literal to make sure it's not a regular expression. However, I wonder if there is a better way to represent this at the parser level -- it seems unintuitive that node.type === 'Literal' && node.value === null should match against anything other than a null literal.

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules labels Feb 3, 2017
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 Feb 6, 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
1 participant