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] no-children-prop
: Add allowFunctions
option
#1903
[New] no-children-prop
: Add allowFunctions
option
#1903
Conversation
5a65b24
to
71513a1
Compare
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'd also like a way to forbid functions from being children at all - ie, maybe an option functions
that can be an enum: child
, prop
, forbid
, or allow
?
Sounds good 👍 |
My personal belief is that function children are an abomination that destroys the entire purpose for using jsx, and I never want them to exist in code I maintain. |
Ok, I'll have to do my research 😃 But immediately, |
Oh sure, I just want an enum value that's equivalent to "not specifying the option" |
Ok, I don't think I'm on the same page. Let me go over it once again. Current rule:
And then extending that, the enum would be the 4 possible combinations of either allowing or forbidding functions in a prop or in the child position. Not specifying the enum value retain the current behaviour of the rule, which would be equal to the |
ahh i see what you mean - ok, fair. then true/false is probably fine. altho i can also see people asking for a third option, which is requiring that functions be in the child position. |
But don't they already have it via the current rule. As soon as you do |
Right - but what if they want all non-function children in the prop position, and function children in the child position? Or, all non-function children in one position or the other, but function children disallowed? |
That sounds like a complicated schema, so maybe we start small to make sure those options are actually in demand? Also the rule being called |
ha, true. the main purpose is to force child position. |
Ok, let me know if any other changes are necessary. |
docs/rules/no-children-prop.md
Outdated
|
||
### `allowFunctions` | ||
|
||
When `true`, passing a function in the children prop is preferred. |
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.
let's say this instead: when true, and passing a function as children
, it must be in prop position and not child position.
6f0d6f5
to
a8702ce
Compare
Any update on this? I'd love to see this feature land, since libraries like |
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. Fans of FaCCs will be screaming in horror at the idea that this rule exists. :)
9fda347
to
e509b9c
Compare
no-children-prop
: Add allowFunctions
option
Codecov Report
@@ Coverage Diff @@
## master #1903 +/- ##
=======================================
Coverage 97.40% 97.40%
=======================================
Files 111 111
Lines 7428 7444 +16
Branches 2715 2723 +8
=======================================
+ Hits 7235 7251 +16
Misses 193 193
Continue to review full report at Codecov.
|
e509b9c
to
241c38b
Compare
Resolves #1803