Skip to content

Is there an eslint rule warning about operator precedence when || ?? chaining is mixed with ternary operator? #18201

Answered by mdjermanovic
teetotum asked this question in Q&A
Discussion options

You must be logged in to vote

I had at least two bugs in the last two days that were caused by a wrong assumption about operator precedence with regard to || / ?? chaining combined with ternery operator.

Is there already a rule I can activate to warn me if I use anything like this in my code base without using parentheses?

I think this is covered by the @stylistic/js/no-mixed-operators rule:

https://eslint.style/rules/js/no-mixed-operators

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@teetotum
Comment options

Answer selected by teetotum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants