-
Notifications
You must be signed in to change notification settings - Fork 1
Customisation
Conan edited this page May 5, 2022
·
3 revisions
$ pnpm i eslint-plugin-big-number-rules --save-dev
Want to use something other than bignumber.js
? Or use its shorter method-names such as pow
and div
instead of exponentiatedBy
and dividedBy
?
Here's a config that works with big.js:
// .eslintrc
{
"plugins": ["big-number-rules"],
"settings": {
"big-number-rules": {
"construct": "Big",
"importDeclaration": "__IGNORE__",
"importSpecifier": "__IGNORE__",
"supportsSum": false,
"supportsBitwise": false,
"supportsRound": true,
"arithmetic": {
"+": "plus",
"-": "minus",
"/": "div",
"*": "times",
"**": "pow",
"%": "mod"
},
"assignment": {
"+=": "plus",
"-=": "minus",
"/=": "div",
"*=": "times",
"**=": "pow",
"%=": "mod"
},
"comparison": {
"<": "lt",
"<=": "lte",
"===": "eq",
"==": "eq",
"!==": ["__NEGATION__", "${L}", "eq", "${R}"],
"!=": ["__NEGATION__", "${L}", "eq", "${R}"],
">=": "gte",
">": "gt"
},
"math": {
"min": "min",
"max": "max",
"random": "NOT_SUPPORTED",
"abs": "abs",
"sign": ["__CONSTRUCT__(${A}).cmp(0)"],
"sqrt": "sqrt"
},
"rounding": {
"round": ["round", "${A}, 1"],
"ceil": ["round", "${A}, 3"],
"floor": ["round", "${A}, 0"]
},
"number": {
"parseFloat": ["__CONSTRUCT__(${A})"],
"toExponential": "toExponential",
"toFixed": "dp",
"toPrecision": "toPrecision",
"toString": "toString"
}
}
}
}
Find more examples in the /eslintrc-for-other-libs folder.
Please report an issue if your particular lib does something differently!
There can't be that many edge-cases, right? ;-)