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
Const enum recommendation Eslint plugin #2246
base: main
Are you sure you want to change the base?
Conversation
I personally don't see anything wrong with adding this in. I definitely agree with the sentiment that people will probably just follow the guidance given rather than thinking about it. I think something that could be helpful is if we also were able to show package size increases in the warning. Just out of curiosity, is there any scenarios that going forward we wouldn't want our enums to be given the |
Generally speaking, enums should be |
I think this should be something we enable in the repo because the default behavior for enums is going to cause the package to grow unnecessarily. Most engineers who add enums will not realize this (myself included). Enabling a rule that causes every engineer who adds an enum to learn about the impact and then make an intentional decision about whether or not it can be Once this rule is enabled, I assume the way that an engineer would "make the decision" is to either add |
"name": "eslint-plugin-recommend-const-enums", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"author": "Noah", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/teams-js/eslint-rules/eslint-plugin-recommend-const-enums/recommendConstEnums.js
Outdated
Show resolved
Hide resolved
packages/teams-js/eslint-rules/eslint-plugin-recommend-const-enums/recommendConstEnums.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more information about how to contribute to this repo, visit this page.
Description
Main changes in the PR:
const
. The plugin will give a warning, but since the repo is configured to treat warnings as errors, they will need to add an eslint ignore line to the line just before their enum if it should not beconst
. The warning text when eslint detects a non-const enum isPlease consider if you can use a const enum for ${enumName} to minimize bundle size. If not, add "/* eslint-disable-next-line recommend-const-enums/recommend-const-enums */" to the line above to disable this warning.
How do people feel about adding this plugin to the repo? I wrote it with the intention of it just being a reminder to people so they stop and think about what they're writing with a little bit more intentionality. On the other hand, I could definitely see it as an unnecessary pain, that could definitely lead to people just blindly following the recommendation without actually thinking about it. So I figured I'd just put this PR out here and see what people thought about it, so some opinions on the matter would be greatly appreciated.
Validation
Validation performed:
Unit Tests added:
<Yes/No>
End-to-end tests added:
<Yes/No>
Additional Requirements
Change file added:
<Yes/No>
Related PRs:
Next/remaining steps:
Screenshots: