-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add rubocop linter for Truncate
#2200
Conversation
🦋 Changeset detectedLatest commit: ddb0cac The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
This looks good overall, but I have one comment I'd like to discuss further.
return if hash_with_inline_value?(node.arguments.first) | ||
|
||
lambda do |corrector| | ||
corrector.replace(node.children.first, "Primer::Beta::Truncate") |
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.
This won't be a totally safe transform, as Primer::Truncate
used to return a <div>
(which is display: block
) where Primer::Beta::Truncate
returns a <span>
(which is display: inline
). This could cause styling issues. Some options:
- Try it and see if it works. There's 67 instances in gh/gh so not an overwhelming amount to check
- Rewrite to always include
tag: :div
in the arguments hash. Then we can look at writing a separate linter forPrimer::Beta::Truncate(tag: :div)
.
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.
That's a good point! I'll adjust to include the tag
.
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.
I've added tag: :div
by default, as long as there isn't one already present.
Primer::Truncate.new(tag: :span)
will turn into Primer::Beta::Truncate.new(tag: :span)
Whereas Primer::Truncate.new()
should turn into Primer::Beta::Truncate.new(tag: :div)
.
Not too sure if this is the right way to go about it, I'd love some eyes on the way I implemented this!
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.
Nice work!
What are you trying to accomplish?
Builds off the work done in #2182.
Introduces a linter for
Truncate
, while also autocorrecting some instances.Integration
N/A
List the issues that this change affects.
https://github.com/github/primer/issues/2342
Risk Assessment
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.