-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[New] style-prop-object
: Add allow
option
#1819
[New] style-prop-object
: Add allow
option
#1819
Conversation
Fixes #1813 Co-Authored-By: Erwin <evosch@users.noreply.github.com> Co-Authored-By: hornta <4553604+hornta@users.noreply.github.com> Co-Authored-By: Anthon Fredriksson <anthonnorrby@gmail.com> fix trailing comma causing eslint error
I think that we should also make sure that |
@jseminck Oh yes of course. Thank you. I'll try to cover that aswell. |
@jseminck I've updated this PR with |
Cool. LGTM from my side, as I attempted to add this improvement myself, and my solution was very similar. 😄 I haven't been involved in this project for a while though so it will need a review from someone else as well. |
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.
Overall this seems good, thanks
lib/rules/style-prop-object.js
Outdated
const componentName = node.arguments[0].name; | ||
|
||
// allowed list contains the name | ||
if (allowed.indexOf(componentName) > -1) { |
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.
we should be able to make a Set
on line 38, so this doesn't need to be O(n)
lib/rules/style-prop-object.js
Outdated
// parent element is a JSXOpeningElement | ||
if (node.parent && node.parent.type === 'JSXOpeningElement') { | ||
// store parent element | ||
const jsxOpeningElement = node.parent; |
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 can be stored prior to the "if", so we don't have to extract it multiple times.
@hornta would you mind checking the "allow edits" checkbox on the right hand side of the PR? |
Done. I totally forgot this one! 😨 |
Sorry for the duplicate pull request, I'm a bit new to this. How should I get the changes in? Do a PR on hornta/eslint-plugin-react? |
@evosch yep! Then you can post the link here, and i can merge it in to the PR if needed. |
Just noticed https://github.com/hornta/eslint-plugin-react/pull/1 was filed. I'll pull that in soon. |
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.
Seems reasonable overall
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.
LGTM
Are there any blockers to be merged 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.
LGTM. Seems pretty weird for components to override default React behavior for the style
prop, but I guess if there's a good use case for it, we should support it.
Hey, @hornta I too would love this to be merged. Any plans moving forward with this? |
allow
option in style-prop-objectstyle-prop-object
: Add allow
option
Fixes #1813