Disallow magic numbers.
Magic numbers are numbers that occur multiple times in code without an explicit meaning. They should preferably be replaced by named constants.
// code-linter.json5
{
"rules": {
"@typescript-eslint/no-magic-numbers": "warn"
}
} const TAX = 0.25; const dutyFreePrice = 100; export const finalPrice = dutyFreePrice + dutyFreePrice * TAX;
export const finalPrice = 100 + 100 * 0.25; const data = ['foo', 'bar', 'baz']; export const dataLast = data[2];
plugin:@typescript-eslint/all
For details about how to configure Code Linter check rules, see Code Linter.