-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Javascript regular expression literal not recognized after comparison operator #1170
Comments
Which error code you'll get for that error (sniff name + error code)? |
I get two errors:
But the issue is not in the LogicalOperatorSpacing sniff, it's in the token processing. The above code generates these tokens:
If I remove the "true ===" part, I get this:
I actually ran into this bug because I ran PHPCBF on the file containing this code and it changed the regex to |
Wow, that's interesting. |
Thanks for the detailed report. I've fixed this now. |
Our coding style enforces strict comparisons with the literal preceding the variable/function to check. Here is part of a function that checks for numeric input:
if( true === /^\d*\.?\d*$/.test( input ) ) return true;
PHPCS does not recognize the regular expression literal when tokenizing the above code.
The text was updated successfully, but these errors were encountered: