-
Notifications
You must be signed in to change notification settings - Fork 71
chore(packages) avoid data-lgid
and data-testid
attributes being duplicated in components
#3184
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
Draft
kraenhansen
wants to merge
14
commits into
main
Choose a base branch
from
kh/avoid-duplicate-ids
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cf5b29e
Add explicit type for "data-testid"
kraenhansen 8e474dc
Add tests for data-testid propagation
kraenhansen c940a03
Revert order of data-testid and ...rest in ModalView
kraenhansen 35ac7fb
Fix propagation of data-testid to buttons
kraenhansen 8a53158
Add note on what generated the rules index
kraenhansen 38d58ab
Create a rule avoid duplicate data-lgid and data-testid attributes
kraenhansen 1929a55
Add use of the eslint plugin
kraenhansen f75d2d9
Fix Checkbox
kraenhansen 8df2903
Fix FormField
kraenhansen ef1b794
Fix ProgressBar
kraenhansen 3ca8a2c
Fix Select
kraenhansen ede1dbf
Fix PasswordInput
kraenhansen 6cd973c
Add changeset
kraenhansen 148ee52
Enable Label and Description overrides
kraenhansen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
'@leafygreen-ui/confirmation-modal': patch | ||
'@leafygreen-ui/password-input': patch | ||
'@leafygreen-ui/progress-bar': patch | ||
'@leafygreen-ui/form-field': patch | ||
'@lg-tools/eslint-plugin': patch | ||
'@leafygreen-ui/checkbox': patch | ||
'@leafygreen-ui/select': patch | ||
'@leafygreen-ui/modal': patch | ||
'@leafygreen-ui/lib': patch | ||
'@lg-tools/lint': patch | ||
--- | ||
|
||
Avoid duplicated data-lgid and data-testid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
/** | ||
* DO NOT MODIFY THIS FILE | ||
* ANY CHANGES WILL BE REMOVED ON THE NEXT BUILD | ||
* USE THE "create-rule" SCRIPT TO ADD NEW RULES INSTEAD | ||
*/ | ||
import { noDuplicateIdsRule } from './no-duplicate-ids'; | ||
import { noIndirectImportsRule } from './no-indirect-imports'; | ||
import { noRenderHookFromRtlRule } from './no-render-hook-from-rtl'; | ||
|
||
export const rules = { | ||
'no-duplicate-ids': noDuplicateIdsRule, | ||
'no-indirect-imports': noIndirectImportsRule, | ||
'no-render-hook-from-rtl': noRenderHookFromRtlRule, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
One of the reasons we pass the root to label and description is because
<Label>
and<Description>
already generate their own specific lgids internally.leafygreen-ui/packages/typography/src/Label/Label.tsx
Lines 38 to 39 in 9b2d156
So if you pass
lgids.root
, the root islg-checkbox
and the id generated in<Label>
will belg-checkbox-label
.However, if we pass
lgIds.label
, that will passlg-checkbox-label
to<Label>
, which will generatelg-checkbox-label-label
.The first approach allows us to avoid duplication in the id string
Uh oh!
There was an error while loading. Please reload this page.
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.
Ahh I see. Wouldn't it make more sense (and in alignment with the style-guide / BEM-like) for the
Label
component to have its owngetLgIds
function? 🤔 I mean,Label
is not a "child element" of some "typography block".I've pushed a suggestion to work around this in the simplest possible way I could imagine.
leafygreen-ui/packages/typography/src/Description/Description.tsx
Lines 36 to 41 in 148ee52