Disallow bitwise operators
The use of bitwise operators in JavaScript is very rare and often &
or |
is simply a mistyped &&
or ||
, which will lead to unexpected behavior.
This rule disallows bitwise operators.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
This rule has an object option:
"allow"
: Allows a list of bitwise operators to be used as exceptions."int32Hint"
: Allows the use of bitwise OR in |0
pattern for type casting.Examples of correct code for this rule with the { "allow": ["~"] }
option:
Examples of correct code for this rule with the { "int32Hint": true }
option:
This rule was introduced in ESLint v0.0.2.
© OpenJS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/latest/rules/no-bitwise