From 163dcde963cf374961f81dfe0d5e1c41e6da7b10 Mon Sep 17 00:00:00 2001 From: Srijan Saurav <68371686+srijan-deepsource@users.noreply.github.com> Date: Mon, 30 May 2022 16:19:26 +0530 Subject: [PATCH] Revert "docs: remove confusing examples for no-mixed-operators (#15875)" This reverts commit abcc7699ed04a8021610e3473c6602cb85d0fcee. --- docs/src/rules/no-mixed-operators.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/src/rules/no-mixed-operators.md b/docs/src/rules/no-mixed-operators.md index 831bd3626ef..48f8849a70b 100644 --- a/docs/src/rules/no-mixed-operators.md +++ b/docs/src/rules/no-mixed-operators.md @@ -12,6 +12,8 @@ This rule warns when different operators are used consecutively without parenthe ```js var foo = a && b || c || d; /*BAD: Unexpected mix of '&&' and '||'.*/ +var foo = a && b ? c : d; /*BAD: Unexpected mix of '&&' and '?:'.*/ +var foo = (a && b) ? c : d; /*GOOD*/ var foo = (a && b) || c || d; /*GOOD*/ var foo = a && (b || c || d); /*GOOD*/ ``` @@ -30,6 +32,17 @@ will generate 1:18 Unexpected mix of '&&' and '||'. (no-mixed-operators) ``` +```js +var foo = a && b ? c : d; +``` + +will generate + +```shell +1:13 Unexpected mix of '&&' and '?:'. (no-mixed-operators) +1:18 Unexpected mix of '&&' and '?:'. (no-mixed-operators) +``` + ## Rule Details This rule checks `BinaryExpression`, `LogicalExpression` and `ConditionalExpression`.