You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, unicorn/numeric-separators-style reports an error for this code:
// hot code path, precalculate 4 (sqrt(2) - 1) / 3constkappa=0.55228474983;// ^^^^^^^^^^^^^// Invalid group length in numeric value.eslint// [unicorn/numeric-separators-style](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v49.0.0/docs/rules/numeric-separators-style.md)
Current behavior
With the default config, this is how the rule expects the number to be formatted
In my personal opinion, the decimal point is "lost" amongst the underscores
constkappa=0.552_284_749_83;// not very readable
I could set a groupLength of 5...
constkappa=0.55228_47498_3;// Wikipedia style - readable
...but this gets in the way of formatting large numbers
constone_million=10_00000;// uh-oh, very misleading
Improvement
This can be resolved by having a different groupLength before and after the decimal place. For example, Wikipedia formats their numbers like this:
149 597 870 700 metres is 1 astronomical unit
3.14159 26535 89793 23846 is π rounded to 20 decimal places
2.71828 18284 59045 23536 is e rounded to 20 decimal places.
I agree. I also see little value from forcing separators for the fractional part. I would go with fractionGroupLength and default it to Infinity (alternatively a separate option to not enforce this for the fraction part).
Is this piece of code run on Node or in the browser? I think some/most minifiers will attempt to resolve simple static calculations, simply to save bytes.
Currently,
unicorn/numeric-separators-style
reports an error for this code:Current behavior
With the default config, this is how the rule expects the number to be formatted
In my personal opinion, the decimal point is "lost" amongst the underscores
I could set a
groupLength
of 5......but this gets in the way of formatting large numbers
Improvement
This can be resolved by having a different
groupLength
before and after the decimal place. For example, Wikipedia formats their numbers like this:https://en.wikipedia.org/wiki/Decimal_separator#Data_versus_mask
Alternatively, it would be fine to disable checking of
numeric-separators-style
after the decimal pointThe text was updated successfully, but these errors were encountered: