In Props Default to "True" of official docs (https://facebook.github.io/react/docs/jsx-in-depth.html#props-default-to-true):
In general, we don't recommend using this because it can be confused with the ES6 object shorthand {foo} which is short for {foo: foo} rather than {foo: true}. This behavior is just there so that it matches the behavior of HTML.
I think explicitly using {true} to a boolean prop better:
// good
<Foo bar={true}>
// bad
<Foo bar>
Is there any lint rule to enforce that?
The airbnb guide requires that the ={true} be omitted; you can configure jsx-boolean-value however you like.
How can I check <Foo bar> to be consider an error with eslint rule react/jsx-boolean-value and forcing to use <Foo bar={true}>?
@xareelee if you read the link I provided, you can configure it with "always" or "never".
@ljharb thanks. I got confused with error/warn/off and always/never.
"react/jsx-boolean-value": [2, "always"],
Now it's OK.
Most helpful comment
@ljharb thanks. I got confused with
error/warn/offandalways/never.Now it's OK.