Bug: no-unsafe-enum-comparison - False positives with bit shifts #7067
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Bug Report Please Confirm You Have Done The Following...
Repro Code
This gives the following error:
The error message says that we are doing a "comparison", but this is false. We are not doing a comparison at all, we are doing a bit shift.
Thus, I propose that the
<<
operator and the>>
operator are exempt from being examined by this rule, and I assume that this was just an oversight when the rule was originally implemented. (Well, I was actually the person to originally implement it, but I guess this behavior got lost in translation somewhere.)Playground
https://typescript-eslint.io/play/#ts=5.0.4&sourceType=module&code=KYOwrgtgBAYg9nKBvAsAKClAQgQwE4A06AvuugMZwgDOALlBAJ5YCWtAygBYsBm9AvFACMUADyjYCAHS486IA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tieQEMAZonpNYAW1pkOY4nyrIOTdFETRoHaJHBgAviB1A&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA
ESLint Config
I am using the recommend configs, i.e.:
The text was updated successfully, but these errors were encountered: