src/content/docs/linter/rules/no-bitwise-operators.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v2.0.0` - Diagnostic Category: [`lint/suspicious/noBitwiseOperators`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`no-bitwise`](https://eslint.org/docs/latest/rules/no-bitwise){
"linter": {
"rules": {
"suspicious": {
"noBitwiseOperators": "error"
}
}
}
}
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.
let x = y | z;
x |= y;
let x = y || z;
let x = y && z;
The rule provides the options described below.
Allows a list of bitwise operators to be used as exceptions.
{
"linter": {
"rules": {
"suspicious": {
"noBitwiseOperators": {
"options": {
"allow": [
"&",
"|",
"^",
"~",
"<<",
">>",
">>>"
]
}
}
}
}
}
}