Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint no-magic-numbers rule can't ignore checking number elements in array

Tags:

eslint

I'm new to eslint. With "no-magic-numbers" rule turned on, declare an array with number literal can't be ignored.eg. let array = [1, 2, 3]; I looked up eslint's documentation and can't find a way to ignore this case.So I must turn off "no-magic-numbers" rule,am I right?Thx in advance.

like image 743
Null Nobody Avatar asked Dec 10 '25 03:12

Null Nobody


1 Answers

Turning of a complete rule to fix one error is not a good idea.

If its just one case you can deactivate this rule for just one line like:

// eslint-disable-next-line no-magic-numbers
let array = [1, 2, 3];

If you don't like the idea of that rule in general you off course can turn it off completely. Have a look at the documentation to get a better overview: https://eslint.org/docs/rules/no-magic-numbers

like image 138
Mattstir Avatar answered Dec 13 '25 02:12

Mattstir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!