In my code I have a series of ternary operators using the addition/subtraction assignment operator to modify the value for a variable corresponding to the pixel position of an element in an SVG.
A few examples of the expressions:
target === 'L' ? (endX -= edgeShift) : (endX += edgeShift);
source === 'L' ? (startX += halfSize) : (startX -= halfSize);
target === 'T' ? (endY -= edgeShift) : (endY += (edgeShift + 12));
My linter is throwing the error @typescript-eslint/no-unused-expressions
. From how I am interpreting the documentation for the rule it seems that each side of the ternary operator modifies the state of the program so I’d think it wouldn’t fail.
I am unable to see what "allowTernary"
is set too and the examples make it unclear of the expected behavior when its false.
Since I’d assume this is an issue on my end, 1) What is causing this? 2) Is there a way I can do this in one line without modifying the configuration? I’d prefer to not have to use two lines with an if/else since it hurts readability.