Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eslint-plugin): [no-unsafe-enum-comparison] exempt bit shift operators #7074

Expand Up @@ -63,7 +63,7 @@ export default util.createRule({
}

return {
'BinaryExpression[operator=/=|<|>/]'(
'BinaryExpression[operator=/^[<>!=]?={0,2}$/]'(
node: TSESTree.BinaryExpression,
): void {
const left = getTypeFromNode(node.left);
Expand Down
Expand Up @@ -292,6 +292,20 @@ ruleTester.run('strict-enums-comparison', rule, {
num === someFunction;
mixed === someFunction;
`,
`
enum Fruit {
Apple,
}

const bitShift = 1 << Fruit.Apple;
`,
`
enum Fruit {
Apple,
}

const bitShift = 1 >> Fruit.Apple;
`,
],
invalid: [
{
Expand Down