Rule: no-magic-numbers

Disallows the use constant number values outside of variable assignments. When no list of allowed values is specified, -1, 0 and 1 are allowed by default.


Magic numbers should be avoided as they often lack documentation. Forcing them to be stored in variables gives them implicit documentation.


A list of allowed numbers.

Config examples
"no-magic-numbers": true
"no-magic-numbers": [true, 1, 2, 3]
  "type": "array",
  "items": {
    "type": "number"
  "minLength": 1