
Product
Redesigned Repositories Page: A Faster Way to Prioritize Security Risk
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
eslint-plugin-use-numeric-separator
Advanced tools
An ESLint plugin to enforce usage of the numeric separator for long numeric literals
use-numeric-separator
is an ESLint plugin to enforce usage of the numeric separator (that '_' that can go in the middle of numbers) for large numbers.
// Hard to read:
10000000
// Easy to read:
10_000_000
This plugin has support for decimal, hexadecimal, octal, and binary literals, and has separate configurable options for each base to specify the threshold at which to start applying the rule, and the number of digits per group.
With default options:
// Incorrect:
10000000
0xDEADBEEF
0b10101010
// Correct:
10_000_000
0xDE_AD_BE_EF
0b1010_1010
// Also correct:
1000 // short number
100.0000001 // decimals are not split
6.02214e+23 // scientific notation is ignored
Each base has its own rule with threshold
and groupSize
options, with defaults. threshold
is the number of digits above which the rule should apply, and groupSize
is the number of digits between each separator. Here is an example .eslintrc.json
with every rule on and set to the default values:
{
...
"rules": {
"use-numeric-separator/decimal": [
"error",
{
"threshold": 5,
"groupSize": 3
}
],
"use-numeric-separator/hexadecimal": [
"error",
{
"threshold": 7,
"groupSize": 2
}
],
"use-numeric-separator/binary": [
"error",
{
"threshold": 5,
"groupSize": 4
}
],
"use-numeric-separator/octal": [
"error",
{
"threshold": 5,
"groupSize": 3
}
]
}
}
FAQs
An ESLint plugin to enforce usage of the numeric separator for long numeric literals
The npm package eslint-plugin-use-numeric-separator receives a total of 7 weekly downloads. As such, eslint-plugin-use-numeric-separator popularity was classified as not popular.
We found that eslint-plugin-use-numeric-separator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Slopsquatting is a new supply chain threat where AI-assisted code generators recommend hallucinated packages that attackers register and weaponize.
Security News
Multiple deserialization flaws in PyTorch Lightning could allow remote code execution when loading untrusted model files, affecting versions up to 2.4.0.