no-magic-numbers enhanced
npm install eslint-plugin-turisapA set of customized ESLint and @typescript/eslint rules
You'll first need to install ESLint:
``sh`
npm i eslint --save-dev
Next, install eslint-plugin-turisap:
`sh`
npm install eslint-plugin-turisap --save-dev
Add turisap to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
`json`
{
"plugins": [
"turisap"
]
}
Then configure the rules you want to use under the rules section.
`json`
{
"rules": {
"turisap/no-magic-numbers": [
"error",
{
"allowRGBa": true,
"allowedCalls": ["setTimeout"]
}
]
}
}
turisap/no-magic-numbers: the same as original ESLint rule, but allows to use a few extra settings, namely
* rgb(a) arrays with numbers:
`js`
const rgbColor = [255, 255, 255];
const rgbaColor = [0, 0, 0, 0.5];
* numeric function params in specified functions. For example, it is pretty obvious what the following parameter means
`js`
const id = setTimeout(fn, 300);
By the same token, it does not report the space param on JSON.stringify
`js``
const body = JSON.stringify(user, null, 2)