You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/rules/no-extra-boolean-cast.md
+41-16Lines changed: 41 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,6 @@ title: no-extra-boolean-cast
3
3
rule_type: suggestion
4
4
---
5
5
6
-
7
-
8
-
9
-
10
6
In contexts such as an `if` statement's test where the result of the expression will already be coerced to a Boolean, casting to a Boolean via double negation (`!!`) or a `Boolean` call is unnecessary. For example, these `if` statements are equivalent:
11
7
12
8
```js
@@ -88,16 +84,18 @@ var foo = bar ? !!baz : !!bat;
88
84
89
85
This rule has an object option:
90
86
91
-
*`"enforceForLogicalOperands"` when set to `true`, in addition to checking default contexts, checks whether the extra boolean cast is contained within a logical expression. Default is `false`, meaning that this rule by default does not warn about extra booleans cast inside logical expression.
87
+
*`"enforceForInnerExpressions"` when set to `true`, in addition to checking default contexts, checks whether extra boolean casts are present in expressions whose result is used in a boolean context. See examples below. Default is `false`, meaning that this rule by default does not warn about extra booleans cast inside inner expressions.
88
+
89
+
**Deprecated:** The object property `enforceForLogicalOperands` is deprecated ([eslint#18222](https://github.com/eslint/eslint/pull/18222)). Please use `enforceForInnerExpressions` instead.
92
90
93
-
### enforceForLogicalOperands
91
+
### enforceForInnerExpressions
94
92
95
-
Examples of **incorrect** code for this rule with `"enforceForLogicalOperands"` option set to `true`:
93
+
Examples of **incorrect** code for this rule with `"enforceForInnerExpressions"` option set to `true`:
0 commit comments