Using a separator ('_') for every thousand digits is a way to improve readability.
This restriction may be one of the ways to improve your number readability.
Examples of 🔴 incorrect code for this rule:
const num = 11111111;
const num = 123456789;
Examples of 🟢 correct code for this rule:
const num = 11_111_111;
const num = 123_456_789;
...
"rules": {
"component/number-easy-read": [
<enabled>,
{ minLength: <minLength> }
]
}
...
enabled
: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.minLength
: set the length of the number to which eslint applies (default to4
).
When minLength
is 9
:
const num = 123456789;
When minLength
is 9
:
const num = 123_456_789;
When you don't care about readability when writing number type code.