Skip to content

fix(enums-eslint): Enum Rule for ESLint #14650

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Patrick-Pimentel-Bitwarden
Copy link
Contributor

@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden commented May 6, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-20454

📔 Objective

Added enums in the warnings for eslint via using a new eslint plugin. Set to warning right now and can be bumped later to error.

📸 Screenshots

Screenshot 2025-05-07 at 5 54 29 PM

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.34%. Comparing base (624dafa) to head (af84567).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14650   +/-   ##
=======================================
  Coverage   36.34%   36.34%           
=======================================
  Files        3190     3190           
  Lines       92150    92150           
  Branches    16524    16524           
=======================================
  Hits        33491    33491           
  Misses      56268    56268           
  Partials     2391     2391           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

github-actions bot commented May 6, 2025

Logo
Checkmarx One – Scan Summary & Details2be133be-15b8-45b8-9805-60a3c8b4181c

Great job, no security vulnerabilities found in this Pull Request

@Hinton
Copy link
Member

Hinton commented May 6, 2025

Do we have clear plans on resolving this in the near future? If not I'd be more open to changing this to error and add ignore statements to all the existing.

Warnings tends to be ignored even with all the noise they produce, just look at the server project.

@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden marked this pull request as draft May 7, 2025 20:59
@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden marked this pull request as ready for review May 7, 2025 21:51
@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden requested a review from a team as a code owner May 7, 2025 21:51
Copy link
Contributor

@coroiu coroiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same concern as @Hinton: if all teams don't immediately start fixing these warnings we should add ignore ignore statements to all the existing code. Otherwise any new warning about usage of enum will completely drown in all of the other existing warnings

@Patrick-Pimentel-Bitwarden
Copy link
Contributor Author

@Hinton @coroiu see decision by @withinfocus here. If both of you feel strongly about the proposed approach regarding erroring all of them and adding an ignore to the existing ones then let's have that conversation here in this pr.

@Hinton
Copy link
Member

Hinton commented May 9, 2025

Yes I feel strongly about it since ignoring existing occurrences is the established standard. We have a long track history of ignoring warnings either explicitly or implicitly.

  1. If we want to prevent new enums from being created the linting must be an error i.e. blocking. If we have 180 warnings we won't notice if it suddenly becomes 181.
  2. Warnings are noisy, printing 180 warnings every time you run lint is not useful.
  3. Warnings will not speed up a migration. Teams will already be aware enums should be migrated but it's not a trivial migration they won't be migrated until the team decides to prioritize the jira ticket.

@coroiu
Copy link
Contributor

coroiu commented May 9, 2025

I agree that we've gone the ignore route for a while now and I think it has proven itself to work. It immediately changes how we write code so that we don't continue writing using deprecated syntax and it allows reviewers to instantly identify when someone might try to "sneak something in. An eslint-disable comment is very easy to spot and it allows anyone to question the addition even if they are unfamiliar with why it was needed in the first place.

If we make the rule a "warning" then we'll be waiting a long time for every single team to fix their existing instances (and maybe some new ones) and someone will have to actively follow up on it so we don't forget to flip the switch to error. We'll also be spamming the console but that's probably the smallest issue.

Here are some of the previous PRs where we've followed this convention (admittedly most are by you @Hinton so it probably shouldn't come as a surprise to anyone that you favor this approach 😄):

…hanged usages of firefox to private and moved the usages to the preferred public method and removed the deprecations.
@Patrick-Pimentel-Bitwarden
Copy link
Contributor Author

Oh cool! Thank you for filling me in on some of the traditional approaches we've taken and why. I'll update to conform and leave a note in the other thread for Matt to visit this conversation just in case he wants to know what's going on 👍

@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden requested review from a team as code owners May 9, 2025 18:37
@Patrick-Pimentel-Bitwarden Patrick-Pimentel-Bitwarden marked this pull request as ready for review May 9, 2025 18:48
Copy link

sonarqubecloud bot commented May 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants