eslint-plugin-reanimated icon indicating copy to clipboard operation
eslint-plugin-reanimated copied to clipboard

Rule idea: flag template literal interpolation of shared value

Open helixbass opened this issue 3 years ago • 2 comments

I just ran into this not being a type error:

useAnimatedStyle(() => ({
  width: `${someSharedValue}%`
}))

But clearly I meant someSharedValue.value

So seems like a type-aware ESLint rule could catch this?

helixbass avatar Mar 11 '21 23:03 helixbass

yes, I have a very similar issue where I do: foo ? 1 : 0 where I meant foo.value ? 1 : 0. It would be nice indeed to flag these

wcandillon avatar Mar 12 '21 04:03 wcandillon

Ah makes sense. So I guess anywhere where it's implicitly treated as a string or boolean? I can also think of:

if (foo) ...

foo && ...

foo || ...

helixbass avatar Mar 12 '21 14:03 helixbass