//In here i am multiplying 1.5 with diameter and my sonarlint plugin is showing above mentioned //error
JavaScript
x
8
1
& + span {
2
position: relative;
3
display: inline-block;
4
user-select: none;
5
transition: 0.4s ease;
6
height: ${({ diameter }) => diameter}px;
7
width: ${({ diameter }) => Math.round(1.5 * diameter)}px;
8
Advertisement
Answer
I am going to ask the same question your linter has. What is 1.5 used for ? No magic Numbers
in other words is don’t hard code numbers, if it is a constant then create it
JavaScript
1
2
1
const circ = 3.1416 * (RADIUS*RADIUS);
2
3.1416 is a magic number, to fix that you need to add its constant
JavaScript
1
4
1
const PI = 3.1416;
2
3
const circ = PI * (RADIUS*RADIUS);
4