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

float support missing for Javascript: (scientific notation of small numbers) #3664

Closed
auge opened this issue Sep 12, 2022 · 2 comments
Closed

Comments

@auge
Copy link

auge commented Sep 12, 2022

Describe the bug
phpcs fails to properly detect small numbers formatted in scientific notation (i.e. '1E-6')

from what I can see in src/Tokenizers/PHP.php, there is float support present, so PHP is not affected.
however the JS Tokenizer (around L846) for numbers seems to lack this support (and therefore also emits errors)

Code sample

var num = 1e-6;

Custom ruleset
none

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.js with the code sample above...
  2. Run command from below ...
  3. See error message displayed
$ phpcs -s --standard=PSR12 test.js

FILE: test.js
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] Expected at least 1 space before "-"; 0 found
   |       |     (PSR12.Operators.OperatorSpacing.NoSpaceBefore)
 1 | ERROR | [x] Expected at least 1 space after "-"; 0 found
   |       |     (PSR12.Operators.OperatorSpacing.NoSpaceAfter)
---------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Expected behavior
no errors reported

Versions (please complete the following information):

  • OS: Windows 10
  • PHP: 7.2.32
  • PHPCS: 3.7.1
  • Standard: PSR12

Additional context
none

@gsherwood
Copy link
Member

I decided to remove support for JS and CSS a while ago, but full support can't be removed until version 4 is released: #2448

In the meantime, I wont be making any additional changes to JS or CSS tokenizing or sniffs. Please use a tool that supports modern versions of these languages.

@auge
Copy link
Author

auge commented Sep 13, 2022

thanks for clarification.
KR

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

No branches or pull requests

2 participants