-
-
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
jsx-boolean-value: change default to 'always' #1505
Comments
React's docs can recommend whatever they like; omitting jsx has a number of things that break the idea that "consistency with JS" is critical, and this is one of the ways I think the deviation is an improvement. jsx is html, conceptually, even if it's implemented as syntactic sugar - so consistency with HTML is more important. |
@ljharb While I think this is a trivial issue, I don't completely agree with your submission.
thinking messages prop will have the array as value (ES6 object shorthand). While it is arguable that these people have not taken time to go through the react docs, I think it's rather becoming a pitfall and unnecessarily so. I'm not saying the rule should be removed, rather I feel the default can be changed to Talking about best practice, I believe best practices are often backed up with reasons that border on readability and efficiency. If it's about what people like, then styleguides don't stand a chance to begin with.
In another vein, I disagree with this, facebook/react#2781 |
Of course jsx is closer to HTML than JS; otherwise why bother with the sugar? |
I get your point, if we are looking at it superficially from the aspect of how it reads, then I somewhat agree with you but then we have stuffs like dot notation for JSX types and spread attributes. Even the JSX specification draft says
See these issues; |
Then at that time, this can be re-evaluated. In the meantime, I’d say you can just set the rule to “always” if you prefer. |
According to the documentation, the first argument to this rule is either 'always' or 'never'
Current behavior: The default value of the first argument is 'never' so it throws a warning if an attribute has a
true
valueProposed behavior: The default value should be changed to
always
so it warns whenever an attribute is missing its value.Why: Prop defaulting to
true
when it has no value is a feature that was added just for consistency with the HTML syntax. According to the react docs; In general, we don’t recommend using this because it can be confused with the ES6 object shorthand.Fundamentally React's JSX is just syntactic sugar. It's still primarily Javascript, so consistency with the language is important which is why the community has done well to put forward these recommendations. In this wise, I think using
never
should be a conscious decision not something that comes out of the boxThe text was updated successfully, but these errors were encountered: